@copilotz/directory 0.0.0-stage → 1.0.0-rc.34

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.
Files changed (68) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +70 -2
  3. package/WORDS.md +197 -0
  4. package/actions/code.d.ts +4 -0
  5. package/actions/code.js +135 -0
  6. package/actions/host.d.ts +2 -0
  7. package/actions/host.js +55 -0
  8. package/actions/invite.d.ts +5 -0
  9. package/actions/invite.js +129 -0
  10. package/actions/org.d.ts +10 -0
  11. package/actions/org.js +273 -0
  12. package/collections/credit-code.d.ts +114 -0
  13. package/collections/credit-code.js +28 -0
  14. package/collections/invite.d.ts +81 -0
  15. package/collections/invite.js +20 -0
  16. package/collections/membership.d.ts +72 -0
  17. package/collections/membership.js +22 -0
  18. package/collections/org-host.d.ts +62 -0
  19. package/collections/org-host.js +30 -0
  20. package/collections/org.d.ts +141 -0
  21. package/collections/org.js +58 -0
  22. package/collections/staff.d.ts +42 -0
  23. package/collections/staff.js +12 -0
  24. package/contract.d.ts +8 -0
  25. package/contract.js +8 -0
  26. package/mod.d.ts +67 -0
  27. package/mod.js +122 -0
  28. package/package.json +65 -4
  29. package/routes/console.d.ts +26 -0
  30. package/routes/console.js +129 -0
  31. package/routes/enter.d.ts +18 -0
  32. package/routes/enter.js +47 -0
  33. package/routes/forward.d.ts +35 -0
  34. package/routes/forward.js +119 -0
  35. package/routes/orgs.d.ts +25 -0
  36. package/routes/orgs.js +113 -0
  37. package/routes/signout.d.ts +11 -0
  38. package/routes/signout.js +36 -0
  39. package/shared/enter.d.ts +36 -0
  40. package/shared/enter.js +82 -0
  41. package/shared/http.d.ts +42 -0
  42. package/shared/http.js +77 -0
  43. package/shared/member.d.ts +21 -0
  44. package/shared/member.js +73 -0
  45. package/shared/settings.d.ts +53 -0
  46. package/shared/settings.js +16 -0
  47. package/shared/state.d.ts +74 -0
  48. package/shared/state.js +101 -0
  49. package/views/web/codes.d.ts +27 -0
  50. package/views/web/codes.js +50 -0
  51. package/views/web/console-codes.d.ts +37 -0
  52. package/views/web/console-codes.js +166 -0
  53. package/views/web/console.d.ts +37 -0
  54. package/views/web/console.js +224 -0
  55. package/views/web/lists.d.ts +48 -0
  56. package/views/web/lists.js +42 -0
  57. package/views/web/org.d.ts +12 -0
  58. package/views/web/org.js +62 -0
  59. package/views/web/orgs.d.ts +148 -0
  60. package/views/web/orgs.js +253 -0
  61. package/views/web/style.d.ts +6 -0
  62. package/views/web/style.js +196 -0
  63. package/views/web/switcher.d.ts +72 -0
  64. package/views/web/switcher.js +354 -0
  65. package/views/web/words.d.ts +10 -0
  66. package/views/web/words.js +201 -0
  67. package/web.d.ts +35 -0
  68. package/web.js +50 -0
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Orgs in the shell, when the app serves many (`useOrgs`), through the web
3
+ * shell's `orgs` slot: the switcher at the top of the sidebar, where the
4
+ * app's identity sits (`orgs.switcher`: the org you're in, your standing
5
+ * there; opened, your orgs, Personal first-class, invitations waiting with a
6
+ * badge, to join or decline in place, a new org, the org's settings, and for
7
+ * staff, every org); beside every page (`orgs.overlay`), the small dialog
8
+ * that makes an org and going between them: a short transition while the
9
+ * page starts over in the other org, and a word once it's there; and what
10
+ * the shell's menu and palette list (`useShellOrgs`). Staff in an org that
11
+ * isn't theirs see it, quietly and all the time (a line along the top of
12
+ * the window): what they do is on its record.
13
+ */
14
+ import { type ReactNode } from "react";
15
+ import type { ViewContext } from "copilotz";
16
+ import { type PaletteGroup } from "copilotz/web";
17
+ import { type Org, type Orgs } from "./orgs.js";
18
+ import { type OrgsShown, type Standing } from "copilotz/plugins/interfaces/contract";
19
+ type Call = <R = unknown>(action: string, input?: unknown) => Promise<R>;
20
+ /** The directory front end's styles, with whatever of it is drawn. */
21
+ export declare const style: import("react").JSX.Element;
22
+ /**
23
+ * The switcher (`orgs.switcher`, the `orgs` slot's): where you are among your orgs, at the top
24
+ * of the sidebar, once they're known (the shell draws it once `useShellOrgs` answers).
25
+ */
26
+ export declare const switcherView: (_: unknown, ctx: ViewContext<ReactNode>) => ReactNode;
27
+ /**
28
+ * Beside every page (`orgs.overlay`, the `orgs` slot's), outside the sidebar, which is a drawer
29
+ * on a phone: the line along the top while in an org as staff, the dialog that makes an org,
30
+ * and going into one.
31
+ */
32
+ export declare const overlayView: () => ReactNode;
33
+ /**
34
+ * What the shell's own parts list of the person's orgs (the `orgs` slot's hook): their email,
35
+ * the org's page and (for staff) every org in their menu, and orgs in the palette. Nothing until
36
+ * the orgs are known, or where the server serves one.
37
+ */
38
+ export declare function useShellOrgs(call: Call): OrgsShown | undefined;
39
+ /** Opens the dialog that makes an org. */
40
+ export declare const openNewOrg: () => void;
41
+ /** An org's face: yours (Personal) is you; a team's, its initials. */
42
+ export declare function OrgFace({ org, person, size }: {
43
+ org: Pick<Org, "name" | "kind"> & {
44
+ id?: string;
45
+ };
46
+ person: string;
47
+ size?: number;
48
+ }): ReactNode;
49
+ export declare function OrgSwitcher({ orgs, here, standing, staff, onNew }: {
50
+ orgs: Orgs;
51
+ /** The org the person is in. */
52
+ here?: Org;
53
+ standing?: Standing;
54
+ /** In it as platform staff. */
55
+ staff: boolean;
56
+ /** Opens the dialog that makes one. */
57
+ onNew(): void;
58
+ }): ReactNode;
59
+ /** The small dialog that makes a team org: its name, then you're in it, its owner. */
60
+ export declare function NewOrg({ open, onClose }: {
61
+ open: boolean;
62
+ onClose(): void;
63
+ }): ReactNode;
64
+ /** While the page goes into another org: its face and name, over everything, until it's there. */
65
+ export declare function Switching(): ReactNode;
66
+ /**
67
+ * What the palette offers for orgs: the others to switch to, invitations to
68
+ * join or decline (with the spaces' own, under one heading), a new org, the
69
+ * org's settings, and for staff, every org.
70
+ */
71
+ export declare function orgsPalette(orgs: Orgs, here: Org | undefined, standing: Standing | undefined): PaletteGroup[];
72
+ export {};
@@ -0,0 +1,354 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Orgs in the shell, when the app serves many (`useOrgs`), through the web
4
+ * shell's `orgs` slot: the switcher at the top of the sidebar, where the
5
+ * app's identity sits (`orgs.switcher`: the org you're in, your standing
6
+ * there; opened, your orgs, Personal first-class, invitations waiting with a
7
+ * badge, to join or decline in place, a new org, the org's settings, and for
8
+ * staff, every org); beside every page (`orgs.overlay`), the small dialog
9
+ * that makes an org and going between them: a short transition while the
10
+ * page starts over in the other org, and a word once it's there; and what
11
+ * the shell's menu and palette list (`useShellOrgs`). Staff in an org that
12
+ * isn't theirs see it, quietly and all the time (a line along the top of
13
+ * the window): what they do is on its record.
14
+ */
15
+ import { useEffect, useRef, useState, useSyncExternalStore, } from "react";
16
+ import { Avatar, Badge, Button, Dialog, Field, Icon, Input, lang, message, Notice, Popover, Spinner, Time, } from "copilotz/web";
17
+ import { answerOrgInvite, arrived, asStaff, createOrg, enterOrg, orgName, useOrgs, useSwitching, } from "./orgs.js";
18
+ import { orgRoleName, runs, useStanding, } from "copilotz/plugins/interfaces/contract";
19
+ import { standingName } from "./lists.js";
20
+ import { STYLE } from "./style.js";
21
+ import { say } from "./words.js";
22
+ /** The directory front end's styles, with whatever of it is drawn. */
23
+ export const style = _jsx("style", { href: "directory-web", precedence: "copilotz", children: STYLE });
24
+ /**
25
+ * The switcher (`orgs.switcher`, the `orgs` slot's): where you are among your orgs, at the top
26
+ * of the sidebar, once they're known (the shell draws it once `useShellOrgs` answers).
27
+ */
28
+ export const switcherView = (_, ctx) => (_jsx(Switcher, { call: ctx.call }));
29
+ function Switcher({ call }) {
30
+ const orgs = useOrgs();
31
+ const ready = orgs.status === "ready";
32
+ const standing = useStanding(call, ready);
33
+ if (!ready)
34
+ return null;
35
+ return (_jsxs(_Fragment, { children: [style, _jsx(OrgSwitcher, { orgs: orgs.value, here: orgs.here, standing: standing, staff: asStaff(orgs.value), onNew: openNewOrg })] }));
36
+ }
37
+ /**
38
+ * Beside every page (`orgs.overlay`, the `orgs` slot's), outside the sidebar, which is a drawer
39
+ * on a phone: the line along the top while in an org as staff, the dialog that makes an org,
40
+ * and going into one.
41
+ */
42
+ export const overlayView = () => _jsx(Overlay, {});
43
+ function Overlay() {
44
+ const orgs = useOrgs();
45
+ const making = useSyncExternalStore(newOrg.subscribe, newOrg.get, newOrg.get);
46
+ const ready = orgs.status === "ready";
47
+ return (_jsxs(_Fragment, { children: [style, ready && asStaff(orgs.value)
48
+ ? (_jsx("div", { className: "copilotz-staff-line", role: "note", children: _jsx("span", { className: "copilotz-sr", children: say("staffLine") }) }))
49
+ : null, ready ? _jsx(NewOrg, { open: making, onClose: closeNewOrg }) : null, _jsx(Switching, {})] }));
50
+ }
51
+ /**
52
+ * What the shell's own parts list of the person's orgs (the `orgs` slot's hook): their email,
53
+ * the org's page and (for staff) every org in their menu, and orgs in the palette. Nothing until
54
+ * the orgs are known, or where the server serves one.
55
+ */
56
+ export function useShellOrgs(call) {
57
+ const orgs = useOrgs();
58
+ const ready = orgs.status === "ready";
59
+ const standing = useStanding(call, ready);
60
+ if (!ready)
61
+ return undefined;
62
+ const { value, here } = orgs;
63
+ return {
64
+ email: value.email,
65
+ menu: [
66
+ ...(here
67
+ ? [{
68
+ label: runs(standing) ? say("orgSettings") : say("aboutOrg"),
69
+ icon: "settings",
70
+ href: "/org",
71
+ }]
72
+ : []),
73
+ ...(value.staff
74
+ ? [{ label: say("allOrgsConsole"), icon: "server", href: "/console" }]
75
+ : []),
76
+ ],
77
+ palette: orgsPalette(value, here, standing),
78
+ };
79
+ }
80
+ /** Whether the dialog that makes an org is open: the switcher opens it, the overlay draws it. */
81
+ let making = false;
82
+ const makers = new Set();
83
+ const newOrg = {
84
+ subscribe(listener) {
85
+ makers.add(listener);
86
+ return () => makers.delete(listener);
87
+ },
88
+ get: () => making,
89
+ };
90
+ const setMaking = (open) => {
91
+ making = open;
92
+ for (const listener of makers)
93
+ listener();
94
+ };
95
+ /** Opens the dialog that makes an org. */
96
+ export const openNewOrg = () => setMaking(true);
97
+ const closeNewOrg = () => setMaking(false);
98
+ /** The words a phrase gives to find an item by (its keywords), apart. */
99
+ const keywords = (key) => say(key).split(/\s+/).filter(Boolean);
100
+ /** An org's face: yours (Personal) is you; a team's, its initials. */
101
+ export function OrgFace({ org, person, size = 26 }) {
102
+ return org.kind === "personal"
103
+ ? _jsx(Avatar, { name: person, size: size })
104
+ : _jsx(Avatar, { name: org.name, kind: "org", size: size, ...(org.id ? { tint: org.id } : {}) });
105
+ }
106
+ /** What the switcher says under the org's name: your standing there. */
107
+ function subline(org, standing, staff) {
108
+ if (staff)
109
+ return say("staffAccess");
110
+ if (org?.kind === "personal")
111
+ return say("justYou");
112
+ return standingName(standing) || " ";
113
+ }
114
+ export function OrgSwitcher({ orgs, here, standing, staff, onNew }) {
115
+ const [failed, setFailed] = useState();
116
+ /** Goes in or back as staff: the page starts over, or it stays and says why. */
117
+ const switchTo = (org, staff) => {
118
+ setFailed(undefined);
119
+ enterOrg(org, staff).catch((e) => setFailed(message(e)));
120
+ };
121
+ const waiting = orgs.invites.length;
122
+ const name = here ? orgName(here) : say("organization");
123
+ const mine = [...orgs.orgs].sort((a, b) => Number(b.kind === "personal") - Number(a.kind === "personal") ||
124
+ a.name.localeCompare(b.name, undefined, { sensitivity: "base" }));
125
+ return (_jsx(Popover, { label: say("yourOrgs"), width: 312, className: "copilotz-orgs", trigger: (props) => (_jsxs("button", { type: "button", ...props, className: "copilotz-org", "data-staff": staff || undefined, title: staff ? say("inAsStaffTitle", { name }) : say("switchOrg", { name }), children: [here
126
+ ? _jsx(OrgFace, { org: here, person: orgs.person, size: 28 })
127
+ : _jsx(Avatar, { name: name, kind: "org", size: 28 }), _jsxs("span", { className: "copilotz-org-text", children: [_jsx("span", { className: "copilotz-org-name", children: name }), _jsxs("span", { className: "copilotz-org-sub", children: [staff ? _jsx(Icon, { name: "shield", size: 12 }) : null, subline(here, standing, staff)] })] }), waiting
128
+ ? (_jsx("span", { className: "copilotz-org-dot", "aria-label": say("invitationsCount", { count: waiting }), children: waiting }))
129
+ : null, _jsx(Icon, { name: "selector", size: 15, className: "copilotz-org-chevron" })] })), children: (close) => (_jsxs("div", { className: "copilotz-orgs-box", children: [_jsx("p", { className: "copilotz-orgs-who", children: say.nodes("signedInAs", { who: _jsx("b", { children: orgs.email ?? orgs.person }) }) }), staff && here
130
+ ? (_jsxs("div", { className: "copilotz-orgs-staff", children: [_jsx(Icon, { name: "shield", size: 15 }), _jsxs("span", { children: [say.nodes("inAsStaff", { name: _jsx("b", { children: here.name }) }), standing?.role
131
+ ? (_jsx("button", { type: "button", "data-popover-item": true, className: "copilotz-orgs-staff-back", onClick: () => switchTo(here, false), children: say("continueAs", { role: standingName(standing) }) }))
132
+ : null] })] }))
133
+ : null, failed ? _jsx(Notice, { tone: "destructive", role: "alert", children: failed }) : null, _jsx("ul", { className: "copilotz-orgs-list", "aria-label": say("organizations"), children: mine.map((org) => (_jsx("li", { children: _jsx(OrgRow, { org: org, person: orgs.person, current: org.id === orgs.current, close: close }) }, org.id))) }), waiting
134
+ ? (_jsxs("section", { className: "copilotz-orgs-invites", "aria-labelledby": "copilotz-orgs-invites", children: [_jsxs("h3", { id: "copilotz-orgs-invites", children: [say("invitations"), " ", _jsx(Badge, { tone: "primary", children: waiting })] }), _jsx("ul", { children: orgs.invites.map((invite) => (_jsx("li", { children: _jsx(InviteRow, { invite: invite, close: close }) }, invite.id))) })] }))
135
+ : null, _jsxs("div", { className: "copilotz-orgs-actions", children: [_jsxs("button", { type: "button", "data-popover-item": true, className: "copilotz-orgs-action", onClick: () => {
136
+ close();
137
+ onNew();
138
+ }, children: [_jsx("span", { className: "copilotz-orgs-icon copilotz-orgs-icon-new", children: _jsx(Icon, { name: "plus", size: 15 }) }), say("newOrgMore")] }), here && (runs(standing) || standing?.role)
139
+ ? (_jsxs("a", { "data-popover-item": true, className: "copilotz-orgs-action", href: "/org", onClick: close, children: [_jsx("span", { className: "copilotz-orgs-icon", children: _jsx(Icon, { name: "settings", size: 15 }) }), runs(standing) ? say("orgSettings") : say("aboutOrg")] }))
140
+ : null, orgs.staff && here && !staff
141
+ ? (_jsxs("button", { type: "button", "data-popover-item": true, className: "copilotz-orgs-action", onClick: () => switchTo(here, true), children: [_jsx("span", { className: "copilotz-orgs-icon", children: _jsx(Icon, { name: "shield", size: 15 }) }), say("enterAsStaff")] }))
142
+ : null, orgs.staff
143
+ ? (_jsxs("a", { "data-popover-item": true, className: "copilotz-orgs-action", href: "/console", onClick: close, children: [_jsx("span", { className: "copilotz-orgs-icon", children: _jsx(Icon, { name: "server", size: 15 }) }), say("allOrgsConsole")] }))
144
+ : null] })] })) }));
145
+ }
146
+ /** One of your orgs: going into it, or where you are (a check). A suspended one says so. */
147
+ function OrgRow({ org, person, current, close }) {
148
+ const [error, setError] = useState();
149
+ const suspended = !!org.suspended && !current;
150
+ return (_jsxs("button", { type: "button", "data-popover-item": true, className: "copilotz-orgs-row", "aria-current": current || undefined, "aria-disabled": suspended || undefined, title: suspended ? say("suspendedTitle", { name: org.name }) : undefined, onClick: () => {
151
+ if (suspended)
152
+ return;
153
+ if (current)
154
+ return close();
155
+ setError(undefined);
156
+ const going = enterOrg(org);
157
+ close();
158
+ going.catch((e) => setError(message(e)));
159
+ }, children: [_jsx(OrgFace, { org: org, person: person, size: 28 }), _jsxs("span", { className: "copilotz-orgs-row-text", children: [_jsx("span", { className: "copilotz-orgs-row-name", children: orgName(org) }), error
160
+ ? _jsx("span", { className: "copilotz-orgs-row-error", children: error })
161
+ : org.kind === "personal"
162
+ ? _jsx("span", { className: "copilotz-orgs-row-sub", children: say("yourOwn") })
163
+ : null] }), suspended ? _jsx(Badge, { tone: "warning", children: say("suspended") }) : null, current ? _jsx(Icon, { name: "check", size: 16, className: "copilotz-orgs-check" }) : null] }));
164
+ }
165
+ /** An invitation to an org, answered in place: joining goes into it. */
166
+ function InviteRow({ invite, close }) {
167
+ const [busy, setBusy] = useState();
168
+ const [error, setError] = useState();
169
+ const answer = (accept) => {
170
+ setBusy(accept ? "join" : "decline");
171
+ setError(undefined);
172
+ const answered = answerOrgInvite(invite, accept);
173
+ // Joining goes into it: the transition shows over everything.
174
+ if (accept)
175
+ close();
176
+ answered.catch((e) => {
177
+ setError(message(e));
178
+ setBusy(undefined);
179
+ });
180
+ };
181
+ return (_jsxs("div", { className: "copilotz-orgs-invite", children: [_jsx(Avatar, { name: invite.name, kind: "org", size: 28, tint: invite.org }), _jsxs("div", { className: "copilotz-orgs-invite-text", children: [_jsx("p", { className: "copilotz-orgs-invite-name", children: invite.name }), _jsx("p", { className: "copilotz-orgs-invite-meta", children: error ?? say.nodes(invite.from ? "invitedFromAsAt" : "invitedAsAt", {
182
+ from: invite.from ?? "",
183
+ role: orgRoleName(invite.role).toLocaleLowerCase(lang()),
184
+ time: _jsx(Time, { at: invite.at }),
185
+ }) }), _jsxs("div", { className: "copilotz-orgs-invite-answers", children: [_jsx(Button, { size: "sm", variant: "primary", "data-popover-item": true, loading: busy === "join", disabled: !!busy, onClick: () => answer(true), children: say("join") }), _jsx(Button, { size: "sm", variant: "ghost", "data-popover-item": true, loading: busy === "decline", disabled: !!busy, onClick: () => answer(false), children: say("decline") })] })] })] }));
186
+ }
187
+ /** Names longer than this aren't taken. */
188
+ const LONGEST = 80;
189
+ /** The small dialog that makes a team org: its name, then you're in it, its owner. */
190
+ export function NewOrg({ open, onClose }) {
191
+ const [name, setName] = useState("");
192
+ const [busy, setBusy] = useState(false);
193
+ const [error, setError] = useState();
194
+ useEffect(() => {
195
+ if (!open) {
196
+ setName("");
197
+ setError(undefined);
198
+ setBusy(false);
199
+ }
200
+ }, [open]);
201
+ const typed = name.trim();
202
+ const long = typed.length > LONGEST;
203
+ const create = async (event) => {
204
+ event?.preventDefault();
205
+ if (!typed || long || busy)
206
+ return;
207
+ setBusy(true);
208
+ setError(undefined);
209
+ try {
210
+ await createOrg(typed);
211
+ }
212
+ catch (e) {
213
+ setError(message(e));
214
+ setBusy(false);
215
+ }
216
+ };
217
+ return (_jsx(Dialog, { open: open, onClose: onClose, size: "sm", title: say("newOrg"), description: say("newOrgAbout"), footer: _jsxs(_Fragment, { children: [_jsx(Button, { variant: "ghost", onClick: onClose, disabled: busy, children: say("cancel") }), _jsx(Button, { variant: "primary", loading: busy, disabled: !typed || long, onClick: () => void create(), children: say("createOrg") })] }), children: _jsxs("form", { onSubmit: create, className: "copilotz-new-org", children: [_jsx("div", { className: "copilotz-new-org-preview", "aria-hidden": "true", children: _jsx(Avatar, { name: typed || "?", kind: "org", size: 44 }) }), _jsx(Field, { label: say("name"), hint: long ? undefined : say("newOrgNameHint"), error: long ? say("atMost", { count: LONGEST }) : error, children: (control) => (_jsx(Input, { ...control, value: name, onChange: (e) => setName(e.target.value), placeholder: say("newOrgPlaceholder"), autoComplete: "organization", maxLength: LONGEST + 20, autoFocus: true })) })] }) }));
218
+ }
219
+ /** While the page goes into another org: its face and name, over everything, until it's there. */
220
+ export function Switching() {
221
+ const to = useSwitching();
222
+ const [welcome, setWelcome] = useState();
223
+ const layer = useRef(null);
224
+ // Over everything, a dialog that started it included: a modal of its own, on top.
225
+ useEffect(() => {
226
+ if (to && !layer.current?.open)
227
+ layer.current?.showModal();
228
+ }, [to]);
229
+ useEffect(() => {
230
+ const came = arrived();
231
+ if (!came)
232
+ return;
233
+ setWelcome(came);
234
+ const done = setTimeout(() => setWelcome(undefined), came.staff || came.moved ? 5200 : 2600);
235
+ return () => clearTimeout(done);
236
+ }, []);
237
+ return (_jsxs(_Fragment, { children: [to
238
+ ? (_jsx("dialog", { ref: layer, className: "copilotz-switching", "aria-live": "assertive", "aria-label": say("goingInto", { name: orgName(to) }),
239
+ // It ends when the page starts over, not on Escape.
240
+ onCancel: (event) => event.preventDefault(), children: _jsxs("div", { className: "copilotz-switching-box", children: [to.kind === "personal"
241
+ ? (_jsx("span", { className: "copilotz-switching-personal", children: _jsx(Icon, { name: "person", size: 26 }) }))
242
+ : (_jsx(Avatar, { name: to.name, kind: "org", size: 56, ...(to.id ? { tint: to.id } : {}) })), _jsx("p", { className: "copilotz-switching-label", children: to.staff ? say("enteringAsStaff") : say("switchingTo") }), _jsx("p", { className: "copilotz-switching-name", children: orgName(to) }), _jsx(Spinner, { variant: "dots", size: 6 })] }) }))
243
+ : null, welcome && !to
244
+ ? (_jsxs("div", { className: "copilotz-arrived", role: "status", "data-staff": welcome.staff || undefined, "data-long": welcome.staff || welcome.moved || undefined, children: [welcome.staff
245
+ ? _jsx(Icon, { name: "shield", size: 16 })
246
+ : _jsx(Icon, { name: welcome.moved ? "info" : "check", size: 16 }), _jsx("span", { children: welcome.staff
247
+ ? say.nodes("inAsStaff", { name: _jsx("b", { children: welcome.name }) })
248
+ : welcome.moved
249
+ ? say.nodes("movedOrg", { name: _jsx("b", { children: orgName(welcome) }) })
250
+ : say.nodes("youreIn", { name: _jsx("b", { children: orgName(welcome) }) }) })] }))
251
+ : null] }));
252
+ }
253
+ /** Making a team org from the palette: its name, then you're in it. */
254
+ const newOrgStep = () => ({
255
+ title: say("newOrg"),
256
+ placeholder: say("nameIt"),
257
+ note: say("newOrgAbout"),
258
+ filter: false,
259
+ items: (search) => {
260
+ const name = search.trim();
261
+ if (!name)
262
+ return [];
263
+ const long = name.length > LONGEST;
264
+ return [{
265
+ title: "",
266
+ items: [{
267
+ key: "org:create",
268
+ label: say("createNamed", { name }),
269
+ icon: "plus",
270
+ disabled: long,
271
+ ...(long ? { description: say("atMost", { count: LONGEST }) } : {}),
272
+ run: () => createOrg(name),
273
+ }],
274
+ }];
275
+ },
276
+ });
277
+ /**
278
+ * What the palette offers for orgs: the others to switch to, invitations to
279
+ * join or decline (with the spaces' own, under one heading), a new org, the
280
+ * org's settings, and for staff, every org.
281
+ */
282
+ export function orgsPalette(orgs, here, standing) {
283
+ const others = orgs.orgs.filter((o) => o.id !== orgs.current);
284
+ const groups = [{
285
+ title: say("organizations"),
286
+ order: 25,
287
+ items: [
288
+ ...others.map((org) => ({
289
+ key: `org:${org.id}`,
290
+ label: say("switchTo", { name: orgName(org) }),
291
+ leading: _jsx(OrgFace, { org: org, person: orgs.person, size: 26 }),
292
+ ...(org.suspended
293
+ ? { description: say("suspended"), disabled: true }
294
+ : org.kind === "personal"
295
+ ? { description: say("yourOwnOrg") }
296
+ : {}),
297
+ keywords: [...keywords("keysSwitch"), org.name],
298
+ run: () => enterOrg(org),
299
+ })),
300
+ {
301
+ key: "org:new",
302
+ label: say("newOrgMore"),
303
+ icon: "plus",
304
+ keywords: keywords("keysNewOrg"),
305
+ step: newOrgStep(),
306
+ },
307
+ ...(here
308
+ ? [{
309
+ key: "org:settings",
310
+ label: runs(standing) ? say("orgSettings") : say("aboutOrg"),
311
+ icon: "settings",
312
+ keywords: keywords("keysOrgSettings"),
313
+ href: "/org",
314
+ }]
315
+ : []),
316
+ ...(orgs.staff
317
+ ? [{
318
+ key: "org:console",
319
+ label: say("allOrgsConsole"),
320
+ icon: "server",
321
+ keywords: keywords("keysConsole"),
322
+ href: "/console",
323
+ }]
324
+ : []),
325
+ ],
326
+ }];
327
+ if (orgs.invites.length) {
328
+ groups.unshift({
329
+ title: say("invitations"),
330
+ order: 5,
331
+ items: orgs.invites.flatMap((invite) => [
332
+ {
333
+ key: `org-invite:${invite.id}`,
334
+ label: say("joinNamed", { name: invite.name }),
335
+ leading: _jsx(Avatar, { name: invite.name, kind: "org", size: 26, tint: invite.org }),
336
+ description: say(invite.from ? "invitedFromAs" : "invitedAs", {
337
+ from: invite.from ?? "",
338
+ role: orgRoleName(invite.role).toLocaleLowerCase(lang()),
339
+ }),
340
+ keywords: keywords("keysAcceptOrgInvite"),
341
+ run: () => answerOrgInvite(invite, true),
342
+ },
343
+ {
344
+ key: `org-decline:${invite.id}`,
345
+ label: say("declineOrgInvite", { name: invite.name }),
346
+ icon: "close",
347
+ keywords: keywords("keysOrgInvite"),
348
+ run: () => answerOrgInvite(invite, false),
349
+ },
350
+ ]),
351
+ });
352
+ }
353
+ return groups;
354
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The words of the directory's front end, in English: the org switcher, going between orgs, the
3
+ * org's page and staff's console keep the keys they had in the web shell (`shell.<key>`), so an
4
+ * app's own words for them still hold; what an org is called where it shows is `directory.<key>`.
5
+ */
6
+ import { type Phrase } from "copilotz/web/words";
7
+ export declare const say: import("copilotz/web/words").Say<"personal" | "team" | "placement" | "join" | "staff" | "cancel" | "name" | "status" | "suspended" | "rename" | "people" | "spaces" | "active" | "goHome" | "staffLine" | "orgSettings" | "aboutOrg" | "allOrgsConsole" | "organization" | "oneOrg" | "oneOrgAbout" | "notInOrg" | "chooseOrg" | "personalOrg" | "teamOrg" | "staffAccess" | "orgAboutStaff" | "orgAboutPersonal" | "orgAboutRuns" | "orgAboutGuest" | "orgAboutMember" | "orgSection" | "heldBack" | "orgSettingsOf" | "nothingToSet" | "nothingToSetAbout" | "justYou" | "yourOrgs" | "organizations" | "inAsStaffTitle" | "switchOrg" | "invitationsCount" | "signedInAs" | "inAsStaff" | "continueAs" | "invitations" | "newOrgMore" | "enterAsStaff" | "suspendedTitle" | "yourOwn" | "invitedFromAsAt" | "invitedAsAt" | "invitedFromAs" | "invitedAs" | "joinNamed" | "decline" | "newOrg" | "newOrgAbout" | "createOrg" | "newOrgNameHint" | "atMost" | "newOrgPlaceholder" | "goingInto" | "enteringAsStaff" | "switchingTo" | "movedOrg" | "youreIn" | "nameIt" | "createNamed" | "switchTo" | "yourOwnOrg" | "declineOrgInvite" | "keysSwitch" | "keysNewOrg" | "keysOrgSettings" | "keysConsole" | "keysAcceptOrgInvite" | "keysOrgInvite" | "filterAll" | "filterTeams" | "giftCodes" | "consoleTitle" | "forStaff" | "forStaffAbout" | "consoleShows" | "giftCodesAbout" | "consoleAbout" | "refresh" | "teamOrgs" | "searchPlaceholder" | "searchOrgs" | "whichOrgs" | "lastActive" | "actions" | "noMatch" | "nothingMatches" | "nothingYet" | "footAll" | "footSome" | "hereAsStaff" | "youreHere" | "copyOrgId" | "notYet" | "inItAsStaff" | "goIntoAsStaff" | "moreOf" | "renameMore" | "liftMore" | "suspendMore" | "moveMore" | "exportRows" | "deleteMore" | "unsupported" | "renamedTo" | "renameOrg" | "renameOrgAbout" | "liftTitle" | "suspendTitle" | "openAgain" | "isSuspended" | "lift" | "suspend" | "liftAbout" | "suspendAbout" | "nowLivesIn" | "moveTitle" | "moveAbout" | "moveRows" | "moveText" | "nowIn" | "newSchema" | "sameSchema" | "schemaRule" | "isDeleted" | "deleteTitle" | "deleteForGood" | "cantUndo" | "deleteAbout" | "exportFirst" | "typeToConfirm" | "codeWaiting" | "codeClaimed" | "codeRevoked" | "codeExpired" | "sayDollars" | "codesCount" | "newGiftCode" | "tryAgain" | "noCodes" | "noCodesAbout" | "termsLapse" | "termsNoLapse" | "termsLapseClaim" | "termsNoLapseClaim" | "codeShortTitle" | "codeMade" | "claimedBy" | "takeBack" | "makeCode" | "makeTheCode" | "credits" | "lapseOn" | "lapseHint" | "claimBy" | "claimHint" | "whatFor" | "whatForHint" | "notePlaceholder" | "yourCode" | "keptIt" | "copyCode" | "notShownAgain" | "notShownAgainAbout" | "takeBackTitle" | "takeItBack" | "takeBackAbout">;
8
+ export declare const sayOrg: import("copilotz/web/words").Say<"personalOrg">;
9
+ /** Every word of the directory's front end, by area (WORDS.md lists them). */
10
+ export declare const PHRASES: Record<string, Record<string, Phrase>>;
@@ -0,0 +1,201 @@
1
+ /**
2
+ * The words of the directory's front end, in English: the org switcher, going between orgs, the
3
+ * org's page and staff's console keep the keys they had in the web shell (`shell.<key>`), so an
4
+ * app's own words for them still hold; what an org is called where it shows is `directory.<key>`.
5
+ */
6
+ import { defineWords } from "copilotz/web/words";
7
+ const shell = {
8
+ // Going home, and staff in an org (org.tsx, switcher.tsx)
9
+ goHome: "Go home",
10
+ staffLine: "You're in this org as platform staff: what you do is on its record.",
11
+ // In the account menu and the palette (web.tsx)
12
+ orgSettings: "Organization settings",
13
+ aboutOrg: "About this organization",
14
+ allOrgsConsole: "All orgs (console)",
15
+ // Standing (lists.ts)
16
+ staff: "Staff",
17
+ // The org's page (org.tsx)
18
+ organization: "Organization",
19
+ oneOrg: "One organization here",
20
+ oneOrgAbout: "This app serves a single organization, so there's nothing to set here.",
21
+ notInOrg: "You're not in an organization",
22
+ chooseOrg: "Choose one from the switcher at the top of the sidebar.",
23
+ personalOrg: "Personal org",
24
+ teamOrg: "Team org",
25
+ staffAccess: "Staff access",
26
+ orgAboutStaff: "You're here as platform staff: what you do is on {name}'s record.",
27
+ orgAboutPersonal: "Your own organization: just you, and what you make alone.",
28
+ orgAboutRuns: "Who's in {name}, what it uses, and what it's called.",
29
+ orgAboutGuest: "What {name} is. As a guest, you work in the spaces you're invited to.",
30
+ orgAboutMember: "What {name} is, and who's in it.",
31
+ orgSection: "{name}: {section}",
32
+ heldBack: "{section} is for this org's owners and admins. Ask one of them if you need something changed there.",
33
+ orgSettingsOf: "{name}'s settings",
34
+ nothingToSet: "Nothing to set here",
35
+ nothingToSetAbout: "This app adds no sections to an organization's page.",
36
+ // Orgs: the switcher, the new-org dialog, going between orgs, the palette (switcher.tsx)
37
+ justYou: "Just you",
38
+ yourOrgs: "Your organizations",
39
+ organizations: "Organizations",
40
+ inAsStaffTitle: "You're in {name} as platform staff: what you do is on its record",
41
+ switchOrg: "{name}: switch organization",
42
+ invitationsCount: "{count} invitations",
43
+ signedInAs: "Signed in as {who}",
44
+ inAsStaff: "You're in {name} as staff. What you do here is on its record.",
45
+ continueAs: "Continue as {role}",
46
+ invitations: "Invitations",
47
+ newOrgMore: "New organization…",
48
+ enterAsStaff: "Enter as staff",
49
+ suspendedTitle: "{name} is suspended: nobody goes in for now",
50
+ yourOwn: "Your own",
51
+ suspended: "Suspended",
52
+ invitedFromAsAt: "{from} invited you, as {role} · {time}",
53
+ invitedAsAt: "You're invited, as {role} · {time}",
54
+ invitedFromAs: "{from} invited you, as {role}",
55
+ invitedAs: "You're invited, as {role}",
56
+ join: "Join",
57
+ joinNamed: "Join {name}",
58
+ decline: "Decline",
59
+ newOrg: "New organization",
60
+ newOrgAbout: "For a team: you'll own it, and invite people by email.",
61
+ cancel: "Cancel",
62
+ createOrg: "Create organization",
63
+ name: "Name",
64
+ newOrgNameHint: "Usually your team's or company's name. You can change it later.",
65
+ atMost: "At most {count} characters",
66
+ newOrgPlaceholder: "e.g. Acme",
67
+ goingInto: "Going into {name}",
68
+ enteringAsStaff: "Entering as staff",
69
+ switchingTo: "Switching to",
70
+ movedOrg: "You're no longer in the org you were in. You're in {name}.",
71
+ youreIn: "You're in {name}",
72
+ nameIt: "Name it",
73
+ createNamed: "Create “{name}”",
74
+ switchTo: "Switch to {name}",
75
+ yourOwnOrg: "Your own org",
76
+ declineOrgInvite: "Decline {name}'s invitation",
77
+ // Words the palette finds an item by, apart by spaces
78
+ keysSwitch: "organization org switch",
79
+ keysNewOrg: "create team organization org",
80
+ keysOrgSettings: "members usage invite roles organization",
81
+ keysConsole: "staff console platform suspend",
82
+ keysAcceptOrgInvite: "invitation accept organization",
83
+ keysOrgInvite: "invitation organization",
84
+ // Staff's console (console.tsx)
85
+ filterAll: "All",
86
+ filterTeams: "Teams",
87
+ personal: "Personal",
88
+ giftCodes: "Gift codes",
89
+ consoleTitle: "Console",
90
+ forStaff: "For platform staff",
91
+ forStaffAbout: "The console lists every organization, for the people who run this app.",
92
+ consoleShows: "What the console shows",
93
+ giftCodesAbout: "Credits waiting to be claimed. Someone who runs an org types one in under Billing, and its credits are that org's.",
94
+ consoleAbout: "Every org on this app: what each last reported, where its rows live, and what you can do about it. Nothing here reads an org's content.",
95
+ refresh: "Refresh",
96
+ teamOrgs: "Team orgs",
97
+ people: "People",
98
+ searchPlaceholder: "Search by name, id, schema or maker",
99
+ searchOrgs: "Search organizations",
100
+ whichOrgs: "Which organizations",
101
+ spaces: "Spaces",
102
+ lastActive: "Last active",
103
+ placement: "Placement",
104
+ status: "Status",
105
+ actions: "Actions",
106
+ noMatch: "No organization matches",
107
+ nothingMatches: "Nothing matches “{search}”",
108
+ nothingYet: "Nothing in this list yet.",
109
+ footAll: {
110
+ one: "{count} organization · the most recently active first",
111
+ other: "{count} organizations · the most recently active first",
112
+ },
113
+ footSome: "{shown} of {total} organizations · the most recently active first",
114
+ hereAsStaff: "You're here as staff",
115
+ youreHere: "You're here",
116
+ team: "Team",
117
+ copyOrgId: "Copy the org's id",
118
+ notYet: "Not yet",
119
+ active: "Active",
120
+ inItAsStaff: "You're in it as staff",
121
+ goIntoAsStaff: "Go into {name} as staff: what you do there is on its record",
122
+ moreOf: "{name}: more",
123
+ renameMore: "Rename…",
124
+ liftMore: "Lift the suspension…",
125
+ suspendMore: "Suspend…",
126
+ moveMore: "Move to another schema…",
127
+ exportRows: "Export its rows (SQL)",
128
+ deleteMore: "Delete for good…",
129
+ unsupported: "This app doesn't do that yet. ({reason})",
130
+ renamedTo: "Renamed to “{name}”.",
131
+ renameOrg: "Rename organization",
132
+ renameOrgAbout: "Its people see the new name at once, everywhere.",
133
+ rename: "Rename",
134
+ liftTitle: "Lift the suspension of {name}?",
135
+ suspendTitle: "Suspend {name}?",
136
+ openAgain: "{name} is open again.",
137
+ isSuspended: "{name} is suspended.",
138
+ lift: "Lift the suspension",
139
+ suspend: "Suspend",
140
+ liftAbout: "Its people can go in again, as before. Nothing in it changed while it was suspended.",
141
+ suspendAbout: "Nobody but staff goes in until you lift it: its people see that it's suspended. Nothing in it is changed or deleted.",
142
+ nowLivesIn: "{name} now lives in “{schema}”.",
143
+ moveTitle: "Move {name}",
144
+ moveAbout: "For big orgs: gives it a schema of its own, so its load and its rows stand apart from the shared pool.",
145
+ moveRows: "Move its rows",
146
+ moveText: "It's closed for a moment, its rows are copied to the new schema as they are, and it opens there on its next use. Its people may see it reconnect.",
147
+ nowIn: "Now in",
148
+ newSchema: "New schema",
149
+ sameSchema: "That's where it is now.",
150
+ schemaRule: "Lowercase letters, digits and _, starting with a letter.",
151
+ isDeleted: "{name} is deleted.",
152
+ deleteTitle: "Delete {name} for good?",
153
+ deleteForGood: "Delete for good",
154
+ cantUndo: "This can't be undone",
155
+ deleteAbout: "Everything in it goes: its people's memberships, spaces, conversations, agents, files and usage. Its people are signed out of it at once. Export its rows first if you may need them.",
156
+ exportFirst: "Export its rows (SQL) first",
157
+ typeToConfirm: "Type {name} to confirm",
158
+ // Gift codes (console-codes.tsx, codes.ts)
159
+ codeWaiting: "Waiting",
160
+ codeClaimed: "Claimed",
161
+ codeRevoked: "Taken back",
162
+ codeExpired: "Expired",
163
+ sayDollars: "Say how many dollars of credits.",
164
+ codesCount: { one: "{count} code, the newest first", other: "{count} codes, the newest first" },
165
+ newGiftCode: "New gift code",
166
+ tryAgain: "Try again",
167
+ noCodes: "No gift codes yet",
168
+ noCodesAbout: "A gift code gives whoever claims it credits for their org.",
169
+ termsLapse: "Credits lapse {lapse}",
170
+ termsNoLapse: "Credits don't lapse",
171
+ termsLapseClaim: "Credits lapse {lapse} · claim by {until}",
172
+ termsNoLapseClaim: "Credits don't lapse · claim by {until}",
173
+ codeShortTitle: "Only the start of what's kept: it can't be claimed with this",
174
+ codeMade: "· made {time}",
175
+ claimedBy: "by {org}, {day}",
176
+ takeBack: "Take back",
177
+ makeCode: "Make a {amount} code",
178
+ makeTheCode: "Make the code",
179
+ credits: "Credits",
180
+ lapseOn: "Credits lapse on",
181
+ lapseHint: "Empty: they don't lapse.",
182
+ claimBy: "Claim by",
183
+ claimHint: "Empty: any time.",
184
+ whatFor: "What it's for",
185
+ whatForHint: "Whoever claims it sees this in their history.",
186
+ notePlaceholder: "Conference, November",
187
+ yourCode: "Your {amount} gift code",
188
+ keptIt: "Done, I've kept it",
189
+ copyCode: "Copy the code",
190
+ notShownAgain: "This won't be shown again",
191
+ notShownAgainAbout: "Only a fingerprint of it is kept, so nobody can look it up later. Copy it now. If it's lost, take this one back and make another.",
192
+ takeBackTitle: "Take back this {amount} code?",
193
+ takeItBack: "Take it back",
194
+ takeBackAbout: "Nobody can claim it after this, and that can't be undone. If someone still needs it, make them a new one.",
195
+ };
196
+ /** What an org is called where it shows: everyone's own. */
197
+ const directory = { personalOrg: "Personal" };
198
+ export const say = defineWords("shell", shell);
199
+ export const sayOrg = defineWords("directory", directory);
200
+ /** Every word of the directory's front end, by area (WORDS.md lists them). */
201
+ export const PHRASES = { shell, directory };