From 1ee9b07a2ce6a29687ca7d87f92b398bb394a10c Mon Sep 17 00:00:00 2001 From: Reinier van der Leer Date: Fri, 11 Oct 2024 21:53:47 +0200 Subject: [PATCH] fix profile layout --- .../frontend/src/app/profile/page.tsx | 108 ++++++++++-------- .../integrations/credentials-input.tsx | 4 +- 2 files changed, 61 insertions(+), 51 deletions(-) diff --git a/autogpt_platform/frontend/src/app/profile/page.tsx b/autogpt_platform/frontend/src/app/profile/page.tsx index 54a9c985aa00..1284fd252849 100644 --- a/autogpt_platform/frontend/src/app/profile/page.tsx +++ b/autogpt_platform/frontend/src/app/profile/page.tsx @@ -10,6 +10,16 @@ import { CredentialsProvidersContext } from "@/components/integrations/credentia import { Separator } from "@/components/ui/separator"; import AutoGPTServerAPI from "@/lib/autogpt-server-api"; import { useToast } from "@/components/ui/use-toast"; +import { IconKey, IconUser } from "@/components/ui/icons"; +import { providerIcons } from "@/components/integrations/credentials-input"; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; export default function PrivatePage() { const { user, isLoading, error } = useUser(); @@ -61,60 +71,62 @@ export default function PrivatePage() { return null; } + const allCredentials = Object.values(providers).flatMap((provider) => + [...provider.savedApiKeys, ...provider.savedOAuthCredentials].map( + (credentials) => ({ + ...credentials, + provider: provider.provider, + providerName: provider.providerName, + ProviderIcon: providerIcons[provider.provider], + TypeIcon: { "oauth2": IconUser, "api_key": IconKey }[credentials.type], + }), + ), + ); + return (

Hello {user.email}

-
- {Object.entries(providers).map(([providerName, provider]) => { - return ( -
- -
{provider.providerName}
- {provider.savedApiKeys.length > 0 && ( -
-
API Keys
- {provider.savedApiKeys.map((apiKey) => ( -
-

- {apiKey.id} - {apiKey.title} -

- -
- ))} + +

Connections & Credentials

+ + + + Provider + Name + Actions + + + + {allCredentials.map((cred) => ( + + +
+ + {cred.providerName}
- )} - {provider.savedOAuthCredentials.length > 0 && ( -
-
OAuth Credentials
- {provider.savedOAuthCredentials.map((oauth) => ( -
-

- {oauth.id} - {oauth.title} -

- -
- ))} + + +
+ + {cred.title || cred.username}
- )} -
- ); - })} - + + {{oauth2: "OAuth2 credentials", api_key: "API key"}[cred.type]} - {cred.id} + +
+ + + +
+ ))} +
+
); } diff --git a/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx b/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx index dca42cb1bcdc..9fe4d1dd574b 100644 --- a/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx +++ b/autogpt_platform/frontend/src/components/integrations/credentials-input.tsx @@ -10,13 +10,11 @@ import { NotionLogoIcon } from "@radix-ui/react-icons"; import { FaGithub, FaGoogle } from "react-icons/fa"; import { FC, useMemo, useState } from "react"; import { - APIKeyCredentials, CredentialsMetaInput, } from "@/lib/autogpt-server-api/types"; import { IconKey, IconKeyPlus, - IconUser, IconUserPlus, } from "@/components/ui/icons"; import { @@ -45,7 +43,7 @@ import { } from "@/components/ui/select"; // --8<-- [start:ProviderIconsEmbed] -const providerIcons: Record> = { +export const providerIcons: Record> = { github: FaGithub, google: FaGoogle, notion: NotionLogoIcon,