(function Pa
)}
>
{pairs.map((p, i) => {
+ if (!showAll && i > MAX_INITIAL_PAIRS) return null;
+
const isLast = i === pairs.length - 1;
return (
@@ -245,6 +246,17 @@ export const PairEditor = forwardRef(function Pa
);
})}
+ {!showAll && pairs.length > MAX_INITIAL_PAIRS && (
+
+ )}
);
});
@@ -607,12 +619,15 @@ function FileActionsDropdown({
);
}
-function ensureValidPair(initialPair?: Pair): Pair {
+function emptyPair(): Pair {
return {
- name: initialPair?.name ?? '',
- value: initialPair?.value ?? '',
- enabled: initialPair?.enabled ?? true,
- isFile: initialPair?.isFile ?? false,
- id: initialPair?.id || generateId(),
+ enabled: true,
+ name: '',
+ value: '',
+ id: generateId(),
};
}
+
+function isPairEmpty(pair: Pair): boolean {
+ return !pair.name && !pair.value;
+}
diff --git a/src-web/hooks/useActiveEnvironmentVariables.ts b/src-web/hooks/useActiveEnvironmentVariables.ts
index 84c27b3d..cf6d45ac 100644
--- a/src-web/hooks/useActiveEnvironmentVariables.ts
+++ b/src-web/hooks/useActiveEnvironmentVariables.ts
@@ -1,24 +1,26 @@
import type { EnvironmentVariable } from '@yaakapp-internal/models';
-import { useMemo } from 'react';
-import { useActiveEnvironment } from './useActiveEnvironment';
-import { useEnvironments } from './useEnvironments';
+import { atom, useAtomValue } from 'jotai';
+import { activeEnvironmentAtom } from './useActiveEnvironment';
+import { environmentsBreakdownAtom } from './useEnvironments';
+
+const activeEnvironmentVariablesAtom = atom((get) => {
+ const { baseEnvironment } = get(environmentsBreakdownAtom);
+ const activeEnvironment = get(activeEnvironmentAtom);
+
+ const varMap: Record