@parallelworks/tandem-web 0.189.7 → 0.189.9

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,207 +1,152 @@
1
1
  import { api as e, unwrap as t } from "../api/client.js";
2
- import { meQuery as n, statusesQuery as r, teamsQuery as i } from "../api/queries.js";
3
- import { useIssuePicker as a } from "../lib/issuePicker.js";
4
- import { useCanTriage as o } from "../lib/roles.js";
2
+ import { statusesQuery as n, teamsQuery as r } from "../api/queries.js";
3
+ import { useIssuePicker as i } from "../lib/issuePicker.js";
4
+ import { useCanTriage as a } from "../lib/roles.js";
5
+ import { useShortcuts as o } from "../lib/shortcuts.js";
5
6
  import { TriageIcon as s } from "./icons.js";
6
- import { Button as c, Checkbox as l, Combobox as u, Popover as d, Select as f, Textarea as p } from "@parallelworks/ui";
7
- import { useId as m, useState as h } from "react";
8
- import { useErrorMessage as g } from "@parallelworks/problem/react";
9
- import { useTranslations as _ } from "use-intl";
10
- import { Fragment as v, jsx as y, jsxs as b } from "react/jsx-runtime";
11
- import { useMutation as x, useQuery as S, useQueryClient as C } from "@tanstack/react-query";
12
- import { CheckIcon as w, CloseIcon as T, DuplicateIcon as E } from "@parallelworks/ui/icons";
7
+ import { Button as c, Checkbox as l, Combobox as u, Select as d, Textarea as f } from "@parallelworks/ui";
8
+ import { useId as p, useState as m } from "react";
9
+ import { useErrorMessage as h } from "@parallelworks/problem/react";
10
+ import { useTranslations as g } from "use-intl";
11
+ import { jsx as _, jsxs as v } from "react/jsx-runtime";
12
+ import { useMutation as y, useQuery as b, useQueryClient as x } from "@tanstack/react-query";
13
+ import { CheckIcon as S, CloseIcon as C, DuplicateIcon as w } from "@parallelworks/ui/icons";
13
14
  // src/components/TriageBanner.tsx
