create-expo-updates-server 0.3.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 (191) hide show
  1. package/README.md +4 -2
  2. package/dist/template/Dockerfile +4 -6
  3. package/dist/template/README.md +5 -10
  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 +382 -248
  18. package/dist/template/app/updates/devices/page.tsx +187 -145
  19. package/dist/template/app/updates/embedded/page.tsx +80 -34
  20. package/dist/template/app/updates/emergency-redirects/page.tsx +138 -71
  21. package/dist/template/app/updates/layout.tsx +2 -1
  22. package/dist/template/app/updates/page.tsx +385 -274
  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 -95
  26. package/dist/template/components/admin/confirm-action.tsx +123 -0
  27. package/dist/template/components/admin/language-switcher.tsx +27 -16
  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/dialog.tsx +13 -4
  39. package/dist/template/components/ui/empty.tsx +103 -0
  40. package/dist/template/components/ui/field.tsx +248 -0
  41. package/dist/template/components/ui/input-group.tsx +170 -0
  42. package/dist/template/components/ui/input.tsx +1 -1
  43. package/dist/template/components/ui/native-select.tsx +1 -1
  44. package/dist/template/components/ui/radio-group.tsx +41 -0
  45. package/dist/template/components/ui/sheet.tsx +6 -2
  46. package/dist/template/components/ui/sidebar.tsx +62 -17
  47. package/dist/template/components/ui/status-tones.ts +15 -0
  48. package/dist/template/components/ui/table.tsx +1 -1
  49. package/dist/template/components/ui/textarea.tsx +1 -1
  50. package/dist/template/docs/admin-ui.md +22 -24
  51. package/dist/template/docs/device-targeting.md +6 -12
  52. package/dist/template/docs/doctor.md +2 -2
  53. package/dist/template/docs/expo-app-setup.md +9 -27
  54. package/dist/template/docs/getting-started.md +3 -4
  55. package/dist/template/docs/getting-started.ru.md +11 -544
  56. package/dist/template/docs/index.md +1 -1
  57. package/dist/template/docs/installation-telemetry.md +6 -12
  58. package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
  59. package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
  60. package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
  61. package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
  62. package/dist/template/docs/migrations/schema.sql +349 -0
  63. package/dist/template/docs/npm-installer.md +3 -3
  64. package/dist/template/docs/operations-guide.md +9 -7
  65. package/dist/template/docs/ota-client-lifecycle.md +30 -68
  66. package/dist/template/docs/ota-emergency-recovery.md +34 -57
  67. package/dist/template/docs/ota-update-policy.md +9 -20
  68. package/dist/template/docs/ru/admin-ui.md +33 -0
  69. package/dist/template/docs/ru/device-targeting.md +59 -0
  70. package/dist/template/docs/ru/doctor.md +98 -0
  71. package/dist/template/docs/ru/expo-app-setup.md +497 -0
  72. package/dist/template/docs/ru/getting-started.md +391 -0
  73. package/dist/template/docs/ru/index.md +50 -0
  74. package/dist/template/docs/ru/installation-telemetry.md +125 -0
  75. package/dist/template/docs/ru/npm-installer.md +71 -0
  76. package/dist/template/docs/ru/operations-guide.md +322 -0
  77. package/dist/template/docs/ru/ota-client-lifecycle.md +162 -0
  78. package/dist/template/docs/ru/ota-emergency-recovery.md +108 -0
  79. package/dist/template/docs/ru/ota-update-policy.md +69 -0
  80. package/dist/template/docs/ru/publishing-npm-installer.md +49 -0
  81. package/dist/template/docs/ru/supabase-setup.md +120 -0
  82. package/dist/template/docs/uk/admin-ui.md +33 -0
  83. package/dist/template/docs/uk/device-targeting.md +59 -0
  84. package/dist/template/docs/uk/doctor.md +98 -0
  85. package/dist/template/docs/uk/expo-app-setup.md +497 -0
  86. package/dist/template/docs/uk/getting-started.md +391 -0
  87. package/dist/template/docs/uk/index.md +50 -0
  88. package/dist/template/docs/uk/installation-telemetry.md +125 -0
  89. package/dist/template/docs/uk/npm-installer.md +71 -0
  90. package/dist/template/docs/uk/operations-guide.md +322 -0
  91. package/dist/template/docs/uk/ota-client-lifecycle.md +162 -0
  92. package/dist/template/docs/uk/ota-emergency-recovery.md +108 -0
  93. package/dist/template/docs/uk/ota-update-policy.md +69 -0
  94. package/dist/template/docs/uk/publishing-npm-installer.md +49 -0
  95. package/dist/template/docs/uk/supabase-setup.md +120 -0
  96. package/dist/template/lib/audience-ids.ts +4 -0
  97. package/dist/template/package-lock.json +46 -0
  98. package/dist/template/package.json +4 -1
  99. package/dist/template/scripts/configure-expo-app.mjs +3 -3
  100. package/dist/template/scripts/create-access-token.mjs +1 -1
  101. package/dist/template/scripts/lib/doctor.mjs +10 -7
  102. package/dist/template/scripts/lib/doctor.test.mjs +7 -5
  103. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
  104. package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
  105. package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
  106. package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
  107. package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
  108. package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
  109. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
  110. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
  111. package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
  112. package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
  113. package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
  114. package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
  115. package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
  116. package/dist/template/scripts/tests/e2e/console.mjs +86 -0
  117. package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
  118. package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
  119. package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
  120. package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
  121. package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
  122. package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
  123. package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
  124. package/dist/template/scripts/tests/e2e/run.mjs +224 -0
  125. package/dist/template/scripts/tests/manifest-identity.sql +7 -5
  126. package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
  127. package/dist/template/src/client/admin-api.ts +45 -10
  128. package/dist/template/src/client/admin-types.ts +35 -1
  129. package/dist/template/src/client/devices/analytics.tsx +169 -219
  130. package/dist/template/src/client/devices/cohorts.tsx +181 -0
  131. package/dist/template/src/client/devices/device-name.tsx +37 -21
  132. package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
  133. package/dist/template/src/client/devices/registry.tsx +265 -233
  134. package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
  135. package/dist/template/src/client/devices/use-devices-report.ts +53 -82
  136. package/dist/template/src/client/devices/version-adoption-chart.tsx +48 -38
  137. package/dist/template/src/client/distribution-control.tsx +98 -53
  138. package/dist/template/src/client/distribution-history.tsx +353 -0
  139. package/dist/template/src/client/guard-action-catalog.tsx +183 -0
  140. package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
  141. package/dist/template/src/client/guard-action-combobox.tsx +134 -234
  142. package/dist/template/src/client/guard-action-options.ts +4 -6
  143. package/dist/template/src/client/i18n/en.json +335 -2
  144. package/dist/template/src/client/i18n/language-switching.test.tsx +233 -0
  145. package/dist/template/src/client/i18n/messages.test.ts +102 -19
  146. package/dist/template/src/client/i18n/messages.ts +31 -16
  147. package/dist/template/src/client/i18n/provider.tsx +6 -3
  148. package/dist/template/src/client/i18n/ru.json +619 -0
  149. package/dist/template/src/client/i18n/uk.json +619 -0
  150. package/dist/template/src/client/i18n/use-formatters.ts +5 -0
  151. package/dist/template/src/client/logout-button.tsx +3 -3
  152. package/dist/template/src/client/policy-draft.ts +138 -0
  153. package/dist/template/src/client/update-audience-editor.tsx +597 -199
  154. package/dist/template/src/client/update-policy-editor.test.ts +101 -29
  155. package/dist/template/src/client/update-policy-editor.tsx +466 -307
  156. package/dist/template/src/client/use-filtered-results.ts +55 -0
  157. package/dist/template/src/server/controllers/manifest.test.ts +23 -3
  158. package/dist/template/src/server/controllers/manifest.ts +15 -1
  159. package/dist/template/src/server/devices/audience.ts +9 -5
  160. package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
  161. package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
  162. package/dist/template/src/server/lib/admin-updates.ts +160 -534
  163. package/dist/template/src/server/lib/distribution-history.ts +97 -0
  164. package/dist/template/src/server/lib/supabase.js +24 -0
  165. package/dist/template/src/server/lib/supabase.test.ts +38 -1
  166. package/dist/template/src/server/lib/update-policy.test.ts +20 -0
  167. package/dist/template/src/server/lib/update-policy.ts +23 -10
  168. package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
  169. package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
  170. package/dist/template/src/server/manifest/manifest-values.ts +21 -13
  171. package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
  172. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
  173. package/dist/template/tsconfig.json +2 -2
  174. package/dist/template-manifest.json +571 -271
  175. package/package.json +1 -1
  176. package/dist/template/scripts/lib/device-identity.test.ts +0 -29
  177. package/dist/template/scripts/lib/ota-client.test.ts +0 -55
  178. package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
  179. package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
  180. package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
  181. package/dist/template/templates/expo-app/ota-client/README.md +0 -73
  182. package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
  183. package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
  184. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
  185. package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
  186. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
  187. package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
  188. package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
  189. package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
  190. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
  191. package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
