@parallelworks/tandem-web 0.152.1 → 0.153.1

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.
@@ -0,0 +1,433 @@
1
+ import { Link as e } from "../lib/router.js";
2
+ import { panelQuery as t } from "../api/queries.js";
3
+ import { DownloadIcon as n, EditIcon as r, TrashIcon as i } from "./icons.js";
4
+ import { Card as a, ChartLegendList as o, IconButton as s, OTHER_SERIES_KEY as c, foldSeries as l, seriesColors as u } from "@parallelworks/ui";
5
+ import { useFormatter as d, useTranslations as f } from "use-intl";
6
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
7
+ import { useQuery as h } from "@tanstack/react-query";
8
+ // src/components/DashboardPanel.tsx
9
+ function g(e) {
10
+ let t = e.team || e.assignee || e.creator ? {} : { scope: "workspace" };
11
+ return Object.fromEntries(Object.entries({
12
+ ...e,
13
+ ...t
14
+ }).filter(([e, t]) => t && e !== "$schema"));
15
+ }
16
+ var _ = /* @__PURE__ */ new Set([
17
+ "created_completed",
18
+ "open",
19
+ "throughput"
20
+ ]);
21
+ function v(e) {
22
+ return [
23
+ {
24
+ title: e("starter.createdCompleted"),
25
+ chart: "stacked",
26
+ spec: {
27
+ measure: "created_completed",
28
+ weeks: 12,
29
+ filters: { view: "all" }
30
+ }
31
+ },
32
+ {
33
+ title: e("starter.cycleTime"),
34
+ chart: "bar",
35
+ spec: {
36
+ measure: "cycle_time",
37
+ groupBy: "team",
38
+ weeks: 12,
39
+ filters: { view: "done" }
40
+ }
41
+ },
42
+ {
43
+ title: e("starter.openByPriority"),
44
+ chart: "bar",
45
+ spec: {
46
+ measure: "count",
47
+ groupBy: "priority",
48
+ filters: { view: "active" }
49
+ }
50
+ },
51
+ {
52
+ title: e("starter.slaBreached"),
53
+ chart: "number",
54
+ spec: {
55
+ measure: "sla_breached",
56
+ filters: { view: "active" }
57
+ }
58
+ }
59
+ ];
60
+ }
61
+ function y(e, t) {
62
+ return [
63
+ {
64
+ value: "private",
65
+ label: e("private")
66
+ },
67
+ {
68
+ value: "workspace",
69
+ label: e("sharedWorkspace")
70
+ },
71
+ ...t.filter((e) => !e.archivedAt).map((t) => ({
72
+ value: `team:${t.key}`,
73
+ label: e("sharedTeam", { team: t.name })
74
+ }))
75
+ ];
76
+ }
77
+ function b(e) {
78
+ return e === "private" ? {
79
+ shared: !1,
80
+ team: ""
81
+ } : e === "workspace" ? {
82
+ shared: !0,
83
+ team: ""
84
+ } : {
85
+ shared: !0,
86
+ team: e.slice(5)
87
+ };
88
+ }
89
+ function x({ workspace: e, panel: o, onEdit: c, onDelete: l }) {
90
+ let u = f("dashboards"), { data: d, isPending: g, isError: _ } = h({
91
+ ...t(e, o.chart, o.spec),
92
+ refetchInterval: 6e4
93
+ });
94
+ return /* @__PURE__ */ m(a, {
95
+ padding: "none",
96
+ interactive: !1,
97
+ className: "flex min-w-0 flex-col",
98
+ children: [/* @__PURE__ */ m("div", {
99
+ className: "flex items-center gap-1 border-b border-border px-3 py-2",
100
+ children: [
101
+ /* @__PURE__ */ p("h2", {
102
+ className: "min-w-0 flex-1 truncate text-sm font-medium",
103
+ children: o.title || u(`measures.${o.spec.measure}`)
104
+ }),
105
+ d && /* @__PURE__ */ p(s, {
106
+ variant: "ghost",
107
+ size: "sm",
108
+ icon: /* @__PURE__ */ p(n, {}),
109
+ label: u("csv"),
110
+ onClick: () => k(o.title || o.spec.measure, d, u)
111
+ }),
112
+ c && /* @__PURE__ */ p(s, {
113
+ variant: "ghost",
114
+ size: "sm",
115
+ icon: /* @__PURE__ */ p(r, {}),
116
+ label: u("edit"),
117
+ onClick: c
118
+ }),
119
+ l && /* @__PURE__ */ p(s, {
120
+ variant: "ghost",
121
+ size: "sm",
122
+ icon: /* @__PURE__ */ p(i, {}),
123
+ label: u("remove"),
124
+ onClick: l
125
+ })
126
+ ]
127
+ }), /* @__PURE__ */ p("div", {
128
+ className: "min-h-48 flex-1 p-3",
129
+ children: g ? /* @__PURE__ */ p("p", {
130
+ className: "text-sm text-muted-foreground",
131
+ children: u("loading")
132
+ }) : _ || !d ? /* @__PURE__ */ p("p", {
133
+ className: "text-sm text-danger",
134
+ children: u("failed")
135
+ }) : /* @__PURE__ */ p(C, {
136
+ workspace: e,
137
+ panel: o,
138
+ data: d
139
+ })
140
+ })]
141
+ });
142
+ }
143
+ function S(e) {
144
+ let t = d(), n = f("dashboards");
145
+ return (r) => e === "days" ? n("daysValue", { days: t.number(r, { maximumFractionDigits: 1 }) }) : t.number(r, { maximumFractionDigits: +(e === "points") });
146
+ }
147
+ function C({ workspace: t, panel: n, data: r }) {
148
+ let i = f("dashboards"), a = S(r.unit), o = r.series.length > 0 && r.weeks.length > 0, s = n.chart;
149
+ return s === "number" ? /* @__PURE__ */ m(e, {
150
+ to: "/$workspace/issues",
151
+ params: { workspace: t },
152
+ search: g(r.filter),
153
+ className: "flex h-full flex-col items-start justify-center gap-1 rounded-md hover:bg-muted",
154
+ children: [/* @__PURE__ */ p("span", {
155
+ className: "text-4xl font-semibold tabular-nums",
156
+ children: a(r.total)
157
+ }), /* @__PURE__ */ p("span", {
158
+ className: "text-xs text-muted-foreground",
159
+ children: i(`units.${r.unit}`)
160
+ })]
161
+ }) : s === "list" ? r.issues.length === 0 ? /* @__PURE__ */ p(w, {}) : /* @__PURE__ */ p("ul", {
162
+ className: "divide-y divide-border text-sm",
163
+ children: r.issues.map((n) => /* @__PURE__ */ p("li", { children: /* @__PURE__ */ m(e, {
164
+ to: "/$workspace/issues/$identifier",
165
+ params: {
166
+ workspace: t,
167
+ identifier: n.identifier
168
+ },
169
+ className: "flex min-w-0 gap-2 py-1.5 hover:bg-muted",
170
+ children: [
171
+ /* @__PURE__ */ p("span", {
172
+ className: "shrink-0 text-muted-foreground tabular-nums",
173
+ children: n.identifier
174
+ }),
175
+ /* @__PURE__ */ p("span", {
176
+ className: "min-w-0 flex-1 truncate",
177
+ children: n.title
178
+ }),
179
+ /* @__PURE__ */ p("span", {
180
+ className: "shrink-0 text-xs text-muted-foreground",
181
+ children: n.status
182
+ })
183
+ ]
184
+ }) }, n.identifier))
185
+ }) : s === "table" ? r.rows.length === 0 ? /* @__PURE__ */ p(w, {}) : /* @__PURE__ */ m("table", {
186
+ className: "w-full text-sm",
187
+ children: [/* @__PURE__ */ p("thead", { children: /* @__PURE__ */ m("tr", {
188
+ className: "text-left text-xs text-muted-foreground",
189
+ children: [/* @__PURE__ */ p("th", {
190
+ className: "pb-1 font-medium",
191
+ children: i("group")
192
+ }), /* @__PURE__ */ p("th", {
193
+ className: "pb-1 text-right font-medium",
194
+ children: i(`units.${r.unit}`)
195
+ })]
196
+ }) }), /* @__PURE__ */ p("tbody", {
197
+ className: "divide-y divide-border",
198
+ children: r.rows.map((r) => /* @__PURE__ */ m("tr", { children: [/* @__PURE__ */ p("td", {
199
+ className: "py-1.5",
200
+ children: /* @__PURE__ */ p(e, {
201
+ to: "/$workspace/issues",
202
+ params: { workspace: t },
203
+ search: g(r.filter),
204
+ className: "hover:underline",
205
+ children: T(r.name, n.spec.groupBy, i)
206
+ })
207
+ }), /* @__PURE__ */ p("td", {
208
+ className: "py-1.5 text-right tabular-nums",
209
+ children: a(r.value)
210
+ })] }, r.key || "-"))
211
+ })]
212
+ }) : o && (s === "line" || s === "stacked" || _.has(n.spec.measure)) ? /* @__PURE__ */ p(O, {
213
+ workspace: t,
214
+ data: r,
215
+ stacked: s !== "line",
216
+ names: (e) => e.key === "created" || e.key === "completed" ? i(`series.${e.key}`) : T(e.name, n.spec.groupBy, i),
217
+ value: a
218
+ }) : r.rows.length === 0 || r.rows.every((e) => e.value === 0) ? /* @__PURE__ */ p(w, {}) : p(s === "pie" ? D : E, {
219
+ workspace: t,
220
+ data: r,
221
+ groupBy: n.spec.groupBy,
222
+ value: a
223
+ });
224
+ }
225
+ function w() {
226
+ let e = f("dashboards");
227
+ return /* @__PURE__ */ p("p", {
228
+ className: "text-sm text-muted-foreground",
229
+ children: e("empty")
230
+ });
231
+ }
232
+ function T(e, t, n) {
233
+ return t === "priority" ? n(`priorities.${e}`) : t === "status" && e ? n(`categories.${e}`) : t ? e || n("none") : n("all");
234
+ }
235
+ function E({ workspace: t, data: n, groupBy: r, value: i }) {
236
+ let a = f("dashboards"), o = Math.max(...n.rows.map((e) => e.value), 1);
237
+ return /* @__PURE__ */ p("ul", {
238
+ className: "space-y-1.5",
239
+ children: n.rows.slice(0, 12).map((n) => /* @__PURE__ */ p("li", { children: /* @__PURE__ */ m(e, {
240
+ to: "/$workspace/issues",
241
+ params: { workspace: t },
242
+ search: g(n.filter),
243
+ className: "group grid grid-cols-[minmax(0,9rem)_1fr_auto] items-center gap-2 text-sm",
244
+ children: [
245
+ /* @__PURE__ */ p("span", {
246
+ className: "truncate text-muted-foreground group-hover:text-foreground",
247
+ children: T(n.name, r, a)
248
+ }),
249
+ /* @__PURE__ */ p("span", {
250
+ className: "h-4 rounded-sm bg-muted",
251
+ children: /* @__PURE__ */ p("span", {
252
+ className: "block h-full rounded-sm bg-primary group-hover:opacity-80",
253
+ style: { width: `${Math.max(2, n.value / o * 100)}%` }
254
+ })
255
+ }),
256
+ /* @__PURE__ */ p("span", {
257
+ className: "tabular-nums",
258
+ children: i(n.value)
259
+ })
260
+ ]
261
+ }) }, n.key))
262
+ });
263
+ }
264
+ function D({ workspace: t, data: n, groupBy: r, value: i }) {
265
+ let a = f("dashboards"), o = n.rows.filter((e) => e.value > 0), { keys: s, folded: d } = l(o.map((e) => e.key)), h = u(s), _ = s.map((e) => {
266
+ if (e === c) return {
267
+ key: e,
268
+ name: a("other"),
269
+ value: o.filter((e) => d.includes(e.key)).reduce((e, t) => e + t.value, 0),
270
+ filter: n.filter
271
+ };
272
+ let t = o.find((t) => t.key === e);
273
+ return {
274
+ key: e,
275
+ name: T(t.name, r, a),
276
+ value: t.value,
277
+ filter: t.filter
278
+ };
279
+ }), v = _.reduce((e, t) => e + t.value, 0) || 1, y = -Math.PI / 2, b = _.map((e) => {
280
+ let t = y;
281
+ y += e.value / v * Math.PI * 2;
282
+ let n = +(y - t > Math.PI), r = (e, t) => `${50 + t * Math.cos(e)} ${50 + t * Math.sin(e)}`, i = _.length === 1 ? "M 50 8 A 42 42 0 1 1 49.99 8 L 49.99 26 A 24 24 0 1 0 50 26 Z" : `M ${r(t, 42)} A 42 42 0 ${n} 1 ${r(y, 42)} L ${r(y, 24)} A 24 24 0 ${n} 0 ${r(t, 24)} Z`;
283
+ return {
284
+ ...e,
285
+ d: i
286
+ };
287
+ });
288
+ return /* @__PURE__ */ m("div", {
289
+ className: "flex flex-wrap items-center gap-4",
290
+ children: [/* @__PURE__ */ p("svg", {
291
+ viewBox: "0 0 100 100",
292
+ className: "size-32 shrink-0",
293
+ role: "img",
294
+ "aria-label": a("pie"),
295
+ children: b.map((e) => /* @__PURE__ */ p("path", {
296
+ d: e.d,
297
+ fill: h[e.key],
298
+ children: /* @__PURE__ */ p("title", { children: `${e.name}: ${i(e.value)}` })
299
+ }, e.key))
300
+ }), /* @__PURE__ */ p("ul", {
301
+ className: "min-w-0 flex-1 space-y-1 text-sm",
302
+ children: b.map((n) => /* @__PURE__ */ p("li", { children: /* @__PURE__ */ m(e, {
303
+ to: "/$workspace/issues",
304
+ params: { workspace: t },
305
+ search: g(n.filter),
306
+ className: "flex items-center gap-2 hover:underline",
307
+ children: [
308
+ /* @__PURE__ */ p("span", {
309
+ className: "size-2.5 shrink-0 rounded-sm",
310
+ style: { background: h[n.key] }
311
+ }),
312
+ /* @__PURE__ */ p("span", {
313
+ className: "min-w-0 flex-1 truncate",
314
+ children: n.name
315
+ }),
316
+ /* @__PURE__ */ p("span", {
317
+ className: "tabular-nums text-muted-foreground",
318
+ children: i(n.value)
319
+ })
320
+ ]
321
+ }) }, n.key))
322
+ })]
323
+ });
324
+ }
325
+ function O({ workspace: t, data: n, stacked: r, names: i, value: a }) {
326
+ let s = f("dashboards"), h = d(), { keys: _, folded: v } = l(n.series.map((e) => e.key)), y = u(_), b = _.map((e) => {
327
+ if (e === c) {
328
+ let t = n.series.filter((e) => v.includes(e.key));
329
+ return {
330
+ key: e,
331
+ name: s("other"),
332
+ values: n.weeks.map((e, n) => t.reduce((e, t) => e + (t.values[n] ?? 0), 0))
333
+ };
334
+ }
335
+ let t = n.series.find((t) => t.key === e);
336
+ return {
337
+ key: e,
338
+ name: i(t),
339
+ values: t.values
340
+ };
341
+ }), x = n.weeks.length, S = n.weeks.map((e, t) => b.reduce((e, n) => e + (n.values[t] ?? 0), 0)), C = Math.max(1, ...r ? S : b.flatMap((e) => e.values)), w = 300 / x, T = (e) => 120 - e / C * 120, E = (e) => h.dateTime(/* @__PURE__ */ new Date(`${n.weeks[e]}T00:00:00Z`), {
342
+ month: "short",
343
+ day: "numeric",
344
+ timeZone: "UTC"
345
+ });
346
+ return /* @__PURE__ */ m(e, {
347
+ to: "/$workspace/issues",
348
+ params: { workspace: t },
349
+ search: g(n.filter),
350
+ className: "block space-y-2",
351
+ children: [/* @__PURE__ */ m("svg", {
352
+ viewBox: "0 0 300 134",
353
+ className: "h-40 w-full overflow-visible",
354
+ role: "img",
355
+ "aria-label": s("overTime"),
356
+ children: [
357
+ /* @__PURE__ */ p("line", {
358
+ x1: 0,
359
+ x2: 300,
360
+ y1: 120,
361
+ y2: 120,
362
+ className: "stroke-border"
363
+ }),
364
+ /* @__PURE__ */ p("text", {
365
+ x: 0,
366
+ y: 8,
367
+ className: "fill-muted-foreground text-[8px]",
368
+ children: a(C)
369
+ }),
370
+ r ? n.weeks.map((e, t) => {
371
+ let n = 120;
372
+ return /* @__PURE__ */ p("g", { children: b.map((e) => {
373
+ let r = (e.values[t] ?? 0) / C * 120;
374
+ return n -= r, /* @__PURE__ */ p("rect", {
375
+ x: t * w + w * .15,
376
+ width: w * .7,
377
+ y: n,
378
+ height: r,
379
+ fill: y[e.key],
380
+ children: /* @__PURE__ */ p("title", { children: `${E(t)} · ${e.name}: ${a(e.values[t] ?? 0)}` })
381
+ }, e.key);
382
+ }) }, t);
383
+ }) : b.map((e) => /* @__PURE__ */ p("polyline", {
384
+ fill: "none",
385
+ stroke: y[e.key],
386
+ strokeWidth: 2,
387
+ vectorEffect: "non-scaling-stroke",
388
+ points: e.values.map((e, t) => `${t * w + w / 2},${T(e)}`).join(" "),
389
+ children: /* @__PURE__ */ p("title", { children: e.name })
390
+ }, e.key)),
391
+ [
392
+ 0,
393
+ Math.floor((x - 1) / 2),
394
+ x - 1
395
+ ].filter((e, t, n) => n.indexOf(e) === t).map((e) => /* @__PURE__ */ p("text", {
396
+ x: e * w + w / 2,
397
+ y: 132,
398
+ textAnchor: "middle",
399
+ className: "fill-muted-foreground text-[8px]",
400
+ children: E(e)
401
+ }, e))
402
+ ]
403
+ }), b.length > 1 && /* @__PURE__ */ p(o, { items: b.map((e) => ({
404
+ key: e.key,
405
+ label: e.name,
406
+ color: y[e.key] ?? ""
407
+ })) })]
408
+ });
409
+ }
410
+ function k(e, t, n) {
411
+ let r = (e) => {
412
+ let t = String(e);
413
+ return /[",\n]/.test(t) ? `"${t.replaceAll("\"", "\"\"")}"` : t;
414
+ }, i = t.series.length > 0 && t.weeks.length > 0 ? [[n("week"), ...t.series.map((e) => e.name || e.key)], ...t.weeks.map((e, n) => [e, ...t.series.map((e) => e.values[n] ?? 0)])] : t.issues.length > 0 ? [[
415
+ "identifier",
416
+ "title",
417
+ "status"
418
+ ], ...t.issues.map((e) => [
419
+ e.identifier,
420
+ e.title,
421
+ e.status
422
+ ])] : [[
423
+ n("group"),
424
+ t.unit,
425
+ n("issuesCount")
426
+ ], ...t.rows.map((e) => [
427
+ e.name || e.key,
428
+ e.value,
429
+ e.count
430
+ ])], a = new Blob([i.map((e) => e.map(r).join(",")).join("\n")], { type: "text/csv" }), o = document.createElement("a");
431
+ o.href = URL.createObjectURL(a), o.download = `${e.replace(/[^\w.-]+/g, "-")}.csv`, o.click(), URL.revokeObjectURL(o.href);
432
+ }
433
+ export { x as DashboardPanel, C as PanelChart, g as issuesSearch, y as sharingItems, b as sharingOf, v as starterPanels };
package/lib/issueList.js CHANGED
@@ -48,7 +48,7 @@ function g(e) {
48
48
  }
49
49
  t.assignee && e.assigneeKind === "agent" && (t.assigneeKind = "agent"), (e.overdue === "true" || e.overdue === !0) && (t.overdue = "true");
50
50
  let i = h(e.order);
51
- i && i !== "updated" && (d.includes(i) || n(i)) && (t.order = i), e.layout === "board" && (t.layout = "board");
51
+ i && i !== "updated" && (d.includes(i) || n(i)) && (t.order = i), e.layout === "board" && (t.layout = "board"), e.scope === "workspace" && (t.scope = "workspace");
52
52
  let a = h(e.group);
53
53
  return a && a !== "status" && (f.includes(a) || n(a)) && (t.group = a), t;
54
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallelworks/tandem-web",
3
- "version": "0.152.1",
3
+ "version": "0.153.1",
4
4
  "description": "Tandem's pages, for a host app to render in its own",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/pages/issues.js CHANGED
@@ -209,7 +209,7 @@ function _({ person: e } = {}) {
209
209
  }, []), l(() => {
210
210
  document.getElementById(`row-${V?.id}`)?.scrollIntoView({ block: "nearest" });
211
211
  }, [V]);
212
- let K = w.find((e) => e.key === x.team), q = Ue(v, x, (e) => S(We(x, e), !0), !!y && !x.assignee && !x.creator && !x.saved), _n = Ie(v, { ...o(x, "q", void 0) }), { views: vn, create: yn, update: bn } = Be(v), J = vn.find((e) => Ee(e, x.saved)), { data: xn } = g(te(v)), { data: Sn } = g(re(v)), { data: Cn } = g({
212
+ let K = w.find((e) => e.key === x.team), q = Ue(v, x, (e) => S(We(x, e), !0), !!y && !x.assignee && !x.creator && !x.saved && !x.scope), _n = Ie(v, { ...o(x, "q", void 0) }), { views: vn, create: yn, update: bn } = Be(v), J = vn.find((e) => Ee(e, x.saved)), { data: xn } = g(te(v)), { data: Sn } = g(re(v)), { data: Cn } = g({
213
213
  ...i(v, K?.key ?? ""),
214
214
  enabled: !!K
215
215
  });