@parallelworks/tandem-web 0.187.0 → 0.188.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,23 @@
1
1
  import { api as e, unwrap as t } from "../../../api/client.js";
2
2
  import { dashboardQuery as n, dashboardsQuery as r, labelsQuery as i, panelQuery as a, teamsQuery as o, viewsQuery as s } from "../../../api/queries.js";
3
3
  import { DashboardPanel as c, PanelChart as l, sharingItems as u, sharingOf as d } from "../../../components/DashboardPanel.js";
4
- import { useFormError as f } from "../../../components/settings.js";
5
- import { useConfirm as p } from "../../../lib/confirm.js";
6
- import { usePageTitle as m } from "../../../lib/pageTitle.js";
7
- import { Link as h } from "../../../lib/router.js";
8
- import { Route as g } from "./_dashboardId.js";
9
- import { Button as _, Field as v, Input as y, Modal as b, Select as x } from "@parallelworks/ui";
10
- import { useNavigate as S } from "@tanstack/react-router";
11
- import { useState as C } from "react";
12
- import { useTranslations as w } from "use-intl";
13
- import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
14
- import { useMutation as O, useQuery as k, useQueryClient as A, useSuspenseQuery as j } from "@tanstack/react-query";
4
+ import { FavoriteStar as f } from "../../../components/FavoriteStar.js";
5
+ import { useFormError as p } from "../../../components/settings.js";
6
+ import { useConfirm as m } from "../../../lib/confirm.js";
7
+ import { usePageTitle as h } from "../../../lib/pageTitle.js";
8
+ import { Link as g } from "../../../lib/router.js";
9
+ import { Route as _ } from "./_dashboardId.js";
10
+ import { Button as v, Field as y, Input as b, Modal as x, Select as S } from "@parallelworks/ui";
11
+ import { useNavigate as C } from "@tanstack/react-router";
12
+ import { useState as w } from "react";
13
+ import { useTranslations as T } from "use-intl";
14
+ import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
15
+ import { useMutation as k, useQuery as A, useQueryClient as j, useSuspenseQuery as M } from "@tanstack/react-query";
15
16
  // src/routes/$workspace/dashboards/$dashboardId.tsx?tsr-split=component
