create-expo-updates-server 0.4.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +4 -2
  2. package/dist/template/Dockerfile +4 -6
  3. package/dist/template/README.md +4 -9
  4. package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
  5. package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
  6. package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
  7. package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
  8. package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
  9. package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
  10. package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
  11. package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
  12. package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
  13. package/dist/template/app/api/admin/updates/route.test.ts +21 -0
  14. package/dist/template/app/api/admin/updates/route.ts +12 -1
  15. package/dist/template/app/globals.css +65 -68
  16. package/dist/template/app/login/page.tsx +66 -42
  17. package/dist/template/app/updates/[encodedKey]/page.tsx +375 -263
  18. package/dist/template/app/updates/devices/page.tsx +188 -152
  19. package/dist/template/app/updates/embedded/page.tsx +63 -29
  20. package/dist/template/app/updates/emergency-redirects/page.tsx +93 -58
  21. package/dist/template/app/updates/layout.tsx +2 -1
  22. package/dist/template/app/updates/page.tsx +381 -283
  23. package/dist/template/app/updates/releases.test.tsx +156 -0
  24. package/dist/template/components/admin/admin-role.ts +5 -0
  25. package/dist/template/components/admin/admin-shell.tsx +166 -101
  26. package/dist/template/components/admin/confirm-action.tsx +123 -0
  27. package/dist/template/components/admin/language-switcher.tsx +25 -17
  28. package/dist/template/components/admin/release-badges.test.tsx +50 -0
  29. package/dist/template/components/admin/release-badges.tsx +101 -0
  30. package/dist/template/components/ui/alert.tsx +10 -3
  31. package/dist/template/components/ui/avatar.tsx +108 -0
  32. package/dist/template/components/ui/badge.tsx +2 -2
  33. package/dist/template/components/ui/breadcrumb.tsx +108 -0
  34. package/dist/template/components/ui/button.tsx +5 -5
  35. package/dist/template/components/ui/card.tsx +2 -2
  36. package/dist/template/components/ui/chart.tsx +1 -1
  37. package/dist/template/components/ui/collapsible.tsx +7 -0
  38. package/dist/template/components/ui/empty.tsx +103 -0
  39. package/dist/template/components/ui/field.tsx +248 -0
  40. package/dist/template/components/ui/input-group.tsx +170 -0
  41. package/dist/template/components/ui/input.tsx +1 -1
  42. package/dist/template/components/ui/native-select.tsx +1 -1
  43. package/dist/template/components/ui/radio-group.tsx +41 -0
  44. package/dist/template/components/ui/status-tones.ts +15 -0
  45. package/dist/template/components/ui/table.tsx +1 -1
  46. package/dist/template/components/ui/textarea.tsx +1 -1
  47. package/dist/template/docs/admin-ui.md +7 -3
  48. package/dist/template/docs/device-targeting.md +2 -7
  49. package/dist/template/docs/doctor.md +2 -2
  50. package/dist/template/docs/expo-app-setup.md +9 -27
  51. package/dist/template/docs/getting-started.md +3 -4
  52. package/dist/template/docs/installation-telemetry.md +2 -8
  53. package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
  54. package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
  55. package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
  56. package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
  57. package/dist/template/docs/migrations/schema.sql +349 -0
  58. package/dist/template/docs/npm-installer.md +3 -3
  59. package/dist/template/docs/operations-guide.md +8 -6
  60. package/dist/template/docs/ota-client-lifecycle.md +30 -68
  61. package/dist/template/docs/ota-update-policy.md +9 -20
  62. package/dist/template/docs/ru/admin-ui.md +7 -3
  63. package/dist/template/docs/ru/device-targeting.md +2 -2
  64. package/dist/template/docs/ru/doctor.md +2 -2
  65. package/dist/template/docs/ru/expo-app-setup.md +9 -9
  66. package/dist/template/docs/ru/getting-started.md +3 -3
  67. package/dist/template/docs/ru/installation-telemetry.md +2 -2
  68. package/dist/template/docs/ru/npm-installer.md +3 -3
  69. package/dist/template/docs/ru/operations-guide.md +8 -3
  70. package/dist/template/docs/ru/ota-client-lifecycle.md +30 -35
  71. package/dist/template/docs/ru/ota-update-policy.md +9 -7
  72. package/dist/template/docs/ru/publishing-npm-installer.md +2 -2
  73. package/dist/template/docs/uk/admin-ui.md +7 -3
  74. package/dist/template/docs/uk/device-targeting.md +2 -2
  75. package/dist/template/docs/uk/doctor.md +2 -2
  76. package/dist/template/docs/uk/expo-app-setup.md +9 -9
  77. package/dist/template/docs/uk/getting-started.md +3 -3
  78. package/dist/template/docs/uk/installation-telemetry.md +2 -2
  79. package/dist/template/docs/uk/npm-installer.md +3 -3
  80. package/dist/template/docs/uk/operations-guide.md +8 -3
  81. package/dist/template/docs/uk/ota-client-lifecycle.md +30 -35
  82. package/dist/template/docs/uk/ota-update-policy.md +9 -7
  83. package/dist/template/docs/uk/publishing-npm-installer.md +2 -2
  84. package/dist/template/lib/audience-ids.ts +4 -0
  85. package/dist/template/package-lock.json +46 -0
  86. package/dist/template/package.json +3 -1
  87. package/dist/template/scripts/configure-expo-app.mjs +3 -3
  88. package/dist/template/scripts/create-access-token.mjs +1 -1
  89. package/dist/template/scripts/lib/doctor.mjs +10 -7
  90. package/dist/template/scripts/lib/doctor.test.mjs +7 -5
  91. package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
  92. package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
  93. package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
  94. package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
  95. package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
  96. package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
  97. package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
  98. package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
  99. package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
  100. package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
  101. package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
  102. package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
  103. package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
  104. package/dist/template/scripts/tests/e2e/console.mjs +86 -0
  105. package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
  106. package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
  107. package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
  108. package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
  109. package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
  110. package/dist/template/scripts/tests/e2e/release-matrix.mjs +303 -0
  111. package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
  112. package/dist/template/scripts/tests/e2e/run.mjs +224 -0
  113. package/dist/template/scripts/tests/manifest-identity.sql +7 -5
  114. package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
  115. package/dist/template/src/client/admin-api.ts +45 -10
  116. package/dist/template/src/client/admin-types.ts +35 -1
  117. package/dist/template/src/client/devices/analytics.tsx +168 -231
  118. package/dist/template/src/client/devices/cohorts.tsx +181 -0
  119. package/dist/template/src/client/devices/device-name.tsx +37 -23
  120. package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
  121. package/dist/template/src/client/devices/registry.tsx +258 -245
  122. package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
  123. package/dist/template/src/client/devices/use-devices-report.ts +53 -82
  124. package/dist/template/src/client/devices/version-adoption-chart.tsx +47 -49
  125. package/dist/template/src/client/distribution-control.tsx +89 -57
  126. package/dist/template/src/client/distribution-history.tsx +353 -0
  127. package/dist/template/src/client/guard-action-catalog.tsx +183 -0
  128. package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
  129. package/dist/template/src/client/guard-action-combobox.tsx +133 -239
  130. package/dist/template/src/client/guard-action-options.ts +4 -6
  131. package/dist/template/src/client/i18n/en.json +133 -2
  132. package/dist/template/src/client/i18n/language-switching.test.tsx +12 -3
  133. package/dist/template/src/client/i18n/ru.json +133 -2
  134. package/dist/template/src/client/i18n/uk.json +133 -2
  135. package/dist/template/src/client/logout-button.tsx +3 -3
  136. package/dist/template/src/client/policy-draft.ts +138 -0
  137. package/dist/template/src/client/update-audience-editor.tsx +597 -206
  138. package/dist/template/src/client/update-policy-editor.test.ts +101 -29
  139. package/dist/template/src/client/update-policy-editor.tsx +454 -320
  140. package/dist/template/src/client/use-filtered-results.ts +55 -0
  141. package/dist/template/src/server/controllers/manifest.test.ts +25 -3
  142. package/dist/template/src/server/controllers/manifest.ts +1 -2
  143. package/dist/template/src/server/devices/audience.ts +9 -5
  144. package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
  145. package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
  146. package/dist/template/src/server/lib/admin-updates.ts +160 -534
  147. package/dist/template/src/server/lib/distribution-history.ts +97 -0
  148. package/dist/template/src/server/lib/supabase.js +24 -0
  149. package/dist/template/src/server/lib/supabase.test.ts +38 -1
  150. package/dist/template/src/server/lib/update-policy.test.ts +20 -0
  151. package/dist/template/src/server/lib/update-policy.ts +23 -10
  152. package/dist/template/src/server/manifest/manifest-repository.ts +2 -2
  153. package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
  154. package/dist/template/src/server/manifest/manifest-values.ts +21 -13
  155. package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
  156. package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
  157. package/dist/template/tsconfig.json +2 -2
  158. package/dist/template-manifest.json +445 -300
  159. package/package.json +1 -1
  160. package/dist/template/scripts/lib/device-identity.test.ts +0 -29
  161. package/dist/template/scripts/lib/ota-client.test.ts +0 -55
  162. package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
  163. package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
  164. package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
  165. package/dist/template/templates/expo-app/ota-client/README.md +0 -73
  166. package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
  167. package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
  168. package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
  169. package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
  170. package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
  171. package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
  172. package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
  173. package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
  174. package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
  175. package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
