@debugkit/dashboard 0.4.0 → 0.6.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/.env.example +3 -0
- package/dist/client/assets/_authed-BMdIkvB6.js +7 -0
- package/dist/client/assets/_authed-Rg-Gabby.js +1 -0
- package/dist/client/assets/{charts-C76vsG2N.js → charts-QIIL2Fv7.js} +18 -18
- package/dist/client/assets/index-CMjwqklY.js +10 -0
- package/dist/client/assets/invite._token-CDogkC9p.js +1 -0
- package/dist/client/assets/issues._fingerprint-DLe_lV5d.js +1 -0
- package/dist/client/assets/login-BG9v4zhc.js +1 -0
- package/dist/client/assets/preload-helper-Dscj_TcA.js +3 -0
- package/dist/client/assets/settings-Ce1uqKl0.js +1 -0
- package/dist/client/assets/styles-DztngwT9.css +2 -0
- package/dist/client/assets/team-TUMAZ4jv.js +1 -0
- package/dist/client/assets/ui-C0HGOza2.js +1 -0
- package/dist/server/assets/_authed-DDQ5yYfy.js +73 -0
- package/dist/server/assets/{_authed-ClbGOSDJ.js → _authed-Dray_9Ct.js} +296 -70
- package/dist/server/assets/_tanstack-start-manifest_v-BItoYCqL.js +61 -0
- package/dist/server/assets/{charts-CNlV7Pga.js → charts-DzTVqJ8z.js} +21 -4
- package/dist/server/assets/{demo-DTdlXNgj.js → demo-BsMMDk_F.js} +87 -10
- package/dist/server/assets/dynamodb-Zkk1-mgz.js +445 -0
- package/dist/server/assets/firestore-C52q_vwM.js +237 -0
- package/dist/server/assets/fns-DwGaMi8S.js +107 -0
- package/dist/server/assets/fns-mbUIXXep.js +529 -0
- package/dist/server/assets/invite._token-BWiwnST7.js +136 -0
- package/dist/server/assets/{issues._fingerprint-D78dy5os.js → issues._fingerprint-D9vjIk3M.js} +159 -17
- package/dist/server/assets/{login-h3B5Vdhl.js → login-BXi46U4B.js} +3 -3
- package/dist/server/assets/{queries-DIVV-5j6.js → memory-BssaqdZm.js} +234 -504
- package/dist/server/assets/queries-BJxX3Kjp.js +1669 -0
- package/dist/server/assets/range-picker-0zbSGr3Z.js +106 -0
- package/dist/server/assets/rolldown-runtime-D8jQpDG7.js +12 -0
- package/dist/server/assets/{router-DqTf7XfT.js → router-m6Hpq6Ep.js} +114 -51
- package/dist/server/assets/settings-ByFLIJce.js +371 -0
- package/dist/server/assets/src-D83GYTrp.js +9 -0
- package/dist/server/assets/team-CifrrNkf.js +255 -0
- package/dist/server/assets/{ui-Lv-KcOoP.js → ui-BJokJdYa.js} +25 -3
- package/dist/server/server.js +60 -8
- package/handler.mjs +95 -0
- package/lambda.mjs +61 -0
- package/package.json +16 -7
- package/server.mjs +4 -39
- package/dist/client/assets/_authed-Bi62GTX3.js +0 -7
- package/dist/client/assets/_authed-mWCAMokt.js +0 -1
- package/dist/client/assets/index-D7uhDdvA.js +0 -12
- package/dist/client/assets/issues._fingerprint-fVGLnT37.js +0 -1
- package/dist/client/assets/login-MqvT094Y.js +0 -1
- package/dist/client/assets/styles-CZZRuG1z.css +0 -2
- package/dist/client/assets/ui-Bj6uJIr8.js +0 -1
- package/dist/server/assets/_authed-BaehIntL.js +0 -40
- package/dist/server/assets/_tanstack-start-manifest_v-eNUCOzFz.js +0 -40
- package/dist/server/assets/dynamodb-DejcakaF.js +0 -187
- package/dist/server/assets/firestore-BH-gx9no.js +0 -112
- package/dist/server/assets/fns-CgB12FUN.js +0 -31
- package/dist/server/assets/fns-Yg8sT1Cb.js +0 -87
- package/dist/server/assets/memory-4DwW5cTO.js +0 -59
- package/dist/server/assets/rollups-JXbazRNh.js +0 -22
- package/dist/server/assets/src-D5jyi_C4.js +0 -235
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
import { t as Card } from "./ui-BJokJdYa.js";
|
|
2
|
+
import { _ as sendTestAlert, g as saveRetention, h as saveAppSettings, m as restampExisting } from "./fns-DwGaMi8S.js";
|
|
3
|
+
import { a as Route } from "./router-m6Hpq6Ep.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { useNavigate, useRouter } from "@tanstack/react-router";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/routes/_authed/settings.tsx?tsr-split=component
|
|
8
|
+
var CHOICES = [
|
|
9
|
+
30,
|
|
10
|
+
60,
|
|
11
|
+
90,
|
|
12
|
+
180,
|
|
13
|
+
365
|
|
14
|
+
];
|
|
15
|
+
function SettingsPage() {
|
|
16
|
+
const { apps, settings } = Route.useLoaderData();
|
|
17
|
+
const navigate = useNavigate({ from: Route.fullPath });
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
const [days, setDays] = useState(String(settings?.retentionDays ?? 60));
|
|
20
|
+
const [status, setStatus] = useState(null);
|
|
21
|
+
const [busy, setBusy] = useState(false);
|
|
22
|
+
if (!settings) return /* @__PURE__ */ jsx("main", {
|
|
23
|
+
className: "mx-auto max-w-3xl px-4 py-16 text-center text-muted",
|
|
24
|
+
children: "No apps yet. Settings appear once an app sends its first event."
|
|
25
|
+
});
|
|
26
|
+
const canEdit = settings.writer !== "none";
|
|
27
|
+
const n = Number(days);
|
|
28
|
+
const changed = Number.isInteger(n) && n !== settings.retentionDays;
|
|
29
|
+
const save = async () => {
|
|
30
|
+
setBusy(true);
|
|
31
|
+
setStatus(null);
|
|
32
|
+
const out = await saveRetention({ data: {
|
|
33
|
+
app: settings.app,
|
|
34
|
+
retentionDays: n
|
|
35
|
+
} }).catch((e) => ({
|
|
36
|
+
ok: false,
|
|
37
|
+
error: e.message
|
|
38
|
+
}));
|
|
39
|
+
setBusy(false);
|
|
40
|
+
if (!out.ok) return setStatus({
|
|
41
|
+
tone: "error",
|
|
42
|
+
text: out.error
|
|
43
|
+
});
|
|
44
|
+
setStatus({
|
|
45
|
+
tone: "ok",
|
|
46
|
+
text: `Saved. New events are kept for ${n} days, starting within about a minute.`
|
|
47
|
+
});
|
|
48
|
+
await router.invalidate();
|
|
49
|
+
};
|
|
50
|
+
const restamp = async () => {
|
|
51
|
+
setBusy(true);
|
|
52
|
+
let cursor;
|
|
53
|
+
let total = 0;
|
|
54
|
+
try {
|
|
55
|
+
do {
|
|
56
|
+
const out = await restampExisting({ data: {
|
|
57
|
+
app: settings.app,
|
|
58
|
+
cursor
|
|
59
|
+
} });
|
|
60
|
+
if (!out.ok) throw new Error(out.error);
|
|
61
|
+
total += out.updated;
|
|
62
|
+
cursor = out.cursor;
|
|
63
|
+
setStatus({
|
|
64
|
+
tone: "info",
|
|
65
|
+
text: `Updating existing events… ${total.toLocaleString()} so far`
|
|
66
|
+
});
|
|
67
|
+
} while (cursor);
|
|
68
|
+
setStatus({
|
|
69
|
+
tone: "ok",
|
|
70
|
+
text: `Done: ${total.toLocaleString()} existing events now expire ${settings.retentionDays} days after they arrived.`
|
|
71
|
+
});
|
|
72
|
+
} catch (err) {
|
|
73
|
+
setStatus({
|
|
74
|
+
tone: "error",
|
|
75
|
+
text: `Stopped after ${total.toLocaleString()} events: ${err.message}`
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
setBusy(false);
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ jsxs("main", {
|
|
81
|
+
className: "mx-auto max-w-3xl space-y-5 px-4 py-6 sm:px-6",
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsxs("div", {
|
|
84
|
+
className: "flex flex-wrap items-end justify-between gap-3",
|
|
85
|
+
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("p", {
|
|
86
|
+
className: "text-xs uppercase tracking-wide text-muted",
|
|
87
|
+
children: "Settings"
|
|
88
|
+
}), /* @__PURE__ */ jsx("h1", {
|
|
89
|
+
className: "text-2xl font-semibold tracking-tight",
|
|
90
|
+
children: settings.app
|
|
91
|
+
})] }), apps.length > 1 && /* @__PURE__ */ jsx("select", {
|
|
92
|
+
"aria-label": "App",
|
|
93
|
+
value: settings.app,
|
|
94
|
+
onChange: (e) => navigate({ search: { app: e.target.value } }),
|
|
95
|
+
className: "rounded-md border border-line bg-panel px-2 py-1.5 text-sm",
|
|
96
|
+
children: apps.map((a) => /* @__PURE__ */ jsx("option", { children: a }, a))
|
|
97
|
+
})]
|
|
98
|
+
}),
|
|
99
|
+
/* @__PURE__ */ jsxs(Card, {
|
|
100
|
+
title: "Data retention",
|
|
101
|
+
subtitle: "Your data lives in your own database, so you decide how long to keep it.",
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ jsxs("dl", {
|
|
104
|
+
className: "grid gap-3 text-sm sm:grid-cols-2",
|
|
105
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
106
|
+
className: "rounded-lg border border-line p-3",
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ jsx("dt", {
|
|
109
|
+
className: "text-xs text-muted",
|
|
110
|
+
children: "Raw events (stack traces, breadcrumbs, context)"
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ jsx("dd", {
|
|
113
|
+
className: "mt-1 text-lg font-semibold",
|
|
114
|
+
children: settings.retentionDays ? `${settings.retentionDays} days` : "Unknown"
|
|
115
|
+
}),
|
|
116
|
+
/* @__PURE__ */ jsx("dd", {
|
|
117
|
+
className: "text-xs text-muted",
|
|
118
|
+
children: settings.source === "setting" ? `Set here${settings.updatedAt ? ` on ${new Date(settings.updatedAt).toLocaleDateString("en-GB")}` : ""}` : settings.source === "default" ? "The default chosen at setup" : "Not reported by this deployment"
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
122
|
+
className: "rounded-lg border border-line p-3",
|
|
123
|
+
children: [
|
|
124
|
+
/* @__PURE__ */ jsx("dt", {
|
|
125
|
+
className: "text-xs text-muted",
|
|
126
|
+
children: "Counts, issues and release health"
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ jsx("dd", {
|
|
129
|
+
className: "mt-1 text-lg font-semibold",
|
|
130
|
+
children: "Forever"
|
|
131
|
+
}),
|
|
132
|
+
/* @__PURE__ */ jsx("dd", {
|
|
133
|
+
className: "text-xs text-muted",
|
|
134
|
+
children: "Charts and trends cover any date range"
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
})]
|
|
138
|
+
}),
|
|
139
|
+
canEdit ? /* @__PURE__ */ jsxs("form", {
|
|
140
|
+
className: "mt-4 space-y-3",
|
|
141
|
+
onSubmit: (e) => {
|
|
142
|
+
e.preventDefault();
|
|
143
|
+
if (changed) save();
|
|
144
|
+
},
|
|
145
|
+
children: [
|
|
146
|
+
/* @__PURE__ */ jsx("label", {
|
|
147
|
+
className: "block text-sm font-medium",
|
|
148
|
+
htmlFor: "days",
|
|
149
|
+
children: "Keep raw events for"
|
|
150
|
+
}),
|
|
151
|
+
/* @__PURE__ */ jsxs("div", {
|
|
152
|
+
className: "flex flex-wrap items-center gap-2",
|
|
153
|
+
children: [
|
|
154
|
+
CHOICES.map((c) => /* @__PURE__ */ jsxs("button", {
|
|
155
|
+
type: "button",
|
|
156
|
+
onClick: () => setDays(String(c)),
|
|
157
|
+
className: `rounded-md border px-3 py-1.5 text-sm ${Number(days) === c ? "border-accent bg-accent-soft text-accent" : "border-line hover:bg-panel-2"}`,
|
|
158
|
+
children: [c, " days"]
|
|
159
|
+
}, c)),
|
|
160
|
+
/* @__PURE__ */ jsx("input", {
|
|
161
|
+
id: "days",
|
|
162
|
+
type: "number",
|
|
163
|
+
min: 1,
|
|
164
|
+
max: 3650,
|
|
165
|
+
value: days,
|
|
166
|
+
onChange: (e) => setDays(e.target.value),
|
|
167
|
+
className: "w-24 rounded-md border border-line bg-panel px-2 py-1.5 text-sm",
|
|
168
|
+
"aria-label": "Days"
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ jsx("button", {
|
|
171
|
+
type: "submit",
|
|
172
|
+
disabled: !changed || busy,
|
|
173
|
+
className: "rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white disabled:opacity-40",
|
|
174
|
+
children: "Save"
|
|
175
|
+
})
|
|
176
|
+
]
|
|
177
|
+
}),
|
|
178
|
+
/* @__PURE__ */ jsx("p", {
|
|
179
|
+
className: "text-xs text-muted",
|
|
180
|
+
children: "Applies to events that arrive from now on. When you shorten it, older events are removed by your database's own clean-up: within about a day on Firestore, up to two days on DynamoDB."
|
|
181
|
+
})
|
|
182
|
+
]
|
|
183
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
184
|
+
className: "mt-4 text-sm text-muted",
|
|
185
|
+
children: settings.note
|
|
186
|
+
}),
|
|
187
|
+
settings.note && canEdit && /* @__PURE__ */ jsx("p", {
|
|
188
|
+
className: "mt-2 text-xs text-sev-high",
|
|
189
|
+
children: settings.note
|
|
190
|
+
})
|
|
191
|
+
]
|
|
192
|
+
}),
|
|
193
|
+
canEdit && /* @__PURE__ */ jsxs(Card, {
|
|
194
|
+
title: "Existing events",
|
|
195
|
+
subtitle: "Events already stored keep the expiry they arrived with.",
|
|
196
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
197
|
+
className: "text-sm",
|
|
198
|
+
children: [
|
|
199
|
+
"Give every stored event an expiry based on the current setting (",
|
|
200
|
+
settings.retentionDays,
|
|
201
|
+
" days after it arrived). This costs one database write per event."
|
|
202
|
+
]
|
|
203
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
204
|
+
type: "button",
|
|
205
|
+
onClick: () => void restamp(),
|
|
206
|
+
disabled: busy,
|
|
207
|
+
className: "mt-3 rounded-md border border-line px-3 py-1.5 text-sm hover:bg-panel-2 disabled:opacity-40",
|
|
208
|
+
children: "Apply to existing events"
|
|
209
|
+
})]
|
|
210
|
+
}),
|
|
211
|
+
canEdit && /* @__PURE__ */ jsx(FlowsAndAlerts, {
|
|
212
|
+
settings,
|
|
213
|
+
onStatus: setStatus
|
|
214
|
+
}, settings.app + (settings.updatedAt ?? "")),
|
|
215
|
+
status && /* @__PURE__ */ jsx("p", {
|
|
216
|
+
role: "status",
|
|
217
|
+
className: `rounded-lg border px-3 py-2 text-sm ${status.tone === "error" ? "border-sev-critical text-sev-critical" : status.tone === "ok" ? "border-line bg-panel-2" : "border-line text-muted"}`,
|
|
218
|
+
children: status.text
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function FlowsAndAlerts({ settings, onStatus }) {
|
|
224
|
+
const router = useRouter();
|
|
225
|
+
const [flows, setFlows] = useState(settings.criticalFlows.join(", "));
|
|
226
|
+
const [hook, setHook] = useState(settings.alerts.slackWebhookUrl ?? "");
|
|
227
|
+
const [newIssues, setNewIssues] = useState(settings.alerts.newIssues !== false);
|
|
228
|
+
const [regressions, setRegressions] = useState(settings.alerts.regressions !== false);
|
|
229
|
+
const [onlyCritical, setOnlyCritical] = useState(settings.alerts.onlyCriticalFlows === true);
|
|
230
|
+
const [dashboardUrl, setDashboardUrl] = useState(settings.alerts.dashboardUrl ?? (typeof window !== "undefined" ? window.location.origin : ""));
|
|
231
|
+
const [busy, setBusy] = useState(false);
|
|
232
|
+
const save = async () => {
|
|
233
|
+
setBusy(true);
|
|
234
|
+
onStatus(null);
|
|
235
|
+
const out = await saveAppSettings({ data: {
|
|
236
|
+
app: settings.app,
|
|
237
|
+
criticalFlows: flows.split(/[\s,]+/).filter(Boolean),
|
|
238
|
+
alerts: {
|
|
239
|
+
slackWebhookUrl: hook,
|
|
240
|
+
newIssues,
|
|
241
|
+
regressions,
|
|
242
|
+
onlyCriticalFlows: onlyCritical,
|
|
243
|
+
dashboardUrl
|
|
244
|
+
}
|
|
245
|
+
} }).catch((e) => ({
|
|
246
|
+
ok: false,
|
|
247
|
+
error: e.message
|
|
248
|
+
}));
|
|
249
|
+
setBusy(false);
|
|
250
|
+
if (!out.ok) return onStatus({
|
|
251
|
+
tone: "error",
|
|
252
|
+
text: out.error
|
|
253
|
+
});
|
|
254
|
+
onStatus({
|
|
255
|
+
tone: "ok",
|
|
256
|
+
text: "Saved. Alerts and critical flows apply within about a minute."
|
|
257
|
+
});
|
|
258
|
+
await router.invalidate();
|
|
259
|
+
};
|
|
260
|
+
const test = async () => {
|
|
261
|
+
setBusy(true);
|
|
262
|
+
const out = await sendTestAlert({ data: { app: settings.app } }).catch((e) => ({
|
|
263
|
+
ok: false,
|
|
264
|
+
error: e.message
|
|
265
|
+
}));
|
|
266
|
+
setBusy(false);
|
|
267
|
+
onStatus(out.ok ? {
|
|
268
|
+
tone: "ok",
|
|
269
|
+
text: "Test message sent. Check your Slack channel."
|
|
270
|
+
} : {
|
|
271
|
+
tone: "error",
|
|
272
|
+
text: out.error
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
const box = "rounded-md border border-line bg-panel px-2 py-1.5 text-sm";
|
|
276
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
277
|
+
/* @__PURE__ */ jsxs(Card, {
|
|
278
|
+
title: "Critical flows",
|
|
279
|
+
subtitle: "Issues in these flows rank one severity level higher, and can be the only ones that alert.",
|
|
280
|
+
children: [/* @__PURE__ */ jsx("label", {
|
|
281
|
+
className: "block text-sm font-medium",
|
|
282
|
+
htmlFor: "flows",
|
|
283
|
+
children: "Flows, separated by commas"
|
|
284
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
285
|
+
id: "flows",
|
|
286
|
+
value: flows,
|
|
287
|
+
onChange: (e) => setFlows(e.target.value),
|
|
288
|
+
placeholder: "checkout.payment, auth.login",
|
|
289
|
+
className: `mt-2 w-full ${box}`
|
|
290
|
+
})]
|
|
291
|
+
}),
|
|
292
|
+
/* @__PURE__ */ jsx(Card, {
|
|
293
|
+
title: "Slack alerts",
|
|
294
|
+
subtitle: "Your ingest function posts to Slack when an issue first appears or comes back after being resolved.",
|
|
295
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
296
|
+
className: "space-y-3 text-sm",
|
|
297
|
+
children: [
|
|
298
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
299
|
+
/* @__PURE__ */ jsx("label", {
|
|
300
|
+
className: "block font-medium",
|
|
301
|
+
htmlFor: "hook",
|
|
302
|
+
children: "Incoming webhook URL"
|
|
303
|
+
}),
|
|
304
|
+
/* @__PURE__ */ jsx("input", {
|
|
305
|
+
id: "hook",
|
|
306
|
+
value: hook,
|
|
307
|
+
onChange: (e) => setHook(e.target.value),
|
|
308
|
+
placeholder: "https://hooks.slack.com/services/…",
|
|
309
|
+
className: `mt-2 w-full font-mono ${box}`
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ jsx("p", {
|
|
312
|
+
className: "mt-1 text-xs text-muted",
|
|
313
|
+
children: "Create one under your Slack app's Incoming Webhooks. Leave empty to turn alerts off."
|
|
314
|
+
})
|
|
315
|
+
] }),
|
|
316
|
+
/* @__PURE__ */ jsxs("label", {
|
|
317
|
+
className: "flex items-center gap-2",
|
|
318
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
319
|
+
type: "checkbox",
|
|
320
|
+
checked: newIssues,
|
|
321
|
+
onChange: (e) => setNewIssues(e.target.checked)
|
|
322
|
+
}), " New issues"]
|
|
323
|
+
}),
|
|
324
|
+
/* @__PURE__ */ jsxs("label", {
|
|
325
|
+
className: "flex items-center gap-2",
|
|
326
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
327
|
+
type: "checkbox",
|
|
328
|
+
checked: regressions,
|
|
329
|
+
onChange: (e) => setRegressions(e.target.checked)
|
|
330
|
+
}), " Regressions"]
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ jsxs("label", {
|
|
333
|
+
className: "flex items-center gap-2",
|
|
334
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
335
|
+
type: "checkbox",
|
|
336
|
+
checked: onlyCritical,
|
|
337
|
+
onChange: (e) => setOnlyCritical(e.target.checked)
|
|
338
|
+
}), " Only for critical flows"]
|
|
339
|
+
}),
|
|
340
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("label", {
|
|
341
|
+
className: "block font-medium",
|
|
342
|
+
htmlFor: "dash-url",
|
|
343
|
+
children: "Dashboard address, for links in alerts"
|
|
344
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
345
|
+
id: "dash-url",
|
|
346
|
+
value: dashboardUrl,
|
|
347
|
+
onChange: (e) => setDashboardUrl(e.target.value),
|
|
348
|
+
className: `mt-2 w-full ${box}`
|
|
349
|
+
})] })
|
|
350
|
+
]
|
|
351
|
+
})
|
|
352
|
+
}),
|
|
353
|
+
/* @__PURE__ */ jsxs("div", {
|
|
354
|
+
className: "flex flex-wrap gap-2",
|
|
355
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
356
|
+
type: "button",
|
|
357
|
+
onClick: () => void save(),
|
|
358
|
+
disabled: busy,
|
|
359
|
+
className: "rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white disabled:opacity-40",
|
|
360
|
+
children: "Save flows and alerts"
|
|
361
|
+
}), settings.alerts.slackWebhookUrl && settings.writer === "admin" && /* @__PURE__ */ jsx("button", {
|
|
362
|
+
type: "button",
|
|
363
|
+
onClick: () => void test(),
|
|
364
|
+
disabled: busy,
|
|
365
|
+
className: "rounded-md border border-line px-3 py-1.5 text-sm hover:bg-panel-2 disabled:opacity-40",
|
|
366
|
+
children: "Send a test alert"
|
|
367
|
+
})]
|
|
368
|
+
})
|
|
369
|
+
] });
|
|
370
|
+
}
|
|
371
|
+
export { SettingsPage as component };
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { c as timeAgo, t as Card } from "./ui-BJokJdYa.js";
|
|
2
|
+
import { l as inviteToTeam, p as removeFromTeam, t as cancelInvite, v as setMemberRole } from "./fns-DwGaMi8S.js";
|
|
3
|
+
import { i as Route } from "./router-m6Hpq6Ep.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { useRouter } from "@tanstack/react-router";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/routes/_authed/team.tsx?tsr-split=component
|
|
8
|
+
var ROLE_HELP = {
|
|
9
|
+
owner: "everything, including owners",
|
|
10
|
+
admin: "settings and the team, except owners",
|
|
11
|
+
member: "sees everything, changes issue status"
|
|
12
|
+
};
|
|
13
|
+
function TeamPage() {
|
|
14
|
+
const team = Route.useLoaderData();
|
|
15
|
+
const router = useRouter();
|
|
16
|
+
const [role, setRole] = useState("member");
|
|
17
|
+
const [email, setEmail] = useState("");
|
|
18
|
+
const [link, setLink] = useState(null);
|
|
19
|
+
const [status, setStatus] = useState(null);
|
|
20
|
+
const [busy, setBusy] = useState(false);
|
|
21
|
+
const canInvite = team.canManage && team.canWrite;
|
|
22
|
+
const act = async (fn, done) => {
|
|
23
|
+
setBusy(true);
|
|
24
|
+
setStatus(null);
|
|
25
|
+
const out = await fn().catch((e) => ({
|
|
26
|
+
ok: false,
|
|
27
|
+
error: e.message
|
|
28
|
+
}));
|
|
29
|
+
setBusy(false);
|
|
30
|
+
if (!out.ok) return setStatus({
|
|
31
|
+
tone: "error",
|
|
32
|
+
text: out.error ?? "That didn't work."
|
|
33
|
+
});
|
|
34
|
+
setStatus({
|
|
35
|
+
tone: "ok",
|
|
36
|
+
text: done
|
|
37
|
+
});
|
|
38
|
+
await router.invalidate();
|
|
39
|
+
};
|
|
40
|
+
const invite = async (e) => {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
setBusy(true);
|
|
43
|
+
setStatus(null);
|
|
44
|
+
setLink(null);
|
|
45
|
+
const out = await inviteToTeam({ data: {
|
|
46
|
+
role,
|
|
47
|
+
email: email.trim() || void 0
|
|
48
|
+
} }).catch((err) => ({
|
|
49
|
+
ok: false,
|
|
50
|
+
error: err.message
|
|
51
|
+
}));
|
|
52
|
+
setBusy(false);
|
|
53
|
+
if (!out.ok) return setStatus({
|
|
54
|
+
tone: "error",
|
|
55
|
+
text: out.error
|
|
56
|
+
});
|
|
57
|
+
setLink({
|
|
58
|
+
url: `${window.location.origin}/invite/${out.token}`,
|
|
59
|
+
expiresAt: out.expiresAt,
|
|
60
|
+
email: email.trim() || void 0
|
|
61
|
+
});
|
|
62
|
+
setEmail("");
|
|
63
|
+
await router.invalidate();
|
|
64
|
+
};
|
|
65
|
+
return /* @__PURE__ */ jsxs("main", {
|
|
66
|
+
className: "mx-auto max-w-3xl space-y-5 px-4 py-6 sm:px-6",
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h1", {
|
|
69
|
+
className: "text-xl font-semibold",
|
|
70
|
+
children: "Team"
|
|
71
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
72
|
+
className: "mt-1 text-sm text-muted",
|
|
73
|
+
children: "Everyone who can sign in to this dashboard. Invite people with a link; nothing is emailed."
|
|
74
|
+
})] }),
|
|
75
|
+
canInvite && /* @__PURE__ */ jsxs(Card, {
|
|
76
|
+
title: "Invite someone",
|
|
77
|
+
subtitle: "The link works once and expires in 7 days.",
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsxs("form", {
|
|
80
|
+
onSubmit: invite,
|
|
81
|
+
className: "flex flex-wrap items-end gap-3",
|
|
82
|
+
children: [
|
|
83
|
+
/* @__PURE__ */ jsxs("label", {
|
|
84
|
+
className: "min-w-0 flex-1 text-sm",
|
|
85
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
86
|
+
className: "font-medium",
|
|
87
|
+
children: "Email (optional)"
|
|
88
|
+
}), /* @__PURE__ */ jsx("input", {
|
|
89
|
+
type: "email",
|
|
90
|
+
value: email,
|
|
91
|
+
onChange: (e) => setEmail(e.target.value),
|
|
92
|
+
placeholder: "Only this person can use the link",
|
|
93
|
+
className: "mt-1 w-full rounded-md border border-line bg-bg px-3 py-2 text-sm outline-none focus:border-accent"
|
|
94
|
+
})]
|
|
95
|
+
}),
|
|
96
|
+
/* @__PURE__ */ jsxs("label", {
|
|
97
|
+
className: "text-sm",
|
|
98
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
99
|
+
className: "font-medium",
|
|
100
|
+
children: "Role"
|
|
101
|
+
}), /* @__PURE__ */ jsx("select", {
|
|
102
|
+
value: role,
|
|
103
|
+
onChange: (e) => setRole(e.target.value),
|
|
104
|
+
className: "mt-1 block rounded-md border border-line bg-bg px-3 py-2 text-sm",
|
|
105
|
+
children: (team.me.role === "owner" ? [
|
|
106
|
+
"member",
|
|
107
|
+
"admin",
|
|
108
|
+
"owner"
|
|
109
|
+
] : ["member", "admin"]).map((r) => /* @__PURE__ */ jsx("option", {
|
|
110
|
+
value: r,
|
|
111
|
+
children: r
|
|
112
|
+
}, r))
|
|
113
|
+
})]
|
|
114
|
+
}),
|
|
115
|
+
/* @__PURE__ */ jsx("button", {
|
|
116
|
+
disabled: busy,
|
|
117
|
+
className: "rounded-md bg-ink px-3 py-2 text-sm font-medium text-bg disabled:opacity-60",
|
|
118
|
+
children: "Create invite link"
|
|
119
|
+
})
|
|
120
|
+
]
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ jsxs("p", {
|
|
123
|
+
className: "mt-2 text-xs text-muted",
|
|
124
|
+
children: [
|
|
125
|
+
role,
|
|
126
|
+
": ",
|
|
127
|
+
ROLE_HELP[role],
|
|
128
|
+
"."
|
|
129
|
+
]
|
|
130
|
+
}),
|
|
131
|
+
link && /* @__PURE__ */ jsxs("div", {
|
|
132
|
+
className: "mt-4 rounded-md border border-accent bg-accent-soft p-3 text-sm",
|
|
133
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
134
|
+
className: "font-medium",
|
|
135
|
+
children: [
|
|
136
|
+
"Send this link",
|
|
137
|
+
link.email ? ` to ${link.email}` : "",
|
|
138
|
+
". It's shown only now."
|
|
139
|
+
]
|
|
140
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
141
|
+
className: "mt-2 flex min-w-0 gap-2",
|
|
142
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
143
|
+
readOnly: true,
|
|
144
|
+
value: link.url,
|
|
145
|
+
"aria-label": "Invite link",
|
|
146
|
+
onFocus: (e) => e.currentTarget.select(),
|
|
147
|
+
className: "min-w-0 flex-1 rounded-md border border-line bg-bg px-2 py-1.5 font-mono text-xs"
|
|
148
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
149
|
+
type: "button",
|
|
150
|
+
className: "rounded-md border border-line bg-bg px-2.5 py-1 text-xs hover:bg-panel-2",
|
|
151
|
+
onClick: () => navigator.clipboard?.writeText(link.url).then(() => setStatus({
|
|
152
|
+
tone: "ok",
|
|
153
|
+
text: "Link copied."
|
|
154
|
+
})),
|
|
155
|
+
children: "Copy"
|
|
156
|
+
})]
|
|
157
|
+
})]
|
|
158
|
+
})
|
|
159
|
+
]
|
|
160
|
+
}),
|
|
161
|
+
team.note && /* @__PURE__ */ jsx("p", {
|
|
162
|
+
className: "text-sm text-muted",
|
|
163
|
+
children: team.note
|
|
164
|
+
}),
|
|
165
|
+
status && /* @__PURE__ */ jsx("p", {
|
|
166
|
+
role: status.tone === "error" ? "alert" : "status",
|
|
167
|
+
className: `text-sm ${status.tone === "error" ? "text-sev-critical" : "text-ink"}`,
|
|
168
|
+
children: status.text
|
|
169
|
+
}),
|
|
170
|
+
/* @__PURE__ */ jsx(Card, {
|
|
171
|
+
title: "Members",
|
|
172
|
+
subtitle: `${team.members.length} ${team.members.length === 1 ? "person" : "people"}`,
|
|
173
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
174
|
+
className: "divide-y divide-line",
|
|
175
|
+
children: team.members.map((m) => {
|
|
176
|
+
const me = m.email === team.me.email;
|
|
177
|
+
const editable = canInvite && m.source === "team" && !me && (team.me.role === "owner" || m.role !== "owner");
|
|
178
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
179
|
+
className: "flex flex-wrap items-center justify-between gap-2 py-3",
|
|
180
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
181
|
+
className: "min-w-0",
|
|
182
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
183
|
+
className: "truncate text-sm font-medium",
|
|
184
|
+
children: [
|
|
185
|
+
m.name ? `${m.name} · ` : "",
|
|
186
|
+
m.email,
|
|
187
|
+
me ? " (you)" : ""
|
|
188
|
+
]
|
|
189
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
190
|
+
className: "text-xs text-muted",
|
|
191
|
+
children: m.source === "env" ? "Set up with npx debugkit init" : `Joined ${m.createdAt ? timeAgo(m.createdAt) : ""}${m.invitedBy ? `, invited by ${m.invitedBy}` : ""}`
|
|
192
|
+
})]
|
|
193
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
194
|
+
className: "flex items-center gap-2",
|
|
195
|
+
children: [editable ? /* @__PURE__ */ jsx("select", {
|
|
196
|
+
"aria-label": `Role for ${m.email}`,
|
|
197
|
+
value: m.role,
|
|
198
|
+
disabled: busy,
|
|
199
|
+
className: "rounded-md border border-line bg-bg px-2 py-1 text-sm",
|
|
200
|
+
onChange: (e) => act(() => setMemberRole({ data: {
|
|
201
|
+
email: m.email,
|
|
202
|
+
role: e.target.value
|
|
203
|
+
} }), `${m.email} is now ${e.target.value}.`),
|
|
204
|
+
children: (team.me.role === "owner" ? [
|
|
205
|
+
"member",
|
|
206
|
+
"admin",
|
|
207
|
+
"owner"
|
|
208
|
+
] : ["member", "admin"]).map((r) => /* @__PURE__ */ jsx("option", {
|
|
209
|
+
value: r,
|
|
210
|
+
children: r
|
|
211
|
+
}, r))
|
|
212
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
213
|
+
className: "rounded-full border border-line px-2 py-0.5 text-xs",
|
|
214
|
+
children: m.role
|
|
215
|
+
}), editable && /* @__PURE__ */ jsx("button", {
|
|
216
|
+
disabled: busy,
|
|
217
|
+
className: "rounded-md border border-line px-2.5 py-1 text-xs text-sev-critical hover:bg-panel-2",
|
|
218
|
+
onClick: () => confirm(`Remove ${m.email}? They're signed out right away.`) && act(() => removeFromTeam({ data: { email: m.email } }), `${m.email} no longer has access.`),
|
|
219
|
+
children: "Remove"
|
|
220
|
+
})]
|
|
221
|
+
})]
|
|
222
|
+
}, m.email);
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
}),
|
|
226
|
+
team.invites.length > 0 && /* @__PURE__ */ jsx(Card, {
|
|
227
|
+
title: "Pending invites",
|
|
228
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
229
|
+
className: "divide-y divide-line",
|
|
230
|
+
children: team.invites.map((i) => /* @__PURE__ */ jsxs("li", {
|
|
231
|
+
className: "flex flex-wrap items-center justify-between gap-2 py-3 text-sm",
|
|
232
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
233
|
+
className: "min-w-0",
|
|
234
|
+
children: [
|
|
235
|
+
/* @__PURE__ */ jsx("b", { children: i.role }),
|
|
236
|
+
" ",
|
|
237
|
+
i.email ? `for ${i.email}` : "for anyone with the link",
|
|
238
|
+
" · by ",
|
|
239
|
+
i.invitedBy,
|
|
240
|
+
" · expires ",
|
|
241
|
+
new Date(i.expiresAt).toLocaleDateString()
|
|
242
|
+
]
|
|
243
|
+
}), canInvite && (team.me.role === "owner" || i.role !== "owner") && /* @__PURE__ */ jsx("button", {
|
|
244
|
+
disabled: busy,
|
|
245
|
+
className: "rounded-md border border-line px-2.5 py-1 text-xs hover:bg-panel-2",
|
|
246
|
+
onClick: () => act(() => cancelInvite({ data: { id: i.id } }), "Invite cancelled."),
|
|
247
|
+
children: "Cancel"
|
|
248
|
+
})]
|
|
249
|
+
}, i.id))
|
|
250
|
+
})
|
|
251
|
+
})
|
|
252
|
+
]
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
export { TeamPage as component };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
// src/components/ui.tsx
|
|
3
3
|
function Logo() {
|
|
4
4
|
return /* @__PURE__ */ jsxs("span", {
|
|
@@ -26,7 +26,7 @@ function SeverityBadge({ severity }) {
|
|
|
26
26
|
}
|
|
27
27
|
function Card({ title, subtitle, children, right }) {
|
|
28
28
|
return /* @__PURE__ */ jsxs("section", {
|
|
29
|
-
className: "rounded-xl border border-line bg-panel p-4 sm:p-5",
|
|
29
|
+
className: "min-w-0 rounded-xl border border-line bg-panel p-4 sm:p-5",
|
|
30
30
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
31
31
|
className: "mb-3 flex items-start justify-between gap-3",
|
|
32
32
|
children: [/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
|
|
@@ -128,4 +128,26 @@ function timeAgo(iso, now = Date.now()) {
|
|
|
128
128
|
if (s < 86400) return `${Math.round(s / 3600)}h ago`;
|
|
129
129
|
return `${Math.round(s / 86400)}d ago`;
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
/** Small labels under an issue: regressed, new in the latest release, resolved, ignored. */
|
|
132
|
+
function IssueLabels({ issue }) {
|
|
133
|
+
const chip = "mt-1 mr-1 inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide";
|
|
134
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
135
|
+
issue.status === "regressed" && /* @__PURE__ */ jsxs("span", {
|
|
136
|
+
className: `${chip} bg-sev-critical text-white`,
|
|
137
|
+
children: ["Regressed", issue.resolvedIn ? ` after ${issue.resolvedIn}` : ""]
|
|
138
|
+
}),
|
|
139
|
+
issue.newInLatest && /* @__PURE__ */ jsxs("span", {
|
|
140
|
+
className: `${chip} bg-accent-soft text-accent`,
|
|
141
|
+
children: ["New in ", issue.firstVersion]
|
|
142
|
+
}),
|
|
143
|
+
issue.status === "resolved" && /* @__PURE__ */ jsxs("span", {
|
|
144
|
+
className: `${chip} border border-line text-muted`,
|
|
145
|
+
children: ["Resolved", issue.resolvedIn ? ` in ${issue.resolvedIn}` : ""]
|
|
146
|
+
}),
|
|
147
|
+
issue.status === "ignored" && /* @__PURE__ */ jsx("span", {
|
|
148
|
+
className: `${chip} border border-line text-muted`,
|
|
149
|
+
children: "Ignored"
|
|
150
|
+
})
|
|
151
|
+
] });
|
|
152
|
+
}
|
|
153
|
+
export { SeverityBadge as a, timeAgo as c, Logo as i, DataTable as n, ShareBars as o, IssueLabels as r, Stat as s, Card as t };
|