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
@@ -3,9 +3,16 @@ import { useFormatters } from "@/src/client/i18n/use-formatters";
3
3
  import { useI18n } from "@/src/client/i18n/provider";
4
4
 
5
5
  import { DeviceName } from "./device-name";
6
- import { useRef, useState } from "react";
6
+ import { AdminRoleContext } from "@/components/admin/admin-role";
7
+ import { BookmarkTarget, useFavoriteTargets } from "./favorite-targets";
8
+ import { useContext, useRef, useState } from "react";
7
9
  import { Copy, Check, ChevronLeft, ChevronRight, Search } from "lucide-react";
8
10
  import { Button } from "@/components/ui/button";
11
+ import {
12
+ PlatformBadge,
13
+ ChannelBadge,
14
+ launchKindTone,
15
+ } from "@/components/admin/release-badges";
9
16
  import { Badge } from "@/components/ui/badge";
10
17
  import {
11
18
  Card,
@@ -14,7 +21,6 @@ import {
14
21
  CardDescription,
15
22
  CardContent,
16
23
  } from "@/components/ui/card";
17
- import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
18
24
  import {
19
25
  Table,
20
26
  TableHeader,
@@ -34,7 +40,7 @@ import type {
34
40
  DeviceInstallation,
35
41
  DevicesReport,
36
42
  } from "@/src/server/devices/report-types";
37
- import { useKindNames, percent } from "./analytics";
43
+ import { useKindNames } from "./analytics";
38
44
  function CopyValue({ value }: { value: string }) {
39
45
  const { t } = useI18n();
40
46
  const [state, setState] = useState<"idle" | "copied" | "failed">("idle");
@@ -85,15 +91,24 @@ export function Registry({
85
91
  const { t } = useI18n();
86
92
  const opener = useRef<HTMLButtonElement | null>(null);
87
93
  const kindNames = useKindNames();
88
- const { number, fullDate } = useFormatters();
94
+ const { number, fullDate, calendarDate } = useFormatters();
89
95
  const [selected, setSelected] = useState<DeviceInstallation | null>(null);
96
+ const role = useContext(AdminRoleContext);
97
+ const canBookmark = role === "admin" || role === "operator";
98
+ const personal = useFavoriteTargets(
99
+ selected?.platform ?? "",
100
+ !!selected && canBookmark,
101
+ 0,
102
+ );
90
103
  return (
91
104
  <>
92
105
  <Card className="min-w-0 shadow-none">
93
106
  <CardHeader>
94
107
  <div className="flex flex-wrap items-center gap-3">
95
- <CardTitle>{t("Реестр установок")}</CardTitle>
96
- <Badge variant="secondary">{number(report.total)}</Badge>
108
+ <CardTitle>
109
+ <h2>{t("Реестр установок")}</h2>
110
+ </CardTitle>
111
+ <Badge variant="info">{number(report.total)}</Badge>
97
112
  </div>
98
113
  <CardDescription>
99
114
  {t(
@@ -101,225 +116,136 @@ export function Registry({
101
116
  )}
102
117
  </CardDescription>
103
118
  </CardHeader>
104
- <CardContent>
105
- <Tabs defaultValue="devices">
106
- <TabsList className="mb-4">
107
- <TabsTrigger value="devices">{t("Установки")}</TabsTrigger>
108
- <TabsTrigger value="versions">
109
- {t("Все версии · ")}
110
- {report.versions.length}
111
- </TabsTrigger>
112
- </TabsList>
113
- <TabsContent value="devices">
114
- <Table>
115
- <TableHeader>
116
- <TableRow>
117
- <TableHead>{t("Установка")}</TableHead>
118
- <TableHead>{t("Платформа / канал")}</TableHead>
119
- <TableHead>{t("Версия")}</TableHead>
120
- <TableHead>{t("Запуск")}</TableHead>
121
- <TableHead>{t("Последняя связь · UTC")}</TableHead>
122
- </TableRow>
123
- </TableHeader>
124
- <TableBody>
125
- {report.devices.map((d) => (
126
- <TableRow key={`${d.platform}:${d.installation_id}`}>
127
- <TableCell>
128
- <Button
129
- variant="link"
130
- className="h-auto p-0 font-mono text-xs"
131
- title={d.installation_id}
132
- onClick={(event) => {
133
- opener.current = event.currentTarget;
134
- setSelected(d);
135
- }}
136
- aria-label={t("Детали установки {0}", [
137
- d.installation_id,
138
- ])}
139
- >
140
- {d.installation_id.slice(0, 8)}…
141
- {d.installation_id.slice(-4)}
142
- </Button>
143
- <p className="mt-1 text-xs text-muted-foreground">
144
- {t("С ")}
145
- {fullDate(d.first_seen_at).split(",")[0]}
146
- </p>
147
- </TableCell>
148
- <TableCell>
149
- <span className="capitalize">{d.platform}</span>
150
- <p className="mt-1 text-xs text-muted-foreground">
151
- {d.channel}
152
- </p>
153
- </TableCell>
154
- <TableCell>
155
- <p
156
- className="max-w-56 truncate text-sm"
157
- title={
158
- d.update_label ||
159
- d.resolved_update_id ||
160
- kindNames[d.launch_kind]
161
- }
162
- >
163
- {d.update_label ||
164
- d.resolved_update_id?.slice(0, 8) ||
165
- kindNames[d.launch_kind]}
166
- </p>
167
- <p
168
- className="mt-1 text-xs text-muted-foreground"
169
- title={d.runtime_version}
170
- >
171
- {d.runtime_version}
172
- </p>
173
- <p className="mt-1 text-xs text-muted-foreground">
174
- Native {d.native_version || "—"} (
175
- {d.native_build || "—"})
176
- </p>
177
- </TableCell>
178
- <TableCell>
179
- <Badge
180
- variant={
181
- d.launch_kind === "ota" ? "default" : "secondary"
182
- }
183
- >
184
- {kindNames[d.launch_kind]}
185
- </Badge>
186
- {d.emergency_launch && (
187
- <Badge
188
- variant="destructive"
189
- className="mt-1 block w-fit"
190
- >
191
- Emergency
192
- </Badge>
193
- )}
194
- </TableCell>
195
- <TableCell className="text-xs tabular-nums">
196
- {fullDate(d.last_seen_at).replace(" UTC", "")}
197
- </TableCell>
198
- </TableRow>
199
- ))}
200
- </TableBody>
201
- </Table>
202
- {!report.devices.length && (
203
- <div className="flex flex-col items-center gap-2 py-12 text-center">
204
- <Search className="size-6 text-muted-foreground" />
205
- <p className="text-sm font-medium">
206
- {t("Установки не найдены")}
207
- </p>
208
- <p className="max-w-sm text-xs leading-5 text-muted-foreground">
209
- {t(
210
- "Измените фильтры или дождитесь heartbeat от приложения с подключённой телеметрией.",
119
+ <CardContent className="min-w-0 px-4 sm:px-6">
120
+ <Table aria-label={t("Реестр установок")}>
121
+ <TableHeader>
122
+ <TableRow>
123
+ <TableHead>{t("Установка")}</TableHead>
124
+ <TableHead>{t("Платформа / канал")}</TableHead>
125
+ <TableHead>{t("Версия")}</TableHead>
126
+ <TableHead>{t("Запуск")}</TableHead>
127
+ <TableHead>{t("Последняя связь · UTC")}</TableHead>
128
+ </TableRow>
129
+ </TableHeader>
130
+ <TableBody>
131
+ {report.devices.map((d) => (
132
+ <TableRow key={`${d.platform}:${d.installation_id}`}>
133
+ <TableCell>
134
+ <Button
135
+ variant="link"
136
+ className="h-auto p-0 font-mono text-xs"
137
+ title={d.installation_id}
138
+ onClick={(event) => {
139
+ opener.current = event.currentTarget;
140
+ setSelected(d);
141
+ }}
142
+ aria-label={t("Детали установки {0}", [
143
+ d.installation_id,
144
+ ])}
145
+ >
146
+ {d.installation_id.slice(0, 8)}…
147
+ {d.installation_id.slice(-4)}
148
+ </Button>
149
+ <p className="mt-1 text-xs text-muted-foreground">
150
+ {t("С ")}
151
+ {calendarDate(d.first_seen_at)}
152
+ </p>
153
+ </TableCell>
154
+ <TableCell>
155
+ <div className="flex max-w-52 flex-wrap items-center gap-1">
156
+ <PlatformBadge platform={d.platform} />
157
+ <ChannelBadge channel={d.channel} />
158
+ </div>
159
+ </TableCell>
160
+ <TableCell>
161
+ <p
162
+ className="max-w-56 truncate text-sm"
163
+ title={
164
+ d.update_label ||
165
+ d.resolved_update_id ||
166
+ kindNames[d.launch_kind]
167
+ }
168
+ >
169
+ {d.update_label ||
170
+ d.resolved_update_id?.slice(0, 8) ||
171
+ kindNames[d.launch_kind]}
172
+ </p>
173
+ <p
174
+ className="mt-1 text-xs text-muted-foreground"
175
+ title={d.runtime_version}
176
+ >
177
+ {d.runtime_version}
178
+ </p>
179
+ <p className="mt-1 text-xs text-muted-foreground">
180
+ {t("Native")} {d.native_version || "—"} (
181
+ {d.native_build || "—"})
182
+ </p>
183
+ </TableCell>
184
+ <TableCell>
185
+ <Badge variant={launchKindTone[d.launch_kind]}>
186
+ {kindNames[d.launch_kind]}
187
+ </Badge>
188
+ {d.emergency_launch && (
189
+ <Badge variant="destructive" className="mt-1 block w-fit">
190
+ {t("Emergency")}
191
+ </Badge>
211
192
  )}
212
- </p>
213
- </div>
214
- )}
215
- <div className="mt-4 flex flex-wrap items-center justify-between gap-3 border-t pt-4">
216
- <p className="text-xs text-muted-foreground">
217
- {report.total
218
- ? t("{0}–{1} из {2}", [
219
- number(report.offset + 1),
220
- number(
221
- Math.min(
222
- report.offset + report.pageSize,
223
- report.total,
224
- ),
225
- ),
226
- number(report.total),
227
- ])
228
- : t("0 установок")}
229
- </p>
230
- <div className="flex gap-2">
231
- <Button
232
- size="sm"
233
- variant="outline"
234
- disabled={loading || report.offset === 0}
235
- onClick={() =>
236
- paginate(Math.max(0, report.offset - report.pageSize))
237
- }
238
- >
239
- <ChevronLeft />
240
- {t("Назад")}
241
- </Button>
242
- <Button
243
- size="sm"
244
- variant="outline"
245
- disabled={
246
- loading || report.offset + report.pageSize >= report.total
247
- }
248
- onClick={() => paginate(report.offset + report.pageSize)}
249
- >
250
- {t("Далее")}
251
- <ChevronRight />
252
- </Button>
253
- </div>
254
- </div>
255
- </TabsContent>
256
- <TabsContent value="versions">
257
- <Table>
258
- <TableHeader>
259
- <TableRow>
260
- <TableHead>{t("Версия / ID")}</TableHead>
261
- <TableHead>{t("Платформа / канал")}</TableHead>
262
- <TableHead>Runtime / native</TableHead>
263
- <TableHead>{t("Запуск")}</TableHead>
264
- <TableHead className="text-right">
265
- {t("Установки")}
266
- </TableHead>
267
- <TableHead className="text-right">{t("Доля")}</TableHead>
268
- </TableRow>
269
- </TableHeader>
270
- <TableBody>
271
- {report.versions.map((v, i) => (
272
- <TableRow key={i}>
273
- <TableCell>
274
- <p
275
- className="max-w-56 truncate font-medium"
276
- title={v.update_label || undefined}
277
- >
278
- {v.update_label || kindNames[v.launch_kind]}
279
- </p>
280
- {v.update_id && (
281
- <code
282
- className="mt-1 block text-xs text-muted-foreground"
283
- title={v.update_id}
284
- >
285
- {v.update_id}
286
- </code>
287
- )}
288
- </TableCell>
289
- <TableCell>
290
- {v.platform}
291
- <p className="text-xs text-muted-foreground">
292
- {v.channel}
293
- </p>
294
- </TableCell>
295
- <TableCell>
296
- {v.runtime_version}
297
- <p className="text-xs text-muted-foreground">
298
- {v.native_version || "—"} ({v.native_build || "—"})
299
- </p>
300
- </TableCell>
301
- <TableCell>
302
- <Badge variant="secondary">
303
- {kindNames[v.launch_kind]}
304
- </Badge>
305
- </TableCell>
306
- <TableCell className="text-right tabular-nums">
307
- {number(v.installations)}
308
- </TableCell>
309
- <TableCell className="text-right tabular-nums">
310
- {percent(v.installations, report.total)}
311
- </TableCell>
312
- </TableRow>
313
- ))}
314
- </TableBody>
315
- </Table>
316
- {!report.versions.length && (
317
- <p className="py-8 text-center text-sm text-muted-foreground">
318
- {t("Нет версий в выбранной выборке.")}
319
- </p>
320
- )}
321
- </TabsContent>
322
- </Tabs>
193
+ </TableCell>
194
+ <TableCell className="text-xs tabular-nums">
195
+ {fullDate(d.last_seen_at).replace(" UTC", "")}
196
+ </TableCell>
197
+ </TableRow>
198
+ ))}
199
+ </TableBody>
200
+ </Table>
201
+ {!report.devices.length && (
202
+ <div className="flex flex-col items-center gap-2 py-12 text-center">
203
+ <Search className="size-6 text-muted-foreground" />
204
+ <p className="text-sm font-medium">{t("Установки не найдены")}</p>
205
+ <p className="max-w-sm text-xs leading-5 text-muted-foreground">
206
+ {t(
207
+ "Измените фильтры или дождитесь heartbeat от приложения с подключённой телеметрией.",
208
+ )}
209
+ </p>
210
+ </div>
211
+ )}
212
+ <div className="mt-4 flex flex-wrap items-center justify-between gap-3 border-t pt-4">
213
+ <p className="text-xs text-muted-foreground">
214
+ {report.total
215
+ ? t("{0}–{1} из {2}", [
216
+ number(report.offset + 1),
217
+ number(
218
+ Math.min(report.offset + report.pageSize, report.total),
219
+ ),
220
+ number(report.total),
221
+ ])
222
+ : t("0 установок")}
223
+ </p>
224
+ <div className="flex gap-2">
225
+ <Button
226
+ size="sm"
227
+ variant="outline"
228
+ disabled={loading || report.offset === 0}
229
+ onClick={() =>
230
+ paginate(Math.max(0, report.offset - report.pageSize))
231
+ }
232
+ >
233
+ <ChevronLeft />
234
+ {t("Назад")}
235
+ </Button>
236
+ <Button
237
+ size="sm"
238
+ variant="outline"
239
+ disabled={
240
+ loading || report.offset + report.pageSize >= report.total
241
+ }
242
+ onClick={() => paginate(report.offset + report.pageSize)}
243
+ >
244
+ {t("Далее")}
245
+ <ChevronRight />
246
+ </Button>
247
+ </div>
248
+ </div>
323
249
  </CardContent>
324
250
  </Card>
325
251
  <Sheet
@@ -343,6 +269,24 @@ export function Registry({
343
269
  )}
344
270
  </SheetDescription>
345
271
  </SheetHeader>
272
+ {selected && canBookmark && (
273
+ <div className="mx-4 space-y-2 sm:mx-6">
274
+ {personal.error && (
275
+ <p role="alert" className="text-sm text-destructive">
276
+ {t(personal.error)}
277
+ </p>
278
+ )}
279
+ <BookmarkTarget
280
+ platform={selected.platform}
281
+ deviceId={selected.device_id ?? null}
282
+ installationId={selected.installation_id}
283
+ displayName={null}
284
+ showLabel
285
+ favorites={personal.favorites ?? []}
286
+ onChanged={personal.refresh}
287
+ />
288
+ </div>
289
+ )}
346
290
  {selected?.device_id && (
347
291
  <DeviceName
348
292
  key={selected.device_id}
@@ -351,23 +295,23 @@ export function Registry({
351
295
  />
352
296
  )}
353
297
  {selected && (
354
- <dl className="space-y-5 px-6 pb-8">
298
+ <dl className="divide-y px-4 pb-6 sm:px-6">
355
299
  {[
356
- ["Installation ID", selected.installation_id],
357
- ["Device ID", selected.device_id || "—"],
300
+ [t("Installation ID"), selected.installation_id],
301
+ [t("Device ID"), selected.device_id || "—"],
358
302
  [t("Платформа"), selected.platform],
359
303
  [t("Канал"), selected.channel],
360
- ["Runtime", selected.runtime_version],
304
+ [t("Runtime"), selected.runtime_version],
361
305
  [
362
- "Native version / build",
306
+ t("Native version / build"),
363
307
  `${selected.native_version || "—"} (${selected.native_build || "—"})`,
364
308
  ],
365
309
  [t("Тип запуска"), kindNames[selected.launch_kind]],
366
310
  [t("Название обновления"), selected.update_label || "—"],
367
- ["OTA artifact ID", selected.resolved_update_id || "—"],
368
- ["Launch update ID", selected.reported_update_id || "—"],
311
+ [t("OTA artifact ID"), selected.resolved_update_id || "—"],
312
+ [t("Launch update ID"), selected.reported_update_id || "—"],
369
313
  [
370
- "Emergency launch",
314
+ t("Emergency launch"),
371
315
  selected.emergency_launch ? t("Да") : t("Нет"),
372
316
  ],
373
317
  [t("Первый heartbeat"), fullDate(selected.first_seen_at)],
@@ -377,7 +321,10 @@ export function Registry({
377
321
  fullDate(selected.observed_at),
378
322
  ],
379
323
  ].map(([label, value]) => (
380
- <div key={label}>
324
+ <div
325
+ key={label}
326
+ className="grid items-start gap-1.5 py-3 sm:grid-cols-[9rem_1fr]"
327
+ >
381
328
  <dt className="mb-1 text-xs font-medium text-muted-foreground">
382
329
  {label}
383
330
  </dt>
@@ -397,3 +344,88 @@ export function Registry({
397
344
  </>
398
345
  );
399
346
  }
347
+
348
+ export function VersionTable({ report }: { report: DevicesReport }) {
349
+ const { t } = useI18n();
350
+ const kindNames = useKindNames();
351
+ const { number, share } = useFormatters();
352
+ return (
353
+ <Card className="min-w-0 gap-4 shadow-none">
354
+ <CardHeader>
355
+ <CardTitle>
356
+ <h2>
357
+ {t("Все версии · ")}
358
+ {number(report.versions.length)}
359
+ </h2>
360
+ </CardTitle>
361
+ <CardDescription>
362
+ {t("Shares across all installations in the selected period.")}
363
+ </CardDescription>
364
+ </CardHeader>
365
+ <CardContent className="min-w-0 px-4 sm:px-6">
366
+ <Table>
367
+ <TableHeader>
368
+ <TableRow>
369
+ <TableHead>{t("Версия / ID")}</TableHead>
370
+ <TableHead>{t("Платформа / канал")}</TableHead>
371
+ <TableHead>{t("Runtime / native")}</TableHead>
372
+ <TableHead>{t("Запуск")}</TableHead>
373
+ <TableHead className="text-right">{t("Установки")}</TableHead>
374
+ <TableHead className="text-right">{t("Доля")}</TableHead>
375
+ </TableRow>
376
+ </TableHeader>
377
+ <TableBody>
378
+ {report.versions.map((v, i) => (
379
+ <TableRow key={i}>
380
+ <TableCell>
381
+ <p
382
+ className="max-w-56 truncate font-medium"
383
+ title={v.update_label || undefined}
384
+ >
385
+ {v.update_label || kindNames[v.launch_kind]}
386
+ </p>
387
+ {v.update_id && (
388
+ <code
389
+ className="mt-1 block text-xs text-muted-foreground"
390
+ title={v.update_id}
391
+ >
392
+ {v.update_id}
393
+ </code>
394
+ )}
395
+ </TableCell>
396
+ <TableCell>
397
+ <div className="flex max-w-52 flex-wrap items-center gap-1">
398
+ <PlatformBadge platform={v.platform} />
399
+ <ChannelBadge channel={v.channel} />
400
+ </div>
401
+ </TableCell>
402
+ <TableCell>
403
+ {v.runtime_version}
404
+ <p className="text-xs text-muted-foreground">
405
+ {v.native_version || "—"} ({v.native_build || "—"})
406
+ </p>
407
+ </TableCell>
408
+ <TableCell>
409
+ <Badge variant={launchKindTone[v.launch_kind]}>
410
+ {kindNames[v.launch_kind]}
411
+ </Badge>
412
+ </TableCell>
413
+ <TableCell className="text-right tabular-nums">
414
+ {number(v.installations)}
415
+ </TableCell>
416
+ <TableCell className="text-right tabular-nums">
417
+ {share(v.installations, report.total)}
418
+ </TableCell>
419
+ </TableRow>
420
+ ))}
421
+ </TableBody>
422
+ </Table>
423
+ {!report.versions.length && (
424
+ <p className="py-8 text-center text-sm text-muted-foreground">
425
+ {t("Нет версий в выбранной выборке.")}
426
+ </p>
427
+ )}
428
+ </CardContent>
429
+ </Card>
430
+ );
431
+ }