From 6a9865ace7fdd3d334af375f8c1a9613f2ffb786 Mon Sep 17 00:00:00 2001 From: Debanjum Singh Solanky Date: Sun, 4 Aug 2024 02:48:21 +0530 Subject: [PATCH] Only show API keys card in non anon mode - Show informative toast messages on copy, delete of API keys - Onle show API keys card in non anonymous mode. API keys aren't required (and is disabled on server side) in anon mode. Not showing card at all in anon mode reduces chance of unnecessary confusion --- src/interface/web/app/settings/page.tsx | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/interface/web/app/settings/page.tsx b/src/interface/web/app/settings/page.tsx index 5b28e455..534a87a7 100644 --- a/src/interface/web/app/settings/page.tsx +++ b/src/interface/web/app/settings/page.tsx @@ -348,7 +348,7 @@ enum PhoneNumberValidationState { export default function SettingsView() { const [title, setTitle] = useState("Settings"); const [isMobileWidth, setIsMobileWidth] = useState(false); - const { apiKeys, generateAPIKey, copyAPIKey, deleteAPIKey } = useApiKeys(); + const {apiKeys, generateAPIKey, copyAPIKey, deleteAPIKey} = useApiKeys(); const {userConfig: initialUserConfig} = useUserConfig(true); const [userConfig, setUserConfig] = useState(null); const [name, setName] = useState(undefined); @@ -845,6 +845,7 @@ export default function SettingsView() {
Clients
+ {!userConfig.anonymous_mode && ( @@ -868,8 +869,22 @@ export default function SettingsView() { {`${key.token.slice(0, 6)}...${key.token.slice(-4)}`}
- copyAPIKey(key.token)}/> - deleteAPIKey(key.token)}/> + { + 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); + }} + />
@@ -880,6 +895,7 @@ export default function SettingsView() {
+ )}