mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-20 17:00:56 +00:00
Address PR comments
This commit is contained in:
-64
@@ -1,64 +0,0 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
import { OrgPermissionCan } from "@app/components/permissions";
|
||||
import { Checkbox } from "@app/components/v2";
|
||||
import { OrgPermissionActions, OrgPermissionSubjects, useOrganization } from "@app/context";
|
||||
import { useUpdateOrg } from "@app/hooks/api/organization/queries";
|
||||
|
||||
export const BlockDuplicateSecretSyncDestinationsSection = () => {
|
||||
const { currentOrg } = useOrganization();
|
||||
const { mutateAsync: updateOrg } = useUpdateOrg();
|
||||
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const handleToggle = async (state: boolean) => {
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
if (!currentOrg?.id) {
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
await updateOrg({
|
||||
orgId: currentOrg.id,
|
||||
blockDuplicateSecretSyncDestinations: state
|
||||
});
|
||||
|
||||
createNotification({
|
||||
text: `Successfully ${state ? "enabled" : "disabled"} blocking duplicate secret sync destinations for this organization`,
|
||||
type: "success"
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
createNotification({
|
||||
text: "Failed to update blocking duplicate secret sync destinations setting for this organization",
|
||||
type: "error"
|
||||
});
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
|
||||
<p className="mb-3 text-xl font-medium">Block Duplicate Secret Sync Destinations</p>
|
||||
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Settings}>
|
||||
{(isAllowed) => (
|
||||
<div className="w-max">
|
||||
<Checkbox
|
||||
id="blockDuplicateSecretSyncDestinations"
|
||||
isDisabled={!isAllowed || isLoading}
|
||||
isChecked={currentOrg?.blockDuplicateSecretSyncDestinations ?? false}
|
||||
onCheckedChange={(state) => handleToggle(state as boolean)}
|
||||
>
|
||||
This feature prevents creating secret syncs with destinations that are already in use
|
||||
by other syncs in your organization.
|
||||
</Checkbox>
|
||||
</div>
|
||||
)}
|
||||
</OrgPermissionCan>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
-1
@@ -1 +0,0 @@
|
||||
export { BlockDuplicateSecretSyncDestinationsSection } from "./BlockDuplicateSecretSyncDestinationsSection";
|
||||
+3
-3
@@ -49,11 +49,11 @@ export const OrgProductSettingsTab = () => {
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<h3 className="mb-2 text-lg font-medium text-mineshaft-100">
|
||||
Block Duplicate Secret Sync Destinations
|
||||
Unique Secret Sync Destination Policy
|
||||
</h3>
|
||||
<p className="text-sm text-mineshaft-400">
|
||||
When enabled, this setting prevents the creation of multiple sync configurations
|
||||
pointing to the same destination.
|
||||
When enabled, ensures each destination can only be used by one secret sync
|
||||
configuration, preventing potential conflicts or overwrites.
|
||||
</p>
|
||||
</div>
|
||||
<OrgPermissionCan I={OrgPermissionActions.Edit} a={OrgPermissionSubjects.Settings}>
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
export { BlockDuplicateSecretSyncDestinationsSection } from "./BlockDuplicateSecretSyncDestinationsSection";
|
||||
export { OrgProductSettingsTab } from "./OrgProductSettingsTab";
|
||||
export { OrgTabGroup } from "./OrgTabGroup";
|
||||
|
||||
Reference in New Issue
Block a user