@parallelworks/tandem-web 0.192.1 → 0.193.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,115 +1,164 @@
1
1
  import { api as e, unwrap as t } from "../api/client.js";
2
2
  import { invalidateIssueViews as n } from "../api/mutations.js";
3
- import { Link as r } from "../lib/router.js";
4
- import { Button as i, ErrorText as a, Modal as o, ModalTitle as s } from "@parallelworks/ui";
5
- import { useEffect as c, useRef as l, useState as u } from "react";
6
- import { useErrorMessage as d } from "@parallelworks/problem/react";
7
- import { useTranslations as f } from "use-intl";
8
- import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
9
- import { useMutation as g, useQueryClient as _ } from "@tanstack/react-query";
3
+ import { basePath as r } from "../lib/base.js";
4
+ import { Link as i } from "../lib/router.js";
5
+ import { DownloadIcon as a, UploadIcon as o } from "./icons.js";
6
+ import { Button as s, ErrorText as c, Modal as l, ModalTitle as u, SettingRow as d, SettingsCard as f } from "@parallelworks/ui";
7
+ import { useEffect as p, useRef 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, useQueryClient as S } from "@tanstack/react-query";
10
12
  // src/components/IssueImport.tsx
11
- function v(e) {
13
+ function C({ workspace: e, team: t, canImport: n }) {
14
+ let r = _("issueImport.settings"), [i, c] = h(null);
15
+ return /* @__PURE__ */ b(f, {
16
+ title: r("title"),
17
+ description: r("description"),
18
+ children: [
19
+ /* @__PURE__ */ y(d, {
20
+ label: r("export"),
21
+ helpText: r("exportHelp"),
22
+ children: /* @__PURE__ */ y(s, {
23
+ size: "sm",
24
+ icon: /* @__PURE__ */ y(a, { className: "size-3.5" }),
25
+ onClick: () => w(e, { team: t }),
26
+ children: r("exportButton")
27
+ })
28
+ }),
29
+ n && /* @__PURE__ */ y(d, {
30
+ label: r("import"),
31
+ helpText: r("importHelp"),
32
+ children: /* @__PURE__ */ y(s, {
33
+ size: "sm",
34
+ icon: /* @__PURE__ */ y(o, { className: "size-3.5" }),
35
+ onClick: () => T((e, t) => c({
36
+ name: e,
37
+ text: t
38
+ })),
39
+ children: r("importButton")
40
+ })
41
+ }),
42
+ i && /* @__PURE__ */ y(E, {
43
+ workspace: e,
44
+ team: t,
45
+ file: i,
46
+ onClose: () => c(null)
47
+ })
48
+ ]
49
+ });
50
+ }
51
+ function w(e, t) {
52
+ let n = new URLSearchParams({
53
+ triage: "exclude",
54
+ archived: "exclude"
55
+ });
56
+ for (let [e, r] of Object.entries(t)) n.set(e, Array.isArray(r) ? r.join(",") : String(r));
57
+ let i = document.createElement("a");
58
+ i.href = `${r}/api/v1/workspaces/${encodeURIComponent(e)}/exports/issues.csv?${n}`, i.download = "", i.click();
59
+ }
60
+ function T(e) {
12
61
  let t = document.createElement("input");
13
62
  t.type = "file", t.accept = ".csv,text/csv", t.onchange = async () => {
14
63
  let n = t.files?.[0];
15
64
  n && e(n.name, await n.text());
16
65
  }, t.click();
17
66
  }
18
- function y({ workspace: r, team: v, file: y, onClose: x }) {
19
- let S = f("issueImport"), C = d(), w = _(), [T, E] = u(!1), D = g({
67
+ function E({ workspace: r, team: i, file: a, onClose: o }) {
68
+ let d = _("issueImport"), f = g(), C = S(), [w, T] = h(!1), E = x({
20
69
  mutationFn: async (n) => t(await e.POST("/api/v1/workspaces/{workspace}/teams/{key}/issues/import", {
21
70
  params: { path: {
22
71
  workspace: r,
23
- key: v
72
+ key: i
24
73
  } },
25
74
  body: {
26
- csv: y.text,
75
+ csv: a.text,
27
76
  dryRun: n
28
77
  }
29
78
  })),
30
79
  onSuccess: (e, t) => {
31
- t || (E(!0), n(w, r));
80
+ t || (T(!0), n(C, r));
32
81
  }
33
- }), O = l(!1), k = l(D.mutate);
34
- c(() => {
82
+ }), O = m(!1), k = m(E.mutate);
83
+ p(() => {
35
84
  O.current || (O.current = !0, k.current(!0));
36
85
  }, []);
37
- let A = D.data;
38
- return /* @__PURE__ */ h(o, {
86
+ let A = E.data;
87
+ return /* @__PURE__ */ b(l, {
39
88
  open: !0,
40
- onClose: x,
89
+ onClose: o,
41
90
  className: "w-full max-w-2xl p-5",
42
91
  children: [
43
- /* @__PURE__ */ m(s, {
92
+ /* @__PURE__ */ y(u, {
44
93
  className: "text-sm font-semibold",
45
- children: S("title", { file: y.name })
94
+ children: d("title", { file: a.name })
46
95
  }),
47
- /* @__PURE__ */ h("div", {
96
+ /* @__PURE__ */ b("div", {
48
97
  className: "mt-3 text-sm",
49
98
  "aria-live": "polite",
50
99
  children: [
51
- D.isPending && /* @__PURE__ */ m("p", {
100
+ E.isPending && /* @__PURE__ */ y("p", {
52
101
  className: "text-muted-foreground",
53
- children: S(T ? "importing" : "reading")
102
+ children: d(w ? "importing" : "reading")
54
103
  }),
55
- D.isError && /* @__PURE__ */ m(a, {
104
+ E.isError && /* @__PURE__ */ y(c, {
56
105
  size: "md",
57
- children: C(D.error)
106
+ children: f(E.error)
58
107
  }),
59
- A && /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m("p", { children: T ? S("imported", { count: A.imported }) : S("preview", {
108
+ A && /* @__PURE__ */ b(v, { children: [/* @__PURE__ */ y("p", { children: w ? d("imported", { count: A.imported }) : d("preview", {
60
109
  count: A.imported,
61
110
  skipped: A.rows.length - A.imported
62
- }) }), /* @__PURE__ */ m("ol", {
111
+ }) }), /* @__PURE__ */ y("ol", {
63
112
  className: "mt-3 max-h-80 divide-y divide-border overflow-y-auto rounded-md border border-border",
64
- children: A.rows.map((e) => /* @__PURE__ */ m(b, {
113
+ children: A.rows.map((e) => /* @__PURE__ */ y(D, {
65
114
  workspace: r,
66
115
  row: e
67
116
  }, e.row))
68
117
  })] })
69
118
  ]
70
119
  }),
71
- /* @__PURE__ */ h("div", {
120
+ /* @__PURE__ */ b("div", {
72
121
  className: "mt-5 flex justify-end gap-2",
73
- children: [/* @__PURE__ */ m(i, {
74
- onClick: x,
75
- children: S(T ? "close" : "cancel")
76
- }), !T && A && A.imported > 0 && /* @__PURE__ */ m(i, {
122
+ children: [/* @__PURE__ */ y(s, {
123
+ onClick: o,
124
+ children: d(w ? "close" : "cancel")
125
+ }), !w && A && A.imported > 0 && /* @__PURE__ */ y(s, {
77
126
  variant: "primary",
78
- loading: D.isPending,
79
- onClick: () => D.mutate(!1),
80
- children: S("import", { count: A.imported })
127
+ loading: E.isPending,
128
+ onClick: () => E.mutate(!1),
129
+ children: d("import", { count: A.imported })
81
130
  })]
82
131
  })
83
132
  ]
84
133
  });
85
134
  }
86
- function b({ workspace: e, row: t }) {
87
- let n = f("issueImport");
88
- return /* @__PURE__ */ h("li", {
135
+ function D({ workspace: e, row: t }) {
136
+ let n = _("issueImport");
137
+ return /* @__PURE__ */ b("li", {
89
138
  className: "flex gap-3 px-3 py-2 text-xs",
90
139
  children: [
91
- /* @__PURE__ */ m("span", {
140
+ /* @__PURE__ */ y("span", {
92
141
  className: "w-8 shrink-0 text-right text-muted-foreground tabular-nums",
93
142
  children: t.row
94
143
  }),
95
- /* @__PURE__ */ h("span", {
144
+ /* @__PURE__ */ b("span", {
96
145
  className: "min-w-0 flex-1",
97
146
  children: [
98
- /* @__PURE__ */ m("span", {
147
+ /* @__PURE__ */ y("span", {
99
148
  className: t.skipped ? "text-muted-foreground line-through" : "",
100
149
  children: t.title || n("untitled")
101
150
  }),
102
- t.skipped && /* @__PURE__ */ m("span", {
151
+ t.skipped && /* @__PURE__ */ y("span", {
103
152
  className: "ml-2 text-danger",
104
153
  children: n(`skipped.${t.skipped}`)
105
154
  }),
106
- t.warnings.length > 0 && /* @__PURE__ */ m("span", {
155
+ t.warnings.length > 0 && /* @__PURE__ */ y("span", {
107
156
  className: "mt-0.5 block text-muted-foreground",
108
157
  children: n("leftOut", { values: t.warnings.map((e) => `${e.field === "field" && e.name ? e.name : n(`field.${e.field}`)} “${e.value}”`).join(", ") })
109
158
  })
110
159
  ]
111
160
  }),
112
- t.identifier && /* @__PURE__ */ m(r, {
161
+ t.identifier && /* @__PURE__ */ y(i, {
113
162
  to: "/$workspace/issues/$identifier",
114
163
  params: {
115
164
  workspace: e,
@@ -121,4 +170,4 @@ function b({ workspace: e, row: t }) {
121
170
  ]
122
171
  });
123
172
  }
124
- export { y as IssueImport, v as pickCsv };
173
+ export { E as IssueImport, C as TeamImportExport, T as pickCsv };