@parallelworks/tandem-web 0.188.0 → 0.189.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.
- package/components/HoverCards.js +118 -115
- package/package.json +1 -1
- package/routes/_workspace/settings/runners2.js +96 -96
package/components/HoverCards.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { api as e, unwrap as t } from "../api/client.js";
|
|
2
2
|
import { docQuery as n, docsQuery as r, knowledgeQuery as i, membersQuery as a, teamsQuery as o } from "../api/queries.js";
|
|
3
|
-
import { appPath as s } from "../lib/base.js";
|
|
4
|
-
import { docLooks as
|
|
5
|
-
import { docKey as
|
|
6
|
-
import { glossary as
|
|
7
|
-
import { issueRefs as
|
|
8
|
-
import { useTermRefs as
|
|
9
|
-
import { termRef as
|
|
10
|
-
import { mentionable as
|
|
11
|
-
import { Link as
|
|
12
|
-
import { teamNames as
|
|
13
|
-
import { DocIcon as
|
|
14
|
-
import { termCaretEvent as
|
|
15
|
-
import { FileTextIcon as
|
|
16
|
-
import { PersonCard as
|
|
17
|
-
import { HoverCard as
|
|
18
|
-
import { useEffect as
|
|
19
|
-
import { useTranslations as
|
|
20
|
-
import { Fragment as
|
|
21
|
-
import { useQuery as
|
|
3
|
+
import { appPath as s, basePath as c } from "../lib/base.js";
|
|
4
|
+
import { docLooks as l } from "../lib/docLooks.js";
|
|
5
|
+
import { docKey as u, docRef as d } from "../lib/docs.js";
|
|
6
|
+
import { glossary as f, headingAnchor as p } from "../lib/glossary.js";
|
|
7
|
+
import { issueRefs as m } from "../lib/issueRefs.js";
|
|
8
|
+
import { useTermRefs as h } from "../lib/knowledge.js";
|
|
9
|
+
import { termRef as g } from "../lib/knowledgeKinds.js";
|
|
10
|
+
import { mentionable as _ } from "../lib/mentions.js";
|
|
11
|
+
import { Link as v, useNavigate as y } from "../lib/router.js";
|
|
12
|
+
import { teamNames as b } from "../lib/teamNames.js";
|
|
13
|
+
import { DocIcon as x } from "./DocIcon.js";
|
|
14
|
+
import { termCaretEvent as S } from "./editorPlugins.js";
|
|
15
|
+
import { FileTextIcon as C } from "./icons.js";
|
|
16
|
+
import { PersonCard as w } from "./PersonHoverCard.js";
|
|
17
|
+
import { HoverCard as T, Loader as E } from "@parallelworks/ui";
|
|
18
|
+
import { useEffect as D, useRef as O, useState as k } from "react";
|
|
19
|
+
import { useTranslations as A } from "use-intl";
|
|
20
|
+
import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
|
|
21
|
+
import { useQuery as P, useQueryClient as F } from "@tanstack/react-query";
|
|
22
22
|
// src/components/HoverCards.tsx
|
|
23
|
-
var
|
|
24
|
-
function
|
|
25
|
-
let t = e?.closest(
|
|
23
|
+
var I = ".kb-term, .person-mention, .prose-issue a[href*=\"/docs/\"]", L = 300, R = 200;
|
|
24
|
+
function z(e) {
|
|
25
|
+
let t = e?.closest(I);
|
|
26
26
|
if (!t) return null;
|
|
27
27
|
if (t.classList.contains("kb-term")) {
|
|
28
28
|
let e = t.dataset.term;
|
|
@@ -44,45 +44,46 @@ function R(e) {
|
|
|
44
44
|
return r?.[1] ? {
|
|
45
45
|
kind: "doc",
|
|
46
46
|
el: t,
|
|
47
|
-
key:
|
|
47
|
+
key: u(r[1])
|
|
48
48
|
} : null;
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function B(e) {
|
|
51
51
|
if (!e.closest(".ProseMirror")) return null;
|
|
52
52
|
let t = new URL(e.getAttribute("href") ?? "", location.href);
|
|
53
53
|
if (t.origin !== location.origin) return null;
|
|
54
54
|
let n = s(t.pathname);
|
|
55
55
|
return /^\/[^/]+\/docs\/(?!space\/)[^/]+\/?$/.test(n) ? n + t.hash : null;
|
|
56
56
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
57
|
+
var V = (e) => location.origin + c + e;
|
|
58
|
+
function H({ workspace: n }) {
|
|
59
|
+
let [s, c] = k(null), u = O(null), d = O(void 0), { data: p } = P(i(n)), h = y(), v = O((e) => {});
|
|
60
|
+
v.current = (e) => {
|
|
61
|
+
let t = p?.find((t) => t.id === e);
|
|
62
|
+
h({
|
|
62
63
|
to: "/$workspace/knowledge/$term",
|
|
63
64
|
params: {
|
|
64
65
|
workspace: n,
|
|
65
|
-
term: t ?
|
|
66
|
+
term: t ? g(t) : e
|
|
66
67
|
}
|
|
67
68
|
});
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
}, [
|
|
71
|
-
let { data:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}, [
|
|
75
|
-
let { data:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}, [
|
|
79
|
-
let { data:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}, [
|
|
83
|
-
let A =
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
}, D(() => {
|
|
70
|
+
f.set(p ?? []);
|
|
71
|
+
}, [p]), D(() => () => f.set([]), []);
|
|
72
|
+
let { data: x } = P(r(n));
|
|
73
|
+
D(() => {
|
|
74
|
+
l.set(x ?? []);
|
|
75
|
+
}, [x]), D(() => () => l.set([]), []);
|
|
76
|
+
let { data: C } = P(a(n));
|
|
77
|
+
D(() => {
|
|
78
|
+
_.set((C ?? []).map((e) => e.user.username));
|
|
79
|
+
}, [C]), D(() => () => _.set([]), []);
|
|
80
|
+
let { data: E } = P(o(n));
|
|
81
|
+
D(() => {
|
|
82
|
+
b.set(E ?? []);
|
|
83
|
+
}, [E]), D(() => () => b.set([]), []);
|
|
84
|
+
let A = F();
|
|
85
|
+
D(() => {
|
|
86
|
+
m.set(n, async (r) => {
|
|
86
87
|
let { issues: i } = t(await e.POST("/api/v1/workspaces/{workspace}/issue-refs", {
|
|
87
88
|
params: { path: { workspace: n } },
|
|
88
89
|
body: { identifiers: r }
|
|
@@ -90,42 +91,42 @@ function B({ workspace: n }) {
|
|
|
90
91
|
return new Map(i.map((e) => [e.identifier, e.issue]));
|
|
91
92
|
});
|
|
92
93
|
let r, i = A.getQueryCache().subscribe((e) => {
|
|
93
|
-
e.type === "updated" && e.query.queryKey[2] === "issues" && (clearTimeout(r), r = setTimeout(() =>
|
|
94
|
+
e.type === "updated" && e.query.queryKey[2] === "issues" && (clearTimeout(r), r = setTimeout(() => m.refresh(), 1e3));
|
|
94
95
|
});
|
|
95
96
|
return () => {
|
|
96
|
-
clearTimeout(r), i(),
|
|
97
|
+
clearTimeout(r), i(), m.set("", void 0);
|
|
97
98
|
};
|
|
98
99
|
}, [n, A]);
|
|
99
|
-
let
|
|
100
|
-
|
|
100
|
+
let j = O((e) => {});
|
|
101
|
+
j.current = (e) => h({
|
|
101
102
|
to: "/$workspace/issues/$identifier",
|
|
102
103
|
params: {
|
|
103
104
|
workspace: n,
|
|
104
105
|
identifier: e
|
|
105
106
|
}
|
|
106
107
|
});
|
|
107
|
-
let
|
|
108
|
-
|
|
109
|
-
let
|
|
110
|
-
|
|
108
|
+
let N = O((e) => {});
|
|
109
|
+
N.current = (e) => h({ href: e });
|
|
110
|
+
let I = O((e) => {});
|
|
111
|
+
I.current = (e) => h({
|
|
111
112
|
to: "/$workspace/teams/$key/issues",
|
|
112
113
|
params: {
|
|
113
114
|
workspace: n,
|
|
114
115
|
key: e
|
|
115
116
|
}
|
|
116
|
-
}),
|
|
117
|
+
}), D(() => {
|
|
117
118
|
let e = (e, t) => {
|
|
118
|
-
clearTimeout(
|
|
119
|
+
clearTimeout(d.current), d.current = setTimeout(e, t);
|
|
119
120
|
}, t = (t) => {
|
|
120
121
|
if (t.pointerType === "touch") return;
|
|
121
|
-
let n =
|
|
122
|
-
n && e(() =>
|
|
122
|
+
let n = z(t.target);
|
|
123
|
+
n && e(() => c(n), L);
|
|
123
124
|
}, n = (t) => {
|
|
124
125
|
let n = t.relatedTarget;
|
|
125
|
-
n && u.current?.contains(n) ||
|
|
126
|
+
n && u.current?.contains(n) || z(t.target) && e(() => c(null), R);
|
|
126
127
|
}, r = (e) => {
|
|
127
|
-
let t =
|
|
128
|
-
t && (clearTimeout(
|
|
128
|
+
let t = z(e.target);
|
|
129
|
+
t && (clearTimeout(d.current), c(t));
|
|
129
130
|
}, i = (e) => {
|
|
130
131
|
e.target.matches?.(".kb-term[tabindex], .prose-issue a[href*=\"/docs/\"]") && r(e);
|
|
131
132
|
}, a = (e) => {
|
|
@@ -136,101 +137,103 @@ function B({ workspace: n }) {
|
|
|
136
137
|
return;
|
|
137
138
|
}
|
|
138
139
|
if (!t.closest("[contenteditable=\"true\"]")) {
|
|
139
|
-
e.preventDefault(),
|
|
140
|
+
e.preventDefault(), j.current(n);
|
|
140
141
|
return;
|
|
141
142
|
}
|
|
142
143
|
}
|
|
143
|
-
let a = e.target.closest?.("a[href]"), o = a && e.button === 0 ?
|
|
144
|
+
let a = e.target.closest?.("a[href]"), o = a && e.button === 0 ? B(a) : null;
|
|
144
145
|
if (a && o) {
|
|
145
|
-
e.preventDefault(),
|
|
146
|
+
e.preventDefault(), c(null), e.metaKey || e.ctrlKey || e.shiftKey ? window.open(V(o), "_blank", "noopener") : N.current(o);
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
|
-
let s = e.target.closest?.(".team-mention"),
|
|
149
|
-
if (s &&
|
|
150
|
-
e.preventDefault(),
|
|
149
|
+
let s = e.target.closest?.(".team-mention"), l = s?.dataset.team;
|
|
150
|
+
if (s && l && (!s.closest("[contenteditable=\"true\"]") || e.metaKey || e.ctrlKey)) {
|
|
151
|
+
e.preventDefault(), I.current(l);
|
|
151
152
|
return;
|
|
152
153
|
}
|
|
153
154
|
let u = e.target.closest?.(".kb-term");
|
|
154
155
|
if (!u) return;
|
|
155
156
|
let d = u.dataset.term;
|
|
156
|
-
d && (!u.closest("[contenteditable=\"true\"]") || e.metaKey || e.ctrlKey) ? (e.preventDefault(),
|
|
157
|
+
d && (!u.closest("[contenteditable=\"true\"]") || e.metaKey || e.ctrlKey) ? (e.preventDefault(), c(null), v.current(d)) : r(e);
|
|
157
158
|
}, o = (e) => {
|
|
158
159
|
if (e.button !== 1) return;
|
|
159
160
|
let t = e.target.closest?.("a[href]");
|
|
160
|
-
t?.closest("[contenteditable=\"true\"]")
|
|
161
|
+
if (!t?.closest("[contenteditable=\"true\"]")) return;
|
|
162
|
+
let n = B(t);
|
|
163
|
+
(t.classList.contains("issue-mention") || n) && (e.preventDefault(), window.open(n ? V(n) : t.href, "_blank", "noopener"));
|
|
161
164
|
}, s = (e) => {
|
|
162
|
-
e.key === "Escape" && u.current?.isConnected && (e.stopPropagation(), e.preventDefault(),
|
|
165
|
+
e.key === "Escape" && u.current?.isConnected && (e.stopPropagation(), e.preventDefault(), c((e) => (e?.el.tabIndex === 0 && e.el.focus(), null)));
|
|
163
166
|
};
|
|
164
|
-
return document.addEventListener("pointerover", t), document.addEventListener("pointerout", n), document.addEventListener("focusin", i), document.addEventListener("click", a), document.addEventListener("auxclick", o), document.addEventListener(
|
|
165
|
-
clearTimeout(
|
|
167
|
+
return document.addEventListener("pointerover", t), document.addEventListener("pointerout", n), document.addEventListener("focusin", i), document.addEventListener("click", a), document.addEventListener("auxclick", o), document.addEventListener(S, r), document.addEventListener("keydown", s, !0), () => {
|
|
168
|
+
clearTimeout(d.current), document.removeEventListener("pointerover", t), document.removeEventListener("pointerout", n), document.removeEventListener("focusin", i), document.removeEventListener("click", a), document.removeEventListener("auxclick", o), document.removeEventListener(S, r), document.removeEventListener("keydown", s, !0);
|
|
166
169
|
};
|
|
167
|
-
}, []),
|
|
170
|
+
}, []), D(() => {
|
|
168
171
|
if (!s) return;
|
|
169
172
|
let e = (e) => {
|
|
170
173
|
let t = e.target;
|
|
171
|
-
!u.current?.contains(t) && !s.el.contains(t) &&
|
|
174
|
+
!u.current?.contains(t) && !s.el.contains(t) && c(null);
|
|
172
175
|
};
|
|
173
176
|
return document.addEventListener("pointerdown", e), () => document.removeEventListener("pointerdown", e);
|
|
174
177
|
}, [s]);
|
|
175
178
|
let H = s?.el.isConnected ? s : null;
|
|
176
|
-
return /* @__PURE__ */
|
|
179
|
+
return /* @__PURE__ */ M(T, {
|
|
177
180
|
at: H?.el ?? null,
|
|
178
181
|
open: !!H,
|
|
179
182
|
onOpenChange: (e) => {
|
|
180
|
-
e ||
|
|
183
|
+
e || c(null);
|
|
181
184
|
},
|
|
182
|
-
onPointerEnter: () => clearTimeout(
|
|
185
|
+
onPointerEnter: () => clearTimeout(d.current),
|
|
183
186
|
onPointerLeave: () => {
|
|
184
|
-
clearTimeout(
|
|
187
|
+
clearTimeout(d.current), d.current = setTimeout(() => c(null), R);
|
|
185
188
|
},
|
|
186
|
-
card: H && /* @__PURE__ */
|
|
189
|
+
card: H && /* @__PURE__ */ M("div", {
|
|
187
190
|
ref: u,
|
|
188
191
|
role: "dialog",
|
|
189
192
|
"aria-label": H.kind === "doc" ? H.key : H.kind === "person" ? H.username : void 0,
|
|
190
193
|
className: H.kind === "person" ? "" : "w-80 max-w-[calc(100vw-16px)] p-3 text-sm",
|
|
191
|
-
children: H.kind === "term" ? /* @__PURE__ */
|
|
194
|
+
children: H.kind === "term" ? /* @__PURE__ */ M(U, {
|
|
192
195
|
workspace: n,
|
|
193
|
-
entry:
|
|
194
|
-
}) : H.kind === "person" ? /* @__PURE__ */
|
|
196
|
+
entry: p?.find((e) => e.id === H.id)
|
|
197
|
+
}) : H.kind === "person" ? /* @__PURE__ */ M(w, {
|
|
195
198
|
workspace: n,
|
|
196
199
|
handle: H.username
|
|
197
|
-
}) : /* @__PURE__ */
|
|
200
|
+
}) : /* @__PURE__ */ M(G, {
|
|
198
201
|
workspace: n,
|
|
199
202
|
docKey: H.key
|
|
200
203
|
})
|
|
201
204
|
})
|
|
202
205
|
});
|
|
203
206
|
}
|
|
204
|
-
function
|
|
205
|
-
let n =
|
|
206
|
-
if (!t) return /* @__PURE__ */
|
|
207
|
+
function U({ workspace: e, entry: t }) {
|
|
208
|
+
let n = A("knowledge"), r = h(e);
|
|
209
|
+
if (!t) return /* @__PURE__ */ M("p", {
|
|
207
210
|
className: "text-muted-foreground",
|
|
208
211
|
children: n("gone")
|
|
209
212
|
});
|
|
210
213
|
let i = t.source.doc;
|
|
211
|
-
return /* @__PURE__ */
|
|
212
|
-
/* @__PURE__ */
|
|
214
|
+
return /* @__PURE__ */ N(j, { children: [
|
|
215
|
+
/* @__PURE__ */ N("p", {
|
|
213
216
|
className: "flex items-center gap-2",
|
|
214
|
-
children: [/* @__PURE__ */
|
|
217
|
+
children: [/* @__PURE__ */ M(v, {
|
|
215
218
|
to: "/$workspace/knowledge/$term",
|
|
216
219
|
params: {
|
|
217
220
|
workspace: e,
|
|
218
|
-
term:
|
|
221
|
+
term: g(t)
|
|
219
222
|
},
|
|
220
223
|
className: "font-semibold hover:underline",
|
|
221
224
|
children: t.name
|
|
222
|
-
}), /* @__PURE__ */
|
|
225
|
+
}), /* @__PURE__ */ M("span", {
|
|
223
226
|
className: "text-xs text-muted-foreground",
|
|
224
227
|
children: n(`kind.${t.kind}`)
|
|
225
228
|
})]
|
|
226
229
|
}),
|
|
227
|
-
/* @__PURE__ */
|
|
230
|
+
/* @__PURE__ */ M("p", {
|
|
228
231
|
className: "mt-1.5 text-foreground",
|
|
229
232
|
children: t.definition
|
|
230
233
|
}),
|
|
231
|
-
t.supersededBy && /* @__PURE__ */
|
|
234
|
+
t.supersededBy && /* @__PURE__ */ M("p", {
|
|
232
235
|
className: "mt-1.5 text-xs",
|
|
233
|
-
children: /* @__PURE__ */
|
|
236
|
+
children: /* @__PURE__ */ M(v, {
|
|
234
237
|
to: "/$workspace/knowledge/$term",
|
|
235
238
|
params: {
|
|
236
239
|
workspace: e,
|
|
@@ -240,21 +243,21 @@ function V({ workspace: e, entry: t }) {
|
|
|
240
243
|
children: n("supersededBy", { name: t.supersededByName ?? "" })
|
|
241
244
|
})
|
|
242
245
|
}),
|
|
243
|
-
(i || t.source.identifier) && /* @__PURE__ */
|
|
246
|
+
(i || t.source.identifier) && /* @__PURE__ */ N("p", {
|
|
244
247
|
className: "mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",
|
|
245
|
-
children: [i && /* @__PURE__ */
|
|
248
|
+
children: [i && /* @__PURE__ */ N(v, {
|
|
246
249
|
to: "/$workspace/docs/$doc",
|
|
247
250
|
params: {
|
|
248
251
|
workspace: e,
|
|
249
|
-
doc:
|
|
252
|
+
doc: d(i)
|
|
250
253
|
},
|
|
251
|
-
...t.source.section && { hash:
|
|
254
|
+
...t.source.section && { hash: p(t.source.section) },
|
|
252
255
|
className: "inline-flex items-center gap-1 hover:text-foreground",
|
|
253
|
-
children: [/* @__PURE__ */
|
|
256
|
+
children: [/* @__PURE__ */ M(C, { className: "size-3" }), t.source.section ? n("sourceSection", {
|
|
254
257
|
doc: i.title,
|
|
255
258
|
section: t.source.section
|
|
256
259
|
}) : i.title]
|
|
257
|
-
}), t.source.identifier && /* @__PURE__ */
|
|
260
|
+
}), t.source.identifier && /* @__PURE__ */ M(v, {
|
|
258
261
|
to: "/$workspace/issues/$identifier",
|
|
259
262
|
params: {
|
|
260
263
|
workspace: e,
|
|
@@ -264,41 +267,41 @@ function V({ workspace: e, entry: t }) {
|
|
|
264
267
|
children: t.source.identifier
|
|
265
268
|
})]
|
|
266
269
|
}),
|
|
267
|
-
/* @__PURE__ */
|
|
270
|
+
/* @__PURE__ */ M(v, {
|
|
268
271
|
to: "/$workspace/knowledge/$term",
|
|
269
272
|
params: {
|
|
270
273
|
workspace: e,
|
|
271
|
-
term:
|
|
274
|
+
term: g(t)
|
|
272
275
|
},
|
|
273
276
|
className: "mt-2 block text-xs text-primary hover:underline",
|
|
274
277
|
children: n("openEntry")
|
|
275
278
|
})
|
|
276
279
|
] });
|
|
277
280
|
}
|
|
278
|
-
function
|
|
281
|
+
function W(e) {
|
|
279
282
|
return e.split("\n").map((e) => e.replace(/^#{1,6}\s+|^[-*>]\s+|^\d+\.\s+|\[[ x]\]\s*/g, "").replace(/[*_`]/g, "")).filter((e) => e.trim()).slice(0, 4).join(" ").slice(0, 280);
|
|
280
283
|
}
|
|
281
|
-
function
|
|
282
|
-
let r =
|
|
284
|
+
function G({ workspace: e, docKey: t }) {
|
|
285
|
+
let r = A("docLinks"), { data: i, isError: a } = P({
|
|
283
286
|
...n(e, t),
|
|
284
287
|
retry: !1
|
|
285
288
|
});
|
|
286
|
-
return a ? /* @__PURE__ */
|
|
289
|
+
return a ? /* @__PURE__ */ M("p", {
|
|
287
290
|
className: "text-muted-foreground",
|
|
288
291
|
children: r("unavailable")
|
|
289
|
-
}) : i ? /* @__PURE__ */
|
|
292
|
+
}) : i ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ N("p", {
|
|
290
293
|
className: "flex items-center gap-2 font-semibold",
|
|
291
|
-
children: [/* @__PURE__ */
|
|
294
|
+
children: [/* @__PURE__ */ M(x, {
|
|
292
295
|
icon: i.icon,
|
|
293
296
|
className: "size-3.5",
|
|
294
297
|
emojiClassName: "text-xs"
|
|
295
|
-
}), /* @__PURE__ */
|
|
298
|
+
}), /* @__PURE__ */ M("span", {
|
|
296
299
|
className: "truncate",
|
|
297
300
|
children: i.title
|
|
298
301
|
})]
|
|
299
|
-
}), /* @__PURE__ */
|
|
302
|
+
}), /* @__PURE__ */ M("p", {
|
|
300
303
|
className: "mt-1.5 line-clamp-4 text-muted-foreground",
|
|
301
|
-
children:
|
|
302
|
-
})] }) : /* @__PURE__ */
|
|
304
|
+
children: W(i.body ?? "") || r("empty")
|
|
305
|
+
})] }) : /* @__PURE__ */ M(E, { size: 16 });
|
|
303
306
|
}
|
|
304
|
-
export {
|
|
307
|
+
export { H as HoverCards };
|
package/package.json
CHANGED
|
@@ -1,183 +1,183 @@
|
|
|
1
1
|
import { api as e, unwrap as t } from "../../../api/client.js";
|
|
2
2
|
import { runnersQuery as n, workspaceRunsQuery as r } from "../../../api/queries.js";
|
|
3
|
-
import { ComputeTargets as
|
|
4
|
-
import { InlineCommand as
|
|
5
|
-
import { WorkerIcon as
|
|
6
|
-
import { SettingsPage as
|
|
7
|
-
import { useConfirm as
|
|
8
|
-
import { copyItem as
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
3
|
+
import { ComputeTargets as ee } from "../../../components/ComputeTargets.js";
|
|
4
|
+
import { InlineCommand as i } from "../../../components/InlineCommand.js";
|
|
5
|
+
import { WorkerIcon as a } from "../../../components/icons.js";
|
|
6
|
+
import { SettingsPage as o } from "../../../components/settings.js";
|
|
7
|
+
import { useConfirm as s } from "../../../lib/confirm.js";
|
|
8
|
+
import { copyItem as c } from "../../../lib/menus.js";
|
|
9
|
+
import { useCan as te } from "../../../lib/roles.js";
|
|
10
|
+
import { Link as l } from "../../../lib/router.js";
|
|
11
|
+
import { useTime as u } from "../../../lib/time.js";
|
|
12
|
+
import { Route as d } from "./runners.js";
|
|
13
|
+
import { Callout as f, StatusDot as ne, Table as p, menuDivider as m, useOpenMenu as h } from "@parallelworks/ui";
|
|
14
|
+
import { useMemo as g } from "react";
|
|
15
|
+
import { useFormatter as _, useTranslations as v } from "use-intl";
|
|
16
|
+
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
17
|
+
import { useMutation as re, useQuery as ie, useQueryClient as ae, useSuspenseQuery as x } from "@tanstack/react-query";
|
|
18
|
+
import { ListCellText as S, ListColumns as C, ListPage as w, ListRow as T, ListToolbar as E, NameCell as D, listTableProps as O, useListNavigate as k, useListSearch as A, useListView as j } from "@parallelworks/ui/list";
|
|
18
19
|
// src/routes/$workspace/settings/runners.tsx?tsr-split=component
|
|
19
|
-
var
|
|
20
|
+
var M = {
|
|
20
21
|
default: "runnerModeDefault",
|
|
21
22
|
"accept-edits": "runnerModeAcceptEdits",
|
|
22
23
|
auto: "runnerModeAuto",
|
|
23
24
|
bypass: "runnerModeBypass"
|
|
24
25
|
};
|
|
25
|
-
function
|
|
26
|
-
let { workspace: e } =
|
|
27
|
-
return /* @__PURE__ */
|
|
26
|
+
function N() {
|
|
27
|
+
let { workspace: e } = d.useParams();
|
|
28
|
+
return /* @__PURE__ */ y(P, { workspace: e });
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
let { data:
|
|
30
|
+
function P({ workspace: d }) {
|
|
31
|
+
let { data: N } = x(n(d)), { data: P = [] } = ie(r(d, {
|
|
31
32
|
live: !0,
|
|
32
33
|
limit: 200
|
|
33
|
-
})),
|
|
34
|
-
for (let e of
|
|
35
|
-
let
|
|
34
|
+
})), F = /* @__PURE__ */ new Map();
|
|
35
|
+
for (let e of P) e.state === "working" && e.runnerId && F.set(e.runnerId, [...F.get(e.runnerId) ?? [], e]);
|
|
36
|
+
let I = v("account"), L = _(), R = v("common"), z = u(), B = ae(), V = A(), H = k(), U = h(), W = te(d, "manage_agents"), G = re({
|
|
36
37
|
mutationFn: async (n) => t(await e.DELETE("/api/v1/workspaces/{workspace}/runners/{runnerId}", { params: { path: {
|
|
37
|
-
workspace:
|
|
38
|
+
workspace: d,
|
|
38
39
|
runnerId: n
|
|
39
40
|
} } })),
|
|
40
|
-
onSettled: () =>
|
|
41
|
-
}), { confirm:
|
|
42
|
-
title:
|
|
43
|
-
description:
|
|
44
|
-
confirmLabel:
|
|
45
|
-
onConfirm: () =>
|
|
46
|
-
}),
|
|
41
|
+
onSettled: () => B.invalidateQueries({ queryKey: n(d).queryKey })
|
|
42
|
+
}), { confirm: K, dialog: q } = s(), J = (e) => K({
|
|
43
|
+
title: I("revokeRunnerTitle"),
|
|
44
|
+
description: I("revokeRunnerDescription", { name: e.name }),
|
|
45
|
+
confirmLabel: I("revoke"),
|
|
46
|
+
onConfirm: () => G.mutateAsync(e.id)
|
|
47
|
+
}), oe = g(() => [
|
|
47
48
|
{
|
|
48
49
|
key: "name",
|
|
49
|
-
label:
|
|
50
|
+
label: R("name"),
|
|
50
51
|
headerClassName: "py-2",
|
|
51
52
|
alwaysVisible: !0
|
|
52
53
|
},
|
|
53
54
|
{
|
|
54
55
|
key: "working",
|
|
55
|
-
label:
|
|
56
|
+
label: I("runnerColWorking"),
|
|
56
57
|
headerClassName: "py-2 w-48"
|
|
57
58
|
},
|
|
58
59
|
{
|
|
59
60
|
key: "seen",
|
|
60
|
-
label:
|
|
61
|
+
label: I("runnerColSeen"),
|
|
61
62
|
headerClassName: "py-2 w-40",
|
|
62
63
|
align: "end"
|
|
63
64
|
}
|
|
64
|
-
], [
|
|
65
|
+
], [I, R]), se = g(() => [{
|
|
65
66
|
value: "name",
|
|
66
|
-
label:
|
|
67
|
+
label: R("name"),
|
|
67
68
|
compare: (e, t) => e.name.localeCompare(t.name)
|
|
68
69
|
}, {
|
|
69
70
|
value: "seen",
|
|
70
|
-
label:
|
|
71
|
+
label: I("runnerColSeen"),
|
|
71
72
|
compare: (e, t) => (t.lastSeenAt ?? "").localeCompare(e.lastSeenAt ?? "")
|
|
72
|
-
}], [
|
|
73
|
-
storageKey: `tandem-runners-${
|
|
73
|
+
}], [I, R]), Y = j({
|
|
74
|
+
storageKey: `tandem-runners-${d}`,
|
|
74
75
|
defaultShowColumnHeaders: !1,
|
|
75
|
-
columns:
|
|
76
|
-
orderBys:
|
|
76
|
+
columns: oe,
|
|
77
|
+
orderBys: se,
|
|
77
78
|
defaultOrderBy: "name",
|
|
78
79
|
facets: []
|
|
79
|
-
}), X =
|
|
80
|
+
}), X = V.filter.trim().toLowerCase(), Z = N.filter((e) => !X || [
|
|
80
81
|
e.name,
|
|
81
82
|
e.group ?? "",
|
|
82
83
|
...e.harnesses,
|
|
83
84
|
...e.labels
|
|
84
|
-
].some((e) => e.toLowerCase().includes(X))), Q =
|
|
85
|
-
return /* @__PURE__ */
|
|
85
|
+
].some((e) => e.toLowerCase().includes(X))), Q = N.filter((e) => e.sharingRefused), $ = N.filter((e) => e.sharingUnchecked);
|
|
86
|
+
return /* @__PURE__ */ b(o, {
|
|
86
87
|
wide: !0,
|
|
87
|
-
title:
|
|
88
|
-
description:
|
|
89
|
-
toolbar:
|
|
88
|
+
title: I("runners"),
|
|
89
|
+
description: I.rich("runnersDescription", { code: (e) => /* @__PURE__ */ y(i, { children: e }) }),
|
|
90
|
+
toolbar: N.length > 0 && /* @__PURE__ */ y(E, {
|
|
90
91
|
view: Y,
|
|
91
|
-
search:
|
|
92
|
-
searchLabel:
|
|
93
|
-
searchPlaceholder:
|
|
92
|
+
search: V,
|
|
93
|
+
searchLabel: I("runnerSearch"),
|
|
94
|
+
searchPlaceholder: I("runnerSearch")
|
|
94
95
|
}),
|
|
95
96
|
children: [
|
|
96
|
-
Q.length > 0 && /* @__PURE__ */
|
|
97
|
+
Q.length > 0 && /* @__PURE__ */ y(f, {
|
|
97
98
|
tone: "warning",
|
|
98
99
|
className: "mb-6",
|
|
99
|
-
children:
|
|
100
|
+
children: I("runnerSharingRefused", {
|
|
100
101
|
count: Q.length,
|
|
101
|
-
names:
|
|
102
|
+
names: L.list(Q.map((e) => e.name), { type: "conjunction" })
|
|
102
103
|
})
|
|
103
104
|
}),
|
|
104
|
-
$.length > 0 && /* @__PURE__ */
|
|
105
|
+
$.length > 0 && /* @__PURE__ */ y(f, {
|
|
105
106
|
tone: "muted",
|
|
106
107
|
className: "mb-6",
|
|
107
|
-
children:
|
|
108
|
+
children: I("runnerSharingUnchecked", {
|
|
108
109
|
count: $.length,
|
|
109
|
-
names:
|
|
110
|
+
names: L.list($.map((e) => e.name), { type: "conjunction" })
|
|
110
111
|
})
|
|
111
112
|
}),
|
|
112
|
-
/* @__PURE__ */
|
|
113
|
+
/* @__PURE__ */ y("div", {
|
|
113
114
|
className: "border-t border-border",
|
|
114
|
-
children: /* @__PURE__ */
|
|
115
|
+
children: /* @__PURE__ */ y(w, {
|
|
115
116
|
view: Y,
|
|
116
|
-
total:
|
|
117
|
+
total: N.length,
|
|
117
118
|
matches: Z.length,
|
|
118
119
|
count: {
|
|
119
|
-
filterActive:
|
|
120
|
-
noun:
|
|
121
|
-
nounPlural:
|
|
120
|
+
filterActive: V.filter.trim() !== "",
|
|
121
|
+
noun: I("runnerNoun"),
|
|
122
|
+
nounPlural: I("runnerNounPlural")
|
|
122
123
|
},
|
|
123
124
|
empty: {
|
|
124
|
-
icon: /* @__PURE__ */
|
|
125
|
-
title:
|
|
125
|
+
icon: /* @__PURE__ */ y(a, {}),
|
|
126
|
+
title: I("noRunners")
|
|
126
127
|
},
|
|
127
|
-
noMatches:
|
|
128
|
-
children: /* @__PURE__ */
|
|
129
|
-
...
|
|
130
|
-
children: [/* @__PURE__ */
|
|
128
|
+
noMatches: I("runnerNoMatches"),
|
|
129
|
+
children: /* @__PURE__ */ b(p, {
|
|
130
|
+
...O,
|
|
131
|
+
children: [/* @__PURE__ */ y(C, { view: Y }), Y.applyOrder(Z).map((e) => /* @__PURE__ */ b(T, {
|
|
131
132
|
href: null,
|
|
132
|
-
goTo:
|
|
133
|
-
openMenu:
|
|
133
|
+
goTo: H,
|
|
134
|
+
openMenu: U,
|
|
134
135
|
items: [
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
m,
|
|
138
|
-
|
|
139
|
-
label: F("revoke"),
|
|
136
|
+
c(I("copyRunnerId"), e.id),
|
|
137
|
+
c(R("copyName"), e.name),
|
|
138
|
+
...!e.group || W ? [m, {
|
|
139
|
+
label: I("revoke"),
|
|
140
140
|
destructive: !0,
|
|
141
|
-
onClick: () =>
|
|
142
|
-
}
|
|
141
|
+
onClick: () => J(e)
|
|
142
|
+
}] : []
|
|
143
143
|
],
|
|
144
144
|
children: [
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
icon: /* @__PURE__ */
|
|
145
|
+
/* @__PURE__ */ y(D, {
|
|
146
|
+
icon: /* @__PURE__ */ y(a, {}),
|
|
147
147
|
iconTile: !0,
|
|
148
148
|
name: e.name,
|
|
149
|
-
subtitle:
|
|
150
|
-
...e.group ? [
|
|
151
|
-
...e.sharingRefused ? [
|
|
152
|
-
...e.sharingUnchecked ? [
|
|
153
|
-
...e.permissionMode ? [
|
|
149
|
+
subtitle: L.list([
|
|
150
|
+
...e.group ? [I("runnerSharedWith", { group: e.group })] : [],
|
|
151
|
+
...e.sharingRefused ? [I("runnerNotTakingRuns")] : [],
|
|
152
|
+
...e.sharingUnchecked ? [I("runnerSharingUnknown")] : [],
|
|
153
|
+
...e.permissionMode ? [I(M[e.permissionMode])] : [],
|
|
154
154
|
...e.harnesses,
|
|
155
155
|
...e.labels
|
|
156
156
|
], { type: "unit" }),
|
|
157
157
|
href: null
|
|
158
158
|
}),
|
|
159
|
-
Y.isVisible("working") && /* @__PURE__ */
|
|
159
|
+
Y.isVisible("working") && /* @__PURE__ */ y(p.Item, {
|
|
160
160
|
className: "py-2.5",
|
|
161
|
-
children: /* @__PURE__ */
|
|
161
|
+
children: /* @__PURE__ */ y(S, { children: (F.get(e.id) ?? []).length > 0 ? (F.get(e.id) ?? []).map((e, t) => /* @__PURE__ */ b("span", { children: [t > 0 && ", ", /* @__PURE__ */ y(l, {
|
|
162
162
|
to: "/$workspace/issues/$identifier",
|
|
163
163
|
params: {
|
|
164
|
-
workspace:
|
|
164
|
+
workspace: d,
|
|
165
165
|
identifier: e.identifier
|
|
166
166
|
},
|
|
167
167
|
className: "hover:underline",
|
|
168
168
|
title: e.issueTitle,
|
|
169
169
|
children: e.identifier
|
|
170
|
-
})] }, e.id)) :
|
|
170
|
+
})] }, e.id)) : I("runnerIdle") })
|
|
171
171
|
}),
|
|
172
|
-
Y.isVisible("seen") && /* @__PURE__ */
|
|
172
|
+
Y.isVisible("seen") && /* @__PURE__ */ b(p.Item, {
|
|
173
173
|
className: "py-2.5",
|
|
174
|
-
children: [/* @__PURE__ */
|
|
174
|
+
children: [/* @__PURE__ */ y(S, { children: e.lastSeenAt ? I("runnerSeen", { seen: z.relative(e.lastSeenAt) }) : I("runnerNeverConnected") }), e.isolation && /* @__PURE__ */ b("span", {
|
|
175
175
|
className: "flex items-center justify-end gap-1.5 text-xs text-muted-foreground",
|
|
176
176
|
title: e.isolation.failures.join("\n") || void 0,
|
|
177
|
-
children: [/* @__PURE__ */
|
|
177
|
+
children: [/* @__PURE__ */ y(ne, {
|
|
178
178
|
variant: e.isolation.passed ? "success" : "error",
|
|
179
179
|
size: 8
|
|
180
|
-
}), e.isolation.passed ?
|
|
180
|
+
}), e.isolation.passed ? I("runnerIsolated") : I("runnerNotIsolated", { count: e.isolation.failures.length })]
|
|
181
181
|
})]
|
|
182
182
|
})
|
|
183
183
|
]
|
|
@@ -185,9 +185,9 @@ function N({ workspace: u }) {
|
|
|
185
185
|
})
|
|
186
186
|
})
|
|
187
187
|
}),
|
|
188
|
-
/* @__PURE__ */
|
|
189
|
-
|
|
188
|
+
/* @__PURE__ */ y(ee, { workspace: d }),
|
|
189
|
+
q
|
|
190
190
|
]
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
|
-
export {
|
|
193
|
+
export { N as component };
|