@parallelworks/tandem-web 0.171.2 → 0.172.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.
@@ -6,14 +6,14 @@ import { usePeople as s } from "../lib/people.js";
6
6
  import { ConnectionCard as c, ConnectionPanel as l } from "./ConnectionCard.js";
7
7
  import { CodeHostIcon as u } from "./icons.js";
8
8
  import { useFormError as d } from "./settings.js";
9
- import { Avatar as f, Button as p, Card as m, ErrorText as h, Section as g, Select as _, SettingsCard as v, StatusLabel as y } from "@parallelworks/ui";
10
- import { useState as b } from "react";
11
- import { useTranslations as x } from "use-intl";
12
- import { Fragment as S, jsx as C, jsxs as w } from "react/jsx-runtime";
13
- import { useMutation as T, useQueryClient as E, useSuspenseQuery as D } from "@tanstack/react-query";
9
+ import { Avatar as f, Button as p, Card as m, ErrorText as h, Section as g, Select as _, SettingsCard as v, StatusLabel as y, Switch as b } from "@parallelworks/ui";
10
+ import { useState as x } from "react";
11
+ import { useTranslations as S } from "use-intl";
12
+ import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
13
+ import { useMutation as E, useQueryClient as D, useSuspenseQuery as O } from "@tanstack/react-query";
14
14
  // src/components/CodeHostSettings.tsx
