Add a setting to leave unused integration pages out of the menu
Settings -> Display -> Menu: when on, the menu, command palette and shortcuts omit the pages of integration kinds nobody has added (off by default, the same for everyone). Pages useful without an integration always stay; adding an integration brings its page back at once. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8f5068c6e0
commit
587e8856a0
13 files changed
+346
-7
No files matched your search
@@ -17,6 +17,7 @@ import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
|
||||
import { useMyWork } from "../hooks/useMyWork";
|
||||
import { useStackedTables } from "../hooks/useStackedTables";
|
||||
import { useShortcuts } from "../hooks/useShortcuts";
|
||||
import { useHiddenPages, useMenuHiding } from "../hooks/useMenuHiding";
|
||||
import { useFormLabels } from "../hooks/useFormLabels";
|
||||
import ShortcutHelp from "../components/ShortcutHelp";
|
||||
import Avatar from "../components/Avatar";
|
||||
@@ -85,6 +86,8 @@ export default function AppShell({ user, children }: { user: CurrentUser; childr
|
||||
const [away, setAway] = useState<AwayView | null>(null);
|
||||
const environment = useEnvironment();
|
||||
useStackedTables();
|
||||
useMenuHiding();
|
||||
useHiddenPages(); // so the menu is drawn again when the pages it leaves out change
|
||||
useShortcuts(user);
|
||||
useFormLabels();
|
||||
const mainRef = useRef<HTMLElement>(null);
|
||||
|
||||
@@ -64,6 +64,7 @@ import {
|
||||
IconReportAnalytics,
|
||||
} from "@tabler/icons-react";
|
||||
import type { CurrentUser } from "../api/client";
|
||||
import { isPageHidden } from "../utils/navVisibility";
|
||||
|
||||
// The menu: what pages there are, how they are grouped, and which role is needed to see each. Used by the sidebar, the command
|
||||
// palette, the keyboard shortcuts and the breadcrumbs, so they always agree.
|
||||
@@ -222,9 +223,9 @@ export const NAV: NavEntry[] = [
|
||||
|
||||
const roleRank: Record<CurrentUser["role"], number> = { viewer: 0, operator: 1, admin: 2 };
|
||||
|
||||
/** What this role can see: pages it isn't allowed are dropped, an emptied group disappears, and a group down to one page becomes that page's own link. */
|
||||
/** What this role can see: pages it isn't allowed are dropped, so are pages of integrations nobody has added when the Display setting says to leave those out, an emptied group disappears, and a group down to one page becomes that page's own link. */
|
||||
export function visibleNav(role: CurrentUser["role"]): NavEntry[] {
|
||||
const allowed = (leaf: NavLeaf) => !leaf.minRole || roleRank[role] >= roleRank[leaf.minRole];
|
||||
const allowed = (leaf: NavLeaf) => (!leaf.minRole || roleRank[role] >= roleRank[leaf.minRole]) && !isPageHidden(leaf.to);
|
||||
const out: NavEntry[] = [];
|
||||
for (const entry of NAV) {
|
||||
if (!isGroup(entry)) {
|
||||
|
||||
Reference in new issue
Block a user