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.
Files changed (175) hide show
  1. package/README.md +4 -2
  2. package/dist/template/Dockerfile +4 -6
  3. package/dist/template/README.md +4 -9
  4. package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
  5. package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
  6. package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
  7. package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
  8. package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
  9. package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
  10. package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
  11. package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
  12. package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
  13. package/dist/template/app/api/admin/updates/route.test.ts +21 -0
  14. package/dist/template/app/api/admin/updates/route.ts +12 -1
  15. package/dist/template/app/globals.css +65 -68
  16. package/dist/template/app/login/page.tsx +66 -42
  17. package/dist/template/app/updates/[encodedKey]/page.tsx +375 -263
  18. package/dist/template/app/updates/devices/page.tsx +188 -152
  19. package/dist/template/app/updates/embedded/page.tsx +63 -29
  20. package/dist/template/app/updates/emergency-redirects/page.tsx +93 -58
  21. package/dist/template/app/updates/layout.tsx +2 -1
  22. package/dist/template/app/updates/page.tsx +381 -283
  23. package/dist/template/app/updates/releases.test.tsx +156 -0
  24. package/dist/template/components/admin/admin-role.ts +5 -0
  25. package/dist/template/components/admin/admin-shell.tsx +166 -101
  26. package/dist/template/components/admin/confirm-action.tsx +123 -0
  27. package/dist/template/components/admin/language-switcher.tsx +25 -17
  28. package/dist/template/components/admin/release-badges.test.tsx +50 -0
  29. package/dist/template/components/admin/release-badges.tsx +101 -0
  30. package/dist/template/components/ui/alert.tsx +10 -3
  31. package/dist/template/components/ui/avatar.tsx +108 -0
  32. package/dist/template/components/ui/badge.tsx +2 -2
  33. package/dist/template/components/ui/breadcrumb.tsx +108 -0
  34. package/dist/template/components/ui/button.tsx +5 -5
  35. package/dist/template/components/ui/card.tsx +2 -2
  36. package/dist/template/components/ui/chart.tsx +1 -1
  37. package/dist/template/components/ui/collapsible.tsx +7 -0
  38. package/dist/template/components/ui/empty.tsx +103 -0
  39. package/dist/template/components/ui/field.tsx +248 -0
  40. package/dist/template/components/ui/input-group.tsx +170 -0
  41. package/dist/template/components/ui/input.tsx +1 -1
  42. package/dist/template/components/ui/native-select.tsx +1 -1
  43. package/dist/template/components/ui/radio-group.tsx +41 -0
  44. package/dist/template/components/ui/status-tones.ts +15 -0
  45. package/dist/template/components/ui/table.tsx +1 -1
  46. package/dist/template/components/ui/textarea.tsx +1 -1
  47. package/dist/template/docs/admin-ui.md +7 -3
  48. package/dist/template/docs/device-targeting.md +2 -7
  49. package/dist/template/docs/doctor.md +2 -2
  50. package/dist/template/docs/expo-app-setup.md +9 -27
  51. package/dist/template/docs/getting-started.md +3 -4
  52. package/dist/template/docs/installation-telemetry.md +2 -8
  53. package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
  54. package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
  55. package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
  56. package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
  57. package/dist/template/docs/migrations/schema.sql +349 -0
  58. package/dist/template/docs/npm-installer.md +3 -3
  59. package/dist/template/docs/operations-guide.md +8 -6
  60. package/dist/template/docs/ota-client-lifecycle.md +30 -68
  61. package/dist/template/docs/ota-update-policy.md +9 -20
  62. package/dist/template/docs/ru/admin-ui.md +7 -3
  63. package/dist/template/docs/ru/device-targeting.md +2 -2
  64. package/dist/template/docs/ru/doctor.md +2 -2
  65. package/dist/template/docs/ru/expo-app-setup.md +9 -9
  66. package/dist/template/docs/ru/getting-started.md +3 -3
  67. package/dist/template/docs/ru/installation-telemetry.md +2 -2
  68. package/dist/template/docs/ru/npm-installer.md +3 -3
  69. package/dist/template/docs/ru/operations-guide.md +8 -3
  70. package/dist/template/docs/ru/ota-client-lifecycle.md +30 -35
  71. package/dist/template/docs/ru/ota-update-policy.md +9 -7
  72. package/dist/template/docs/ru/publishing-npm-installer.md +2 -2
  73. package/dist/template/docs/uk/admin-ui.md +7 -3
  74. package/dist/template/docs/uk/device-targeting.md +2 -2
  75. package/dist/template/docs/uk/doctor.md +2 -2
  76. package/dist/template/docs/uk/expo-app-setup.md +9 -9
  77. package/dist/template/docs/uk/getting-started.md +3 -3
  78. package/dist/template/docs/uk/installation-telemetry.md +2 -2
  79. package/dist/template/docs/uk/npm-installer.md +3 -3
  80. package/dist/template/docs/uk/operations-guide.md +8 -3
  81. package/dist/template/docs/uk/ota-client-lifecycle.md +30 -35
  82. package/dist/template/docs/uk/ota-update-policy.md +9 -7
  83. package/dist/template/docs/uk/publishing-npm-installer.md +2 -2
  84. package/dist/template/lib/audience-ids.ts +4 -0
  85. package/dist/template/package-lock.json +46 -0
  86. package/dist/template/package.json +3 -1
  87. package/dist/template/scripts/configure-expo-app.mjs +3 -3
  88. package/dist/template/scripts/create-access-token.mjs +1 -1
  89. package/dist/template/scripts/lib/doctor.mjs +10 -7
  90. package/dist/template/scripts/lib/doctor.test.mjs +7 -5
  91. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
  92. package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
  93. package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
  94. package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
  95. package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
  96. package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
  97. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
  98. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
  99. package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
  100. package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
  101. package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
  102. package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
  103. package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
  104. package/dist/template/scripts/tests/e2e/console.mjs +86 -0
  105. package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
  106. package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
  107. package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
  108. package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
  109. package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
  110. package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
  111. package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
  112. package/dist/template/scripts/tests/e2e/run.mjs +224 -0
  113. package/dist/template/scripts/tests/manifest-identity.sql +7 -5
  114. package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
  115. package/dist/template/src/client/admin-api.ts +45 -10
  116. package/dist/template/src/client/admin-types.ts +35 -1
  117. package/dist/template/src/client/devices/analytics.tsx +168 -231
  118. package/dist/template/src/client/devices/cohorts.tsx +181 -0
  119. package/dist/template/src/client/devices/device-name.tsx +37 -23
  120. package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
  121. package/dist/template/src/client/devices/registry.tsx +258 -245
  122. package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
  123. package/dist/template/src/client/devices/use-devices-report.ts +53 -82
  124. package/dist/template/src/client/devices/version-adoption-chart.tsx +47 -49
  125. package/dist/template/src/client/distribution-control.tsx +89 -57
  126. package/dist/template/src/client/distribution-history.tsx +353 -0
  127. package/dist/template/src/client/guard-action-catalog.tsx +183 -0
  128. package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
  129. package/dist/template/src/client/guard-action-combobox.tsx +133 -239
  130. package/dist/template/src/client/guard-action-options.ts +4 -6
  131. package/dist/template/src/client/i18n/en.json +133 -2
  132. package/dist/template/src/client/i18n/language-switching.test.tsx +12 -3
  133. package/dist/template/src/client/i18n/ru.json +133 -2
  134. package/dist/template/src/client/i18n/uk.json +133 -2
  135. package/dist/template/src/client/logout-button.tsx +3 -3
  136. package/dist/template/src/client/policy-draft.ts +138 -0
  137. package/dist/template/src/client/update-audience-editor.tsx +597 -206
  138. package/dist/template/src/client/update-policy-editor.test.ts +101 -29
  139. package/dist/template/src/client/update-policy-editor.tsx +454 -320
  140. package/dist/template/src/client/use-filtered-results.ts +55 -0
  141. package/dist/template/src/server/controllers/manifest.test.ts +23 -3
  142. package/dist/template/src/server/controllers/manifest.ts +15 -1
  143. package/dist/template/src/server/devices/audience.ts +9 -5
  144. package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
  145. package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
  146. package/dist/template/src/server/lib/admin-updates.ts +160 -534
  147. package/dist/template/src/server/lib/distribution-history.ts +97 -0
  148. package/dist/template/src/server/lib/supabase.js +24 -0
  149. package/dist/template/src/server/lib/supabase.test.ts +38 -1
  150. package/dist/template/src/server/lib/update-policy.test.ts +20 -0
  151. package/dist/template/src/server/lib/update-policy.ts +23 -10
  152. package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
  153. package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
  154. package/dist/template/src/server/manifest/manifest-values.ts +21 -13
  155. package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
  156. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
  157. package/dist/template/tsconfig.json +2 -2
  158. package/dist/template-manifest.json +446 -301
  159. package/package.json +1 -1
  160. package/dist/template/scripts/lib/device-identity.test.ts +0 -29
  161. package/dist/template/scripts/lib/ota-client.test.ts +0 -55
  162. package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
  163. package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
  164. package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
  165. package/dist/template/templates/expo-app/ota-client/README.md +0 -73
  166. package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
  167. package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
  168. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
  169. package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
  170. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
  171. package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
  172. package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
  173. package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
  174. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
  175. package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