@@ -1,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,178 +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
- className={
61
- loading ? "animate-spin motion-reduce:animate-none" : ""
62
- }
63
+ className={loading ? "animate-spin motion-reduce:animate-none" : ""}
63
64
  />
64
65
  {loading ? t("Обновление…") : t("Обновить")}
65
66
  </Button>
66
67
  </header>
67
- <Card className="gap-0 py-5 shadow-none">
68
- <CardContent>
69
- <div className="mb-4 flex items-center gap-2 text-sm font-medium">
70
- <SlidersHorizontal className="size-4 text-muted-foreground" />
71
- {t("Фильтры")}
72
- {activeFilters > 0 && (
73
- <Badge variant="secondary">{activeFilters}</Badge>
74
- )}
75
- <span className="ml-auto text-xs font-normal text-muted-foreground">
76
- {t("Вся выборка")}
77
- </span>
78
- </div>
79
- <form
80
- onSubmit={(e) => {
81
- e.preventDefault();
82
- apply();
83
- }}
84
- className="grid grid-cols-2 items-end gap-3 lg:grid-cols-3 2xl:grid-cols-6"
85
- >
86
- <Filter
87
- label={t("Период активности")}
88
- id="days"
89
- value={filters.days}
90
- onChange={(v) => update("days", v)}
91
- items={[
92
- ["1", t("24 часа")],
93
- ["7", t("7 дней")],
94
- ["30", t("30 дней")],
95
- ]}
96
- />
97
- <Filter
98
- label={t("Платформа")}
99
- id="platform"
100
- value={filters.platform}
101
- onChange={(v) => update("platform", v)}
102
- items={[
103
- ["", t("Все платформы")],
104
- ...["android", "ios"].map((v) => [
105
- v,
106
- v === "ios" ? "iOS" : "Android",
107
- ]),
108
- ]}
109
- />
110
- <Filter
111
- label={t("Канал")}
112
- id="channel"
113
- value={filters.channel}
114
- onChange={(v) => update("channel", v)}
115
- items={[
116
- ["", t("Все каналы")],
117
- ...(options?.channels || []).map((v) => [v, v]),
118
- ]}
119
- />
120
- <Filter
121
- label={t("Runtime")}
122
- id="runtime"
123
- value={filters.runtime}
124
- onChange={(v) => update("runtime", v)}
125
- items={[
126
- ["", t("Все runtime")],
127
- ...(options?.runtimes || []).map((v) => [v, v]),
128
- ]}
129
- />
130
- <Filter
131
- label={t("Тип запуска")}
132
- id="launchKind"
133
- value={filters.launchKind}
134
- onChange={(v) => update("launchKind", v)}
135
- items={[["", t("Все типы")], ...Object.entries(kindNames)]}
136
- />
137
- <div className="grid gap-2">
138
- <Label htmlFor="installation-search">
139
- {t("Installation ID")}
140
- </Label>
141
- <Input
142
- id="installation-search"
143
- placeholder={t("ID или часть ID")}
144
- value={filters.search}
145
- maxLength={36}
146
- pattern="[a-fA-F0-9\-]*"
147
- title={t("Часть UUID: цифры, буквы a–f и дефисы")}
148
- onChange={(e) => update("search", e.target.value)}
149
- className="bg-background/40"
150
- />
151
- </div>
152
- <div className="flex flex-wrap items-center gap-2 col-span-2 lg:col-span-3 2xl:col-span-6">
153
- <Button type="submit" size="sm" disabled={loading}>
154
- {t("Применить")}
155
- </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>
156
72
  <Button