14
- function D({ workspace: e, issue: t }) {
15
- let n = _("triage");
16
- return /* @__PURE__ */ b("div", {
17
- className: "mb-5 flex flex-wrap items-center gap-3 rounded-xl border border-border bg-muted/40 px-4 py-3",
18
- children: [
19
- /* @__PURE__ */ y(s, { className: "size-4 shrink-0 text-muted-foreground" }),
20
- /* @__PURE__ */ y("p", {
21
- className: "min-w-48 flex-1 text-sm",
22
- children: n("waiting")
23
- }),
24
- /* @__PURE__ */ y(O, {
25
- workspace: e,
26
- issue: t
27
- })
28
- ]
15
+ function T({ workspace: e, issue: t, shortcuts: n = !1 }) {
16
+ let r = g("triage");
17
+ return /* @__PURE__ */ v("div", {
18
+ className: "mb-5 flex flex-col gap-3 rounded-xl border border-border bg-muted/40 px-4 py-3",
19
+ children: [/* @__PURE__ */ v("p", {
20
+ className: "flex items-center gap-2 text-sm",
21
+ children: [/* @__PURE__ */ _(s, { className: "size-4 shrink-0 text-muted-foreground" }), r("waiting")]
22
+ }), /* @__PURE__ */ _(D, {
23
+ workspace: e,
24
+ issue: t,
25
+ shortcuts: n
26
+ })]
29
27
  });
30
28
  }
31
- function O({ workspace: s, issue: D, compact: O = !1 }) {
32
- let k = _("triage"), A = g(), j = C(), M = o(s, D.teamId), { data: N = [] } = S(i(s)), P = N.find((e) => e.id === D.teamId)?.key ?? "", { data: F = [] } = S({
33
- ...r(s, P),
34
- enabled: !!P
35
- }), { data: I } = S(n), L = { params: { path: {
36
- workspace: s,
37
- identifier: D.identifier
38
- } } }, R = (t) => e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/triage", {
39
- ...L,
40
- body: { decision: t }
41
- }), z = () => j.invalidateQueries({ queryKey: [
42
- "workspace",
43
- s,
44
- "issues"
45
- ] }), [B, V] = h(""), [H, U] = h(!1), W = x({
46
- mutationFn: async () => {
47
- let n = I?.user.username, r = H && n ? [{
48
- kind: "user",
49
- handle: n
50
- }] : void 0;
51
- B ? t(await e.PATCH("/api/v1/workspaces/{workspace}/issues/{identifier}", {
52
- ...L,
53
- body: {
54
- statusId: B,
55
- ...r && { addAssignees: r }
56
- }
57
- })) : (t(await R("accept")), r && t(await e.PATCH("/api/v1/workspaces/{workspace}/issues/{identifier}", {
58
- ...L,
59
- body: { addAssignees: r }
60
- })));
61
- },
62
- onSuccess: z
63
- }), [G, K] = h(""), q = x({
64
- mutationFn: async () => {
65
- G.trim() && t(await e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/comments", {
66
- ...L,
67
- body: { body: G.trim() }
68
- })), t(await R("decline"));
69
- },
70
- onSuccess: z
71
- }), J = x({
72
- mutationFn: async (n) => {
73
- t(await e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/relations", {
74
- ...L,
75
- body: {
76
- type: "duplicate",
77
- issue: n
78
- }
79
- })), t(await R("decline"));
80
- },
81
- onSuccess: z
82
- }), Y = a(s, (e) => e.identifier !== D.identifier), X = m(), Z = W.error ?? q.error ?? J.error, Q = W.isPending || q.isPending || J.isPending, $ = F.filter((e) => e.category !== "triage" && e.category !== "canceled");
83
- return M ? /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ b("span", {
84
- className: O ? "flex items-center gap-0.5" : "flex flex-wrap gap-2",
29
+ function E(e) {
30
+ let t = e.filter((e) => e.category !== "triage" && e.category !== "completed" && e.category !== "canceled");
31
+ return t.find((e) => e.category === "unstarted") ?? t[0];
32
+ }
33
+ function D({ workspace: s, issue: T, shortcuts: D = !1 }) {
34
+ let O = g("triage"), k = h(), A = x(), j = a(s, T.teamId), { data: M = [] } = b(r(s)), N = M.find((e) => e.id === T.teamId)?.key ?? "", { data: P = [] } = b({
35
+ ...n(s, N),
36
+ enabled: !!N
37
+ }), F = y({
38
+ mutationFn: async (n) => t(await e.POST("/api/v1/workspaces/{workspace}/issues/{identifier}/triage", {
39
+ params: { path: {
40
+ workspace: s,
41
+ identifier: T.identifier
42
+ } },
43
+ body: n
44
+ })),
45
+ onSuccess: () => A.invalidateQueries({ queryKey: [
46
+ "workspace",
47
+ s,
48
+ "issues"
49
+ ] })
50
+ }), I = P.filter((e) => e.category !== "triage" && e.category !== "completed" && e.category !== "canceled"), [L, R] = m(null), z = L ?? E(P)?.id ?? "", [B, V] = m(T.assignees.length === 0), [H, U] = m(!1), [W, G] = m(""), K = i(s, (e) => e.identifier !== T.identifier), q = p(), J = () => F.mutate({
51
+ decision: "accept",
52
+ ...z && { statusId: z },
53
+ assignToMe: B
54
+ }), Y = () => F.mutate({
55
+ decision: "decline",
56
+ reason: W.trim()
57
+ });
58
+ if (o({
59
+ 1: J,
60
+ 2: Y
61
+ }, D && j && !F.isPending), !j) return null;
62
+ let X = F.isPending;
63
+ return /* @__PURE__ */ v("div", {
64
+ className: "flex flex-col gap-2",
85
65
  children: [
86
- /* @__PURE__ */ y(u, {
87
- "aria-label": k("markDuplicate"),
88
- ...Y,
89
- value: null,
90
- onValueChange: (e) => e && J.mutate(e),
91
- placeholder: k("findIssue"),
92
- trigger: O ? /* @__PURE__ */ y(c, {
93
- variant: "ghost",
94
- size: "sm",
95
- "aria-label": k("markDuplicate"),
96
- title: k("markDuplicate"),
97
- disabled: Q,
98
- children: /* @__PURE__ */ y(E, {})
99
- }) : /* @__PURE__ */ y(c, {
100
- variant: "ghost",
101
- size: "sm",
102
- disabled: Q,
103
- children: k("markDuplicate")
104
- })
105
- }),
106
- /* @__PURE__ */ y(d, {
107
- trigger: O ? /* @__PURE__ */ y(c, {
108
- variant: "ghost",
109
- size: "sm",
110
- "aria-label": k("decline"),
111
- title: k("decline"),
112
- disabled: Q,
113
- children: /* @__PURE__ */ y(T, {})
114
- }) : /* @__PURE__ */ y(c, {
115
- variant: "outline",
116
- size: "sm",
117
- disabled: Q,
118
- children: k("decline")
119
- }),
120
- align: "end",
121
- className: "w-80",
122
- "aria-label": k("decline"),
123
- children: /* @__PURE__ */ b("form", {
124
- className: "flex flex-col gap-2",
125
- onSubmit: (e) => {
126
- e.preventDefault(), q.mutate();
127
- },
128
- children: [/* @__PURE__ */ y(p, {
129
- value: G,
130
- onChange: (e) => K(e.target.value),
131
- placeholder: k("declineReason"),
132
- "aria-label": k("declineReason"),
133
- rows: 3
134
- }), /* @__PURE__ */ y(c, {
135
- type: "submit",
66
+ /* @__PURE__ */ v("div", {
67
+ className: "flex flex-wrap items-center gap-2",
68
+ children: [
69
+ /* @__PURE__ */ _(d, {
70
+ "aria-label": O("acceptInto"),
71
+ value: z,
72
+ items: I.map((e) => ({
73
+ value: e.id,
74
+ label: e.name
75
+ })),
76
+ onValueChange: (e) => e && R(e),
77
+ className: "w-36"
78
+ }),
79
+ /* @__PURE__ */ v("span", {
80
+ className: "flex items-center gap-1.5 text-sm",
81
+ children: [/* @__PURE__ */ _(l, {
82
+ id: q,
83
+ checked: B,
84
+ onCheckedChange: (e) => V(e === !0)
85
+ }), /* @__PURE__ */ _("label", {
86
+ htmlFor: q,
87
+ children: O("assignToMe")
88
+ })]
89
+ }),
90
+ /* @__PURE__ */ v(c, {
136
91
  variant: "primary",
137
92
  size: "sm",
138
- loading: q.isPending,
139
- className: "self-end",
140
- children: k("decline")
141
- })]
142
- })
93
+ onClick: J,
94
+ disabled: X,
95
+ title: O("acceptKey"),
96
+ children: [/* @__PURE__ */ _(S, {}), O("accept")]
97
+ })
98
+ ]
143
99
  }),
144
- /* @__PURE__ */ y(d, {
145
- trigger: O ? /* @__PURE__ */ y(c, {
146
- variant: "ghost",
147
- size: "sm",
148
- "aria-label": k("accept"),
149
- title: k("accept"),
150
- disabled: Q,
151
- children: /* @__PURE__ */ y(w, {})
152
- }) : /* @__PURE__ */ y(c, {
153
- variant: "primary",
154
- size: "sm",
155
- disabled: Q,
156
- children: k("accept")
157
- }),
158
- align: "end",
159
- className: "w-72",
160
- "aria-label": k("accept"),
161
- children: /* @__PURE__ */ b("form", {
162
- className: "flex flex-col gap-3",
163
- onSubmit: (e) => {
164
- e.preventDefault(), W.mutate();
165
- },
166
- children: [
167
- /* @__PURE__ */ y(f, {
168
- "aria-label": k("acceptInto"),
169
- value: B,
170
- items: [{
171
- value: "",
172
- label: k("acceptWhereItIs")
173
- }, ...$.map((e) => ({
174
- value: e.id,
175
- label: e.name
176
- }))],
177
- onValueChange: (e) => V(e ?? "")
178
- }),
179
- /* @__PURE__ */ b("span", {
180
- className: "flex items-center gap-2 text-sm",
181
- children: [/* @__PURE__ */ y(l, {
182
- id: X,
183
- checked: H,
184
- onCheckedChange: (e) => U(e === !0)
185
- }), /* @__PURE__ */ y("label", {
186
- htmlFor: X,
187
- children: k("assignToMe")
188
- })]
100
+ /* @__PURE__ */ v("div", {
101
+ className: "flex flex-wrap items-center gap-2",
102
+ children: [
103
+ /* @__PURE__ */ v(c, {
104
+ variant: "outline",
105
+ size: "sm",
106
+ onClick: Y,
107
+ disabled: X,
108
+ title: O("declineKey"),
109
+ children: [/* @__PURE__ */ _(C, {}), O("decline")]
110
+ }),
111
+ !H && /* @__PURE__ */ _(c, {
112
+ variant: "ghost",
113
+ size: "sm",
114
+ onClick: () => U(!0),
115
+ disabled: X,
116
+ children: O("addReason")
117
+ }),
118
+ /* @__PURE__ */ _(u, {
119
+ "aria-label": O("markDuplicate"),
120
+ ...K,
121
+ value: null,
122
+ onValueChange: (e) => e && F.mutate({
123
+ decision: "duplicate",
124
+ duplicateOf: e,
125
+ reason: W.trim()
189
126
  }),
190
- /* @__PURE__ */ y(c, {
191
- type: "submit",
192
- variant: "primary",
127
+ placeholder: O("findIssue"),
128
+ trigger: /* @__PURE__ */ v(c, {
129
+ variant: "ghost",
193
130
  size: "sm",
194
- loading: W.isPending,
195
- className: "self-end",
196
- children: k("accept")
131
+ disabled: X,
132
+ children: [/* @__PURE__ */ _(w, {}), O("markDuplicate")]
197
133
  })
198
- ]
199
- })
134
+ })
135
+ ]
136
+ }),
137
+ H && /* @__PURE__ */ _(f, {
138
+ value: W,
139
+ onChange: (e) => G(e.target.value),
140
+ placeholder: O("declineReason"),
141
+ "aria-label": O("declineReason"),
142
+ rows: 2,
143
+ autoFocus: !0
144
+ }),
145
+ F.error && /* @__PURE__ */ _("p", {
146
+ className: "text-xs text-danger",
147
+ children: k(F.error)
200
148
  })
201
149
  ]
202
- }), Z && /* @__PURE__ */ y("p", {
203
- className: "basis-full text-xs text-danger",
204
- children: A(Z)
205
- })] }) : null;
150
+ });
206
151
  }
207
- export { O as TriageActions, D as TriageBanner };
152
+ export { D as TriageActions, T as TriageBanner, E as acceptStatus };
@@ -221,11 +221,11 @@ var H = S.create({
221
221
  },
222
222
  props: {
223
223
  decorations: (e) => z.getState(e),
224
- handleClickOn: (t, n, r, i, a) => r.type.name !== "image" || !e(r.attrs.src) ? !1 : (a.preventDefault(), t.dom.dispatchEvent(new CustomEvent(P, {
224
+ handleClickOn: (e, t, n, r, i) => n.type.name !== "image" || i.button !== 0 ? !1 : (i.preventDefault(), e.dom.dispatchEvent(new CustomEvent(P, {
225
225
  bubbles: !0,
226
226
  detail: {
227
- src: r.attrs.src,
228
- name: r.attrs.alt ?? ""
227
+ src: n.attrs.src,
228
+ name: n.attrs.alt ?? ""
229
229
  }
230
230
  })), !0),
231
231
  handleClick: (t, n, i) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parallelworks/tandem-web",
3
- "version": "0.189.7",
3
+ "version": "0.189.9",
4
4
  "description": "Tandem's pages, for a host app to render in its own",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",