@@ -1,4 +1,7 @@
1
1
  "use client";
2
+ import { Skeleton } from "@/components/ui/skeleton";
3
+ import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
4
+ import { useConfirmAction } from "@/components/admin/confirm-action";
2
5
  import type { TranslationMessage } from "@/src/client/i18n/messages";
3
6
  import { useI18n } from "@/src/client/i18n/provider";
4
7
  import { useFormatters } from "@/src/client/i18n/use-formatters";
@@ -23,7 +26,26 @@ import UpdateAudienceEditor from "@/src/client/update-audience-editor";
23
26
  import UpdatePolicyEditor from "@/src/client/update-policy-editor";
24
27
  import Link from "next/link";
25
28
  import { useParams, useRouter } from "next/navigation";
26
- import { useEffect, useMemo, useState } from "react";
29
+ import { useContext, useEffect, useMemo, useState } from "react";
30
+ import {
31
+ ArrowLeft,
32
+ FileJson,
33
+ Radio,
34
+ Users,
35
+ Undo2,
36
+ ShieldAlert,
37
+ Trash2,
38
+ } from "lucide-react";
39
+ import { AdminRoleContext } from "@/components/admin/admin-role";
40
+ import {
41
+ PlatformBadge,
42
+ ChannelBadge,
43
+ ReleaseStatusBadge,
44
+ AudienceBadge,
45
+ DeliveryBadge,
46
+ } from "@/components/admin/release-badges";
47
+ import { Badge } from "@/components/ui/badge";
48
+ import { Tabs, TabsList, TabsContent, TabsTrigger } from "@/components/ui/tabs";
27
49
  import {
28
50
  DistributionControlBanner,
29
51
  useDistributionControlState,
@@ -40,8 +62,11 @@ function prettyJson(value: unknown): string {
40
62
  }
41
63
 
42
64
  export default function UpdateDetailsPage() {
65
+ const confirmAction = useConfirmAction();
43
66
  const { t } = useI18n();
44
67
  const { fullDate } = useFormatters();
68
+ const role = useContext(AdminRoleContext);
69
+ const canWrite = role === "operator" || role === "admin";
45
70
  const params = useParams<{ encodedKey: string }>();
46
71
  const router = useRouter();
47
72
  const encodedKey = params.encodedKey;
@@ -77,51 +102,39 @@ export default function UpdateDetailsPage() {
77
102
  const rollbackActive =
78
103
  Boolean(activeUpdateId) && activeUpdateId !== latestUpdateId;
79
104
 
80
- const newestUpdateId =
81
- detail?.channelLatest &&
82
- typeof detail.channelLatest.newestUpdateId === "string"
83
- ? detail.channelLatest.newestUpdateId
84
- : null;
85
-
86
105
  const currentServedUpdateId = activeUpdateId || latestUpdateId;
87
- const isNewestInScope = Boolean(
88
- detail?.updateId &&
89
- newestUpdateId &&
90
- detail.updateId === newestUpdateId,
91
- );
92
106
 
93
107
  return {
94
108
  latestUpdateId,
95
109
  activeUpdateId,
96
110
  rollbackActive,
97
- newestUpdateId,
98
111
  currentServedUpdateId,
99
- isNewestInScope,
112
+ isNewestInScope:
113
+ detail?.isNewestInScope ??
114
+ (Boolean(detail?.updateId) &&
115
+ detail?.channelLatest?.newestUpdateId === detail?.updateId),
100
116
  };
101
117
  }, [detail]);
102
118
 
103
119
  const canPromote = Boolean(
104
- !distributionBlocked &&
105
- channelState.isNewestInScope &&
106
- channelState.rollbackActive,
120
+ !distributionBlocked && detail?.isLatest && channelState.rollbackActive,
107
121
  );
108
122
  const canRollback = Boolean(
109
123
  detail &&
110
- !distributionBlocked &&
111
- !channelState.isNewestInScope &&
112
- channelState.currentServedUpdateId &&
113
- detail.updateId !== channelState.currentServedUpdateId,
124
+ !distributionBlocked &&
125
+ !channelState.isNewestInScope &&
126
+ channelState.currentServedUpdateId &&
127
+ detail.updateId !== channelState.currentServedUpdateId,
114
128
  );
115
129
  const canToggleDisabled = Boolean(
116
- detail &&
117
- !(channelState.rollbackActive && channelState.isNewestInScope),
130
+ detail && !(channelState.rollbackActive && channelState.isNewestInScope),
118
131
  );
119
132
  const canDirectActivate = Boolean(
120
133
  detail &&
121
- !distributionBlocked &&
122
- detail.status === "disabled" &&
123
- channelState.isNewestInScope &&
124
- !channelState.rollbackActive,
134
+ !distributionBlocked &&
135
+ detail.status === "disabled" &&
136
+ channelState.isNewestInScope &&
137
+ !channelState.rollbackActive,
125
138
  );
126
139
  const canDirectDeactivate = Boolean(
127
140
  detail && detail.status !== "disabled" && canToggleDisabled,
@@ -175,24 +188,23 @@ export default function UpdateDetailsPage() {
175
188
  }, [fileContent]);
176
189
 
177
190
  useEffect(() => {
178
- const loadDetail = async () => {
179
- setLoading(true);
180
- setError("");
181
- setSuccess("");
182
-
183
- try {
184
- const response = await getUpdate(encodedKey);
185
- setDetail(response);
186
- } catch (loadError: unknown) {
187
- setError(
188
- (loadError as Error).message || "Не удалось загрузить детали",
189
- );
190
- } finally {
191
- setLoading(false);
192
- }
193
- };
194
-
195
- void loadDetail();
191
+ const controller = new AbortController();
192
+ setDetail(null);
193
+ setLoading(true);
194
+ setError("");
195
+ setSuccess("");
196
+ getUpdate(encodedKey, controller.signal)
197
+ .then((next) => {
198
+ if (!controller.signal.aborted) setDetail(next);
199
+ })
200
+ .catch((e: Error) => {
201
+ if (!controller.signal.aborted)
202
+ setError(e.message || "Не удалось загрузить детали");
203
+ })
204
+ .finally(() => {
205
+ if (!controller.signal.aborted) setLoading(false);
206
+ });
207
+ return () => controller.abort();
196
208
  }, [encodedKey]);
197
209
 
198
210
  const reload = async () => {
@@ -225,10 +237,12 @@ export default function UpdateDetailsPage() {
225
237
  };
226
238
 
227
239
  const handleRollback = async () => {
228
- const confirmed = window.confirm(
240
+ const confirmed = await confirmAction(
241
+ t("Rollback"),
229
242
  t(
230
243
  "Вы действительно хотите начать распространение предыдущей версии обновления?",
231
244
  ),
245
+ true,
232
246
  );
233
247
  if (!confirmed) {
234
248
  return;
@@ -249,7 +263,8 @@ export default function UpdateDetailsPage() {
249
263
  };
250
264
 
251
265
  const handlePromote = async () => {
252
- const confirmed = window.confirm(
266
+ const confirmed = await confirmAction(
267
+ t("Promote"),
253
268
  t("Вернуть распространение к последнему апдейту (promote)?"),
254
269
  );
255
270
  if (!confirmed) {
@@ -284,9 +299,7 @@ export default function UpdateDetailsPage() {
284
299
  await reload();
285
300
  setSuccess(disabled ? "Апдейт деактивирован" : "Апдейт активирован");
286
301
  } catch (toggleError: unknown) {
287
- setError(
288
- (toggleError as Error).message || "Не удалось изменить статус",
289
- );
302
+ setError((toggleError as Error).message || "Не удалось изменить статус");
290
303
  } finally {
291
304
  setSaving(false);
292
305
  }
@@ -298,8 +311,10 @@ export default function UpdateDetailsPage() {
298
311
  return;
299
312
  }
300
313
 
301
- const confirmed = window.confirm(
314
+ const confirmed = await confirmAction(
315
+ t("Удалить апдейт"),
302
316
  t("Удалить апдейт полностью из bucket?"),
317
+ true,
303
318
  );
304
319
  if (!confirmed) {
305
320
  return;
@@ -313,47 +328,61 @@ export default function UpdateDetailsPage() {
313
328
  await deleteUpdate(encodedKey);
314
329
  router.replace("/updates");
315
330
  } catch (deleteError: unknown) {
316
- setError(
317
- (deleteError as Error).message || "Не удалось удалить апдейт",
318
- );
331
+ setError((deleteError as Error).message || "Не удалось удалить апдейт");
319
332
  setSaving(false);
320
333
  }
321
334
  };
322
335
 
323
336
  return (
324
- <div className="mx-auto max-w-[1600px] space-y-6 p-4 md:p-8">
325
- <div className="space-y-6">
326
- <header className="space-y-2">
337
+ <div className="mx-auto max-w-[1500px] space-y-5 p-4 sm:p-6 lg:p-8">
338
+ <div className="space-y-5">
339
+ <header className="space-y-3">
327
340
  <Link
328
341
  href="/updates"
329
- className="inline-flex items-center text-xs text-muted-foreground hover:text-primary"
342
+ className="inline-flex items-center gap-1.5 rounded-sm text-sm text-muted-foreground hover:text-foreground"
330
343
  >
331
- {t("← Все обновления")}
344
+ <ArrowLeft className="size-4" />
345
+ {t("Публикации")}
332
346
  </Link>
333
- <h1 className="text-2xl font-semibold tracking-tight">
334
- {t("Детали обновления")}
335
- </h1>
336
- <p className="text-sm text-muted-foreground">
337
- {t("Метаданные, политика доставки и управление публикацией.")}
338
- </p>
347
+ <div className="flex flex-wrap items-center gap-2">
348
+ <h1 className="break-words text-3xl font-semibold tracking-tight">
349
+ {detail?.comment ||
350
+ (detail?.appVersion
351
+ ? t("Version {0}", [detail.appVersion])
352
+ : t("Детали обновления"))}
353
+ </h1>
354
+ {detail && <ReleaseStatusBadge release={detail} />}
355
+ {detail?.isLatest && <Badge variant="info">{t("Latest")}</Badge>}
356
+ {!canWrite && <Badge variant="neutral">{t("Read only")}</Badge>}
357
+ </div>
358
+ {detail && (
359
+ <div className="flex min-w-0 flex-wrap items-center gap-2 text-sm text-muted-foreground">
360
+ <PlatformBadge platform={detail.platform} />
361
+ <ChannelBadge channel={detail.channel} />
362
+ <span className="break-all">
363
+ {t("Runtime {0}", [detail.runtimeVersion])}
364
+ </span>
365
+ <span>· {fullDate(detail.createdAt)}</span>
366
+ </div>
367
+ )}
339
368
  </header>
340
369
 
341
370
  {loading ? (
342
- <div className="rounded-xl border border-border bg-card p-5 ">
343
- {t("Загрузка...")}
344
- </div>
371
+ <Skeleton className="h-16" role="status">
372
+ <span className="sr-only">{t("Загрузка...")}</span>
373
+ </Skeleton>
345
374
  ) : null}
346
375
 
347
376
  {error ? (
348
- <div className="rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300">
349
- {t(error)}
350
- </div>
377
+ <Alert variant="destructive">
378
+ <AlertDescription>{t(error)}</AlertDescription>
379
+ </Alert>
351
380
  ) : null}
352
381
 
353
382
  {success ? (
354
- <div className="rounded-md border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950/40 dark:text-emerald-300">
355
- {t(success)}
356
- </div>
383
+ <Alert role="status">
384
+ <AlertDescription>{t(success)}</AlertDescription>
385
+ </Alert>
357
386
  ) : null}
358
387
 
359
388
  <DistributionControlBanner
@@ -365,212 +394,295 @@ export default function UpdateDetailsPage() {
365
394
  {!loading && detail ? (
366
395
  <>
367
396
  {channelState.rollbackActive ? (
368
- <section className="rounded-xl border border-orange-300 bg-orange-50 p-4 dark:border-orange-700 dark:bg-orange-950/30">
369
- <p className="text-sm font-medium text-orange-900 dark:text-orange-200">
397
+ <Alert variant="destructive" role="status">
398
+ <Undo2 aria-hidden="true" />
399
+ <AlertTitle>
370
400
  {t("⚠️ Rollback активен в этом канале/платформе.")}
371
- </p>
372
- <p className="mt-1 text-xs text-orange-800 dark:text-orange-300">
401
+ </AlertTitle>
402
+ <AlertDescription>
373
403
  {t("Сейчас раздаётся updateId: ")}
374
404
  {channelState.activeUpdateId}
375
- </p>
376
- <p className="mt-1 text-xs text-orange-800 dark:text-orange-300">
405
+ </AlertDescription>
406
+ <AlertDescription>
377
407
  {t(
378
408
  "Новые апдейты автоматически игнорируются до выполнения Promote.",
379
409
  )}
380
- </p>
381
- </section>
410
+ </AlertDescription>
411
+ </Alert>
382
412
  ) : null}
383
413
 
384
414
  {detail.isIgnoredByRollback ? (
385
- <section className="rounded-xl border border-border bg-muted/30 p-4 ">
386
- <p className="text-sm font-medium text-foreground">
415
+ <Alert variant="warning" role="status">
416
+ <ShieldAlert aria-hidden="true" />
417
+ <AlertTitle>
387
418
  {t("Этот апдейт сейчас не доставляется.")}
388
- </p>
389
- <p className="mt-1 text-xs text-muted-foreground">
419
+ </AlertTitle>
420
+ <AlertDescription>
390
421
  {t(
391
422
  "Причина: активен rollback, автодоставка новых апдейтов выключена.",
392
423
  )}
393
- </p>
394
- </section>
424
+ </AlertDescription>
425
+ </Alert>
395
426
  ) : null}
396
427
 
397
- <Card className="grid gap-4 rounded-xl border border-border bg-card p-5 md:grid-cols-2 lg:grid-cols-4 shadow-none">
398
- <Info label={t("Runtime")} value={detail.runtimeVersion} />
399
- <Info label={t("Platform")} value={detail.platform} />
400
- <Info label={t("Channel")} value={detail.channel} />
401
- <Info label={t("Stage")} value={detail.stage} />
402
- <Info
403
- label={t("Created")}
404
- value={
405
- detail.createdAt
406
- ? fullDate(detail.createdAt)
407
- : detail.createdAtPath
408
- }
409
- />
410
- <Info label={t("Status")} value={t(detail.status)} />
411
- <Info
412
- label={t("Latest")}
413
- value={detail.isLatest ? t("Да") : t("Нет")}
414
- />
415
- <Info
416
- label={t("Rollback")}
417
- value={detail.isRollbackActive ? t("Активен") : t("Нет")}
418
- />
419
- <Info
420
- label={t("Доставка")}
421
- value={
422
- detail.isIgnoredByRollback
423
- ? t("Ignored by rollback")
424
- : detail.deliveryMode === "background"
425
- ? t("Background")
426
- : t("Manual")
427
- }
428
- />
429
- <Info
430
- label={t("Guard")}
431
- value={detail.hasGuard ? t("Yes") : t("None")}
432
- />
433
- <Info
434
- label={t("Policy")}
435
- value={`v${detail.policyVersion} · ${detail.policyEditable ? t("draft") : t("published")}`}
436
- />
437
- <Info
438
- label={t("Assets")}
439
- value={String(detail.assetsCount)}
440
- />
441
- <Info
442
- label={t("Update ID")}
443
- value={detail.updateId}
444
- className="md:col-span-2 lg:col-span-2"
445
- />
446
- <Info
447
- label={t("Комментарий")}
448
- value={detail.comment || "-"}
449
- className="md:col-span-2 lg:col-span-2"
450
- />
451
- <Info
452
- label={t("Активный update ID")}
453
- value={channelState.activeUpdateId || "-"}
454
- className="md:col-span-2 lg:col-span-2"
455
- />
456
- </Card>
457
-
458
- <UpdateAudienceEditor
459
- key={encodedKey}
460
- encodedKey={encodedKey}
461
- platform={detail.platform}
462
- />
463
- <UpdatePolicyEditor
464
- key={`${encodedKey}-${detail.policyVersion}-${detail.policyPublishedAt || "draft"}`}
465
- encodedKey={encodedKey}
466
- onSaved={reload}
467
- />
468
-
469
- <Card className="gap-4 p-5 shadow-none">
470
- <div className="flex flex-wrap gap-2">
471
- {canRollback ? (
472
- <Button
473
- variant="outline"
474
- size="sm"
475
- type="button"
476
- onClick={handleRollback}
477
- disabled={saving}
478
- >
479
- {t("Rollback")}
480
- </Button>
481
- ) : null}
482
- {canPromote ? (
483
- <Button
484
- variant="default"
485
- size="sm"
486
- type="button"
487
- onClick={handlePromote}
488
- disabled={saving}
489
- >
490
- {t("Promote")}
491
- </Button>
492
- ) : null}
493
- {showToggleDisabledButton ? (
494
- <Button
495
- variant="outline"
496
- size="sm"
497
- type="button"
498
- onClick={handleToggleDisabled}
499
- disabled={saving}
500
- >
501
- {detail.status === "disabled"
502
- ? t("Активировать")
503
- : t("Деактивировать")}
504
- </Button>
505
- ) : null}
506
- {canDelete ? (
507
- <Button
508
- variant="destructive"
509
- size="sm"
510
- type="button"
511
- onClick={handleDelete}
512
- disabled={saving}
513
- >
514
- {t("Удалить апдейт")}
515
- </Button>
516
- ) : null}
517
- </div>
518
- </Card>
519
-
520
- <Card className="gap-4 p-5 shadow-none">
521
- <div className="flex flex-wrap items-center gap-2">
522
- <label className="text-sm">{t("JSON файл")}</label>
523
- <NativeSelect
524
- value={selectedFile}
525
- onChange={(event) =>
526
- setSelectedFile(event.target.value as EditableFile)
428
+ <Card className="gap-4 py-0 shadow-none">
429
+ <div className="grid gap-4 p-4 sm:grid-cols-3 sm:p-5">
430
+ <Info
431
+ label={t("Audience")}
432
+ value={<AudienceBadge mode={detail.audienceMode} />}
433
+ />
434
+ <Info
435
+ label={t("Доставка")}
436
+ value={
437
+ detail.isIgnoredByRollback ? (
438
+ <Badge variant="warning">
439
+ {t("Ignored by rollback")}
440
+ </Badge>
441
+ ) : (
442
+ <DeliveryBadge mode={detail.deliveryMode} />
443
+ )
527
444
  }
528
- aria-label={t("Выбор JSON файла")}
529
- className="rounded-md border border-input bg-background px-2 py-2 text-sm "
530
- >
531
- <option value="update-info.json">update-info.json</option>
532
- <option value="update-meta.json">update-meta.json</option>
533
- <option value="metadata.json">metadata.json</option>
534
- <option value="channel-latest.json">
535
- channel latest.json
536
- </option>
537
- </NativeSelect>
538
- <Button
539
- variant="outline"
540
- size="sm"
541
- type="button"
542
- onClick={handleSaveJson}
543
- disabled={
544
- saving ||
545
- channelLatestLocked ||
546
- updateMetaDistributionLocked
547
- }
548
- >
549
- {t("Сохранить JSON")}
550
- </Button>
445
+ />
446
+ <Info label={t("Update ID")} value={detail.updateId} />
551
447
  </div>
552
- {channelLatestLocked ? (
553
- <p className="mt-2 text-xs text-orange-700 dark:text-orange-300">
554
- {t(
555
- "Редактирование channel latest.json заблокировано: активен rollback или глобальный аварийный выключатель.",
556
- )}
557
- </p>
558
- ) : null}
559
- {updateMetaDistributionLocked ? (
560
- <p className="mt-2 text-xs text-red-700 dark:text-red-300">
561
- {t(
562
- "Активация через update-meta.json недоступна при глобальной блокировке. Деактивация с isActive=false остаётся доступна.",
563
- )}
564
- </p>
565
- ) : null}
566
- <Textarea
567
- value={editorValue}
568
- onChange={(event) => setEditorValue(event.target.value)}
569
- aria-label={t("Редактор JSON")}
570
- className="mt-3 h-120 w-full rounded-md border border-border bg-muted/30 p-3 font-mono text-xs outline-none ring-blue-500 focus:ring-2 "
571
- spellCheck={false}
572
- />
448
+ {canWrite &&
449
+ (canRollback || canPromote || showToggleDisabledButton) && (
450
+ <div className="flex flex-wrap items-center gap-2 border-t bg-muted/20 px-4 py-3 sm:px-5">
451
+ {canRollback ? (
452
+ <Button
453
+ variant="destructive"
454
+ size="sm"
455
+ type="button"
456
+ onClick={handleRollback}
457
+ disabled={saving}
458
+ >
459
+ <Undo2 aria-hidden="true" />
460
+ {t("Rollback")}
461
+ </Button>
462
+ ) : null}
463
+ {canPromote ? (
464
+ <Button
465
+ variant="default"
466
+ size="sm"
467
+ type="button"
468
+ onClick={handlePromote}
469
+ disabled={saving}
470
+ >
471
+ {t("Promote")}
472
+ </Button>
473
+ ) : null}
474
+ {showToggleDisabledButton ? (
475
+ <Button
476
+ variant={
477
+ detail.status === "disabled" ? "default" : "outline"
478
+ }
479
+ size="sm"
480
+ type="button"
481
+ onClick={handleToggleDisabled}
482
+ disabled={saving}
483
+ >
484
+ {detail.status === "disabled"
485
+ ? t("Активировать")
486
+ : t("Деактивировать")}
487
+ </Button>
488
+ ) : null}
489
+ </div>
490
+ )}
573
491
  </Card>
492
+ <Tabs
493
+ defaultValue="audience"
494
+ key={encodedKey}
495
+ className="min-w-0 gap-4"
496
+ >
497
+ <TabsList
498
+ aria-label={t("Release sections")}
499
+ variant="line"
500
+ className="max-w-full justify-start border-b"
501
+ >
502
+ <TabsTrigger value="audience">
503
+ <Users className="hidden size-4 sm:block" />
504
+ {t("Audience")}
505
+ </TabsTrigger>
506
+ <TabsTrigger value="policy">
507
+ <Radio className="hidden size-4 sm:block" />
508
+ {t("Policy")}
509
+ </TabsTrigger>
510
+ <TabsTrigger value="metadata">
511
+ <FileJson className="hidden size-4 sm:block" />
512
+ {t("Metadata")}
513
+ </TabsTrigger>
514
+ </TabsList>
515
+ <TabsContent
516
+ value="audience"
517
+ forceMount
518
+ className="data-[state=inactive]:hidden"
519
+ >
520
+ <UpdateAudienceEditor
521
+ key={encodedKey}
522
+ channel={detail.channel}
523
+ runtime={detail.runtimeVersion}
524
+ active={detail.status === "active"}
525
+ encodedKey={encodedKey}
526
+ platform={detail.platform}
527
+ canWrite={canWrite}
528
+ onSaved={(mode) =>
529
+ setDetail(
530
+ (current) =>
531
+ current && { ...current, audienceMode: mode },
532
+ )
533
+ }
534
+ />
535
+ </TabsContent>
536
+ <TabsContent
537
+ value="policy"
538
+ forceMount
539
+ className="data-[state=inactive]:hidden"
540
+ >
541
+ <UpdatePolicyEditor
542
+ key={`${encodedKey}-${detail.policyPublishedAt || "draft"}`}
543
+ platform={detail.platform}
544
+ encodedKey={encodedKey}
545
+ onSaved={reload}
546
+ />
547
+ </TabsContent>
548
+ <TabsContent value="metadata" className="space-y-4">
549
+ <Card className="grid gap-4 p-5 shadow-none sm:grid-cols-2 lg:grid-cols-4">
550
+ <Info label={t("Runtime")} value={detail.runtimeVersion} />
551
+ <Info label={t("Platform")} value={detail.platform} />
552
+ <Info label={t("Channel")} value={detail.channel} />
553
+ <Info
554
+ label={t("Created")}
555
+ value={
556
+ detail.createdAt
557
+ ? fullDate(detail.createdAt)
558
+ : detail.createdAtPath
559
+ }
560
+ />
561
+ <Info label={t("Status")} value={t(detail.status)} />
562
+ <Info
563
+ label={t("Latest")}
564
+ value={detail.isLatest ? t("Да") : t("Нет")}
565
+ />
566
+ <Info
567
+ label={t("Rollback")}
568
+ value={detail.isRollbackActive ? t("Активен") : t("Нет")}
569
+ />
570
+ <Info
571
+ label={t("Доставка")}
572
+ value={
573
+ detail.isIgnoredByRollback
574
+ ? t("Ignored by rollback")
575
+ : detail.deliveryMode === "manual-postpone"
576
+ ? t("Download on postpone")
577
+ : detail.deliveryMode === "background"
578
+ ? t("Background")
579
+ : t("Manual")
580
+ }
581
+ />
582
+ <Info
583
+ label={t("Guard")}
584
+ value={detail.hasGuard ? t("Yes") : t("None")}
585
+ />
586
+ <Info
587
+ label={t("Policy")}
588
+ value={`v${detail.policyVersion} · ${detail.policyEditable ? t("draft") : t("published")}`}
589
+ />
590
+ <Info
591
+ label={t("Assets")}
592
+ value={String(detail.assetsCount)}
593
+ />
594
+ <Info
595
+ label={t("Update ID")}
596
+ value={detail.updateId}
597
+ className="md:col-span-2 lg:col-span-2"
598
+ />
599
+ <Info
600
+ label={t("Комментарий")}
601
+ value={detail.comment || "-"}
602
+ className="md:col-span-2 lg:col-span-2"
603
+ />
604
+ <Info
605
+ label={t("Активный update ID")}
606
+ value={channelState.activeUpdateId || "-"}
607
+ className="md:col-span-2 lg:col-span-2"
608
+ />
609
+ </Card>
610
+ <Card className="gap-3 p-5 shadow-none">
611
+ <div className="flex flex-wrap items-center gap-2">
612
+ <label className="text-sm">{t("JSON файл")}</label>
613
+ <NativeSelect
614
+ value={selectedFile}
615
+ onChange={(event) =>
616
+ setSelectedFile(event.target.value as EditableFile)
617
+ }
618
+ aria-label={t("Выбор JSON файла")}
619
+ className="rounded-md border border-input bg-background px-2 py-2 text-sm "
620
+ >
621
+ <option value="update-info.json">update-info.json</option>
622
+ <option value="update-meta.json">update-meta.json</option>
623
+ <option value="metadata.json">metadata.json</option>
624
+ <option value="channel-latest.json">
625
+ channel latest.json
626
+ </option>
627
+ </NativeSelect>
628
+ {canWrite && (
629
+ <Button
630
+ variant="outline"
631
+ size="sm"
632
+ type="button"
633
+ onClick={handleSaveJson}
634
+ disabled={
635
+ saving ||
636
+ channelLatestLocked ||
637
+ updateMetaDistributionLocked
638
+ }
639
+ >
640
+ {t("Сохранить JSON")}
641
+ </Button>
642
+ )}
643
+ </div>
644
+ {channelLatestLocked ? (
645
+ <p className="mt-2 text-xs text-orange-700 dark:text-orange-300">
646
+ {t(
647
+ "Редактирование channel latest.json заблокировано: активен rollback или глобальный аварийный выключатель.",
648
+ )}
649
+ </p>
650
+ ) : null}
651
+ {updateMetaDistributionLocked ? (
652
+ <p className="mt-2 text-xs text-red-700 dark:text-red-300">
653
+ {t(
654
+ "Активация через update-meta.json недоступна при глобальной блокировке. Деактивация с isActive=false остаётся доступна.",
655
+ )}
656
+ </p>
657
+ ) : null}
658
+ <Textarea
659
+ value={editorValue}
660
+ readOnly={!canWrite}
661
+ onChange={(event) => setEditorValue(event.target.value)}
662
+ aria-label={t("Редактор JSON")}
663
+ className="mt-3 h-120 w-full rounded-md border border-border bg-muted/30 p-3 font-mono text-xs outline-none ring-blue-500 focus:ring-2 "
664
+ spellCheck={false}
665
+ />
666
+ </Card>
667
+ {canWrite && canDelete ? (
668
+ <div className="flex flex-wrap items-center justify-between gap-3 rounded-lg border border-destructive/35 bg-destructive/5 p-4">
669
+ <p className="text-sm text-foreground">
670
+ {t("Delete this release and its files from storage.")}
671
+ </p>
672
+ <Button
673
+ variant="destructive"
674
+ size="sm"
675
+ type="button"
676
+ onClick={handleDelete}
677
+ disabled={saving}
678
+ >
679
+ <Trash2 aria-hidden="true" />
680
+ {t("Удалить апдейт")}
681
+ </Button>
682
+ </div>
683
+ ) : null}
684
+ </TabsContent>
685
+ </Tabs>
574
686
  </>
575
687
  ) : null}
576
688
  </div>
@@ -584,7 +696,7 @@ function Info({
584
696
  className,
585
697
  }: {
586
698
  label: string;
587
- value: string;
699
+ value: React.ReactNode;
588
700
  className?: string;
589
701
  }) {
590
702
  return (