Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

improvement: default secret path to root on mount and env change

Scott Wilson382aa39f0aa4
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
index 7001210b78..d3316a7aba 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/SelectionPanel/components/MoveSecretsDialog/MoveSecretsDialog.tsx
@@ -63,17 +63,15 @@ type OptionValue = { secretPath: string };
const FolderPathSelect = ({
environments,
projectId,
- sourceSecretPath,
value,
onChange
}: {
environments: ProjectEnv[];
projectId: string;
- sourceSecretPath: string;
value: OptionValue | null;
onChange: (newValue: OptionValue | null) => void;
}) => {
- const [search, setSearch] = useState(sourceSecretPath);
+ const [search, setSearch] = useState("/");
const [debouncedSearch] = useDebounce(search);
const [previousValue, setPreviousValue] = useState<OptionValue | null>(value);
@@ -198,7 +196,7 @@ const SingleEnvContent = ({
const sourceEnv = visibleEnvs[0];
const moveSecrets = useMoveSecrets();
const [selectedPath, setSelectedPath] = useState<OptionValue | null>({
- secretPath: sourceSecretPath
+ secretPath: "/"
});
const {
@@ -216,6 +214,10 @@ const SingleEnvContent = ({
const selectedEnvironment = watch("environment");
+ useEffect(() => {
+ setSelectedPath({ secretPath: "/" });
+ }, [selectedEnvironment]);
+
const destinationSelected =
Boolean(selectedPath?.secretPath) &&
(sourceSecretPath !== selectedPath?.secretPath || selectedEnvironment !== sourceEnv.slug);
@@ -322,13 +324,13 @@ const SingleEnvContent = ({
<FieldLabel>Secret Path</FieldLabel>
<FieldContent>
<FolderPathSelect
+ key={selectedEnvironment}
environments={
selectedEnvironment
? environments.filter((e) => e.slug === selectedEnvironment)
: environments
}
projectId={projectId}
- sourceSecretPath={sourceSecretPath}
value={selectedPath}
onChange={setSelectedPath}
/>
@@ -400,7 +402,7 @@ const MultiEnvContent = ({
const { permission } = useProjectPermission();
const [moveResults, setMoveResults] = useState<MoveResults | null>(null);
const [selectedPath, setSelectedPath] = useState<OptionValue | null>({
- secretPath: sourceSecretPath
+ secretPath: "/"
});
const {
@@ -585,7 +587,6 @@ const MultiEnvContent = ({
<FolderPathSelect
environments={environments}
projectId={projectId}
- sourceSecretPath={sourceSecretPath}
value={selectedPath}
onChange={setSelectedPath}
/>