create-expo-updates-server 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/README.md +4 -2
- package/dist/template/Dockerfile +4 -6
- package/dist/template/README.md +4 -9
- package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
- package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
- package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
- package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
- package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
- package/dist/template/app/api/admin/updates/route.test.ts +21 -0
- package/dist/template/app/api/admin/updates/route.ts +12 -1
- package/dist/template/app/globals.css +65 -68
- package/dist/template/app/login/page.tsx +66 -42
- package/dist/template/app/updates/[encodedKey]/page.tsx +375 -263
- package/dist/template/app/updates/devices/page.tsx +188 -152
- package/dist/template/app/updates/embedded/page.tsx +63 -29
- package/dist/template/app/updates/emergency-redirects/page.tsx +93 -58
- package/dist/template/app/updates/layout.tsx +2 -1
- package/dist/template/app/updates/page.tsx +381 -283
- package/dist/template/app/updates/releases.test.tsx +156 -0
- package/dist/template/components/admin/admin-role.ts +5 -0
- package/dist/template/components/admin/admin-shell.tsx +166 -101
- package/dist/template/components/admin/confirm-action.tsx +123 -0
- package/dist/template/components/admin/language-switcher.tsx +25 -17
- package/dist/template/components/admin/release-badges.test.tsx +50 -0
- package/dist/template/components/admin/release-badges.tsx +101 -0
- package/dist/template/components/ui/alert.tsx +10 -3
- package/dist/template/components/ui/avatar.tsx +108 -0
- package/dist/template/components/ui/badge.tsx +2 -2
- package/dist/template/components/ui/breadcrumb.tsx +108 -0
- package/dist/template/components/ui/button.tsx +5 -5
- package/dist/template/components/ui/card.tsx +2 -2
- package/dist/template/components/ui/chart.tsx +1 -1
- package/dist/template/components/ui/collapsible.tsx +7 -0
- package/dist/template/components/ui/empty.tsx +103 -0
- package/dist/template/components/ui/field.tsx +248 -0
- package/dist/template/components/ui/input-group.tsx +170 -0
- package/dist/template/components/ui/input.tsx +1 -1
- package/dist/template/components/ui/native-select.tsx +1 -1
- package/dist/template/components/ui/radio-group.tsx +41 -0
- package/dist/template/components/ui/status-tones.ts +15 -0
- package/dist/template/components/ui/table.tsx +1 -1
- package/dist/template/components/ui/textarea.tsx +1 -1
- package/dist/template/docs/admin-ui.md +7 -3
- package/dist/template/docs/device-targeting.md +2 -7
- package/dist/template/docs/doctor.md +2 -2
- package/dist/template/docs/expo-app-setup.md +9 -27
- package/dist/template/docs/getting-started.md +3 -4
- package/dist/template/docs/installation-telemetry.md +2 -8
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
- package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
- package/dist/template/docs/migrations/schema.sql +349 -0
- package/dist/template/docs/npm-installer.md +3 -3
- package/dist/template/docs/operations-guide.md +8 -6
- package/dist/template/docs/ota-client-lifecycle.md +30 -68
- package/dist/template/docs/ota-update-policy.md +9 -20
- package/dist/template/docs/ru/admin-ui.md +7 -3
- package/dist/template/docs/ru/device-targeting.md +2 -2
- package/dist/template/docs/ru/doctor.md +2 -2
- package/dist/template/docs/ru/expo-app-setup.md +9 -9
- package/dist/template/docs/ru/getting-started.md +3 -3
- package/dist/template/docs/ru/installation-telemetry.md +2 -2
- package/dist/template/docs/ru/npm-installer.md +3 -3
- package/dist/template/docs/ru/operations-guide.md +8 -3
- package/dist/template/docs/ru/ota-client-lifecycle.md +30 -35
- package/dist/template/docs/ru/ota-update-policy.md +9 -7
- package/dist/template/docs/ru/publishing-npm-installer.md +2 -2
- package/dist/template/docs/uk/admin-ui.md +7 -3
- package/dist/template/docs/uk/device-targeting.md +2 -2
- package/dist/template/docs/uk/doctor.md +2 -2
- package/dist/template/docs/uk/expo-app-setup.md +9 -9
- package/dist/template/docs/uk/getting-started.md +3 -3
- package/dist/template/docs/uk/installation-telemetry.md +2 -2
- package/dist/template/docs/uk/npm-installer.md +3 -3
- package/dist/template/docs/uk/operations-guide.md +8 -3
- package/dist/template/docs/uk/ota-client-lifecycle.md +30 -35
- package/dist/template/docs/uk/ota-update-policy.md +9 -7
- package/dist/template/docs/uk/publishing-npm-installer.md +2 -2
- package/dist/template/lib/audience-ids.ts +4 -0
- package/dist/template/package-lock.json +46 -0
- package/dist/template/package.json +3 -1
- package/dist/template/scripts/configure-expo-app.mjs +3 -3
- package/dist/template/scripts/create-access-token.mjs +1 -1
- package/dist/template/scripts/lib/doctor.mjs +10 -7
- package/dist/template/scripts/lib/doctor.test.mjs +7 -5
- package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
- package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
- package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
- package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
- package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
- package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
- package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
- package/dist/template/scripts/tests/e2e/console.mjs +86 -0
- package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
- package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
- package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
- package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
- package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
- package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
- package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
- package/dist/template/scripts/tests/e2e/run.mjs +224 -0
- package/dist/template/scripts/tests/manifest-identity.sql +7 -5
- package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
- package/dist/template/src/client/admin-api.ts +45 -10
- package/dist/template/src/client/admin-types.ts +35 -1
- package/dist/template/src/client/devices/analytics.tsx +168 -231
- package/dist/template/src/client/devices/cohorts.tsx +181 -0
- package/dist/template/src/client/devices/device-name.tsx +37 -23
- package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
- package/dist/template/src/client/devices/registry.tsx +258 -245
- package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
- package/dist/template/src/client/devices/use-devices-report.ts +53 -82
- package/dist/template/src/client/devices/version-adoption-chart.tsx +47 -49
- package/dist/template/src/client/distribution-control.tsx +89 -57
- package/dist/template/src/client/distribution-history.tsx +353 -0
- package/dist/template/src/client/guard-action-catalog.tsx +183 -0
- package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
- package/dist/template/src/client/guard-action-combobox.tsx +133 -239
- package/dist/template/src/client/guard-action-options.ts +4 -6
- package/dist/template/src/client/i18n/en.json +133 -2
- package/dist/template/src/client/i18n/language-switching.test.tsx +12 -3
- package/dist/template/src/client/i18n/ru.json +133 -2
- package/dist/template/src/client/i18n/uk.json +133 -2
- package/dist/template/src/client/logout-button.tsx +3 -3
- package/dist/template/src/client/policy-draft.ts +138 -0
- package/dist/template/src/client/update-audience-editor.tsx +597 -206
- package/dist/template/src/client/update-policy-editor.test.ts +101 -29
- package/dist/template/src/client/update-policy-editor.tsx +454 -320
- package/dist/template/src/client/use-filtered-results.ts +55 -0
- package/dist/template/src/server/controllers/manifest.test.ts +23 -3
- package/dist/template/src/server/controllers/manifest.ts +15 -1
- package/dist/template/src/server/devices/audience.ts +9 -5
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
- package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
- package/dist/template/src/server/lib/admin-updates.ts +160 -534
- package/dist/template/src/server/lib/distribution-history.ts +97 -0
- package/dist/template/src/server/lib/supabase.js +24 -0
- package/dist/template/src/server/lib/supabase.test.ts +38 -1
- package/dist/template/src/server/lib/update-policy.test.ts +20 -0
- package/dist/template/src/server/lib/update-policy.ts +23 -10
- package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
- package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
- package/dist/template/src/server/manifest/manifest-values.ts +21 -13
- package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
- package/dist/template/tsconfig.json +2 -2
- package/dist/template-manifest.json +446 -301
- package/package.json +1 -1
- package/dist/template/scripts/lib/device-identity.test.ts +0 -29
- package/dist/template/scripts/lib/ota-client.test.ts +0 -55
- package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
- package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
- package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
- package/dist/template/templates/expo-app/ota-client/README.md +0 -73
- package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
- package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
- package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
- package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
- package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
- package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
- package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useI18n } from "@/src/client/i18n/provider";
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { useFilteredResults } from "@/src/client/use-filtered-results";
|
|
5
4
|
import type { DevicesReport } from "@/src/server/devices/report-types";
|
|
6
5
|
export type Filters = {
|
|
7
6
|
days: string;
|
|
@@ -19,90 +18,62 @@ export const defaultFilters: Filters = {
|
|
|
19
18
|
launchKind: "",
|
|
20
19
|
search: "",
|
|
21
20
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fetch(`/api/admin/devices?${params}`, {
|
|
38
|
-
signal
|
|
21
|
+
const initialQuery = { ...defaultFilters, offset: 0 };
|
|
22
|
+
|
|
23
|
+
async function loadReport(
|
|
24
|
+
query: typeof initialQuery,
|
|
25
|
+
signal: AbortSignal,
|
|
26
|
+
): Promise<DevicesReport> {
|
|
27
|
+
if (!/^[a-f0-9-]{0,36}$/i.test(query.search.trim()))
|
|
28
|
+
throw new Error("Часть UUID: цифры, буквы a–f и дефисы");
|
|
29
|
+
|
|
30
|
+
const params = new URLSearchParams();
|
|
31
|
+
for (const [key, value] of Object.entries(query)) {
|
|
32
|
+
if (String(value).trim()) params.set(key, String(value).trim());
|
|
33
|
+
}
|
|
34
|
+
for (;;) {
|
|
35
|
+
signal.throwIfAborted();
|
|
36
|
+
const response = await fetch(`/api/admin/devices?${params}`, {
|
|
37
|
+
signal,
|
|
39
38
|
cache: "no-store",
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
63
|
-
.catch((e) => {
|
|
64
|
-
if (!controller.signal.aborted) {
|
|
65
|
-
setError(e.message);
|
|
66
|
-
setLoading(false);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
return () => controller.abort();
|
|
70
|
-
}, [applied, offset, revision]);
|
|
71
|
-
const refresh = () => {
|
|
72
|
-
setLoading(true);
|
|
73
|
-
setError("");
|
|
74
|
-
setRevision((n) => n + 1);
|
|
75
|
-
};
|
|
76
|
-
const apply = () => {
|
|
77
|
-
setLoading(true);
|
|
78
|
-
setError("");
|
|
79
|
-
setApplied({ ...filters });
|
|
80
|
-
setOffset(0);
|
|
81
|
-
};
|
|
82
|
-
const reset = () => {
|
|
83
|
-
setFilters(defaultFilters);
|
|
84
|
-
setApplied({ ...defaultFilters });
|
|
85
|
-
setOffset(0);
|
|
86
|
-
setLoading(true);
|
|
87
|
-
setError("");
|
|
88
|
-
};
|
|
89
|
-
const paginate = (next: number) => {
|
|
90
|
-
setLoading(true);
|
|
91
|
-
setError("");
|
|
92
|
-
setOffset(next);
|
|
93
|
-
setRevision((n) => n + 1);
|
|
94
|
-
};
|
|
39
|
+
});
|
|
40
|
+
const data = await response.json();
|
|
41
|
+
if (!response.ok)
|
|
42
|
+
throw new Error(data.error || "Не удалось загрузить статистику");
|
|
43
|
+
const report: DevicesReport = data;
|
|
44
|
+
if (report.offset === 0 || report.offset < report.total) return report;
|
|
45
|
+
// A concurrent removal can make the requested registry page disappear.
|
|
46
|
+
const lastOffset = Math.max(
|
|
47
|
+
0,
|
|
48
|
+
Math.floor((report.total - 1) / report.pageSize) * report.pageSize,
|
|
49
|
+
);
|
|
50
|
+
params.set("offset", String(lastOffset));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function useDevicesReport() {
|
|
55
|
+
const { query, success, error, loading, request } = useFilteredResults(
|
|
56
|
+
initialQuery,
|
|
57
|
+
loadReport,
|
|
58
|
+
);
|
|
59
|
+
const { offset, ...filters } = query;
|
|
60
|
+
const report = success?.data ?? null;
|
|
95
61
|
return {
|
|
96
62
|
filters,
|
|
97
|
-
setFilters,
|
|
98
|
-
applied,
|
|
99
63
|
report,
|
|
100
|
-
error
|
|
64
|
+
error,
|
|
101
65
|
loading,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
66
|
+
update: (key: keyof Filters, value: string) =>
|
|
67
|
+
request(
|
|
68
|
+
{ ...query, [key]: value, offset: 0 },
|
|
69
|
+
key === "search" && Boolean(value.trim()),
|
|
70
|
+
),
|
|
71
|
+
reset: () => request(initialQuery),
|
|
72
|
+
refresh: () =>
|
|
73
|
+
request({
|
|
74
|
+
...query,
|
|
75
|
+
offset: success?.query === query && report ? report.offset : offset,
|
|
76
|
+
}),
|
|
77
|
+
paginate: (offset: number) => request({ ...query, offset }),
|
|
107
78
|
};
|
|
108
79
|
}
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
import { useFormatters } from "@/src/client/i18n/use-formatters";
|
|
3
3
|
import { useI18n } from "@/src/client/i18n/provider";
|
|
4
4
|
|
|
5
|
+
import {
|
|
6
|
+
Collapsible,
|
|
7
|
+
CollapsibleTrigger,
|
|
8
|
+
CollapsibleContent,
|
|
9
|
+
} from "@/components/ui/collapsible";
|
|
5
10
|
import { useState } from "react";
|
|
11
|
+
import { ChevronDown, ChevronUp, BarChart3, Layers } from "lucide-react";
|
|
6
12
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
GitBranch,
|
|
12
|
-
} from "lucide-react";
|
|
13
|
+
PlatformBadge,
|
|
14
|
+
ChannelBadge,
|
|
15
|
+
launchKindTone,
|
|
16
|
+
} from "@/components/admin/release-badges";
|
|
13
17
|
import { Badge } from "@/components/ui/badge";
|
|
14
18
|
import { Button } from "@/components/ui/button";
|
|
15
19
|
import {
|
|
@@ -46,21 +50,15 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
46
50
|
: scope.versions.slice(0, PREVIEW_ROWS);
|
|
47
51
|
return (
|
|
48
52
|
<section
|
|
49
|
-
className="min-w-0 rounded-lg border p-4"
|
|
53
|
+
className="@container min-w-0 rounded-lg border bg-background/35 p-3 sm:p-4"
|
|
50
54
|
aria-label={t("Канал {0}, {1}", [scope.channel, scope.platform])}
|
|
51
55
|
>
|
|
52
56
|
<header className="mb-4 flex flex-wrap items-center justify-between gap-3">
|
|
53
57
|
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
{t("Канал")}
|
|
57
|
-
</span>
|
|
58
|
-
<h4 className="break-all text-sm font-semibold">
|
|
59
|
-
{scope.channel}
|
|
58
|
+
<h4 className="min-w-0 max-w-full">
|
|
59
|
+
<ChannelBadge channel={scope.channel} />
|
|
60
60
|
</h4>
|
|
61
|
-
<
|
|
62
|
-
{scope.platform === "ios" ? "iOS" : "Android"}
|
|
63
|
-
</Badge>
|
|
61
|
+
<PlatformBadge platform={scope.platform} />
|
|
64
62
|
</div>
|
|
65
63
|
<span className="text-xs text-muted-foreground">
|
|
66
64
|
{t("Активных установок:")}{" "}
|
|
@@ -69,7 +67,7 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
69
67
|
</strong>
|
|
70
68
|
</span>
|
|
71
69
|
</header>
|
|
72
|
-
<div className="hidden grid-cols-[minmax(0,
|
|
70
|
+
<div className="hidden grid-cols-[minmax(0,1fr)_minmax(4rem,1.4fr)_6.5rem] gap-5 border-b pb-3 text-xs text-muted-foreground @min-[32rem]:grid">
|
|
73
71
|
<span>{t("Версия приложения / OTA")}</span>
|
|
74
72
|
<div className="flex justify-between">
|
|
75
73
|
<span>0%</span>
|
|
@@ -84,7 +82,7 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
84
82
|
{visible.map((version) => (
|
|
85
83
|
<li
|
|
86
84
|
key={version.key}
|
|
87
|
-
className="grid min-w-0 gap-x-
|
|
85
|
+
className="grid min-w-0 grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-2.5 border-b py-3 last:border-b-0 @min-[32rem]:grid-cols-[minmax(0,1fr)_minmax(4rem,1.4fr)_6.5rem] @min-[32rem]:items-center"
|
|
88
86
|
>
|
|
89
87
|
<div className="min-w-0">
|
|
90
88
|
<div className="flex flex-wrap items-center gap-2">
|
|
@@ -92,32 +90,38 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
92
90
|
{version.appVersion || t("Версия не указана")}
|
|
93
91
|
</p>
|
|
94
92
|
<Badge
|
|
95
|
-
variant=
|
|
96
|
-
className="font-mono text-[
|
|
93
|
+
variant={launchKindTone[version.kind]}
|
|
94
|
+
className="font-mono text-[11px]"
|
|
97
95
|
title={version.updateId || undefined}
|
|
98
96
|
>
|
|
99
97
|
{kindLabels[version.kind]}
|
|
100
|
-
{version.updateId
|
|
101
|
-
? ` ${version.updateId.slice(0, 8)}`
|
|
102
|
-
: ""}
|
|
98
|
+
{version.updateId ? ` ${version.updateId.slice(0, 8)}` : ""}
|
|
103
99
|
</Badge>
|
|
104
100
|
</div>
|
|
105
101
|
<p className="mt-1 break-words text-xs leading-5 text-muted-foreground">
|
|
106
102
|
{t("Native:")} {version.nativeBuilds.join(", ")}
|
|
107
103
|
</p>
|
|
108
104
|
{version.updateId && (
|
|
109
|
-
<
|
|
110
|
-
<
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
105
|
+
<Collapsible className="group/id mt-1 text-xs text-muted-foreground">
|
|
106
|
+
<CollapsibleTrigger asChild>
|
|
107
|
+
<Button size="xs" variant="ghost" className="-ml-1 px-1">
|
|
108
|
+
<ChevronDown
|
|
109
|
+
className="size-3 group-data-[state=open]/id:rotate-180"
|
|
110
|
+
aria-hidden="true"
|
|
111
|
+
/>
|
|
112
|
+
{t("Полный ID")}
|
|
113
|
+
</Button>
|
|
114
|
+
</CollapsibleTrigger>
|
|
115
|
+
<CollapsibleContent>
|
|
116
|
+
<code className="mt-1 block break-all select-all">
|
|
117
|
+
{version.updateId}
|
|
118
|
+
</code>
|
|
119
|
+
</CollapsibleContent>
|
|
120
|
+
</Collapsible>
|
|
117
121
|
)}
|
|
118
122
|
</div>
|
|
119
123
|
<div
|
|
120
|
-
className="flex h-
|
|
124
|
+
className="col-span-2 row-start-2 flex h-3 items-center @min-[32rem]:col-span-1 @min-[32rem]:col-start-2 @min-[32rem]:row-start-1 overflow-hidden rounded-sm bg-muted"
|
|
121
125
|
role="img"
|
|
122
126
|
aria-label={t(
|
|
123
127
|
"{0}, {1} {2}: {3} установок, {4} внутри канала {5}, {6}",
|
|
@@ -133,7 +137,7 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
133
137
|
)}
|
|
134
138
|
>
|
|
135
139
|
<div
|
|
136
|
-
className="h-full rounded-
|
|
140
|
+
className="h-full rounded-sm"
|
|
137
141
|
style={{
|
|
138
142
|
width: `${scope.total ? (version.installations / scope.total) * 100 : 0}%`,
|
|
139
143
|
minWidth: version.installations ? 2 : 0,
|
|
@@ -141,8 +145,8 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
141
145
|
}}
|
|
142
146
|
/>
|
|
143
147
|
</div>
|
|
144
|
-
<div className="flex items-baseline justify-end gap-2 tabular-nums">
|
|
145
|
-
<strong className="text-
|
|
148
|
+
<div className="col-start-2 row-start-1 flex flex-wrap items-baseline justify-end gap-x-2 tabular-nums @min-[32rem]:col-start-3">
|
|
149
|
+
<strong className="text-base font-semibold">
|
|
146
150
|
{number(version.installations)}
|
|
147
151
|
</strong>
|
|
148
152
|
<span className="text-sm text-muted-foreground">
|
|
@@ -157,8 +161,7 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
157
161
|
<p className="text-xs text-muted-foreground">
|
|
158
162
|
{t("Показано ")}
|
|
159
163
|
{visible.length} {t(" из ")}
|
|
160
|
-
{scope.versions.length}{" "}
|
|
161
|
-
{t(" версий. Доли учитывают весь блок.")}
|
|
164
|
+
{scope.versions.length} {t(" версий. Доли учитывают весь блок.")}
|
|
162
165
|
</p>
|
|
163
166
|
<Button
|
|
164
167
|
variant="outline"
|
|
@@ -176,11 +179,7 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
176
179
|
</section>
|
|
177
180
|
);
|
|
178
181
|
}
|
|
179
|
-
export function VersionAdoptionChart({
|
|
180
|
-
report,
|
|
181
|
-
}: {
|
|
182
|
-
report: DevicesReport;
|
|
183
|
-
}) {
|
|
182
|
+
export function VersionAdoptionChart({ report }: { report: DevicesReport }) {
|
|
184
183
|
const kindLabels = useKindLabels();
|
|
185
184
|
const { number } = useFormatters();
|
|
186
185
|
const { t } = useI18n();
|
|
@@ -197,9 +196,9 @@ export function VersionAdoptionChart({
|
|
|
197
196
|
<CardHeader>
|
|
198
197
|
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
199
198
|
<CardTitle id="version-adoption-title">
|
|
200
|
-
{t("Активные установки по версиям")}
|
|
199
|
+
<h2>{t("Активные установки по версиям")}</h2>
|
|
201
200
|
</CardTitle>
|
|
202
|
-
<Badge variant="
|
|
201
|
+
<Badge variant="info">
|
|
203
202
|
{t("Всего: ")}
|
|
204
203
|
{number(report.total)}
|
|
205
204
|
</Badge>
|
|
@@ -212,7 +211,7 @@ export function VersionAdoptionChart({
|
|
|
212
211
|
)}
|
|
213
212
|
</CardDescription>
|
|
214
213
|
</CardHeader>
|
|
215
|
-
<CardContent>
|
|
214
|
+
<CardContent className="min-w-0 px-4 sm:px-6">
|
|
216
215
|
{runtimes.length ? (
|
|
217
216
|
<>
|
|
218
217
|
<div className="mb-5 flex flex-wrap gap-x-5 gap-y-2 text-xs text-muted-foreground">
|
|
@@ -221,15 +220,14 @@ export function VersionAdoptionChart({
|
|
|
221
220
|
<i
|
|
222
221
|
className="size-2 rounded-full"
|
|
223
222
|
style={{
|
|
224
|
-
background:
|
|
225
|
-
kindColors[kind as keyof typeof kindColors],
|
|
223
|
+
background: kindColors[kind as keyof typeof kindColors],
|
|
226
224
|
}}
|
|
227
225
|
/>
|
|
228
226
|
{label}
|
|
229
227
|
</span>
|
|
230
228
|
))}
|
|
231
229
|
</div>
|
|
232
|
-
<div className="space-y-
|
|
230
|
+
<div className="space-y-6">
|
|
233
231
|
{runtimes.map((runtime) => (
|
|
234
232
|
<section
|
|
235
233
|
key={runtime.runtime}
|
|
@@ -245,7 +243,7 @@ export function VersionAdoptionChart({
|
|
|
245
243
|
{runtime.runtime}
|
|
246
244
|
</span>
|
|
247
245
|
</h3>
|
|
248
|
-
<Badge variant="
|
|
246
|
+
<Badge variant="info">
|
|
249
247
|
{t("Установок: ")}
|
|
250
248
|
{number(runtime.total)}
|
|
251
249
|
</Badge>
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useConfirmAction } from "@/components/admin/confirm-action";
|
|
2
3
|
import type { TranslationMessage } from "@/src/client/i18n/messages";
|
|
3
4
|
import { useI18n } from "@/src/client/i18n/provider";
|
|
4
5
|
|
|
6
|
+
import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";
|
|
7
|
+
import { Field, FieldLabel } from "@/components/ui/field";
|
|
8
|
+
import { Skeleton } from "@/components/ui/skeleton";
|
|
5
9
|
import { Textarea } from "@/components/ui/textarea";
|
|
6
10
|
|
|
11
|
+
import { statusTones } from "@/components/ui/status-tones";
|
|
12
|
+
import { cn } from "@/lib/utils";
|
|
7
13
|
import { Button } from "@/components/ui/button";
|
|
8
14
|
import { Badge } from "@/components/ui/badge";
|
|
9
15
|
import { Card } from "@/components/ui/card";
|
|
10
|
-
import {
|
|
11
|
-
ShieldCheck,
|
|
12
|
-
ShieldAlert,
|
|
13
|
-
ChevronDown,
|
|
14
|
-
RefreshCw,
|
|
15
|
-
} from "lucide-react";
|
|
16
|
+
import { ShieldCheck, ShieldAlert, ChevronDown, RefreshCw } from "lucide-react";
|
|
16
17
|
|
|
17
18
|
import {
|
|
18
19
|
AdminApiError,
|
|
@@ -23,9 +24,7 @@ import type { DistributionControlResponse } from "./admin-types";
|
|
|
23
24
|
import { useCallback, useEffect, useState } from "react";
|
|
24
25
|
|
|
25
26
|
export function useDistributionControlState() {
|
|
26
|
-
const [state, setState] = useState<DistributionControlResponse | null>(
|
|
27
|
-
null,
|
|
28
|
-
);
|
|
27
|
+
const [state, setState] = useState<DistributionControlResponse | null>(null);
|
|
29
28
|
const [loading, setLoading] = useState(true);
|
|
30
29
|
const [error, setError] = useState("");
|
|
31
30
|
|
|
@@ -76,50 +75,64 @@ export function DistributionControlBanner({
|
|
|
76
75
|
const { t, formatLocale } = useI18n();
|
|
77
76
|
if (loading) {
|
|
78
77
|
return (
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
<Skeleton className="h-12" role="status">
|
|
79
|
+
<span className="sr-only">
|
|
80
|
+
{t("Проверка глобального статуса OTA…")}
|
|
81
|
+
</span>
|
|
82
|
+
</Skeleton>
|
|
82
83
|
);
|
|
83
84
|
}
|
|
84
|
-
|
|
85
85
|
if (error || !state) {
|
|
86
86
|
return (
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
<Alert variant="destructive">
|
|
88
|
+
<ShieldAlert />
|
|
89
|
+
<AlertTitle>
|
|
90
|
+
{t(
|
|
91
|
+
"Глобальный статус OTA недоступен. Распространяющие действия отключены до восстановления связи.",
|
|
92
|
+
)}
|
|
93
|
+
</AlertTitle>
|
|
94
|
+
{error && <AlertDescription>{t(error)}</AlertDescription>}
|
|
95
|
+
</Alert>
|
|
93
96
|
);
|
|
94
97
|
}
|
|
95
|
-
|
|
96
98
|
if (!state.blocked) {
|
|
97
99
|
return null;
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
return (
|
|
101
|
-
<
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
<Alert variant="destructive">
|
|
104
|
+
<ShieldAlert />
|
|
105
|
+
<AlertTitle>{t("Распространение OTA остановлено")}</AlertTitle>
|
|
106
|
+
<AlertDescription>
|
|
107
|
+
<p>{state.reason}</p>
|
|
108
|
+
<p>
|
|
109
|
+
{new Date(state.changedAt).toLocaleString(formatLocale)} ·{" "}
|
|
110
|
+
{formatChangedBy(state, t)}
|
|
111
|
+
</p>
|
|
112
|
+
</AlertDescription>
|
|
113
|
+
</Alert>
|
|
111
114
|
);
|
|
112
115
|
}
|
|
113
116
|
|
|
114
|
-
export default function DistributionControl(
|
|
117
|
+
export default function DistributionControl({
|
|
118
|
+
onAvailabilityChange,
|
|
119
|
+
}: {
|
|
120
|
+
onAvailabilityChange?: (blocked: boolean) => void;
|
|
121
|
+
}) {
|
|
122
|
+
const confirmAction = useConfirmAction();
|
|
115
123
|
const { t, formatLocale } = useI18n();
|
|
116
|
-
const { state, setState, loading, error,
|
|
124
|
+
const { state, setState, loading, error, refresh } =
|
|
117
125
|
useDistributionControlState();
|
|
126
|
+
const [actionError, setActionError] = useState("");
|
|
118
127
|
const [reason, setReason] = useState("");
|
|
119
128
|
const [saving, setSaving] = useState(false);
|
|
120
129
|
const [message, setMessage] = useState<TranslationMessage>("");
|
|
121
130
|
const [expanded, setExpanded] = useState(false);
|
|
122
131
|
|
|
132
|
+
useEffect(() => {
|
|
133
|
+
onAvailabilityChange?.(loading || !!error || !state || state.blocked);
|
|
134
|
+
}, [loading, error, state, onAvailabilityChange]);
|
|
135
|
+
|
|
123
136
|
const changeState = async (blocked: boolean) => {
|
|
124
137
|
if (!state) {
|
|
125
138
|
return;
|
|
@@ -127,23 +140,25 @@ export default function DistributionControl() {
|
|
|
127
140
|
|
|
128
141
|
const normalizedReason = reason.trim();
|
|
129
142
|
if (blocked && !normalizedReason) {
|
|
130
|
-
|
|
143
|
+
setActionError("Укажите причину аварийной блокировки.");
|
|
131
144
|
return;
|
|
132
145
|
}
|
|
133
146
|
|
|
134
|
-
const confirmed =
|
|
147
|
+
const confirmed = await confirmAction(
|
|
148
|
+
blocked ? t("Остановить все OTA") : t("Возобновить OTA"),
|
|
135
149
|
blocked
|
|
136
150
|
? t(
|
|
137
151
|
"Немедленно остановить выдачу manifest и всех OTA assets для всех клиентов?",
|
|
138
152
|
)
|
|
139
153
|
: t("Возобновить глобальное OTA-распространение?"),
|
|
154
|
+
blocked,
|
|
140
155
|
);
|
|
141
156
|
if (!confirmed) {
|
|
142
157
|
return;
|
|
143
158
|
}
|
|
144
159
|
|
|
145
160
|
setSaving(true);
|
|
146
|
-
|
|
161
|
+
setActionError("");
|
|
147
162
|
setMessage("");
|
|
148
163
|
try {
|
|
149
164
|
const updated = await setDistributionControl({
|
|
@@ -161,11 +176,11 @@ export default function DistributionControl() {
|
|
|
161
176
|
} catch (saveError: unknown) {
|
|
162
177
|
if (saveError instanceof AdminApiError && saveError.status === 409) {
|
|
163
178
|
await refresh();
|
|
164
|
-
|
|
179
|
+
setActionError(
|
|
165
180
|
"Состояние уже изменил другой оператор. Данные обновлены; проверьте их и повторите действие.",
|
|
166
181
|
);
|
|
167
182
|
} else {
|
|
168
|
-
|
|
183
|
+
setActionError(
|
|
169
184
|
saveError instanceof Error
|
|
170
185
|
? saveError.message
|
|
171
186
|
: "Не удалось изменить глобальный статус OTA",
|
|
@@ -177,11 +192,16 @@ export default function DistributionControl() {
|
|
|
177
192
|
};
|
|
178
193
|
|
|
179
194
|
return (
|
|
180
|
-
<Card
|
|
195
|
+
<Card
|
|
196
|
+
className={cn(
|
|
197
|
+
"gap-0 overflow-hidden py-0 shadow-none",
|
|
198
|
+
(state?.blocked || error) && "border-l-4 border-l-destructive",
|
|
199
|
+
)}
|
|
200
|
+
>
|
|
181
201
|
<div className="flex flex-wrap items-center justify-between gap-4 p-4">
|
|
182
202
|
<div className="flex items-start gap-3">
|
|
183
203
|
<div
|
|
184
|
-
className={`flex size-9 shrink-0 items-center justify-center rounded-lg ${state?.blocked || error ?
|
|
204
|
+
className={`flex size-9 shrink-0 items-center justify-center rounded-lg ${state?.blocked || error ? statusTones.destructive : state && !loading ? statusTones.positive : "bg-muted text-muted-foreground"}`}
|
|
185
205
|
>
|
|
186
206
|
{loading ? (
|
|
187
207
|
<RefreshCw className="size-4 animate-spin" />
|
|
@@ -197,11 +217,12 @@ export default function DistributionControl() {
|
|
|
197
217
|
{t("Распространение OTA")}
|
|
198
218
|
</h2>
|
|
199
219
|
<Badge
|
|
200
|
-
variant=
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
220
|
+
variant={
|
|
221
|
+
loading
|
|
222
|
+
? "neutral"
|
|
223
|
+
: state?.blocked || error || !state
|
|
224
|
+
? "destructive"
|
|
225
|
+
: "positive"
|
|
205
226
|
}
|
|
206
227
|
>
|
|
207
228
|
{loading
|
|
@@ -234,34 +255,42 @@ export default function DistributionControl() {
|
|
|
234
255
|
/>
|
|
235
256
|
</Button>
|
|
236
257
|
) : state ? (
|
|
237
|
-
<Badge variant="
|
|
258
|
+
<Badge variant="neutral">{t("Read only · updates:write")}</Badge>
|
|
238
259
|
) : null}
|
|
239
260
|
</div>
|
|
240
261
|
{expanded && state?.canWrite && (
|
|
241
262
|
<div
|
|
242
263
|
id="distribution-controls"
|
|
243
|
-
className=
|
|
264
|
+
className={cn(
|
|
265
|
+
"space-y-3 border-t p-4",
|
|
266
|
+
state.blocked ? "bg-muted/20" : statusTones.destructive,
|
|
267
|
+
)}
|
|
244
268
|
>
|
|
245
269
|
<p className="text-xs text-muted-foreground">
|
|
246
270
|
{t("Изменено: ")}
|
|
247
271
|
{new Date(state.changedAt).toLocaleString(formatLocale)} ·{" "}
|
|
248
|
-
{formatChangedBy(state, t)}{" "}
|
|
249
|
-
{t(" · version {0}", [state.version])}
|
|
272
|
+
{formatChangedBy(state, t)} {t(" · version {0}", [state.version])}
|
|
250
273
|
</p>
|
|
251
274
|
{!state.blocked && (
|
|
252
|
-
<
|
|
253
|
-
|
|
275
|
+
<Field>
|
|
276
|
+
<FieldLabel htmlFor="stop-reason">
|
|
277
|
+
{t("Причина остановки")}
|
|
278
|
+
</FieldLabel>
|
|
254
279
|
<Textarea
|
|
280
|
+
id="stop-reason"
|
|
255
281
|
value={reason}
|
|
256
|
-
onChange={(event) =>
|
|
282
|
+
onChange={(event) => {
|
|
283
|
+
setReason(event.target.value);
|
|
284
|
+
setActionError("");
|
|
285
|
+
}}
|
|
257
286
|
maxLength={500}
|
|
258
287
|
aria-label={t("Причина аварийной блокировки OTA")}
|
|
259
288
|
placeholder={t(
|
|
260
289
|
"Обязательная причина остановки (до 500 символов)",
|
|
261
290
|
)}
|
|
262
|
-
className="
|
|
291
|
+
className="min-h-20 max-w-2xl bg-background text-foreground"
|
|
263
292
|
/>
|
|
264
|
-
</
|
|
293
|
+
</Field>
|
|
265
294
|
)}
|
|
266
295
|
<Button
|
|
267
296
|
variant={state.blocked ? "default" : "destructive"}
|
|
@@ -277,18 +306,21 @@ export default function DistributionControl() {
|
|
|
277
306
|
</Button>
|
|
278
307
|
</div>
|
|
279
308
|
)}
|
|
280
|
-
{error && (
|
|
309
|
+
{(error || actionError) && (
|
|
281
310
|
<p
|
|
282
311
|
role="alert"
|
|
283
|
-
className="border-t
|
|
312
|
+
className={cn("border-t px-4 py-3 text-sm", statusTones.destructive)}
|
|
284
313
|
>
|
|
285
|
-
{t(error)}
|
|
314
|
+
{t(error || actionError)}
|
|
286
315
|
</p>
|
|
287
316
|
)}
|
|
288
317
|
{message && (
|
|
289
318
|
<p
|
|
290
319
|
role="status"
|
|
291
|
-
className=
|
|
320
|
+
className={cn(
|
|
321
|
+
"border-t px-4 py-3 text-sm",
|
|
322
|
+
state?.blocked ? statusTones.destructive : statusTones.positive,
|
|
323
|
+
)}
|
|
292
324
|
>
|
|
293
325
|
{t(message)}
|
|
294
326
|
</p>
|