@parallelworks/tandem-web 0.162.0 → 0.164.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.
@@ -2,235 +2,254 @@ import { api as e, unwrap as t } from "../api/client.js";
2
2
  import { Link as n } from "../lib/router.js";
3
3
  import { availableRepositoriesQuery as r, codeHostQuery as i, githubSettingsQuery as a, repositoriesQuery as o, teamsQuery as s } from "../api/queries.js";
4
4
  import { copyItem as c } from "../lib/menus.js";
5
- import { externalUrl as ee } from "../lib/externalUrl.js";
6
- import { AddIcon as l, CodeHostIcon as u, RepositoryIcon as d } from "./icons.js";
7
- import { useConfirm as f } from "../lib/confirm.js";
8
- import { useFormError as p } from "./settings.js";
9
- import { RepositoryIssueSync as m } from "./GitHub.js";
10
- import { Button as h, Card as g, Checkbox as te, Combobox as _, ErrorText as v, InfoTip as y, Section as b, Tooltip as ne, menuDivider as x, useOpenMenu as S } from "@parallelworks/ui";
11
- import { useState as C } from "react";
12
- import { useTranslations as w } from "use-intl";
13
- import { jsx as T, jsxs as E } from "react/jsx-runtime";
14
- import { useMutation as D, useQuery as O, useQueryClient as re, useSuspenseQuery as k } from "@tanstack/react-query";
5
+ import { externalUrl as l } from "../lib/externalUrl.js";
6
+ import { AddIcon as ee, CodeHostIcon as te, RepositoryIcon as u } from "./icons.js";
7
+ import { useConfirm as d } from "../lib/confirm.js";
8
+ import { useFormError as f } from "./settings.js";
9
+ import { RepositoryIssueSync as p } from "./GitHub.js";
10
+ import { Button as m, Card as h, Checkbox as g, Combobox as ne, ErrorText as _, InfoTip as v, Section as y, Tooltip as b, menuDivider as x, useOpenMenu as re } from "@parallelworks/ui";
11
+ import { useState as ie } from "react";
12
+ import { useTranslations as S } from "use-intl";
13
+ import { jsx as C, jsxs as w } from "react/jsx-runtime";
14
+ import { useMutation as T, useQuery as E, useQueryClient as D, useSuspenseQuery as O } from "@tanstack/react-query";
15
15
  // src/components/TeamRepositories.tsx
