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,7 +1,7 @@
1
1
  "use client";
2
2
  import { useI18n } from "@/src/client/i18n/provider";
3
3
 
4
- import { RefreshCw, SlidersHorizontal, X } from "lucide-react";
4
+ import { ChevronDown, RefreshCw, SlidersHorizontal, X } from "lucide-react";
5
5
  import { Button } from "@/components/ui/button";
6
6
  import { Input } from "@/components/ui/input";
7
7
  import { Label } from "@/components/ui/label";
@@ -10,172 +10,173 @@ import {
10
10
  NativeSelectOption,
11
11
  } from "@/components/ui/native-select";
12
12
  import { Badge } from "@/components/ui/badge";
13
+ import {
14
+ Collapsible,
15
+ CollapsibleTrigger,
16
+ CollapsibleContent,
17
+ } from "@/components/ui/collapsible";
13
18
  import { Card, CardContent } from "@/components/ui/card";
14
19
  import { Alert, AlertTitle, AlertDescription } from "@/components/ui/alert";
15
20
  import { Skeleton } from "@/components/ui/skeleton";
16
- import { Analytics, useKindNames } from "@/src/client/devices/analytics";
17
- import { Registry } from "@/src/client/devices/registry";
18
- import {
19
- useDevicesReport,
20
- type Filters,
21
- } from "@/src/client/devices/use-devices-report";
21
+ import { Overview, useKindNames } from "@/src/client/devices/analytics";
22
+ import { Cohorts } from "@/src/client/devices/cohorts";
23
+ import { VersionAdoptionChart } from "@/src/client/devices/version-adoption-chart";
24
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
25
+ import { Registry, VersionTable } from "@/src/client/devices/registry";
26
+ import { useDevicesReport } from "@/src/client/devices/use-devices-report";
22
27
  export default function DevicesPage() {
23
28
  const { t, formatLocale } = useI18n();
24
29
  const kindNames = useKindNames();
25
30
  const {
26
31
  filters,
27
- setFilters,
28
- applied,
32
+ update,
29
33
  report,
30
34
  error,
31
35
  loading,
32
- apply,
33
36
  reset,
34
37
  refresh,
35
38
  paginate,
36
39
  } = useDevicesReport();
37
- const dirty = JSON.stringify(filters) !== JSON.stringify(applied);
38
- const activeFilters = Object.entries(applied).filter(
39
- ([key, value]) => key !== "days" && value,
40
+ const activeFilters = Object.entries(filters).filter(
41
+ ([key, value]) => key !== "days" && value.trim(),
40
42
  ).length;
41
- const update = (key: keyof Filters, value: string) =>
42
- setFilters((previous) => ({ ...previous, [key]: value }));
43
43
  const options = report?.options;
44
+ const period =
45
+ filters.days === "1" ? t("24 часа") : t("{0} дней", [filters.days]);
44
46
  return (
45
- <main className="mx-auto max-w-[1600px] space-y-6 p-4 md:p-8">
46
- <header className="flex flex-wrap items-start justify-between gap-4">
47
+ <div className="mx-auto w-full max-w-[1600px] space-y-5 p-4 md:p-8">
48
+ <header className="flex flex-wrap items-center justify-between gap-3">
47
49
  <div>
48
- <p className="mb-1 text-xs font-medium uppercase tracking-[.16em] text-muted-foreground">
49
- {t("Аналитика приложения")}
50
- </p>
51
- <h1 className="text-2xl font-semibold tracking-tight md:text-[28px]">
50
+ <h1 className="text-3xl font-semibold tracking-tight">
52
51
  {t("Установки")}
53
52
  </h1>
54
- <p className="mt-1 text-sm text-muted-foreground">
55
- {t("Версии, активность и переход на OTA в одном месте.")}
53
+ <p className="mt-1.5 text-sm text-muted-foreground">
54
+ {t("Versions and activity reported by app installations.")}
56
55
  </p>
57
56
  </div>
58
- <Button variant="outline" disabled={loading} onClick={refresh}>
57
+ <Button
58
+ size="sm"
59
+ disabled={loading}
60
+ onClick={refresh}
61
+ >
59
62
  <RefreshCw
60
63
  className={loading ? "animate-spin motion-reduce:animate-none" : ""}
61
64
  />
62
65
  {loading ? t("Обновление…") : t("Обновить")}
63
66
  </Button>
64
67
  </header>
65
- <Card className="gap-0 py-5 shadow-none">
66
- <CardContent>
67
- <div className="mb-4 flex items-center gap-2 text-sm font-medium">
68
- <SlidersHorizontal className="size-4 text-muted-foreground" />
69
- {t("Фильтры")}
70
- {activeFilters > 0 && (
71
- <Badge variant="secondary">{activeFilters}</Badge>
72
- )}
73
- <span className="ml-auto text-xs font-normal text-muted-foreground">
74
- {t("Вся выборка")}
75
- </span>
76
- </div>
77
- <form
78
- onSubmit={(e) => {
79
- e.preventDefault();
80
- apply();
81
- }}
82
- className="grid grid-cols-2 items-end gap-3 lg:grid-cols-3 2xl:grid-cols-6"
83
- >
84
- <Filter
85
- label={t("Период активности")}
86
- id="days"
87
- value={filters.days}
88
- onChange={(v) => update("days", v)}
89
- items={[
90
- ["1", t("24 часа")],
91
- ["7", t("7 дней")],
92
- ["30", t("30 дней")],
93
- ]}
94
- />
95
- <Filter
96
- label={t("Платформа")}
97
- id="platform"
98
- value={filters.platform}
99
- onChange={(v) => update("platform", v)}
100
- items={[
101
- ["", t("Все платформы")],
102
- ...["android", "ios"].map((v) => [
103
- v,
104
- v === "ios" ? "iOS" : "Android",
105
- ]),
106
- ]}
107
- />
108
- <Filter
109
- label={t("Канал")}
110
- id="channel"
111
- value={filters.channel}
112
- onChange={(v) => update("channel", v)}
113
- items={[
114
- ["", t("Все каналы")],
115
- ...(options?.channels || []).map((v) => [v, v]),
116
- ]}
117
- />
118
- <Filter
119
- label="Runtime"
120
- id="runtime"
121
- value={filters.runtime}
122
- onChange={(v) => update("runtime", v)}
123
- items={[
124
- ["", t("Все runtime")],
125
- ...(options?.runtimes || []).map((v) => [v, v]),
126
- ]}
127
- />
128
- <Filter
129
- label={t("Тип запуска")}
130
- id="launchKind"
131
- value={filters.launchKind}
132
- onChange={(v) => update("launchKind", v)}
133
- items={[["", t("Все типы")], ...Object.entries(kindNames)]}
134
- />
135
- <div className="grid gap-2">
136
- <Label htmlFor="installation-search">Installation ID</Label>
137
- <Input
138
- id="installation-search"
139
- placeholder={t("ID или часть ID")}
140
- value={filters.search}
141
- maxLength={36}
142
- pattern="[a-fA-F0-9\-]*"
143
- title={t("Часть UUID: цифры, буквы a–f и дефисы")}
144
- onChange={(e) => update("search", e.target.value)}
145
- className="bg-background/40"
146
- />
147
- </div>
148
- <div className="flex flex-wrap items-center gap-2 col-span-2 lg:col-span-3 2xl:col-span-6">
149
- <Button type="submit" size="sm" disabled={loading}>
150
- {t("Применить")}
151
- </Button>
68
+ <Card className="gap-0 py-0 shadow-none">
69
+ <CardContent className="px-4 sm:px-5">
70
+ <Collapsible className="group/filters">
71
+ <CollapsibleTrigger asChild>
152
72
  <Button
153
- type="button"
154
- size="sm"
155
73
  variant="ghost"
156
- onClick={reset}
157
- disabled={loading}
74
+ className="h-auto w-full flex-wrap justify-start gap-x-3 gap-y-2 py-3.5 whitespace-normal"
75
+ aria-label={t("Фильтры")}
158
76
  >
159
- <X />
160
- {t("Сбросить")}
161
- </Button>
162
- {dirty && (
163
- <span className="text-xs text-muted-foreground">
164
- {t("Есть неприменённые изменения")}
77
+ <SlidersHorizontal
78
+ aria-hidden="true"
79
+ className="size-4 text-primary"
80
+ />
81
+ <span className="font-medium">{t("Фильтры")}</span>
82
+ <span className="border-l pl-3 text-xs text-muted-foreground">
83
+ {period}
165
84
  </span>
166
- )}
167
- <span className="ml-auto text-xs text-muted-foreground">
168
- {report && !loading
169
- ? t("Данные на {0}", [
170
- new Date(report.coverage.generatedAt).toLocaleTimeString(
171
- formatLocale,
172
- { hour: "2-digit", minute: "2-digit" },
173
- ),
174
- ])
175
- : ""}
176
- </span>
177
- </div>
178
- </form>
85
+ {activeFilters > 0 && (
86
+ <Badge variant="info">
87
+ {t("{0} filters applied", [activeFilters])}
88
+ </Badge>
89
+ )}
90
+ <ChevronDown
91
+ aria-hidden="true"
92
+ className="ml-auto size-4 text-muted-foreground group-data-[state=open]/filters:rotate-180"
93
+ />
94
+ </Button>
95
+ </CollapsibleTrigger>
96
+ <CollapsibleContent>
97
+ <div
98
+ className="grid grid-cols-1 items-end gap-3 border-t py-4 min-[380px]:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-6"
99
+ >
100
+ <Filter
101
+ label={t("Период активности")}
102
+ id="days"
103
+ value={filters.days}
104
+ onChange={(v) => update("days", v)}
105
+ items={[
106
+ ["1", t("24 часа")],
107
+ ["7", t("7 дней")],
108
+ ["30", t("30 дней")],
109
+ ]}
110
+ />
111
+ <Filter
112
+ label={t("Платформа")}
113
+ id="platform"
114
+ value={filters.platform}
115
+ onChange={(v) => update("platform", v)}
116
+ items={[
117
+ ["", t("Все платформы")],
118
+ ...["android", "ios"].map((v) => [
119
+ v,
120
+ v === "ios" ? "iOS" : "Android",
121
+ ]),
122
+ ]}
123
+ />
124
+ <Filter
125
+ label={t("Канал")}
126
+ id="channel"
127
+ value={filters.channel}
128
+ onChange={(v) => update("channel", v)}
129
+ items={[
130
+ ["", t("Все каналы")],
131
+ ...(options?.channels || []).map((v) => [v, v]),
132
+ ]}
133
+ />
134
+ <Filter
135
+ label={t("Runtime")}
136
+ id="runtime"
137
+ value={filters.runtime}
138
+ onChange={(v) => update("runtime", v)}
139
+ items={[
140
+ ["", t("Все runtime")],
141
+ ...(options?.runtimes || []).map((v) => [v, v]),
142
+ ]}
143
+ />
144
+ <Filter
145
+ label={t("Тип запуска")}
146
+ id="launchKind"
147
+ value={filters.launchKind}
148
+ onChange={(v) => update("launchKind", v)}
149
+ items={[["", t("Все типы")], ...Object.entries(kindNames)]}
150
+ />
151
+ <div className="grid gap-2">
152
+ <Label htmlFor="installation-search">
153
+ {t("Installation ID")}
154
+ </Label>
155
+ <Input
156
+ id="installation-search"
157
+ placeholder={t("ID или часть ID")}
158
+ value={filters.search}
159
+ maxLength={36}
160
+ pattern="[a-fA-F0-9\-]*"
161
+ title={t("Часть UUID: цифры, буквы a–f и дефисы")}
162
+ onChange={(e) => update("search", e.target.value)}
163
+ className="bg-background/40"
164
+ />
165
+ </div>
166
+ <div className="col-span-full flex flex-wrap items-center gap-2">
167
+ <Button
168
+ type="button"
169
+ size="sm"
170
+ variant="ghost"
171
+ onClick={reset}
172
+ >
173
+ <X />
174
+ {t("Сбросить")}
175
+ </Button>
176
+ </div>
177
+ </div>
178
+ </CollapsibleContent>
179
+ </Collapsible>
179
180
  </CardContent>
180
181
  </Card>
181
182
  {error && (
@@ -210,20 +211,61 @@ export default function DevicesPage() {
210
211
  <Skeleton className="h-64 rounded-xl" />
211
212
  </div>
212
213
  ) : report ? (
213
- <div
214
- className={loading ? "space-y-6 opacity-60" : "space-y-6"}
214
+ <Tabs
215
+ defaultValue="overview"
216
+ className="min-w-0 gap-4"
215
217
  aria-busy={loading}
216
218
  >
217
- <Analytics report={report} />
218
- <Registry report={report} loading={loading} paginate={paginate} />
219
- <p className="text-xs leading-5 text-muted-foreground">
220
- {t(
221
- "Метрика считает установки приложения, а не уникальных людей. Сводка и реестр отражают последнее состояние; график — состояние на конец каждого дня. Переустановка может изменить Installation ID.",
222
- )}
223
- </p>
224
- </div>
219
+ <div className="flex min-w-0 flex-wrap items-center justify-between gap-3 border-b pb-2">
220
+ <TabsList
221
+ aria-label={t("Аналитика приложения")}
222
+ variant="line"
223
+ className="grid h-auto w-full grid-cols-2 justify-start gap-0 sm:flex sm:w-fit"
224
+ >
225
+ {[
226
+ ["overview", t("Overview")],
227
+ ["versions", t("Versions")],
228
+ ["cohorts", t("Cohorts")],
229
+ ["registry", t("Registry")],
230
+ ].map(([id, label]) => (
231
+ <TabsTrigger
232
+ value={id}
233
+ key={id}
234
+ className="min-h-9 px-3 after:bottom-0! after:bg-primary"
235
+ >
236
+ {label}
237
+ </TabsTrigger>
238
+ ))}
239
+ </TabsList>
240
+ <p className="text-xs text-muted-foreground">
241
+ {t("Данные на {0}", [
242
+ new Date(report.coverage.generatedAt).toLocaleTimeString(
243
+ formatLocale,
244
+ {
245
+ hour: "2-digit",
246
+ minute: "2-digit",
247
+ timeZone: "UTC",
248
+ },
249
+ ) + " UTC",
250
+ ])}
251
+ </p>
252
+ </div>
253
+ <TabsContent value="overview" className="min-w-0 space-y-4">
254
+ <Overview report={report} />
255
+ </TabsContent>
256
+ <TabsContent value="versions" className="min-w-0 space-y-4">
257
+ <VersionAdoptionChart report={report} />
258
+ <VersionTable report={report} />
259
+ </TabsContent>
260
+ <TabsContent value="cohorts" className="min-w-0">
261
+ <Cohorts report={report} />
262
+ </TabsContent>
263
+ <TabsContent value="registry" className="min-w-0">
264
+ <Registry report={report} loading={loading} paginate={paginate} />
265
+ </TabsContent>
266
+ </Tabs>
225
267
  ) : null}
226
- </main>
268
+ </div>
227
269
  );
228
270
  }
229
271
  function Filter({
@@ -1,8 +1,14 @@
1
1
  "use client";
2
+ import { Alert, AlertDescription } from "@/components/ui/alert";
3
+ import { useConfirmAction } from "@/components/admin/confirm-action";
4
+ import type { TranslationMessage } from "@/src/client/i18n/messages";
2
5
  import { useI18n } from "@/src/client/i18n/provider";
3
6
 
7
+ import { AdminRoleContext } from "@/components/admin/admin-role";
8
+ import { Input } from "@/components/ui/input";
4
9
  import { Button } from "@/components/ui/button";
5
10
  import { Card } from "@/components/ui/card";
11
+ import { PlatformBadge, ChannelBadge } from "@/components/admin/release-badges";
6
12
  import { Badge } from "@/components/ui/badge";
7
13
  import {
8
14
  Table,
@@ -18,15 +24,18 @@ import {
18
24
  getEmbeddedUpdates,
19
25
  } from "@/src/client/admin-api";
20
26
  import { EmbeddedUpdateItem } from "@/src/client/admin-types";
21
- import { useCallback, useEffect, useState } from "react";
27
+ import { useContext, useCallback, useEffect, useState } from "react";
22
28
 
23
29
  export default function EmbeddedUpdatesPage() {
30
+ const canWrite = useContext(AdminRoleContext) !== "viewer";
31
+ const [query, setQuery] = useState("");
32
+ const confirmAction = useConfirmAction();
24
33
  const { t, formatLocale } = useI18n();
25
34
  const [items, setItems] = useState<EmbeddedUpdateItem[]>([]);
26
35
  const [loading, setLoading] = useState(true);
27
36
  const [deletingId, setDeletingId] = useState<string | null>(null);
28
37
  const [error, setError] = useState("");
29
- const [success, setSuccess] = useState("");
38
+ const [success, setSuccess] = useState<TranslationMessage>("");
30
39
 
31
40
  const loadItems = useCallback(async () => {
32
41
  setLoading(true);
@@ -50,8 +59,10 @@ export default function EmbeddedUpdatesPage() {
50
59
  }, [loadItems]);
51
60
 
52
61
  const handleDelete = async (embeddedUpdateId: string) => {
53
- const confirmed = window.confirm(
62
+ const confirmed = await confirmAction(
63
+ t("Удалить"),
54
64
  t("Удалить запись embedded update {0}?", [embeddedUpdateId]),
65
+ true,
55
66
  );
56
67
  if (!confirmed) {
57
68
  return;
@@ -63,7 +74,10 @@ export default function EmbeddedUpdatesPage() {
63
74
 
64
75
  try {
65
76
  await deleteEmbeddedUpdate(embeddedUpdateId);
66
- setSuccess(t("Запись удалена: {0}", [embeddedUpdateId]));
77
+ setSuccess({
78
+ key: "Запись удалена: {0}",
79
+ values: [embeddedUpdateId],
80
+ });
67
81
  await loadItems();
68
82
  } catch (deleteError: unknown) {
69
83
  setError(
@@ -75,54 +89,80 @@ export default function EmbeddedUpdatesPage() {
75
89
  }
76
90
  };
77
91
 
92
+ const search = query.trim().toLowerCase();
93
+ const visible = items.filter((item) =>
94
+ [item.embeddedUpdateId, item.appVersion, item.platform, item.channel].some(
95
+ (field) => field?.toLowerCase().includes(search),
96
+ ),
97
+ );
98
+
78
99
  return (
79
100
  <div className="mx-auto max-w-[1600px] space-y-6 p-4 md:p-8">
80
101
  <div className="space-y-6">
81
102
  <header className="flex flex-wrap items-start justify-between gap-4">
82
103
  <div className="space-y-1">
83
104
  <h1 className="text-2xl font-semibold tracking-tight">
84
- Embedded builds
105
+ {t("Embedded builds")}
85
106
  </h1>
86
107
  <p className="text-sm text-muted-foreground">
87
108
  {t("Встроенные версии приложения и регистрация нативных сборок.")}
88
109
  </p>
89
110
  </div>
90
- <Badge variant="secondary" className="px-3 py-1">
91
- {items.length} {t(" сборок")}
111
+ <Badge variant="info" className="px-3 py-1">
112
+ {t("Builds: {0}", [items.length])}
92
113
  </Badge>
93
114
  </header>
94
115
 
95
116
  {error ? (
96
- <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">
97
- {t(error)}
98
- </div>
117
+ <Alert variant="destructive">
118
+ <AlertDescription>{t(error)}</AlertDescription>
119
+ </Alert>
99
120
  ) : null}
100
121
 
101
122
  {success ? (
102
- <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">
103
- {success}
104
- </div>
123
+ <Alert role="status">
124
+ <AlertDescription>{t(success)}</AlertDescription>
125
+ </Alert>
105
126
  ) : null}
106
127
 
107
128
  <Card className="gap-0 overflow-hidden py-0 shadow-none">
129
+ <div className="flex flex-wrap items-center gap-2 border-b p-4">
130
+ <Input
131
+ type="search"
132
+ className="max-w-md"
133
+ placeholder={t("Search embedded builds")}
134
+ aria-label={t("Search embedded builds")}
135
+ value={query}
136
+ onChange={(event) => setQuery(event.target.value)}
137
+ />
138
+ {query && (
139
+ <Button variant="ghost" onClick={() => setQuery("")}>
140
+ {t("Сбросить")}
141
+ </Button>
142
+ )}
143
+ </div>
108
144
  <div className="overflow-x-auto">
109
145
  <Table className="min-w-full text-sm">
110
146
  <TableHeader className="bg-muted/40">
111
147
  <TableRow>
112
148
  <TableHead className="px-4 py-3 text-left">
113
- Created At
149
+ {t("Created At")}
114
150
  </TableHead>
115
151
  <TableHead className="px-4 py-3 text-left">
116
- App version
152
+ {t("App version")}
117
153
  </TableHead>
118
154
  <TableHead className="px-4 py-3 text-left">
119
- Platform
155
+ {t("Platform")}
120
156
  </TableHead>
121
- <TableHead className="px-4 py-3 text-left">Channel</TableHead>
122
157
  <TableHead className="px-4 py-3 text-left">
123
- Embedded ID
158
+ {t("Channel")}
159
+ </TableHead>
160
+ <TableHead className="px-4 py-3 text-left">
161
+ {t("Embedded ID")}
162
+ </TableHead>
163
+ <TableHead className="px-4 py-3 text-left">
164
+ {t("Action")}
124
165
  </TableHead>
125
- <TableHead className="px-4 py-3 text-left">Action</TableHead>
126
166
  </TableRow>
127
167
  </TableHeader>
128
168
  <TableBody>
@@ -137,7 +177,7 @@ export default function EmbeddedUpdatesPage() {
137
177
  </TableRow>
138
178
  ) : null}
139
179
 
140
- {!loading && items.length === 0 ? (
180
+ {!loading && visible.length === 0 ? (
141
181
  <TableRow>
142
182
  <TableCell
143
183
  className="h-36 px-3 py-4 text-center text-muted-foreground"
@@ -149,7 +189,7 @@ export default function EmbeddedUpdatesPage() {
149
189
  ) : null}
150
190
 
151
191
  {!loading
152
- ? items.map((item) => (
192
+ ? visible.map((item) => (
153
193
  <TableRow
154
194
  key={item.embeddedUpdateId}
155
195
  className="border-t border-border "
@@ -163,10 +203,10 @@ export default function EmbeddedUpdatesPage() {
163
203
  {item.appVersion || "—"}
164
204
  </TableCell>
165
205
  <TableCell className="px-4 py-3">
166
- {item.platform}
206
+ <PlatformBadge platform={item.platform} />
167
207
  </TableCell>
168
208
  <TableCell className="px-4 py-3">
169
- <Badge variant="outline">{item.channel}</Badge>
209
+ <ChannelBadge channel={item.channel} />
170
210
  </TableCell>
171
211
  <TableCell className="px-4 py-3 font-mono text-xs">
172
212
  <span
@@ -177,17 +217,23 @@ export default function EmbeddedUpdatesPage() {
177
217
  </span>
178
218
  </TableCell>
179
219
  <TableCell className="px-4 py-3">
180
- <Button
181
- variant="destructive"
182
- size="sm"
183
- type="button"
184
- onClick={() => handleDelete(item.embeddedUpdateId)}
185
- disabled={deletingId === item.embeddedUpdateId}
186
- >
187
- {deletingId === item.embeddedUpdateId
188
- ? t("Удаление...")
189
- : t("Удалить")}
190
- </Button>
220
+ {canWrite ? (
221
+ <Button
222
+ variant="destructive"
223
+ size="sm"
224
+ type="button"
225
+ onClick={() =>
226
+ handleDelete(item.embeddedUpdateId)
227
+ }
228
+ disabled={deletingId === item.embeddedUpdateId}
229
+ >
230
+ {deletingId === item.embeddedUpdateId
231
+ ? t("Удаление...")
232
+ : t("Удалить")}
233
+ </Button>
234
+ ) : (
235
+ t("Read only")
236
+ )}
191
237
  </TableCell>
192
238
  </TableRow>
193
239
  ))