@parallelworks/tandem-web 0.175.1 → 0.175.3

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,160 +1,158 @@
1
1
  import { api as e, unwrap as t } from "../../../api/client.js";
2
2
  import { tokensQuery as n } from "../../../api/queries.js";
3
- import { KeyIcon as r } from "../../../components/icons.js";
4
- import { OneTimeSecret as i } from "../../../components/OneTimeSecret.js";
5
- import { SettingsPage as a, useFormError as o } from "../../../components/settings.js";
6
- import { useConfirm as s } from "../../../lib/confirm.js";
7
- import { copyItem as c } from "../../../lib/menus.js";
8
- import { useTime as l } from "../../../lib/time.js";
9
- import { Route as u } from "./tokens.js";
10
- import { Button as d, ErrorText as f, Input as p, Modal as m, ModalTitle as h, PageHeaderAddButton as g, Select as _, Table as v, menuDivider as y, useOpenMenu as b } from "@parallelworks/ui";
11
- import { useMemo as x, useState as S } from "react";
12
- import { useTranslations as C } from "use-intl";
13
- import { jsx as w, jsxs as T } from "react/jsx-runtime";
14
- import { useMutation as E, useQueryClient as D, useSuspenseQuery as O } from "@tanstack/react-query";
15
- import { ListCellText as k, ListColumns as A, ListPage as j, ListRow as M, ListToolbar as N, NameCell as P, listTableProps as F, useListNavigate as I, useListSearch as L, useListView as R } from "@parallelworks/ui/list";
3
+ import { InlineCommand as r } from "../../../components/InlineCommand.js";
4
+ import { KeyIcon as i } from "../../../components/icons.js";
5
+ import { OneTimeSecret as a } from "../../../components/OneTimeSecret.js";
6
+ import { SettingsPage as o, useFormError as s } from "../../../components/settings.js";
7
+ import { useConfirm as c } from "../../../lib/confirm.js";
8
+ import { copyItem as l } from "../../../lib/menus.js";
9
+ import { useTime as u } from "../../../lib/time.js";
10
+ import { Route as d } from "./tokens.js";
11
+ import { Button as f, ErrorText as p, Input as m, Modal as h, ModalTitle as g, PageHeaderAddButton as _, Select as v, Table as y, menuDivider as b, useOpenMenu as x } from "@parallelworks/ui";
12
+ import { useMemo as S, useState as C } from "react";
13
+ import { useTranslations as w } from "use-intl";
14
+ import { jsx as T, jsxs as E } from "react/jsx-runtime";
15
+ import { useMutation as D, useQueryClient as O, useSuspenseQuery as k } from "@tanstack/react-query";
16
+ import { ListCellText as A, ListColumns as j, ListPage as M, ListRow as N, ListToolbar as P, NameCell as F, listTableProps as I, useListNavigate as L, useListSearch as R, useListView as z } from "@parallelworks/ui/list";
16
17
  // src/routes/$workspace/settings/tokens.tsx?tsr-split=component
