paseo-dsh 0.2.20 → 0.2.22
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/OVERVIEW.md +4 -4
- package/OVERVIEW.zh-CN.md +15 -0
- package/README.md +6 -6
- package/client/dsh-plugins-page.tsx +960 -0
- package/client/guard.tsx +115 -0
- package/client/i18n.ts +100 -0
- package/client/labels.ts +23 -0
- package/client/locales/en.json +215 -0
- package/client/locales/zh-CN.json +213 -0
- package/client/messages.ts +85 -0
- package/client/react-native.d.ts +3 -0
- package/client/settings-screen.tsx +34 -21
- package/client/stream-stats.tsx +71 -48
- package/client/timeline.tsx +442 -123
- package/index.client.tsx +42 -4
- package/index.server.ts +30 -7
- package/package.json +8 -6
- package/paseo-plugin.json +8 -2
- package/server/bootstrap.ts +8 -2
- package/server/bridge-assets.ts +3 -2
- package/server/dsh-plugins-rpc.ts +45 -0
- package/server/dsh-plugins.ts +970 -0
- package/server/dsh-process.ts +61 -11
- package/server/provider.ts +25 -7
- package/server/session.ts +410 -48
- package/server/timeline.ts +69 -4
- package/shared/dsh-plugins-api.ts +175 -0
- package/shared/image-preview.ts +8 -1
- package/shared/settings.ts +14 -43
|
@@ -0,0 +1,960 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Component,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useState,
|
|
7
|
+
type ReactNode,
|
|
8
|
+
} from "react";
|
|
9
|
+
import {
|
|
10
|
+
ActivityIndicator,
|
|
11
|
+
Pressable,
|
|
12
|
+
ScrollView,
|
|
13
|
+
Switch,
|
|
14
|
+
Text,
|
|
15
|
+
TextInput,
|
|
16
|
+
View,
|
|
17
|
+
} from "react-native";
|
|
18
|
+
import type { PluginSurfaceProps } from "@getpaseo/plugin/client";
|
|
19
|
+
import { useRpc } from "@getpaseo/plugin/client";
|
|
20
|
+
import { useTranslation } from "./i18n";
|
|
21
|
+
import { report } from "./guard";
|
|
22
|
+
import {
|
|
23
|
+
inspectSpecRpc,
|
|
24
|
+
jobStatusRpc,
|
|
25
|
+
listRpc,
|
|
26
|
+
setEnabledRpc,
|
|
27
|
+
startJobRpc,
|
|
28
|
+
type BundleInfo,
|
|
29
|
+
type FailureCode,
|
|
30
|
+
type InspectSpecOutput,
|
|
31
|
+
type JobStatus,
|
|
32
|
+
type PluginsSnapshot,
|
|
33
|
+
type StartJobInput,
|
|
34
|
+
} from "../shared/dsh-plugins-api";
|
|
35
|
+
|
|
36
|
+
type ThemeColors = PluginSurfaceProps["theme"]["colors"];
|
|
37
|
+
type Styles = ReturnType<typeof createStyles>;
|
|
38
|
+
|
|
39
|
+
// The catalog is known at build time; helpers only pass keys from it.
|
|
40
|
+
type Translate = (key: string, args?: Record<string, unknown>) => string;
|
|
41
|
+
|
|
42
|
+
interface UiFailure {
|
|
43
|
+
code: FailureCode;
|
|
44
|
+
detail?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const FAILURE_CODES = new Set<string>([
|
|
48
|
+
"profile-unreadable",
|
|
49
|
+
"profile-invalid",
|
|
50
|
+
"invalid-platform",
|
|
51
|
+
"lock-timeout",
|
|
52
|
+
"invalid-name",
|
|
53
|
+
"protected",
|
|
54
|
+
"not-installed",
|
|
55
|
+
"not-a-bundle",
|
|
56
|
+
"invalid-spec",
|
|
57
|
+
"registry-unreadable",
|
|
58
|
+
"registry-invalid",
|
|
59
|
+
"already-installed",
|
|
60
|
+
"not-removable",
|
|
61
|
+
"not-in-dependencies",
|
|
62
|
+
"invalid-version",
|
|
63
|
+
"check-failed",
|
|
64
|
+
"disposed",
|
|
65
|
+
"busy",
|
|
66
|
+
"job-missing",
|
|
67
|
+
"spawn-failed",
|
|
68
|
+
"command-failed",
|
|
69
|
+
"request-failed",
|
|
70
|
+
]);
|
|
71
|
+
|
|
72
|
+
function failureOf(error: unknown): UiFailure {
|
|
73
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
74
|
+
return {
|
|
75
|
+
code: FAILURE_CODES.has(message) ? message as FailureCode : "request-failed",
|
|
76
|
+
...(message === "" ? {} : { detail: message }),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const FAILURE_KEYS: Record<FailureCode, string> = {
|
|
81
|
+
"profile-unreadable": "plugins.errors.profile-unreadable",
|
|
82
|
+
"profile-invalid": "plugins.errors.profile-invalid",
|
|
83
|
+
"invalid-platform": "plugins.errors.invalid-platform",
|
|
84
|
+
"lock-timeout": "plugins.errors.lock-timeout",
|
|
85
|
+
"invalid-name": "plugins.errors.invalid-name",
|
|
86
|
+
"protected": "plugins.errors.protected",
|
|
87
|
+
"not-installed": "plugins.errors.not-installed",
|
|
88
|
+
"not-a-bundle": "plugins.errors.not-a-bundle",
|
|
89
|
+
"invalid-spec": "plugins.errors.invalid-spec",
|
|
90
|
+
"registry-unreadable": "plugins.errors.registry-unreadable",
|
|
91
|
+
"registry-invalid": "plugins.errors.registry-invalid",
|
|
92
|
+
"already-installed": "plugins.errors.already-installed",
|
|
93
|
+
"not-removable": "plugins.errors.not-removable",
|
|
94
|
+
"not-in-dependencies": "plugins.errors.not-in-dependencies",
|
|
95
|
+
"invalid-version": "plugins.errors.invalid-version",
|
|
96
|
+
"check-failed": "plugins.errors.check-failed",
|
|
97
|
+
"disposed": "plugins.errors.disposed",
|
|
98
|
+
"busy": "plugins.errors.busy",
|
|
99
|
+
"job-missing": "plugins.errors.job-missing",
|
|
100
|
+
"spawn-failed": "plugins.errors.spawn-failed",
|
|
101
|
+
"command-failed": "plugins.errors.command-failed",
|
|
102
|
+
"request-failed": "plugins.errors.request-failed",
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
function failureText(t: Translate, failure: UiFailure): string {
|
|
106
|
+
const base = t(FAILURE_KEYS[failure.code]);
|
|
107
|
+
if (
|
|
108
|
+
failure.detail !== undefined
|
|
109
|
+
&& (failure.code === "command-failed"
|
|
110
|
+
|| failure.code === "check-failed"
|
|
111
|
+
|| failure.code === "invalid-platform"
|
|
112
|
+
|| failure.code === "request-failed")
|
|
113
|
+
) {
|
|
114
|
+
return `${base}\n${failure.detail}`;
|
|
115
|
+
}
|
|
116
|
+
return base;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function tailLines(text: string, count: number): string {
|
|
120
|
+
const lines = text.replace(/\r\n/g, "\n").split("\n");
|
|
121
|
+
while (lines.length > 0 && lines[lines.length - 1].trim() === "") lines.pop();
|
|
122
|
+
return lines.slice(-count).join("\n");
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function jobTitle(job: JobStatus, t: Translate): string {
|
|
126
|
+
const action = job.kind === "install"
|
|
127
|
+
? t("plugins.job.installAction")
|
|
128
|
+
: job.kind === "remove"
|
|
129
|
+
? t("plugins.job.removeAction")
|
|
130
|
+
: job.kind === "update"
|
|
131
|
+
? t("plugins.job.updateAction")
|
|
132
|
+
: t("plugins.job.checkAction");
|
|
133
|
+
if (job.state === "running") return t("plugins.job.running", { action });
|
|
134
|
+
if (job.state === "failed") return t("plugins.job.failed", { action });
|
|
135
|
+
return t("plugins.job.succeeded", { action });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function createStyles(colors: ThemeColors, compact: boolean) {
|
|
139
|
+
return {
|
|
140
|
+
content: {
|
|
141
|
+
padding: compact ? 16 : 24,
|
|
142
|
+
paddingBottom: 40,
|
|
143
|
+
gap: 16,
|
|
144
|
+
width: "100%" as const,
|
|
145
|
+
maxWidth: 880,
|
|
146
|
+
alignSelf: "center" as const,
|
|
147
|
+
},
|
|
148
|
+
header: {
|
|
149
|
+
flexDirection: "row" as const,
|
|
150
|
+
alignItems: "flex-start" as const,
|
|
151
|
+
gap: 12,
|
|
152
|
+
flexWrap: "wrap" as const,
|
|
153
|
+
},
|
|
154
|
+
headerText: { flex: 1, minWidth: 180, gap: 4 },
|
|
155
|
+
muted: { color: colors.foregroundMuted, fontSize: 13, lineHeight: 19 },
|
|
156
|
+
path: { color: colors.foregroundMuted, fontSize: 12 },
|
|
157
|
+
notice: { color: colors.foregroundMuted, fontSize: 12, lineHeight: 18 },
|
|
158
|
+
headerActions: {
|
|
159
|
+
flexDirection: "row" as const,
|
|
160
|
+
alignItems: "center" as const,
|
|
161
|
+
gap: 8,
|
|
162
|
+
flexWrap: "wrap" as const,
|
|
163
|
+
},
|
|
164
|
+
section: { gap: 10 },
|
|
165
|
+
groupTitle: {
|
|
166
|
+
color: colors.foreground,
|
|
167
|
+
fontSize: 15,
|
|
168
|
+
fontWeight: "600" as const,
|
|
169
|
+
},
|
|
170
|
+
card: {
|
|
171
|
+
backgroundColor: colors.surface1,
|
|
172
|
+
borderColor: colors.border,
|
|
173
|
+
borderWidth: 1,
|
|
174
|
+
borderRadius: 12,
|
|
175
|
+
padding: compact ? 12 : 14,
|
|
176
|
+
gap: 8,
|
|
177
|
+
},
|
|
178
|
+
rowTop: {
|
|
179
|
+
flexDirection: "row" as const,
|
|
180
|
+
alignItems: "center" as const,
|
|
181
|
+
gap: 8,
|
|
182
|
+
flexWrap: "wrap" as const,
|
|
183
|
+
},
|
|
184
|
+
name: { color: colors.foreground, fontSize: 14, fontWeight: "600" as const },
|
|
185
|
+
version: { color: colors.foregroundMuted, fontSize: 12 },
|
|
186
|
+
description: { color: colors.foregroundMuted, fontSize: 13, lineHeight: 19 },
|
|
187
|
+
badgeRow: {
|
|
188
|
+
flexDirection: "row" as const,
|
|
189
|
+
gap: 6,
|
|
190
|
+
flexWrap: "wrap" as const,
|
|
191
|
+
},
|
|
192
|
+
badge: {
|
|
193
|
+
backgroundColor: colors.surface2,
|
|
194
|
+
borderRadius: 6,
|
|
195
|
+
paddingHorizontal: 7,
|
|
196
|
+
paddingVertical: 2,
|
|
197
|
+
},
|
|
198
|
+
badgeText: { color: colors.foregroundMuted, fontSize: 11 },
|
|
199
|
+
badgeWarn: {
|
|
200
|
+
backgroundColor: colors.surface2,
|
|
201
|
+
borderColor: colors.statusWarning,
|
|
202
|
+
borderWidth: 1,
|
|
203
|
+
borderRadius: 6,
|
|
204
|
+
paddingHorizontal: 7,
|
|
205
|
+
paddingVertical: 2,
|
|
206
|
+
},
|
|
207
|
+
badgeWarnText: { color: colors.statusWarning, fontSize: 11 },
|
|
208
|
+
badgeDanger: {
|
|
209
|
+
backgroundColor: colors.surface2,
|
|
210
|
+
borderColor: colors.statusDanger,
|
|
211
|
+
borderWidth: 1,
|
|
212
|
+
borderRadius: 6,
|
|
213
|
+
paddingHorizontal: 7,
|
|
214
|
+
paddingVertical: 2,
|
|
215
|
+
},
|
|
216
|
+
badgeDangerText: { color: colors.statusDanger, fontSize: 11 },
|
|
217
|
+
badgeSuccess: {
|
|
218
|
+
backgroundColor: colors.surface2,
|
|
219
|
+
borderColor: colors.statusSuccess,
|
|
220
|
+
borderWidth: 1,
|
|
221
|
+
borderRadius: 6,
|
|
222
|
+
paddingHorizontal: 7,
|
|
223
|
+
paddingVertical: 2,
|
|
224
|
+
},
|
|
225
|
+
badgeSuccessText: { color: colors.statusSuccess, fontSize: 11 },
|
|
226
|
+
rowActions: {
|
|
227
|
+
flexDirection: "row" as const,
|
|
228
|
+
alignItems: "center" as const,
|
|
229
|
+
gap: 8,
|
|
230
|
+
flexWrap: "wrap" as const,
|
|
231
|
+
},
|
|
232
|
+
button: {
|
|
233
|
+
borderColor: colors.border,
|
|
234
|
+
borderWidth: 1,
|
|
235
|
+
borderRadius: 8,
|
|
236
|
+
paddingHorizontal: 10,
|
|
237
|
+
paddingVertical: 6,
|
|
238
|
+
backgroundColor: colors.surface2,
|
|
239
|
+
},
|
|
240
|
+
buttonPrimary: { backgroundColor: colors.accent, borderColor: colors.accent },
|
|
241
|
+
buttonDisabled: { opacity: 0.45 },
|
|
242
|
+
buttonText: { color: colors.foreground, fontSize: 12, fontWeight: "500" as const },
|
|
243
|
+
buttonPrimaryText: {
|
|
244
|
+
color: colors.accentForeground,
|
|
245
|
+
fontSize: 12,
|
|
246
|
+
fontWeight: "600" as const,
|
|
247
|
+
},
|
|
248
|
+
input: {
|
|
249
|
+
color: colors.foreground,
|
|
250
|
+
backgroundColor: colors.surface2,
|
|
251
|
+
borderColor: colors.border,
|
|
252
|
+
borderWidth: 1,
|
|
253
|
+
borderRadius: 8,
|
|
254
|
+
paddingHorizontal: 12,
|
|
255
|
+
paddingVertical: 10,
|
|
256
|
+
fontSize: 14,
|
|
257
|
+
},
|
|
258
|
+
statusCard: {
|
|
259
|
+
backgroundColor: colors.surface1,
|
|
260
|
+
borderColor: colors.border,
|
|
261
|
+
borderWidth: 1,
|
|
262
|
+
borderRadius: 12,
|
|
263
|
+
padding: 12,
|
|
264
|
+
gap: 8,
|
|
265
|
+
},
|
|
266
|
+
errorCard: {
|
|
267
|
+
backgroundColor: colors.surface1,
|
|
268
|
+
borderColor: colors.statusDanger,
|
|
269
|
+
borderWidth: 1,
|
|
270
|
+
borderRadius: 12,
|
|
271
|
+
padding: 12,
|
|
272
|
+
gap: 8,
|
|
273
|
+
},
|
|
274
|
+
errorText: { color: colors.statusDanger, fontSize: 13, lineHeight: 19 },
|
|
275
|
+
output: { color: colors.foregroundMuted, fontSize: 11, lineHeight: 16 },
|
|
276
|
+
rowTags: {
|
|
277
|
+
flexDirection: "row" as const,
|
|
278
|
+
gap: 6,
|
|
279
|
+
flexWrap: "wrap" as const,
|
|
280
|
+
},
|
|
281
|
+
tag: {
|
|
282
|
+
backgroundColor: colors.surface2,
|
|
283
|
+
borderRadius: 4,
|
|
284
|
+
paddingHorizontal: 6,
|
|
285
|
+
paddingVertical: 2,
|
|
286
|
+
},
|
|
287
|
+
tagText: { color: colors.foregroundMuted, fontSize: 10 },
|
|
288
|
+
infoBox: {
|
|
289
|
+
backgroundColor: colors.surface2,
|
|
290
|
+
borderRadius: 8,
|
|
291
|
+
padding: 10,
|
|
292
|
+
gap: 6,
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function ActionButton({
|
|
298
|
+
label,
|
|
299
|
+
onPress,
|
|
300
|
+
disabled,
|
|
301
|
+
primary,
|
|
302
|
+
styles,
|
|
303
|
+
}: {
|
|
304
|
+
label: string;
|
|
305
|
+
onPress: () => void;
|
|
306
|
+
disabled?: boolean;
|
|
307
|
+
primary?: boolean;
|
|
308
|
+
styles: Styles;
|
|
309
|
+
}) {
|
|
310
|
+
return (
|
|
311
|
+
<Pressable
|
|
312
|
+
accessibilityRole="button"
|
|
313
|
+
accessibilityLabel={label}
|
|
314
|
+
disabled={disabled}
|
|
315
|
+
onPress={onPress}
|
|
316
|
+
style={[
|
|
317
|
+
styles.button,
|
|
318
|
+
primary === true ? styles.buttonPrimary : null,
|
|
319
|
+
disabled === true ? styles.buttonDisabled : null,
|
|
320
|
+
]}
|
|
321
|
+
>
|
|
322
|
+
<Text style={[styles.buttonText, primary === true ? styles.buttonPrimaryText : null]}>
|
|
323
|
+
{label}
|
|
324
|
+
</Text>
|
|
325
|
+
</Pressable>
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function Badge({
|
|
330
|
+
label,
|
|
331
|
+
tone = "muted",
|
|
332
|
+
styles,
|
|
333
|
+
}: {
|
|
334
|
+
label: string;
|
|
335
|
+
tone?: "muted" | "warn" | "danger" | "success";
|
|
336
|
+
styles: Styles;
|
|
337
|
+
}) {
|
|
338
|
+
const badgeStyle = tone === "warn"
|
|
339
|
+
? styles.badgeWarn
|
|
340
|
+
: tone === "danger"
|
|
341
|
+
? styles.badgeDanger
|
|
342
|
+
: tone === "success"
|
|
343
|
+
? styles.badgeSuccess
|
|
344
|
+
: styles.badge;
|
|
345
|
+
const textStyle = tone === "warn"
|
|
346
|
+
? styles.badgeWarnText
|
|
347
|
+
: tone === "danger"
|
|
348
|
+
? styles.badgeDangerText
|
|
349
|
+
: tone === "success"
|
|
350
|
+
? styles.badgeSuccessText
|
|
351
|
+
: styles.badgeText;
|
|
352
|
+
return (
|
|
353
|
+
<View style={badgeStyle}>
|
|
354
|
+
<Text style={textStyle}>{label}</Text>
|
|
355
|
+
</View>
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function BundleRow({
|
|
360
|
+
bundle,
|
|
361
|
+
t,
|
|
362
|
+
styles,
|
|
363
|
+
busy,
|
|
364
|
+
toggleBusy,
|
|
365
|
+
confirmRemove,
|
|
366
|
+
confirmUpdate,
|
|
367
|
+
onToggle,
|
|
368
|
+
onRemove,
|
|
369
|
+
onUpdate,
|
|
370
|
+
}: {
|
|
371
|
+
bundle: BundleInfo;
|
|
372
|
+
t: Translate;
|
|
373
|
+
styles: Styles;
|
|
374
|
+
busy: boolean;
|
|
375
|
+
toggleBusy: string | null;
|
|
376
|
+
confirmRemove: string | null;
|
|
377
|
+
confirmUpdate: { name: string; version: string } | null;
|
|
378
|
+
onToggle: (bundle: BundleInfo) => void;
|
|
379
|
+
onRemove: (name: string) => void;
|
|
380
|
+
onUpdate: (name: string, version: string) => void;
|
|
381
|
+
}) {
|
|
382
|
+
const isDependency = bundle.kind === "dependency";
|
|
383
|
+
const canToggle = bundle.kind !== "dependency" && !bundle.protected;
|
|
384
|
+
const removePending = confirmRemove === bundle.name;
|
|
385
|
+
const updatePending = confirmUpdate?.name === bundle.name;
|
|
386
|
+
const rowBusy = busy || toggleBusy === bundle.name;
|
|
387
|
+
|
|
388
|
+
return (
|
|
389
|
+
<View style={styles.card}>
|
|
390
|
+
<View style={styles.rowTop}>
|
|
391
|
+
<Text style={styles.name}>{bundle.name}</Text>
|
|
392
|
+
{bundle.version === undefined ? null : <Text style={styles.version}>{bundle.version}</Text>}
|
|
393
|
+
{bundle.official ? <Badge label={t("plugins.badges.official")} styles={styles} /> : null}
|
|
394
|
+
{bundle.protected ? <Badge label={t("plugins.badges.protected")} styles={styles} /> : null}
|
|
395
|
+
{bundle.client ? <Badge label={t("plugins.badges.client")} tone="warn" styles={styles} /> : null}
|
|
396
|
+
{bundle.platformSupported ? null : <Badge label={t("plugins.badges.platformUnsupported")} tone="danger" styles={styles} />}
|
|
397
|
+
{bundle.installed ? null : <Badge label={t("plugins.badges.missing")} tone="danger" styles={styles} />}
|
|
398
|
+
{bundle.update === undefined
|
|
399
|
+
? null
|
|
400
|
+
: <Badge label={t("plugins.badges.updateAvailable", { version: bundle.update })} tone="warn" styles={styles} />}
|
|
401
|
+
</View>
|
|
402
|
+
|
|
403
|
+
{bundle.description === undefined || bundle.description === ""
|
|
404
|
+
? null
|
|
405
|
+
: <Text style={styles.description}>{bundle.description}</Text>}
|
|
406
|
+
|
|
407
|
+
{isDependency
|
|
408
|
+
? <Text style={styles.muted}>{t("plugins.bundle.dependencyNote")}</Text>
|
|
409
|
+
: null}
|
|
410
|
+
{bundle.client
|
|
411
|
+
? <Text style={styles.muted}>{t("plugins.bundle.clientNote")}</Text>
|
|
412
|
+
: null}
|
|
413
|
+
{bundle.platformSupported
|
|
414
|
+
? null
|
|
415
|
+
: bundle.platformReason === undefined || bundle.platformReason === ""
|
|
416
|
+
? <Text style={styles.muted}>{t("plugins.bundle.platformsUnknown")}</Text>
|
|
417
|
+
: <Text style={styles.muted}>{t("plugins.bundle.platforms", { platforms: bundle.platformReason })}</Text>}
|
|
418
|
+
|
|
419
|
+
{bundle.rows.length === 0 ? null : (
|
|
420
|
+
<View style={styles.rowTags}>
|
|
421
|
+
{bundle.rows.map((row) => (
|
|
422
|
+
<View key={row.id} style={styles.tag}>
|
|
423
|
+
<Text style={styles.tagText}>{row.id}</Text>
|
|
424
|
+
</View>
|
|
425
|
+
))}
|
|
426
|
+
</View>
|
|
427
|
+
)}
|
|
428
|
+
|
|
429
|
+
<View style={styles.rowActions}>
|
|
430
|
+
{canToggle ? (
|
|
431
|
+
<Switch
|
|
432
|
+
value={bundle.enabled}
|
|
433
|
+
disabled={rowBusy || (!bundle.enabled && (bundle.installed === false || !bundle.platformSupported))}
|
|
434
|
+
onValueChange={() => onToggle(bundle)}
|
|
435
|
+
trackColor={{ false: styles.button.backgroundColor, true: styles.buttonPrimary.backgroundColor }}
|
|
436
|
+
thumbColor={styles.name.color}
|
|
437
|
+
/>
|
|
438
|
+
) : null}
|
|
439
|
+
|
|
440
|
+
{bundle.removable ? (
|
|
441
|
+
removePending ? (
|
|
442
|
+
<>
|
|
443
|
+
<ActionButton
|
|
444
|
+
label={t("plugins.bundle.confirmRemove")}
|
|
445
|
+
disabled={rowBusy}
|
|
446
|
+
onPress={() => onRemove(bundle.name)}
|
|
447
|
+
styles={styles}
|
|
448
|
+
/>
|
|
449
|
+
<ActionButton label={t("plugins.bundle.cancel")} disabled={rowBusy} onPress={() => onRemove("")} styles={styles} />
|
|
450
|
+
</>
|
|
451
|
+
) : (
|
|
452
|
+
<ActionButton
|
|
453
|
+
label={t("plugins.bundle.remove")}
|
|
454
|
+
disabled={rowBusy}
|
|
455
|
+
onPress={() => onRemove(bundle.name)}
|
|
456
|
+
styles={styles}
|
|
457
|
+
/>
|
|
458
|
+
)
|
|
459
|
+
) : null}
|
|
460
|
+
|
|
461
|
+
{bundle.update === undefined ? null : updatePending ? (
|
|
462
|
+
<>
|
|
463
|
+
<ActionButton
|
|
464
|
+
label={t("plugins.bundle.confirmUpdate", { version: bundle.update })}
|
|
465
|
+
disabled={rowBusy}
|
|
466
|
+
primary
|
|
467
|
+
onPress={() => onUpdate(bundle.name, bundle.update as string)}
|
|
468
|
+
styles={styles}
|
|
469
|
+
/>
|
|
470
|
+
<ActionButton label={t("plugins.bundle.cancel")} disabled={rowBusy} onPress={() => onUpdate("", "")} styles={styles} />
|
|
471
|
+
</>
|
|
472
|
+
) : (
|
|
473
|
+
<ActionButton
|
|
474
|
+
label={t("plugins.bundle.update", { version: bundle.update })}
|
|
475
|
+
disabled={rowBusy}
|
|
476
|
+
onPress={() => onUpdate(bundle.name, bundle.update as string)}
|
|
477
|
+
styles={styles}
|
|
478
|
+
/>
|
|
479
|
+
)}
|
|
480
|
+
</View>
|
|
481
|
+
</View>
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function DshPluginsPageBody({ theme, host, layout }: PluginSurfaceProps) {
|
|
486
|
+
const compact = layout.compact || layout.platform === "ios" || layout.platform === "android";
|
|
487
|
+
const { t } = useTranslation();
|
|
488
|
+
const translate = t as unknown as Translate;
|
|
489
|
+
const styles = useMemo(() => createStyles(theme.colors, compact), [theme.colors, compact]);
|
|
490
|
+
|
|
491
|
+
const list = useRpc(listRpc);
|
|
492
|
+
const setEnabled = useRpc(setEnabledRpc);
|
|
493
|
+
const inspectSpec = useRpc(inspectSpecRpc);
|
|
494
|
+
const startJob = useRpc(startJobRpc);
|
|
495
|
+
const jobStatus = useRpc(jobStatusRpc);
|
|
496
|
+
|
|
497
|
+
const [snapshot, setSnapshot] = useState<PluginsSnapshot | null>(null);
|
|
498
|
+
const [loadError, setLoadError] = useState<UiFailure | null>(null);
|
|
499
|
+
const [refreshing, setRefreshing] = useState(false);
|
|
500
|
+
const [job, setJob] = useState<JobStatus | null>(null);
|
|
501
|
+
const [actionError, setActionError] = useState<UiFailure | null>(null);
|
|
502
|
+
const [spec, setSpec] = useState("");
|
|
503
|
+
const [inspection, setInspection] = useState<InspectSpecOutput | null>(null);
|
|
504
|
+
const [inspecting, setInspecting] = useState(false);
|
|
505
|
+
const [toggleBusy, setToggleBusy] = useState<string | null>(null);
|
|
506
|
+
const [confirmRemove, setConfirmRemove] = useState<string | null>(null);
|
|
507
|
+
const [confirmUpdate, setConfirmUpdate] = useState<{ name: string; version: string } | null>(null);
|
|
508
|
+
|
|
509
|
+
const refresh = useCallback(async (): Promise<void> => {
|
|
510
|
+
setRefreshing(true);
|
|
511
|
+
try {
|
|
512
|
+
const next = await list({});
|
|
513
|
+
setSnapshot(next);
|
|
514
|
+
setLoadError(next.errorCode === undefined
|
|
515
|
+
? null
|
|
516
|
+
: {
|
|
517
|
+
code: next.errorCode,
|
|
518
|
+
...(next.errorDetail === undefined ? {} : { detail: next.errorDetail }),
|
|
519
|
+
});
|
|
520
|
+
setJob((current) => {
|
|
521
|
+
if (next.activeJobId === undefined) return current;
|
|
522
|
+
if (current !== null && current.id === next.activeJobId) return current;
|
|
523
|
+
return {
|
|
524
|
+
id: next.activeJobId,
|
|
525
|
+
kind: next.activeJobKind ?? "install",
|
|
526
|
+
state: "running",
|
|
527
|
+
output: "",
|
|
528
|
+
startedAt: Date.now(),
|
|
529
|
+
};
|
|
530
|
+
});
|
|
531
|
+
} catch (error) {
|
|
532
|
+
setLoadError(failureOf(error));
|
|
533
|
+
} finally {
|
|
534
|
+
setRefreshing(false);
|
|
535
|
+
}
|
|
536
|
+
}, [list]);
|
|
537
|
+
|
|
538
|
+
useEffect(() => {
|
|
539
|
+
void refresh();
|
|
540
|
+
}, [refresh]);
|
|
541
|
+
|
|
542
|
+
useEffect(() => {
|
|
543
|
+
if (job === null || job.state !== "running") return;
|
|
544
|
+
let cancelled = false;
|
|
545
|
+
let timer: ReturnType<typeof setInterval> | undefined;
|
|
546
|
+
|
|
547
|
+
const tick = async () => {
|
|
548
|
+
try {
|
|
549
|
+
const next = await jobStatus({ id: job.id });
|
|
550
|
+
if (cancelled) return;
|
|
551
|
+
setJob(next);
|
|
552
|
+
if (next.state !== "running") await refresh();
|
|
553
|
+
} catch (error) {
|
|
554
|
+
if (cancelled) return;
|
|
555
|
+
const failure = failureOf(error);
|
|
556
|
+
setActionError(failure);
|
|
557
|
+
setJob((current) => current === null
|
|
558
|
+
? current
|
|
559
|
+
: {
|
|
560
|
+
...current,
|
|
561
|
+
state: "failed",
|
|
562
|
+
errorCode: failure.code,
|
|
563
|
+
errorDetail: failure.detail,
|
|
564
|
+
finishedAt: Date.now(),
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
void tick();
|
|
570
|
+
timer = setInterval(() => {
|
|
571
|
+
void tick();
|
|
572
|
+
}, 1000);
|
|
573
|
+
|
|
574
|
+
return () => {
|
|
575
|
+
cancelled = true;
|
|
576
|
+
if (timer !== undefined) clearInterval(timer);
|
|
577
|
+
};
|
|
578
|
+
}, [job?.id, job?.state, jobStatus, refresh]);
|
|
579
|
+
|
|
580
|
+
useEffect(() => {
|
|
581
|
+
if (job?.state === "succeeded" && job.kind === "install") {
|
|
582
|
+
setSpec("");
|
|
583
|
+
setInspection(null);
|
|
584
|
+
}
|
|
585
|
+
}, [job?.kind, job?.state]);
|
|
586
|
+
|
|
587
|
+
const busy = job?.state === "running" || snapshot?.busy === true;
|
|
588
|
+
|
|
589
|
+
const beginJob = useCallback(async (input: StartJobInput): Promise<boolean> => {
|
|
590
|
+
setActionError(null);
|
|
591
|
+
try {
|
|
592
|
+
const started = await startJob(input);
|
|
593
|
+
if (!started.ok || started.id === undefined) {
|
|
594
|
+
setActionError({
|
|
595
|
+
code: started.errorCode ?? "command-failed",
|
|
596
|
+
...(started.errorDetail === undefined ? {} : { detail: started.errorDetail }),
|
|
597
|
+
});
|
|
598
|
+
return false;
|
|
599
|
+
}
|
|
600
|
+
setJob({
|
|
601
|
+
id: started.id,
|
|
602
|
+
kind: input.kind,
|
|
603
|
+
state: "running",
|
|
604
|
+
output: "",
|
|
605
|
+
startedAt: Date.now(),
|
|
606
|
+
});
|
|
607
|
+
setSnapshot((current) => current === null
|
|
608
|
+
? current
|
|
609
|
+
: {
|
|
610
|
+
...current,
|
|
611
|
+
busy: true,
|
|
612
|
+
activeJobId: started.id,
|
|
613
|
+
activeJobKind: input.kind,
|
|
614
|
+
});
|
|
615
|
+
return true;
|
|
616
|
+
} catch (error) {
|
|
617
|
+
setActionError(failureOf(error));
|
|
618
|
+
return false;
|
|
619
|
+
}
|
|
620
|
+
}, [startJob]);
|
|
621
|
+
|
|
622
|
+
const inspect = async (): Promise<void> => {
|
|
623
|
+
const value = spec.trim();
|
|
624
|
+
if (value === "") return;
|
|
625
|
+
setInspecting(true);
|
|
626
|
+
setActionError(null);
|
|
627
|
+
setInspection(null);
|
|
628
|
+
try {
|
|
629
|
+
setInspection(await inspectSpec({ spec: value }));
|
|
630
|
+
} catch (error) {
|
|
631
|
+
setActionError(failureOf(error));
|
|
632
|
+
} finally {
|
|
633
|
+
setInspecting(false);
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
|
|
637
|
+
const install = async (): Promise<void> => {
|
|
638
|
+
if (inspection === null || !inspection.ok) return;
|
|
639
|
+
const started = await beginJob({ kind: "install", spec: spec.trim() });
|
|
640
|
+
if (started) setInspection(null);
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
const toggle = async (bundle: BundleInfo): Promise<void> => {
|
|
644
|
+
setToggleBusy(bundle.name);
|
|
645
|
+
setActionError(null);
|
|
646
|
+
try {
|
|
647
|
+
const result = await setEnabled({ name: bundle.name, enabled: !bundle.enabled });
|
|
648
|
+
if (!result.ok) {
|
|
649
|
+
setActionError({
|
|
650
|
+
code: result.errorCode ?? "command-failed",
|
|
651
|
+
...(result.errorDetail === undefined ? {} : { detail: result.errorDetail }),
|
|
652
|
+
});
|
|
653
|
+
return;
|
|
654
|
+
}
|
|
655
|
+
await refresh();
|
|
656
|
+
} catch (error) {
|
|
657
|
+
setActionError(failureOf(error));
|
|
658
|
+
} finally {
|
|
659
|
+
setToggleBusy(null);
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
const remove = async (name: string): Promise<void> => {
|
|
664
|
+
if (name === "") {
|
|
665
|
+
setConfirmRemove(null);
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
if (confirmRemove !== name) {
|
|
669
|
+
setConfirmRemove(name);
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
setConfirmRemove(null);
|
|
673
|
+
await beginJob({ kind: "remove", name });
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
const update = async (name: string, version: string): Promise<void> => {
|
|
677
|
+
if (name === "" || version === "") {
|
|
678
|
+
setConfirmUpdate(null);
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (confirmUpdate?.name !== name || confirmUpdate.version !== version) {
|
|
682
|
+
setConfirmUpdate({ name, version });
|
|
683
|
+
return;
|
|
684
|
+
}
|
|
685
|
+
setConfirmUpdate(null);
|
|
686
|
+
await beginJob({ kind: "update", name, version });
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
const bundles = snapshot?.bundles ?? [];
|
|
690
|
+
const groups = ([
|
|
691
|
+
{ title: "plugins.groups.enabled", items: bundles.filter((bundle) => bundle.enabled && bundle.kind !== "dependency") },
|
|
692
|
+
{ title: "plugins.groups.disabled", items: bundles.filter((bundle) => !bundle.enabled && bundle.kind !== "dependency") },
|
|
693
|
+
{ title: "plugins.groups.dependencies", items: bundles.filter((bundle) => bundle.kind === "dependency") },
|
|
694
|
+
] as Array<{
|
|
695
|
+
title: "plugins.groups.enabled" | "plugins.groups.disabled" | "plugins.groups.dependencies";
|
|
696
|
+
items: BundleInfo[];
|
|
697
|
+
}>).filter((group) => group.items.length > 0);
|
|
698
|
+
|
|
699
|
+
return (
|
|
700
|
+
<ScrollView
|
|
701
|
+
style={{ flex: 1, backgroundColor: theme.colors.surface0 }}
|
|
702
|
+
contentContainerStyle={styles.content}
|
|
703
|
+
>
|
|
704
|
+
<View style={styles.header}>
|
|
705
|
+
<View style={styles.headerText}>
|
|
706
|
+
<Text style={styles.muted}>
|
|
707
|
+
{snapshot === null
|
|
708
|
+
? host.label
|
|
709
|
+
: t("plugins.header.profile", { profile: snapshot.profile, host: host.label })}
|
|
710
|
+
</Text>
|
|
711
|
+
{snapshot === null ? null : <Text style={styles.path}>{snapshot.displayDir}</Text>}
|
|
712
|
+
<Text style={styles.notice}>{t("plugins.header.notice")}</Text>
|
|
713
|
+
</View>
|
|
714
|
+
<View style={styles.headerActions}>
|
|
715
|
+
<ActionButton
|
|
716
|
+
label={refreshing ? t("plugins.header.refreshing") : t("plugins.header.refresh")}
|
|
717
|
+
disabled={refreshing}
|
|
718
|
+
onPress={() => {
|
|
719
|
+
void refresh();
|
|
720
|
+
}}
|
|
721
|
+
styles={styles}
|
|
722
|
+
/>
|
|
723
|
+
<ActionButton
|
|
724
|
+
label={job?.kind === "check" && job.state === "running"
|
|
725
|
+
? t("plugins.header.checkingUpdates")
|
|
726
|
+
: t("plugins.header.checkUpdates")}
|
|
727
|
+
disabled={busy}
|
|
728
|
+
onPress={() => {
|
|
729
|
+
void beginJob({ kind: "check" });
|
|
730
|
+
}}
|
|
731
|
+
styles={styles}
|
|
732
|
+
/>
|
|
733
|
+
</View>
|
|
734
|
+
</View>
|
|
735
|
+
|
|
736
|
+
{loadError === null ? null : (
|
|
737
|
+
<View style={styles.errorCard}>
|
|
738
|
+
<Text style={styles.errorText}>{failureText(translate, loadError)}</Text>
|
|
739
|
+
<ActionButton
|
|
740
|
+
label={t("plugins.header.retry")}
|
|
741
|
+
onPress={() => {
|
|
742
|
+
void refresh();
|
|
743
|
+
}}
|
|
744
|
+
styles={styles}
|
|
745
|
+
/>
|
|
746
|
+
</View>
|
|
747
|
+
)}
|
|
748
|
+
|
|
749
|
+
{actionError === null ? null : (
|
|
750
|
+
<View style={styles.errorCard}>
|
|
751
|
+
<Text style={styles.errorText}>{failureText(translate, actionError)}</Text>
|
|
752
|
+
</View>
|
|
753
|
+
)}
|
|
754
|
+
|
|
755
|
+
{job === null ? null : (
|
|
756
|
+
<View style={styles.statusCard}>
|
|
757
|
+
<View style={styles.rowTop}>
|
|
758
|
+
{job.state === "running" ? (
|
|
759
|
+
<ActivityIndicator size="small" color={theme.colors.accent} />
|
|
760
|
+
) : null}
|
|
761
|
+
<Text style={styles.name}>{jobTitle(job, translate)}</Text>
|
|
762
|
+
{job.state === "failed" ? <Badge label={t("plugins.job.failedBadge")} tone="danger" styles={styles} /> : null}
|
|
763
|
+
{job.state === "succeeded" ? <Badge label={t("plugins.job.doneBadge")} tone="success" styles={styles} /> : null}
|
|
764
|
+
</View>
|
|
765
|
+
{job.errorCode === undefined
|
|
766
|
+
? null
|
|
767
|
+
: (
|
|
768
|
+
<Text style={styles.errorText}>
|
|
769
|
+
{failureText(translate, {
|
|
770
|
+
code: job.errorCode,
|
|
771
|
+
...(job.errorDetail === undefined ? {} : { detail: job.errorDetail }),
|
|
772
|
+
})}
|
|
773
|
+
</Text>
|
|
774
|
+
)}
|
|
775
|
+
{job.kind === "check" && job.updates !== undefined && Object.keys(job.updates).length > 0 ? (
|
|
776
|
+
<Text style={styles.muted}>
|
|
777
|
+
{t("plugins.job.updatesFound", { count: Object.keys(job.updates).length })}
|
|
778
|
+
</Text>
|
|
779
|
+
) : null}
|
|
780
|
+
{job.output === "" ? null : (
|
|
781
|
+
<Text style={styles.output}>{tailLines(job.output, 12)}</Text>
|
|
782
|
+
)}
|
|
783
|
+
</View>
|
|
784
|
+
)}
|
|
785
|
+
|
|
786
|
+
<View style={styles.card}>
|
|
787
|
+
<Text style={styles.groupTitle}>{t("plugins.install.title")}</Text>
|
|
788
|
+
<Text style={styles.muted}>{t("plugins.install.hint")}</Text>
|
|
789
|
+
<TextInput
|
|
790
|
+
value={spec}
|
|
791
|
+
onChangeText={(value: string) => {
|
|
792
|
+
setSpec(value);
|
|
793
|
+
setInspection(null);
|
|
794
|
+
}}
|
|
795
|
+
placeholder={t("plugins.install.placeholder")}
|
|
796
|
+
placeholderTextColor={theme.colors.foregroundMuted}
|
|
797
|
+
editable={!busy && !inspecting && !(inspection?.ok === true)}
|
|
798
|
+
autoCapitalize="none"
|
|
799
|
+
autoCorrect={false}
|
|
800
|
+
style={styles.input}
|
|
801
|
+
/>
|
|
802
|
+
<View style={styles.rowActions}>
|
|
803
|
+
<ActionButton
|
|
804
|
+
label={inspecting ? t("plugins.install.checking") : t("plugins.install.check")}
|
|
805
|
+
disabled={busy || inspecting || spec.trim() === ""}
|
|
806
|
+
onPress={() => {
|
|
807
|
+
void inspect();
|
|
808
|
+
}}
|
|
809
|
+
styles={styles}
|
|
810
|
+
/>
|
|
811
|
+
{inspection === null ? null : (
|
|
812
|
+
<ActionButton
|
|
813
|
+
label={t("plugins.bundle.cancel")}
|
|
814
|
+
disabled={busy || inspecting}
|
|
815
|
+
onPress={() => {
|
|
816
|
+
setInspection(null);
|
|
817
|
+
}}
|
|
818
|
+
styles={styles}
|
|
819
|
+
/>
|
|
820
|
+
)}
|
|
821
|
+
</View>
|
|
822
|
+
|
|
823
|
+
{inspection === null ? null : inspection.ok ? (
|
|
824
|
+
<View style={styles.infoBox}>
|
|
825
|
+
<Text style={styles.name}>
|
|
826
|
+
{inspection.name ?? t("plugins.install.unknown")}
|
|
827
|
+
{inspection.version === undefined ? "" : ` ${inspection.version}`}
|
|
828
|
+
</Text>
|
|
829
|
+
{inspection.description === undefined || inspection.description === ""
|
|
830
|
+
? null
|
|
831
|
+
: <Text style={styles.description}>{inspection.description}</Text>}
|
|
832
|
+
{inspection.client
|
|
833
|
+
? <Text style={styles.muted}>{t("plugins.bundle.clientNote")}</Text>
|
|
834
|
+
: null}
|
|
835
|
+
<Text style={styles.muted}>{t("plugins.install.trust")}</Text>
|
|
836
|
+
<View style={styles.rowActions}>
|
|
837
|
+
<ActionButton
|
|
838
|
+
label={t("plugins.install.confirm")}
|
|
839
|
+
primary
|
|
840
|
+
disabled={busy}
|
|
841
|
+
onPress={() => {
|
|
842
|
+
void install();
|
|
843
|
+
}}
|
|
844
|
+
styles={styles}
|
|
845
|
+
/>
|
|
846
|
+
<ActionButton
|
|
847
|
+
label={t("plugins.bundle.cancel")}
|
|
848
|
+
disabled={busy}
|
|
849
|
+
onPress={() => {
|
|
850
|
+
setInspection(null);
|
|
851
|
+
}}
|
|
852
|
+
styles={styles}
|
|
853
|
+
/>
|
|
854
|
+
</View>
|
|
855
|
+
</View>
|
|
856
|
+
) : (
|
|
857
|
+
<View style={styles.infoBox}>
|
|
858
|
+
<Text style={styles.errorText}>
|
|
859
|
+
{inspection.errorCode === "not-a-bundle"
|
|
860
|
+
? t("plugins.install.notBundle")
|
|
861
|
+
: failureText(translate, {
|
|
862
|
+
code: inspection.errorCode ?? "command-failed",
|
|
863
|
+
...(inspection.errorDetail === undefined ? {} : { detail: inspection.errorDetail }),
|
|
864
|
+
})}
|
|
865
|
+
</Text>
|
|
866
|
+
</View>
|
|
867
|
+
)}
|
|
868
|
+
</View>
|
|
869
|
+
|
|
870
|
+
{snapshot === null && loadError === null ? (
|
|
871
|
+
<View style={styles.statusCard}>
|
|
872
|
+
<ActivityIndicator size="small" color={theme.colors.accent} />
|
|
873
|
+
<Text style={styles.muted}>{t("plugins.status.loadingProfile")}</Text>
|
|
874
|
+
</View>
|
|
875
|
+
) : null}
|
|
876
|
+
|
|
877
|
+
{groups.map((group) => (
|
|
878
|
+
<View key={group.title} style={styles.section}>
|
|
879
|
+
<Text style={styles.groupTitle}>
|
|
880
|
+
{t(group.title as "plugins.groups.enabled")} · {group.items.length}
|
|
881
|
+
</Text>
|
|
882
|
+
{group.items.map((bundle) => (
|
|
883
|
+
<BundleRow
|
|
884
|
+
key={bundle.name}
|
|
885
|
+
bundle={bundle}
|
|
886
|
+
t={translate}
|
|
887
|
+
styles={styles}
|
|
888
|
+
busy={busy}
|
|
889
|
+
toggleBusy={toggleBusy}
|
|
890
|
+
confirmRemove={confirmRemove}
|
|
891
|
+
confirmUpdate={confirmUpdate}
|
|
892
|
+
onToggle={(item) => {
|
|
893
|
+
void toggle(item);
|
|
894
|
+
}}
|
|
895
|
+
onRemove={(name) => {
|
|
896
|
+
void remove(name);
|
|
897
|
+
}}
|
|
898
|
+
onUpdate={(name, version) => {
|
|
899
|
+
void update(name, version);
|
|
900
|
+
}}
|
|
901
|
+
/>
|
|
902
|
+
))}
|
|
903
|
+
</View>
|
|
904
|
+
))}
|
|
905
|
+
</ScrollView>
|
|
906
|
+
);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* A render error used to be fatal for the whole app: release Hermes hands it to
|
|
911
|
+
* RN's fatal handler, which aborts the process. Keep one malformed field or
|
|
912
|
+
* host prop from taking the sidebar and every open agent down with it.
|
|
913
|
+
*/
|
|
914
|
+
class SurfaceBoundary extends Component<
|
|
915
|
+
{ fallback: ReactNode; children: ReactNode },
|
|
916
|
+
{ failed: boolean }
|
|
917
|
+
> {
|
|
918
|
+
state = { failed: false };
|
|
919
|
+
|
|
920
|
+
static getDerivedStateFromError(): { failed: boolean } {
|
|
921
|
+
return { failed: true };
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
componentDidCatch(error: Error): void {
|
|
925
|
+
report("dsh plugins screen", error);
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
render(): ReactNode {
|
|
929
|
+
return this.state.failed ? this.props.fallback : this.props.children;
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
export function DshPluginsPage(props: PluginSurfaceProps) {
|
|
934
|
+
const { t } = useTranslation();
|
|
935
|
+
return (
|
|
936
|
+
<SurfaceBoundary
|
|
937
|
+
fallback={(
|
|
938
|
+
<View
|
|
939
|
+
style={{
|
|
940
|
+
flex: 1,
|
|
941
|
+
padding: 24,
|
|
942
|
+
backgroundColor: props.theme.colors.surface0,
|
|
943
|
+
}}
|
|
944
|
+
>
|
|
945
|
+
<Text
|
|
946
|
+
style={{
|
|
947
|
+
color: props.theme.colors.statusDanger,
|
|
948
|
+
fontSize: 13,
|
|
949
|
+
lineHeight: 19,
|
|
950
|
+
}}
|
|
951
|
+
>
|
|
952
|
+
{t("plugins.errors.render")}
|
|
953
|
+
</Text>
|
|
954
|
+
</View>
|
|
955
|
+
)}
|
|
956
|
+
>
|
|
957
|
+
<DshPluginsPageBody {...props} />
|
|
958
|
+
</SurfaceBoundary>
|
|
959
|
+
);
|
|
960
|
+
}
|