Skip to content

Commit

Permalink
revamp community integration flow
Browse files Browse the repository at this point in the history
  • Loading branch information
timothycarambat committed Nov 8, 2024
1 parent a7757de commit 77b1615
Show file tree
Hide file tree
Showing 38 changed files with 1,906 additions and 794 deletions.
32 changes: 25 additions & 7 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ const AdminInvites = lazy(() => import("@/pages/Admin/Invitations"));
const AdminWorkspaces = lazy(() => import("@/pages/Admin/Workspaces"));
const AdminLogs = lazy(() => import("@/pages/Admin/Logging"));
const AdminAgents = lazy(() => import("@/pages/Admin/Agents"));
const AdminCommunityHub = lazy(
() => import("@/pages/GeneralSettings/CommunityHub")
);
const GeneralChats = lazy(() => import("@/pages/GeneralSettings/Chats"));
const GeneralAppearance = lazy(
() => import("@/pages/GeneralSettings/Appearance")
Expand Down Expand Up @@ -71,6 +68,16 @@ const LiveDocumentSyncManage = lazy(
);
const FineTuningWalkthrough = lazy(() => import("@/pages/FineTuning"));

const CommunityHubTrending = lazy(
() => import("@/pages/GeneralSettings/CommunityHub/Trending")
);
const CommunityHubAuthentication = lazy(
() => import("@/pages/GeneralSettings/CommunityHub/Authentication")
);
const CommunityHubImportItem = lazy(
() => import("@/pages/GeneralSettings/CommunityHub/ImportItem")
);

export default function App() {
return (
<Suspense fallback={<FullScreenLoader />}>
Expand Down Expand Up @@ -132,10 +139,6 @@ export default function App() {
path="/settings/agents"
element={<AdminRoute Component={AdminAgents} />}
/>
<Route
path="/settings/community-hub"
element={<AdminRoute Component={AdminCommunityHub} />}
/>
<Route
path="/settings/event-logs"
element={<AdminRoute Component={AdminLogs} />}
Expand Down Expand Up @@ -204,6 +207,21 @@ export default function App() {
path="/fine-tuning"
element={<AdminRoute Component={FineTuningWalkthrough} />}
/>

<Route
path="/settings/community-hub/trending"
element={<AdminRoute Component={CommunityHubTrending} />}
/>
<Route
path="/settings/community-hub/authentication"
element={
<AdminRoute Component={CommunityHubAuthentication} />
}
/>
<Route
path="/settings/community-hub/import-item"
element={<AdminRoute Component={CommunityHubImportItem} />}
/>
</Routes>
<ToastContainer />
</I18nextProvider>
Expand Down
24 changes: 20 additions & 4 deletions frontend/src/components/SettingsSidebar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,26 @@ const SidebarOptions = ({ user = null, t }) => (
<Option
btnText={t("settings.community-hub")}
icon={<Globe className="h-5 w-5 flex-shrink-0" />}
href={paths.settings.communityHub()}
user={user}
flex={true}
roles={["admin"]}
childOptions={[
{
btnText: "Explore Trending",
href: paths.communityHub.trending(),
flex: true,
roles: ["admin"],
},
{
btnText: "Your Account",
href: paths.communityHub.authentication(),
flex: true,
roles: ["admin"],
},
{
btnText: "Import Item",
href: paths.communityHub.importItem(),
flex: true,
roles: ["admin"],
},
]}
/>
<Option
btnText={t("settings.customization")}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/locales/nl/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ const TRANSLATIONS = {
},
message: {
title: "Berichten Aanpassen",
description: "Pas de automatische berichten aan die aan je gebruikers worden weergegeven.",
description:
"Pas de automatische berichten aan die aan je gebruikers worden weergegeven.",
new: "Nieuw",
system: "systeem",
user: "gebruiker",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/locales/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const resources = {
he: {
common: Hebrew,
},
nl: {
nl: {
common: Dutch,
},
};
112 changes: 112 additions & 0 deletions frontend/src/models/communityHub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import { API_BASE } from "@/utils/constants";
import { baseHeaders } from "@/utils/request";

const CommunityHub = {
/**
* Get an item from the community hub by its import ID.
* @param {string} importId - The import ID of the item.
* @returns {Promise<{error: string | null, item: object | null}>}
*/
async getItemFromImportId(importId) {
return await fetch(`${API_BASE}/community-hub/item`, {
method: "POST",
headers: baseHeaders(),
body: JSON.stringify({ importId }),
})
.then((res) => res.json())
.catch((e) => {
console.error(e);
return {
error: e.message,
item: null,
};
});
},

/**
* Import a bundle item from the community hub.
* @param {string} importId - The import ID of the item.
* @returns {Promise<{error: string | null, item: object | null}>}
*/
async importBundleItem(importId) {
return await fetch(`${API_BASE}/community-hub/import`, {
method: "POST",
headers: baseHeaders(),
body: JSON.stringify({ importId }),
})
.then((res) => res.json())
.catch((e) => {
console.error(e);
return {
error: e.message,
item: null,
};
});
},

/**
* Update the hub settings (API key, etc.)
* @param {Object} data - The data to update.
* @returns {Promise<{success: boolean, error: string | null}>}
*/
updateSettings: async (data) => {
return await fetch(`${API_BASE}/community-hub/settings`, {
method: "POST",
headers: baseHeaders(),
body: JSON.stringify(data),
})
.then(async (res) => {
const response = await res.json();
if (!res.ok)
throw new Error(response.error || "Failed to update settings");
return { success: true, error: null };
})
.catch((e) => ({
success: false,
error: e.message,
}));
},

/**
* Get the hub settings (API key, etc.)
* @returns {Promise<{connectionKey: string | null, error: string | null}>}
*/
getSettings: async () => {
return await fetch(`${API_BASE}/community-hub/settings`, {
method: "GET",
headers: baseHeaders(),
})
.then(async (res) => {
const response = await res.json();
if (!res.ok)
throw new Error(response.error || "Failed to fetch settings");
return { connectionKey: response.connectionKey, error: null };
})
.catch((e) => ({
connectionKey: null,
error: e.message,
}));
},

/**
* Fetch the explore items from the community hub that are publicly available.
* @returns {Promise<{agentSkills: {items: [], hasMore: boolean, totalCount: number}, systemPrompts: {items: [], hasMore: boolean, totalCount: number}, slashCommands: {items: [], hasMore: boolean, totalCount: number}}>}
*/
fetchExploreItems: async () => {
return await fetch(`${API_BASE}/community-hub/explore`, {
method: "GET",
headers: baseHeaders(),
})
.then((res) => res.json())
.catch((e) => {
console.error(e);
return {
success: false,
error: e.message,
result: null,
};
});
},
};

export default CommunityHub;
97 changes: 0 additions & 97 deletions frontend/src/models/hub.js

This file was deleted.

Loading

0 comments on commit 77b1615

Please sign in to comment.