Manta Developers
GitHub
Menu

Operator dashboard and workspace picker

Give operators a dashboard across every datastore, put the workspace picker at the top of the sidebar, and add your app's own pages.

An app on the SDK’s layout can add four things to its shell: a dashboard for operators that spans every datastore, the workspace picker as the sidebar’s first row, pages of its own outside any datastore, and menu entries before the SDK’s own. Each is opt-in. Without it, the sidebar and the picker stay as they are.

An operator dashboard

Wrap the app in OperatorHomeProvider with a value for operators, and undefined for everyone else. The datastore picker then lists the dashboard first (“Operator dashboard”), and while it is open (active) the sidebar shows its own menu (nav) in place of a datastore’s. A datastore picked while the dashboard is open opens at pickedDatastorePath, such as its Today, instead of the page the person was on.

import { OperatorHomeProvider, type OperatorHome } from "@manta-eu/react/providers/OperatorHomeContext";

const operatorHome: OperatorHome | undefined = isOperator
  ? {
      label: "Operator dashboard",
      active: datastoreId === undefined && pathname.startsWith("/operator"),
      open: () => navigate("/operator"),
      pickedDatastorePath: "/today",
      nav: [{ id: "overview", title: "Overview", icon: LayoutDashboard, href: "/operator", isActive: true }],
    }
  : undefined;

<OperatorHomeProvider value={operatorHome}>{app}</OperatorHomeProvider>;

nav takes the sidebar’s NavLeafItems. Leave it out to keep the datastore’s menu while the dashboard is open.

With v1_groupedSidebar on, the dashboard leaves the datastore picker and becomes a plain “Operator dashboard” button in the account menu, below the person. Billing joins it there for a datastore that has it, and Custom apps moves to the datastore menu’s Under the hood, where it opens the apps page narrowed to that datastore’s organization.

Pages outside any datastore

getGlobalRoutes takes your own routes as a second argument, rendered beside the SDK’s global routes and before its catch-all. The dashboard is one of them.

import { getGlobalRoutes } from "@manta-eu/react/datastore-routes";
import { Route } from "react-router";

getGlobalRoutes(routeElements, <Route path="/operator" element={<OperatorOverview />} />);

Your own menu entries first

NavExtrasProvider adds your app’s pages to the sidebar after the SDK’s. Give an entry placement: "top" to put it first, for a page people start from, such as a workspace’s Today.

import { NavExtrasProvider } from "@manta-eu/react/providers/NavExtrasProvider";

<NavExtrasProvider items={[{ title: "Today", icon: Sun, href: "/today", placement: "top" }]}>{app}</NavExtrasProvider>;