Skip to content

SmythOS Studio: Open-Source Visual AI Agent Builder and deployable runtime stack from SmythOS. Start with an intuitive drag-and-drop workspace, extend with custom code, and deploy your agents anywhere — local, cloud, or edge — with full governance and control.

remove team nav & add plugins instead

ahmedcoder018e0bbf1498ba
diff --git a/packages/app/src/react/shared/components/layouts/topbarPrimary/TopbarPrimary.tsx b/packages/app/src/react/shared/components/layouts/topbarPrimary/TopbarPrimary.tsx
index f261ebdc..2bc43204 100644
--- a/packages/app/src/react/shared/components/layouts/topbarPrimary/TopbarPrimary.tsx
+++ b/packages/app/src/react/shared/components/layouts/topbarPrimary/TopbarPrimary.tsx
@@ -15,7 +15,7 @@ export const TopbarPrimary = () => {
const [isLoading, setIsLoading] = useState(true);
const { userInfo, userTeams, getPageAccess } = useAuthCtx();
const [profilePages, setProfilePages] = useState(
- profileDropdownItems.filter((p) => {
+ profileDropdownItems().filter((p) => {
return (
p.url !== '/teams/settings' && p.url !== '/teams/members' && getPageAccess(p.url)?.read
);
@@ -66,13 +66,13 @@ export const TopbarPrimary = () => {
const currTeam = userTeams?.filter?.((t) => t.id === userSettings?.userSelectedTeam)?.[0];
if (!currTeam?.parentId) {
setProfilePages(
- profileDropdownItems.filter(
+ profileDropdownItems().filter(
(p) => p.url !== '/teams/settings' && getPageAccess(p.url)?.read,
),
);
} else {
setProfilePages(
- profileDropdownItems.filter((p) => {
+ profileDropdownItems().filter((p) => {
return (
p.url !== '/teams/members' &&
p.url !== '/teams/settings' &&
diff --git a/packages/app/src/react/shared/components/sidebar/Sidebar.tsx b/packages/app/src/react/shared/components/sidebar/Sidebar.tsx
index 5269e459..3af901d1 100644
--- a/packages/app/src/react/shared/components/sidebar/Sidebar.tsx
+++ b/packages/app/src/react/shared/components/sidebar/Sidebar.tsx
@@ -1,22 +1,16 @@
// src/components/sidebar/Sidebar.tsx
import { useGetTeamSettings } from '@react/features/teams/hooks/useTeamSettings';
-import { FEATURE_FLAGS } from '@shared/constants/featureflags';
import { teamSettingKeys } from '@shared/teamSettingKeys';
import { userSettingKeys } from '@shared/userSettingKeys';
import ErrorFallback from '@src/react/features/error-pages/components/ErrorFallback';
import { ErrorBoundarySuspense } from '@src/react/features/error-pages/higher-order-components/ErrorBoundary';
-import {
- bottomLinks,
- sidebarMenuItems,
- sidebarMenuItemsWithTeams,
-} from '@src/react/shared/constants/navigation';
+import { bottomLinks, getSidebarMenuItems } from '@src/react/shared/constants/navigation';
import { useAuthCtx } from '@src/react/shared/contexts/auth.context';
import { useScreenSize } from '@src/react/shared/hooks/useScreenSize';
import { useGetUserSettings } from '@src/react/shared/hooks/useUserSettings';
import classNames from 'classnames';
import React, { useEffect, useRef, useState } from 'react';
import { Link, useLocation, useNavigate } from 'react-router-dom';
-import { useFeatureVisibility } from '../featureFlags';
import { CollapseIcon } from '../svgs';
import { BottomMenuItem } from './BottomMenuItem';
import { SidebarMenuItem } from './SidebarMenuItem';
@@ -34,8 +28,8 @@ export const Sidebar: React.FC = () => {
});
const { isCollapsed, toggleSidebar } = useScreenSize();
- const { isStaffUser, userTeams, getPageAccess } = useAuthCtx();
- const isTeamsUIEnabled = useFeatureVisibility(FEATURE_FLAGS.TEAMS_UI);
+ const { userTeams, getPageAccess } = useAuthCtx();
+ // const isTeamsUIEnabled = useFeatureVisibility(FEATURE_FLAGS.TEAMS_UI);
const { data: userSettings, isLoading: isUserSettingsLoading } = useGetUserSettings(
userSettingKeys.USER_TEAM,
);
@@ -46,38 +40,43 @@ export const Sidebar: React.FC = () => {
access['/domains'] = getPageAccess('/domains')?.read;
access['/data/'] = getPageAccess('/data')?.read;
access['/analytics'] = getPageAccess('/analytics')?.read;
- access['/teams/settings'] = isTeamsUIEnabled && getPageAccess('/teams/members')?.read;
+ access['/teams/settings'] = getPageAccess('/teams/members')?.read;
const currentTeam = userTeams?.find((team) => team.id === userSettings?.userSelectedTeam);
const { data: companyLogo } = useGetTeamSettings(teamSettingKeys.COMPANY_LOGO);
const showCustomLogo =
currentTeam?.parentId && companyLogo?.url && getPageAccess('/teams/members')?.read;
- // const isTeamsUIEnabled = false;
- // featureFlagPayload === FEATURE_FLAG_PAYLOAD_RELEASE_TYPE.PUBLIC || isStaffUser;
- let menuItems = sidebarMenuItemsWithTeams.filter((item) => access[item.url]);
- // let menuItems = isTeamsUIEnabled ? sidebarMenuItemsWithTeams : sidebarMenuItems;
- if (isTeamsUIEnabled && currentTeam) {
- if (!currentTeam.parentId) {
- // Create a new array based on sidebarMenuItems priority
- menuItems = sidebarMenuItems.reduce(
- (acc, item) => {
- // Skip '/teams/settings'
- if (item.url === '/teams/settings') {
- return acc;
- }
+ let menuItems = getSidebarMenuItems().filter((item) => {
+ const isVisible =
+ typeof item.visible === 'boolean'
+ ? item.visible
+ : typeof item.visible === 'function'
+ ? item.visible(currentTeam)
+ : true;
+ return access[item.url] && isVisible;
+ });
+ // if (currentTeam && currentTeam.parentId) {
+ // // if it is SUBTEAM team, add subTeamsMenuItems to menuItems
+ // // Create a new array based on sidebarMenuItems priority
+ // // menuItems = sidebarMenuItems.reduce(
+ // // (acc, item) => {
+ // // // Skip '/teams/settings'
+ // // if (item.url === '/teams/settings') {
+ // // return acc;
+ // // }
- // Include all other items
- if (menuItems.some((menuItem) => menuItem.url === item.url)) {
- acc.push(item);
- }
+ // // // Include all other items
+ // // if (menuItems.some((menuItem) => menuItem.url === item.url)) {
+ // // acc.push(item);
+ // // }
- return acc;
- },
- [] as typeof sidebarMenuItems,
- );
- }
- }
+ // // return acc;
+ // // },
+ // // [] as typeof sidebarMenuItems,
+ // // );
+ // menuItems = [...menuItems, ...subTeamsMenuItems];
+ // }
useEffect(() => {
const currentPage = menuItems.find((page) => page.url === location.pathname);
diff --git a/packages/app/src/react/shared/constants/navigation.ts b/packages/app/src/react/shared/constants/navigation.ts
index 61e5d8fe..de462006 100644
--- a/packages/app/src/react/shared/constants/navigation.ts
+++ b/packages/app/src/react/shared/constants/navigation.ts
@@ -1,8 +1,8 @@
+import { plugins, PluginTarget, PluginType } from '@src/react/shared/plugins/Plugins';
import { SMYTHOS_DOCS_URL } from '@src/shared/constants/general';
import {
BinaryTreeIcon,
BookIcon,
- CogIcon,
DatabaseIcon,
DiscordIcon,
GridIcon,
@@ -15,23 +15,30 @@ export const PRICING_PLAN_REDIRECT = 'https://smythos.com/pricing/';
export const NEW_ENTERPRISE_PLAN_REDIRECT = 'https://smythos.com/pricing-enquiry/';
-export const sidebarMenuItems = [
- { url: '/agents', name: 'Home', icon: HomeIcon },
- { url: '/domains', name: 'Subdomains', icon: BinaryTreeIcon },
- { url: '/data/', name: 'Data Pool', icon: DatabaseIcon },
- { url: '/analytics', name: 'Analytics', icon: LineChartIcon },
- { url: '/vault', name: 'Vault', icon: KeyIcon },
- { url: '/templates', name: 'Templates', icon: GridIcon },
-];
-export const sidebarMenuItemsWithTeams = [
- { url: '/agents', name: 'Home', icon: HomeIcon },
- { url: '/domains', name: 'Subdomains', icon: BinaryTreeIcon },
- { url: '/data/', name: 'Data Pool', icon: DatabaseIcon },
- { url: '/analytics', name: 'Analytics', icon: LineChartIcon },
- { url: '/vault', name: 'Vault', icon: KeyIcon },
- { url: '/templates', name: 'Templates', icon: GridIcon },
- { url: '/teams/settings', name: 'Space Settings', icon: CogIcon },
-];
+export type SidebarMenuItem = {
+ url: string;
+ name: string;
+ icon: React.FC;
+ visible: boolean | ((ctx: any) => boolean);
+};
+
+export const getSidebarMenuItems = (): SidebarMenuItem[] => {
+ let pluginItems = (
+ plugins.getPluginsByTarget(PluginTarget.SidebarMenuItems, PluginType.Config) as {
+ config: any;
+ }[]
+ ).flatMap((item) => item.config);
+
+ return [
+ { url: '/agents', name: 'Home', icon: HomeIcon, visible: true },
+ { url: '/domains', name: 'Subdomains', icon: BinaryTreeIcon, visible: true },
+ { url: '/data/', name: 'Data Pool', icon: DatabaseIcon, visible: true },
+ { url: '/analytics', name: 'Analytics', icon: LineChartIcon, visible: true },
+ { url: '/vault', name: 'Vault', icon: KeyIcon, visible: true },
+ { url: '/templates', name: 'Templates', icon: GridIcon, visible: true },
+ ...pluginItems,
+ ];
+};
export const bottomLinks = [
{ title: 'Docs', path: SMYTHOS_DOCS_URL, icon: BookIcon, isExternal: true },
@@ -43,11 +50,18 @@ export const bottomLinks = [
},
];
-export const profileDropdownItems = [
- { url: '/account', name: 'Account' },
- // { url: '/teams', name: 'Spaces' },
- { url: '/teams/members', name: 'User Management' },
- { url: '/teams/settings', name: 'User Management' },
- // { url: '/teams/roles', name: 'Manage Roles' },
- { url: '/my-plan', name: 'My Plan' },
-];
+export const profileDropdownItems = () => {
+ const pluginItems = (
+ plugins.getPluginsByTarget(PluginTarget.TopMenuProfileDropdownItems, PluginType.Config) as {
+ config: any;
+ }[]
+ ).flatMap((item) => item.config);
+
+ return [
+ { url: '/account', name: 'Account' },
+ // { url: '/teams/members', name: 'User Management' },
+ ...pluginItems,
+ { url: '/teams/settings', name: 'User Management' },
+ { url: '/my-plan', name: 'My Plan' },
+ ];
+};
diff --git a/packages/app/src/react/shared/plugins/Plugins.ts b/packages/app/src/react/shared/plugins/Plugins.ts
index 9aef07f7..536d049f 100644
--- a/packages/app/src/react/shared/plugins/Plugins.ts
+++ b/packages/app/src/react/shared/plugins/Plugins.ts
@@ -2,6 +2,8 @@ export enum PluginTarget {
BuilderLoadScript = 'builder/LoadScript',
TopMenuItem = 'topMenuItem',
Onboarding = 'onboarding',
+ SidebarMenuItems = 'sidebarMenuItems',
+ TopMenuProfileDropdownItems = 'topMenuProfileDropdownItems',
}
export enum PluginType {