16
- function M() {
17
- let i = w("dashboards"), { workspace: a, dashboardId: s } = g.useParams(), { data: l } = j(n(a, s)), { data: v } = j(o(a));
18
- m(l.name);
19
- let y = A(), b = S(), { confirm: k, dialog: M } = p(), N = f(), [P, F] = C(null), I = O({
17
+ function N() {
18
+ let i = T("dashboards"), { workspace: a, dashboardId: s } = _.useParams(), { data: l } = M(n(a, s)), { data: y } = M(o(a));
19
+ h(l.name);
20
+ let b = j(), x = C(), { confirm: A, dialog: N } = m(), P = p(), [F, I] = w(null), L = k({
20
21
  mutationFn: async (n) => t(await e.PATCH("/api/v1/workspaces/{workspace}/dashboards/{dashboardId}", {
21
22
  params: { path: {
22
23
  workspace: a,
@@ -24,57 +25,64 @@ function M() {
24
25
  } },
25
26
  body: n
26
27
  })),
27
- onMutate: N.clear,
28
+ onMutate: P.clear,
28
29
  onSuccess: (e) => {
29
- y.setQueryData(n(a, s).queryKey, e), y.invalidateQueries({ queryKey: r(a).queryKey });
30
+ b.setQueryData(n(a, s).queryKey, e), b.invalidateQueries({ queryKey: r(a).queryKey });
30
31
  },
31
- onError: N.set
32
- }), L = O({
32
+ onError: P.set
33
+ }), R = k({
33
34
  mutationFn: async () => t(await e.DELETE("/api/v1/workspaces/{workspace}/dashboards/{dashboardId}", { params: { path: {
34
35
  workspace: a,
35
36
  dashboardId: s
36
37
  } } })),
37
38
  onSuccess: () => {
38
- y.invalidateQueries({ queryKey: r(a).queryKey }), b({
39
+ b.invalidateQueries({ queryKey: r(a).queryKey }), x({
39
40
  to: "/$workspace/dashboards",
40
41
  params: { workspace: a }
41
42
  });
42
43
  },
43
- onError: N.set
44
- }), z = l.shared ? l.team ? `team:${l.team}` : "workspace" : "private", B = (e) => I.mutate({ panels: e });
45
- return /* @__PURE__ */ D("div", {
44
+ onError: P.set
45
+ }), B = l.shared ? l.team ? `team:${l.team}` : "workspace" : "private", V = (e) => L.mutate({ panels: e });
46
+ return /* @__PURE__ */ O("div", {
46
47
  className: "w-full space-y-6 px-4 py-6 md:px-8 md:py-8",
47
48
  children: [
48
- M,
49
- /* @__PURE__ */ D("div", {
49
+ N,
50
+ /* @__PURE__ */ O("div", {
50
51
  className: "flex flex-wrap items-end justify-between gap-4",
51
- children: [/* @__PURE__ */ D("div", {
52
+ children: [/* @__PURE__ */ O("div", {
52
53
  className: "min-w-0",
53
- children: [/* @__PURE__ */ E(h, {
54
+ children: [/* @__PURE__ */ D(g, {
54
55
  to: "/$workspace/dashboards",
55
56
  params: { workspace: a },
56
57
  className: "text-xs text-muted-foreground hover:underline",
57
58
  children: i("title")
58
- }), /* @__PURE__ */ E("h1", {
59
- className: "truncate text-xl font-semibold tracking-tight",
60
- children: l.name
59
+ }), /* @__PURE__ */ O("div", {
60
+ className: "flex min-w-0 items-center gap-2",
61
+ children: [/* @__PURE__ */ D("h1", {
62
+ className: "truncate text-xl font-semibold tracking-tight",
63
+ children: l.name
64
+ }), /* @__PURE__ */ D(f, {
65
+ workspace: a,
66
+ kind: "dashboard",
67
+ target: l.id
68
+ })]
61
69
  })]
62
- }), /* @__PURE__ */ D("div", {
70
+ }), /* @__PURE__ */ O("div", {
63
71
  className: "flex flex-wrap items-center gap-2",
64
- children: [l.canEdit ? /* @__PURE__ */ E(x, {
72
+ children: [l.canEdit ? /* @__PURE__ */ D(S, {
65
73
  "aria-label": i("sharing"),
66
- value: z,
67
- onValueChange: (e) => e && I.mutate(d(e)),
68
- items: u(i, v),
74
+ value: B,
75
+ onValueChange: (e) => e && L.mutate(d(e)),
76
+ items: u(i, y),
69
77
  size: "sm",
70
78
  width: "content"
71
- }) : /* @__PURE__ */ E("span", {
79
+ }) : /* @__PURE__ */ D("span", {
72
80
  className: "text-xs text-muted-foreground",
73
81
  children: i("ownedBy", { owner: l.owner })
74
- }), l.canEdit && /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(_, {
82
+ }), l.canEdit && /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(v, {
75
83
  size: "sm",
76
84
  variant: "primary",
77
- onClick: () => F({
85
+ onClick: () => I({
78
86
  at: l.panels.length,
79
87
  panel: {
80
88
  title: "",
@@ -87,51 +95,51 @@ function M() {
87
95
  }
88
96
  }),
89
97
  children: i("addPanel")
90
- }), /* @__PURE__ */ E(_, {
98
+ }), /* @__PURE__ */ D(v, {
91
99
  size: "sm",
92
100
  variant: "outline",
93
- onClick: () => k({
101
+ onClick: () => A({
94
102
  title: i("deleteTitle"),
95
103
  description: i("deleteDescription", { name: l.name }),
96
104
  confirmLabel: i("delete"),
97
- onConfirm: () => L.mutateAsync()
105
+ onConfirm: () => R.mutateAsync()
98
106
  }),
99
107
  children: i("delete")
100
108
  })] })]
101
109
  })]
102
110
  }),
103
- N.error && /* @__PURE__ */ E("p", {
111
+ P.error && /* @__PURE__ */ D("p", {
104
112
  className: "text-sm text-danger",
105
- children: N.error
113
+ children: P.error
106
114
  }),
107
- l.panels.length === 0 ? /* @__PURE__ */ E("p", {
115
+ l.panels.length === 0 ? /* @__PURE__ */ D("p", {
108
116
  className: "text-sm text-muted-foreground",
109
117
  children: i("noPanels")
110
- }) : /* @__PURE__ */ E("div", {
118
+ }) : /* @__PURE__ */ D("div", {
111
119
  className: "grid gap-4 md:grid-cols-2 xl:grid-cols-3",
112
- children: l.panels.map((e, t) => /* @__PURE__ */ E(c, {
120
+ children: l.panels.map((e, t) => /* @__PURE__ */ D(c, {
113
121
  workspace: a,
114
122
  panel: e,
115
- onEdit: l.canEdit ? () => F({
123
+ onEdit: l.canEdit ? () => I({
116
124
  at: t,
117
125
  panel: e
118
126
  }) : void 0,
119
- onDelete: l.canEdit ? () => B(l.panels.filter((e, n) => n !== t)) : void 0
127
+ onDelete: l.canEdit ? () => V(l.panels.filter((e, n) => n !== t)) : void 0
120
128
  }, e.id ?? t))
121
129
  }),
122
- P && /* @__PURE__ */ E(R, {
130
+ F && /* @__PURE__ */ D(z, {
123
131
  workspace: a,
124
- initial: P.panel,
125
- onClose: () => F(null),
132
+ initial: F.panel,
133
+ onClose: () => I(null),
126
134
  onSave: (e) => {
127
135
  let t = [...l.panels];
128
- t.splice(P.at, +(P.at < l.panels.length), e), B(t), F(null);
136
+ t.splice(F.at, +(F.at < l.panels.length), e), V(t), I(null);
129
137
  }
130
138
  })
131
139
  ]
132
140
  });
133
141
  }
134
- var N = [
142
+ var P = [
135
143
  "count",
136
144
  "created_completed",
137
145
  "open",
@@ -140,7 +148,7 @@ var N = [
140
148
  "lead_time",
141
149
  "estimate",
142
150
  "sla_breached"
143
- ], P = [
151
+ ], F = [
144
152
  "bar",
145
153
  "stacked",
146
154
  "line",
@@ -148,7 +156,7 @@ var N = [
148
156
  "number",
149
157
  "table",
150
158
  "list"
151
- ], F = [
159
+ ], I = [
152
160
  "",
153
161
  "team",
154
162
  "assignee",
@@ -157,30 +165,30 @@ var N = [
157
165
  "priority",
158
166
  "status",
159
167
  "type"
160
- ], I = /* @__PURE__ */ new Set([
168
+ ], L = /* @__PURE__ */ new Set([
161
169
  "created_completed",
162
170
  "open",
163
171
  "throughput",
164
172
  "cycle_time",
165
173
  "lead_time"
166
- ]), L = [
174
+ ]), R = [
167
175
  "active",
168
176
  "backlog",
169
177
  "done",
170
178
  "all"
171
179
  ];
172
- function R({ workspace: e, initial: t, onClose: n, onSave: r }) {
173
- let c = w("dashboards"), [u, d] = C(t), { data: f = [] } = k(o(e)), { data: p = [] } = k(s(e)), { data: m = [] } = k(i(e)), { data: h } = k(a(e, u.chart, u.spec)), g = u.spec, S = g.filters, O = (e) => d((t) => ({
180
+ function z({ workspace: e, initial: t, onClose: n, onSave: r }) {
181
+ let c = T("dashboards"), [u, d] = w(t), { data: f = [] } = A(o(e)), { data: p = [] } = A(s(e)), { data: m = [] } = A(i(e)), { data: h } = A(a(e, u.chart, u.spec)), g = u.spec, _ = g.filters, C = (e) => d((t) => ({
174
182
  ...t,
175
183
  spec: Object.fromEntries(Object.entries({
176
184
  ...t.spec,
177
185
  ...e
178
186
  }).filter(([, e]) => e !== void 0))
179
- })), A = (e) => O({ filters: Object.fromEntries(Object.entries({
180
- ...S,
187
+ })), k = (e) => C({ filters: Object.fromEntries(Object.entries({
188
+ ..._,
181
189
  ...e
182
190
  }).filter(([, e]) => e)) }), { viewId: j, ...M } = g;
183
- return /* @__PURE__ */ E(b, {
191
+ return /* @__PURE__ */ D(x, {
184
192
  open: !0,
185
193
  onClose: n,
186
194
  title: t.id ? c("editPanel") : c("addPanel"),
@@ -188,23 +196,23 @@ function R({ workspace: e, initial: t, onClose: n, onSave: r }) {
188
196
  onSubmit: (e) => {
189
197
  e.preventDefault(), r(u);
190
198
  },
191
- footer: /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(_, {
199
+ footer: /* @__PURE__ */ O(E, { children: [/* @__PURE__ */ D(v, {
192
200
  variant: "ghost",
193
201
  onClick: n,
194
202
  children: c("cancel")
195
- }), /* @__PURE__ */ E(_, {
203
+ }), /* @__PURE__ */ D(v, {
196
204
  type: "submit",
197
205
  variant: "primary",
198
206
  children: c("save")
199
207
  })] }),
200
- children: /* @__PURE__ */ D("div", {
208
+ children: /* @__PURE__ */ O("div", {
201
209
  className: "grid gap-4 md:grid-cols-2",
202
- children: [/* @__PURE__ */ D("div", {
210
+ children: [/* @__PURE__ */ O("div", {
203
211
  className: "space-y-3",
204
212
  children: [
205
- /* @__PURE__ */ E(v, {
213
+ /* @__PURE__ */ D(y, {
206
214
  label: c("panelTitle"),
207
- children: /* @__PURE__ */ E(y, {
215
+ children: /* @__PURE__ */ D(b, {
208
216
  value: u.title,
209
217
  placeholder: c(`measures.${g.measure}`),
210
218
  onChange: (e) => d({
@@ -214,47 +222,47 @@ function R({ workspace: e, initial: t, onClose: n, onSave: r }) {
214
222
  maxLength: 200
215
223
  })
216
224
  }),
217
- /* @__PURE__ */ E(v, {
225
+ /* @__PURE__ */ D(y, {
218
226
  label: c("measure"),
219
- children: /* @__PURE__ */ E(x, {
227
+ children: /* @__PURE__ */ D(S, {
220
228
  value: g.measure,
221
- onValueChange: (e) => e && O({ measure: e }),
222
- items: N.map((e) => ({
229
+ onValueChange: (e) => e && C({ measure: e }),
230
+ items: P.map((e) => ({
223
231
  value: e,
224
232
  label: c(`measures.${e}`)
225
233
  }))
226
234
  })
227
235
  }),
228
- g.measure !== "created_completed" && /* @__PURE__ */ E(v, {
236
+ g.measure !== "created_completed" && /* @__PURE__ */ D(y, {
229
237
  label: c("groupBy"),
230
- children: /* @__PURE__ */ E(x, {
238
+ children: /* @__PURE__ */ D(S, {
231
239
  value: g.groupBy ?? "",
232
- onValueChange: (e) => O(e ? { groupBy: e } : { groupBy: void 0 }),
233
- items: F.map((e) => ({
240
+ onValueChange: (e) => C(e ? { groupBy: e } : { groupBy: void 0 }),
241
+ items: I.map((e) => ({
234
242
  value: e,
235
243
  label: c(`groupings.${e || "none"}`)
236
244
  }))
237
245
  })
238
246
  }),
239
- /* @__PURE__ */ E(v, {
247
+ /* @__PURE__ */ D(y, {
240
248
  label: c("chart"),
241
- children: /* @__PURE__ */ E(x, {
249
+ children: /* @__PURE__ */ D(S, {
242
250
  value: u.chart,
243
251
  onValueChange: (e) => e && d({
244
252
  ...u,
245
253
  chart: e
246
254
  }),
247
- items: P.map((e) => ({
255
+ items: F.map((e) => ({
248
256
  value: e,
249
257
  label: c(`charts.${e}`)
250
258
  }))
251
259
  })
252
260
  }),
253
- I.has(g.measure) && /* @__PURE__ */ E(v, {
261
+ L.has(g.measure) && /* @__PURE__ */ D(y, {
254
262
  label: c("weeks"),
255
- children: /* @__PURE__ */ E(x, {
263
+ children: /* @__PURE__ */ D(S, {
256
264
  value: String(g.weeks ?? 12),
257
- onValueChange: (e) => e && O({ weeks: Number(e) }),
265
+ onValueChange: (e) => e && C({ weeks: Number(e) }),
258
266
  items: [
259
267
  4,
260
268
  8,
@@ -267,9 +275,9 @@ function R({ workspace: e, initial: t, onClose: n, onSave: r }) {
267
275
  }))
268
276
  })
269
277
  }),
270
- /* @__PURE__ */ E(v, {
278
+ /* @__PURE__ */ D(y, {
271
279
  label: c("issuesFrom"),
272
- children: /* @__PURE__ */ E(x, {
280
+ children: /* @__PURE__ */ D(S, {
273
281
  value: g.viewId ?? "",
274
282
  onValueChange: (e) => d({
275
283
  ...u,
@@ -287,13 +295,13 @@ function R({ workspace: e, initial: t, onClose: n, onSave: r }) {
287
295
  }))]
288
296
  })
289
297
  }),
290
- !g.viewId && /* @__PURE__ */ D("div", {
298
+ !g.viewId && /* @__PURE__ */ O("div", {
291
299
  className: "grid grid-cols-2 gap-2",
292
300
  children: [
293
- /* @__PURE__ */ E(x, {
301
+ /* @__PURE__ */ D(S, {
294
302
  "aria-label": c("team"),
295
- value: S.team ?? "",
296
- onValueChange: (e) => A({ team: e ?? "" }),
303
+ value: _.team ?? "",
304
+ onValueChange: (e) => k({ team: e ?? "" }),
297
305
  items: [{
298
306
  value: "",
299
307
  label: c("allTeams")
@@ -303,20 +311,20 @@ function R({ workspace: e, initial: t, onClose: n, onSave: r }) {
303
311
  }))],
304
312
  size: "sm"
305
313
  }),
306
- /* @__PURE__ */ E(x, {
314
+ /* @__PURE__ */ D(S, {
307
315
  "aria-label": c("tab"),
308
- value: S.view ?? "active",
309
- onValueChange: (e) => A({ view: e ?? "active" }),
310
- items: L.map((e) => ({
316
+ value: _.view ?? "active",
317
+ onValueChange: (e) => k({ view: e ?? "active" }),
318
+ items: R.map((e) => ({
311
319
  value: e,
312
320
  label: c(`tabs.${e}`)
313
321
  })),
314
322
  size: "sm"
315
323
  }),
316
- /* @__PURE__ */ E(x, {
324
+ /* @__PURE__ */ D(S, {
317
325
  "aria-label": c("priority"),
318
- value: S.priority ?? "",
319
- onValueChange: (e) => A({ priority: e ?? "" }),
326
+ value: _.priority ?? "",
327
+ onValueChange: (e) => k({ priority: e ?? "" }),
320
328
  items: [{
321
329
  value: "",
322
330
  label: c("anyPriority")
@@ -332,10 +340,10 @@ function R({ workspace: e, initial: t, onClose: n, onSave: r }) {
332
340
  }))],
333
341
  size: "sm"
334
342
  }),
335
- /* @__PURE__ */ E(x, {
343
+ /* @__PURE__ */ D(S, {
336
344
  "aria-label": c("label"),
337
- value: S.label ?? "",
338
- onValueChange: (e) => A({ label: e ?? "" }),
345
+ value: _.label ?? "",
346
+ onValueChange: (e) => k({ label: e ?? "" }),
339
347
  items: [{
340
348
  value: "",
341
349
  label: c("anyLabel")
@@ -348,16 +356,16 @@ function R({ workspace: e, initial: t, onClose: n, onSave: r }) {
348
356
  ]
349
357
  })
350
358
  ]
351
- }), /* @__PURE__ */ D("div", {
359
+ }), /* @__PURE__ */ O("div", {
352
360
  className: "min-w-0 rounded-md border border-border p-3",
353
- children: [/* @__PURE__ */ E("p", {
361
+ children: [/* @__PURE__ */ D("p", {
354
362
  className: "mb-2 text-xs font-medium text-muted-foreground",
355
363
  children: c("preview")
356
- }), h ? /* @__PURE__ */ E(l, {
364
+ }), h ? /* @__PURE__ */ D(l, {
357
365
  workspace: e,
358
366
  panel: u,
359
367
  data: h
360
- }) : /* @__PURE__ */ E("p", {
368
+ }) : /* @__PURE__ */ D("p", {
361
369
  className: "text-sm text-muted-foreground",
362
370
  children: c("loading")
363
371
  })]
@@ -365,4 +373,4 @@ function R({ workspace: e, initial: t, onClose: n, onSave: r }) {
365
373
  })
366
374
  });
367
375
  }
368
- export { M as component };
376
+ export { N as component };