16
- var A = "cursor-help underline decoration-dotted underline-offset-2";
17
- function j({ workspace: j, team: M, isAdmin: N }) {
18
- let P = w("code"), F = w("common"), { data: I } = k(i(j)), { data: L } = k(o(j, M.key)), { data: R } = O({
19
- ...a(j),
20
- enabled: N
21
- }), z = w("github"), [B, V] = C(!1), H = I.connections.some((e) => !e.removed), U = O({
22
- ...r(j, M.key),
23
- enabled: B && N && H
24
- }), W = re(), G = S(), K = p(), { confirm: q, dialog: J } = f(), Y = () => W.invalidateQueries({ queryKey: o(j, M.key).queryKey }), X = (e) => {
16
+ var k = "cursor-help underline decoration-dotted underline-offset-2";
17
+ function A({ workspace: A, team: j, isAdmin: M }) {
18
+ let N = S("code"), P = S("common"), { data: F } = O(i(A)), { data: I } = O(o(A, j.key)), { data: L } = E({
19
+ ...a(A),
20
+ enabled: M
21
+ }), R = S("github"), [z, B] = ie(!1), V = F.connections.some((e) => !e.removed), H = E({
22
+ ...r(A, j.key),
23
+ enabled: z && M && V
24
+ }), U = D(), W = re(), G = f(), { confirm: K, dialog: q } = d(), J = () => U.invalidateQueries({ queryKey: o(A, j.key).queryKey }), Y = (e) => {
25
25
  let [t = "", n = ""] = e.split("/");
26
26
  return { path: {
27
- workspace: j,
28
- key: M.key,
27
+ workspace: A,
28
+ key: j.key,
29
29
  owner: t,
30
30
  name: n
31
31
  } };
32
- }, Z = D({
32
+ }, X = T({
33
33
  mutationFn: async (n) => t(await e.PUT("/api/v1/workspaces/{workspace}/teams/{key}/repositories/{owner}/{name}", {
34
- params: X(n.repository),
34
+ params: Y(n.repository),
35
35
  body: { default: n.makeDefault }
36
36
  })),
37
- onMutate: K.clear,
38
- onError: K.set,
39
- onSettled: Y
40
- }), ie = D({
41
- mutationFn: async (n) => t(await e.DELETE("/api/v1/workspaces/{workspace}/teams/{key}/repositories/{owner}/{name}", { params: X(n) })),
42
- onMutate: K.clear,
43
- onSettled: Y
44
- }), Q = D({
37
+ onMutate: G.clear,
38
+ onError: G.set,
39
+ onSettled: J
40
+ }), ae = T({
41
+ mutationFn: async (n) => t(await e.DELETE("/api/v1/workspaces/{workspace}/teams/{key}/repositories/{owner}/{name}", { params: Y(n) })),
42
+ onMutate: G.clear,
43
+ onSettled: J
44
+ }), Z = T({
45
45
  mutationFn: async (n) => t(await e.PATCH("/api/v1/workspaces/{workspace}/teams/{key}", {
46
46
  params: { path: {
47
- workspace: j,
48
- key: M.key
47
+ workspace: A,
48
+ key: j.key
49
49
  } },
50
50
  body: { closeIssuesOnMerge: n }
51
51
  })),
52
- onMutate: K.clear,
53
- onError: K.set,
54
- onSettled: () => W.invalidateQueries({ queryKey: s(j).queryKey })
55
- }), $ = (e) => q({
56
- title: P("unlinkConfirm", { repository: e }),
57
- description: P("unlinkDetail"),
58
- confirmLabel: P("unlink"),
59
- onConfirm: () => ie.mutateAsync(e)
52
+ onMutate: G.clear,
53
+ onError: G.set,
54
+ onSettled: () => U.invalidateQueries({ queryKey: s(A).queryKey })
55
+ }), Q = T({
56
+ mutationFn: async (n) => t(await e.PATCH("/api/v1/workspaces/{workspace}/teams/{key}", {
57
+ params: { path: {
58
+ workspace: A,
59
+ key: j.key
60
+ } },
61
+ body: { keepIssuesHere: n }
62
+ })),
63
+ onMutate: G.clear,
64
+ onError: G.set,
65
+ onSettled: () => U.invalidateQueries({ queryKey: s(A).queryKey })
66
+ }), $ = (e) => K({
67
+ title: N("unlinkConfirm", { repository: e }),
68
+ description: N("unlinkDetail"),
69
+ confirmLabel: N("unlink"),
70
+ onConfirm: () => ae.mutateAsync(e)
60
71
  });
61
- if (I.provider === "") return /* @__PURE__ */ T(b, {
72
+ if (F.provider === "") return /* @__PURE__ */ C(y, {
62
73
  variant: "bare",
63
74
  headingLevel: 2,
64
75
  collapsible: !1,
65
- title: P("repositories"),
66
- children: /* @__PURE__ */ T("p", {
76
+ title: N("repositories"),
77
+ children: /* @__PURE__ */ C("p", {
67
78
  className: "text-sm text-muted-foreground",
68
- children: P("notConfigured")
79
+ children: N("notConfigured")
69
80
  })
70
81
  });
71
- let ae = new Set(L.map((e) => `${e.owner}/${e.name}`.toLowerCase()));
72
- return /* @__PURE__ */ E(b, {
82
+ let oe = new Set(I.map((e) => `${e.owner}/${e.name}`.toLowerCase()));
83
+ return /* @__PURE__ */ w(y, {
73
84
  variant: "bare",
74
85
  headingLevel: 2,
75
86
  collapsible: !1,
76
- title: P("repositories"),
77
- description: P("repositoriesDescription"),
87
+ title: N("repositories"),
88
+ description: N("repositoriesDescription"),
78
89
  children: [
79
- /* @__PURE__ */ E(g, {
90
+ /* @__PURE__ */ w(h, {
80
91
  size: "fill",
81
92
  padding: "none",
82
93
  divided: !0,
83
94
  interactive: !1,
84
- render: /* @__PURE__ */ T("ul", {}),
85
- children: [L.map((e) => {
86
- let t = `${e.owner}/${e.name}`, n = ee(e.url), r = R?.enabled && R.repositories.find((e) => e.team === M.key && e.fullName.toLowerCase() === t.toLowerCase());
87
- return /* @__PURE__ */ E("li", {
88
- onContextMenu: (r) => G(r, [
95
+ render: /* @__PURE__ */ C("ul", {}),
96
+ children: [I.map((e) => {
97
+ let t = `${e.owner}/${e.name}`, n = l(e.url), r = L?.enabled && L.repositories.find((e) => e.team === j.key && e.fullName.toLowerCase() === t.toLowerCase());
98
+ return /* @__PURE__ */ w("li", {
99
+ onContextMenu: (r) => W(r, [
89
100
  n ? {
90
- label: P("openOnHost"),
101
+ label: N("openOnHost"),
91
102
  href: n,
92
103
  target: "_blank"
93
104
  } : {
94
- label: P("openOnHost"),
105
+ label: N("openOnHost"),
95
106
  disabled: !0,
96
107
  onClick: () => {}
97
108
  },
98
- c(F("copyName"), t),
99
- ...N ? [
109
+ c(P("copyName"), t),
110
+ ...M ? [
100
111
  x,
101
112
  {
102
- label: P("makeDefault"),
113
+ label: N("makeDefault"),
103
114
  disabled: e.default,
104
- onClick: () => Z.mutate({
115
+ onClick: () => X.mutate({
105
116
  repository: t,
106
117
  makeDefault: !0
107
118
  })
108
119
  },
109
120
  {
110
- label: P("unlink"),
121
+ label: N("unlink"),
111
122
  destructive: !0,
112
123
  onClick: () => $(t)
113
124
  }
114
125
  ] : []
115
126
  ]),
116
127
  className: "px-3 py-2 text-sm",
117
- children: [/* @__PURE__ */ E("div", {
128
+ children: [/* @__PURE__ */ w("div", {
118
129
  className: "flex items-center gap-3",
119
130
  children: [
120
- /* @__PURE__ */ T(u, {
131
+ /* @__PURE__ */ C(te, {
121
132
  provider: e.provider,
122
133
  className: "size-4 text-muted-foreground"
123
134
  }),
124
- /* @__PURE__ */ T("a", {
135
+ /* @__PURE__ */ C("a", {
125
136
  href: n,
126
137
  target: "_blank",
127
138
  rel: "noopener noreferrer",
128
139
  className: "min-w-0 truncate hover:underline",
129
140
  children: t
130
141
  }),
131
- /* @__PURE__ */ T("span", {
142
+ /* @__PURE__ */ C("span", {
132
143
  className: "flex-1 text-xs text-muted-foreground",
133
- children: e.default ? /* @__PURE__ */ T(y, {
134
- text: P("defaultHint"),
135
- className: A,
136
- children: P("defaultRepository")
137
- }) : e.private && P("private")
144
+ children: e.default ? /* @__PURE__ */ C(v, {
145
+ text: N("defaultHint"),
146
+ className: k,
147
+ children: N("defaultRepository")
148
+ }) : e.private && N("private")
138
149
  }),
139
- N && !e.default && /* @__PURE__ */ T(ne, {
140
- content: P("makeDefaultHint"),
150
+ M && !e.default && /* @__PURE__ */ C(b, {
151
+ content: N("makeDefaultHint"),
141
152
  describesAnchor: !0,
142
- children: /* @__PURE__ */ T("button", {
153
+ children: /* @__PURE__ */ C("button", {
143
154
  type: "button",
144
- onClick: () => Z.mutate({
155
+ onClick: () => X.mutate({
145
156
  repository: t,
146
157
  makeDefault: !0
147
158
  }),
148
159
  className: "text-xs text-muted-foreground hover:text-foreground",
149
- children: P("makeDefault")
160
+ children: N("makeDefault")
150
161
  })
151
162
  }),
152
- N && /* @__PURE__ */ T("button", {
163
+ M && /* @__PURE__ */ C("button", {
153
164
  type: "button",
154
165
  onClick: () => $(t),
155
166
  className: "text-xs text-muted-foreground hover:text-danger",
156
- children: P("unlink")
167
+ children: N("unlink")
157
168
  })
158
169
  ]
159
- }), r && /* @__PURE__ */ T("div", {
170
+ }), r && /* @__PURE__ */ C("div", {
160
171
  className: "mt-2 pl-7",
161
- children: /* @__PURE__ */ T(m, {
162
- workspace: j,
172
+ children: /* @__PURE__ */ C(p, {
173
+ workspace: A,
163
174
  repository: r,
164
- teamName: M.name,
165
- children: /* @__PURE__ */ T("span", {
175
+ teamName: j.name,
176
+ children: /* @__PURE__ */ C("span", {
166
177
  className: "flex-1 text-xs text-muted-foreground",
167
- children: /* @__PURE__ */ T(y, {
168
- text: z("issueSyncHint"),
169
- className: A,
170
- children: z("issueSync")
178
+ children: /* @__PURE__ */ C(v, {
179
+ text: R("issueSyncHint"),
180
+ className: k,
181
+ children: R("issueSync")
171
182
  })
172
183
  })
173
184
  })
174
185
  })]
175
186
  }, t);
176
- }), L.length === 0 && /* @__PURE__ */ T("li", {
187
+ }), I.length === 0 && /* @__PURE__ */ C("li", {
177
188
  className: "px-3 py-2 text-sm text-muted-foreground",
178
- children: P("noRepositories")
189
+ children: N("noRepositories")
179
190
  })]
180
191
  }),
181
- N && !H && /* @__PURE__ */ T("p", {
192
+ M && !V && /* @__PURE__ */ C("p", {
182
193
  className: "mt-3 text-sm text-muted-foreground",
183
- children: P.rich("connectFirst", { settings: (e) => /* @__PURE__ */ T(n, {
194
+ children: N.rich("connectFirst", { settings: (e) => /* @__PURE__ */ C(n, {
184
195
  to: "/$workspace/settings/github",
185
- params: { workspace: j },
196
+ params: { workspace: A },
186
197
  className: "underline",
187
198
  children: e
188
199
  }) })
189
200
  }),
190
- N && H && /* @__PURE__ */ T("div", {
201
+ M && V && /* @__PURE__ */ C("div", {
191
202
  className: "mt-3",
192
- children: /* @__PURE__ */ T(_, {
193
- open: B,
194
- onOpenChange: V,
195
- items: (U.data ?? []).filter((e) => !ae.has(`${e.owner}/${e.name}`.toLowerCase())).map((e) => ({
203
+ children: /* @__PURE__ */ C(ne, {
204
+ open: z,
205
+ onOpenChange: B,
206
+ items: (H.data ?? []).filter((e) => !oe.has(`${e.owner}/${e.name}`.toLowerCase())).map((e) => ({
196
207
  value: `${e.owner}/${e.name}`,
197
208
  label: `${e.owner}/${e.name}`,
198
- ...e.private && { hint: P("private") },
199
- icon: /* @__PURE__ */ T(d, { className: "size-3.5 text-muted-foreground" })
209
+ ...e.private && { hint: N("private") },
210
+ icon: /* @__PURE__ */ C(u, { className: "size-3.5 text-muted-foreground" })
200
211
  })),
201
212
  value: null,
202
- onValueChange: (e) => e !== null && Z.mutate({
213
+ onValueChange: (e) => e !== null && X.mutate({
203
214
  repository: e,
204
215
  makeDefault: !1
205
216
  }),
206
- placeholder: P("linkPlaceholder"),
207
- "aria-label": P("linkRepository"),
208
- loading: U.isPending,
209
- trigger: /* @__PURE__ */ E(h, {
217
+ placeholder: N("linkPlaceholder"),
218
+ "aria-label": N("linkRepository"),
219
+ loading: H.isPending,
220
+ trigger: /* @__PURE__ */ w(m, {
210
221
  type: "button",
211
222
  children: [
212
- /* @__PURE__ */ T(l, { className: "size-3.5" }),
223
+ /* @__PURE__ */ C(ee, { className: "size-3.5" }),
213
224
  " ",
214
- P("linkRepository")
225
+ N("linkRepository")
215
226
  ]
216
227
  })
217
228
  })
218
229
  }),
219
- /* @__PURE__ */ E("label", {
230
+ /* @__PURE__ */ w("label", {
220
231
  className: "mt-4 flex w-fit items-center gap-2 text-sm",
221
- children: [/* @__PURE__ */ T(te, {
222
- checked: M.closeIssuesOnMerge,
223
- disabled: !N || Q.isPending,
232
+ children: [/* @__PURE__ */ C(g, {
233
+ checked: j.closeIssuesOnMerge,
234
+ disabled: !M || Z.isPending,
235
+ onCheckedChange: (e) => Z.mutate(e)
236
+ }), N("closeOnMerge")]
237
+ }),
238
+ /* @__PURE__ */ w("label", {
239
+ className: "mt-2 flex w-fit items-center gap-2 text-sm",
240
+ children: [/* @__PURE__ */ C(g, {
241
+ checked: j.keepIssuesHere,
242
+ disabled: !M || Q.isPending,
224
243
  onCheckedChange: (e) => Q.mutate(e)
225
- }), P("closeOnMerge")]
244
+ }), N("keepIssuesHere")]
226
245
  }),
227
- (K.error || U.isError) && /* @__PURE__ */ T(v, {
246
+ (G.error || H.isError) && /* @__PURE__ */ C(_, {
228
247
  size: "md",
229
248
  className: "mt-2",
230
- children: K.error ?? P("unavailable")
249
+ children: G.error ?? N("unavailable")
231
250
  }),
232
- J
251
+ q
233
252
  ]
234
253
  });
235
254
  }
236
- export { j as TeamRepositories };
255
+ export { A as TeamRepositories };