17
- function z() {
18
- let { workspace: o } = u.useParams(), { data: d } = O(n), f = C("account"), p = C("common"), m = l(), h = D(), _ = L(), z = I(), V = b(), [H, U] = S(!1), [W, G] = S(null), K = E({
18
+ function B() {
19
+ let { workspace: s } = d.useParams(), { data: f } = k(n), p = w("account"), m = w("common"), h = u(), g = O(), v = R(), B = L(), H = x(), [U, W] = C(!1), [G, K] = C(null), q = D({
19
20
  mutationFn: async (n) => t(await e.DELETE("/api/v1/me/tokens/{tokenId}", { params: { path: { tokenId: n } } })),
20
- onSettled: () => h.invalidateQueries({ queryKey: n.queryKey })
21
- }), { confirm: q, dialog: J } = s(), Y = (e) => q({
22
- title: f("revokeTokenTitle"),
23
- description: f("revokeTokenDescription", { name: e.name }),
24
- confirmLabel: f("revoke"),
25
- onConfirm: () => K.mutateAsync(e.id)
26
- }), X = x(() => [
21
+ onSettled: () => g.invalidateQueries({ queryKey: n.queryKey })
22
+ }), { confirm: J, dialog: Y } = c(), X = (e) => J({
23
+ title: p("revokeTokenTitle"),
24
+ description: p("revokeTokenDescription", { name: e.name }),
25
+ confirmLabel: p("revoke"),
26
+ onConfirm: () => q.mutateAsync(e.id)
27
+ }), ee = S(() => [
27
28
  {
28
29
  key: "name",
29
- label: p("name"),
30
+ label: m("name"),
30
31
  headerClassName: "py-2",
31
32
  alwaysVisible: !0
32
33
  },
33
34
  {
34
35
  key: "access",
35
- label: f("tokenAccess"),
36
+ label: p("tokenAccess"),
36
37
  headerClassName: "py-2 w-56"
37
38
  },
38
39
  {
39
40
  key: "used",
40
- label: f("tokenColUsed"),
41
+ label: p("tokenColUsed"),
41
42
  headerClassName: "py-2 w-40",
42
43
  align: "end"
43
44
  }
44
- ], [f, p]), ee = x(() => [{
45
+ ], [p, m]), te = S(() => [{
45
46
  value: "name",
46
- label: p("name"),
47
+ label: m("name"),
47
48
  compare: (e, t) => e.name.localeCompare(t.name)
48
49
  }, {
49
50
  value: "used",
50
- label: f("tokenColUsed"),
51
+ label: p("tokenColUsed"),
51
52
  compare: (e, t) => (t.lastUsedAt ?? "").localeCompare(e.lastUsedAt ?? "")
52
- }], [f, p]), Z = R({
53
+ }], [p, m]), Z = z({
53
54
  storageKey: "tandem-tokens",
54
55
  defaultShowColumnHeaders: !1,
55
- columns: X,
56
- orderBys: ee,
56
+ columns: ee,
57
+ orderBys: te,
57
58
  defaultOrderBy: "name",
58
59
  facets: []
59
- }), Q = _.filter.trim().toLowerCase(), $ = d.filter((e) => !Q || e.name.toLowerCase().includes(Q));
60
- return /* @__PURE__ */ T(a, {
60
+ }), Q = v.filter.trim().toLowerCase(), $ = f.filter((e) => !Q || e.name.toLowerCase().includes(Q));
61
+ return /* @__PURE__ */ E(o, {
61
62
  wide: !0,
62
- title: f("tokens"),
63
- description: f.rich("tokensDescription", { code: (e) => /* @__PURE__ */ w("code", {
64
- className: "rounded bg-muted px-1 py-0.5 text-xs",
65
- children: e
66
- }) }),
67
- actions: /* @__PURE__ */ w(g, {
68
- label: f("newToken"),
63
+ title: p("tokens"),
64
+ description: p.rich("tokensDescription", { code: (e) => /* @__PURE__ */ T(r, { children: e }) }),
65
+ actions: /* @__PURE__ */ T(_, {
66
+ label: p("newToken"),
69
67
  word: "create",
70
- onClick: () => U(!0)
68
+ onClick: () => W(!0)
71
69
  }),
72
- toolbar: d.length > 0 && /* @__PURE__ */ w(N, {
70
+ toolbar: f.length > 0 && /* @__PURE__ */ T(P, {
73
71
  view: Z,
74
- search: _,
75
- searchLabel: f("tokenSearch"),
76
- searchPlaceholder: f("tokenSearch")
72
+ search: v,
73
+ searchLabel: p("tokenSearch"),
74
+ searchPlaceholder: p("tokenSearch")
77
75
  }),
78
76
  children: [
79
- W && /* @__PURE__ */ w("div", {
77
+ G && /* @__PURE__ */ T("div", {
80
78
  className: "px-4 pb-4",
81
- children: /* @__PURE__ */ w(i, {
82
- title: f("tokenCreated", { name: W.name }),
83
- secret: W.secret,
84
- onDismiss: () => G(null)
79
+ children: /* @__PURE__ */ T(a, {
80
+ title: p("tokenCreated", { name: G.name }),
81
+ secret: G.secret,
82
+ onDismiss: () => K(null)
85
83
  })
86
84
  }),
87
- /* @__PURE__ */ w("div", {
85
+ /* @__PURE__ */ T("div", {
88
86
  className: "border-t border-border",
89
- children: /* @__PURE__ */ w(j, {
87
+ children: /* @__PURE__ */ T(M, {
90
88
  view: Z,
91
- total: d.length,
89
+ total: f.length,
92
90
  matches: $.length,
93
91
  count: {
94
- filterActive: _.filter.trim() !== "",
95
- noun: f("tokenNoun"),
96
- nounPlural: f("tokenNounPlural")
92
+ filterActive: v.filter.trim() !== "",
93
+ noun: p("tokenNoun"),
94
+ nounPlural: p("tokenNounPlural")
97
95
  },
98
96
  empty: {
99
- icon: /* @__PURE__ */ w(r, {}),
100
- title: f("noTokens")
97
+ icon: /* @__PURE__ */ T(i, {}),
98
+ title: p("noTokens")
101
99
  },
102
- noMatches: f("tokenNoMatches"),
103
- children: /* @__PURE__ */ T(v, {
104
- ...F,
105
- children: [/* @__PURE__ */ w(A, { view: Z }), Z.applyOrder($).map((e) => /* @__PURE__ */ T(M, {
100
+ noMatches: p("tokenNoMatches"),
101
+ children: /* @__PURE__ */ E(y, {
102
+ ...I,
103
+ children: [/* @__PURE__ */ T(j, { view: Z }), Z.applyOrder($).map((e) => /* @__PURE__ */ E(N, {
106
104
  href: null,
107
- goTo: z,
108
- openMenu: V,
105
+ goTo: B,
106
+ openMenu: H,
109
107
  items: [
110
- c(p("copyName"), e.name),
111
- y,
108
+ l(m("copyName"), e.name),
109
+ b,
112
110
  {
113
- label: f("revoke"),
111
+ label: p("revoke"),
114
112
  destructive: !0,
115
- onClick: () => Y(e)
113
+ onClick: () => X(e)
116
114
  }
117
115
  ],
118
116
  children: [
119
- /* @__PURE__ */ w(P, {
120
- icon: /* @__PURE__ */ w(r, {}),
117
+ /* @__PURE__ */ T(F, {
118
+ icon: /* @__PURE__ */ T(i, {}),
121
119
  iconTile: !0,
122
120
  name: e.name,
123
- subtitle: f("tokenCreatedAgo", { created: m.relative(e.createdAt) }),
121
+ subtitle: p("tokenCreatedAgo", { created: h.relative(e.createdAt) }),
124
122
  href: null
125
123
  }),
126
- Z.isVisible("access") && /* @__PURE__ */ w(v.Item, {
124
+ Z.isVisible("access") && /* @__PURE__ */ T(y.Item, {
127
125
  className: "py-2.5",
128
- children: /* @__PURE__ */ T(k, { children: [
129
- e.readOnly ? f("readOnly") : f("readWrite"),
126
+ children: /* @__PURE__ */ E(A, { children: [
127
+ e.readOnly ? p("readOnly") : p("readWrite"),
130
128
  " · ",
131
- e.workspace || f("allWorkspaces")
129
+ e.workspace || p("allWorkspaces")
132
130
  ] })
133
131
  }),
134
- Z.isVisible("used") && /* @__PURE__ */ w(v.Item, {
132
+ Z.isVisible("used") && /* @__PURE__ */ T(y.Item, {
135
133
  className: "py-2.5",
136
- children: /* @__PURE__ */ w(k, { children: e.lastUsedAt ? m.relative(e.lastUsedAt) : f("tokenNotUsed") })
134
+ children: /* @__PURE__ */ T(A, { children: e.lastUsedAt ? h.relative(e.lastUsedAt) : p("tokenNotUsed") })
137
135
  })
138
136
  ]
139
137
  }, e.id))]
140
138
  })
141
139
  })
142
140
  }),
143
- J,
144
- H && /* @__PURE__ */ w(B, {
145
- workspace: o,
141
+ Y,
142
+ U && /* @__PURE__ */ T(V, {
143
+ workspace: s,
146
144
  onCreated: (e) => {
147
- U(!1), G(e);
145
+ W(!1), K(e);
148
146
  },
149
- onClose: () => U(!1)
147
+ onClose: () => W(!1)
150
148
  })
151
149
  ]
152
150
  });
153
151
  }
154
- function B({ workspace: r, onCreated: i, onClose: a }) {
155
- let s = C("account"), c = C("common"), l = D(), u = o(), [g, v] = S(""), [y, b] = S("read"), [x, O] = S("one"), [k, A] = S("90"), j = E({
152
+ function V({ workspace: r, onCreated: i, onClose: a }) {
153
+ let o = w("account"), c = w("common"), l = O(), u = s(), [d, _] = C(""), [y, b] = C("read"), [x, S] = C("one"), [k, A] = C("90"), j = D({
156
154
  mutationFn: async () => t(await e.POST("/api/v1/me/tokens", { body: {
157
- name: g,
155
+ name: d,
158
156
  readOnly: y === "read",
159
157
  ...x === "one" && { workspace: r },
160
158
  ...k !== "0" && { expiresInDays: Number(k) }
@@ -167,104 +165,104 @@ function B({ workspace: r, onCreated: i, onClose: a }) {
167
165
  onSettled: () => l.invalidateQueries({ queryKey: n.queryKey }),
168
166
  onError: u.set
169
167
  });
170
- return /* @__PURE__ */ w(m, {
168
+ return /* @__PURE__ */ T(h, {
171
169
  open: !0,
172
170
  onClose: a,
173
171
  className: "w-full max-w-md p-5",
174
- children: /* @__PURE__ */ T("form", {
172
+ children: /* @__PURE__ */ E("form", {
175
173
  onSubmit: (e) => {
176
174
  e.preventDefault(), j.mutate();
177
175
  },
178
176
  children: [
179
- /* @__PURE__ */ w(h, {
177
+ /* @__PURE__ */ T(g, {
180
178
  className: "text-sm font-semibold",
181
- children: s("newToken")
179
+ children: o("newToken")
182
180
  }),
183
- /* @__PURE__ */ w(p, {
181
+ /* @__PURE__ */ T(m, {
184
182
  required: !0,
185
183
  autoFocus: !0,
186
- value: g,
187
- onChange: (e) => v(e.target.value),
188
- placeholder: s("tokenNamePlaceholder"),
189
- "aria-label": s("tokenName"),
184
+ value: d,
185
+ onChange: (e) => _(e.target.value),
186
+ placeholder: o("tokenNamePlaceholder"),
187
+ "aria-label": o("tokenName"),
190
188
  className: "mt-4 w-full"
191
189
  }),
192
- /* @__PURE__ */ T("div", {
190
+ /* @__PURE__ */ E("div", {
193
191
  className: "mt-3 flex flex-wrap gap-2",
194
192
  children: [
195
- /* @__PURE__ */ w(_, {
193
+ /* @__PURE__ */ T(v, {
196
194
  value: y,
197
195
  onValueChange: b,
198
- "aria-label": s("tokenAccess"),
196
+ "aria-label": o("tokenAccess"),
199
197
  items: [{
200
198
  value: "read",
201
- label: s("readOnly")
199
+ label: o("readOnly")
202
200
  }, {
203
201
  value: "write",
204
- label: s("readWrite")
202
+ label: o("readWrite")
205
203
  }],
206
204
  width: "content"
207
205
  }),
208
- /* @__PURE__ */ w(_, {
206
+ /* @__PURE__ */ T(v, {
209
207
  value: x,
210
- onValueChange: O,
211
- "aria-label": s("tokenWorkspace"),
208
+ onValueChange: S,
209
+ "aria-label": o("tokenWorkspace"),
212
210
  items: [{
213
211
  value: "one",
214
- label: s("thisWorkspace", { workspace: r })
212
+ label: o("thisWorkspace", { workspace: r })
215
213
  }, {
216
214
  value: "all",
217
- label: s("allWorkspaces")
215
+ label: o("allWorkspaces")
218
216
  }],
219
217
  width: "content"
220
218
  }),
221
- /* @__PURE__ */ w(_, {
219
+ /* @__PURE__ */ T(v, {
222
220
  value: k,
223
221
  onValueChange: A,
224
- "aria-label": s("tokenExpiry"),
222
+ "aria-label": o("tokenExpiry"),
225
223
  items: [
226
224
  {
227
225
  value: "30",
228
- label: s("expiresIn", { days: 30 })
226
+ label: o("expiresIn", { days: 30 })
229
227
  },
230
228
  {
231
229
  value: "90",
232
- label: s("expiresIn", { days: 90 })
230
+ label: o("expiresIn", { days: 90 })
233
231
  },
234
232
  {
235
233
  value: "365",
236
- label: s("expiresIn", { days: 365 })
234
+ label: o("expiresIn", { days: 365 })
237
235
  },
238
236
  {
239
237
  value: "0",
240
- label: s("noExpiry")
238
+ label: o("noExpiry")
241
239
  }
242
240
  ],
243
241
  width: "content"
244
242
  })
245
243
  ]
246
244
  }),
247
- /* @__PURE__ */ w(f, {
245
+ /* @__PURE__ */ T(p, {
248
246
  size: "md",
249
247
  className: "mt-3",
250
248
  children: u.error
251
249
  }),
252
- /* @__PURE__ */ T("div", {
250
+ /* @__PURE__ */ E("div", {
253
251
  className: "mt-5 flex justify-end gap-2",
254
- children: [/* @__PURE__ */ w(d, {
252
+ children: [/* @__PURE__ */ T(f, {
255
253
  type: "button",
256
254
  onClick: a,
257
255
  children: c("cancel")
258
- }), /* @__PURE__ */ w(d, {
256
+ }), /* @__PURE__ */ T(f, {
259
257
  type: "submit",
260
258
  variant: "primary",
261
- disabled: !g.trim(),
259
+ disabled: !d.trim(),
262
260
  loading: j.isPending,
263
- children: s("createToken")
261
+ children: o("createToken")
264
262
  })]
265
263
  })
266
264
  ]
267
265
  })
268
266
  });
269
267
  }
270
- export { z as component };
268
+ export { B as component };