moduel setgins fixed

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-20 22:49:31 +00:00
parent 5c9ef81aba
commit 646095da65
7 changed files with 220 additions and 54 deletions

View File

@@ -23,6 +23,7 @@ import SidebarWidget from "./SidebarWidget";
import { APP_VERSION } from "../config/version";
import { useAuthStore } from "../store/authStore";
import { useSettingsStore } from "../store/settingsStore";
import { useModuleStore } from "../store/moduleStore";
type NavItem = {
name: string;
@@ -41,6 +42,7 @@ const AppSidebar: React.FC = () => {
const { isExpanded, isMobileOpen, isHovered, setIsHovered } = useSidebar();
const location = useLocation();
const { user, isAuthenticated } = useAuthStore();
const { isModuleEnabled, settings: moduleSettings } = useModuleStore();
const [openSubmenu, setOpenSubmenu] = useState<{
sectionIndex: number;
@@ -56,12 +58,9 @@ const AppSidebar: React.FC = () => {
[location.pathname]
);
// Load module enable settings on mount (only once) - but only if user is authenticated
// REMOVED: Module enable settings functionality - all modules always shown
// Module enable/disable is now controlled ONLY via Django Admin (GlobalModuleSettings)
// Define menu sections with useMemo to prevent recreation on every render
// New structure: Dashboard (standalone) → SETUP → WORKFLOW → SETTINGS
// Module visibility is controlled by GlobalModuleSettings (Django Admin only)
const menuSections: MenuSection[] = useMemo(() => {
// SETUP section items (single items, no dropdowns - submenus shown as in-page navigation)
const setupItems: NavItem[] = [
@@ -70,57 +69,73 @@ const AppSidebar: React.FC = () => {
name: "Add Keywords",
path: "/setup/add-keywords",
},
{
];
// Add Sites (Site Builder) if enabled
if (isModuleEnabled('site_builder')) {
setupItems.push({
icon: <GridIcon />,
name: "Sites",
path: "/sites", // Submenus shown as in-page navigation
},
];
});
}
// Add Thinker (always shown)
setupItems.push({
icon: <BoltIcon />,
name: "Thinker",
path: "/thinker/prompts", // Default to prompts, submenus shown as in-page navigation
});
// Add Thinker if enabled
if (isModuleEnabled('thinker')) {
setupItems.push({
icon: <BoltIcon />,
name: "Thinker",
path: "/thinker/prompts", // Default to prompts, submenus shown as in-page navigation
});
}
// WORKFLOW section items (all modules always shown)
// WORKFLOW section items (conditionally shown based on global settings)
const workflowItems: NavItem[] = [];
// Add Planner
workflowItems.push({
icon: <ListIcon />,
name: "Planner",
path: "/planner/keywords", // Default to keywords, submenus shown as in-page navigation
});
// Add Planner if enabled
if (isModuleEnabled('planner')) {
workflowItems.push({
icon: <ListIcon />,
name: "Planner",
path: "/planner/keywords", // Default to keywords, submenus shown as in-page navigation
});
}
// Add Writer
workflowItems.push({
icon: <TaskIcon />,
name: "Writer",
path: "/writer/tasks", // Default to tasks, submenus shown as in-page navigation
});
// Add Writer if enabled
if (isModuleEnabled('writer')) {
workflowItems.push({
icon: <TaskIcon />,
name: "Writer",
path: "/writer/tasks", // Default to tasks, submenus shown as in-page navigation
});
}
// Add Automation
workflowItems.push({
icon: <BoltIcon />,
name: "Automation",
path: "/automation",
});
// Add Automation if enabled
if (isModuleEnabled('automation')) {
workflowItems.push({
icon: <BoltIcon />,
name: "Automation",
path: "/automation",
});
}
// Add Linker
workflowItems.push({
icon: <PlugInIcon />,
name: "Linker",
path: "/linker/content",
});
// Add Linker if enabled
if (isModuleEnabled('linker')) {
workflowItems.push({
icon: <PlugInIcon />,
name: "Linker",
path: "/linker/content",
});
}
// Add Optimizer
workflowItems.push({
icon: <BoltIcon />,
name: "Optimizer",
path: "/optimizer/content",
});
// Add Optimizer if enabled
if (isModuleEnabled('optimizer')) {
workflowItems.push({
icon: <BoltIcon />,
name: "Optimizer",
path: "/optimizer/content",
});
}
return [
// Dashboard is standalone (no section header)
@@ -203,7 +218,7 @@ const AppSidebar: React.FC = () => {
],
},
];
}, []); // No dependencies - always show all modules
}, [isModuleEnabled, moduleSettings]); // Re-run when settings change
// Combine all sections
const allSections = useMemo(() => {