Update BackfillSecretReferenceSection.tsx

This commit is contained in:
Daniel Hougaard
2024-09-20 23:07:52 +04:00
parent 0f70c3ea9a
commit 69311f058b
@@ -5,39 +5,40 @@ import { useBackfillSecretReference } from "@app/hooks/api";
import { ProjectMembershipRole } from "@app/hooks/api/roles/types"; import { ProjectMembershipRole } from "@app/hooks/api/roles/types";
export const BackfillSecretReferenceSecretion = () => { export const BackfillSecretReferenceSecretion = () => {
const { currentWorkspace } = useWorkspace(); const { currentWorkspace } = useWorkspace();
const { membership } = useProjectPermission(); const { membership } = useProjectPermission();
const backfillSecretReferences = useBackfillSecretReference(); const backfillSecretReferences = useBackfillSecretReference();
if (!currentWorkspace) return null; if (!currentWorkspace) return null;
const handleBackfill = async () => { const handleBackfill = async () => {
if (backfillSecretReferences.isLoading) return; if (backfillSecretReferences.isLoading) return;
try { try {
await backfillSecretReferences.mutateAsync({ projectId: currentWorkspace.id || "" }); await backfillSecretReferences.mutateAsync({ projectId: currentWorkspace.id || "" });
createNotification({ text: "Successfully re-indexed secret references", type: "success" }); createNotification({ text: "Successfully re-indexed secret references", type: "success" });
} catch { } catch {
createNotification({ text: "Failed to re-index secret references", type: "error" }); createNotification({ text: "Failed to re-index secret references", type: "error" });
} }
}; };
const isAdmin = membership.roles.includes(ProjectMembershipRole.Admin); const isAdmin = membership.roles.includes(ProjectMembershipRole.Admin);
return ( return (
<div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4"> <div className="mb-6 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">
<div className="flex w-full items-center justify-between"> <div className="flex w-full items-center justify-between">
<p className="text-xl font-semibold">Index Secret References</p> <p className="text-xl font-semibold">Index Secret References</p>
</div> </div>
<p className="mb-4 mt-2 max-w-2xl text-sm text-gray-400"> <p className="mb-4 mt-2 max-w-2xl text-sm text-gray-400">
This will index all secret references, enabling integrations to be triggered when their values change going forward. This will index all secret references, enabling integrations to be triggered when their
</p> values change going forward. This happens automatically when secrets are created or updated.
<Button </p>
variant="outline_bg" <Button
isLoading={backfillSecretReferences.isLoading} variant="outline_bg"
onClick={handleBackfill} isLoading={backfillSecretReferences.isLoading}
isDisabled={!isAdmin} onClick={handleBackfill}
> isDisabled={!isAdmin}
Index Secret References >
</Button> Index Secret References
</div> </Button>
); </div>
);
}; };