@coffre/ui 0.1.17 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -3
- package/dist/{server/_coffre/assets/affordances-CKANXDTG.js → chunks/affordances-DAvsVz7u.js} +12 -7
- package/dist/chunks/affordances-DAvsVz7u.js.map +1 -0
- package/dist/chunks/directory-CSjWWUQ1.js +370 -0
- package/dist/chunks/directory-CSjWWUQ1.js.map +1 -0
- package/dist/{server/_coffre/assets/grants-DdKT11Ny.js → chunks/grants-saMQagmG.js} +41 -39
- package/dist/chunks/grants-saMQagmG.js.map +1 -0
- package/dist/chunks/icons-D-PfAfnH.js +203 -0
- package/dist/chunks/icons-D-PfAfnH.js.map +1 -0
- package/dist/chunks/mounted-jJmqqV_n.js +17 -0
- package/dist/chunks/mounted-jJmqqV_n.js.map +1 -0
- package/dist/{server/_coffre/assets/offboarding-CRz-K82H.js → chunks/offboarding-C6l30DZR.js} +70 -69
- package/dist/chunks/offboarding-C6l30DZR.js.map +1 -0
- package/dist/chunks/page-C5HcNqf2.js +190 -0
- package/dist/chunks/page-C5HcNqf2.js.map +1 -0
- package/dist/chunks/page-route-Drfw7lmn.js +20 -0
- package/dist/chunks/page-route-Drfw7lmn.js.map +1 -0
- package/dist/{server/_coffre/assets/principal-page-C-EFwJQw.js → chunks/principal-page-D_91OA0l.js} +105 -103
- package/dist/chunks/principal-page-D_91OA0l.js.map +1 -0
- package/dist/{server/_coffre/assets → chunks}/project-environments-lEzFHUt4.js +2 -0
- package/dist/chunks/project-environments-lEzFHUt4.js.map +1 -0
- package/dist/chunks/queries-CQ81o4so.js +376 -0
- package/dist/chunks/queries-CQ81o4so.js.map +1 -0
- package/dist/{server/_coffre/assets/row-state-C2P57xT1.js → chunks/row-state-0PsrEzOL.js} +22 -21
- package/dist/chunks/row-state-0PsrEzOL.js.map +1 -0
- package/dist/{server/_coffre/assets → chunks}/signin-errors-BEFlVDbQ.js +2 -0
- package/dist/chunks/signin-errors-BEFlVDbQ.js.map +1 -0
- package/dist/chunks/theme-B2vQolVR.js +86 -0
- package/dist/chunks/theme-B2vQolVR.js.map +1 -0
- package/dist/chunks/ui-DixXLQvQ.js +405 -0
- package/dist/chunks/ui-DixXLQvQ.js.map +1 -0
- package/dist/{server/_coffre/assets/use-action-B-xpvVRO.js → chunks/use-action-CWsg_YWU.js} +8 -6
- package/dist/chunks/use-action-CWsg_YWU.js.map +1 -0
- package/dist/{server/_coffre/assets/use-change-C8BCf3oU.js → chunks/use-change-c6CeLRin.js} +10 -474
- package/dist/chunks/use-change-c6CeLRin.js.map +1 -0
- package/dist/chunks/use-shell-jxd7Tzd-.js +26 -0
- package/dist/chunks/use-shell-jxd7Tzd-.js.map +1 -0
- package/dist/{server/_coffre/assets → chunks}/validation-BQtqPe2V.js +2 -0
- package/dist/chunks/validation-BQtqPe2V.js.map +1 -0
- package/dist/index.d.ts +386 -18
- package/dist/index.js +1147 -0
- package/dist/index.js.map +1 -0
- package/dist/pages/account.d.ts +9 -0
- package/dist/pages/account.js +334 -0
- package/dist/pages/account.js.map +1 -0
- package/dist/pages/audit.d.ts +3 -0
- package/dist/{server/_coffre/assets/audit-qB9G2AQJ.js → pages/audit.js} +102 -100
- package/dist/pages/audit.js.map +1 -0
- package/dist/pages/device-login.d.ts +9 -0
- package/dist/pages/device-login.js +211 -0
- package/dist/pages/device-login.js.map +1 -0
- package/dist/pages/environment.d.ts +3 -0
- package/dist/{server/_coffre/assets/projects._project._environment-C6uybzeU.js → pages/environment.js} +323 -469
- package/dist/pages/environment.js.map +1 -0
- package/dist/pages/login.d.ts +10 -0
- package/dist/pages/login.js +104 -0
- package/dist/pages/login.js.map +1 -0
- package/dist/pages/project.d.ts +2 -0
- package/dist/{server/_coffre/assets/projects._project.index-3CXwkyTh.js → pages/project.js} +223 -225
- package/dist/pages/project.js.map +1 -0
- package/dist/pages/projects.d.ts +3 -0
- package/dist/{server/_coffre/assets/projects.index-iSoBpRFz.js → pages/projects.js} +83 -81
- package/dist/pages/projects.js.map +1 -0
- package/dist/pages/settings.d.ts +3 -0
- package/dist/{server/_coffre/assets/settings-BDQTF5XW.js → pages/settings.js} +20 -18
- package/dist/pages/settings.js.map +1 -0
- package/dist/pages/token.d.ts +3 -0
- package/dist/{server/_coffre/assets/tokens._token-CrBMpcbN.js → pages/token.js} +195 -265
- package/dist/pages/token.js.map +1 -0
- package/dist/pages/tokens.d.ts +3 -0
- package/dist/pages/tokens.js +39 -0
- package/dist/pages/tokens.js.map +1 -0
- package/dist/pages/unregistered.d.ts +8 -0
- package/dist/pages/unregistered.js +54 -0
- package/dist/pages/unregistered.js.map +1 -0
- package/dist/pages/user.d.ts +3 -0
- package/dist/pages/user.js +16 -0
- package/dist/pages/user.js.map +1 -0
- package/dist/pages/users.d.ts +3 -0
- package/dist/pages/users.js +39 -0
- package/dist/pages/users.js.map +1 -0
- package/dist/project-BqIy8gYR.d.ts +5 -0
- package/dist/vite.d.ts +16 -0
- package/dist/vite.js +52 -0
- package/package.json +36 -21
- package/src/assets/icon.svg +1 -0
- package/src/components/affordances.ts +10 -4
- package/src/components/command-palette.tsx +229 -203
- package/src/components/directory.tsx +34 -38
- package/src/components/principal.tsx +7 -3
- package/src/components/shell.tsx +89 -127
- package/src/components/theme.tsx +14 -81
- package/src/components/ui.tsx +97 -68
- package/src/index.ts +29 -0
- package/src/layout.tsx +113 -0
- package/src/lib/coffre.ts +8 -4
- package/src/lib/mounted.ts +13 -0
- package/src/lib/page-context.ts +31 -0
- package/src/lib/page-route.ts +22 -0
- package/src/lib/preferences.tsx +46 -0
- package/src/options.ts +240 -0
- package/src/{routes → pages}/account.tsx +7 -24
- package/src/{routes → pages}/audit.tsx +5 -16
- package/src/{routes/auth.device.tsx → pages/device-login.tsx} +8 -21
- package/src/{routes/projects.$project.$environment.tsx → pages/environment.tsx} +43 -52
- package/src/{routes → pages}/login.tsx +5 -16
- package/src/{routes/projects.$project.index.tsx → pages/project.tsx} +38 -50
- package/src/{routes/projects.index.tsx → pages/projects.tsx} +2 -7
- package/src/{routes → pages}/settings.tsx +3 -10
- package/src/{routes/tokens.$token.tsx → pages/token.tsx} +6 -7
- package/src/{routes/tokens.index.tsx → pages/tokens.tsx} +3 -8
- package/src/{routes → pages}/unregistered.tsx +1 -6
- package/src/pages/user.tsx +10 -0
- package/src/{routes/users.index.tsx → pages/users.tsx} +3 -8
- package/src/register.ts +55 -0
- package/src/router.tsx +31 -62
- package/src/styles/globals.css +104 -46
- package/src/vite.ts +78 -0
- package/dist/client/.assetsignore +0 -2
- package/dist/client/_coffre/assets/account-BoLGAxbD.js +0 -2
- package/dist/client/_coffre/assets/account-CnnuRTDB.js +0 -1
- package/dist/client/_coffre/assets/affordances-CEafRJcN.js +0 -1
- package/dist/client/_coffre/assets/audit-CHSvKLWX.js +0 -1
- package/dist/client/_coffre/assets/audit-Cn4hmS4u.js +0 -2
- package/dist/client/_coffre/assets/auth.device-Co5vrpaA.js +0 -2
- package/dist/client/_coffre/assets/auth.device-DAlqWacc.js +0 -1
- package/dist/client/_coffre/assets/directory-H8Eh3MnS.js +0 -1
- package/dist/client/_coffre/assets/dist-Braunv_x.js +0 -1
- package/dist/client/_coffre/assets/globals-CpMrgkV6.css +0 -1
- package/dist/client/_coffre/assets/grants-DPDxJXU1.js +0 -1
- package/dist/client/_coffre/assets/icons-Dc_-t0lp.js +0 -1
- package/dist/client/_coffre/assets/index-sUCIXRgJ.js +0 -12
- package/dist/client/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/client/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/client/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/client/_coffre/assets/link-DBINMwm6.js +0 -1
- package/dist/client/_coffre/assets/login-BZFYfL1Y.js +0 -1
- package/dist/client/_coffre/assets/login-CYCKWTOD.js +0 -2
- package/dist/client/_coffre/assets/offboarding-Bwpftp3g.js +0 -1
- package/dist/client/_coffre/assets/page-C_hnzdaR.js +0 -1
- package/dist/client/_coffre/assets/preload-helper-CLkO85Nq.js +0 -1
- package/dist/client/_coffre/assets/principal-page-DLho8TSJ.js +0 -1
- package/dist/client/_coffre/assets/project-environments-CfIH5kFM.js +0 -1
- package/dist/client/_coffre/assets/projects._project._environment-DHRRvQw0.js +0 -3
- package/dist/client/_coffre/assets/projects._project._environment-TLI-RjBZ.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-BO-8FZIY.js +0 -2
- package/dist/client/_coffre/assets/projects._project.index-DGl921dP.js +0 -1
- package/dist/client/_coffre/assets/projects.index-BDn7Bhoo.js +0 -1
- package/dist/client/_coffre/assets/row-state-DJ-KLamZ.js +0 -1
- package/dist/client/_coffre/assets/settings-q9G1QvR_.js +0 -1
- package/dist/client/_coffre/assets/signin-errors-CroZWZgm.js +0 -1
- package/dist/client/_coffre/assets/suspense-O8sP0mEC.js +0 -1
- package/dist/client/_coffre/assets/tokens._token-B_qczpT9.js +0 -2
- package/dist/client/_coffre/assets/tokens._token-T-sqwMbz.js +0 -2
- package/dist/client/_coffre/assets/tokens.index-CcXSZnAG.js +0 -1
- package/dist/client/_coffre/assets/ui-BXP2IqrW.js +0 -46
- package/dist/client/_coffre/assets/unregistered-D2JXJ90x.js +0 -1
- package/dist/client/_coffre/assets/use-action-BpzKWhgg.js +0 -1
- package/dist/client/_coffre/assets/use-change-CKj3Inq9.js +0 -1
- package/dist/client/_coffre/assets/use-shell-W0SusPkz.js +0 -1
- package/dist/client/_coffre/assets/useQuery-B-lxFSES.js +0 -1
- package/dist/client/_coffre/assets/useSuspenseQuery-BZ-nzHST.js +0 -1
- package/dist/client/_coffre/assets/users._user-Bb3BGYHl.js +0 -1
- package/dist/client/_coffre/assets/users._user-DXmvKrzE.js +0 -2
- package/dist/client/_coffre/assets/users.index-BvzP3qwW.js +0 -1
- package/dist/client/_coffre/assets/validation-9Cl_XS-l.js +0 -1
- package/dist/server/.vite/manifest.json +0 -668
- package/dist/server/_coffre/assets/_tanstack-start-manifest_v-GsKnGGRy.js +0 -162
- package/dist/server/_coffre/assets/account-CV-a2IU2.js +0 -329
- package/dist/server/_coffre/assets/account-hk6wcIXU.js +0 -162
- package/dist/server/_coffre/assets/async-local-storage-C10uQtMM.js +0 -3108
- package/dist/server/_coffre/assets/audit-C1_Ej6YB.js +0 -31
- package/dist/server/_coffre/assets/auth.device-6JRrWbSV.js +0 -210
- package/dist/server/_coffre/assets/auth.device-CLoAxC2T.js +0 -29
- package/dist/server/_coffre/assets/directory-B-_rqsPx.js +0 -371
- package/dist/server/_coffre/assets/dist-CnnV3t2g.js +0 -908
- package/dist/server/_coffre/assets/empty-plugin-adapters-Cq4--YW-.js +0 -5
- package/dist/server/_coffre/assets/globals-CpMrgkV6.css +0 -1
- package/dist/server/_coffre/assets/icons-DOFT-eWB.js +0 -1704
- package/dist/server/_coffre/assets/inter-cyrillic-ext-opsz-normal-CfYZpDVp.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-cyrillic-opsz-normal-BFQXbQ-f.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-ext-opsz-normal-BmPQvyvo.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-greek-opsz-normal-BM0NlUE_.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-ext-opsz-normal-DpK-iCPk.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-latin-opsz-normal-BwkfbSeq.woff2 +0 -0
- package/dist/server/_coffre/assets/inter-vietnamese-opsz-normal-Ci9T9ieq.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-ext-wght-normal-EocZY2iu.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
- package/dist/server/_coffre/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
- package/dist/server/_coffre/assets/lazyRouteComponent-CqBNCGuZ.js +0 -480
- package/dist/server/_coffre/assets/link-42ZWdjzZ.js +0 -422
- package/dist/server/_coffre/assets/login-DRKUKkaW.js +0 -22
- package/dist/server/_coffre/assets/login-DnwxVl4Y.js +0 -102
- package/dist/server/_coffre/assets/matchContext-qLfYbC6_.js +0 -56
- package/dist/server/_coffre/assets/page-D6n45dcK.js +0 -3561
- package/dist/server/_coffre/assets/projects._project._environment-CS8DdSMY.js +0 -48
- package/dist/server/_coffre/assets/projects._project.index-BGfcNpj0.js +0 -23
- package/dist/server/_coffre/assets/react-dom-bBoJXlK2.js +0 -1718
- package/dist/server/_coffre/assets/router-9BTgJhWG.js +0 -2322
- package/dist/server/_coffre/assets/start-DR3rN0St.js +0 -4
- package/dist/server/_coffre/assets/suspense-C-2QfDd2.js +0 -602
- package/dist/server/_coffre/assets/tokens._token-rY86Cjgp.js +0 -10
- package/dist/server/_coffre/assets/tokens.index-Bq5qDW9q.js +0 -37
- package/dist/server/_coffre/assets/ui-Cc0CGMtr.js +0 -14881
- package/dist/server/_coffre/assets/unregistered-D9ZKLOPJ.js +0 -53
- package/dist/server/_coffre/assets/use-shell-DwOzEi87.js +0 -462
- package/dist/server/_coffre/assets/useQuery-CTe86qFq.js +0 -8
- package/dist/server/_coffre/assets/useRouter-CaUSUNsw.js +0 -473
- package/dist/server/_coffre/assets/useSuspenseQuery-CSoHzrMb.js +0 -117
- package/dist/server/_coffre/assets/users._user-BmLKYeo_.js +0 -10
- package/dist/server/_coffre/assets/users._user-BmiHwQx3.js +0 -14
- package/dist/server/_coffre/assets/users.index-BiEax90r.js +0 -37
- package/dist/server/index.js +0 -13911
- package/src/assets/favicon-32.png +0 -0
- package/src/components/agentation.tsx +0 -34
- package/src/entry.ts +0 -19
- package/src/routeTree.gen.ts +0 -367
- package/src/routes/__root.tsx +0 -169
- package/src/routes/access.tsx +0 -11
- package/src/routes/index.tsx +0 -15
- package/src/routes/users.$user.tsx +0 -13
- package/src/types.ts +0 -21
package/dist/index.js
ADDED
|
@@ -0,0 +1,1147 @@
|
|
|
1
|
+
import { n as isActiveAccessibleEnvironment } from "./chunks/project-environments-lEzFHUt4.js";
|
|
2
|
+
import { t as useMounted } from "./chunks/mounted-jJmqqV_n.js";
|
|
3
|
+
import { _ as rememberSidebar, c as Notice, d as Tip, g as browserPreferences, h as PreferencesContext, o as MenuPopup, p as TooltipProvider, v as rememberTheme, y as usePreferences } from "./chunks/ui-DixXLQvQ.js";
|
|
4
|
+
import { a as administrationEntries, t as AdministrationItems } from "./chunks/affordances-DAvsVz7u.js";
|
|
5
|
+
import { D as Moon, E as Monitor, F as Settings, G as X, L as SignOut, P as Search, R as SlashCircle, T as Menu$1, U as UserCog, W as Users, a as Check, b as Ledger, c as ChevronsUpDown, k as PanelLeft, m as GitHub, p as Folder, r as AlertTriangle, v as Key, w as Mark, y as Layers, z as Sun } from "./chunks/icons-D-PfAfnH.js";
|
|
6
|
+
import { n as ThemeMenuItems, r as ThemeToggle } from "./chunks/theme-B2vQolVR.js";
|
|
7
|
+
import { d as Tile, l as uiResult, n as ClosedDoor, u as useCoffre } from "./chunks/page-C5HcNqf2.js";
|
|
8
|
+
import { n as LiveRegion } from "./chunks/row-state-0PsrEzOL.js";
|
|
9
|
+
import { a as loadPrincipal, i as loadDirectory, n as createQueryClient, o as loadProject, s as loadShell, u as queries } from "./chunks/queries-CQ81o4so.js";
|
|
10
|
+
import { t as useShell } from "./chunks/use-shell-jxd7Tzd-.js";
|
|
11
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
12
|
+
import { Link, Outlet, createRouter as createRouter$1, redirect, useNavigate, useRouter, useRouterState } from "@tanstack/react-router";
|
|
13
|
+
import { Toaster } from "sonner";
|
|
14
|
+
import { Dialog } from "@base-ui/react/dialog";
|
|
15
|
+
import { Menu } from "@base-ui/react/menu";
|
|
16
|
+
import { NO_MIDDLEWARE } from "@coffre/core/pages";
|
|
17
|
+
import { Autocomplete } from "@base-ui/react/autocomplete";
|
|
18
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { createClient } from "@coffre/client";
|
|
20
|
+
import { setupRouterSsrQueryIntegration } from "@tanstack/react-router-ssr-query";
|
|
21
|
+
import { getGlobalStartContext } from "@tanstack/react-start";
|
|
22
|
+
//#region src/lib/instance.ts
|
|
23
|
+
/** Where an owner reads how to upgrade: update the CLI, deploy, then migrate. */
|
|
24
|
+
var UPGRADE_DOC = "https://github.com/erwinkn/coffre/blob/main/docs/deploy.md#upgrading";
|
|
25
|
+
/**
|
|
26
|
+
* The migrations this instance's code ships and its database lacks. Only
|
|
27
|
+
* owners and root admins are told an instance's state; for anyone else it
|
|
28
|
+
* is null, and nothing is pending as far as they can tell.
|
|
29
|
+
*/
|
|
30
|
+
function pendingMigrations(instance) {
|
|
31
|
+
return instance === null ? [] : instance.migrations.known.slice(instance.migrations.applied);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/components/command-palette.tsx
|
|
35
|
+
/**
|
|
36
|
+
* Every word of the query appears somewhere in the command's value, so
|
|
37
|
+
* `prod acme` finds `acme/prod` and `denied` finds "Audit, denials only".
|
|
38
|
+
*/
|
|
39
|
+
function matches(command, query) {
|
|
40
|
+
const value = command.value.toLowerCase();
|
|
41
|
+
return query.toLowerCase().split(/\s+/).every((word) => value.includes(word));
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Command palette.
|
|
45
|
+
*
|
|
46
|
+
* The fast path, never the only path: everything reachable here is also
|
|
47
|
+
* reachable by clicking.
|
|
48
|
+
*
|
|
49
|
+
* Selecting an item uses router navigation so the destination loader finishes
|
|
50
|
+
* before the new screen replaces the current one.
|
|
51
|
+
*/
|
|
52
|
+
function CommandPalette({ projects, capabilities }) {
|
|
53
|
+
const { portal, setTheme } = usePreferences();
|
|
54
|
+
const navigate = useNavigate();
|
|
55
|
+
const [open, setOpen] = useState(false);
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
function onKeyDown(event) {
|
|
58
|
+
if (event.key === "k" && (event.metaKey || event.ctrlKey)) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
setOpen((value) => !value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
document.addEventListener("keydown", onKeyDown);
|
|
64
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
65
|
+
}, []);
|
|
66
|
+
const active = projects.filter((project) => project.archivedAt === null);
|
|
67
|
+
const closing = (action) => () => {
|
|
68
|
+
setOpen(false);
|
|
69
|
+
action();
|
|
70
|
+
};
|
|
71
|
+
const mounted = useMounted();
|
|
72
|
+
const groups = [
|
|
73
|
+
{
|
|
74
|
+
value: "Environments",
|
|
75
|
+
items: active.flatMap((project) => project.environments.filter(isActiveAccessibleEnvironment).map((environment) => ({
|
|
76
|
+
value: `${project.slug}/${environment.slug} ${environment.name}`,
|
|
77
|
+
icon: /* @__PURE__ */ jsx(Layers, { size: 15 }),
|
|
78
|
+
label: /* @__PURE__ */ jsxs("span", {
|
|
79
|
+
className: "mono",
|
|
80
|
+
children: [
|
|
81
|
+
project.slug,
|
|
82
|
+
"/",
|
|
83
|
+
environment.slug
|
|
84
|
+
]
|
|
85
|
+
}),
|
|
86
|
+
hint: `${environment.details.secretCount} secret${environment.details.secretCount === 1 ? "" : "s"}`,
|
|
87
|
+
path: "/projects/$project/$environment",
|
|
88
|
+
run: closing(() => navigate({
|
|
89
|
+
to: "/projects/$project/$environment",
|
|
90
|
+
params: {
|
|
91
|
+
project: project.slug,
|
|
92
|
+
environment: environment.slug
|
|
93
|
+
}
|
|
94
|
+
}))
|
|
95
|
+
})))
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
value: "Projects",
|
|
99
|
+
items: active.map((project) => ({
|
|
100
|
+
value: `${project.slug} ${project.name}`,
|
|
101
|
+
icon: /* @__PURE__ */ jsx(Folder, { size: 15 }),
|
|
102
|
+
label: /* @__PURE__ */ jsx("span", {
|
|
103
|
+
className: "mono",
|
|
104
|
+
children: project.slug
|
|
105
|
+
}),
|
|
106
|
+
hint: project.name,
|
|
107
|
+
path: "/projects/$project",
|
|
108
|
+
run: closing(() => navigate({
|
|
109
|
+
to: "/projects/$project",
|
|
110
|
+
params: { project: project.slug }
|
|
111
|
+
}))
|
|
112
|
+
}))
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
value: "Pages",
|
|
116
|
+
items: [
|
|
117
|
+
{
|
|
118
|
+
value: "projects all",
|
|
119
|
+
icon: /* @__PURE__ */ jsx(Folder, { size: 15 }),
|
|
120
|
+
label: "Projects",
|
|
121
|
+
path: "/projects",
|
|
122
|
+
run: closing(() => navigate({ to: "/projects" }))
|
|
123
|
+
},
|
|
124
|
+
...administrationEntries(capabilities, {
|
|
125
|
+
users: [{
|
|
126
|
+
value: "users people members directory",
|
|
127
|
+
icon: /* @__PURE__ */ jsx(Users, { size: 15 }),
|
|
128
|
+
label: "Users",
|
|
129
|
+
path: "/users",
|
|
130
|
+
run: closing(() => navigate({ to: "/users" }))
|
|
131
|
+
}, {
|
|
132
|
+
value: "tokens service accounts machines ci directory",
|
|
133
|
+
icon: /* @__PURE__ */ jsx(Key, { size: 15 }),
|
|
134
|
+
label: "Tokens",
|
|
135
|
+
path: "/tokens",
|
|
136
|
+
run: closing(() => navigate({ to: "/tokens" }))
|
|
137
|
+
}],
|
|
138
|
+
audit: [{
|
|
139
|
+
value: "audit log history reads",
|
|
140
|
+
icon: /* @__PURE__ */ jsx(Ledger, { size: 15 }),
|
|
141
|
+
label: "Audit",
|
|
142
|
+
path: "/audit",
|
|
143
|
+
run: closing(() => navigate({
|
|
144
|
+
to: "/audit",
|
|
145
|
+
search: {}
|
|
146
|
+
}))
|
|
147
|
+
}, {
|
|
148
|
+
value: "audit denials denied refused",
|
|
149
|
+
icon: /* @__PURE__ */ jsx(SlashCircle, { size: 15 }),
|
|
150
|
+
label: "Audit, denials only",
|
|
151
|
+
path: "/audit",
|
|
152
|
+
run: closing(() => navigate({
|
|
153
|
+
to: "/audit",
|
|
154
|
+
search: { decision: "deny" }
|
|
155
|
+
}))
|
|
156
|
+
}]
|
|
157
|
+
}),
|
|
158
|
+
{
|
|
159
|
+
value: "settings instance sign-in",
|
|
160
|
+
icon: /* @__PURE__ */ jsx(Settings, { size: 15 }),
|
|
161
|
+
label: "Settings",
|
|
162
|
+
path: "/settings",
|
|
163
|
+
run: closing(() => navigate({ to: "/settings" }))
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
value: "account preferences appearance identity profile me",
|
|
167
|
+
icon: /* @__PURE__ */ jsx(UserCog, { size: 15 }),
|
|
168
|
+
label: "Account",
|
|
169
|
+
path: "/account",
|
|
170
|
+
run: closing(() => navigate({ to: "/account" }))
|
|
171
|
+
}
|
|
172
|
+
]
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
value: "Appearance",
|
|
176
|
+
items: [
|
|
177
|
+
{
|
|
178
|
+
value: "theme system automatic",
|
|
179
|
+
icon: /* @__PURE__ */ jsx(Monitor, { size: 15 }),
|
|
180
|
+
label: "Match system colours",
|
|
181
|
+
run: closing(() => setTheme("system"))
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
value: "theme light paper",
|
|
185
|
+
icon: /* @__PURE__ */ jsx(Sun, { size: 15 }),
|
|
186
|
+
label: "Light",
|
|
187
|
+
run: closing(() => setTheme("light"))
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
value: "theme dark night",
|
|
191
|
+
icon: /* @__PURE__ */ jsx(Moon, { size: 15 }),
|
|
192
|
+
label: "Dark",
|
|
193
|
+
run: closing(() => setTheme("dark"))
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
].map((group) => ({
|
|
198
|
+
...group,
|
|
199
|
+
items: group.items.filter((item) => item.path === void 0 || mounted(item.path))
|
|
200
|
+
})).filter((group) => group.items.length > 0);
|
|
201
|
+
return /* @__PURE__ */ jsxs(Dialog.Root, {
|
|
202
|
+
open,
|
|
203
|
+
onOpenChange: setOpen,
|
|
204
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
205
|
+
type: "button",
|
|
206
|
+
className: "search-trigger",
|
|
207
|
+
onClick: () => setOpen(true),
|
|
208
|
+
"aria-label": "Search projects and environments",
|
|
209
|
+
"aria-keyshortcuts": "Meta+K Control+K",
|
|
210
|
+
children: [
|
|
211
|
+
/* @__PURE__ */ jsx(Search, { size: 14 }),
|
|
212
|
+
/* @__PURE__ */ jsx("span", {
|
|
213
|
+
className: "search-label",
|
|
214
|
+
children: "Search…"
|
|
215
|
+
}),
|
|
216
|
+
/* @__PURE__ */ jsx("kbd", {
|
|
217
|
+
"aria-hidden": true,
|
|
218
|
+
children: "⌘K"
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
}), /* @__PURE__ */ jsxs(Dialog.Portal, {
|
|
222
|
+
container: portal,
|
|
223
|
+
children: [/* @__PURE__ */ jsx(Dialog.Backdrop, { className: "overlay" }), /* @__PURE__ */ jsx(Dialog.Popup, {
|
|
224
|
+
className: "palette",
|
|
225
|
+
"aria-label": "Jump to a project, environment or page",
|
|
226
|
+
children: /* @__PURE__ */ jsxs(Autocomplete.Root, {
|
|
227
|
+
items: groups,
|
|
228
|
+
filter: matches,
|
|
229
|
+
itemToStringValue: (command) => command.value,
|
|
230
|
+
open: true,
|
|
231
|
+
inline: true,
|
|
232
|
+
autoHighlight: "always",
|
|
233
|
+
keepHighlight: true,
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ jsx(Autocomplete.Input, {
|
|
236
|
+
className: "palette-input",
|
|
237
|
+
placeholder: "Search projects, environments and pages…",
|
|
238
|
+
"aria-label": "Search projects, environments and pages"
|
|
239
|
+
}),
|
|
240
|
+
/* @__PURE__ */ jsxs("div", {
|
|
241
|
+
className: "palette-list",
|
|
242
|
+
children: [/* @__PURE__ */ jsx(Autocomplete.Empty, {
|
|
243
|
+
className: "palette-empty",
|
|
244
|
+
children: "Nothing by that name."
|
|
245
|
+
}), /* @__PURE__ */ jsx(Autocomplete.List, { children: (group) => /* @__PURE__ */ jsxs(Autocomplete.Group, {
|
|
246
|
+
items: group.items,
|
|
247
|
+
children: [/* @__PURE__ */ jsx(Autocomplete.GroupLabel, {
|
|
248
|
+
className: "palette-group-label",
|
|
249
|
+
children: group.value
|
|
250
|
+
}), /* @__PURE__ */ jsx(Autocomplete.Collection, { children: (command) => /* @__PURE__ */ jsxs(Autocomplete.Item, {
|
|
251
|
+
value: command,
|
|
252
|
+
className: "palette-item",
|
|
253
|
+
onClick: command.run,
|
|
254
|
+
children: [
|
|
255
|
+
command.icon,
|
|
256
|
+
command.label,
|
|
257
|
+
command.hint !== void 0 && /* @__PURE__ */ jsx("span", {
|
|
258
|
+
className: "palette-hint",
|
|
259
|
+
children: command.hint
|
|
260
|
+
})
|
|
261
|
+
]
|
|
262
|
+
}, command.value) })]
|
|
263
|
+
}, group.value) })]
|
|
264
|
+
}),
|
|
265
|
+
/* @__PURE__ */ jsxs("div", {
|
|
266
|
+
className: "palette-foot",
|
|
267
|
+
"aria-hidden": true,
|
|
268
|
+
children: [
|
|
269
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
270
|
+
/* @__PURE__ */ jsx("kbd", { children: "↑" }),
|
|
271
|
+
/* @__PURE__ */ jsx("kbd", { children: "↓" }),
|
|
272
|
+
" move"
|
|
273
|
+
] }),
|
|
274
|
+
/* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("kbd", { children: "↵" }), " open"] }),
|
|
275
|
+
/* @__PURE__ */ jsxs("span", { children: [/* @__PURE__ */ jsx("kbd", { children: "esc" }), " close"] })
|
|
276
|
+
]
|
|
277
|
+
})
|
|
278
|
+
]
|
|
279
|
+
})
|
|
280
|
+
})]
|
|
281
|
+
})]
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
//#region src/components/shell.tsx
|
|
286
|
+
var REPOSITORY = "https://github.com/erwinkn/coffre";
|
|
287
|
+
/** Wide enough for the sidebar to sit beside the page; narrower, it is a drawer. */
|
|
288
|
+
var WIDE = "(width > 60rem)";
|
|
289
|
+
/** Whether the sidebar is folded down to its icons, as the visitor left it, and the switch. */
|
|
290
|
+
function useSidebarCollapsed() {
|
|
291
|
+
const { sidebar, setSidebar } = usePreferences();
|
|
292
|
+
const collapsed = sidebar === "collapsed";
|
|
293
|
+
return [collapsed, () => setSidebar(collapsed ? "expanded" : "collapsed")];
|
|
294
|
+
}
|
|
295
|
+
/** Marks the current route without each link having to compare paths itself. */
|
|
296
|
+
var CURRENT = { "aria-current": "page" };
|
|
297
|
+
function roleLabel(principal, instanceRole) {
|
|
298
|
+
if (principal?.type === "service") return "Token";
|
|
299
|
+
if (instanceRole === "root-admin") return "Root admin";
|
|
300
|
+
if (instanceRole === "owner") return "Owner";
|
|
301
|
+
return "Member";
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Above every page, for owners and root admins, while the database is behind
|
|
305
|
+
* the code this instance runs: what to run, and where the steps are.
|
|
306
|
+
*/
|
|
307
|
+
function MigrationBanner({ instance }) {
|
|
308
|
+
const pending = pendingMigrations(instance);
|
|
309
|
+
if (pending.length === 0) return null;
|
|
310
|
+
return /* @__PURE__ */ jsx("div", {
|
|
311
|
+
className: "migration-banner",
|
|
312
|
+
children: /* @__PURE__ */ jsxs(Notice, {
|
|
313
|
+
tone: "info",
|
|
314
|
+
children: [
|
|
315
|
+
/* @__PURE__ */ jsx("strong", { children: "Database migrations pending:" }),
|
|
316
|
+
" run ",
|
|
317
|
+
/* @__PURE__ */ jsx("code", { children: "coffre migrate" }),
|
|
318
|
+
" to apply",
|
|
319
|
+
" ",
|
|
320
|
+
/* @__PURE__ */ jsx("span", {
|
|
321
|
+
className: "mono",
|
|
322
|
+
children: pending.join(", ")
|
|
323
|
+
}),
|
|
324
|
+
", which coffre ",
|
|
325
|
+
instance?.version,
|
|
326
|
+
" ships.",
|
|
327
|
+
" ",
|
|
328
|
+
/* @__PURE__ */ jsx("a", {
|
|
329
|
+
href: UPGRADE_DOC,
|
|
330
|
+
target: "_blank",
|
|
331
|
+
rel: "noreferrer",
|
|
332
|
+
children: "How to upgrade"
|
|
333
|
+
})
|
|
334
|
+
]
|
|
335
|
+
})
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
/** The product's mark and name, for the pages you see before signing in. */
|
|
339
|
+
function Brand() {
|
|
340
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
341
|
+
className: "brand",
|
|
342
|
+
children: [/* @__PURE__ */ jsx(Mark, { size: 24 }), /* @__PURE__ */ jsx("span", {
|
|
343
|
+
className: "brand-name",
|
|
344
|
+
children: "coffre"
|
|
345
|
+
})]
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* The application frame: a sidebar of sections, headed by coffre's mark and
|
|
350
|
+
* footed by your account, and a bar across the content with search on the
|
|
351
|
+
* right. The sidebar folds down to its icons (⌘B, or the button at the left
|
|
352
|
+
* of the bar) and stays folded across visits.
|
|
353
|
+
*
|
|
354
|
+
* Inside a project, the left of that bar is the path to where you are, and
|
|
355
|
+
* each step of it switches: that is the only place project and environment
|
|
356
|
+
* navigation lives outside the pages themselves. Everywhere else the page's
|
|
357
|
+
* own title says where you are, so the bar leaves it out rather than repeat it.
|
|
358
|
+
*/
|
|
359
|
+
function Shell({ projects, principal, instanceRole, capabilities, instance, children }) {
|
|
360
|
+
const { portal } = usePreferences();
|
|
361
|
+
const pathname = useRouterState({ select: (state) => state.location.pathname });
|
|
362
|
+
const [drawerOpen, setDrawerOpen] = useState(false);
|
|
363
|
+
const drawerClose = useRef(null);
|
|
364
|
+
const [collapsed, toggleSidebar] = useSidebarCollapsed();
|
|
365
|
+
useEffect(() => setDrawerOpen(false), [pathname]);
|
|
366
|
+
useEffect(() => {
|
|
367
|
+
function onKeyDown(event) {
|
|
368
|
+
if (event.key === "b" && (event.metaKey || event.ctrlKey) && matchMedia(WIDE).matches) {
|
|
369
|
+
event.preventDefault();
|
|
370
|
+
toggleSidebar();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
document.addEventListener("keydown", onKeyDown);
|
|
374
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
375
|
+
}, [toggleSidebar]);
|
|
376
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
377
|
+
className: "shell",
|
|
378
|
+
children: [/* @__PURE__ */ jsx("aside", {
|
|
379
|
+
className: "sidebar",
|
|
380
|
+
children: /* @__PURE__ */ jsx(Sidebar, {
|
|
381
|
+
principal,
|
|
382
|
+
instanceRole,
|
|
383
|
+
capabilities,
|
|
384
|
+
collapsed
|
|
385
|
+
})
|
|
386
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
387
|
+
className: "main",
|
|
388
|
+
children: [/* @__PURE__ */ jsxs("header", {
|
|
389
|
+
className: "header",
|
|
390
|
+
children: [
|
|
391
|
+
/* @__PURE__ */ jsx(Tip, {
|
|
392
|
+
label: /* @__PURE__ */ jsxs(Fragment$1, { children: [collapsed ? "Expand sidebar" : "Collapse sidebar", /* @__PURE__ */ jsx("kbd", { children: "⌘B" })] }),
|
|
393
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
394
|
+
type: "button",
|
|
395
|
+
className: "btn btn-quiet btn-icon header-sidebar",
|
|
396
|
+
"aria-label": collapsed ? "Expand sidebar" : "Collapse sidebar",
|
|
397
|
+
"aria-keyshortcuts": "Meta+B Control+B",
|
|
398
|
+
onClick: toggleSidebar,
|
|
399
|
+
children: /* @__PURE__ */ jsx(PanelLeft, { size: 16 })
|
|
400
|
+
})
|
|
401
|
+
}),
|
|
402
|
+
/* @__PURE__ */ jsxs(Dialog.Root, {
|
|
403
|
+
open: drawerOpen,
|
|
404
|
+
onOpenChange: setDrawerOpen,
|
|
405
|
+
children: [/* @__PURE__ */ jsx(Dialog.Trigger, {
|
|
406
|
+
className: "btn btn-quiet btn-icon header-menu",
|
|
407
|
+
"aria-label": "Open navigation",
|
|
408
|
+
children: /* @__PURE__ */ jsx(Menu$1, { size: 18 })
|
|
409
|
+
}), /* @__PURE__ */ jsxs(Dialog.Portal, {
|
|
410
|
+
container: portal,
|
|
411
|
+
children: [/* @__PURE__ */ jsx(Dialog.Backdrop, { className: "overlay" }), /* @__PURE__ */ jsxs(Dialog.Popup, {
|
|
412
|
+
className: "drawer",
|
|
413
|
+
initialFocus: drawerClose,
|
|
414
|
+
children: [/* @__PURE__ */ jsx(Dialog.Title, {
|
|
415
|
+
className: "visually-hidden",
|
|
416
|
+
children: "Navigation"
|
|
417
|
+
}), /* @__PURE__ */ jsx(Sidebar, {
|
|
418
|
+
principal,
|
|
419
|
+
instanceRole,
|
|
420
|
+
capabilities,
|
|
421
|
+
close: /* @__PURE__ */ jsx(Dialog.Close, {
|
|
422
|
+
ref: drawerClose,
|
|
423
|
+
className: "btn btn-quiet btn-sm btn-icon",
|
|
424
|
+
"aria-label": "Close navigation",
|
|
425
|
+
children: /* @__PURE__ */ jsx(X, { size: 16 })
|
|
426
|
+
})
|
|
427
|
+
})]
|
|
428
|
+
})]
|
|
429
|
+
})]
|
|
430
|
+
}),
|
|
431
|
+
/* @__PURE__ */ jsx(Breadcrumbs, {
|
|
432
|
+
pathname,
|
|
433
|
+
projects,
|
|
434
|
+
canListPrincipals: capabilities.canManageGrants
|
|
435
|
+
}),
|
|
436
|
+
/* @__PURE__ */ jsxs("div", {
|
|
437
|
+
className: "header-end",
|
|
438
|
+
children: [/* @__PURE__ */ jsx(CommandPalette, {
|
|
439
|
+
projects,
|
|
440
|
+
capabilities
|
|
441
|
+
}), /* @__PURE__ */ jsx(Tip, {
|
|
442
|
+
label: "coffre on GitHub",
|
|
443
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
444
|
+
className: "btn btn-quiet btn-icon",
|
|
445
|
+
href: REPOSITORY,
|
|
446
|
+
target: "_blank",
|
|
447
|
+
rel: "noreferrer",
|
|
448
|
+
"aria-label": "coffre on GitHub",
|
|
449
|
+
children: /* @__PURE__ */ jsx(GitHub, { size: 16 })
|
|
450
|
+
})
|
|
451
|
+
})]
|
|
452
|
+
})
|
|
453
|
+
]
|
|
454
|
+
}), /* @__PURE__ */ jsxs("main", {
|
|
455
|
+
className: "content",
|
|
456
|
+
id: "content",
|
|
457
|
+
children: [/* @__PURE__ */ jsx(MigrationBanner, { instance }), children]
|
|
458
|
+
})]
|
|
459
|
+
})]
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
/** The sidebar's contents, shared by the wide layout and the narrow drawer. */
|
|
463
|
+
function Sidebar({ principal, instanceRole, capabilities, collapsed = false, close }) {
|
|
464
|
+
const mounted = useMounted();
|
|
465
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
466
|
+
/* @__PURE__ */ jsxs("div", {
|
|
467
|
+
className: "sidebar-head",
|
|
468
|
+
children: [/* @__PURE__ */ jsx(CollapsedTip, {
|
|
469
|
+
collapsed,
|
|
470
|
+
label: "coffre",
|
|
471
|
+
children: /* @__PURE__ */ jsxs(Link, {
|
|
472
|
+
className: "brand sidebar-brand",
|
|
473
|
+
to: "/projects",
|
|
474
|
+
children: [/* @__PURE__ */ jsx(Mark, { size: 24 }), /* @__PURE__ */ jsx("span", {
|
|
475
|
+
className: "brand-name",
|
|
476
|
+
children: "coffre"
|
|
477
|
+
})]
|
|
478
|
+
})
|
|
479
|
+
}), close]
|
|
480
|
+
}),
|
|
481
|
+
/* @__PURE__ */ jsxs("nav", {
|
|
482
|
+
className: "sidebar-nav",
|
|
483
|
+
"aria-label": "Sections",
|
|
484
|
+
children: [
|
|
485
|
+
/* @__PURE__ */ jsx(NavLink, {
|
|
486
|
+
to: "/projects",
|
|
487
|
+
label: "Projects",
|
|
488
|
+
icon: /* @__PURE__ */ jsx(Folder, { size: 16 }),
|
|
489
|
+
collapsed
|
|
490
|
+
}),
|
|
491
|
+
/* @__PURE__ */ jsx(AdministrationItems, {
|
|
492
|
+
capabilities,
|
|
493
|
+
users: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(NavLink, {
|
|
494
|
+
to: "/users",
|
|
495
|
+
label: "Users",
|
|
496
|
+
icon: /* @__PURE__ */ jsx(Users, { size: 16 }),
|
|
497
|
+
collapsed
|
|
498
|
+
}), /* @__PURE__ */ jsx(NavLink, {
|
|
499
|
+
to: "/tokens",
|
|
500
|
+
label: "Tokens",
|
|
501
|
+
icon: /* @__PURE__ */ jsx(Key, { size: 16 }),
|
|
502
|
+
collapsed
|
|
503
|
+
})] }),
|
|
504
|
+
audit: /* @__PURE__ */ jsx(NavLink, {
|
|
505
|
+
to: "/audit",
|
|
506
|
+
label: "Audit",
|
|
507
|
+
icon: /* @__PURE__ */ jsx(Ledger, { size: 16 }),
|
|
508
|
+
collapsed
|
|
509
|
+
})
|
|
510
|
+
}),
|
|
511
|
+
/* @__PURE__ */ jsx(NavLink, {
|
|
512
|
+
to: "/settings",
|
|
513
|
+
label: "Settings",
|
|
514
|
+
icon: /* @__PURE__ */ jsx(Settings, { size: 16 }),
|
|
515
|
+
collapsed
|
|
516
|
+
})
|
|
517
|
+
]
|
|
518
|
+
}),
|
|
519
|
+
principal !== null && /* @__PURE__ */ jsxs("div", {
|
|
520
|
+
className: "sidebar-foot",
|
|
521
|
+
children: [/* @__PURE__ */ jsx(AccountMenu, {
|
|
522
|
+
principal,
|
|
523
|
+
instanceRole,
|
|
524
|
+
collapsed
|
|
525
|
+
}), mounted("/account") && /* @__PURE__ */ jsx(Tip, {
|
|
526
|
+
label: "Account settings",
|
|
527
|
+
side: collapsed ? "right" : void 0,
|
|
528
|
+
children: /* @__PURE__ */ jsx(Link, {
|
|
529
|
+
className: "btn btn-quiet btn-icon sidebar-foot-settings",
|
|
530
|
+
to: "/account",
|
|
531
|
+
"aria-label": "Account settings",
|
|
532
|
+
activeProps: CURRENT,
|
|
533
|
+
children: /* @__PURE__ */ jsx(UserCog, { size: 16 })
|
|
534
|
+
})
|
|
535
|
+
})]
|
|
536
|
+
})
|
|
537
|
+
] });
|
|
538
|
+
}
|
|
539
|
+
/** A folded sidebar's stand-in for the labels it hides. */
|
|
540
|
+
function CollapsedTip({ collapsed, label, children }) {
|
|
541
|
+
return collapsed ? /* @__PURE__ */ jsx(Tip, {
|
|
542
|
+
label,
|
|
543
|
+
side: "right",
|
|
544
|
+
children
|
|
545
|
+
}) : children;
|
|
546
|
+
}
|
|
547
|
+
function NavLink({ to, label, icon, collapsed }) {
|
|
548
|
+
if (!useMounted()(to)) return null;
|
|
549
|
+
return /* @__PURE__ */ jsx(CollapsedTip, {
|
|
550
|
+
collapsed,
|
|
551
|
+
label,
|
|
552
|
+
children: /* @__PURE__ */ jsxs(Link, {
|
|
553
|
+
className: "nav-link",
|
|
554
|
+
to,
|
|
555
|
+
activeProps: CURRENT,
|
|
556
|
+
children: [icon, /* @__PURE__ */ jsx("span", {
|
|
557
|
+
className: "nav-label",
|
|
558
|
+
children: label
|
|
559
|
+
})]
|
|
560
|
+
})
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Sign out with a real form post, built on the spot: the menu item unmounts
|
|
565
|
+
* as the menu closes, so it cannot hold the form itself, and the response is
|
|
566
|
+
* a redirect the browser should follow (to Access's logout, in Cloudflare
|
|
567
|
+
* mode).
|
|
568
|
+
*/
|
|
569
|
+
function signOut() {
|
|
570
|
+
const form = document.createElement("form");
|
|
571
|
+
form.method = "post";
|
|
572
|
+
form.action = "/auth/signout";
|
|
573
|
+
document.body.appendChild(form);
|
|
574
|
+
form.submit();
|
|
575
|
+
}
|
|
576
|
+
function AccountMenu({ principal, instanceRole, collapsed }) {
|
|
577
|
+
return /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(CollapsedTip, {
|
|
578
|
+
collapsed,
|
|
579
|
+
label: principal.id,
|
|
580
|
+
children: /* @__PURE__ */ jsxs(Menu.Trigger, {
|
|
581
|
+
className: "account",
|
|
582
|
+
title: collapsed ? void 0 : principal.id,
|
|
583
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
584
|
+
className: "avatar",
|
|
585
|
+
"aria-hidden": true,
|
|
586
|
+
children: principal.id.slice(0, 1)
|
|
587
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
588
|
+
className: "account-text",
|
|
589
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
590
|
+
className: "account-name",
|
|
591
|
+
children: principal.id
|
|
592
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
593
|
+
className: "account-role",
|
|
594
|
+
children: roleLabel(principal, instanceRole)
|
|
595
|
+
})]
|
|
596
|
+
})]
|
|
597
|
+
})
|
|
598
|
+
}), /* @__PURE__ */ jsxs(MenuPopup, {
|
|
599
|
+
className: "menu-account",
|
|
600
|
+
side: "top",
|
|
601
|
+
align: "start",
|
|
602
|
+
children: [
|
|
603
|
+
/* @__PURE__ */ jsx(ThemeMenuItems, {}),
|
|
604
|
+
/* @__PURE__ */ jsx(Menu.Separator, { className: "menu-sep" }),
|
|
605
|
+
/* @__PURE__ */ jsxs(Menu.Item, {
|
|
606
|
+
className: "menu-item",
|
|
607
|
+
onClick: signOut,
|
|
608
|
+
children: [/* @__PURE__ */ jsx(SignOut, { size: 14 }), "Sign out"]
|
|
609
|
+
})
|
|
610
|
+
]
|
|
611
|
+
})] });
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* The path to the project or environment you are in, where each step also
|
|
615
|
+
* switches: one click on `prod` lists its siblings. Absent everywhere else.
|
|
616
|
+
*/
|
|
617
|
+
function Breadcrumbs({ pathname, projects, canListPrincipals }) {
|
|
618
|
+
const [section, projectSlug, environmentSlug] = pathname.split("/").filter((segment) => segment !== "").map(decodeURIComponent);
|
|
619
|
+
if ((section === "users" || section === "tokens") && projectSlug !== void 0) {
|
|
620
|
+
const label = /* @__PURE__ */ jsx("span", { children: section === "users" ? "Users" : "Tokens" });
|
|
621
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
622
|
+
className: "crumbs",
|
|
623
|
+
"aria-label": "Breadcrumb",
|
|
624
|
+
children: [
|
|
625
|
+
canListPrincipals ? /* @__PURE__ */ jsx(Link, {
|
|
626
|
+
className: "crumb-link crumb-root",
|
|
627
|
+
to: section === "users" ? "/users" : "/tokens",
|
|
628
|
+
children: label
|
|
629
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
630
|
+
className: "crumb-link crumb-root",
|
|
631
|
+
children: label
|
|
632
|
+
}),
|
|
633
|
+
/* @__PURE__ */ jsx("span", {
|
|
634
|
+
className: "crumb-sep",
|
|
635
|
+
"aria-hidden": true,
|
|
636
|
+
children: "/"
|
|
637
|
+
}),
|
|
638
|
+
/* @__PURE__ */ jsx("span", {
|
|
639
|
+
className: "crumb",
|
|
640
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
641
|
+
className: "crumb-link",
|
|
642
|
+
"aria-current": "page",
|
|
643
|
+
children: /* @__PURE__ */ jsx("span", { children: projectSlug })
|
|
644
|
+
})
|
|
645
|
+
})
|
|
646
|
+
]
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
if (section !== "projects" || projectSlug === void 0) return null;
|
|
650
|
+
const active = projects.filter((project) => project.archivedAt === null);
|
|
651
|
+
const project = projects.find((entry) => entry.slug === projectSlug);
|
|
652
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
653
|
+
className: "crumbs",
|
|
654
|
+
"aria-label": "Breadcrumb",
|
|
655
|
+
children: [
|
|
656
|
+
/* @__PURE__ */ jsx(Link, {
|
|
657
|
+
className: "crumb-link crumb-root",
|
|
658
|
+
to: "/projects",
|
|
659
|
+
children: /* @__PURE__ */ jsx("span", { children: "Projects" })
|
|
660
|
+
}),
|
|
661
|
+
/* @__PURE__ */ jsx("span", {
|
|
662
|
+
className: "crumb-sep",
|
|
663
|
+
"aria-hidden": true,
|
|
664
|
+
children: "/"
|
|
665
|
+
}),
|
|
666
|
+
/* @__PURE__ */ jsx(ProjectCrumb, {
|
|
667
|
+
slug: projectSlug,
|
|
668
|
+
current: environmentSlug === void 0,
|
|
669
|
+
projects: active
|
|
670
|
+
}),
|
|
671
|
+
environmentSlug !== void 0 && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
|
|
672
|
+
className: "crumb-sep",
|
|
673
|
+
"aria-hidden": true,
|
|
674
|
+
children: "/"
|
|
675
|
+
}), /* @__PURE__ */ jsx(EnvironmentCrumb, {
|
|
676
|
+
projectSlug,
|
|
677
|
+
slug: environmentSlug,
|
|
678
|
+
environments: project?.environments.filter(isActiveAccessibleEnvironment) ?? []
|
|
679
|
+
})] })
|
|
680
|
+
]
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
function ProjectCrumb({ slug, current, projects }) {
|
|
684
|
+
const navigate = useNavigate();
|
|
685
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
686
|
+
className: "crumb",
|
|
687
|
+
children: [/* @__PURE__ */ jsxs(Link, {
|
|
688
|
+
className: "crumb-link",
|
|
689
|
+
to: "/projects/$project",
|
|
690
|
+
params: { project: slug },
|
|
691
|
+
"aria-current": current ? "page" : void 0,
|
|
692
|
+
children: [/* @__PURE__ */ jsx(Tile, { name: slug }), /* @__PURE__ */ jsx("span", {
|
|
693
|
+
className: "crumb-project-name",
|
|
694
|
+
children: slug
|
|
695
|
+
})]
|
|
696
|
+
}), /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
|
|
697
|
+
className: "crumb-switch",
|
|
698
|
+
"aria-label": "Switch project",
|
|
699
|
+
children: /* @__PURE__ */ jsx(ChevronsUpDown, { size: 14 })
|
|
700
|
+
}), /* @__PURE__ */ jsx(MenuPopup, {
|
|
701
|
+
align: "start",
|
|
702
|
+
children: /* @__PURE__ */ jsxs(Menu.Group, { children: [/* @__PURE__ */ jsx(Menu.GroupLabel, {
|
|
703
|
+
className: "menu-label",
|
|
704
|
+
children: "Projects"
|
|
705
|
+
}), projects.map((project) => /* @__PURE__ */ jsxs(Menu.Item, {
|
|
706
|
+
className: "menu-item",
|
|
707
|
+
onClick: () => navigate({
|
|
708
|
+
to: "/projects/$project",
|
|
709
|
+
params: { project: project.slug }
|
|
710
|
+
}),
|
|
711
|
+
children: [
|
|
712
|
+
/* @__PURE__ */ jsx(Tile, { name: project.slug }),
|
|
713
|
+
project.slug,
|
|
714
|
+
/* @__PURE__ */ jsx("span", {
|
|
715
|
+
className: "menu-hint",
|
|
716
|
+
children: project.name
|
|
717
|
+
}),
|
|
718
|
+
project.slug === slug && /* @__PURE__ */ jsx(Check, {
|
|
719
|
+
size: 14,
|
|
720
|
+
className: "menu-check"
|
|
721
|
+
})
|
|
722
|
+
]
|
|
723
|
+
}, project.slug))] })
|
|
724
|
+
})] })]
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
function EnvironmentCrumb({ projectSlug, slug, environments }) {
|
|
728
|
+
const navigate = useNavigate();
|
|
729
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
730
|
+
className: "crumb",
|
|
731
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
732
|
+
className: "crumb-link",
|
|
733
|
+
"aria-current": "page",
|
|
734
|
+
children: /* @__PURE__ */ jsx("span", { children: slug })
|
|
735
|
+
}), environments.length > 0 && /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsx(Menu.Trigger, {
|
|
736
|
+
className: "crumb-switch",
|
|
737
|
+
"aria-label": "Switch environment",
|
|
738
|
+
children: /* @__PURE__ */ jsx(ChevronsUpDown, { size: 14 })
|
|
739
|
+
}), /* @__PURE__ */ jsx(MenuPopup, {
|
|
740
|
+
align: "start",
|
|
741
|
+
children: /* @__PURE__ */ jsxs(Menu.Group, { children: [/* @__PURE__ */ jsxs(Menu.GroupLabel, {
|
|
742
|
+
className: "menu-label",
|
|
743
|
+
children: ["Environments in ", projectSlug]
|
|
744
|
+
}), environments.map((environment) => /* @__PURE__ */ jsxs(Menu.Item, {
|
|
745
|
+
className: "menu-item",
|
|
746
|
+
onClick: () => navigate({
|
|
747
|
+
to: "/projects/$project/$environment",
|
|
748
|
+
params: {
|
|
749
|
+
project: projectSlug,
|
|
750
|
+
environment: environment.slug
|
|
751
|
+
}
|
|
752
|
+
}),
|
|
753
|
+
children: [
|
|
754
|
+
/* @__PURE__ */ jsx("span", {
|
|
755
|
+
className: "mono",
|
|
756
|
+
children: environment.slug
|
|
757
|
+
}),
|
|
758
|
+
/* @__PURE__ */ jsxs("span", {
|
|
759
|
+
className: "menu-hint",
|
|
760
|
+
children: [
|
|
761
|
+
environment.details?.secretCount ?? 0,
|
|
762
|
+
" secret",
|
|
763
|
+
environment.details?.secretCount === 1 ? "" : "s"
|
|
764
|
+
]
|
|
765
|
+
}),
|
|
766
|
+
environment.slug === slug && /* @__PURE__ */ jsx(Check, {
|
|
767
|
+
size: 14,
|
|
768
|
+
className: "menu-check"
|
|
769
|
+
})
|
|
770
|
+
]
|
|
771
|
+
}, environment.slug))] })
|
|
772
|
+
})] })]
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
//#endregion
|
|
776
|
+
//#region src/layout.tsx
|
|
777
|
+
function Toasts() {
|
|
778
|
+
return /* @__PURE__ */ jsx(Toaster, {
|
|
779
|
+
position: "bottom-right",
|
|
780
|
+
gap: 10,
|
|
781
|
+
offset: 20,
|
|
782
|
+
toastOptions: {
|
|
783
|
+
duration: 4200,
|
|
784
|
+
unstyled: true,
|
|
785
|
+
classNames: {
|
|
786
|
+
toast: "toast",
|
|
787
|
+
title: "toast-title",
|
|
788
|
+
description: "toast-description",
|
|
789
|
+
actionButton: "toast-action",
|
|
790
|
+
success: "toast-success",
|
|
791
|
+
error: "toast-error"
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
/**
|
|
797
|
+
* What coffre's pages need around them, for the deployment's document to put
|
|
798
|
+
* in its body: `<body><CoffreProvider>{children}</CoffreProvider><Scripts /></body>`.
|
|
799
|
+
* coffre's element, drawn in the visitor's theme, its sidebar folded or not,
|
|
800
|
+
* as their cookies say, from the first byte: the server and the browser
|
|
801
|
+
* both render it from them, so nothing waits for a script. Tooltips, toasts
|
|
802
|
+
* and the live region, which the deployment's own pages may use too. The
|
|
803
|
+
* query client comes with the router (`createRouter`).
|
|
804
|
+
*/
|
|
805
|
+
function CoffreProvider({ children }) {
|
|
806
|
+
const initial = useRouter().options.context.preferences;
|
|
807
|
+
const [theme, setThemeState] = useState(initial.theme);
|
|
808
|
+
const [sidebar, setSidebarState] = useState(initial.sidebar);
|
|
809
|
+
const portal = useRef(null);
|
|
810
|
+
const preferences = useMemo(() => ({
|
|
811
|
+
theme,
|
|
812
|
+
sidebar,
|
|
813
|
+
setTheme: (next) => {
|
|
814
|
+
rememberTheme(next);
|
|
815
|
+
setThemeState(next);
|
|
816
|
+
},
|
|
817
|
+
setSidebar: (next) => {
|
|
818
|
+
rememberSidebar(next);
|
|
819
|
+
setSidebarState(next);
|
|
820
|
+
},
|
|
821
|
+
portal
|
|
822
|
+
}), [theme, sidebar]);
|
|
823
|
+
return /* @__PURE__ */ jsx(PreferencesContext.Provider, {
|
|
824
|
+
value: preferences,
|
|
825
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
826
|
+
ref: portal,
|
|
827
|
+
className: "coffre",
|
|
828
|
+
"data-theme": theme === "system" ? void 0 : theme,
|
|
829
|
+
"data-sidebar": sidebar === "collapsed" ? "collapsed" : void 0,
|
|
830
|
+
children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
831
|
+
children,
|
|
832
|
+
/* @__PURE__ */ jsx(Toasts, {}),
|
|
833
|
+
/* @__PURE__ */ jsx(LiveRegion, {})
|
|
834
|
+
] })
|
|
835
|
+
})
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
/** coffre's shell: the nav, around the signed-in pages. */
|
|
839
|
+
function ShellLayout() {
|
|
840
|
+
const { principal, instanceRole, projects, capabilities, instance } = useShell();
|
|
841
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("a", {
|
|
842
|
+
className: "skip-link",
|
|
843
|
+
href: "#content",
|
|
844
|
+
children: "Skip to content"
|
|
845
|
+
}), /* @__PURE__ */ jsx(Shell, {
|
|
846
|
+
projects,
|
|
847
|
+
principal,
|
|
848
|
+
instanceRole,
|
|
849
|
+
capabilities,
|
|
850
|
+
instance,
|
|
851
|
+
children: /* @__PURE__ */ jsx(Outlet, {})
|
|
852
|
+
})] });
|
|
853
|
+
}
|
|
854
|
+
/** The sign-in pages' frame: coffre's mark and the theme, nothing else. */
|
|
855
|
+
function SoloLayout() {
|
|
856
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
857
|
+
className: "solo",
|
|
858
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
859
|
+
className: "solo-top",
|
|
860
|
+
children: [/* @__PURE__ */ jsx(Brand, {}), /* @__PURE__ */ jsx(ThemeToggle, {})]
|
|
861
|
+
}), /* @__PURE__ */ jsx("main", {
|
|
862
|
+
className: "solo-main",
|
|
863
|
+
id: "content",
|
|
864
|
+
children: /* @__PURE__ */ jsx(Outlet, {})
|
|
865
|
+
})]
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
//#endregion
|
|
869
|
+
//#region src/components/route-states.tsx
|
|
870
|
+
/** A path that matches no page. */
|
|
871
|
+
function NotFound() {
|
|
872
|
+
return /* @__PURE__ */ jsx(ClosedDoor, {
|
|
873
|
+
icon: /* @__PURE__ */ jsx(Search, { size: 18 }),
|
|
874
|
+
label: "404",
|
|
875
|
+
title: "Nothing at this address",
|
|
876
|
+
actions: /* @__PURE__ */ jsx(Link, {
|
|
877
|
+
className: "btn",
|
|
878
|
+
to: "/projects",
|
|
879
|
+
children: "All projects"
|
|
880
|
+
}),
|
|
881
|
+
children: "There is no page at this address. If you followed a link to a project or environment, it may have been renamed or archived since."
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
/**
|
|
885
|
+
* A loader or render failure the page itself did not anticipate.
|
|
886
|
+
*
|
|
887
|
+
* Deliberately says nothing about the error's contents: they can include
|
|
888
|
+
* server detail that has no business on screen. Retrying re-runs the loaders.
|
|
889
|
+
*/
|
|
890
|
+
function RouteError({ reset }) {
|
|
891
|
+
const router = useRouter();
|
|
892
|
+
return /* @__PURE__ */ jsx(ClosedDoor, {
|
|
893
|
+
icon: /* @__PURE__ */ jsx(AlertTriangle, { size: 18 }),
|
|
894
|
+
label: "Something went wrong",
|
|
895
|
+
title: "This page could not be shown",
|
|
896
|
+
actions: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
897
|
+
type: "button",
|
|
898
|
+
className: "btn btn-primary",
|
|
899
|
+
onClick: () => {
|
|
900
|
+
reset();
|
|
901
|
+
router.invalidate();
|
|
902
|
+
},
|
|
903
|
+
children: "Try again"
|
|
904
|
+
}), /* @__PURE__ */ jsx(Link, {
|
|
905
|
+
className: "btn",
|
|
906
|
+
to: "/projects",
|
|
907
|
+
children: "All projects"
|
|
908
|
+
})] }),
|
|
909
|
+
children: "coffre could not load what this page needs, and nothing was read or written. If you typed this address, check it; if it keeps happening, the service or its database may be unavailable."
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
//#endregion
|
|
913
|
+
//#region src/lib/page-context.ts
|
|
914
|
+
var DEFAULT_PREFERENCES = {
|
|
915
|
+
theme: "system",
|
|
916
|
+
sidebar: "expanded"
|
|
917
|
+
};
|
|
918
|
+
/**
|
|
919
|
+
* On the server, the request's page context: the visitor's API client, an
|
|
920
|
+
* in-process call with their credential, the response's nonce and their
|
|
921
|
+
* preferences, which coffre's middleware hands each request. A request it
|
|
922
|
+
* did not pass through fails here, saying so, rather than render a page
|
|
923
|
+
* with neither the client nor the headers. Undefined outside a request,
|
|
924
|
+
* where a router is built only to resolve a redirect, and renders nothing.
|
|
925
|
+
*/
|
|
926
|
+
function requestPage() {
|
|
927
|
+
let context;
|
|
928
|
+
try {
|
|
929
|
+
context = getGlobalStartContext();
|
|
930
|
+
} catch {
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
if (context === void 0) return void 0;
|
|
934
|
+
if (context.client === void 0) throw new Error(NO_MIDDLEWARE);
|
|
935
|
+
return context;
|
|
936
|
+
}
|
|
937
|
+
//#endregion
|
|
938
|
+
//#region src/router.tsx
|
|
939
|
+
/**
|
|
940
|
+
* The deployment's router, around its route tree, which holds coffre's
|
|
941
|
+
* routes: `export const getRouter = () => createRouter(routeTree)`. It gives
|
|
942
|
+
* the routes coffre's context (`CoffreContext`). TanStack
|
|
943
|
+
* Start calls it once per request on the server and once on the client, so
|
|
944
|
+
* each gets a query cache of its own: a request's reads are never another
|
|
945
|
+
* visitor's. The server's reads travel with the page, so the browser starts
|
|
946
|
+
* from them rather than asking again.
|
|
947
|
+
*
|
|
948
|
+
* Loaders read through the query cache (`lib/queries.ts`, which says how
|
|
949
|
+
* fresh it keeps a page), so the router keeps no copy of its own: it runs a
|
|
950
|
+
* route's loader on every navigation and every hover, and the cache answers
|
|
951
|
+
* whatever it already holds. A hover is then a read the click reuses.
|
|
952
|
+
*/
|
|
953
|
+
function createRouter(routeTree) {
|
|
954
|
+
const queryClient = createQueryClient();
|
|
955
|
+
const page = typeof window === "undefined" ? requestPage() : void 0;
|
|
956
|
+
const context = {
|
|
957
|
+
coffre: page?.client ?? browserClient(),
|
|
958
|
+
queryClient,
|
|
959
|
+
preferences: page?.preferences ?? (typeof window === "undefined" ? DEFAULT_PREFERENCES : browserPreferences())
|
|
960
|
+
};
|
|
961
|
+
const router = createRouter$1({
|
|
962
|
+
routeTree,
|
|
963
|
+
defaultPreload: "intent",
|
|
964
|
+
defaultStaleTime: 0,
|
|
965
|
+
defaultPreloadStaleTime: 0,
|
|
966
|
+
scrollRestoration: true,
|
|
967
|
+
defaultNotFoundComponent: NotFound,
|
|
968
|
+
defaultErrorComponent: RouteError,
|
|
969
|
+
ssr: { nonce: page?.cspNonce },
|
|
970
|
+
context
|
|
971
|
+
});
|
|
972
|
+
setupRouterSsrQueryIntegration({
|
|
973
|
+
router,
|
|
974
|
+
queryClient
|
|
975
|
+
});
|
|
976
|
+
return router;
|
|
977
|
+
}
|
|
978
|
+
/**
|
|
979
|
+
* The API as this visitor in the browser, which every loader reads through
|
|
980
|
+
* (`context.coffre.secrets.list('market/dev')`): plain `fetch` to `/api`,
|
|
981
|
+
* which sends the session cookie itself. On the server, coffre's
|
|
982
|
+
* middleware builds it per request; outside one, nothing calls it.
|
|
983
|
+
*/
|
|
984
|
+
function browserClient() {
|
|
985
|
+
return createClient({ url: typeof window === "undefined" ? "http://coffre.invalid" : window.location.origin });
|
|
986
|
+
}
|
|
987
|
+
//#endregion
|
|
988
|
+
//#region src/options.ts
|
|
989
|
+
/**
|
|
990
|
+
* coffre's context, as a route's loader reads it. The options take any
|
|
991
|
+
* parent, whose context the types cannot follow; the root's is coffre's.
|
|
992
|
+
*/
|
|
993
|
+
var coffreOf = (context) => context;
|
|
994
|
+
/** coffre's nav, around the signed-in pages: someone not signed in, or not yet registered, is sent to the page for it. */
|
|
995
|
+
var shell = {
|
|
996
|
+
loader: async ({ context, location }) => {
|
|
997
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
998
|
+
const shell = await loadShell(queryClient, coffre);
|
|
999
|
+
if (shell.registrationRequired) throw redirect({ to: "/unregistered" });
|
|
1000
|
+
if (shell.principal === null) throw redirect({
|
|
1001
|
+
to: "/login",
|
|
1002
|
+
search: { next: location.href }
|
|
1003
|
+
});
|
|
1004
|
+
},
|
|
1005
|
+
component: ShellLayout
|
|
1006
|
+
};
|
|
1007
|
+
/** The bare frame of the sign-in pages. Each sends on whoever does not belong there. */
|
|
1008
|
+
var solo = { component: SoloLayout };
|
|
1009
|
+
/** `/`, which sends to the projects. */
|
|
1010
|
+
var home = { beforeLoad: () => {
|
|
1011
|
+
throw redirect({ to: "/projects" });
|
|
1012
|
+
} };
|
|
1013
|
+
/** `/projects`. */
|
|
1014
|
+
var projects = { loader: ({ context }) => {
|
|
1015
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1016
|
+
return queryClient.fetchQuery(queries.projects(coffre));
|
|
1017
|
+
} };
|
|
1018
|
+
/** `/projects/$project`. */
|
|
1019
|
+
var project = {
|
|
1020
|
+
validateSearch: (search) => ({ tab: search.tab === "users" || search.tab === "tokens" || search.tab === "settings" ? search.tab : void 0 }),
|
|
1021
|
+
loader: ({ context, params }) => {
|
|
1022
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1023
|
+
return loadProject(queryClient, coffre, params.project);
|
|
1024
|
+
}
|
|
1025
|
+
};
|
|
1026
|
+
/** `/projects/$project/$environment`. */
|
|
1027
|
+
var environment = {
|
|
1028
|
+
validateSearch: (search) => ({ filter: typeof search.filter === "string" && search.filter !== "" ? search.filter : void 0 }),
|
|
1029
|
+
loader: ({ context, params }) => {
|
|
1030
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1031
|
+
return queryClient.fetchQuery(queries.secrets(coffre, params));
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
/** `/audit`. */
|
|
1035
|
+
var audit = {
|
|
1036
|
+
validateSearch: (search) => ({
|
|
1037
|
+
decision: search.decision === "deny" ? "deny" : void 0,
|
|
1038
|
+
actorId: typeof search.actorId === "string" && search.actorId !== "" ? search.actorId : void 0,
|
|
1039
|
+
detail: search.detail === "1" || search.detail === 1 ? "1" : void 0
|
|
1040
|
+
}),
|
|
1041
|
+
loaderDeps: ({ search }) => search,
|
|
1042
|
+
loader: ({ context, deps }) => {
|
|
1043
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1044
|
+
return queryClient.fetchQuery(queries.auditEntries(coffre, deps));
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
/** `/access`: the access page became the users page, and old links land there. */
|
|
1048
|
+
var access = { beforeLoad: () => {
|
|
1049
|
+
throw redirect({ to: "/users" });
|
|
1050
|
+
} };
|
|
1051
|
+
/** `/users`. */
|
|
1052
|
+
var users = { loader: ({ context }) => {
|
|
1053
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1054
|
+
return loadDirectory(queryClient, coffre);
|
|
1055
|
+
} };
|
|
1056
|
+
/** `/users/$user`. */
|
|
1057
|
+
var user = { loader: ({ context, params }) => {
|
|
1058
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1059
|
+
return loadPrincipal(queryClient, coffre, "user", params.user);
|
|
1060
|
+
} };
|
|
1061
|
+
/** `/tokens`. */
|
|
1062
|
+
var tokens = { loader: ({ context }) => {
|
|
1063
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1064
|
+
return loadDirectory(queryClient, coffre);
|
|
1065
|
+
} };
|
|
1066
|
+
/** `/tokens/$token`. */
|
|
1067
|
+
var token = { loader: ({ context, params }) => {
|
|
1068
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1069
|
+
return loadPrincipal(queryClient, coffre, "service", params.token);
|
|
1070
|
+
} };
|
|
1071
|
+
/** `/settings`. */
|
|
1072
|
+
var settings = { loader: ({ context }) => {
|
|
1073
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1074
|
+
return loadDirectory(queryClient, coffre);
|
|
1075
|
+
} };
|
|
1076
|
+
/** `/account`. */
|
|
1077
|
+
var account = {
|
|
1078
|
+
validateSearch: (search) => {
|
|
1079
|
+
const out = {};
|
|
1080
|
+
for (const name of ["linked", "error"]) {
|
|
1081
|
+
const value = search[name];
|
|
1082
|
+
if (typeof value === "string" && /^[a-z0-9_-]{1,40}$/.test(value)) out[name] = value;
|
|
1083
|
+
}
|
|
1084
|
+
return out;
|
|
1085
|
+
},
|
|
1086
|
+
loader: async ({ context }) => {
|
|
1087
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1088
|
+
const shell = await loadShell(queryClient, coffre);
|
|
1089
|
+
if (shell.auth.signin === null || shell.principal?.type !== "user") return;
|
|
1090
|
+
await Promise.all([queryClient.fetchQuery(queries.identities(coffre)), queryClient.fetchQuery(queries.sessions(coffre))]);
|
|
1091
|
+
}
|
|
1092
|
+
};
|
|
1093
|
+
/** `/login`. */
|
|
1094
|
+
var login = {
|
|
1095
|
+
validateSearch: (search) => {
|
|
1096
|
+
const out = {};
|
|
1097
|
+
const { next, error } = search;
|
|
1098
|
+
if (typeof next === "string" && next.startsWith("/") && !next.startsWith("//")) out.next = next;
|
|
1099
|
+
if (typeof error === "string" && /^[a-z_]{1,40}$/.test(error)) out.error = error;
|
|
1100
|
+
return out;
|
|
1101
|
+
},
|
|
1102
|
+
loader: async ({ context }) => {
|
|
1103
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1104
|
+
const shell = await loadShell(queryClient, coffre);
|
|
1105
|
+
if (shell.registrationRequired) throw redirect({ to: "/unregistered" });
|
|
1106
|
+
if (shell.principal !== null) throw redirect({ to: "/projects" });
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1109
|
+
/** `/unregistered`. */
|
|
1110
|
+
var unregistered = { loader: async ({ context, location }) => {
|
|
1111
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1112
|
+
const shell = await loadShell(queryClient, coffre);
|
|
1113
|
+
if (shell.registrationRequired) return;
|
|
1114
|
+
if (shell.principal === null) throw redirect({
|
|
1115
|
+
to: "/login",
|
|
1116
|
+
search: { next: location.href }
|
|
1117
|
+
});
|
|
1118
|
+
throw redirect({ to: "/projects" });
|
|
1119
|
+
} };
|
|
1120
|
+
/** `/auth/device`. */
|
|
1121
|
+
var deviceLogin = {
|
|
1122
|
+
validateSearch: (search) => {
|
|
1123
|
+
const code = search.code;
|
|
1124
|
+
return typeof code === "string" && code.length <= 16 ? { code } : {};
|
|
1125
|
+
},
|
|
1126
|
+
loaderDeps: ({ search }) => ({ code: search.code }),
|
|
1127
|
+
loader: async ({ context, deps, location }) => {
|
|
1128
|
+
const { coffre, queryClient } = coffreOf(context);
|
|
1129
|
+
const shell = await loadShell(queryClient, coffre);
|
|
1130
|
+
if (shell.registrationRequired) throw redirect({ to: "/unregistered" });
|
|
1131
|
+
if (shell.principal === null) throw redirect({
|
|
1132
|
+
to: "/login",
|
|
1133
|
+
search: { next: location.href }
|
|
1134
|
+
});
|
|
1135
|
+
if (deps.code === void 0) return null;
|
|
1136
|
+
if (!shell.auth.signin) return {
|
|
1137
|
+
ok: false,
|
|
1138
|
+
error: "This instance has no CLI sign-in."
|
|
1139
|
+
};
|
|
1140
|
+
const code = deps.code;
|
|
1141
|
+
return uiResult(() => coffre.deviceLogins.get(code));
|
|
1142
|
+
}
|
|
1143
|
+
};
|
|
1144
|
+
//#endregion
|
|
1145
|
+
export { CoffreProvider, access, account, audit, createRouter, deviceLogin, environment, home, login, project, projects, settings, shell, solo, token, tokens, unregistered, useCoffre, user, users };
|
|
1146
|
+
|
|
1147
|
+
//# sourceMappingURL=index.js.map
|