@nanocollective/roster 0.1.0-beta.6 → 0.1.0-beta.8

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.
@@ -55,35 +55,10 @@ export function viewHome(m) {
55
55
  const page = el("div", { className: "home" });
56
56
  page.append(askBox(staff));
57
57
 
58
- if (h.reports.length) {
58
+ const reporters = staff.filter((x) => x.brain && x.statusIssue);
59
+ if (reporters.length) {
59
60
  page.append(section("Latest reports"));
60
- const box = el("div", { className: "card homereports" });
61
- for (const r of h.reports) {
62
- /* The report is markdown the staff member wrote, with links to the work it names. The
63
- whole report opens their status issue, where it was posted; a link inside it goes
64
- where it points. */
65
- const row = el("div", { className: "homereport homeclick", tabIndex: 0, role: "button" }, [
66
- el("div", { className: "homereportwho" }, [
67
- el("span", { className: "homewho2" }, [icon(staffIcon(r.staff), "ic"), el("b", { textContent: r.staff.name })]),
68
- el("span", { className: "meta", textContent: ago(r.at) }),
69
- ]),
70
- el("div", {
71
- className: "md homereportbody",
72
- innerHTML: mdlite(r.lines.join("\n\n"), { repo: r.staff.brain }),
73
- }),
74
- ]);
75
- row.onclick = (ev) => {
76
- if (!ev.target.closest("a, button")) openThread(r.item);
77
- };
78
- row.onkeydown = (ev) => {
79
- if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
80
- ev.preventDefault();
81
- openThread(r.item);
82
- }
83
- };
84
- box.append(row);
85
- }
86
- page.append(box);
61
+ page.append(el("div", { className: "card homereports" }, reporters.map((s) => reportRow(s, h.reports))));
87
62
  }
88
63
 
89
64
  page.append(section("Needs you", h.needs.length));
@@ -116,6 +91,61 @@ export function viewHome(m) {
116
91
  m.append(page);
117
92
  }
118
93
 
94
+ /* ------------------------------- reports -------------------------------- */
95
+
96
+ /**
97
+ * One staff member's last report, or a line saying there is none today, with a button that asks
98
+ * for one. The report is markdown the staff member wrote, with links to the work it names. The
99
+ * whole row opens their status issue, where it was posted; a link inside it goes where it points.
100
+ */
101
+ function reportRow(s, reports) {
102
+ const r = reports.find((x) => x.staff.handle === s.handle);
103
+ const item = r?.item ?? { repo: s.brain, number: s.statusIssue, kind: "issue" };
104
+ const note = el("span", { className: "meta" });
105
+ const ask = el("button", { className: "ghbtn", textContent: "Ask for a report" });
106
+ ask.onclick = async () => {
107
+ ask.disabled = true;
108
+ note.className = "meta";
109
+ note.textContent = "Asking…";
110
+ try {
111
+ await post({
112
+ action: "comment",
113
+ repo: s.brain,
114
+ number: s.statusIssue,
115
+ body: `${s.mention ?? "@" + s.handle} Report, please.`,
116
+ });
117
+ ask.remove();
118
+ note.textContent = `Asked. ${s.name} replies in a few minutes.`;
119
+ refreshSoon();
120
+ } catch (e) {
121
+ note.textContent = String(e.message || e);
122
+ note.className = "meta err";
123
+ ask.disabled = false;
124
+ }
125
+ };
126
+
127
+ const row = el("div", { className: "homereport homeclick", tabIndex: 0, role: "button" }, [
128
+ el("div", { className: "homereportwho" }, [
129
+ el("span", { className: "homewho2" }, [icon(staffIcon(s), "ic"), el("b", { textContent: s.name })]),
130
+ el("span", { className: "meta", textContent: r ? ago(r.at) : "No report today" }),
131
+ el("div", { className: "homereportask" }, [ask, note]),
132
+ ]),
133
+ r
134
+ ? el("div", { className: "md homereportbody", innerHTML: mdlite(r.lines.join("\n\n"), { repo: s.brain }) })
135
+ : el("div"),
136
+ ]);
137
+ row.onclick = (ev) => {
138
+ if (!ev.target.closest("a, button")) openThread(item);
139
+ };
140
+ row.onkeydown = (ev) => {
141
+ if (ev.target === row && (ev.key === "Enter" || ev.key === " ")) {
142
+ ev.preventDefault();
143
+ openThread(item);
144
+ }
145
+ };
146
+ return row;
147
+ }
148
+
119
149
  /* ------------------------------- asking -------------------------------- */
120
150
 
121
151
  function askBox(staff) {