15
- function O({ workspace: n }) {
16
- let o = x("code"), { data: s } = D(i), { data: c } = D(r(n)), l = E(), u = d(), { confirm: f, dialog: m } = a(), v = T({
15
+ function k({ workspace: n }) {
16
+ let o = S("code"), { data: s } = O(i), { data: c } = O(r(n)), l = D(), u = d(), { confirm: f, dialog: m } = a(), v = E({
17
17
  mutationFn: async (r) => t(await e.DELETE("/api/v1/workspaces/{workspace}/code-host/connections/{account}", { params: { path: {
18
18
  workspace: n,
19
19
  account: r
@@ -31,10 +31,10 @@ function O({ workspace: n }) {
31
31
  description: o("disconnectDetail"),
32
32
  confirmLabel: o("disconnect"),
33
33
  onConfirm: () => v.mutateAsync(e)
34
- }), [S, O] = b(""), k = c.connections.filter((e) => e.connectedBy === s?.user.username), A = k[0];
34
+ }), [b, C] = x(""), k = c.connections.filter((e) => e.connectedBy === s?.user.username), A = k[0];
35
35
  if (!A) return null;
36
- let j = k.some((e) => e.account === S) ? S : A.account;
37
- return /* @__PURE__ */ w(g, {
36
+ let j = k.some((e) => e.account === b) ? b : A.account;
37
+ return /* @__PURE__ */ T(g, {
38
38
  variant: "card",
39
39
  tone: "error",
40
40
  collapsible: !1,
@@ -43,27 +43,27 @@ function O({ workspace: n }) {
43
43
  description: o("disconnectDetail"),
44
44
  className: "mt-10",
45
45
  children: [
46
- /* @__PURE__ */ w("div", {
46
+ /* @__PURE__ */ T("div", {
47
47
  className: "flex flex-wrap items-center gap-2",
48
- children: [/* @__PURE__ */ C("div", {
48
+ children: [/* @__PURE__ */ w("div", {
49
49
  className: "w-56 max-w-full",
50
- children: /* @__PURE__ */ C(_, {
50
+ children: /* @__PURE__ */ w(_, {
51
51
  "aria-label": o("disconnectWhich"),
52
52
  value: j,
53
- onValueChange: (e) => e && O(e),
53
+ onValueChange: (e) => e && C(e),
54
54
  items: k.map((e) => ({
55
55
  value: e.account,
56
56
  label: e.account
57
57
  }))
58
58
  })
59
- }), /* @__PURE__ */ C(p, {
59
+ }), /* @__PURE__ */ w(p, {
60
60
  variant: "danger",
61
61
  onClick: () => y(j),
62
62
  loading: v.isPending,
63
63
  children: o("disconnectAccount", { account: j })
64
64
  })]
65
65
  }),
66
- /* @__PURE__ */ C(h, {
66
+ /* @__PURE__ */ w(h, {
67
67
  size: "md",
68
68
  className: "mt-3",
69
69
  children: u.error
@@ -72,8 +72,19 @@ function O({ workspace: n }) {
72
72
  ]
73
73
  });
74
74
  }
75
- function k({ workspace: n, isAdmin: i, result: a }) {
76
- let m = x("code"), { data: h } = D(r(n)), { person: g } = s(n), _ = d(), b = T({
75
+ function A({ workspace: n, isAdmin: i, result: a }) {
76
+ let m = S("code"), { data: h } = O(r(n)), { person: g } = s(n), _ = d(), x = D(), k = E({
77
+ mutationFn: async ({ account: r, on: i }) => t(await e.PATCH("/api/v1/workspaces/{workspace}/code-host/connections/{account}", {
78
+ params: { path: {
79
+ workspace: n,
80
+ account: r
81
+ } },
82
+ body: { showImages: i }
83
+ })),
84
+ onMutate: _.clear,
85
+ onSuccess: () => x.invalidateQueries({ queryKey: r(n).queryKey }),
86
+ onError: _.set
87
+ }), A = E({
77
88
  mutationFn: async () => t(await e.POST("/api/v1/workspaces/{workspace}/code-host/connect", { params: { path: { workspace: n } } })),
78
89
  onMutate: _.clear,
79
90
  onSuccess: ({ url: e }) => {
@@ -82,62 +93,85 @@ function k({ workspace: n, isAdmin: i, result: a }) {
82
93
  },
83
94
  onError: _.set
84
95
  });
85
- return h.provider === "" ? /* @__PURE__ */ C(v, { children: /* @__PURE__ */ C("p", {
96
+ return h.provider === "" ? /* @__PURE__ */ w(v, { children: /* @__PURE__ */ w("p", {
86
97
  className: "px-3 py-2 text-sm text-muted-foreground",
87
98
  children: m("notConfigured")
88
- }) }) : /* @__PURE__ */ w(S, { children: [
89
- a && a !== "choose" && /* @__PURE__ */ C("p", {
99
+ }) }) : /* @__PURE__ */ T(C, { children: [
100
+ a && a !== "choose" && /* @__PURE__ */ w("p", {
90
101
  role: "status",
91
102
  className: `mb-3 rounded-md bg-muted px-3 py-2 text-sm ${a === "failed" ? "text-danger" : ""}`,
92
103
  children: m(`result.${a}`)
93
104
  }),
94
- /* @__PURE__ */ C(c, {
95
- icon: /* @__PURE__ */ C(u, {
105
+ /* @__PURE__ */ w(c, {
106
+ icon: /* @__PURE__ */ w(u, {
96
107
  provider: h.provider,
97
108
  className: "size-7"
98
109
  }),
99
110
  name: m("provider"),
100
111
  status: h.connections.length > 0 ? m("linkedCount", { count: h.connections.length }) : m("description"),
101
112
  error: _.error,
102
- action: /* @__PURE__ */ w(S, { children: [h.connections.length === 0 && /* @__PURE__ */ C(y, {
113
+ action: /* @__PURE__ */ T(C, { children: [h.connections.length === 0 && /* @__PURE__ */ w(y, {
103
114
  off: !0,
104
115
  children: m("notLinked")
105
- }), i && /* @__PURE__ */ C(p, {
116
+ }), i && /* @__PURE__ */ w(p, {
106
117
  type: "button",
107
118
  variant: h.connections.length === 0 ? "primary" : "outline",
108
- onClick: () => b.mutate(),
109
- loading: b.isPending,
119
+ onClick: () => A.mutate(),
120
+ loading: A.isPending,
110
121
  children: m("connect")
111
122
  })] }),
112
- children: h.connections.length > 0 && /* @__PURE__ */ C(l, {
123
+ children: h.connections.length > 0 && /* @__PURE__ */ w(l, {
113
124
  title: m("connections"),
114
- children: h.connections.map((e) => /* @__PURE__ */ w("li", {
115
- className: "flex items-center gap-3 px-4 py-3 text-sm",
116
- children: [/* @__PURE__ */ C(f, {
117
- name: e.account,
118
- size: "sm",
119
- decorative: !0
120
- }), /* @__PURE__ */ w("div", {
121
- className: "min-w-0 flex-1",
122
- children: [/* @__PURE__ */ C("p", {
123
- className: "truncate font-medium",
124
- children: e.account
125
- }), /* @__PURE__ */ C("p", {
126
- className: "truncate text-muted-foreground",
127
- children: e.removed ? m("removed") : e.connectedBy && m("connectedBy", { name: g(e.connectedBy).name })
125
+ children: h.connections.map((e) => /* @__PURE__ */ T("li", {
126
+ className: "px-4 py-3 text-sm",
127
+ children: [/* @__PURE__ */ T("div", {
128
+ className: "flex items-center gap-3",
129
+ children: [/* @__PURE__ */ w(f, {
130
+ name: e.account,
131
+ size: "sm",
132
+ decorative: !0
133
+ }), /* @__PURE__ */ T("div", {
134
+ className: "min-w-0 flex-1",
135
+ children: [/* @__PURE__ */ w("p", {
136
+ className: "truncate font-medium",
137
+ children: e.account
138
+ }), /* @__PURE__ */ w("p", {
139
+ className: "truncate text-muted-foreground",
140
+ children: e.removed ? m("removed") : e.connectedBy && m("connectedBy", { name: g(e.connectedBy).name })
141
+ })]
142
+ })]
143
+ }), i && !e.removed && /* @__PURE__ */ T("div", {
144
+ className: "mt-3 flex items-start gap-3 pl-9",
145
+ children: [/* @__PURE__ */ T("div", {
146
+ className: "min-w-0 flex-1",
147
+ children: [/* @__PURE__ */ w("p", {
148
+ className: "font-medium",
149
+ children: m("showImages")
150
+ }), /* @__PURE__ */ w("p", {
151
+ className: "text-muted-foreground",
152
+ children: h.canShowImages ? m("showImagesHint") : m("showImagesUnavailable")
153
+ })]
154
+ }), /* @__PURE__ */ w(b, {
155
+ "aria-label": m("showImagesFor", { account: e.account }),
156
+ checked: e.showImages,
157
+ disabled: !h.canShowImages || k.isPending,
158
+ onCheckedChange: (t) => k.mutate({
159
+ account: e.account,
160
+ on: t
161
+ })
128
162
  })]
129
163
  })]
130
164
  }, e.account))
131
165
  })
132
166
  }),
133
- i && /* @__PURE__ */ C(A, {
167
+ i && /* @__PURE__ */ w(j, {
134
168
  workspace: n,
135
169
  chosen: a === "choose"
136
170
  })
137
171
  ] });
138
172
  }
139
- function A({ workspace: i, chosen: a }) {
140
- let s = x("code"), { data: c } = D(n(i)), l = E(), u = d(), f = T({
173
+ function j({ workspace: i, chosen: a }) {
174
+ let s = S("code"), { data: c } = O(n(i)), l = D(), u = d(), f = E({
141
175
  mutationFn: async (n) => t(await e.POST("/api/v1/workspaces/{workspace}/code-host/connections", {
142
176
  params: { path: { workspace: i } },
143
177
  body: { id: n }
@@ -151,7 +185,7 @@ function A({ workspace: i, chosen: a }) {
151
185
  "teams"
152
186
  ] });
153
187
  }
154
- }), g = T({
188
+ }), g = E({
155
189
  mutationFn: async () => t(await e.POST("/api/v1/workspaces/{workspace}/code-host/connect", {
156
190
  params: { path: { workspace: i } },
157
191
  body: { install: !0 }
@@ -159,29 +193,29 @@ function A({ workspace: i, chosen: a }) {
159
193
  onMutate: u.clear,
160
194
  onError: u.set
161
195
  });
162
- return !a && c.length === 0 ? null : /* @__PURE__ */ w(m, {
196
+ return !a && c.length === 0 ? null : /* @__PURE__ */ T(m, {
163
197
  size: "fill",
164
198
  padding: "sm",
165
199
  className: "mt-4",
166
200
  children: [
167
- /* @__PURE__ */ C("h3", {
201
+ /* @__PURE__ */ w("h3", {
168
202
  className: "text-sm font-medium",
169
203
  children: s("chooseTitle")
170
204
  }),
171
- /* @__PURE__ */ C("p", {
205
+ /* @__PURE__ */ w("p", {
172
206
  className: "mt-0.5 text-sm text-muted-foreground",
173
207
  children: c.length > 0 ? s("chooseDescription") : s("noAccounts")
174
208
  }),
175
- c.length > 0 && /* @__PURE__ */ C("ul", {
209
+ c.length > 0 && /* @__PURE__ */ w("ul", {
176
210
  className: "mt-3 divide-y divide-border rounded-md border border-border",
177
- children: c.map((e) => /* @__PURE__ */ w("li", {
211
+ children: c.map((e) => /* @__PURE__ */ T("li", {
178
212
  className: "px-3 py-2 text-sm",
179
- children: [/* @__PURE__ */ w("div", {
213
+ children: [/* @__PURE__ */ T("div", {
180
214
  className: "flex items-center gap-3",
181
- children: [/* @__PURE__ */ C("span", {
215
+ children: [/* @__PURE__ */ w("span", {
182
216
  className: "min-w-0 flex-1 truncate font-medium",
183
217
  children: e.account
184
- }), /* @__PURE__ */ C(p, {
218
+ }), /* @__PURE__ */ w(p, {
185
219
  size: "sm",
186
220
  type: "button",
187
221
  onClick: () => f.mutate(e.id),
@@ -189,16 +223,16 @@ function A({ workspace: i, chosen: a }) {
189
223
  loading: f.isPending && f.variables === e.id,
190
224
  children: s("connectThis")
191
225
  })]
192
- }), /* @__PURE__ */ C(h, {
226
+ }), /* @__PURE__ */ w(h, {
193
227
  size: "md",
194
228
  className: "mt-2",
195
229
  children: f.isError && f.variables === e.id ? u.error : null
196
230
  })]
197
231
  }, e.id))
198
232
  }),
199
- /* @__PURE__ */ w("div", {
233
+ /* @__PURE__ */ T("div", {
200
234
  className: "mt-3 flex flex-wrap items-center gap-x-3 gap-y-1",
201
- children: [/* @__PURE__ */ C(p, {
235
+ children: [/* @__PURE__ */ w(p, {
202
236
  size: "sm",
203
237
  type: "button",
204
238
  onClick: () => {
@@ -215,12 +249,12 @@ function A({ workspace: i, chosen: a }) {
215
249
  },
216
250
  loading: g.isPending,
217
251
  children: s("installElsewhere")
218
- }), /* @__PURE__ */ C("span", {
252
+ }), /* @__PURE__ */ w("span", {
219
253
  className: "text-xs text-muted-foreground",
220
254
  children: s("installHint")
221
255
  })]
222
256
  }),
223
- /* @__PURE__ */ C(h, {
257
+ /* @__PURE__ */ w(h, {
224
258
  size: "md",
225
259
  className: "mt-2",
226
260
  children: g.isError ? u.error : null
@@ -228,4 +262,4 @@ function A({ workspace: i, chosen: a }) {
228
262
  ]
229
263
  });
230
264
  }
231
- export { O as CodeHostDangerZone, k as CodeHostSettings };
265
+ export { k as CodeHostDangerZone, A as CodeHostSettings };