Skip to content

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

feat: add new query keys for listing all access and secret approval requests by project

Victor Hugo dos Santos5f14a8987d2b
diff --git a/frontend/src/hooks/api/accessApproval/mutation.tsx b/frontend/src/hooks/api/accessApproval/mutation.tsx
index d8270d724c..a8e2ee2e97 100644
--- a/frontend/src/hooks/api/accessApproval/mutation.tsx
+++ b/frontend/src/hooks/api/accessApproval/mutation.tsx
@@ -136,6 +136,9 @@ export const useCreateAccessRequest = () => {
queryClient.invalidateQueries({
queryKey: accessApprovalKeys.getAccessApprovalRequestCount(projectSlug)
});
+ queryClient.invalidateQueries({
+ queryKey: accessApprovalKeys.getAccessApprovalRequestsAllForProject(projectSlug)
+ });
}
});
};
@@ -153,7 +156,7 @@ export const useUpdateAccessRequest = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
- queryKey: accessApprovalKeys.getAccessApprovalRequests(projectSlug)
+ queryKey: accessApprovalKeys.getAccessApprovalRequestsAllForProject(projectSlug)
});
}
});
@@ -177,7 +180,7 @@ export const useRevokeAccessRequest = () => {
},
onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
- queryKey: accessApprovalKeys.getAccessApprovalRequests(projectSlug)
+ queryKey: accessApprovalKeys.getAccessApprovalRequestsAllForProject(projectSlug)
});
queryClient.invalidateQueries({
queryKey: accessApprovalKeys.getAccessApprovalRequestCount(projectSlug)
@@ -210,14 +213,9 @@ export const useReviewAccessRequest = () => {
);
return data;
},
- onSuccess: (_, { projectSlug, envSlug, requestedBy, bypassReason }) => {
+ onSuccess: (_, { projectSlug }) => {
queryClient.invalidateQueries({
- queryKey: accessApprovalKeys.getAccessApprovalRequests(
- projectSlug,
- envSlug,
- requestedBy,
- bypassReason
- )
+ queryKey: accessApprovalKeys.getAccessApprovalRequestsAllForProject(projectSlug)
});
queryClient.invalidateQueries({
queryKey: accessApprovalKeys.getAccessApprovalRequestCount(projectSlug)
diff --git a/frontend/src/hooks/api/accessApproval/queries.tsx b/frontend/src/hooks/api/accessApproval/queries.tsx
index d9470634a4..d577994c8e 100644
--- a/frontend/src/hooks/api/accessApproval/queries.tsx
+++ b/frontend/src/hooks/api/accessApproval/queries.tsx
@@ -25,6 +25,8 @@ export const accessApprovalKeys = {
requestedBy?: string,
bypassReason?: string
) => ["access-approvals-requests", projectSlug, envSlug, requestedBy, bypassReason] as const,
+ getAccessApprovalRequestsAllForProject: (projectSlug: string) =>
+ ["access-approvals-requests", projectSlug] as const,
getAccessApprovalRequestCount: (projectSlug: string, policyId?: string) =>
[{ projectSlug }, "access-approval-request-count", ...(policyId ? [policyId] : [])] as const
};
diff --git a/frontend/src/hooks/api/secretApprovalRequest/mutation.tsx b/frontend/src/hooks/api/secretApprovalRequest/mutation.tsx
index 52f37848f1..fb90469f4b 100644
--- a/frontend/src/hooks/api/secretApprovalRequest/mutation.tsx
+++ b/frontend/src/hooks/api/secretApprovalRequest/mutation.tsx
@@ -22,7 +22,9 @@ export const useUpdateSecretApprovalReviewStatus = () => {
},
onSuccess: (_, { id, projectId }) => {
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.detail({ id }) });
- queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.list({ projectId }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}
});
@@ -40,6 +42,9 @@ export const useUpdateSecretApprovalRequestStatus = () => {
},
onSuccess: (_, { id, projectId }) => {
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.detail({ id }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}
});
@@ -57,7 +62,9 @@ export const usePerformSecretApprovalRequestMerge = () => {
},
onSuccess: (_, { id, projectId }) => {
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.detail({ id }) });
- queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.list({ projectId }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
}
});
diff --git a/frontend/src/hooks/api/secretApprovalRequest/queries.tsx b/frontend/src/hooks/api/secretApprovalRequest/queries.tsx
index 4c55f34215..c5514e7975 100644
--- a/frontend/src/hooks/api/secretApprovalRequest/queries.tsx
+++ b/frontend/src/hooks/api/secretApprovalRequest/queries.tsx
@@ -26,6 +26,8 @@ export const secretApprovalRequestKeys = {
{ projectId, environment, status, committer, offset, limit, search },
"secret-approval-requests"
] as const,
+ listAllForProject: ({ projectId }: { projectId: string }) =>
+ [{ projectId }, "secret-approval-requests"] as const,
detail: ({ id }: Omit<TGetSecretApprovalRequestDetails, "decryptKey">) =>
[{ id }, "secret-approval-request-detail"] as const,
count: ({ projectId, policyId }: TGetSecretApprovalRequestCount) => [
diff --git a/frontend/src/hooks/api/secrets/mutations.tsx b/frontend/src/hooks/api/secrets/mutations.tsx
index d4c0e88a4a..1a7f79d021 100644
--- a/frontend/src/hooks/api/secrets/mutations.tsx
+++ b/frontend/src/hooks/api/secrets/mutations.tsx
@@ -80,6 +80,9 @@ export const useCreateSecretV3 = ({
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
},
...options
});
@@ -151,6 +154,9 @@ export const useUpdateSecretV3 = ({
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
},
...options
});
@@ -202,6 +208,9 @@ export const useDeleteSecretV3 = ({
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
},
...options
});
@@ -250,6 +259,9 @@ export const useCreateSecretBatch = ({
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
},
...options
});
@@ -298,6 +310,9 @@ export const useUpdateSecretBatch = ({
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
},
...options
});
@@ -348,6 +363,9 @@ export const useDeleteSecretBatch = ({
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
},
...options
});
@@ -439,6 +457,9 @@ export const useMoveSecrets = ({
queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ projectId })
});
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
},
...options
});
@@ -560,6 +581,9 @@ export const useCreateCommit = () => {
queryKey: commitKeys.history({ projectId, environment, directory: secretPath })
});
queryClient.invalidateQueries({ queryKey: secretApprovalRequestKeys.count({ projectId }) });
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
}
});
};
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx
index c71e7417ff..c1c0339dc9 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/ActionBar.tsx
@@ -652,8 +652,10 @@ export const ActionBar = ({
queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ projectId })
});
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
- // Close the modal and show notification
handlePopUpClose("confirmUpload");
createNotification({
type: "success",
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
index c16bc52593..6475bcc54b 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/SecretListView/SecretListView.tsx
@@ -435,6 +435,9 @@ export const SecretListView = ({
queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ projectId })
});
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
if (!isReminderEvent) {
handlePopUpClose("secretDetail");
}
@@ -545,6 +548,9 @@ export const SecretListView = ({
queryClient.invalidateQueries({
queryKey: secretApprovalRequestKeys.count({ projectId })
});
+ queryClient.invalidateQueries({
+ queryKey: secretApprovalRequestKeys.listAllForProject({ projectId })
+ });
handlePopUpClose("deleteSecret");
handlePopUpClose("secretDetail");
createNotification({