mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-21 01:16:49 +00:00
refactor: streamline modal close handlers and completion callbacks across various components
This commit is contained in:
@@ -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) => {
|
||||
|
||||
+19
-33
@@ -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 =
|
||||
|
||||
+18
-25
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user