create-expo-updates-server 0.4.0 → 0.6.1
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 +303 -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 +25 -3
- package/dist/template/src/server/controllers/manifest.ts +1 -2
- 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 +2 -2
- 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 +445 -300
- 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
|
@@ -3,15 +3,16 @@ import { useFormatters } from "@/src/client/i18n/use-formatters";
|
|
|
3
3
|
import { useI18n } from "@/src/client/i18n/provider";
|
|
4
4
|
|
|
5
5
|
import { DeviceName } from "./device-name";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
ChevronLeft,
|
|
11
|
-
ChevronRight,
|
|
12
|
-
Search,
|
|
13
|
-
} from "lucide-react";
|
|
6
|
+
import { AdminRoleContext } from "@/components/admin/admin-role";
|
|
7
|
+
import { BookmarkTarget, useFavoriteTargets } from "./favorite-targets";
|
|
8
|
+
import { useContext, useRef, useState } from "react";
|
|
9
|
+
import { Copy, Check, ChevronLeft, ChevronRight, Search } from "lucide-react";
|
|
14
10
|
import { Button } from "@/components/ui/button";
|
|
11
|
+
import {
|
|
12
|
+
PlatformBadge,
|
|
13
|
+
ChannelBadge,
|
|
14
|
+
launchKindTone,
|
|
15
|
+
} from "@/components/admin/release-badges";
|
|
15
16
|
import { Badge } from "@/components/ui/badge";
|
|
16
17
|
import {
|
|
17
18
|
Card,
|
|
@@ -20,12 +21,6 @@ import {
|
|
|
20
21
|
CardDescription,
|
|
21
22
|
CardContent,
|
|
22
23
|
} from "@/components/ui/card";
|
|
23
|
-
import {
|
|
24
|
-
Tabs,
|
|
25
|
-
TabsList,
|
|
26
|
-
TabsTrigger,
|
|
27
|
-
TabsContent,
|
|
28
|
-
} from "@/components/ui/tabs";
|
|
29
24
|
import {
|
|
30
25
|
Table,
|
|
31
26
|
TableHeader,
|
|
@@ -45,7 +40,7 @@ import type {
|
|
|
45
40
|
DeviceInstallation,
|
|
46
41
|
DevicesReport,
|
|
47
42
|
} from "@/src/server/devices/report-types";
|
|
48
|
-
import { useKindNames
|
|
43
|
+
import { useKindNames } from "./analytics";
|
|
49
44
|
function CopyValue({ value }: { value: string }) {
|
|
50
45
|
const { t } = useI18n();
|
|
51
46
|
const [state, setState] = useState<"idle" | "copied" | "failed">("idle");
|
|
@@ -98,13 +93,22 @@ export function Registry({
|
|
|
98
93
|
const kindNames = useKindNames();
|
|
99
94
|
const { number, fullDate, calendarDate } = useFormatters();
|
|
100
95
|
const [selected, setSelected] = useState<DeviceInstallation | null>(null);
|
|
96
|
+
const role = useContext(AdminRoleContext);
|
|
97
|
+
const canBookmark = role === "admin" || role === "operator";
|
|
98
|
+
const personal = useFavoriteTargets(
|
|
99
|
+
selected?.platform ?? "",
|
|
100
|
+
!!selected && canBookmark,
|
|
101
|
+
0,
|
|
102
|
+
);
|
|
101
103
|
return (
|
|
102
104
|
<>
|
|
103
105
|
<Card className="min-w-0 shadow-none">
|
|
104
106
|
<CardHeader>
|
|
105
107
|
<div className="flex flex-wrap items-center gap-3">
|
|
106
|
-
<CardTitle>
|
|
107
|
-
|
|
108
|
+
<CardTitle>
|
|
109
|
+
<h2>{t("Реестр установок")}</h2>
|
|
110
|
+
</CardTitle>
|
|
111
|
+
<Badge variant="info">{number(report.total)}</Badge>
|
|
108
112
|
</div>
|
|
109
113
|
<CardDescription>
|
|
110
114
|
{t(
|
|
@@ -112,233 +116,136 @@ export function Registry({
|
|
|
112
116
|
)}
|
|
113
117
|
</CardDescription>
|
|
114
118
|
</CardHeader>
|
|
115
|
-
<CardContent>
|
|
116
|
-
<
|
|
117
|
-
<
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
{t("
|
|
121
|
-
{
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
</TableCell>
|
|
189
|
-
<TableCell>
|
|
190
|
-
<Badge
|
|
191
|
-
variant={
|
|
192
|
-
d.launch_kind === "ota"
|
|
193
|
-
? "default"
|
|
194
|
-
: "secondary"
|
|
195
|
-
}
|
|
196
|
-
>
|
|
197
|
-
{kindNames[d.launch_kind]}
|
|
198
|
-
</Badge>
|
|
199
|
-
{d.emergency_launch && (
|
|
200
|
-
<Badge
|
|
201
|
-
variant="destructive"
|
|
202
|
-
className="mt-1 block w-fit"
|
|
203
|
-
>
|
|
204
|
-
{t("Emergency")}
|
|
205
|
-
</Badge>
|
|
206
|
-
)}
|
|
207
|
-
</TableCell>
|
|
208
|
-
<TableCell className="text-xs tabular-nums">
|
|
209
|
-
{fullDate(d.last_seen_at).replace(" UTC", "")}
|
|
210
|
-
</TableCell>
|
|
211
|
-
</TableRow>
|
|
212
|
-
))}
|
|
213
|
-
</TableBody>
|
|
214
|
-
</Table>
|
|
215
|
-
{!report.devices.length && (
|
|
216
|
-
<div className="flex flex-col items-center gap-2 py-12 text-center">
|
|
217
|
-
<Search className="size-6 text-muted-foreground" />
|
|
218
|
-
<p className="text-sm font-medium">
|
|
219
|
-
{t("Установки не найдены")}
|
|
220
|
-
</p>
|
|
221
|
-
<p className="max-w-sm text-xs leading-5 text-muted-foreground">
|
|
222
|
-
{t(
|
|
223
|
-
"Измените фильтры или дождитесь heartbeat от приложения с подключённой телеметрией.",
|
|
119
|
+
<CardContent className="min-w-0 px-4 sm:px-6">
|
|
120
|
+
<Table aria-label={t("Реестр установок")}>
|
|
121
|
+
<TableHeader>
|
|
122
|
+
<TableRow>
|
|
123
|
+
<TableHead>{t("Установка")}</TableHead>
|
|
124
|
+
<TableHead>{t("Платформа / канал")}</TableHead>
|
|
125
|
+
<TableHead>{t("Версия")}</TableHead>
|
|
126
|
+
<TableHead>{t("Запуск")}</TableHead>
|
|
127
|
+
<TableHead>{t("Последняя связь · UTC")}</TableHead>
|
|
128
|
+
</TableRow>
|
|
129
|
+
</TableHeader>
|
|
130
|
+
<TableBody>
|
|
131
|
+
{report.devices.map((d) => (
|
|
132
|
+
<TableRow key={`${d.platform}:${d.installation_id}`}>
|
|
133
|
+
<TableCell>
|
|
134
|
+
<Button
|
|
135
|
+
variant="link"
|
|
136
|
+
className="h-auto p-0 font-mono text-xs"
|
|
137
|
+
title={d.installation_id}
|
|
138
|
+
onClick={(event) => {
|
|
139
|
+
opener.current = event.currentTarget;
|
|
140
|
+
setSelected(d);
|
|
141
|
+
}}
|
|
142
|
+
aria-label={t("Детали установки {0}", [
|
|
143
|
+
d.installation_id,
|
|
144
|
+
])}
|
|
145
|
+
>
|
|
146
|
+
{d.installation_id.slice(0, 8)}…
|
|
147
|
+
{d.installation_id.slice(-4)}
|
|
148
|
+
</Button>
|
|
149
|
+
<p className="mt-1 text-xs text-muted-foreground">
|
|
150
|
+
{t("С ")}
|
|
151
|
+
{calendarDate(d.first_seen_at)}
|
|
152
|
+
</p>
|
|
153
|
+
</TableCell>
|
|
154
|
+
<TableCell>
|
|
155
|
+
<div className="flex max-w-52 flex-wrap items-center gap-1">
|
|
156
|
+
<PlatformBadge platform={d.platform} />
|
|
157
|
+
<ChannelBadge channel={d.channel} />
|
|
158
|
+
</div>
|
|
159
|
+
</TableCell>
|
|
160
|
+
<TableCell>
|
|
161
|
+
<p
|
|
162
|
+
className="max-w-56 truncate text-sm"
|
|
163
|
+
title={
|
|
164
|
+
d.update_label ||
|
|
165
|
+
d.resolved_update_id ||
|
|
166
|
+
kindNames[d.launch_kind]
|
|
167
|
+
}
|
|
168
|
+
>
|
|
169
|
+
{d.update_label ||
|
|
170
|
+
d.resolved_update_id?.slice(0, 8) ||
|
|
171
|
+
kindNames[d.launch_kind]}
|
|
172
|
+
</p>
|
|
173
|
+
<p
|
|
174
|
+
className="mt-1 text-xs text-muted-foreground"
|
|
175
|
+
title={d.runtime_version}
|
|
176
|
+
>
|
|
177
|
+
{d.runtime_version}
|
|
178
|
+
</p>
|
|
179
|
+
<p className="mt-1 text-xs text-muted-foreground">
|
|
180
|
+
{t("Native")} {d.native_version || "—"} (
|
|
181
|
+
{d.native_build || "—"})
|
|
182
|
+
</p>
|
|
183
|
+
</TableCell>
|
|
184
|
+
<TableCell>
|
|
185
|
+
<Badge variant={launchKindTone[d.launch_kind]}>
|
|
186
|
+
{kindNames[d.launch_kind]}
|
|
187
|
+
</Badge>
|
|
188
|
+
{d.emergency_launch && (
|
|
189
|
+
<Badge variant="destructive" className="mt-1 block w-fit">
|
|
190
|
+
{t("Emergency")}
|
|
191
|
+
</Badge>
|
|
224
192
|
)}
|
|
225
|
-
</
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
{t("Установки")}
|
|
282
|
-
</TableHead>
|
|
283
|
-
<TableHead className="text-right">
|
|
284
|
-
{t("Доля")}
|
|
285
|
-
</TableHead>
|
|
286
|
-
</TableRow>
|
|
287
|
-
</TableHeader>
|
|
288
|
-
<TableBody>
|
|
289
|
-
{report.versions.map((v, i) => (
|
|
290
|
-
<TableRow key={i}>
|
|
291
|
-
<TableCell>
|
|
292
|
-
<p
|
|
293
|
-
className="max-w-56 truncate font-medium"
|
|
294
|
-
title={v.update_label || undefined}
|
|
295
|
-
>
|
|
296
|
-
{v.update_label || kindNames[v.launch_kind]}
|
|
297
|
-
</p>
|
|
298
|
-
{v.update_id && (
|
|
299
|
-
<code
|
|
300
|
-
className="mt-1 block text-xs text-muted-foreground"
|
|
301
|
-
title={v.update_id}
|
|
302
|
-
>
|
|
303
|
-
{v.update_id}
|
|
304
|
-
</code>
|
|
305
|
-
)}
|
|
306
|
-
</TableCell>
|
|
307
|
-
<TableCell>
|
|
308
|
-
{v.platform}
|
|
309
|
-
<p className="text-xs text-muted-foreground">
|
|
310
|
-
{v.channel}
|
|
311
|
-
</p>
|
|
312
|
-
</TableCell>
|
|
313
|
-
<TableCell>
|
|
314
|
-
{v.runtime_version}
|
|
315
|
-
<p className="text-xs text-muted-foreground">
|
|
316
|
-
{v.native_version || "—"} ({v.native_build || "—"}
|
|
317
|
-
)
|
|
318
|
-
</p>
|
|
319
|
-
</TableCell>
|
|
320
|
-
<TableCell>
|
|
321
|
-
<Badge variant="secondary">
|
|
322
|
-
{kindNames[v.launch_kind]}
|
|
323
|
-
</Badge>
|
|
324
|
-
</TableCell>
|
|
325
|
-
<TableCell className="text-right tabular-nums">
|
|
326
|
-
{number(v.installations)}
|
|
327
|
-
</TableCell>
|
|
328
|
-
<TableCell className="text-right tabular-nums">
|
|
329
|
-
{percent(v.installations, report.total)}
|
|
330
|
-
</TableCell>
|
|
331
|
-
</TableRow>
|
|
332
|
-
))}
|
|
333
|
-
</TableBody>
|
|
334
|
-
</Table>
|
|
335
|
-
{!report.versions.length && (
|
|
336
|
-
<p className="py-8 text-center text-sm text-muted-foreground">
|
|
337
|
-
{t("Нет версий в выбранной выборке.")}
|
|
338
|
-
</p>
|
|
339
|
-
)}
|
|
340
|
-
</TabsContent>
|
|
341
|
-
</Tabs>
|
|
193
|
+
</TableCell>
|
|
194
|
+
<TableCell className="text-xs tabular-nums">
|
|
195
|
+
{fullDate(d.last_seen_at).replace(" UTC", "")}
|
|
196
|
+
</TableCell>
|
|
197
|
+
</TableRow>
|
|
198
|
+
))}
|
|
199
|
+
</TableBody>
|
|
200
|
+
</Table>
|
|
201
|
+
{!report.devices.length && (
|
|
202
|
+
<div className="flex flex-col items-center gap-2 py-12 text-center">
|
|
203
|
+
<Search className="size-6 text-muted-foreground" />
|
|
204
|
+
<p className="text-sm font-medium">{t("Установки не найдены")}</p>
|
|
205
|
+
<p className="max-w-sm text-xs leading-5 text-muted-foreground">
|
|
206
|
+
{t(
|
|
207
|
+
"Измените фильтры или дождитесь heartbeat от приложения с подключённой телеметрией.",
|
|
208
|
+
)}
|
|
209
|
+
</p>
|
|
210
|
+
</div>
|
|
211
|
+
)}
|
|
212
|
+
<div className="mt-4 flex flex-wrap items-center justify-between gap-3 border-t pt-4">
|
|
213
|
+
<p className="text-xs text-muted-foreground">
|
|
214
|
+
{report.total
|
|
215
|
+
? t("{0}–{1} из {2}", [
|
|
216
|
+
number(report.offset + 1),
|
|
217
|
+
number(
|
|
218
|
+
Math.min(report.offset + report.pageSize, report.total),
|
|
219
|
+
),
|
|
220
|
+
number(report.total),
|
|
221
|
+
])
|
|
222
|
+
: t("0 установок")}
|
|
223
|
+
</p>
|
|
224
|
+
<div className="flex gap-2">
|
|
225
|
+
<Button
|
|
226
|
+
size="sm"
|
|
227
|
+
variant="outline"
|
|
228
|
+
disabled={loading || report.offset === 0}
|
|
229
|
+
onClick={() =>
|
|
230
|
+
paginate(Math.max(0, report.offset - report.pageSize))
|
|
231
|
+
}
|
|
232
|
+
>
|
|
233
|
+
<ChevronLeft />
|
|
234
|
+
{t("Назад")}
|
|
235
|
+
</Button>
|
|
236
|
+
<Button
|
|
237
|
+
size="sm"
|
|
238
|
+
variant="outline"
|
|
239
|
+
disabled={
|
|
240
|
+
loading || report.offset + report.pageSize >= report.total
|
|
241
|
+
}
|
|
242
|
+
onClick={() => paginate(report.offset + report.pageSize)}
|
|
243
|
+
>
|
|
244
|
+
{t("Далее")}
|
|
245
|
+
<ChevronRight />
|
|
246
|
+
</Button>
|
|
247
|
+
</div>
|
|
248
|
+
</div>
|
|
342
249
|
</CardContent>
|
|
343
250
|
</Card>
|
|
344
251
|
<Sheet
|
|
@@ -362,6 +269,24 @@ export function Registry({
|
|
|
362
269
|
)}
|
|
363
270
|
</SheetDescription>
|
|
364
271
|
</SheetHeader>
|
|
272
|
+
{selected && canBookmark && (
|
|
273
|
+
<div className="mx-4 space-y-2 sm:mx-6">
|
|
274
|
+
{personal.error && (
|
|
275
|
+
<p role="alert" className="text-sm text-destructive">
|
|
276
|
+
{t(personal.error)}
|
|
277
|
+
</p>
|
|
278
|
+
)}
|
|
279
|
+
<BookmarkTarget
|
|
280
|
+
platform={selected.platform}
|
|
281
|
+
deviceId={selected.device_id ?? null}
|
|
282
|
+
installationId={selected.installation_id}
|
|
283
|
+
displayName={null}
|
|
284
|
+
showLabel
|
|
285
|
+
favorites={personal.favorites ?? []}
|
|
286
|
+
onChanged={personal.refresh}
|
|
287
|
+
/>
|
|
288
|
+
</div>
|
|
289
|
+
)}
|
|
365
290
|
{selected?.device_id && (
|
|
366
291
|
<DeviceName
|
|
367
292
|
key={selected.device_id}
|
|
@@ -370,7 +295,7 @@ export function Registry({
|
|
|
370
295
|
/>
|
|
371
296
|
)}
|
|
372
297
|
{selected && (
|
|
373
|
-
<dl className="
|
|
298
|
+
<dl className="divide-y px-4 pb-6 sm:px-6">
|
|
374
299
|
{[
|
|
375
300
|
[t("Installation ID"), selected.installation_id],
|
|
376
301
|
[t("Device ID"), selected.device_id || "—"],
|
|
@@ -396,7 +321,10 @@ export function Registry({
|
|
|
396
321
|
fullDate(selected.observed_at),
|
|
397
322
|
],
|
|
398
323
|
].map(([label, value]) => (
|
|
399
|
-
<div
|
|
324
|
+
<div
|
|
325
|
+
key={label}
|
|
326
|
+
className="grid items-start gap-1.5 py-3 sm:grid-cols-[9rem_1fr]"
|
|
327
|
+
>
|
|
400
328
|
<dt className="mb-1 text-xs font-medium text-muted-foreground">
|
|
401
329
|
{label}
|
|
402
330
|
</dt>
|
|
@@ -416,3 +344,88 @@ export function Registry({
|
|
|
416
344
|
</>
|
|
417
345
|
);
|
|
418
346
|
}
|
|
347
|
+
|
|
348
|
+
export function VersionTable({ report }: { report: DevicesReport }) {
|
|
349
|
+
const { t } = useI18n();
|
|
350
|
+
const kindNames = useKindNames();
|
|
351
|
+
const { number, share } = useFormatters();
|
|
352
|
+
return (
|
|
353
|
+
<Card className="min-w-0 gap-4 shadow-none">
|
|
354
|
+
<CardHeader>
|
|
355
|
+
<CardTitle>
|
|
356
|
+
<h2>
|
|
357
|
+
{t("Все версии · ")}
|
|
358
|
+
{number(report.versions.length)}
|
|
359
|
+
</h2>
|
|
360
|
+
</CardTitle>
|
|
361
|
+
<CardDescription>
|
|
362
|
+
{t("Shares across all installations in the selected period.")}
|
|
363
|
+
</CardDescription>
|
|
364
|
+
</CardHeader>
|
|
365
|
+
<CardContent className="min-w-0 px-4 sm:px-6">
|
|
366
|
+
<Table>
|
|
367
|
+
<TableHeader>
|
|
368
|
+
<TableRow>
|
|
369
|
+
<TableHead>{t("Версия / ID")}</TableHead>
|
|
370
|
+
<TableHead>{t("Платформа / канал")}</TableHead>
|
|
371
|
+
<TableHead>{t("Runtime / native")}</TableHead>
|
|
372
|
+
<TableHead>{t("Запуск")}</TableHead>
|
|
373
|
+
<TableHead className="text-right">{t("Установки")}</TableHead>
|
|
374
|
+
<TableHead className="text-right">{t("Доля")}</TableHead>
|
|
375
|
+
</TableRow>
|
|
376
|
+
</TableHeader>
|
|
377
|
+
<TableBody>
|
|
378
|
+
{report.versions.map((v, i) => (
|
|
379
|
+
<TableRow key={i}>
|
|
380
|
+
<TableCell>
|
|
381
|
+
<p
|
|
382
|
+
className="max-w-56 truncate font-medium"
|
|
383
|
+
title={v.update_label || undefined}
|
|
384
|
+
>
|
|
385
|
+
{v.update_label || kindNames[v.launch_kind]}
|
|
386
|
+
</p>
|
|
387
|
+
{v.update_id && (
|
|
388
|
+
<code
|
|
389
|
+
className="mt-1 block text-xs text-muted-foreground"
|
|
390
|
+
title={v.update_id}
|
|
391
|
+
>
|
|
392
|
+
{v.update_id}
|
|
393
|
+
</code>
|
|
394
|
+
)}
|
|
395
|
+
</TableCell>
|
|
396
|
+
<TableCell>
|
|
397
|
+
<div className="flex max-w-52 flex-wrap items-center gap-1">
|
|
398
|
+
<PlatformBadge platform={v.platform} />
|
|
399
|
+
<ChannelBadge channel={v.channel} />
|
|
400
|
+
</div>
|
|
401
|
+
</TableCell>
|
|
402
|
+
<TableCell>
|
|
403
|
+
{v.runtime_version}
|
|
404
|
+
<p className="text-xs text-muted-foreground">
|
|
405
|
+
{v.native_version || "—"} ({v.native_build || "—"})
|
|
406
|
+
</p>
|
|
407
|
+
</TableCell>
|
|
408
|
+
<TableCell>
|
|
409
|
+
<Badge variant={launchKindTone[v.launch_kind]}>
|
|
410
|
+
{kindNames[v.launch_kind]}
|
|
411
|
+
</Badge>
|
|
412
|
+
</TableCell>
|
|
413
|
+
<TableCell className="text-right tabular-nums">
|
|
414
|
+
{number(v.installations)}
|
|
415
|
+
</TableCell>
|
|
416
|
+
<TableCell className="text-right tabular-nums">
|
|
417
|
+
{share(v.installations, report.total)}
|
|
418
|
+
</TableCell>
|
|
419
|
+
</TableRow>
|
|
420
|
+
))}
|
|
421
|
+
</TableBody>
|
|
422
|
+
</Table>
|
|
423
|
+
{!report.versions.length && (
|
|
424
|
+
<p className="py-8 text-center text-sm text-muted-foreground">
|
|
425
|
+
{t("Нет версий в выбранной выборке.")}
|
|
426
|
+
</p>
|
|
427
|
+
)}
|
|
428
|
+
</CardContent>
|
|
429
|
+
</Card>
|
|
430
|
+
);
|
|
431
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, useLayoutEffect } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
|
5
|
+
import { useDevicesReport } from "./use-devices-report";
|
|
6
|
+
|
|
7
|
+
let root: Root;
|
|
8
|
+
let state: ReturnType<typeof useDevicesReport>;
|
|
9
|
+
const fetchReport = vi.fn<typeof fetch>();
|
|
10
|
+
const response = (total: number, offset = 0) =>
|
|
11
|
+
Response.json({
|
|
12
|
+
total,
|
|
13
|
+
offset,
|
|
14
|
+
pageSize: 20,
|
|
15
|
+
options: { channels: [], runtimes: [] },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function Screen() {
|
|
19
|
+
const result = useDevicesReport();
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
state = result;
|
|
22
|
+
});
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
beforeEach(async () => {
|
|
27
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
28
|
+
vi.useFakeTimers();
|
|
29
|
+
fetchReport.mockReset().mockImplementation(async () => response(24));
|
|
30
|
+
vi.stubGlobal("fetch", fetchReport);
|
|
31
|
+
root = createRoot(document.createElement("div"));
|
|
32
|
+
await act(async () => root.render(<Screen />));
|
|
33
|
+
});
|
|
34
|
+
afterEach(async () => {
|
|
35
|
+
await act(async () => root.unmount());
|
|
36
|
+
vi.useRealTimers();
|
|
37
|
+
vi.unstubAllGlobals();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("debounces typing, cancels pending searches on select/reset, and starts filtering at the first page", async () => {
|
|
41
|
+
await act(async () => state.paginate(20));
|
|
42
|
+
await act(async () => state.update("search", "a"));
|
|
43
|
+
await act(async () => state.update("search", "ab"));
|
|
44
|
+
expect(fetchReport).toHaveBeenCalledTimes(2);
|
|
45
|
+
await act(async () => state.update("platform", "ios"));
|
|
46
|
+
const params = new URL(
|
|
47
|
+
String(fetchReport.mock.lastCall![0]),
|
|
48
|
+
"http://localhost",
|
|
49
|
+
).searchParams;
|
|
50
|
+
expect(Object.fromEntries(params)).toEqual({
|
|
51
|
+
days: "7",
|
|
52
|
+
offset: "0",
|
|
53
|
+
search: "ab",
|
|
54
|
+
platform: "ios",
|
|
55
|
+
});
|
|
56
|
+
await act(async () => state.update("search", "abc"));
|
|
57
|
+
await act(async () => state.reset());
|
|
58
|
+
await act(async () => vi.advanceTimersByTimeAsync(500));
|
|
59
|
+
expect(fetchReport).toHaveBeenCalledTimes(4);
|
|
60
|
+
expect(String(fetchReport.mock.lastCall![0])).not.toContain("search=");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("keeps the last success through errors and ignores late responses from aborted requests", async () => {
|
|
64
|
+
let resolveLate!: (value: Response) => void;
|
|
65
|
+
fetchReport.mockImplementationOnce(
|
|
66
|
+
() =>
|
|
67
|
+
new Promise((resolve) => {
|
|
68
|
+
resolveLate = resolve;
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
await act(async () => state.update("days", "1"));
|
|
72
|
+
const signal = fetchReport.mock.lastCall![1]!.signal!;
|
|
73
|
+
await act(async () => state.update("search", "a"));
|
|
74
|
+
expect(signal.aborted).toBe(true);
|
|
75
|
+
fetchReport.mockResolvedValueOnce(
|
|
76
|
+
Response.json({ error: "Temporary outage" }, { status: 503 }),
|
|
77
|
+
);
|
|
78
|
+
await act(async () => vi.advanceTimersByTimeAsync(300));
|
|
79
|
+
expect(state.error).toBe("Temporary outage");
|
|
80
|
+
await act(async () => resolveLate(response(900)));
|
|
81
|
+
expect(state.report?.total).toBe(24);
|
|
82
|
+
expect(state.error).toBe("Temporary outage");
|
|
83
|
+
fetchReport.mockResolvedValueOnce(response(2));
|
|
84
|
+
await act(async () => state.refresh());
|
|
85
|
+
expect(state.report?.total).toBe(2);
|
|
86
|
+
expect(state.error).toBe("");
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("retrieves the last available page when a refresh shrinks the registry", async () => {
|
|
90
|
+
fetchReport
|
|
91
|
+
.mockResolvedValueOnce(response(23, 40))
|
|
92
|
+
.mockResolvedValueOnce(response(23, 20));
|
|
93
|
+
await act(async () => state.paginate(40));
|
|
94
|
+
expect(String(fetchReport.mock.lastCall![0])).toContain("offset=20");
|
|
95
|
+
expect(state.report?.offset).toBe(20);
|
|
96
|
+
await act(async () => state.refresh());
|
|
97
|
+
expect(String(fetchReport.mock.lastCall![0])).toContain("offset=20");
|
|
98
|
+
});
|