diff --git a/src/interface/web/app/settings/page.tsx b/src/interface/web/app/settings/page.tsx index cd419e40..20c979a5 100644 --- a/src/interface/web/app/settings/page.tsx +++ b/src/interface/web/app/settings/page.tsx @@ -490,6 +490,75 @@ const useApiKeys = () => { }; }; +function ApiKeyCard() { + const { apiKeys, generateAPIKey, copyAPIKey, deleteAPIKey } = useApiKeys(); + const { toast } = useToast(); + + return ( + + + + + API Keys + + + + +

+ Access Khoj from the{" "} + + Desktop + + , Obsidian,{" "} + Emacs apps and more. +

+ + + {apiKeys.map((key) => ( + + {key.name} + + + {`${key.token.slice(0, 6)}...${key.token.slice(-4)}`} + +
+ { + toast({ + title: `🔑 Copied API Key: ${key.name}`, + description: `Set this API key in the Khoj apps you want to connect to this Khoj account`, + }); + copyAPIKey(key.token); + }} + /> + { + toast({ + title: `🔑 Deleted API Key: ${key.name}`, + description: `Apps using this API key will no longer connect to this Khoj account`, + }); + deleteAPIKey(key.token); + }} + /> +
+
+
+ ))} +
+
+
+ +
+ ); +} + enum PhoneNumberValidationState { Setup = "setup", SendOTP = "otp", @@ -498,7 +567,6 @@ enum PhoneNumberValidationState { } export default function SettingsView() { - const { apiKeys, generateAPIKey, copyAPIKey, deleteAPIKey } = useApiKeys(); const { userConfig: initialUserConfig } = useUserConfig(true); const [userConfig, setUserConfig] = useState(null); const [name, setName] = useState(undefined); @@ -1333,92 +1401,7 @@ export default function SettingsView() { Clients
- {!userConfig.anonymous_mode && ( - - - - - API Keys - - - - -

- Access Khoj from the{" "} - - Desktop - - ,{" "} - - Obsidian - - ,{" "} - - Emacs - {" "} - apps and more. -

- - - {apiKeys.map((key) => ( - - - {key.name} - - - - {`${key.token.slice(0, 6)}...${key.token.slice(-4)}`} - -
- { - toast({ - title: `🔑 Copied API Key: ${key.name}`, - description: `Set this API key in the Khoj apps you want to connect to this Khoj account`, - }); - copyAPIKey( - key.token, - ); - }} - /> - { - toast({ - title: `🔑 Deleted API Key: ${key.name}`, - description: `Apps using this API key will no longer connect to this Khoj account`, - }); - deleteAPIKey( - key.token, - ); - }} - /> -
-
-
- ))} -
-
-
- -
- )} + {!userConfig.anonymous_mode && }