From 731986bc84876c04b4a44202945fc6a2f4df2d34 Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Tue, 26 Nov 2024 11:28:57 -0800 Subject: [PATCH 1/3] add empty states to your account hub page + disconnect button for api key --- .../Authentication/UserItems/index.jsx | 16 +++++- .../CommunityHub/Authentication/index.jsx | 52 +++++++++++++++---- 2 files changed, 57 insertions(+), 11 deletions(-) diff --git a/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx b/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx index 03787b02a20..dd4c47592cb 100644 --- a/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx +++ b/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx @@ -9,6 +9,10 @@ export default function UserItems({ connectionKey }) { const { createdByMe = {}, teamItems = [] } = userItems || {}; if (loading) return ; + const hasItems = (items) => { + return Object.values(items).some(category => category?.items?.length > 0); + }; + return (
{/* Created By Me Section */} @@ -46,6 +50,11 @@ export default function UserItems({ connectionKey }) {
); })} + {!hasItems(createdByMe) && ( +

+ You haven't created any items yet. +

+ )} @@ -66,7 +75,7 @@ export default function UserItems({ connectionKey }) { {team.teamName} {Object.keys(team.items).map((type) => { - if (team.items[type].items.length === 0) return null; + if (!team.items[type]?.items?.length) return null; return (

@@ -80,6 +89,11 @@ export default function UserItems({ connectionKey }) {

); })} + {!hasItems(team.items) && ( +

+ No items shared with this team yet. +

+ )} ))} diff --git a/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/index.jsx b/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/index.jsx index 98f4450c35c..7cf0d1c7603 100644 --- a/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/index.jsx +++ b/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/index.jsx @@ -46,6 +46,26 @@ function useCommunityHubAuthentication() { } } + async function disconnectHub() { + setLoading(true); + try { + const response = await CommunityHub.updateSettings({ + hub_api_key: "", + }); + if (!response.success) + return showToast("Failed to disconnect from hub", "error"); + setHasChanges(false); + showToast("Disconnected from AnythingLLM Community Hub", "success"); + setOriginalConnectionKey(""); + setConnectionKey(""); + } catch (error) { + console.error(error); + showToast("Failed to disconnect from hub", "error"); + } finally { + setLoading(false); + } + } + useEffect(() => { const fetchData = async () => { setLoading(true); @@ -70,6 +90,7 @@ function useCommunityHubAuthentication() { updateConnectionKey, hasChanges, resetChanges, + disconnectHub, }; } @@ -82,6 +103,7 @@ export default function CommunityHubAuthentication() { updateConnectionKey, hasChanges, resetChanges, + disconnectHub, } = useCommunityHubAuthentication(); if (loading) return ; return ( @@ -149,16 +171,26 @@ export default function CommunityHubAuthentication() { className="border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none block w-full p-2.5" placeholder="Enter your AnythingLLM Hub API key" /> -

- You can get your API key from your{" "} - - AnythingLLM Community Hub profile page - - . -

+
+

+ You can get your API key from your{" "} + + AnythingLLM Community Hub profile page + + . +

+ {!!originalConnectionKey && ( + + )} +
From 11badb6c2ad0afb10e446ed6a2e13840ccaa0e98 Mon Sep 17 00:00:00 2001 From: shatfield4 Date: Tue, 26 Nov 2024 11:30:15 -0800 Subject: [PATCH 2/3] lint --- .../CommunityHub/Authentication/UserItems/index.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx b/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx index dd4c47592cb..89457542e89 100644 --- a/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx +++ b/frontend/src/pages/GeneralSettings/CommunityHub/Authentication/UserItems/index.jsx @@ -10,7 +10,7 @@ export default function UserItems({ connectionKey }) { if (loading) return ; const hasItems = (items) => { - return Object.values(items).some(category => category?.items?.length > 0); + return Object.values(items).some((category) => category?.items?.length > 0); }; return ( From 88dd9d431920392b3535f12665a6457c3423d178 Mon Sep 17 00:00:00 2001 From: timothycarambat Date: Tue, 26 Nov 2024 11:39:18 -0800 Subject: [PATCH 3/3] lint --- .../PromptInput/SlashCommands/SlashPresets/index.jsx | 2 +- .../Steps/PullAndReview/HubItem/AgentSkill.jsx | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SlashCommands/SlashPresets/index.jsx b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SlashCommands/SlashPresets/index.jsx index ec42050a28c..e7e5536ea2a 100644 --- a/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SlashCommands/SlashPresets/index.jsx +++ b/frontend/src/components/WorkspaceChat/ChatContainer/PromptInput/SlashCommands/SlashPresets/index.jsx @@ -100,7 +100,7 @@ export default function SlashPresets({ setShowing, sendCommand }) { e.stopPropagation(); handleEditPreset(preset); }} - className="text-theme-text-primary text-sm p-1 hover:cursor-pointer hover:bg-theme-action-menu-item-hover rounded-full mt-1" + className="border-none text-theme-text-primary text-sm p-1 hover:cursor-pointer hover:bg-theme-action-menu-item-hover rounded-full mt-1" > diff --git a/frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/AgentSkill.jsx b/frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/AgentSkill.jsx index b3d949112ed..c5f10a65a81 100644 --- a/frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/AgentSkill.jsx +++ b/frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/AgentSkill.jsx @@ -150,7 +150,7 @@ function FileReview({ item }) {