157
- type="button"
158
- size="sm"
159
73
  variant="ghost"
160
- onClick={reset}
161
- 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("Фильтры")}
162
76
  >
163
- <X />
164
- {t("Сбросить")}
165
- </Button>
166
- {dirty && (
167
- <span className="text-xs text-muted-foreground">
168
- {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}
169
84
  </span>
170
- )}
171
- <span className="ml-auto text-xs text-muted-foreground">
172
- {report && !loading
173
- ? t("Данные на {0}", [
174
- new Date(
175
- report.coverage.generatedAt,
176
- ).toLocaleTimeString(formatLocale, {
177
- hour: "2-digit",
178
- minute: "2-digit",
179
- }),
180
- ])
181
- : ""}
182
- </span>
183
- </div>
184
- </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>
185
180
  </CardContent>
186
181
  </Card>
187
182
  {error && (
@@ -216,20 +211,61 @@ export default function DevicesPage() {
216
211
  <Skeleton className="h-64 rounded-xl" />
217
212
  </div>
218
213
  ) : report ? (
219
- <div
220
- className={loading ? "space-y-6 opacity-60" : "space-y-6"}
214
+ <Tabs
215
+ defaultValue="overview"
216
+ className="min-w-0 gap-4"
221
217
  aria-busy={loading}
222
218
  >
223
- <Analytics report={report} />
224
- <Registry report={report} loading={loading} paginate={paginate} />
225
- <p className="text-xs leading-5 text-muted-foreground">
226
- {t(
227
- "Метрика считает установки приложения, а не уникальных людей. Сводка и реестр отражают последнее состояние; график — состояние на конец каждого дня. Переустановка может изменить Installation ID.",
228
- )}
229
- </p>
230
- </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>
231
267
  ) : null}
232
- </main>
268
+ </div>
233
269
  );
