@nanocollective/roster 0.1.0-alpha.9 → 0.1.0-beta.10
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 +6 -0
- package/dist/cli.js +4189 -1971
- package/dist/worker/assets/assets/css/base.css +327 -0
- package/dist/worker/assets/assets/css/brain.css +116 -0
- package/dist/worker/assets/assets/css/diff.css +33 -0
- package/dist/worker/assets/assets/css/graph.css +39 -0
- package/dist/worker/assets/assets/css/health.css +75 -0
- package/dist/worker/assets/assets/css/home.css +114 -0
- package/dist/worker/assets/assets/css/inbox.css +199 -0
- package/dist/worker/assets/assets/css/layout.css +181 -0
- package/dist/worker/assets/assets/css/markdown.css +96 -0
- package/dist/worker/assets/assets/css/runs.css +13 -0
- package/dist/worker/assets/assets/css/search.css +48 -0
- package/dist/worker/assets/assets/css/setup.css +194 -0
- package/dist/worker/assets/assets/js/api.js +191 -0
- package/dist/worker/assets/assets/js/app.js +500 -0
- package/dist/worker/assets/assets/js/dialog.js +196 -0
- package/dist/worker/assets/assets/js/dom.js +131 -0
- package/dist/worker/assets/assets/js/homesort.js +174 -0
- package/dist/worker/assets/assets/js/icons.js +142 -0
- package/dist/worker/assets/assets/js/inflight.js +18 -0
- package/dist/worker/assets/assets/js/lightbox.js +273 -0
- package/dist/worker/assets/assets/js/md.js +406 -0
- package/dist/worker/assets/assets/js/mdedit.js +84 -0
- package/dist/worker/assets/assets/js/mention.js +264 -0
- package/dist/worker/assets/assets/js/readiness.js +70 -0
- package/dist/worker/assets/assets/js/refresh.js +197 -0
- package/dist/worker/assets/assets/js/router.js +20 -0
- package/dist/worker/assets/assets/js/search.js +366 -0
- package/dist/worker/assets/assets/js/state.js +213 -0
- package/dist/worker/assets/assets/js/textdiff.js +96 -0
- package/dist/worker/assets/assets/js/views/app.js +145 -0
- package/dist/worker/assets/assets/js/views/brain.js +260 -0
- package/dist/worker/assets/assets/js/views/changed.js +157 -0
- package/dist/worker/assets/assets/js/views/checklist.js +115 -0
- package/dist/worker/assets/assets/js/views/credential.js +84 -0
- package/dist/worker/assets/assets/js/views/docs.js +174 -0
- package/dist/worker/assets/assets/js/views/files.js +139 -0
- package/dist/worker/assets/assets/js/views/graph.js +436 -0
- package/dist/worker/assets/assets/js/views/health.js +304 -0
- package/dist/worker/assets/assets/js/views/hire.js +593 -0
- package/dist/worker/assets/assets/js/views/home.js +621 -0
- package/dist/worker/assets/assets/js/views/inbox.js +1558 -0
- package/dist/worker/assets/assets/js/views/memory.js +150 -0
- package/dist/worker/assets/assets/js/views/org.js +195 -0
- package/dist/worker/assets/assets/js/views/orgedit.js +240 -0
- package/dist/worker/assets/assets/js/views/paste.js +216 -0
- package/dist/worker/assets/assets/js/views/prompt.js +457 -0
- package/dist/worker/assets/assets/js/views/repos.js +97 -0
- package/dist/worker/assets/assets/js/views/runonce.js +94 -0
- package/dist/worker/assets/assets/js/views/runs.js +182 -0
- package/dist/worker/assets/assets/js/views/setup.js +557 -0
- package/dist/worker/assets/assets/js/views/staff.js +291 -0
- package/dist/worker/assets/assets/js/views/todo.js +62 -0
- package/dist/worker/assets/assets/js/yaml.js +134 -0
- package/dist/worker/assets/docs-images/brain.jpg +0 -0
- package/dist/worker/assets/docs-images/home.jpg +0 -0
- package/dist/worker/assets/docs-images/org.jpg +0 -0
- package/dist/worker/assets/docs-images/prompt.jpg +0 -0
- package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
- package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
- package/dist/worker/assets/docs-images/staff.jpg +0 -0
- package/dist/worker/assets/index.html +82 -0
- package/dist/worker/index.js +5143 -0
- package/docs/README.md +2 -2
- package/docs/architecture.md +23 -4
- package/docs/charters/analyst.md +65 -0
- package/docs/charters/community.md +63 -0
- package/docs/charters/designer.md +65 -0
- package/docs/charters/devops.md +65 -0
- package/docs/charters/pm.md +70 -0
- package/docs/charters/qa.md +65 -0
- package/docs/charters/writer.md +63 -0
- package/docs/commands.md +36 -9
- package/docs/concepts.md +34 -21
- package/docs/cost.md +3 -3
- package/docs/developing.md +28 -10
- package/docs/doctor-codes.md +3 -1
- package/docs/export.md +2 -0
- package/docs/getting-started.md +49 -29
- package/docs/hosting.md +114 -43
- package/docs/images/brain.jpg +0 -0
- package/docs/images/home.jpg +0 -0
- package/docs/images/org.jpg +0 -0
- package/docs/images/prompt.jpg +0 -0
- package/docs/images/staff.jpg +0 -0
- package/docs/manual-steps.md +3 -2
- package/docs/memory.md +2 -1
- package/docs/org-yaml.md +3 -0
- package/docs/portal.md +144 -45
- package/docs/prompts.md +6 -0
- package/docs/security.md +70 -11
- package/docs/session-workflow.md +24 -6
- package/docs/staff-yaml.md +21 -2
- package/docs/upgrading.md +3 -3
- package/docs/writing-a-charter.md +19 -6
- package/package.json +4 -3
- package/templates/brain/.github/workflows/%%STAFF%%-daily.yaml +20 -1
- package/templates/brain/.github/workflows/%%STAFF%%-mention.yaml +53 -13
- package/templates/brain/CHARTER.md +2 -2
- package/templates/brain/STATE.md +16 -0
- package/templates/brain/memory/INDEX.md +1 -1
- package/templates/brain/staff.yaml +4 -1
- package/templates/briefs/amend.md +4 -3
- package/templates/briefs/priorities.md +46 -0
- package/templates/ops/.github/workflows/session.yaml +150 -3
- package/templates/ops/compose.mjs +35 -8
- package/templates/ops/org/operating.md +29 -10
- package/templates/ops/org/voice.md +2 -1
- package/templates/ops/prompts/daily.md +51 -14
- package/templates/ops/prompts/mention.md +24 -2
- package/templates/ops/run-record.mjs +5 -3
- package/templates/ops/status-week.mjs +169 -0
- package/templates/portal/css/base.css +49 -0
- package/templates/portal/css/health.css +14 -1
- package/templates/portal/css/home.css +114 -0
- package/templates/portal/css/inbox.css +21 -4
- package/templates/portal/css/layout.css +35 -3
- package/templates/portal/css/markdown.css +19 -0
- package/templates/portal/css/search.css +48 -0
- package/templates/portal/css/setup.css +79 -4
- package/templates/portal/index.html +15 -9
- package/templates/portal/js/api.js +60 -4
- package/templates/portal/js/app.js +125 -7
- package/templates/portal/js/dialog.js +36 -0
- package/templates/portal/js/homesort.js +174 -0
- package/templates/portal/js/icons.js +41 -0
- package/templates/portal/js/inflight.js +18 -0
- package/templates/portal/js/md.js +5 -2
- package/templates/portal/js/mdedit.js +84 -0
- package/templates/portal/js/readiness.js +70 -0
- package/templates/portal/js/refresh.js +10 -2
- package/templates/portal/js/search.js +366 -0
- package/templates/portal/js/state.js +11 -5
- package/templates/portal/js/views/app.js +1 -2
- package/templates/portal/js/views/brain.js +1 -1
- package/templates/portal/js/views/checklist.js +19 -4
- package/templates/portal/js/views/credential.js +42 -51
- package/templates/portal/js/views/health.js +11 -6
- package/templates/portal/js/views/hire.js +593 -0
- package/templates/portal/js/views/home.js +621 -0
- package/templates/portal/js/views/inbox.js +237 -68
- package/templates/portal/js/views/org.js +31 -111
- package/templates/portal/js/views/orgedit.js +240 -0
- package/templates/portal/js/views/paste.js +111 -66
- package/templates/portal/js/views/prompt.js +94 -40
- package/templates/portal/js/views/repos.js +10 -10
- package/templates/portal/js/views/runs.js +21 -4
- package/templates/portal/js/views/setup.js +130 -163
- package/templates/portal/js/views/staff.js +181 -301
- package/templates/portal/js/views/todo.js +62 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* The handful of DOM helpers every view uses. No framework: the portal is a few thousand
|
|
2
|
+
lines of rendering over a JSON export, and a build step would cost more than it saves. */
|
|
3
|
+
|
|
4
|
+
export const $ = (s, r = document) => r.querySelector(s);
|
|
5
|
+
|
|
6
|
+
export const el = (t, props = {}, kids = []) => {
|
|
7
|
+
const n = Object.assign(document.createElement(t), props);
|
|
8
|
+
for (const k of [].concat(kids)) n.append(k);
|
|
9
|
+
return n;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const esc = (s) =>
|
|
13
|
+
String(s ?? "").replace(
|
|
14
|
+
/[&<>"]/g,
|
|
15
|
+
(c) => ({ "&": "&", "<": "<", ">": ">", '"': """ })[c],
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
export function ago(iso) {
|
|
19
|
+
const s = (Date.now() - new Date(iso).getTime()) / 1000;
|
|
20
|
+
if (s < 90) return "just now";
|
|
21
|
+
if (s < 5400) return Math.round(s / 60) + "m ago";
|
|
22
|
+
if (s < 172800) return Math.round(s / 3600) + "h ago";
|
|
23
|
+
return Math.round(s / 86400) + "d ago";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const kb = (n) =>
|
|
27
|
+
n < 1024 ? n + "b" : n < 1048576 ? Math.round(n / 1024) + "k" : (n / 1048576).toFixed(1) + "M";
|
|
28
|
+
|
|
29
|
+
/** Rows are `.tfile` in a file tree and `.irow` in the inbox. Matching only one of them is
|
|
30
|
+
how every clicked row stayed selected. */
|
|
31
|
+
export function markCurrent(list, btn) {
|
|
32
|
+
for (const o of list.querySelectorAll('[aria-current="true"]')) {
|
|
33
|
+
o.setAttribute("aria-current", "false");
|
|
34
|
+
}
|
|
35
|
+
btn.setAttribute("aria-current", "true");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Placeholder shapes, for the seconds a screen spends asking GitHub.
|
|
40
|
+
*
|
|
41
|
+
* The inbox reads every repo in the org, which is several seconds on a cold cache, and what
|
|
42
|
+
* stood there meanwhile was the word "Asking GitHub…" in an otherwise empty box beside an
|
|
43
|
+
* empty box. Nothing about that says the shape of what is coming, so the page looked broken
|
|
44
|
+
* rather than busy.
|
|
45
|
+
*
|
|
46
|
+
* `kind` names the shape: "row" for a list item, "line" for a paragraph, "head" for a title.
|
|
47
|
+
* They are decorative, so they are hidden from assistive technology and the live region
|
|
48
|
+
* elsewhere on the screen does the announcing.
|
|
49
|
+
*/
|
|
50
|
+
export function skeleton(kind, n = 1) {
|
|
51
|
+
const out = [];
|
|
52
|
+
for (let i = 0; i < n; i++) {
|
|
53
|
+
const box = el("div", { className: "sk sk-" + kind });
|
|
54
|
+
box.setAttribute("aria-hidden", "true");
|
|
55
|
+
if (kind === "row") {
|
|
56
|
+
box.append(el("div", { className: "skbar t" }), el("div", { className: "skbar m" }));
|
|
57
|
+
}
|
|
58
|
+
out.push(box);
|
|
59
|
+
}
|
|
60
|
+
return out;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function store(k, v) {
|
|
64
|
+
try {
|
|
65
|
+
return v === undefined ? localStorage.getItem(k) : localStorage.setItem(k, v);
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** GitHub's heading slug, for in-page anchors. */
|
|
72
|
+
export function slug(text) {
|
|
73
|
+
return String(text)
|
|
74
|
+
.toLowerCase()
|
|
75
|
+
.replace(/[^\w\s-]/g, "")
|
|
76
|
+
.trim()
|
|
77
|
+
.replace(/\s+/g, "-");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Size a textarea to its content, so the card it sits in is the only thing that scrolls.
|
|
82
|
+
*
|
|
83
|
+
* The border has to be added back: everything here is `border-box`, so `height` sets the
|
|
84
|
+
* outer box while `scrollHeight` counts the padding and not the border. Two pixels short is
|
|
85
|
+
* enough to clip the last line.
|
|
86
|
+
*/
|
|
87
|
+
export function grow(ta) {
|
|
88
|
+
ta.style.height = "auto";
|
|
89
|
+
const border = (ta.offsetHeight || 0) - (ta.clientHeight || 0);
|
|
90
|
+
ta.style.height = (ta.scrollHeight || 0) + border + "px";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Put text on the clipboard and say so on the button that asked.
|
|
95
|
+
*
|
|
96
|
+
* `navigator.clipboard` needs a secure context, and http://localhost counts, but a portal
|
|
97
|
+
* bound to a LAN address does not. The textarea fallback is what makes the button work there
|
|
98
|
+
* rather than failing silently, which for a copy button is the worst outcome: you paste the
|
|
99
|
+
* last thing you copied and never notice.
|
|
100
|
+
*/
|
|
101
|
+
export async function toClipboard(text, btn, label) {
|
|
102
|
+
const said = (msg) => {
|
|
103
|
+
if (!btn) return;
|
|
104
|
+
btn.textContent = msg;
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
btn.textContent = label;
|
|
107
|
+
}, 2200);
|
|
108
|
+
};
|
|
109
|
+
try {
|
|
110
|
+
await navigator.clipboard.writeText(text);
|
|
111
|
+
said("copied · " + Math.round(text.length / 1000) + "k");
|
|
112
|
+
return true;
|
|
113
|
+
} catch {
|
|
114
|
+
/* fall through */
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
const ta = document.createElement("textarea");
|
|
118
|
+
ta.value = text;
|
|
119
|
+
ta.style.position = "fixed";
|
|
120
|
+
ta.style.opacity = "0";
|
|
121
|
+
document.body.append(ta);
|
|
122
|
+
ta.select();
|
|
123
|
+
const ok = document.execCommand("copy");
|
|
124
|
+
ta.remove();
|
|
125
|
+
said(ok ? "copied" : "could not copy");
|
|
126
|
+
return ok;
|
|
127
|
+
} catch {
|
|
128
|
+
said("could not copy");
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/* Where every issue and pull request goes on Home.
|
|
2
|
+
*
|
|
3
|
+
* Every open item lands in exactly one place, so nothing is missed and nothing shows twice:
|
|
4
|
+
*
|
|
5
|
+
* needs an ask on a person, or a pull request ready to merge
|
|
6
|
+
* requests something a person asked a staff member for
|
|
7
|
+
* staff a staff member's own work: their status issue, a peer's ask, their own issues
|
|
8
|
+
* elsewhere draft pull requests, and product or ops issues nobody has put on a person
|
|
9
|
+
*
|
|
10
|
+
* `unread` is not a place: it lists what in `staff` and `elsewhere` has activity you have not
|
|
11
|
+
* seen (from your GitHub notifications), since those two are otherwise off Home. Items in the
|
|
12
|
+
* other places carry their own unread mark.
|
|
13
|
+
*
|
|
14
|
+
* Closed items only matter when a staff member closed them today: that is "Closed today", with
|
|
15
|
+
* Reopen beside each, because staff now close things without asking. */
|
|
16
|
+
|
|
17
|
+
/** The kinds an ask on a person carries. Older trackers used other words for a chore. */
|
|
18
|
+
const KINDS = ["decision", "review", "chore"];
|
|
19
|
+
const CHORE_WORDS = ["setup", "submit", "data", "blocked"];
|
|
20
|
+
|
|
21
|
+
const lower = (s) => String(s ?? "").toLowerCase();
|
|
22
|
+
|
|
23
|
+
/** How old a run report can be and still be this morning's. */
|
|
24
|
+
const REPORT_HOURS = 20;
|
|
25
|
+
|
|
26
|
+
/** A run report as lines, without the @mention it opens with. */
|
|
27
|
+
function reportLines(body) {
|
|
28
|
+
return String(body ?? "")
|
|
29
|
+
.split("\n")
|
|
30
|
+
.map((l) => l.replace(/^\s*(@[\w-]+\s*)+/, "").replace(/^[-*]\s+/, "").trim())
|
|
31
|
+
.filter(Boolean)
|
|
32
|
+
.slice(0, 5);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @param items the inbox list: open and recently closed issues and pull requests
|
|
37
|
+
* @param staff S.data.staff: handle, name, brain, statusIssue, mention
|
|
38
|
+
* @param humans [{ github, marker }]
|
|
39
|
+
* @param live /api/live's staff list, or [] before it has answered
|
|
40
|
+
* @param now for "today", in the viewer's own day
|
|
41
|
+
*/
|
|
42
|
+
export function sortHome(items, staff, humans, live = [], now = new Date()) {
|
|
43
|
+
const people = new Set(humans.map((h) => lower(h.github)).filter(Boolean));
|
|
44
|
+
const markers = new Set(humans.map((h) => lower(h.marker)).filter(Boolean));
|
|
45
|
+
const byBrain = new Map(staff.filter((s) => s.brain).map((s) => [s.brain, s]));
|
|
46
|
+
const working = new Set();
|
|
47
|
+
for (const l of live) {
|
|
48
|
+
const s = staff.find((x) => x.handle === l.handle);
|
|
49
|
+
for (const r of l.running ?? []) if (s && r.issue) working.add(`${s.brain}#${r.issue}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const out = {
|
|
53
|
+
reports: [],
|
|
54
|
+
needs: [],
|
|
55
|
+
requests: [],
|
|
56
|
+
staff: [],
|
|
57
|
+
elsewhere: [],
|
|
58
|
+
unread: [],
|
|
59
|
+
closedToday: [],
|
|
60
|
+
};
|
|
61
|
+
const today = dayOf(now);
|
|
62
|
+
|
|
63
|
+
for (const item of items) {
|
|
64
|
+
const owner = byBrain.get(item.repo) ?? null;
|
|
65
|
+
|
|
66
|
+
if (item.state !== "OPEN") {
|
|
67
|
+
if (
|
|
68
|
+
owner &&
|
|
69
|
+
item.kind === "issue" &&
|
|
70
|
+
item.closedAt &&
|
|
71
|
+
dayOf(new Date(item.closedAt)) === today &&
|
|
72
|
+
!people.has(lower(item.closedBy))
|
|
73
|
+
) {
|
|
74
|
+
out.closedToday.push({ item, staff: owner, reason: reasonOf(item, people) });
|
|
75
|
+
}
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// The run report: the last word on a status issue, from the staff member, in the last day.
|
|
80
|
+
const c = item.lastComment;
|
|
81
|
+
if (
|
|
82
|
+
owner &&
|
|
83
|
+
item.number === owner.statusIssue &&
|
|
84
|
+
c &&
|
|
85
|
+
!people.has(lower(c.author)) &&
|
|
86
|
+
now - new Date(c.createdAt) < REPORT_HOURS * 3_600_000
|
|
87
|
+
) {
|
|
88
|
+
out.reports.push({ staff: owner, item, at: c.createdAt, lines: reportLines(c.body) });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const place = placeOf(item, owner, people, markers);
|
|
92
|
+
const entry = { item, staff: owner, ...place };
|
|
93
|
+
if (place.place === "requests") {
|
|
94
|
+
entry.status = working.has(`${item.repo}#${item.number}`)
|
|
95
|
+
? "working"
|
|
96
|
+
: item.lastComment && !people.has(lower(item.lastComment.author))
|
|
97
|
+
? "answered"
|
|
98
|
+
: "waiting";
|
|
99
|
+
}
|
|
100
|
+
out[place.place].push(entry);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const oldest = (a, b) => a.item.createdAt.localeCompare(b.item.createdAt);
|
|
104
|
+
out.needs.sort(oldest);
|
|
105
|
+
out.requests.sort((a, b) => b.item.updatedAt.localeCompare(a.item.updatedAt));
|
|
106
|
+
out.closedToday.sort((a, b) => b.item.closedAt.localeCompare(a.item.closedAt));
|
|
107
|
+
out.unread = [...out.staff, ...out.elsewhere]
|
|
108
|
+
.filter((e) => e.item.unread)
|
|
109
|
+
.sort((a, b) => b.item.updatedAt.localeCompare(a.item.updatedAt));
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Which place an open item belongs in, and for an ask, which kind it is. */
|
|
114
|
+
export function placeOf(item, owner, people, markers) {
|
|
115
|
+
if (item.kind === "pr") {
|
|
116
|
+
return item.draft ? { place: "elsewhere", why: "draft" } : { place: "needs", kind: "merge" };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const labels = (item.labels ?? []).map(lower);
|
|
120
|
+
const onPerson =
|
|
121
|
+
(item.assignees ?? []).some((a) => people.has(lower(a))) ||
|
|
122
|
+
labels.some((l) => markers.has(l));
|
|
123
|
+
const byPerson = people.has(lower(item.author));
|
|
124
|
+
/* You had the last word on an ask: approved it, answered it, said go with the default. It is
|
|
125
|
+
waiting on them now, so it is one of your requests until they reply or close it. If they
|
|
126
|
+
reply, the last word is theirs and it is back on you. */
|
|
127
|
+
const youAnswered = Boolean(item.lastComment) && people.has(lower(item.lastComment.author));
|
|
128
|
+
|
|
129
|
+
if (!owner) {
|
|
130
|
+
if (!onPerson || byPerson) {
|
|
131
|
+
return { place: "elsewhere", why: item.role === "product" ? "contributor" : "other" };
|
|
132
|
+
}
|
|
133
|
+
return youAnswered ? { place: "requests" } : { place: "needs", kind: kindOf(labels) };
|
|
134
|
+
}
|
|
135
|
+
if (item.number === owner.statusIssue || labels.includes("keep-open")) {
|
|
136
|
+
return { place: "staff", why: "status" };
|
|
137
|
+
}
|
|
138
|
+
if (byPerson) return { place: "requests" };
|
|
139
|
+
if (onPerson) return youAnswered ? { place: "requests" } : { place: "needs", kind: kindOf(labels) };
|
|
140
|
+
return {
|
|
141
|
+
place: "staff",
|
|
142
|
+
why: labels.some((l) => l.startsWith("from-")) ? "peer" : "own",
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function kindOf(labels) {
|
|
147
|
+
const found = KINDS.find((k) => labels.includes(k));
|
|
148
|
+
if (found) return found;
|
|
149
|
+
return labels.some((l) => CHORE_WORDS.includes(l)) ? "chore" : "ask";
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The one line a staff member closed it with: their last comment's first line. */
|
|
153
|
+
function reasonOf(item, people) {
|
|
154
|
+
const c = item.lastComment;
|
|
155
|
+
if (!c || people.has(lower(c.author))) return "";
|
|
156
|
+
const line = String(c.body ?? "")
|
|
157
|
+
.split("\n")
|
|
158
|
+
.map((l) => l.trim())
|
|
159
|
+
.find(Boolean);
|
|
160
|
+
return line ? line.replace(/^[#>*\s-]+/, "").slice(0, 160) : "";
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** A date as the viewer's own calendar day. */
|
|
164
|
+
export function dayOf(d) {
|
|
165
|
+
return `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Whole days from today to a YYYY-MM-DD date: 0 today, negative once it has passed. */
|
|
169
|
+
export function daysUntil(date, now = new Date()) {
|
|
170
|
+
const [y, m, d] = String(date).split("-").map(Number);
|
|
171
|
+
const due = new Date(y, m - 1, d);
|
|
172
|
+
const start = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
|
173
|
+
return Math.round((due - start) / 86_400_000);
|
|
174
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/* Icons.
|
|
2
|
+
*
|
|
3
|
+
* Lucide glyphs (lucide.dev, ISC), vendored as path data rather than pulled from
|
|
4
|
+
* a CDN or a font. The portal is local-first and offline, so an icon that needs the network
|
|
5
|
+
* is an icon that is sometimes a blank square.
|
|
6
|
+
*
|
|
7
|
+
* This replaces the arrow-and-lozenge characters the UI used to draw with. Those were never
|
|
8
|
+
* icons: they are text, they render differently on every platform, half of them fall back to
|
|
9
|
+
* a box in the wrong font, and none of them line up with a baseline.
|
|
10
|
+
*
|
|
11
|
+
* They inherit `currentColor` and size from the `--ic` custom property, so a caller sets
|
|
12
|
+
* colour and size in CSS and never touches the SVG.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
const PATHS = {
|
|
16
|
+
"search":
|
|
17
|
+
"<circle cx=\"11\" cy=\"11\" r=\"8\" /> <path d=\"m21 21-4.3-4.3\" />",
|
|
18
|
+
"lightbulb":
|
|
19
|
+
"<path d=\"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5\" /> <path d=\"M9 18h6\" /> <path d=\"M10 22h4\" />",
|
|
20
|
+
"code":
|
|
21
|
+
"<polyline points=\"16 18 22 12 16 6\" /> <polyline points=\"8 6 2 12 8 18\" />",
|
|
22
|
+
"megaphone":
|
|
23
|
+
"<path d=\"m3 11 18-5v12L3 14v-3z\" /> <path d=\"M11.6 16.8a3 3 0 1 1-5.8-1.6\" />",
|
|
24
|
+
"life-buoy":
|
|
25
|
+
"<circle cx=\"12\" cy=\"12\" r=\"10\" /> <path d=\"m4.93 4.93 4.24 4.24\" /> <path d=\"m14.83 9.17 4.24-4.24\" /> <path d=\"m14.83 14.83 4.24 4.24\" /> <path d=\"m9.17 14.83-4.24 4.24\" /> <circle cx=\"12\" cy=\"12\" r=\"4\" />",
|
|
26
|
+
"compass":
|
|
27
|
+
"<circle cx=\"12\" cy=\"12\" r=\"10\" /> <polygon points=\"16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76\" />",
|
|
28
|
+
"brush":
|
|
29
|
+
"<path d=\"m9.06 11.9 8.07-8.06a2.85 2.85 0 1 1 4.03 4.03l-8.06 8.08\" /> <path d=\"M7.07 14.94c-1.66 0-3 1.35-3 3.02 0 1.33-2.5 1.52-2 2.02 1.08 1.1 2.49 2.02 4 2.02 2.2 0 4-1.8 4-4.04a3.01 3.01 0 0 0-3-3.02z\" />",
|
|
30
|
+
"bug":
|
|
31
|
+
"<path d=\"m8 2 1.88 1.88\" /> <path d=\"M14.12 3.88 16 2\" /> <path d=\"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1\" /> <path d=\"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6\" /> <path d=\"M12 20v-9\" /> <path d=\"M6.53 9C4.6 8.8 3 7.1 3 5\" /> <path d=\"M6 13H2\" /> <path d=\"M3 21c0-2.1 1.7-3.9 3.8-4\" /> <path d=\"M20.97 5c0 2.1-1.6 3.8-3.5 4\" /> <path d=\"M22 13h-4\" /> <path d=\"M17.2 17c2.1.1 3.8 1.9 3.8 4\" />",
|
|
32
|
+
"server":
|
|
33
|
+
"<rect width=\"20\" height=\"8\" x=\"2\" y=\"2\" rx=\"2\" ry=\"2\" /> <rect width=\"20\" height=\"8\" x=\"2\" y=\"14\" rx=\"2\" ry=\"2\" /> <line x1=\"6\" x2=\"6.01\" y1=\"6\" y2=\"6\" /> <line x1=\"6\" x2=\"6.01\" y1=\"18\" y2=\"18\" />",
|
|
34
|
+
"book-open":
|
|
35
|
+
"<path d=\"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z\" /> <path d=\"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z\" />",
|
|
36
|
+
"bar-chart":
|
|
37
|
+
"<line x1=\"12\" x2=\"12\" y1=\"20\" y2=\"10\" /> <line x1=\"18\" x2=\"18\" y1=\"20\" y2=\"4\" /> <line x1=\"6\" x2=\"6\" y1=\"20\" y2=\"16\" />",
|
|
38
|
+
"users":
|
|
39
|
+
"<path d=\"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2\" /> <circle cx=\"9\" cy=\"7\" r=\"4\" /> <path d=\"M22 21v-2a4 4 0 0 0-3-3.87\" /> <path d=\"M16 3.13a4 4 0 0 1 0 7.75\" />",
|
|
40
|
+
"check":
|
|
41
|
+
"<path d=\"M20 6 9 17l-5-5\" />",
|
|
42
|
+
"chevron":
|
|
43
|
+
"<path d=\"m6 9 6 6 6-6\" />",
|
|
44
|
+
"close":
|
|
45
|
+
"<path d=\"M18 6 6 18\" /> <path d=\"m6 6 12 12\" />",
|
|
46
|
+
"closed":
|
|
47
|
+
"<circle cx=\"12\" cy=\"12\" r=\"10\" /> <path d=\"m15 9-6 6\" /> <path d=\"m9 9 6 6\" />",
|
|
48
|
+
"commit":
|
|
49
|
+
"<circle cx=\"12\" cy=\"12\" r=\"3\" /> <line x1=\"3\" x2=\"9\" y1=\"12\" y2=\"12\" /> <line x1=\"15\" x2=\"21\" y1=\"12\" y2=\"12\" />",
|
|
50
|
+
"crossref":
|
|
51
|
+
"<path d=\"M7 7h10v10\" /> <path d=\"M7 17 17 7\" />",
|
|
52
|
+
"dash":
|
|
53
|
+
"<path d=\"M5 12h14\" />",
|
|
54
|
+
"docs":
|
|
55
|
+
"<path d=\"M12 5v16\" /> <path d=\"M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z\" />",
|
|
56
|
+
"dot":
|
|
57
|
+
"<circle cx=\"12\" cy=\"12\" r=\"1\" />",
|
|
58
|
+
"draft":
|
|
59
|
+
"<circle cx=\"18\" cy=\"18\" r=\"3\" /> <circle cx=\"6\" cy=\"6\" r=\"3\" /> <path d=\"M18 6V5\" /> <path d=\"M18 11v-1\" /> <line x1=\"6\" x2=\"6\" y1=\"9\" y2=\"21\" />",
|
|
60
|
+
"edit":
|
|
61
|
+
"<path d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\" /> <path d=\"m15 5 4 4\" />",
|
|
62
|
+
"file":
|
|
63
|
+
"<path d=\"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\" /> <path d=\"M14 2v5a1 1 0 0 0 1 1h5\" /> <path d=\"M10 9H8\" /> <path d=\"M16 13H8\" /> <path d=\"M16 17H8\" />",
|
|
64
|
+
"gallery":
|
|
65
|
+
"<path d=\"m22 11-1.296-1.296a2.4 2.4 0 0 0-3.408 0L11 16\" /> <path d=\"M4 8a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2\" /> <circle cx=\"13\" cy=\"7\" r=\"1\" fill=\"currentColor\" /> <rect x=\"8\" y=\"2\" width=\"14\" height=\"14\" rx=\"2\" />",
|
|
66
|
+
"inbox":
|
|
67
|
+
"<polyline points=\"22 12 16 12 14 15 10 15 8 12 2 12\" /> <path d=\"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z\" />",
|
|
68
|
+
"issue-closed":
|
|
69
|
+
"<circle cx=\"12\" cy=\"12\" r=\"10\" /> <path d=\"m16 9-5.5 5.5L8 12\" />",
|
|
70
|
+
"issue-open":
|
|
71
|
+
"<circle cx=\"12\" cy=\"12\" r=\"1\" /> <circle cx=\"12\" cy=\"12\" r=\"10\" />",
|
|
72
|
+
"label":
|
|
73
|
+
"<path d=\"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z\" /> <circle cx=\"7.5\" cy=\"7.5\" r=\".5\" fill=\"currentColor\" />",
|
|
74
|
+
"merged":
|
|
75
|
+
"<circle cx=\"18\" cy=\"18\" r=\"3\" /> <circle cx=\"6\" cy=\"6\" r=\"3\" /> <path d=\"M6 21V9a9 9 0 0 0 9 9\" />",
|
|
76
|
+
"monitor":
|
|
77
|
+
"<rect width=\"20\" height=\"14\" x=\"2\" y=\"3\" rx=\"2\" /> <line x1=\"8\" x2=\"16\" y1=\"21\" y2=\"21\" /> <line x1=\"12\" x2=\"12\" y1=\"17\" y2=\"21\" />",
|
|
78
|
+
"moon":
|
|
79
|
+
"<path d=\"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\" />",
|
|
80
|
+
"paperclip":
|
|
81
|
+
"<path d=\"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48\" />",
|
|
82
|
+
"person":
|
|
83
|
+
"<circle cx=\"12\" cy=\"8\" r=\"5\" /> <path d=\"M20 21a8 8 0 0 0-16 0\" />",
|
|
84
|
+
"play":
|
|
85
|
+
"<path d=\"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z\" />",
|
|
86
|
+
// The pair for the lightbox's zoom controls. `dash` above is the other half.
|
|
87
|
+
"plus":
|
|
88
|
+
"<path d=\"M5 12h14\" /> <path d=\"M12 5v14\" />",
|
|
89
|
+
"refresh":
|
|
90
|
+
"<path d=\"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8\" /> <path d=\"M21 3v5h-5\" /> <path d=\"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16\" /> <path d=\"M8 16H3v5\" />",
|
|
91
|
+
"rename":
|
|
92
|
+
"<path d=\"M13 21h8\" /> <path d=\"m15 5 4 4\" /> <path d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\" />",
|
|
93
|
+
"reopened":
|
|
94
|
+
"<path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\" /> <path d=\"M3 3v5h5\" />",
|
|
95
|
+
"review":
|
|
96
|
+
"<path d=\"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z\" /> <path d=\"M7 11h10\" /> <path d=\"M7 15h6\" /> <path d=\"M7 7h8\" />",
|
|
97
|
+
"square":
|
|
98
|
+
"<rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\" />",
|
|
99
|
+
"sun":
|
|
100
|
+
"<circle cx=\"12\" cy=\"12\" r=\"4\" /> <path d=\"M12 2v2\" /> <path d=\"M12 20v2\" /> <path d=\"m4.93 4.93 1.41 1.41\" /> <path d=\"m17.66 17.66 1.41 1.41\" /> <path d=\"M2 12h2\" /> <path d=\"M20 12h2\" /> <path d=\"m6.34 17.66-1.41 1.41\" /> <path d=\"m19.07 4.93-1.41 1.41\" />",
|
|
101
|
+
"task-done":
|
|
102
|
+
"<path d=\"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344\" /> <path d=\"m9 11 3 3L22 4\" />",
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const OPEN =
|
|
106
|
+
'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" ' +
|
|
107
|
+
'stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"';
|
|
108
|
+
|
|
109
|
+
/** An icon as an HTML string, for the places that build markup rather than nodes. */
|
|
110
|
+
export function iconHTML(name, cls = "") {
|
|
111
|
+
const body = PATHS[name];
|
|
112
|
+
if (!body) return "";
|
|
113
|
+
return OPEN + ' class="ic' + (cls ? " " + cls : "") + '">' + body + "</svg>";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** An icon as an element. */
|
|
117
|
+
export function icon(name, cls = "") {
|
|
118
|
+
const span = document.createElement("span");
|
|
119
|
+
span.innerHTML = iconHTML(name, cls);
|
|
120
|
+
return span.firstChild ?? span;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* A staff member's icon: `icon:` in their staff.yaml, or one picked from their role. */
|
|
124
|
+
const ROLE_ICONS = {
|
|
125
|
+
cto: "code",
|
|
126
|
+
cmo: "megaphone",
|
|
127
|
+
support: "life-buoy",
|
|
128
|
+
pm: "compass",
|
|
129
|
+
designer: "brush",
|
|
130
|
+
qa: "bug",
|
|
131
|
+
devops: "server",
|
|
132
|
+
writer: "book-open",
|
|
133
|
+
analyst: "bar-chart",
|
|
134
|
+
community: "users",
|
|
135
|
+
};
|
|
136
|
+
export function staffIcon(s) {
|
|
137
|
+
return s?.icon && hasIcon(s.icon) ? s.icon : (ROLE_ICONS[s?.handle] ?? "person");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function hasIcon(name) {
|
|
141
|
+
return Object.hasOwn(PATHS, name);
|
|
142
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* How many requests the page has open. The setup dialog waits for this to reach zero before it
|
|
2
|
+
* shows itself, because the list it draws is only final once every answer is back. */
|
|
3
|
+
|
|
4
|
+
let open = 0;
|
|
5
|
+
|
|
6
|
+
if (typeof globalThis.fetch === "function" && !globalThis.fetch.counted) {
|
|
7
|
+
const real = globalThis.fetch.bind(globalThis);
|
|
8
|
+
const counted = (...args) => {
|
|
9
|
+
open++;
|
|
10
|
+
return real(...args).finally(() => {
|
|
11
|
+
open--;
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
counted.counted = true;
|
|
15
|
+
globalThis.fetch = counted;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const pending = () => open;
|