refactor: streamline modal close handlers and completion callbacks across various components

This commit is contained in:
Victor Santos
2025-10-31 18:43:34 -03:00
parent 7d8b28367e
commit b26fb73053
116 changed files with 1865 additions and 2949 deletions
@@ -95,42 +95,26 @@ const Page = () => {
const handleDeleteRotation = async () => {
const { id } = popUp.deleteRotation.data as { id: string };
try {
await deleteSecretRotation({
id,
workspaceId
});
handlePopUpClose("deleteRotation");
createNotification({
type: "success",
text: "Successfully removed rotation"
});
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to remove rotation"
});
}
await deleteSecretRotation({
id,
workspaceId
});
handlePopUpClose("deleteRotation");
createNotification({
type: "success",
text: "Successfully removed rotation"
});
};
const handleRestartRotation = async (id: string) => {
try {
await restartSecretRotation({
id,
workspaceId
});
createNotification({
type: "success",
text: "Secret rotation initiated"
});
} catch (error) {
console.log(error);
createNotification({
type: "error",
text: "Failed to restart rotation"
});
}
await restartSecretRotation({
id,
workspaceId
});
createNotification({
type: "success",
text: "Secret rotation initiated"
});
};
const handleCreateRotation = (provider: TSecretRotationProviderTemplate) => {
@@ -89,44 +89,30 @@ export const SecretSyncActionTriggers = ({ secretSync }: Props) => {
const handleToggleEnableSync = async () => {
const isAutoSyncEnabled = !secretSync.isAutoSyncEnabled;
try {
await updateSync.mutateAsync({
syncId: secretSync.id,
destination: secretSync.destination,
isAutoSyncEnabled,
projectId: secretSync.projectId
});
await updateSync.mutateAsync({
syncId: secretSync.id,
destination: secretSync.destination,
isAutoSyncEnabled,
projectId: secretSync.projectId
});
createNotification({
text: `Successfully ${isAutoSyncEnabled ? "enabled" : "disabled"} auto-sync for ${destinationName} Sync`,
type: "success"
});
} catch {
createNotification({
text: `Failed to ${isAutoSyncEnabled ? "enable" : "disable"} auto-sync for ${destinationName} Sync`,
type: "error"
});
}
createNotification({
text: `Successfully ${isAutoSyncEnabled ? "enabled" : "disabled"} auto-sync for ${destinationName} Sync`,
type: "success"
});
};
const handleTriggerSync = async () => {
try {
await triggerSyncSecrets.mutateAsync({
syncId: secretSync.id,
destination: secretSync.destination,
projectId: secretSync.projectId
});
await triggerSyncSecrets.mutateAsync({
syncId: secretSync.id,
destination: secretSync.destination,
projectId: secretSync.projectId
});
createNotification({
text: `Successfully triggered ${destinationName} Sync`,
type: "success"
});
} catch {
createNotification({
text: `Failed to trigger ${destinationName} Sync`,
type: "error"
});
}
createNotification({
text: `Successfully triggered ${destinationName} Sync`,
type: "success"
});
};
const permissionSubject =
@@ -76,32 +76,25 @@ export const SlackIntegrationForm = ({ onClose }: Props) => {
});
const handleIntegrationSave = async (data: TSlackConfigForm) => {
try {
if (!currentProject) {
return;
}
await updateProjectSlackConfig({
...data,
projectId: currentProject.id,
integration: WorkflowIntegrationPlatform.SLACK,
integrationId: data.slackIntegrationId,
accessRequestChannels: data.accessRequestChannels.filter(Boolean).join(", "),
secretRequestChannels: data.secretRequestChannels.filter(Boolean).join(", ")
});
createNotification({
type: "success",
text: "Successfully created slack integration"
});
onClose();
} catch {
createNotification({
type: "error",
text: "Failed to create slack integration"
});
if (!currentProject) {
return;
}
await updateProjectSlackConfig({
...data,
projectId: currentProject.id,
integration: WorkflowIntegrationPlatform.SLACK,
integrationId: data.slackIntegrationId,
accessRequestChannels: data.accessRequestChannels.filter(Boolean).join(", "),
secretRequestChannels: data.secretRequestChannels.filter(Boolean).join(", ")
});
createNotification({
type: "success",
text: "Successfully created slack integration"
});
onClose();
};
const secretRequestNotifState = watch("isSecretRequestNotificationEnabled");