@tangle-network/sandbox-ui 0.122.0 → 0.122.2
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/dist/pages.js +42 -22
- package/package.json +1 -1
package/dist/pages.js
CHANGED
|
@@ -3693,6 +3693,8 @@ function StartupScriptsPage({ apiClient, className }) {
|
|
|
3693
3693
|
const [secrets, setSecrets] = React$1.useState([]);
|
|
3694
3694
|
const [environments, setEnvironments] = React$1.useState([]);
|
|
3695
3695
|
const [loading, setLoading] = React$1.useState(true);
|
|
3696
|
+
const [hasLoaded, setHasLoaded] = React$1.useState(false);
|
|
3697
|
+
const [loadError, setLoadError] = React$1.useState(null);
|
|
3696
3698
|
const [error, setError] = React$1.useState(null);
|
|
3697
3699
|
const [isDialogOpen, setIsDialogOpen] = React$1.useState(false);
|
|
3698
3700
|
const [dialogStep, setDialogStep] = React$1.useState("picker");
|
|
@@ -3708,23 +3710,28 @@ function StartupScriptsPage({ apiClient, className }) {
|
|
|
3708
3710
|
const apiRef = React$1.useRef(apiClient);
|
|
3709
3711
|
apiRef.current = apiClient;
|
|
3710
3712
|
const loadGenRef = React$1.useRef(0);
|
|
3711
|
-
const loadData = React$1.useCallback(async (
|
|
3713
|
+
const loadData = React$1.useCallback(async () => {
|
|
3712
3714
|
const gen = ++loadGenRef.current;
|
|
3715
|
+
setLoading(true);
|
|
3716
|
+
setLoadError(null);
|
|
3717
|
+
setError(null);
|
|
3713
3718
|
try {
|
|
3714
|
-
|
|
3715
|
-
setError(null);
|
|
3716
|
-
const [scriptData, secretData, envData] = await Promise.all([
|
|
3719
|
+
const [scriptResult, secretResult, envResult] = await Promise.allSettled([
|
|
3717
3720
|
apiRef.current.listScripts(),
|
|
3718
3721
|
apiRef.current.listSecrets?.() ?? Promise.resolve([]),
|
|
3719
3722
|
apiRef.current.listEnvironments?.() ?? Promise.resolve([])
|
|
3720
3723
|
]);
|
|
3721
3724
|
if (gen !== loadGenRef.current) return;
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
if (
|
|
3727
|
-
|
|
3725
|
+
if (scriptResult.status === "fulfilled") {
|
|
3726
|
+
setScripts(scriptResult.value);
|
|
3727
|
+
setHasLoaded(true);
|
|
3728
|
+
}
|
|
3729
|
+
if (secretResult.status === "fulfilled") setSecrets(secretResult.value);
|
|
3730
|
+
if (envResult.status === "fulfilled") setEnvironments(envResult.value);
|
|
3731
|
+
if (scriptResult.status === "rejected") setLoadError("Couldn't load startup scripts.");
|
|
3732
|
+
else if (secretResult.status === "rejected" || envResult.status === "rejected") setLoadError("Some script options couldn't load.");
|
|
3733
|
+
} catch {
|
|
3734
|
+
if (gen === loadGenRef.current) setLoadError("Couldn't load startup scripts.");
|
|
3728
3735
|
} finally {
|
|
3729
3736
|
if (gen === loadGenRef.current) setLoading(false);
|
|
3730
3737
|
}
|
|
@@ -3794,7 +3801,7 @@ function StartupScriptsPage({ apiClient, className }) {
|
|
|
3794
3801
|
if (editingScript) await apiRef.current.updateScript(editingScript.id, formData);
|
|
3795
3802
|
else await apiRef.current.createScript(formData);
|
|
3796
3803
|
setIsDialogOpen(false);
|
|
3797
|
-
await loadData(
|
|
3804
|
+
await loadData();
|
|
3798
3805
|
} catch (err) {
|
|
3799
3806
|
setFormError(err instanceof Error ? err.message : "Failed to save script");
|
|
3800
3807
|
} finally {
|
|
@@ -3804,7 +3811,7 @@ function StartupScriptsPage({ apiClient, className }) {
|
|
|
3804
3811
|
const handleToggle = async (script) => {
|
|
3805
3812
|
try {
|
|
3806
3813
|
await apiRef.current.toggleScript(script.id);
|
|
3807
|
-
await loadData(
|
|
3814
|
+
await loadData();
|
|
3808
3815
|
} catch (err) {
|
|
3809
3816
|
setError(err instanceof Error ? err.message : "Failed to toggle script");
|
|
3810
3817
|
}
|
|
@@ -3815,7 +3822,7 @@ function StartupScriptsPage({ apiClient, className }) {
|
|
|
3815
3822
|
try {
|
|
3816
3823
|
await apiRef.current.deleteScript(deleteTarget.id);
|
|
3817
3824
|
setDeleteTarget(null);
|
|
3818
|
-
await loadData(
|
|
3825
|
+
await loadData();
|
|
3819
3826
|
} catch (err) {
|
|
3820
3827
|
setError(err instanceof Error ? err.message : "Failed to delete script");
|
|
3821
3828
|
} finally {
|
|
@@ -3847,12 +3854,23 @@ function StartupScriptsPage({ apiClient, className }) {
|
|
|
3847
3854
|
children: [/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }), "New Script"]
|
|
3848
3855
|
})
|
|
3849
3856
|
}),
|
|
3850
|
-
error && /* @__PURE__ */ jsxs("div", {
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3857
|
+
(loadError || error) && /* @__PURE__ */ jsxs("div", {
|
|
3858
|
+
role: "alert",
|
|
3859
|
+
className: "flex flex-wrap items-center gap-3 rounded-lg border border-destructive/30 bg-destructive/10 p-4",
|
|
3860
|
+
children: [
|
|
3861
|
+
/* @__PURE__ */ jsx(AlertCircle, { className: "h-5 w-5 shrink-0 text-destructive" }),
|
|
3862
|
+
/* @__PURE__ */ jsx("p", {
|
|
3863
|
+
className: "flex-1 text-sm font-medium text-destructive",
|
|
3864
|
+
children: error ?? loadError
|
|
3865
|
+
}),
|
|
3866
|
+
loadError && !error && /* @__PURE__ */ jsx("button", {
|
|
3867
|
+
type: "button",
|
|
3868
|
+
onClick: () => void loadData(),
|
|
3869
|
+
disabled: loading,
|
|
3870
|
+
className: "inline-flex min-h-11 items-center justify-center rounded-lg border border-border bg-surface-container-high px-4 text-sm font-semibold text-foreground shadow-sm hover:bg-surface-container-highest disabled:opacity-50",
|
|
3871
|
+
children: "Retry"
|
|
3872
|
+
})
|
|
3873
|
+
]
|
|
3856
3874
|
}),
|
|
3857
3875
|
/* @__PURE__ */ jsx(Dialog, {
|
|
3858
3876
|
open: isDialogOpen,
|
|
@@ -4217,7 +4235,7 @@ function StartupScriptsPage({ apiClient, className }) {
|
|
|
4217
4235
|
})] })]
|
|
4218
4236
|
})
|
|
4219
4237
|
}),
|
|
4220
|
-
/* @__PURE__ */ jsxs("div", {
|
|
4238
|
+
(loading || hasLoaded) && /* @__PURE__ */ jsxs("div", {
|
|
4221
4239
|
className: "overflow-hidden rounded-lg border border-[var(--md3-outline-variant)] bg-surface-container shadow-[var(--shadow-card)]",
|
|
4222
4240
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
4223
4241
|
className: "border-b border-[var(--md3-outline-variant)] px-6 py-4 flex items-center justify-between",
|
|
@@ -4227,7 +4245,7 @@ function StartupScriptsPage({ apiClient, className }) {
|
|
|
4227
4245
|
className: "text-xs font-bold uppercase tracking-widest text-foreground",
|
|
4228
4246
|
children: "All Scripts"
|
|
4229
4247
|
})
|
|
4230
|
-
}), /* @__PURE__ */ jsxs("span", {
|
|
4248
|
+
}), hasLoaded && /* @__PURE__ */ jsxs("span", {
|
|
4231
4249
|
className: "text-xs text-muted-foreground font-mono",
|
|
4232
4250
|
children: [
|
|
4233
4251
|
scripts.length,
|
|
@@ -4235,7 +4253,9 @@ function StartupScriptsPage({ apiClient, className }) {
|
|
|
4235
4253
|
scripts.length !== 1 ? "s" : ""
|
|
4236
4254
|
]
|
|
4237
4255
|
})]
|
|
4238
|
-
}), loading ? /* @__PURE__ */ jsx("div", {
|
|
4256
|
+
}), loading && !hasLoaded ? /* @__PURE__ */ jsx("div", {
|
|
4257
|
+
role: "status",
|
|
4258
|
+
"aria-label": "Loading startup scripts",
|
|
4239
4259
|
className: "flex items-center justify-center py-16",
|
|
4240
4260
|
children: /* @__PURE__ */ jsx("div", {
|
|
4241
4261
|
className: "h-6 w-6 animate-spin rounded-full border-2 border-primary border-t-transparent",
|
package/package.json
CHANGED