Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | 3x 3x 5x 3x 3x 3x 3x 3x 3x 5x 3x 3x 3x 3x 6x 213x 3x 6x 3x 3x | import React from "react";
import { lazyPage } from "@/routes/lazyPage";
import { legacyRedirect } from "@/routes/legacyRedirect";
import NavTitle from "@/components/nav/NavTitle/NavTitle";
import { Building2, Cog, FolderKanban } from "lucide-react";
import { PageConfig } from "../App";
import { APP_ROUTES } from "../const";
import { USER_APP } from "./User";
import { notfound } from "./default";
/**
* The pages an organisation or a project shows (`routes/workspace.ts`).
*
* The same pages Personal shows, mounted under the workspace's prefix by
* `WorkspaceApp`: a page is written once, against `APP_ROUTES.USER`, and
* lists, creates and links inside whichever workspace it is showing. Which
* of Personal's pages a workspace shows is opt-in — `SHARED` below — so a
* page added to Personal stays Personal's until someone decides otherwise.
* Account pages (settings, invites, the organisations list) are never
* here: they belong to the person.
*/
const SHARED = [
"activity",
"dashboards",
"dashboards_by_id",
"inference",
"models_by_id",
"models_chat",
"agents_by_id",
"agents_new",
"agents_new_manual",
"agents_new_generative",
"agent_chat",
"inference_skills_by_id",
"inference_skill_run",
"inference_skills_new",
"inference_skillsets_by_id",
"inference_swarms_by_id",
"inference_swarms_edit",
"inference_swarms_new",
"inference_swarm_run",
"inference_toolkits_by_id",
"knowledge",
"knowledge_new",
"knowledge_by_id",
"knowledge_edit",
"knowledge_repository_by_id",
"governance",
"rules_new",
"rules_by_id",
"rules_edit",
// Opened from a workspace's own answers, runs, flags and activity.
"decision_by_id",
"statement_by_month",
"experiment_by_id",
"dataset_by_id",
// Usage in this workspace: its conversations, agents and model calls.
"stats",
] as const;
/** An organisation holds projects; a project holds none. */
const ORGANISATION_ONLY = ["projects", "projects_new", "projects_by_id"] as const;
const WorkspaceHome = lazyPage(() => import("@/apps/workspace/pages/Home"));
const OrganisationMembers = lazyPage(
() => import("@/apps/organisation/pages/Members"),
);
const ProjectMembers = lazyPage(() => import("@/apps/project/pages/Members"));
const ProjectInheritance = lazyPage(
() => import("@/apps/workspace/pages/Inheritance"),
);
const GeneralSettings = lazyPage(
() => import("@/apps/workspace/pages/settings/General"),
);
const OrganisationPolicies = lazyPage(
() => import("@/apps/workspace/pages/settings/Policies"),
);
const TABS = APP_ROUTES.USER.WORKSPACE_SETTINGS;
/**
* Settings, as Personal's are: one entry in the navigation, opening a tab
* bar (`WorkspaceSettingsTabs`) whose tabs are pages of their own. Members
* and Inheritance had entries of their own; their old paths still land.
*/
const settings = (
tabs: Record<string, PageConfig>,
): Record<string, PageConfig> => ({
settings: {
title: <NavTitle icon={Cog} label="Settings" />,
route: APP_ROUTES.USER.settings,
page: legacyRedirect(TABS.general),
nav_section: "settings",
},
settings_general: {
title: "General",
route: TABS.general,
page: GeneralSettings,
},
...tabs,
members: {
title: "Members",
route: APP_ROUTES.USER.members,
page: legacyRedirect(TABS.members),
},
});
function pick(keys: readonly string[]): Record<string, PageConfig> {
return Object.fromEntries(keys.map((key) => [key, USER_APP[key]]));
}
/** Where the separate organisation and project apps kept their pages, so a
* bookmark of one still lands. */
const LEGACY: Record<string, PageConfig> = {
legacy_home: {
title: "Home",
route: `${APP_ROUTES.USER.overview.replace(/\/$/, "")}/home`,
page: legacyRedirect(APP_ROUTES.USER.overview),
},
legacy_agents: {
title: "Agents",
route: `${APP_ROUTES.USER.overview.replace(/\/$/, "")}/agents`,
page: legacyRedirect(APP_ROUTES.USER.inference),
},
legacy_models: {
title: "Models",
route: `${APP_ROUTES.USER.overview.replace(/\/$/, "")}/models`,
page: legacyRedirect(APP_ROUTES.USER.inference),
},
};
/** Titled with its name once it resolves (`WorkspaceApp`'s `titleMap`). */
const home = (title: React.ReactNode): PageConfig => ({
title,
route: APP_ROUTES.USER.overview,
page: WorkspaceHome,
nav_section: "home",
});
export const ORGANISATION_WORKSPACE_APP: Record<string, PageConfig> = {
home: home(<NavTitle icon={Building2} label="Organisation" />),
...pick(SHARED),
...pick(ORGANISATION_ONLY),
...settings({
settings_policies: {
title: "Policies",
route: TABS.policies,
page: OrganisationPolicies,
},
settings_members: {
title: "Members",
route: TABS.members,
page: OrganisationMembers,
},
}),
...LEGACY,
notfound,
};
export const PROJECT_WORKSPACE_APP: Record<string, PageConfig> = {
home: home(<NavTitle icon={FolderKanban} label="Project" />),
...pick(SHARED),
...settings({
settings_members: {
title: "Members",
route: TABS.members,
page: ProjectMembers,
},
settings_inheritance: {
title: "Inheritance",
route: TABS.inheritance,
page: ProjectInheritance,
},
inheritance: {
title: "Inheritance",
route: APP_ROUTES.USER.inheritance,
page: legacyRedirect(TABS.inheritance),
},
}),
...LEGACY,
notfound,
};
|