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.
- package/README.md +4 -2
- package/dist/template/Dockerfile +4 -6
- package/dist/template/README.md +5 -10
- package/dist/template/app/api/admin/device-favorites/route.test.ts +125 -0
- package/dist/template/app/api/admin/device-favorites/route.ts +91 -0
- package/dist/template/app/api/admin/distribution-history/restore/route.ts +39 -0
- package/dist/template/app/api/admin/distribution-history/route.test.ts +55 -0
- package/dist/template/app/api/admin/distribution-history/route.ts +24 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/deactivate/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/promote/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/rollback/route.ts +2 -1
- package/dist/template/app/api/admin/updates/[encodedKey]/route.ts +2 -1
- package/dist/template/app/api/admin/updates/route.test.ts +21 -0
- package/dist/template/app/api/admin/updates/route.ts +12 -1
- package/dist/template/app/globals.css +65 -68
- package/dist/template/app/login/page.tsx +66 -42
- package/dist/template/app/updates/[encodedKey]/page.tsx +382 -248
- package/dist/template/app/updates/devices/page.tsx +187 -145
- package/dist/template/app/updates/embedded/page.tsx +80 -34
- package/dist/template/app/updates/emergency-redirects/page.tsx +138 -71
- package/dist/template/app/updates/layout.tsx +2 -1
- package/dist/template/app/updates/page.tsx +385 -274
- package/dist/template/app/updates/releases.test.tsx +156 -0
- package/dist/template/components/admin/admin-role.ts +5 -0
- package/dist/template/components/admin/admin-shell.tsx +166 -95
- package/dist/template/components/admin/confirm-action.tsx +123 -0
- package/dist/template/components/admin/language-switcher.tsx +27 -16
- package/dist/template/components/admin/release-badges.test.tsx +50 -0
- package/dist/template/components/admin/release-badges.tsx +101 -0
- package/dist/template/components/ui/alert.tsx +10 -3
- package/dist/template/components/ui/avatar.tsx +108 -0
- package/dist/template/components/ui/badge.tsx +2 -2
- package/dist/template/components/ui/breadcrumb.tsx +108 -0
- package/dist/template/components/ui/button.tsx +5 -5
- package/dist/template/components/ui/card.tsx +2 -2
- package/dist/template/components/ui/chart.tsx +1 -1
- package/dist/template/components/ui/collapsible.tsx +7 -0
- package/dist/template/components/ui/dialog.tsx +13 -4
- package/dist/template/components/ui/empty.tsx +103 -0
- package/dist/template/components/ui/field.tsx +248 -0
- package/dist/template/components/ui/input-group.tsx +170 -0
- package/dist/template/components/ui/input.tsx +1 -1
- package/dist/template/components/ui/native-select.tsx +1 -1
- package/dist/template/components/ui/radio-group.tsx +41 -0
- package/dist/template/components/ui/sheet.tsx +6 -2
- package/dist/template/components/ui/sidebar.tsx +62 -17
- package/dist/template/components/ui/status-tones.ts +15 -0
- package/dist/template/components/ui/table.tsx +1 -1
- package/dist/template/components/ui/textarea.tsx +1 -1
- package/dist/template/docs/admin-ui.md +22 -24
- package/dist/template/docs/device-targeting.md +6 -12
- package/dist/template/docs/doctor.md +2 -2
- package/dist/template/docs/expo-app-setup.md +9 -27
- package/dist/template/docs/getting-started.md +3 -4
- package/dist/template/docs/getting-started.ru.md +11 -544
- package/dist/template/docs/index.md +1 -1
- package/dist/template/docs/installation-telemetry.md +6 -12
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-device-favorites.sql +53 -0
- package/dist/template/docs/migrations/2026-11-25-download-on-postpone.sql +5 -0
- package/dist/template/docs/migrations/2026-11-25-public-distribution-history.sql +283 -0
- package/dist/template/docs/migrations/schema.sql +349 -0
- package/dist/template/docs/npm-installer.md +3 -3
- package/dist/template/docs/operations-guide.md +9 -7
- package/dist/template/docs/ota-client-lifecycle.md +30 -68
- package/dist/template/docs/ota-emergency-recovery.md +34 -57
- package/dist/template/docs/ota-update-policy.md +9 -20
- package/dist/template/docs/ru/admin-ui.md +33 -0
- package/dist/template/docs/ru/device-targeting.md +59 -0
- package/dist/template/docs/ru/doctor.md +98 -0
- package/dist/template/docs/ru/expo-app-setup.md +497 -0
- package/dist/template/docs/ru/getting-started.md +391 -0
- package/dist/template/docs/ru/index.md +50 -0
- package/dist/template/docs/ru/installation-telemetry.md +125 -0
- package/dist/template/docs/ru/npm-installer.md +71 -0
- package/dist/template/docs/ru/operations-guide.md +322 -0
- package/dist/template/docs/ru/ota-client-lifecycle.md +162 -0
- package/dist/template/docs/ru/ota-emergency-recovery.md +108 -0
- package/dist/template/docs/ru/ota-update-policy.md +69 -0
- package/dist/template/docs/ru/publishing-npm-installer.md +49 -0
- package/dist/template/docs/ru/supabase-setup.md +120 -0
- package/dist/template/docs/uk/admin-ui.md +33 -0
- package/dist/template/docs/uk/device-targeting.md +59 -0
- package/dist/template/docs/uk/doctor.md +98 -0
- package/dist/template/docs/uk/expo-app-setup.md +497 -0
- package/dist/template/docs/uk/getting-started.md +391 -0
- package/dist/template/docs/uk/index.md +50 -0
- package/dist/template/docs/uk/installation-telemetry.md +125 -0
- package/dist/template/docs/uk/npm-installer.md +71 -0
- package/dist/template/docs/uk/operations-guide.md +322 -0
- package/dist/template/docs/uk/ota-client-lifecycle.md +162 -0
- package/dist/template/docs/uk/ota-emergency-recovery.md +108 -0
- package/dist/template/docs/uk/ota-update-policy.md +69 -0
- package/dist/template/docs/uk/publishing-npm-installer.md +49 -0
- package/dist/template/docs/uk/supabase-setup.md +120 -0
- package/dist/template/lib/audience-ids.ts +4 -0
- package/dist/template/package-lock.json +46 -0
- package/dist/template/package.json +4 -1
- package/dist/template/scripts/configure-expo-app.mjs +3 -3
- package/dist/template/scripts/create-access-token.mjs +1 -1
- package/dist/template/scripts/lib/doctor.mjs +10 -7
- package/dist/template/scripts/lib/doctor.test.mjs +7 -5
- package/dist/template/scripts/lib/embedded-update-registrar.test.ts +22 -7
- package/dist/template/scripts/lib/expo-app-configurator.mjs +25 -22
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +37 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +152 -55
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +60 -20
- package/dist/template/scripts/lib/ota-client-package.mjs +25 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +90 -32
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +49 -6
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +12 -1
- package/dist/template/scripts/tests/device-targeting-activation.mjs +2 -3
- package/dist/template/scripts/tests/e2e/client-lifecycle.mjs +161 -0
- package/dist/template/scripts/tests/e2e/client-lifecycle.scenario.jsx +465 -0
- package/dist/template/scripts/tests/e2e/client-vitest.mts +18 -0
- package/dist/template/scripts/tests/e2e/console.mjs +86 -0
- package/dist/template/scripts/tests/e2e/delivery.mjs +296 -0
- package/dist/template/scripts/tests/e2e/device-favorites.mjs +309 -0
- package/dist/template/scripts/tests/e2e/installations.mjs +132 -0
- package/dist/template/scripts/tests/e2e/policy.mjs +253 -0
- package/dist/template/scripts/tests/e2e/registrar-token.mjs +59 -0
- package/dist/template/scripts/tests/e2e/release-matrix.mjs +307 -0
- package/dist/template/scripts/tests/e2e/releases.mjs +162 -0
- package/dist/template/scripts/tests/e2e/run.mjs +224 -0
- package/dist/template/scripts/tests/manifest-identity.sql +7 -5
- package/dist/template/scripts/tests/public-distribution-history.mjs +102 -0
- package/dist/template/src/client/admin-api.ts +45 -10
- package/dist/template/src/client/admin-types.ts +35 -1
- package/dist/template/src/client/devices/analytics.tsx +169 -219
- package/dist/template/src/client/devices/cohorts.tsx +181 -0
- package/dist/template/src/client/devices/device-name.tsx +37 -21
- package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
- package/dist/template/src/client/devices/registry.tsx +265 -233
- package/dist/template/src/client/devices/use-devices-report.test.tsx +98 -0
- package/dist/template/src/client/devices/use-devices-report.ts +53 -82
- package/dist/template/src/client/devices/version-adoption-chart.tsx +48 -38
- package/dist/template/src/client/distribution-control.tsx +98 -53
- package/dist/template/src/client/distribution-history.tsx +353 -0
- package/dist/template/src/client/guard-action-catalog.tsx +183 -0
- package/dist/template/src/client/guard-action-combobox.test.ts +16 -22
- package/dist/template/src/client/guard-action-combobox.tsx +134 -234
- package/dist/template/src/client/guard-action-options.ts +4 -6
- package/dist/template/src/client/i18n/en.json +335 -2
- package/dist/template/src/client/i18n/language-switching.test.tsx +233 -0
- package/dist/template/src/client/i18n/messages.test.ts +102 -19
- package/dist/template/src/client/i18n/messages.ts +31 -16
- package/dist/template/src/client/i18n/provider.tsx +6 -3
- package/dist/template/src/client/i18n/ru.json +619 -0
- package/dist/template/src/client/i18n/uk.json +619 -0
- package/dist/template/src/client/i18n/use-formatters.ts +5 -0
- package/dist/template/src/client/logout-button.tsx +3 -3
- package/dist/template/src/client/policy-draft.ts +138 -0
- package/dist/template/src/client/update-audience-editor.tsx +597 -199
- package/dist/template/src/client/update-policy-editor.test.ts +101 -29
- package/dist/template/src/client/update-policy-editor.tsx +466 -307
- package/dist/template/src/client/use-filtered-results.ts +55 -0
- package/dist/template/src/server/controllers/manifest.test.ts +23 -3
- package/dist/template/src/server/controllers/manifest.ts +15 -1
- package/dist/template/src/server/devices/audience.ts +9 -5
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +37 -90
- package/dist/template/src/server/lib/admin-release-history.test.ts +138 -0
- package/dist/template/src/server/lib/admin-updates.ts +160 -534
- package/dist/template/src/server/lib/distribution-history.ts +97 -0
- package/dist/template/src/server/lib/supabase.js +24 -0
- package/dist/template/src/server/lib/supabase.test.ts +38 -1
- package/dist/template/src/server/lib/update-policy.test.ts +20 -0
- package/dist/template/src/server/lib/update-policy.ts +23 -10
- package/dist/template/src/server/manifest/manifest-repository.ts +11 -3
- package/dist/template/src/server/manifest/manifest-values.test.ts +2 -0
- package/dist/template/src/server/manifest/manifest-values.ts +21 -13
- package/dist/template/templates/expo-app/scripts/ota-publish/api/database-client.mjs +7 -30
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +2 -1
- package/dist/template/tsconfig.json +2 -2
- package/dist/template-manifest.json +571 -271
- package/package.json +1 -1
- package/dist/template/scripts/lib/device-identity.test.ts +0 -29
- package/dist/template/scripts/lib/ota-client.test.ts +0 -55
- package/dist/template/scripts/lib/ota-update-controller.test.ts +0 -232
- package/dist/template/scripts/lib/ota-updates-ui.test.tsx +0 -154
- package/dist/template/scripts/tests/ota-client-types.mjs +0 -69
- package/dist/template/templates/expo-app/ota-client/README.md +0 -73
- package/dist/template/templates/expo-app/ota-client/controller.ts +0 -107
- package/dist/template/templates/expo-app/ota-client/device-identity.ts +0 -48
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +0 -61
- package/dist/template/templates/expo-app/ota-client/index.ts +0 -16
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.ts +0 -97
- package/dist/template/templates/expo-app/ota-client/model/update-controller.ts +0 -293
- package/dist/template/templates/expo-app/ota-client/runtime.ts +0 -153
- package/dist/template/templates/expo-app/ota-client/types.ts +0 -85
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.tsx +0 -25
- package/dist/template/templates/expo-app/ota-client/ui/ota-updates.tsx +0 -196
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act, useLayoutEffect } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
|
5
|
+
import { useDevicesReport } from "./use-devices-report";
|
|
6
|
+
|
|
7
|
+
let root: Root;
|
|
8
|
+
let state: ReturnType<typeof useDevicesReport>;
|
|
9
|
+
const fetchReport = vi.fn<typeof fetch>();
|
|
10
|
+
const response = (total: number, offset = 0) =>
|
|
11
|
+
Response.json({
|
|
12
|
+
total,
|
|
13
|
+
offset,
|
|
14
|
+
pageSize: 20,
|
|
15
|
+
options: { channels: [], runtimes: [] },
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function Screen() {
|
|
19
|
+
const result = useDevicesReport();
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
state = result;
|
|
22
|
+
});
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
beforeEach(async () => {
|
|
27
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
28
|
+
vi.useFakeTimers();
|
|
29
|
+
fetchReport.mockReset().mockImplementation(async () => response(24));
|
|
30
|
+
vi.stubGlobal("fetch", fetchReport);
|
|
31
|
+
root = createRoot(document.createElement("div"));
|
|
32
|
+
await act(async () => root.render(<Screen />));
|
|
33
|
+
});
|
|
34
|
+
afterEach(async () => {
|
|
35
|
+
await act(async () => root.unmount());
|
|
36
|
+
vi.useRealTimers();
|
|
37
|
+
vi.unstubAllGlobals();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("debounces typing, cancels pending searches on select/reset, and starts filtering at the first page", async () => {
|
|
41
|
+
await act(async () => state.paginate(20));
|
|
42
|
+
await act(async () => state.update("search", "a"));
|
|
43
|
+
await act(async () => state.update("search", "ab"));
|
|
44
|
+
expect(fetchReport).toHaveBeenCalledTimes(2);
|
|
45
|
+
await act(async () => state.update("platform", "ios"));
|
|
46
|
+
const params = new URL(
|
|
47
|
+
String(fetchReport.mock.lastCall![0]),
|
|
48
|
+
"http://localhost",
|
|
49
|
+
).searchParams;
|
|
50
|
+
expect(Object.fromEntries(params)).toEqual({
|
|
51
|
+
days: "7",
|
|
52
|
+
offset: "0",
|
|
53
|
+
search: "ab",
|
|
54
|
+
platform: "ios",
|
|
55
|
+
});
|
|
56
|
+
await act(async () => state.update("search", "abc"));
|
|
57
|
+
await act(async () => state.reset());
|
|
58
|
+
await act(async () => vi.advanceTimersByTimeAsync(500));
|
|
59
|
+
expect(fetchReport).toHaveBeenCalledTimes(4);
|
|
60
|
+
expect(String(fetchReport.mock.lastCall![0])).not.toContain("search=");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it("keeps the last success through errors and ignores late responses from aborted requests", async () => {
|
|
64
|
+
let resolveLate!: (value: Response) => void;
|
|
65
|
+
fetchReport.mockImplementationOnce(
|
|
66
|
+
() =>
|
|
67
|
+
new Promise((resolve) => {
|
|
68
|
+
resolveLate = resolve;
|
|
69
|
+
}),
|
|
70
|
+
);
|
|
71
|
+
await act(async () => state.update("days", "1"));
|
|
72
|
+
const signal = fetchReport.mock.lastCall![1]!.signal!;
|
|
73
|
+
await act(async () => state.update("search", "a"));
|
|
74
|
+
expect(signal.aborted).toBe(true);
|
|
75
|
+
fetchReport.mockResolvedValueOnce(
|
|
76
|
+
Response.json({ error: "Temporary outage" }, { status: 503 }),
|
|
77
|
+
);
|
|
78
|
+
await act(async () => vi.advanceTimersByTimeAsync(300));
|
|
79
|
+
expect(state.error).toBe("Temporary outage");
|
|
80
|
+
await act(async () => resolveLate(response(900)));
|
|
81
|
+
expect(state.report?.total).toBe(24);
|
|
82
|
+
expect(state.error).toBe("Temporary outage");
|
|
83
|
+
fetchReport.mockResolvedValueOnce(response(2));
|
|
84
|
+
await act(async () => state.refresh());
|
|
85
|
+
expect(state.report?.total).toBe(2);
|
|
86
|
+
expect(state.error).toBe("");
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it("retrieves the last available page when a refresh shrinks the registry", async () => {
|
|
90
|
+
fetchReport
|
|
91
|
+
.mockResolvedValueOnce(response(23, 40))
|
|
92
|
+
.mockResolvedValueOnce(response(23, 20));
|
|
93
|
+
await act(async () => state.paginate(40));
|
|
94
|
+
expect(String(fetchReport.mock.lastCall![0])).toContain("offset=20");
|
|
95
|
+
expect(state.report?.offset).toBe(20);
|
|
96
|
+
await act(async () => state.refresh());
|
|
97
|
+
expect(String(fetchReport.mock.lastCall![0])).toContain("offset=20");
|
|
98
|
+
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useI18n } from "@/src/client/i18n/provider";
|
|
3
2
|
|
|
4
|
-
import {
|
|
3
|
+
import { useFilteredResults } from "@/src/client/use-filtered-results";
|
|
5
4
|
import type { DevicesReport } from "@/src/server/devices/report-types";
|
|
6
5
|
export type Filters = {
|
|
7
6
|
days: string;
|
|
@@ -19,90 +18,62 @@ export const defaultFilters: Filters = {
|
|
|
19
18
|
launchKind: "",
|
|
20
19
|
search: "",
|
|
21
20
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
fetch(`/api/admin/devices?${params}`, {
|
|
38
|
-
signal
|
|
21
|
+
const initialQuery = { ...defaultFilters, offset: 0 };
|
|
22
|
+
|
|
23
|
+
async function loadReport(
|
|
24
|
+
query: typeof initialQuery,
|
|
25
|
+
signal: AbortSignal,
|
|
26
|
+
): Promise<DevicesReport> {
|
|
27
|
+
if (!/^[a-f0-9-]{0,36}$/i.test(query.search.trim()))
|
|
28
|
+
throw new Error("Часть UUID: цифры, буквы a–f и дефисы");
|
|
29
|
+
|
|
30
|
+
const params = new URLSearchParams();
|
|
31
|
+
for (const [key, value] of Object.entries(query)) {
|
|
32
|
+
if (String(value).trim()) params.set(key, String(value).trim());
|
|
33
|
+
}
|
|
34
|
+
for (;;) {
|
|
35
|
+
signal.throwIfAborted();
|
|
36
|
+
const response = await fetch(`/api/admin/devices?${params}`, {
|
|
37
|
+
signal,
|
|
39
38
|
cache: "no-store",
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
63
|
-
.catch((e) => {
|
|
64
|
-
if (!controller.signal.aborted) {
|
|
65
|
-
setError(e.message);
|
|
66
|
-
setLoading(false);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
return () => controller.abort();
|
|
70
|
-
}, [applied, offset, revision]);
|
|
71
|
-
const refresh = () => {
|
|
72
|
-
setLoading(true);
|
|
73
|
-
setError("");
|
|
74
|
-
setRevision((n) => n + 1);
|
|
75
|
-
};
|
|
76
|
-
const apply = () => {
|
|
77
|
-
setLoading(true);
|
|
78
|
-
setError("");
|
|
79
|
-
setApplied({ ...filters });
|
|
80
|
-
setOffset(0);
|
|
81
|
-
};
|
|
82
|
-
const reset = () => {
|
|
83
|
-
setFilters(defaultFilters);
|
|
84
|
-
setApplied({ ...defaultFilters });
|
|
85
|
-
setOffset(0);
|
|
86
|
-
setLoading(true);
|
|
87
|
-
setError("");
|
|
88
|
-
};
|
|
89
|
-
const paginate = (next: number) => {
|
|
90
|
-
setLoading(true);
|
|
91
|
-
setError("");
|
|
92
|
-
setOffset(next);
|
|
93
|
-
setRevision((n) => n + 1);
|
|
94
|
-
};
|
|
39
|
+
});
|
|
40
|
+
const data = await response.json();
|
|
41
|
+
if (!response.ok)
|
|
42
|
+
throw new Error(data.error || "Не удалось загрузить статистику");
|
|
43
|
+
const report: DevicesReport = data;
|
|
44
|
+
if (report.offset === 0 || report.offset < report.total) return report;
|
|
45
|
+
// A concurrent removal can make the requested registry page disappear.
|
|
46
|
+
const lastOffset = Math.max(
|
|
47
|
+
0,
|
|
48
|
+
Math.floor((report.total - 1) / report.pageSize) * report.pageSize,
|
|
49
|
+
);
|
|
50
|
+
params.set("offset", String(lastOffset));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function useDevicesReport() {
|
|
55
|
+
const { query, success, error, loading, request } = useFilteredResults(
|
|
56
|
+
initialQuery,
|
|
57
|
+
loadReport,
|
|
58
|
+
);
|
|
59
|
+
const { offset, ...filters } = query;
|
|
60
|
+
const report = success?.data ?? null;
|
|
95
61
|
return {
|
|
96
62
|
filters,
|
|
97
|
-
setFilters,
|
|
98
|
-
applied,
|
|
99
63
|
report,
|
|
100
|
-
error
|
|
64
|
+
error,
|
|
101
65
|
loading,
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
66
|
+
update: (key: keyof Filters, value: string) =>
|
|
67
|
+
request(
|
|
68
|
+
{ ...query, [key]: value, offset: 0 },
|
|
69
|
+
key === "search" && Boolean(value.trim()),
|
|
70
|
+
),
|
|
71
|
+
reset: () => request(initialQuery),
|
|
72
|
+
refresh: () =>
|
|
73
|
+
request({
|
|
74
|
+
...query,
|
|
75
|
+
offset: success?.query === query && report ? report.offset : offset,
|
|
76
|
+
}),
|
|
77
|
+
paginate: (offset: number) => request({ ...query, offset }),
|
|
107
78
|
};
|
|
108
79
|
}
|
|
@@ -2,14 +2,18 @@
|
|
|
2
2
|
import { useFormatters } from "@/src/client/i18n/use-formatters";
|
|
3
3
|
import { useI18n } from "@/src/client/i18n/provider";
|
|
4
4
|
|
|
5
|
+
import {
|
|
6
|
+
Collapsible,
|
|
7
|
+
CollapsibleTrigger,
|
|
8
|
+
CollapsibleContent,
|
|
9
|
+
} from "@/components/ui/collapsible";
|
|
5
10
|
import { useState } from "react";
|
|
11
|
+
import { ChevronDown, ChevronUp, BarChart3, Layers } from "lucide-react";
|
|
6
12
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
GitBranch,
|
|
12
|
-
} from "lucide-react";
|
|
13
|
+
PlatformBadge,
|
|
14
|
+
ChannelBadge,
|
|
15
|
+
launchKindTone,
|
|
16
|
+
} from "@/components/admin/release-badges";
|
|
13
17
|
import { Badge } from "@/components/ui/badge";
|
|
14
18
|
import { Button } from "@/components/ui/button";
|
|
15
19
|
import {
|
|
@@ -25,7 +29,7 @@ function useKindLabels() {
|
|
|
25
29
|
const { t } = useI18n();
|
|
26
30
|
return {
|
|
27
31
|
ota: "OTA",
|
|
28
|
-
embedded: "Embedded",
|
|
32
|
+
embedded: t("Embedded"),
|
|
29
33
|
unknown: t("Не определён"),
|
|
30
34
|
};
|
|
31
35
|
}
|
|
@@ -46,17 +50,15 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
46
50
|
: scope.versions.slice(0, PREVIEW_ROWS);
|
|
47
51
|
return (
|
|
48
52
|
<section
|
|
49
|
-
className="min-w-0 rounded-lg border p-4"
|
|
53
|
+
className="@container min-w-0 rounded-lg border bg-background/35 p-3 sm:p-4"
|
|
50
54
|
aria-label={t("Канал {0}, {1}", [scope.channel, scope.platform])}
|
|
51
55
|
>
|
|
52
56
|
<header className="mb-4 flex flex-wrap items-center justify-between gap-3">
|
|
53
57
|
<div className="flex min-w-0 flex-wrap items-center gap-2">
|
|
54
|
-
<
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<
|
|
58
|
-
{scope.platform === "ios" ? "iOS" : "Android"}
|
|
59
|
-
</Badge>
|
|
58
|
+
<h4 className="min-w-0 max-w-full">
|
|
59
|
+
<ChannelBadge channel={scope.channel} />
|
|
60
|
+
</h4>
|
|
61
|
+
<PlatformBadge platform={scope.platform} />
|
|
60
62
|
</div>
|
|
61
63
|
<span className="text-xs text-muted-foreground">
|
|
62
64
|
{t("Активных установок:")}{" "}
|
|
@@ -65,7 +67,7 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
65
67
|
</strong>
|
|
66
68
|
</span>
|
|
67
69
|
</header>
|
|
68
|
-
<div className="hidden grid-cols-[minmax(0,
|
|
70
|
+
<div className="hidden grid-cols-[minmax(0,1fr)_minmax(4rem,1.4fr)_6.5rem] gap-5 border-b pb-3 text-xs text-muted-foreground @min-[32rem]:grid">
|
|
69
71
|
<span>{t("Версия приложения / OTA")}</span>
|
|
70
72
|
<div className="flex justify-between">
|
|
71
73
|
<span>0%</span>
|
|
@@ -80,7 +82,7 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
80
82
|
{visible.map((version) => (
|
|
81
83
|
<li
|
|
82
84
|
key={version.key}
|
|
83
|
-
className="grid min-w-0 gap-x-
|
|
85
|
+
className="grid min-w-0 grid-cols-[minmax(0,1fr)_auto] gap-x-4 gap-y-2.5 border-b py-3 last:border-b-0 @min-[32rem]:grid-cols-[minmax(0,1fr)_minmax(4rem,1.4fr)_6.5rem] @min-[32rem]:items-center"
|
|
84
86
|
>
|
|
85
87
|
<div className="min-w-0">
|
|
86
88
|
<div className="flex flex-wrap items-center gap-2">
|
|
@@ -88,8 +90,8 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
88
90
|
{version.appVersion || t("Версия не указана")}
|
|
89
91
|
</p>
|
|
90
92
|
<Badge
|
|
91
|
-
variant=
|
|
92
|
-
className="font-mono text-[
|
|
93
|
+
variant={launchKindTone[version.kind]}
|
|
94
|
+
className="font-mono text-[11px]"
|
|
93
95
|
title={version.updateId || undefined}
|
|
94
96
|
>
|
|
95
97
|
{kindLabels[version.kind]}
|
|
@@ -97,21 +99,29 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
97
99
|
</Badge>
|
|
98
100
|
</div>
|
|
99
101
|
<p className="mt-1 break-words text-xs leading-5 text-muted-foreground">
|
|
100
|
-
Native: {version.nativeBuilds.join(", ")}
|
|
102
|
+
{t("Native:")} {version.nativeBuilds.join(", ")}
|
|
101
103
|
</p>
|
|
102
104
|
{version.updateId && (
|
|
103
|
-
<
|
|
104
|
-
<
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
<Collapsible className="group/id mt-1 text-xs text-muted-foreground">
|
|
106
|
+
<CollapsibleTrigger asChild>
|
|
107
|
+
<Button size="xs" variant="ghost" className="-ml-1 px-1">
|
|
108
|
+
<ChevronDown
|
|
109
|
+
className="size-3 group-data-[state=open]/id:rotate-180"
|
|
110
|
+
aria-hidden="true"
|
|
111
|
+
/>
|
|
112
|
+
{t("Полный ID")}
|
|
113
|
+
</Button>
|
|
114
|
+
</CollapsibleTrigger>
|
|
115
|
+
<CollapsibleContent>
|
|
116
|
+
<code className="mt-1 block break-all select-all">
|
|
117
|
+
{version.updateId}
|
|
118
|
+
</code>
|
|
119
|
+
</CollapsibleContent>
|
|
120
|
+
</Collapsible>
|
|
111
121
|
)}
|
|
112
122
|
</div>
|
|
113
123
|
<div
|
|
114
|
-
className="flex h-
|
|
124
|
+
className="col-span-2 row-start-2 flex h-3 items-center @min-[32rem]:col-span-1 @min-[32rem]:col-start-2 @min-[32rem]:row-start-1 overflow-hidden rounded-sm bg-muted"
|
|
115
125
|
role="img"
|
|
116
126
|
aria-label={t(
|
|
117
127
|
"{0}, {1} {2}: {3} установок, {4} внутри канала {5}, {6}",
|
|
@@ -127,7 +137,7 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
127
137
|
)}
|
|
128
138
|
>
|
|
129
139
|
<div
|
|
130
|
-
className="h-full rounded-
|
|
140
|
+
className="h-full rounded-sm"
|
|
131
141
|
style={{
|
|
132
142
|
width: `${scope.total ? (version.installations / scope.total) * 100 : 0}%`,
|
|
133
143
|
minWidth: version.installations ? 2 : 0,
|
|
@@ -135,8 +145,8 @@ function ScopeChart({ scope }: { scope: VersionScope }) {
|
|
|
135
145
|
}}
|
|
136
146
|
/>
|
|
137
147
|
</div>
|
|
138
|
-
<div className="flex items-baseline justify-end gap-2 tabular-nums">
|
|
139
|
-
<strong className="text-
|
|
148
|
+
<div className="col-start-2 row-start-1 flex flex-wrap items-baseline justify-end gap-x-2 tabular-nums @min-[32rem]:col-start-3">
|
|
149
|
+
<strong className="text-base font-semibold">
|
|
140
150
|
{number(version.installations)}
|
|
141
151
|
</strong>
|
|
142
152
|
<span className="text-sm text-muted-foreground">
|
|
@@ -186,9 +196,9 @@ export function VersionAdoptionChart({ report }: { report: DevicesReport }) {
|
|
|
186
196
|
<CardHeader>
|
|
187
197
|
<div className="flex flex-wrap items-center justify-between gap-3">
|
|
188
198
|
<CardTitle id="version-adoption-title">
|
|
189
|
-
{t("Активные установки по версиям")}
|
|
199
|
+
<h2>{t("Активные установки по версиям")}</h2>
|
|
190
200
|
</CardTitle>
|
|
191
|
-
<Badge variant="
|
|
201
|
+
<Badge variant="info">
|
|
192
202
|
{t("Всего: ")}
|
|
193
203
|
{number(report.total)}
|
|
194
204
|
</Badge>
|
|
@@ -201,7 +211,7 @@ export function VersionAdoptionChart({ report }: { report: DevicesReport }) {
|
|
|
201
211
|
)}
|
|
202
212
|
</CardDescription>
|
|
203
213
|
</CardHeader>
|
|
204
|
-
<CardContent>
|
|
214
|
+
<CardContent className="min-w-0 px-4 sm:px-6">
|
|
205
215
|
{runtimes.length ? (
|
|
206
216
|
<>
|
|
207
217
|
<div className="mb-5 flex flex-wrap gap-x-5 gap-y-2 text-xs text-muted-foreground">
|
|
@@ -217,23 +227,23 @@ export function VersionAdoptionChart({ report }: { report: DevicesReport }) {
|
|
|
217
227
|
</span>
|
|
218
228
|
))}
|
|
219
229
|
</div>
|
|
220
|
-
<div className="space-y-
|
|
230
|
+
<div className="space-y-6">
|
|
221
231
|
{runtimes.map((runtime) => (
|
|
222
232
|
<section
|
|
223
233
|
key={runtime.runtime}
|
|
224
|
-
aria-label={
|
|
234
|
+
aria-label={t("Runtime {0}", [runtime.runtime])}
|
|
225
235
|
>
|
|
226
236
|
<header className="mb-3 flex flex-wrap items-center justify-between gap-3">
|
|
227
237
|
<h3 className="flex min-w-0 items-center gap-2 text-sm">
|
|
228
238
|
<Layers className="size-4 shrink-0 text-muted-foreground" />
|
|
229
239
|
<span className="shrink-0 text-muted-foreground">
|
|
230
|
-
Runtime
|
|
240
|
+
{t("Runtime")}
|
|
231
241
|
</span>
|
|
232
242
|
<span className="break-all font-semibold">
|
|
233
243
|
{runtime.runtime}
|
|
234
244
|
</span>
|
|
235
245
|
</h3>
|
|
236
|
-
<Badge variant="
|
|
246
|
+
<Badge variant="info">
|
|
237
247
|
{t("Установок: ")}
|
|
238
248
|
{number(runtime.total)}
|
|
239
249
|
</Badge>
|