46 lines
2.4 KiB
TypeScript
46 lines
2.4 KiB
TypeScript
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
|
// What a project offers, in one place: the pages of the modules, as the organization home, the
|
|
// workspace page and the project home all list them (spec §3.1, §4.1). Server-only: it reads the manifests,
|
|
// so a page's loader hands the entries to its view (F10).
|
|
//
|
|
// A module with pages under a project says so in its manifest (`ui.nav`, scope `project`) and
|
|
// `modules/pages.ts` mounts them (`modulePages`); nothing here is edited to add one. The documents
|
|
// module is the exception that proves the rule: its two pages are routes of the shell
|
|
// (`src/routes/$org.$workspace.$project.documents.*`), so the shell lists it by name.
|
|
|
|
import { PROFILE } from "@app/config"
|
|
import { appModules } from "@app/modules"
|
|
import { moduleSelected } from "@app/modules/inclusion" // kit:documents
|
|
import type { Profile } from "@conusai-kit/platform"
|
|
import type { ProjectEntry } from "../ui/projects"
|
|
|
|
/**
|
|
* Documents, then every project-level entry the manifests declare, by their `order` (core-5): lower first across
|
|
* modules, equal or absent ones (Documents among them, at 0) in this order.
|
|
*/
|
|
export function projectEntriesFor(profile: Profile): readonly ProjectEntry[] {
|
|
return [
|
|
...(moduleSelected("documents") ? [{ href: "documents", label: "documents.title", module: "documents" }] : []), // kit:documents
|
|
...appModules.flatMap((module) =>
|
|
(module.ui?.nav ?? [])
|
|
.filter((item) => item.scope === "project")
|
|
.filter(() => profile !== "convex" || ["notes", "files"].includes(module.id))
|
|
.map((item) => ({
|
|
href: item.href,
|
|
label: item.label,
|
|
module: module.id,
|
|
...(item.icon ? { icon: item.icon } : {}),
|
|
...(item.permission === undefined ? {} : { permission: item.permission }),
|
|
...(item.order === undefined ? {} : { order: item.order }),
|
|
...(item.flag === undefined ? {} : { flag: item.flag }),
|
|
})),
|
|
),
|
|
].sort((a: ProjectEntry, b: ProjectEntry) => (a.order ?? 0) - (b.order ?? 0))
|
|
}
|
|
|
|
export const PROJECT_ENTRIES: readonly ProjectEntry[] = projectEntriesFor(PROFILE)
|
|
|
|
/** The values a project's `moduleKey` can take when it is created from the shell. */
|
|
const moduleKeys = [...new Set(PROJECT_ENTRIES.map((entry) => entry.module))]
|
|
export const PROJECT_MODULE_KEYS: readonly string[] = moduleKeys.length ? moduleKeys : ["general"]
|