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,356 +1,467 @@
1
1
  "use client";
2
- import { useI18n } from "@/src/client/i18n/provider";
3
-
4
- import { NativeSelect } from "@/components/ui/native-select";
5
2
 
6
- import { getUpdates } from "@/src/client/admin-api";
7
- import { UpdateItem } from "@/src/client/admin-types";
8
- import DistributionControl from "@/src/client/distribution-control";
9
3
  import Link from "next/link";
10
- import { Button } from "@/components/ui/button";
11
- import { Badge } from "@/components/ui/badge";
12
- import { Card } from "@/components/ui/card";
13
- import {
14
- Table,
15
- TableHeader,
16
- TableBody,
17
- TableRow,
18
- TableHead,
19
- TableCell,
20
- } from "@/components/ui/table";
4
+ import { useState } from "react";
21
5
  import {
22
6
  ArrowDownUp,
23
- ArrowRight,
7
+ ArrowUpRight,
24
8
  ChevronLeft,
25
9
  ChevronRight,
10
+ Layers3,
26
11
  RefreshCw,
27
- Package,
12
+ Search,
28
13
  ShieldAlert,
29
14
  } from "lucide-react";
30
- import { useCallback, useEffect, useState } from "react";
15
+ import {
16
+ PlatformBadge,
17
+ ChannelBadge,
18
+ ReleaseStatusBadge,
19
+ AudienceBadge,
20
+ DeliveryBadge,
21
+ } from "@/components/admin/release-badges";
22
+ import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
23
+ import { Badge } from "@/components/ui/badge";
24
+ import { Button } from "@/components/ui/button";
25
+ import { Card } from "@/components/ui/card";
26
+ import {
27
+ InputGroup,
28
+ InputGroupAddon,
29
+ InputGroupInput,
30
+ } from "@/components/ui/input-group";
31
+ import DistributionHistory from "@/src/client/distribution-history";
32
+ import {
33
+ Select,
34
+ SelectContent,
35
+ SelectItem,
36
+ SelectTrigger,
37
+ SelectValue,
38
+ } from "@/components/ui/select";
39
+ import { NativeSelect } from "@/components/ui/native-select";
40
+ import {
41
+ Table,
42
+ TableBody,
43
+ TableCell,
44
+ TableHead,
45
+ TableHeader,
46
+ TableRow,
47
+ } from "@/components/ui/table";
48
+ import { getUpdates } from "@/src/client/admin-api";
49
+ import type { ReleaseFilters } from "@/src/client/admin-types";
50
+ import { useFilteredResults } from "@/src/client/use-filtered-results";
51
+ import DistributionControl from "@/src/client/distribution-control";
52
+ import { useI18n } from "@/src/client/i18n/provider";
53
+ import { useFormatters } from "@/src/client/i18n/use-formatters";
31
54
 
32
- const PAGE_SIZE = 20;
55
+ const emptyFilters: ReleaseFilters = {
56
+ q: "",
57
+ platform: "",
58
+ channel: "",
59
+ runtime: "",
60
+ status: "",
61
+ audience: "",
62
+ };
63
+ const sorts = [
64
+ ["createdAt", "По дате"],
65
+ ["runtimeVersion", "По runtime"],
66
+ ["platform", "По платформе"],
67
+ ["channel", "По каналу"],
68
+ ["status", "По статусу"],
69
+ ["updateId", "По ID"],
70
+ ];
33
71
 
34
- type SortBy =
35
- | "createdAt"
36
- | "runtimeVersion"
37
- | "platform"
38
- | "channel"
39
- | "stage"
40
- | "status"
41
- | "updateId";
72
+ const initialQuery = {
73
+ ...emptyFilters,
74
+ page: 1,
75
+ sortBy: "createdAt",
76
+ order: "desc" as "asc" | "desc",
77
+ };
42
78
 