@@ -1,5 +1,10 @@
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";
5
+ import type { TranslationMessage } from "@/src/client/i18n/messages";
2
6
  import { useI18n } from "@/src/client/i18n/provider";
7
+ import { useFormatters } from "@/src/client/i18n/use-formatters";
3
8
 
4
9
  import { Textarea } from "@/components/ui/textarea";
5
10
 
@@ -21,7 +26,26 @@ import UpdateAudienceEditor from "@/src/client/update-audience-editor";
21
26
  import UpdatePolicyEditor from "@/src/client/update-policy-editor";
22
27
  import Link from "next/link";
23
28
  import { useParams, useRouter } from "next/navigation";
24
- 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";
25
49
  import {
26
50
  DistributionControlBanner,
27
51
  useDistributionControlState,
@@ -38,7 +62,11 @@ function prettyJson(value: unknown): string {
38
62
  }
39
63
 
40
64
  export default function UpdateDetailsPage() {
65
+ const confirmAction = useConfirmAction();
41
66
  const { t } = useI18n();
67
+ const { fullDate } = useFormatters();
68
+ const role = useContext(AdminRoleContext);
69
+ const canWrite = role === "operator" || role === "admin";
42
70
  const params = useParams<{ encodedKey: string }>();
43
71
  const router = useRouter();
44
72
  const encodedKey = params.encodedKey;
@@ -47,7 +75,7 @@ export default function UpdateDetailsPage() {
47
75
  const [loading, setLoading] = useState(true);
48
76
  const [saving, setSaving] = useState(false);
49
77
  const [error, setError] = useState("");
50
- const [success, setSuccess] = useState("");
78
+ const [success, setSuccess] = useState<TranslationMessage>("");
51
79
  const [selectedFile, setSelectedFile] =
52
80
  useState<EditableFile>("update-info.json");
53
81
  const [editorValue, setEditorValue] = useState("{}");
@@ -74,48 +102,39 @@ export default function UpdateDetailsPage() {
74
102
  const rollbackActive =
75
103
  Boolean(activeUpdateId) && activeUpdateId !== latestUpdateId;
76
104
 
77
- const newestUpdateId =
78
- detail?.channelLatest &&
79
- typeof detail.channelLatest.newestUpdateId === "string"
80
- ? detail.channelLatest.newestUpdateId
81
- : null;
82
-
83
105
  const currentServedUpdateId = activeUpdateId || latestUpdateId;
84
- const isNewestInScope = Boolean(
85
- detail?.updateId && newestUpdateId && detail.updateId === newestUpdateId,
86
- );
87
106
 
88
107
  return {
89
108
  latestUpdateId,
90
109
  activeUpdateId,
91
110
  rollbackActive,
92
- newestUpdateId,
93
111
  currentServedUpdateId,
94
- isNewestInScope,
112
+ isNewestInScope:
113
+ detail?.isNewestInScope ??
114
+ (Boolean(detail?.updateId) &&
115
+ detail?.channelLatest?.newestUpdateId === detail?.updateId),
95
116
  };
96
117
  }, [detail]);
97
118
 
98
119
  const canPromote = Boolean(
99
- !distributionBlocked &&
100
- channelState.isNewestInScope &&
101
- channelState.rollbackActive,
120
+ !distributionBlocked && detail?.isLatest && channelState.rollbackActive,
102
121
  );
103
122
  const canRollback = Boolean(
104
123
  detail &&
105
- !distributionBlocked &&
106
- !channelState.isNewestInScope &&
107
- channelState.currentServedUpdateId &&
108
- detail.updateId !== channelState.currentServedUpdateId,
124
+ !distributionBlocked &&
125
+ !channelState.isNewestInScope &&
126
+ channelState.currentServedUpdateId &&
127
+ detail.updateId !== channelState.currentServedUpdateId,
109
128
  );
110
129
  const canToggleDisabled = Boolean(
111
130
  detail && !(channelState.rollbackActive && channelState.isNewestInScope),
112
131
  );
113
132
  const canDirectActivate = Boolean(
114
133
  detail &&
115
- !distributionBlocked &&
116
- detail.status === "disabled" &&
117
- channelState.isNewestInScope &&
118
- !channelState.rollbackActive,
134
+ !distributionBlocked &&
135
+ detail.status === "disabled" &&
136
+ channelState.isNewestInScope &&
137
+ !channelState.rollbackActive,
119
138
  );
120
139
  const canDirectDeactivate = Boolean(
121
140
  detail && detail.status !== "disabled" && canToggleDisabled,
@@ -169,22 +188,23 @@ export default function UpdateDetailsPage() {
169
188
  }, [fileContent]);
170
189
 
171
190
  useEffect(() => {
172
- const loadDetail = async () => {
173
- setLoading(true);
174
- setError("");
175
- setSuccess("");
176
-
177
- try {
178
- const response = await getUpdate(encodedKey);
179
- setDetail(response);
180
- } catch (loadError: unknown) {
181
- setError((loadError as Error).message || "Не удалось загрузить детали");
182
- } finally {
183
- setLoading(false);
184
- }
185
- };
186
-
187
- 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();
188
208
  }, [encodedKey]);
189
209
 
190
210
  const reload = async () => {
@@ -208,7 +228,7 @@ export default function UpdateDetailsPage() {
208
228
  try {
209
229
  await updateJsonFile(encodedKey, selectedFile, parsed);
210
230
  await reload();
211
- setSuccess(t("Файл {0} обновлён", [selectedFile]));
231
+ setSuccess({ key: "Файл {0} обновлён", values: [selectedFile] });
212
232
  } catch (saveError: unknown) {
213
233
  setError((saveError as Error).message || "Ошибка сохранения");
214
234
  } finally {
@@ -217,10 +237,12 @@ export default function UpdateDetailsPage() {
217
237
  };
218
238
 
219
239
  const handleRollback = async () => {
220
- const confirmed = window.confirm(
240
+ const confirmed = await confirmAction(
241
+ t("Rollback"),
221
242
  t(
222
243
  "Вы действительно хотите начать распространение предыдущей версии обновления?",
223
244
  ),
245
+ true,
224
246
  );
225
247
  if (!confirmed) {
226
248
  return;
@@ -232,7 +254,7 @@ export default function UpdateDetailsPage() {
232
254
  try {
233
255
  await rollbackUpdate(encodedKey);
234
256
  await reload();
235
- setSuccess(t("Rollback активирован"));
257
+ setSuccess("Rollback активирован");
236
258
  } catch (rollbackError: unknown) {
237
259
  setError((rollbackError as Error).message || "Rollback не выполнен");
238
260
  } finally {
@@ -241,7 +263,8 @@ export default function UpdateDetailsPage() {
241
263
  };
242
264
 
243
265
  const handlePromote = async () => {
244
- const confirmed = window.confirm(
266
+ const confirmed = await confirmAction(
267
+ t("Promote"),
245
268
  t("Вернуть распространение к последнему апдейту (promote)?"),
246
269
  );
247
270
  if (!confirmed) {
@@ -254,7 +277,7 @@ export default function UpdateDetailsPage() {
254
277
  try {
255
278
  await promoteUpdate(encodedKey);
256
279
  await reload();
257
- setSuccess(t("Promote выполнен: распространение возвращено к latest"));
280
+ setSuccess("Promote выполнен: распространение возвращено к latest");
258
281
  } catch (promoteError: unknown) {
259
282
  setError((promoteError as Error).message || "Promote не выполнен");
260
283
  } finally {
@@ -274,9 +297,7 @@ export default function UpdateDetailsPage() {
274
297
  const disabled = detail.status !== "disabled";
275
298
  await setUpdateDisabled(encodedKey, disabled);
276
299
  await reload();
277
- setSuccess(
278
- disabled ? t("Апдейт деактивирован") : t("Апдейт активирован"),
279
- );
300
+ setSuccess(disabled ? "Апдейт деактивирован" : "Апдейт активирован");
280
301
  } catch (toggleError: unknown) {
281
302
  setError((toggleError as Error).message || "Не удалось изменить статус");
282
303
  } finally {
@@ -290,7 +311,11 @@ export default function UpdateDetailsPage() {
290
311
  return;
291
312
  }
292
313
 
293
- const confirmed = window.confirm(t("Удалить апдейт полностью из bucket?"));
314
+ const confirmed = await confirmAction(
315
+ t("Удалить апдейт"),
316
+ t("Удалить апдейт полностью из bucket?"),
317
+ true,
318
+ );
294
319
  if (!confirmed) {
295
320
  return;
296
321
  }
@@ -309,39 +334,55 @@ export default function UpdateDetailsPage() {
309
334
  };
310
335
 
311
336
  return (
312
- <div className="mx-auto max-w-[1600px] space-y-6 p-4 md:p-8">
313
- <div className="space-y-6">
314
- <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">
315
340
  <Link
316
341
  href="/updates"
317
- 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"
318
343
  >
319
- {t("← Все обновления")}
344
+ <ArrowLeft className="size-4" />
345
+ {t("Публикации")}
320
346
  </Link>
321
- <h1 className="text-2xl font-semibold tracking-tight">
322
- {t("Детали обновления")}
323
- </h1>
324
- <p className="text-sm text-muted-foreground">
325
- {t("Метаданные, политика доставки и управление публикацией.")}
326
- </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
+ )}
327
368
  </header>
328
369
 
329
370
  {loading ? (
330
- <div className="rounded-xl border border-border bg-card p-5 ">
331
- {t("Загрузка...")}
332
- </div>
371
+ <Skeleton className="h-16" role="status">
372
+ <span className="sr-only">{t("Загрузка...")}</span>
373
+ </Skeleton>
333
374
  ) : null}
334
375
 
335
376
  {error ? (
336
- <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">
337
- {t(error)}
338
- </div>
377
+ <Alert variant="destructive">
378
+ <AlertDescription>{t(error)}</AlertDescription>
379
+ </Alert>
339
380
  ) : null}
340
381
 
341
382
  {success ? (
342
- <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">
343
- {success}
344
- </div>
383
+ <Alert role="status">
384
+ <AlertDescription>{t(success)}</AlertDescription>
385
+ </Alert>
345
386
  ) : null}
346
387
 
347
388
  <DistributionControlBanner
@@ -353,202 +394,295 @@ export default function UpdateDetailsPage() {
353
394
  {!loading && detail ? (
354
395
  <>
355
396
  {channelState.rollbackActive ? (
356
- <section className="rounded-xl border border-orange-300 bg-orange-50 p-4 dark:border-orange-700 dark:bg-orange-950/30">
357
- <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>
358
400
  {t("⚠️ Rollback активен в этом канале/платформе.")}
359
- </p>
360
- <p className="mt-1 text-xs text-orange-800 dark:text-orange-300">
401
+ </AlertTitle>
402
+ <AlertDescription>
361
403
  {t("Сейчас раздаётся updateId: ")}
362
404
  {channelState.activeUpdateId}
363
- </p>
364
- <p className="mt-1 text-xs text-orange-800 dark:text-orange-300">
405
+ </AlertDescription>
406
+ <AlertDescription>
365
407
  {t(
366
408
  "Новые апдейты автоматически игнорируются до выполнения Promote.",
367
409
  )}
368
- </p>
369
- </section>
410
+ </AlertDescription>
411
+ </Alert>
370
412
  ) : null}
371
413
 
372
414
  {detail.isIgnoredByRollback ? (
373
- <section className="rounded-xl border border-border bg-muted/30 p-4 ">
374
- <p className="text-sm font-medium text-foreground">
415
+ <Alert variant="warning" role="status">
416
+ <ShieldAlert aria-hidden="true" />
417
+ <AlertTitle>
375
418
  {t("Этот апдейт сейчас не доставляется.")}
376
- </p>
377
- <p className="mt-1 text-xs text-muted-foreground">
419
+ </AlertTitle>
420
+ <AlertDescription>
378
421
  {t(
379
422
  "Причина: активен rollback, автодоставка новых апдейтов выключена.",
380
423
  )}
381
- </p>
382
- </section>
424
+ </AlertDescription>
425
+ </Alert>
383
426
  ) : null}
384
427
 
385
- <Card className="grid gap-4 rounded-xl border border-border bg-card p-5 md:grid-cols-2 lg:grid-cols-4 shadow-none">
386
- <Info label="Runtime" value={detail.runtimeVersion} />
387
- <Info label="Platform" value={detail.platform} />
388
- <Info label="Channel" value={detail.channel} />
389
- <Info label="Stage" value={detail.stage} />
390
- <Info
391
- label="Created"
392
- value={detail.createdAt || detail.createdAtPath}
393
- />
394
- <Info label="Status" value={detail.status} />
395
- <Info
396
- label="Latest"
397
- value={detail.isLatest ? t("Да") : t("Нет")}
398
- />
399
- <Info
400
- label="Rollback"
401
- value={detail.isRollbackActive ? t("Активен") : t("Нет")}
402
- />
403
- <Info
404
- label={t("Доставка")}
405
- value={
406
- detail.isIgnoredByRollback
407
- ? "Ignored by rollback"
408
- : detail.deliveryMode === "background"
409
- ? "Background"
410
- : "Manual"
411
- }
412
- />
413
- <Info label="Guard" value={detail.hasGuard ? "Yes" : "None"} />
414
- <Info
415
- label="Policy"
416
- value={`v${detail.policyVersion} · ${detail.policyEditable ? "draft" : "published"}`}
417
- />
418
- <Info label="Assets" value={String(detail.assetsCount)} />
419
- <Info
420
- label="Update ID"
421
- value={detail.updateId}
422
- className="md:col-span-2 lg:col-span-2"
423
- />
424
- <Info
425
- label={t("Комментарий")}
426
- value={detail.comment || "-"}
427
- className="md:col-span-2 lg:col-span-2"
428
- />
429
- <Info
430
- label={t("Активный update ID")}
431
- value={channelState.activeUpdateId || "-"}
432
- className="md:col-span-2 lg:col-span-2"
433
- />
434
- </Card>
435
-
436
- <UpdateAudienceEditor
437
- key={encodedKey}
438
- encodedKey={encodedKey}
439
- platform={detail.platform}
440
- />
441
- <UpdatePolicyEditor
442
- key={`${encodedKey}-${detail.policyVersion}-${detail.policyPublishedAt || "draft"}`}
443
- encodedKey={encodedKey}
444
- onSaved={reload}
445
- />
446
-
447
- <Card className="gap-4 p-5 shadow-none">
448
- <div className="flex flex-wrap gap-2">
449
- {canRollback ? (
450
- <Button
451
- variant="outline"
452
- size="sm"
453
- type="button"
454
- onClick={handleRollback}
455
- disabled={saving}
456
- >
457
- Rollback
458
- </Button>
459
- ) : null}
460
- {canPromote ? (
461
- <Button
462
- variant="default"
463
- size="sm"
464
- type="button"
465
- onClick={handlePromote}
466
- disabled={saving}
467
- >
468
- Promote
469
- </Button>
470
- ) : null}
471
- {showToggleDisabledButton ? (
472
- <Button
473
- variant="outline"
474
- size="sm"
475
- type="button"
476
- onClick={handleToggleDisabled}
477
- disabled={saving}
478
- >
479
- {detail.status === "disabled"
480
- ? t("Активировать")
481
- : t("Деактивировать")}
482
- </Button>
483
- ) : null}
484
- {canDelete ? (
485
- <Button
486
- variant="destructive"
487
- size="sm"
488
- type="button"
489
- onClick={handleDelete}
490
- disabled={saving}
491
- >
492
- {t("Удалить апдейт")}
493
- </Button>
494
- ) : null}
495
- </div>
496
- </Card>
497
-
498
- <Card className="gap-4 p-5 shadow-none">
499
- <div className="flex flex-wrap items-center gap-2">
500
- <label className="text-sm">{t("JSON файл")}</label>
501
- <NativeSelect
502
- value={selectedFile}
503
- onChange={(event) =>
504
- 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
+ )
505
444
  }
506
- aria-label={t("Выбор JSON файла")}
507
- className="rounded-md border border-input bg-background px-2 py-2 text-sm "
508
- >
509
- <option value="update-info.json">update-info.json</option>
510
- <option value="update-meta.json">update-meta.json</option>
511
- <option value="metadata.json">metadata.json</option>
512
- <option value="channel-latest.json">
513
- channel latest.json
514
- </option>
515
- </NativeSelect>
516
- <Button
517
- variant="outline"
518
- size="sm"
519
- type="button"
520
- onClick={handleSaveJson}
521
- disabled={
522
- saving ||
523
- channelLatestLocked ||
524
- updateMetaDistributionLocked
525
- }
526
- >
527
- {t("Сохранить JSON")}
528
- </Button>
445
+ />
446
+ <Info label={t("Update ID")} value={detail.updateId} />
529
447
  </div>
530
- {channelLatestLocked ? (
531
- <p className="mt-2 text-xs text-orange-700 dark:text-orange-300">
532
- {t(
533
- "Редактирование channel latest.json заблокировано: активен rollback или глобальный аварийный выключатель.",
534
- )}
535
- </p>
536
- ) : null}
537
- {updateMetaDistributionLocked ? (
538
- <p className="mt-2 text-xs text-red-700 dark:text-red-300">
539
- {t(
540
- "Активация через update-meta.json недоступна при глобальной блокировке. Деактивация с isActive=false остаётся доступна.",
541
- )}
542
- </p>
543
- ) : null}
544
- <Textarea
545
- value={editorValue}
546
- onChange={(event) => setEditorValue(event.target.value)}
547
- aria-label={t("Редактор JSON")}
548
- 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 "
549
- spellCheck={false}
550
- />
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
+ )}
551
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>
552
686
  </>
553
687
  ) : null}
554
688
  </div>
@@ -562,7 +696,7 @@ function Info({
562
696
  className,
563
697
  }: {
564
698
  label: string;
565
- value: string;
699
+ value: React.ReactNode;
566
700
  className?: string;
567
701
  }) {
568
702
  return (