AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(frontend): hide delete control on AutoGPT-managed credentials (#13085)
Zamil Majdyaa4d94a9c79e
diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsxindex 4b38b8ef87..d67add5234 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/__tests__/main.test.tsx@@ -184,6 +184,31 @@ describe("SettingsIntegrationsPage — delete", () => {expect(screen.queryByText("Personal")).toBeNull();});});++ test("managed credentials hide the trash button and select checkbox", async () => {+ server.use(+ getGetV1ListCredentialsMockHandler([+ makeCred({+ id: "a1",+ provider: "ayrshare",+ title: "Ayrshare (managed by AutoGPT)",+ is_managed: true,+ }),+ ]),+ );++ render(<SettingsIntegrationsPage />);++ expect(+ await screen.findByText("Ayrshare (managed by AutoGPT)"),+ ).toBeDefined();+ expect(+ screen.queryByRole("button", { name: /delete ayrshare/i }),+ ).toBeNull();+ expect(+ screen.queryByRole("checkbox", { name: /select ayrshare/i }),+ ).toBeNull();+ });});describe("SettingsIntegrationsPage — selection bar", () => {diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/components/CredentialRow/CredentialRow.tsx b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/components/CredentialRow/CredentialRow.tsxindex 26c487e119..f5df31d2f4 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/components/CredentialRow/CredentialRow.tsx+++ b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/components/CredentialRow/CredentialRow.tsx@@ -7,6 +7,13 @@ import {TrashIcon,} from "@phosphor-icons/react";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "@/components/atoms/Tooltip/BaseTooltip";+import {formatMaskedValue,typeBadgeLabel,@@ -34,24 +41,28 @@ export function CredentialRow({className="flex w-full items-center justify-between py-3 pl-3 pr-5 transition-colors data-[selected=true]:bg-zinc-100"><div className="flex items-center gap-3">- <button- type="button"- role="checkbox"- aria-checked={selected}- aria-label={`Select ${credential.title}`}- onClick={onToggleSelected}- className={`shrink-0 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-800 ${- selected- ? "text-zinc-800 hover:text-zinc-900"- : "text-zinc-500 hover:text-zinc-700"- }`}- >- {selected ? (- <CheckSquareIcon size={20} weight="fill" />- ) : (- <SquareIcon size={20} />- )}- </button>+ {credential.isManaged ? (+ <div className="size-5 shrink-0" aria-hidden="true" />+ ) : (+ <button+ type="button"+ role="checkbox"+ aria-checked={selected}+ aria-label={`Select ${credential.title}`}+ onClick={onToggleSelected}+ className={`shrink-0 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-800 ${+ selected+ ? "text-zinc-800 hover:text-zinc-900"+ : "text-zinc-500 hover:text-zinc-700"+ }`}+ >+ {selected ? (+ <CheckSquareIcon size={20} weight="fill" />+ ) : (+ <SquareIcon size={20} />+ )}+ </button>+ )}<div className="flex flex-col gap-1"><div className="flex items-center gap-3">@@ -70,20 +81,38 @@ export function CredentialRow({</div></div>- <button- type="button"- onClick={onDelete}- disabled={isDeleting}- aria-busy={isDeleting}- aria-label={`Delete ${credential.title}`}- className="inline-flex size-5 items-center justify-center text-[#1F1F20] transition-colors hover:text-red-500 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-purple-400 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:text-[#1F1F20]"- >- {isDeleting ? (- <SpinnerIcon size={20} className="animate-spin" />- ) : (- <TrashIcon size={20} />- )}- </button>+ {credential.isManaged ? (+ <TooltipProvider>+ <Tooltip>+ <TooltipTrigger asChild>+ <span+ tabIndex={0}+ className="text-[11px] font-medium uppercase tracking-[1.1px] text-[#505057] focus:outline-none focus-visible:ring-2 focus-visible:ring-zinc-800"+ >+ Managed+ </span>+ </TooltipTrigger>+ <TooltipContent side="top">+ Managed by AutoGPT — cannot be removed+ </TooltipContent>+ </Tooltip>+ </TooltipProvider>+ ) : (+ <button+ type="button"+ onClick={onDelete}+ disabled={isDeleting}+ aria-busy={isDeleting}+ aria-label={`Delete ${credential.title}`}+ className="inline-flex size-5 items-center justify-center text-[#1F1F20] transition-colors hover:text-red-500 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-purple-400 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:text-[#1F1F20]"+ >+ {isDeleting ? (+ <SpinnerIcon size={20} className="animate-spin" />+ ) : (+ <TrashIcon size={20} />+ )}+ </button>+ )}</div>);}diff --git a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/components/IntegrationsList/useIntegrationsList.ts b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/components/IntegrationsList/useIntegrationsList.tsindex 48dcde16d8..f42afa1a27 100644--- a/autogpt_platform/frontend/src/app/(platform)/settings/integrations/components/IntegrationsList/useIntegrationsList.ts+++ b/autogpt_platform/frontend/src/app/(platform)/settings/integrations/components/IntegrationsList/useIntegrationsList.ts@@ -34,7 +34,7 @@ export function useIntegrationsList() {const providers = filterProviders(allProviders, debouncedQuery);const allCredentialIds = allProviders.flatMap((p) =>- p.credentials.map((c) => c.id),+ p.credentials.filter((c) => !c.isManaged).map((c) => c.id),);const selection = useIntegrationsSelection(allCredentialIds);const {