43
- export default function UpdatesPage() {
44
- const { t, formatLocale } = useI18n();
45
- const [items, setItems] = useState<UpdateItem[]>([]);
46
- const [rollbackScopes, setRollbackScopes] = useState<
47
- Array<{
48
- scopeKey: string;
49
- runtimeVersion: string;
50
- channel: string;
51
- platform: "ios" | "android";
52
- rollbackActive: boolean;
53
- autoDeliveryEnabled: boolean;
54
- activeUpdateId: string | null;
55
- latestUpdateId: string | null;
56
- }>
57
- >([]);
58
- const [page, setPage] = useState(1);
59
- const [totalPages, setTotalPages] = useState(1);
60
- const [total, setTotal] = useState(0);
61
- const [sortBy, setSortBy] = useState<SortBy>("createdAt");
62
- const [order, setOrder] = useState<"asc" | "desc">("desc");
63
- const [loading, setLoading] = useState(true);
64
- const [error, setError] = useState("");
79
+ function loadReleases(query: typeof initialQuery, signal: AbortSignal) {
80
+ return getUpdates({ ...query, q: query.q.trim(), pageSize: 20 }, signal);
81
+ }
65
82
 
66
- const hasRollbackActive = items.some((item) => item.isRollbackActive);
67
- const hasIgnoredUpdates = items.some((item) => item.isIgnoredByRollback);
68
- const lockedScopes = rollbackScopes.filter((scope) => scope.rollbackActive);
83
+ function hasFilters(query: ReleaseFilters) {
84
+ return Boolean(
85
+ query.q.trim() ||
86
+ query.platform ||
87
+ query.channel ||
88
+ query.runtime ||
89
+ query.status ||
90
+ query.audience,
91
+ );
92
+ }
69
93
 
70
- const loadUpdates = useCallback(async () => {
71
- setLoading(true);
72
- setError("");
94
+ export default function UpdatesPage() {
95
+ const { t } = useI18n();
96
+ const { number, fullDate } = useFormatters();
97
+ const [historyRevision, setHistoryRevision] = useState(0);
98
+ const [distributionBlocked, setDistributionBlocked] = useState(true);
99
+ const {
100
+ query,
101
+ success,
102
+ loading,
103
+ error,
104
+ request: requestPage,
105
+ } = useFilteredResults(initialQuery, loadReleases);
106
+ const result = success?.data;
107
+ const resultsFiltered = success && hasFilters(success.query);
73
108
 
74
- try {
75
- const response = await getUpdates({
76
- page,
77
- pageSize: PAGE_SIZE,
78
- sortBy,
79
- order,
80
- });
81
- setItems(response.items);
82
- setRollbackScopes(response.rollbackLockByScope || []);
83
- setTotalPages(response.totalPages);
84
- setTotal(response.total);
85
- } catch (loadError: unknown) {
86
- setError((loadError as Error).message || "Не удалось загрузить список");
87
- } finally {
88
- setLoading(false);
89
- }
90
- }, [page, sortBy, order]);
109
+ function refreshReleases() {
110
+ requestPage({ ...query });
111
+ setHistoryRevision((value) => value + 1);
112
+ }
91
113
 
92
- useEffect(() => {
93
- void loadUpdates();
94
- }, [loadUpdates]);
114
+ function reset() {
115
+ requestPage({ ...query, ...emptyFilters, page: 1 });
116
+ }
117
+ function filter(
118
+ key: keyof ReleaseFilters,
119
+ label: string,
120
+ options: [string, string][],
121
+ ) {
122
+ return (
123
+ <Select
124
+ value={"option:" + query[key]}
125
+ onValueChange={(value) =>
126
+ requestPage({ ...query, [key]: value.slice(7), page: 1 })
127
+ }
128
+ >
129
+ <SelectTrigger aria-label={label} className="max-w-48">
130
+ <SelectValue />
131
+ </SelectTrigger>
132
+ <SelectContent>
133
+ <SelectItem value="option:">{label}</SelectItem>
134
+ {options.map(([value, title]) => (
135
+ <SelectItem key={value} value={"option:" + value}>
136
+ {title}
137
+ </SelectItem>
138
+ ))}
139
+ </SelectContent>
140
+ </Select>
141
+ );
142
+ }
143
+ const locked =
144
+ result?.rollbackLockByScope.filter((scope) => scope.rollbackActive) ?? [];
145
+ const page = result?.page ?? 1;
146
+ const pages = result?.totalPages ?? 1;
95
147
 
96
148
  return (
97
- <div className="mx-auto max-w-[1600px] space-y-6 p-4 md:p-8">
98
- <header className="flex flex-wrap items-start justify-between gap-4">
99
- <div className="space-y-1">
100
- <h1 className="text-2xl font-semibold tracking-tight">OTA Updates</h1>
101
- <p className="text-sm text-muted-foreground">
102
- {t("Публикации, версии и управление доставкой обновлений.")}
149
+ <div className="mx-auto max-w-[1500px] space-y-5 p-4 sm:p-6 lg:p-8">
150
+ <header className="flex flex-wrap items-center justify-between gap-4">
151
+ <div>
152
+ <h1 className="text-3xl font-semibold tracking-tight">
153
+ {t("Публикации")}
154
+ </h1>
155
+ <p className="mt-1.5 text-sm text-muted-foreground">
156
+ {t("Manage release audiences, delivery policies and rollbacks.")}
103
157
  </p>
104
158
  </div>
105
159
  <Button
106
- variant="outline"
107
- onClick={() => void loadUpdates()}
160
+ size="sm"
108
161
  disabled={loading}
162
+ onClick={refreshReleases}
109
163
  >
110
- <RefreshCw className={loading ? "animate-spin" : ""} />{" "}
111
- {t(" Обновить")}
164
+ <RefreshCw className={loading ? "animate-spin" : ""} />
165
+ {t("Обновить")}
112
166
  </Button>
113
167
  </header>
114
168
 
115
- <DistributionControl />
169
+ <DistributionControl onAvailabilityChange={setDistributionBlocked} />
116
170
 
117
- {error && (
118
- <div
119
- role="alert"
120
- className="rounded-lg border border-destructive/25 bg-destructive/5 p-4 text-sm text-destructive"
121
- >
122
- {t(error)}
123
- </div>
171
+ {locked.length > 0 && (
172
+ <Alert role="status" variant="destructive">
173
+ <ShieldAlert aria-hidden="true" />
174
+ <AlertTitle>{t("Rollback активен")}</AlertTitle>
175
+ <AlertDescription className="break-words">
176
+ {t("Автодоставка новых обновлений временно отключена.")}{" "}
177
+ {locked
178
+ .map((s) => [s.runtimeVersion, s.platform, s.channel].join(" / "))
179
+ .join(" · ")}
180
+ </AlertDescription>
181
+ </Alert>
124
182
  )}
125
- {hasRollbackActive && (
126
- <div className="flex gap-3 rounded-lg border border-amber-500/25 bg-amber-500/5 p-4 text-sm">
127
- <ShieldAlert className="mt-0.5 size-4 shrink-0 text-amber-600" />
128
- <div>
129
- <p className="font-medium">{t("Rollback активен")}</p>
130
- <p className="mt-1 text-muted-foreground">
131
- {t("Автодоставка новых обновлений временно отключена.")}
132
- {hasIgnoredUpdates
133
- ? t(" Новые публикации в этих scope помечены как ignored.")
134
- : ""}
135
- </p>
183
+
184
+ <Card className="min-w-0 gap-0 overflow-hidden py-0 shadow-none">
185
+ <div className="space-y-4 border-b p-4 sm:p-5">
186
+ <div className="flex flex-wrap items-center justify-between gap-3">
187
+ <div className="flex items-center gap-2">
188
+ <h2 className="text-lg font-semibold">{t("Release history")}</h2>
189
+ {result && (
190
+ <Badge variant="info" className="tabular-nums">
191
+ {number(result.total)}
192
+ </Badge>
193
+ )}
194
+ </div>
195
+ <div className="flex items-center gap-1.5">
196
+ <NativeSelect
197
+ size="sm"
198
+ aria-label={t("Сортировка списка апдейтов")}
199
+ value={query.sortBy}
200
+ onChange={(e) =>
201
+ requestPage({ ...query, sortBy: e.target.value, page: 1 })
202
+ }
203
+ >
204
+ {sorts.map(([key, label]) => (
205
+ <option key={key} value={key}>
206
+ {t(label)}
207
+ </option>
208
+ ))}
209
+ </NativeSelect>
210
+ <Button
211
+ variant="outline"
212
+ size="sm"
213
+ aria-label={
214
+ query.order === "desc"
215
+ ? t("Сортировать по возрастанию")
216
+ : t("Сортировать по убыванию")
217
+ }
218
+ onClick={() =>
219
+ requestPage({
220
+ ...query,
221
+ order: query.order === "desc" ? "asc" : "desc",
222
+ page: 1,
223
+ })
224
+ }
225
+ >
226
+ <ArrowDownUp />
227
+ {query.order === "desc" ? t("Descending") : t("Ascending")}
228
+ </Button>
229
+ </div>
230
+ </div>
231
+ <div role="search" className="space-y-3">
232
+ <InputGroup>
233
+ <InputGroupAddon>
234
+ <Search />
235
+ </InputGroupAddon>
236
+ <InputGroupInput
237
+ type="search"
238
+ aria-label={t("Search releases")}
239
+ placeholder={t(
240
+ "Search by comment, update ID, version or channel",
241
+ )}
242
+ value={query.q}
243
+ onChange={(event) => {
244
+ const q = event.target.value;
245
+ requestPage({ ...query, q, page: 1 }, Boolean(q.trim()));
246
+ }}
247
+ />
248
+ </InputGroup>
249
+ <div className="flex flex-wrap items-center gap-2">
250
+ {filter("platform", t("Все платформы"), [
251
+ ["ios", "iOS"],
252
+ ["android", "Android"],
253
+ ])}
254
+ {filter(
255
+ "channel",
256
+ t("Все каналы"),
257
+ (result?.filters?.channels ?? []).map((v) => [v, v]),
258
+ )}
259
+ {filter(
260
+ "runtime",
261
+ t("All runtimes"),
262
+ (result?.filters?.runtimes ?? []).map((v) => [v, v]),
263
+ )}
264
+ {filter("status", t("All statuses"), [
265
+ ["active", t("active")],
266
+ ["draft", t("draft")],
267
+ ["disabled", t("disabled")],
268
+ ["rollback", t("Rollback")],
269
+ ])}
270
+ {filter("audience", t("All audiences"), [
271
+ ["all", t("Все совместимые устройства")],
272
+ ["devices", t("Выбранные устройства")],
273
+ ])}
274
+ {(hasFilters(query) || resultsFiltered) && (
275
+ <Button type="button" variant="ghost" size="sm" onClick={reset}>
276
+ {t("Сбросить")}
277
+ </Button>
278
+ )}
279
+ </div>
136
280
  </div>
137
281
  </div>
138
- )}
139
- {lockedScopes.length > 0 && (
140
- <p className="text-xs text-muted-foreground">
141
- Rollback lock:{" "}
142
- {lockedScopes
143
- .map(
144
- (scope) =>
145
- `${scope.runtimeVersion} / ${scope.platform} / ${scope.channel}`,
146
- )
147
- .join("; ")}
148
- </p>
149
- )}
150
282
 
151
- <Card className="gap-0 overflow-hidden py-0 shadow-none">
152
- <div className="flex flex-wrap items-center justify-between gap-4 border-b p-4">
153
- <div className="flex items-center gap-2">
154
- <Package className="size-4 text-muted-foreground" />
155
- <h2 className="text-sm font-semibold">{t("Публикации")}</h2>
156
- <Badge variant="secondary">{total}</Badge>
157
- </div>
158
- <div className="flex items-center gap-2">
159
- <NativeSelect
160
- value={sortBy}
161
- onChange={(event) => {
162
- setSortBy(event.target.value as SortBy);
163
- setPage(1);
164
- }}
165
- aria-label={t("Сортировка списка апдейтов")}
166
- className="h-9 rounded-md border border-input bg-background px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring"
167
- >
168
- <option value="createdAt">{t("По дате")}</option>
169
- <option value="runtimeVersion">{t("По runtime")}</option>
170
- <option value="platform">{t("По платформе")}</option>
171
- <option value="channel">{t("По каналу")}</option>
172
- <option value="stage">{t("По stage")}</option>
173
- <option value="status">{t("По статусу")}</option>
174
- <option value="updateId">{t("По ID")}</option>
175
- </NativeSelect>
283
+ {error && (
284
+ <div
285
+ role="alert"
286
+ className="border-b bg-destructive/5 p-4 text-sm text-destructive"
287
+ >
288
+ {t(error)} {result && t("Showing the previous results.")}{" "}
176
289
  <Button
177
- variant="outline"
178
290
  size="sm"
179
- onClick={() => {
180
- setOrder((current) => (current === "asc" ? "desc" : "asc"));
181
- setPage(1);
182
- }}
183
- aria-label={
184
- order === "asc"
185
- ? t("Сортировать по убыванию")
186
- : t("Сортировать по возрастанию")
187
- }
291
+ variant="outline"
292
+ onClick={() => requestPage({ ...query })}
188
293
  >
189
- <ArrowDownUp />
190
- {order === "asc" ? "ASC" : "DESC"}
294
+ {t("Retry")}
191
295
  </Button>
192
296
  </div>
193
- </div>
194
- <Table>
297
+ )}
298
+ <Table aria-busy={loading}>
195
299
  <TableHeader>
196
- <TableRow className="bg-muted/40 hover:bg-muted/40">
197
- <TableHead className="pl-5">{t("Обновление")}</TableHead>
198
- <TableHead>Runtime / App</TableHead>
199
- <TableHead>{t("Платформа / канал")}</TableHead>
300
+ <TableRow className="bg-muted/35">
301
+ <TableHead className="pl-4 sm:pl-5">{t("Release")}</TableHead>
302
+ <TableHead className="hidden lg:table-cell">
303
+ {t("Compatibility")}
304
+ </TableHead>
200
305
  <TableHead>{t("Состояние")}</TableHead>
201
- <TableHead>{t("Доставка")}</TableHead>
202
- <TableHead>Assets</TableHead>
203
- <TableHead className="pr-5 text-right">{t("Создано")}</TableHead>
306
+ <TableHead className="hidden sm:table-cell">
307
+ {t("Audience")}
308
+ </TableHead>
309
+ <TableHead className="hidden xl:table-cell">
310
+ {t("Доставка")}
311
+ </TableHead>
312
+ <TableHead className="hidden pr-5 text-right md:table-cell">
313
+ {t("Создано")}
314
+ </TableHead>
204
315
  </TableRow>
205
316
  </TableHeader>
206
317
  <TableBody>
207
- {loading && (
318
+ {!result && loading && (
208
319
  <TableRow>
209
320
  <TableCell
210
- colSpan={7}
321
+ colSpan={6}
211
322
  className="h-36 text-center text-muted-foreground"
212
323
  >
213
- <RefreshCw className="mx-auto mb-2 size-5 animate-spin" />
214
324
  {t("Загрузка обновлений…")}
215
325
  </TableCell>
216
326
  </TableRow>
217
327
  )}
218
- {!loading && items.length === 0 && (
328
+ {result?.items.length === 0 && (
219
329
  <TableRow>
220
- <TableCell colSpan={7} className="h-48 text-center">
221
- <Package className="mx-auto mb-3 size-8 text-muted-foreground/50" />
222
- <p className="font-medium">{t("Обновлений пока нет")}</p>
223
- <p className="mt-1 text-sm text-muted-foreground">
224
- {t("Опубликуйте OTA, чтобы управлять его доставкой здесь.")}
330
+ <TableCell colSpan={6} className="h-40 text-center">
331
+ <Layers3 className="mx-auto mb-3 size-6 text-muted-foreground" />
332
+ <p className="font-medium">
333
+ {resultsFiltered
334
+ ? t("No matching releases")
335
+ : t("Обновлений пока нет")}
225
336
  </p>
337
+ {resultsFiltered ? (
338
+ <Button variant="link" size="sm" onClick={reset}>
339
+ {t("Сбросить")}
340
+ </Button>
341
+ ) : (
342
+ <p className="mt-1 whitespace-normal text-sm text-muted-foreground">
343
+ {t(
344
+ "Опубликуйте OTA, чтобы управлять его доставкой здесь.",
345
+ )}
346
+ </p>
347
+ )}
226
348
  </TableCell>
227
349
  </TableRow>
228
350
  )}
229
- {!loading &&
230
- items.map((item) => (
231
- <TableRow
232
- key={item.key}
233
- className={item.isRollbackActive ? "bg-amber-500/5" : ""}
234
- >
235
- <TableCell className="max-w-80 py-4 pl-5">
236
- <Link
237
- href={`/updates/${item.encodedKey}`}
238
- className="group flex items-center gap-2 text-sm font-medium text-foreground hover:text-primary"
239
- >
240
- <span className="truncate">
241
- {item.comment || t("Без комментария")}
242
- </span>
243
- <ArrowRight className="size-3.5 shrink-0 opacity-0 transition-opacity group-hover:opacity-100" />
244
- </Link>
245
- <Link
246
- href={`/updates/${item.encodedKey}`}
247
- className="mt-1 block max-w-60 truncate font-mono text-[11px] text-muted-foreground hover:text-primary"
248
- title={item.updateId}
249
- >
250
- {item.updateId}
251
- </Link>
252
- </TableCell>
253
- <TableCell>
254
- <p className="font-medium">{item.runtimeVersion}</p>
255
- <p className="mt-1 text-xs text-muted-foreground">
256
- App {item.appVersion || "—"}
257
- </p>
258
- </TableCell>
259
- <TableCell>
260
- <span className="text-sm">
261
- {item.platform === "ios" ? "iOS" : "Android"}
351
+ {result?.items.map((item) => (
352
+ <TableRow key={item.key}>
353
+ <TableCell className="max-w-44 whitespace-normal py-4 pl-4 sm:max-w-80 sm:pl-5">
354
+ <Link
355
+ href={`/updates/${item.encodedKey}`}
356
+ className="group inline-flex max-w-full items-start gap-1.5 rounded-sm font-semibold hover:text-primary"
357
+ >
358
+ <span className="line-clamp-2 break-words">
359
+ {item.comment ||
360
+ (item.appVersion
361
+ ? t("Version {0}", [item.appVersion])
362
+ : t("Release {0}", [item.updateId.slice(0, 8)]))}
262
363
  </span>
263
- <p className="mt-1 text-xs text-muted-foreground">
264
- {item.channel}
265
- </p>
266
- </TableCell>
267
- <TableCell>
268
- <div className="flex flex-wrap gap-1.5">
364
+ <ArrowUpRight className="mt-0.5 size-3.5 shrink-0 text-muted-foreground group-hover:text-primary" />
365
+ </Link>
366
+ <div
367
+ className="mt-1 font-mono text-xs text-muted-foreground"
368
+ title={item.updateId}
369
+ >
370
+ {item.updateId.slice(0, 8)}
371
+ </div>
372
+ <div className="mt-1 flex min-w-0 flex-wrap items-center gap-1 text-xs text-muted-foreground lg:hidden">
373
+ <PlatformBadge platform={item.platform} />
374
+ <ChannelBadge channel={item.channel} />
375
+ <span className="break-all">{item.runtimeVersion}</span>
376
+ </div>
377
+ </TableCell>
378
+ <TableCell className="hidden max-w-60 whitespace-normal lg:table-cell">
379
+ <div className="flex min-w-0 flex-wrap items-center gap-1">
380
+ <PlatformBadge platform={item.platform} />
381
+ <ChannelBadge channel={item.channel} />
382
+ </div>
383
+ <div className="mt-1 break-words text-xs text-muted-foreground">
384
+ {t("Runtime {0}", [item.runtimeVersion])}
385
+ {item.appVersion ? ` · ${t("App")} ${item.appVersion}` : ""}
386
+ </div>
387
+ </TableCell>
388
+ <TableCell>
389
+ <div className="flex flex-col items-start gap-1.5">
390
+ <ReleaseStatusBadge release={item} />
391
+ {item.isLatest && (
392
+ <span className="text-xs text-muted-foreground">
393
+ {t("Latest")}
394
+ </span>
395
+ )}
396
+ {(item.isRollbackActive || item.isIgnoredByRollback) && (
269
397
  <Badge
270
398
  variant={
271
- item.status === "active" ? "default" : "secondary"
272
- }
273
- className={
274
- item.status === "active"
275
- ? "bg-emerald-500/10 text-emerald-700 dark:text-emerald-400"
276
- : ""
399
+ item.isRollbackActive ? "destructive" : "warning"
277
400
  }
401
+ className="max-w-36 whitespace-normal text-left"
278
402
  >
279
- {item.status}
280
- </Badge>
281
- {item.isLatest && <Badge variant="outline">Latest</Badge>}
282
- {item.audienceMode === "devices" && (
283
- <Badge variant="outline">
284
- {t("Выбранные устройства")}
285
- </Badge>
286
- )}
287
- </div>
288
- <p className="mt-1.5 text-xs text-muted-foreground">
289
- {item.stage}
290
- </p>
291
- </TableCell>
292
- <TableCell>
293
- <div className="flex flex-wrap gap-1.5">
294
- <Badge variant="outline">
295
- {item.deliveryMode === "background"
296
- ? "Background"
297
- : "Manual"}
403
+ {item.isRollbackActive
404
+ ? t("Rollback")
405
+ : t("Ignored by rollback")}
298
406
  </Badge>
299
- {item.hasGuard && (
300
- <Badge variant="secondary">Guard</Badge>
301
- )}
407
+ )}
408
+ <div className="max-w-32 sm:hidden">
409
+ <AudienceBadge mode={item.audienceMode} compact />
302
410
  </div>
303
- <p
304
- className={`mt-1.5 text-xs ${item.isRollbackActive ? "text-amber-600" : "text-muted-foreground"}`}
305
- >
306
- {item.isRollbackActive
307
- ? "Rollback"
308
- : item.isIgnoredByRollback
309
- ? "Ignored by rollback"
310
- : "Scope open"}
311
- </p>
312
- </TableCell>
313
- <TableCell className="tabular-nums text-muted-foreground">
314
- {item.assetsCount}
315
- </TableCell>
316
- <TableCell className="pr-5 text-right text-xs tabular-nums text-muted-foreground">
317
- {new Date(item.createdAt).toLocaleString(formatLocale) ||
318
- item.createdAtPath}
319
- </TableCell>
320
- </TableRow>
321
- ))}
411
+ </div>
412
+ </TableCell>
413
+ <TableCell className="hidden sm:table-cell">
414
+ <AudienceBadge mode={item.audienceMode} compact />
415
+ </TableCell>
416
+ <TableCell className="hidden xl:table-cell">
417
+ <DeliveryBadge mode={item.deliveryMode} />
418
+ {item.hasGuard && (
419
+ <Badge className="ml-1.5" variant="warning">
420
+ {t("Guard")}
421
+ </Badge>
422
+ )}
423
+ </TableCell>
424
+ <TableCell className="hidden pr-5 text-right text-xs text-muted-foreground md:table-cell">
425
+ {fullDate(item.createdAt)}
426
+ </TableCell>
427
+ </TableRow>
428
+ ))}
322
429
  </TableBody>
323
430
  </Table>
324
- <div className="flex items-center justify-between gap-3 border-t px-5 py-3">
325
- <p className="text-xs text-muted-foreground">
326
- {t("Страница ")}
327
- {page} {t(" из ")}
328
- {totalPages}
329
- </p>
431
+ <footer className="flex flex-wrap items-center justify-between gap-3 border-t px-4 py-3 sm:px-5">
432
+ <span aria-live="polite" className="text-sm text-muted-foreground">
433
+ {loading
434
+ ? t("Загрузка...")
435
+ : t("Page {0} of {1}", [number(page), number(pages)])}
436
+ </span>
330
437
  <div className="flex gap-2">
331
438
  <Button
332
- variant="outline"
333
439
  size="sm"
334
- onClick={() => setPage((current) => Math.max(1, current - 1))}
335
- disabled={page <= 1 || loading}
440
+ variant="outline"
441
+ disabled={loading || page <= 1}
442
+ onClick={() => requestPage({ ...query, page: page - 1 })}
336
443
  >
337
444
  <ChevronLeft />
338
445
  {t("Назад")}
339
446
  </Button>
340
447
  <Button
341
- variant="outline"
342
448
  size="sm"
343
- onClick={() =>
344
- setPage((current) => Math.min(totalPages, current + 1))
345
- }
346
- disabled={page >= totalPages || loading}
449
+ variant="outline"
450
+ disabled={loading || page >= pages}
451
+ onClick={() => requestPage({ ...query, page: page + 1 })}
347
452
  >
348
453
  {t("Вперёд")}
349
454
  <ChevronRight />
350
455
  </Button>
351
456
  </div>
352
- </div>
457
+ </footer>
353
458
  </Card>
459
+
460
+ <DistributionHistory
461
+ revision={historyRevision}
462
+ blocked={distributionBlocked}
463
+ onRestored={refreshReleases}
464
+ />
354
465
  </div>
355
466
  );
356
467
  }