Skip to content

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

improvement: invalidate secret imports on secret mutation

Scott Wilson92b8888d0c78
diff --git a/frontend/src/hooks/api/secrets/mutations.tsx b/frontend/src/hooks/api/secrets/mutations.tsx
index 33f888c5a4..48b18a0676 100644
--- a/frontend/src/hooks/api/secrets/mutations.tsx
+++ b/frontend/src/hooks/api/secrets/mutations.tsx
@@ -56,6 +56,12 @@ export const useCreateSecretV3 = ({
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
+ queryClient.invalidateQueries({
+ predicate: (query) =>
+ (query.queryKey[0] as { projectId?: string })?.projectId === projectId &&
+ (query.queryKey[1] === "secrets-import-sec" ||
+ query.queryKey[1] === "imported-folders-all-envs")
+ });
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
@@ -121,6 +127,12 @@ export const useUpdateSecretV3 = ({
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
+ queryClient.invalidateQueries({
+ predicate: (query) =>
+ (query.queryKey[0] as { projectId?: string })?.projectId === projectId &&
+ (query.queryKey[1] === "secrets-import-sec" ||
+ query.queryKey[1] === "imported-folders-all-envs")
+ });
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
@@ -166,6 +178,12 @@ export const useDeleteSecretV3 = ({
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
+ queryClient.invalidateQueries({
+ predicate: (query) =>
+ (query.queryKey[0] as { projectId?: string })?.projectId === projectId &&
+ (query.queryKey[1] === "secrets-import-sec" ||
+ query.queryKey[1] === "imported-folders-all-envs")
+ });
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
@@ -208,6 +226,12 @@ export const useCreateSecretBatch = ({
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
+ queryClient.invalidateQueries({
+ predicate: (query) =>
+ (query.queryKey[0] as { projectId?: string })?.projectId === projectId &&
+ (query.queryKey[1] === "secrets-import-sec" ||
+ query.queryKey[1] === "imported-folders-all-envs")
+ });
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
@@ -250,6 +274,12 @@ export const useUpdateSecretBatch = ({
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
+ queryClient.invalidateQueries({
+ predicate: (query) =>
+ (query.queryKey[0] as { projectId?: string })?.projectId === projectId &&
+ (query.queryKey[1] === "secrets-import-sec" ||
+ query.queryKey[1] === "imported-folders-all-envs")
+ });
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
@@ -294,6 +324,12 @@ export const useDeleteSecretBatch = ({
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
+ queryClient.invalidateQueries({
+ predicate: (query) =>
+ (query.queryKey[0] as { projectId?: string })?.projectId === projectId &&
+ (query.queryKey[1] === "secrets-import-sec" ||
+ query.queryKey[1] === "imported-folders-all-envs")
+ });
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});
@@ -500,6 +536,12 @@ export const useCreateCommit = () => {
queryClient.invalidateQueries({
queryKey: dashboardKeys.getDashboardSecrets({ projectId, secretPath })
});
+ queryClient.invalidateQueries({
+ predicate: (query) =>
+ (query.queryKey[0] as { projectId?: string })?.projectId === projectId &&
+ (query.queryKey[1] === "secrets-import-sec" ||
+ query.queryKey[1] === "imported-folders-all-envs")
+ });
queryClient.invalidateQueries({
queryKey: secretKeys.getProjectSecret({ projectId, environment, secretPath })
});