ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
feat(files): hide File Manager nav when files.read is revoked
Juan Denise4d35bffae1f
diff --git a/frontend/src/components/Sidebar.jsx b/frontend/src/components/Sidebar.jsxindex 9af0732b..20769f1f 100644--- a/frontend/src/components/Sidebar.jsx+++ b/frontend/src/components/Sidebar.jsx@@ -13,7 +13,7 @@ import { sanitizeSvgInner } from '../utils/sanitizeSvg';import useModules from '../hooks/useModules';const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {} }) => {- const { user, logout, updateUser } = useAuth();+ const { user, logout, updateUser, hasPermission } = useAuth();const { theme, resolvedTheme, setTheme, whiteLabel } = useTheme();const { layout, setLayout } = useLayout();const navigate = useNavigate();@@ -162,6 +162,12 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {let items = [...core, ...fromPlugins].filter((item) => !item.requiresCondition || conds[item.requiresCondition]);+ // Per-user feature permissions: a user whose files.read is revoked+ // (custom permissions override the role template) gets 403s from every+ // /api/v1/files endpoint, so don't surface the File Manager at all.+ if (!hasPermission('files', 'read')) {+ items = items.filter((item) => item.id !== 'files');+ }// Extension-contributed tab-group tabs (#43) keep the host group's// sidebar item lit on extension-owned tab routes (group id == sidebar// item id) — the core matchPrefixes only cover the group's own tabs.@@ -188,7 +194,7 @@ const Sidebar = ({ mobileOpen = false, isMobile = false, onMobileClose = () => {}}return applyWorkspaceNavPermissions(items, activeWorkspace, user);- }, [user?.sidebar_config, pluginNav, pluginTabs, wpInstalled, gpuAvailable, wordpressEnabled, user]);+ }, [user?.sidebar_config, pluginNav, pluginTabs, wpInstalled, gpuAvailable, wordpressEnabled, user, hasPermission]);// Group visible items by categoryconst groupedItems = useMemo(() => {diff --git a/frontend/src/hooks/usePaletteAuthz.js b/frontend/src/hooks/usePaletteAuthz.jsindex d7ac8e78..3dddd576 100644--- a/frontend/src/hooks/usePaletteAuthz.js+++ b/frontend/src/hooks/usePaletteAuthz.js@@ -20,7 +20,7 @@ const ALWAYS_VISIBLE = new Set(* you hid from your sidebar for tidiness stays reachable via the palette.*/export default function usePaletteAuthz() {- const { isAdmin } = useAuth();+ const { isAdmin, hasPermission } = useAuth();return useMemo(() => {let navMap = null;@@ -38,6 +38,9 @@ export default function usePaletteAuthz() {if (!navId) return true;if (isAdmin) return true;if (ALWAYS_VISIBLE.has(navId)) return true;+ // Per-user feature permissions: files.read=false 403s every files+ // endpoint, so don't offer the File Manager in the palette either.+ if (navId === 'files' && !hasPermission('files', 'read')) return false;if (!navMap) return true;const allowed = navMap[role];if (!Array.isArray(allowed) || allowed.length === 0) return true;@@ -52,5 +55,5 @@ export default function usePaletteAuthz() {return { isAdmin, allowNav, allowItem };// Recomputes on login/role change (isAdmin flips); the workspace nav map// is read from localStorage at build time and isn't otherwise reactive.- }, [isAdmin]);+ }, [isAdmin, hasPermission]);}