234
270
  }
235
271
  function Filter({
@@ -1,9 +1,14 @@
1
1
  "use client";
2
+ import { Alert, AlertDescription } from "@/components/ui/alert";
3
+ import { useConfirmAction } from "@/components/admin/confirm-action";
2
4
  import type { TranslationMessage } from "@/src/client/i18n/messages";
3
5
  import { useI18n } from "@/src/client/i18n/provider";
4
6
 
7
+ import { AdminRoleContext } from "@/components/admin/admin-role";
8
+ import { Input } from "@/components/ui/input";
5
9
  import { Button } from "@/components/ui/button";
6
10
  import { Card } from "@/components/ui/card";
11
+ import { PlatformBadge, ChannelBadge } from "@/components/admin/release-badges";
7
12
  import { Badge } from "@/components/ui/badge";
8
13
  import {
9
14
  Table,
@@ -19,9 +24,12 @@ import {
19
24
  getEmbeddedUpdates,
20
25
  } from "@/src/client/admin-api";
21
26
  import { EmbeddedUpdateItem } from "@/src/client/admin-types";
22
- import { useCallback, useEffect, useState } from "react";
27
+ import { useContext, useCallback, useEffect, useState } from "react";
23
28
 
24
29
  export default function EmbeddedUpdatesPage() {
30
+ const canWrite = useContext(AdminRoleContext) !== "viewer";
31
+ const [query, setQuery] = useState("");
32
+ const confirmAction = useConfirmAction();
25
33
  const { t, formatLocale } = useI18n();
26
34
  const [items, setItems] = useState<EmbeddedUpdateItem[]>([]);
27
35
  const [loading, setLoading] = useState(true);
@@ -51,8 +59,10 @@ export default function EmbeddedUpdatesPage() {
51
59
  }, [loadItems]);
52
60
 
53
61
  const handleDelete = async (embeddedUpdateId: string) => {
54
- const confirmed = window.confirm(
62
+ const confirmed = await confirmAction(
63
+ t("Удалить"),
55
64
  t("Удалить запись embedded update {0}?", [embeddedUpdateId]),
65
+ true,
56
66
  );
57
67
  if (!confirmed) {
58
68
  return;
@@ -79,6 +89,13 @@ export default function EmbeddedUpdatesPage() {
79
89
  }
80
90
  };
81
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
+
82
99
  return (
83
100
  <div className="mx-auto max-w-[1600px] space-y-6 p-4 md:p-8">
84
101
  <div className="space-y-6">
@@ -88,29 +105,42 @@ export default function EmbeddedUpdatesPage() {
88
105
  {t("Embedded builds")}
89
106
  </h1>
90
107
  <p className="text-sm text-muted-foreground">
91
- {t(
92
- "Встроенные версии приложения и регистрация нативных сборок.",
93
- )}
108
+ {t("Встроенные версии приложения и регистрация нативных сборок.")}
94
109
  </p>
95
110
  </div>
96
- <Badge variant="secondary" className="px-3 py-1">
111
+ <Badge variant="info" className="px-3 py-1">
97
112
  {t("Builds: {0}", [items.length])}
98
113
  </Badge>
99
114
  </header>
100
115
 
101
116
  {error ? (
102
- <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">
103
- {t(error)}
104
- </div>
117
+ <Alert variant="destructive">
118
+ <AlertDescription>{t(error)}</AlertDescription>
119
+ </Alert>
105
120
  ) : null}
106
121
 
107
122
  {success ? (
108
- <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">
109
- {t(success)}
110
- </div>
123
+ <Alert role="status">
124
+ <AlertDescription>{t(success)}</AlertDescription>
125
+ </Alert>
111
126
  ) : null}
112
127
 
113
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>
114
144
  <div className="overflow-x-auto">
115
145
  <Table className="min-w-full text-sm">
116
146
  <TableHeader className="bg-muted/40">
@@ -147,7 +177,7 @@ export default function EmbeddedUpdatesPage() {
147
177
  </TableRow>
148
178
  ) : null}
149
179
 
150
- {!loading && items.length === 0 ? (
180
+ {!loading && visible.length === 0 ? (
151
181
  <TableRow>
152
182
  <TableCell
153
183
  className="h-36 px-3 py-4 text-center text-muted-foreground"
@@ -159,7 +189,7 @@ export default function EmbeddedUpdatesPage() {
159
189
  ) : null}
160
190
 
161
191
  {!loading
162
- ? items.map((item) => (
192
+ ? visible.map((item) => (
163
193
  <TableRow
164
194
  key={item.embeddedUpdateId}
165
195
  className="border-t border-border "
@@ -173,10 +203,10 @@ export default function EmbeddedUpdatesPage() {
173
203
  {item.appVersion || "—"}
174
204
  </TableCell>
175
205
  <TableCell className="px-4 py-3">
176
- {item.platform}
206
+ <PlatformBadge platform={item.platform} />
177
207
  </TableCell>
178
208
  <TableCell className="px-4 py-3">
179
- <Badge variant="outline">{item.channel}</Badge>
209
+ <ChannelBadge channel={item.channel} />
180
210
  </TableCell>
181
211
  <TableCell className="px-4 py-3 font-mono text-xs">
182
212
  <span
@@ -187,19 +217,23 @@ export default function EmbeddedUpdatesPage() {
187
217
  </span>
188
218
  </TableCell>
189
219
  <TableCell className="px-4 py-3">
190
- <Button
191
- variant="destructive"
192
- size="sm"
193
- type="button"
194
- onClick={() =>
195
- handleDelete(item.embeddedUpdateId)
196
- }
197
- disabled={deletingId === item.embeddedUpdateId}
198
- >
199
- {deletingId === item.embeddedUpdateId
200
- ? t("Удаление...")
201
- : t("Удалить")}
202
- </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
+ )}
203
237
  </TableCell>
204
238
  </TableRow>
205
239
  ))