create-expo-updates-server 0.4.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 +4 -9
- 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 +375 -263
- package/dist/template/app/updates/devices/page.tsx +188 -152
- package/dist/template/app/updates/embedded/page.tsx +63 -29
- package/dist/template/app/updates/emergency-redirects/page.tsx +93 -58
- package/dist/template/app/updates/layout.tsx +2 -1
- package/dist/template/app/updates/page.tsx +381 -283
- 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 -101
- package/dist/template/components/admin/confirm-action.tsx +123 -0
- package/dist/template/components/admin/language-switcher.tsx +25 -17
- 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/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/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 +7 -3
- package/dist/template/docs/device-targeting.md +2 -7
- 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/installation-telemetry.md +2 -8
- 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 +8 -6
- package/dist/template/docs/ota-client-lifecycle.md +30 -68
- package/dist/template/docs/ota-update-policy.md +9 -20
- package/dist/template/docs/ru/admin-ui.md +7 -3
- package/dist/template/docs/ru/device-targeting.md +2 -2
- package/dist/template/docs/ru/doctor.md +2 -2
- package/dist/template/docs/ru/expo-app-setup.md +9 -9
- package/dist/template/docs/ru/getting-started.md +3 -3
- package/dist/template/docs/ru/installation-telemetry.md +2 -2
- package/dist/template/docs/ru/npm-installer.md +3 -3
- package/dist/template/docs/ru/operations-guide.md +8 -3
- package/dist/template/docs/ru/ota-client-lifecycle.md +30 -35
- package/dist/template/docs/ru/ota-update-policy.md +9 -7
- package/dist/template/docs/ru/publishing-npm-installer.md +2 -2
- package/dist/template/docs/uk/admin-ui.md +7 -3
- package/dist/template/docs/uk/device-targeting.md +2 -2
- package/dist/template/docs/uk/doctor.md +2 -2
- package/dist/template/docs/uk/expo-app-setup.md +9 -9
- package/dist/template/docs/uk/getting-started.md +3 -3
- package/dist/template/docs/uk/installation-telemetry.md +2 -2
- package/dist/template/docs/uk/npm-installer.md +3 -3
- package/dist/template/docs/uk/operations-guide.md +8 -3
- package/dist/template/docs/uk/ota-client-lifecycle.md +30 -35
- package/dist/template/docs/uk/ota-update-policy.md +9 -7
- package/dist/template/docs/uk/publishing-npm-installer.md +2 -2
- package/dist/template/lib/audience-ids.ts +4 -0
- package/dist/template/package-lock.json +46 -0
- package/dist/template/package.json +3 -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 +168 -231
- package/dist/template/src/client/devices/cohorts.tsx +181 -0
- package/dist/template/src/client/devices/device-name.tsx +37 -23
- package/dist/template/src/client/devices/favorite-targets.tsx +381 -0
- package/dist/template/src/client/devices/registry.tsx +258 -245
- 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 +47 -49
- package/dist/template/src/client/distribution-control.tsx +89 -57
- 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 +133 -239
- package/dist/template/src/client/guard-action-options.ts +4 -6
- package/dist/template/src/client/i18n/en.json +133 -2
- package/dist/template/src/client/i18n/language-switching.test.tsx +12 -3
- package/dist/template/src/client/i18n/ru.json +133 -2
- package/dist/template/src/client/i18n/uk.json +133 -2
- 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 -206
- package/dist/template/src/client/update-policy-editor.test.ts +101 -29
- package/dist/template/src/client/update-policy-editor.tsx +454 -320
- 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 +446 -301
- 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
|
@@ -1,262 +1,156 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { useRef, useState } from "react";
|
|
3
|
+
import { Plus } from "lucide-react";
|
|
4
|
+
import { Button } from "@/components/ui/button";
|
|
4
5
|
import { Input } from "@/components/ui/input";
|
|
5
|
-
|
|
6
|
+
import { Label } from "@/components/ui/label";
|
|
7
|
+
import {
|
|
8
|
+
Select,
|
|
9
|
+
SelectTrigger,
|
|
10
|
+
SelectValue,
|
|
11
|
+
SelectContent,
|
|
12
|
+
SelectItem,
|
|
13
|
+
} from "@/components/ui/select";
|
|
14
|
+
import { useI18n } from "./i18n/provider";
|
|
6
15
|
import {
|
|
7
|
-
filterGuardActionOptions,
|
|
8
|
-
GuardActionOption,
|
|
9
16
|
normalizeCreatableGuardAction,
|
|
17
|
+
type GuardActionOption,
|
|
10
18
|
} from "./guard-action-options";
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
value: string;
|
|
15
|
-
options: GuardActionOption[];
|
|
16
|
-
selectionDisabled: boolean;
|
|
17
|
-
canMutateCatalog: boolean;
|
|
18
|
-
mutationError?: string;
|
|
19
|
-
onChange: (actionKey: string) => void;
|
|
20
|
-
onCreate: (actionKey: string) => Promise<void>;
|
|
21
|
-
onDelete: (option: GuardActionOption) => Promise<void>;
|
|
22
|
-
onRetry?: () => Promise<void>;
|
|
23
|
-
};
|
|
19
|
+
import { isBuiltInAction } from "./policy-draft";
|
|
24
20
|
|
|
25
|
-
export default function
|
|
21
|
+
export default function GuardActionPicker({
|
|
26
22
|
value,
|
|
27
23
|
options,
|
|
28
|
-
|
|
29
|
-
canMutateCatalog,
|
|
30
|
-
mutationError,
|
|
24
|
+
disabled,
|
|
31
25
|
onChange,
|
|
32
26
|
onCreate,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
}: {
|
|
28
|
+
value: string;
|
|
29
|
+
options: GuardActionOption[];
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
onChange: (value: string) => void;
|
|
32
|
+
onCreate: (value: string) => Promise<void>;
|
|
33
|
+
}) {
|
|
36
34
|
const { t } = useI18n();
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
const [
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
: filterGuardActionOptions(options, inputValue);
|
|
49
|
-
|
|
50
|
-
let creatableValue: string | null = null;
|
|
51
|
-
try {
|
|
52
|
-
creatableValue = normalizeCreatableGuardAction(inputValue);
|
|
53
|
-
} catch {
|
|
54
|
-
// Validation feedback is shown when the user attempts to create.
|
|
35
|
+
const selectRef = useRef<HTMLButtonElement>(null);
|
|
36
|
+
const newActionRef = useRef<HTMLButtonElement>(null);
|
|
37
|
+
const [creating, setCreating] = useState(false);
|
|
38
|
+
const [name, setName] = useState("");
|
|
39
|
+
const [error, setError] = useState("");
|
|
40
|
+
const choices = options.filter(
|
|
41
|
+
(option) => !isBuiltInAction(option.actionKey),
|
|
42
|
+
);
|
|
43
|
+
function cancelCreation() {
|
|
44
|
+
setCreating(false);
|
|
45
|
+
requestAnimationFrame(() => newActionRef.current?.focus());
|
|
55
46
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
: undefined;
|
|
59
|
-
const showCreate =
|
|
60
|
-
!selectionDisabled && Boolean(creatableValue) && !exactOption;
|
|
61
|
-
const rowCount = filteredOptions.length + (showCreate ? 1 : 0);
|
|
62
|
-
|
|
63
|
-
const choose = (actionKey: string) => {
|
|
64
|
-
onChange(actionKey);
|
|
65
|
-
setDraftValue(null);
|
|
66
|
-
setInputError("");
|
|
67
|
-
setOpen(false);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const chooseOption = (option: GuardActionOption) => {
|
|
71
|
-
choose(option.actionKey);
|
|
72
|
-
if (!option.persisted) {
|
|
73
|
-
void onCreate(option.actionKey);
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const create = async () => {
|
|
78
|
-
let actionKey: string;
|
|
47
|
+
function add() {
|
|
48
|
+
let key: string;
|
|
79
49
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
50
|
+
key = normalizeCreatableGuardAction(name);
|
|
51
|
+
if (isBuiltInAction(key))
|
|
52
|
+
throw new Error(
|
|
53
|
+
"Choose the corresponding built-in behavior for this action.",
|
|
54
|
+
);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
setError((e as Error).message);
|
|
83
57
|
return;
|
|
84
58
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
chooseOption(filteredOptions[index]);
|
|
93
|
-
} else if (showCreate) {
|
|
94
|
-
void create();
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
99
|
-
if (selectionDisabled) {
|
|
100
|
-
if (event.key === "Escape") setOpen(false);
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
104
|
-
event.preventDefault();
|
|
105
|
-
setOpen(true);
|
|
106
|
-
const direction = event.key === "ArrowDown" ? 1 : -1;
|
|
107
|
-
setActiveIndex((current) => {
|
|
108
|
-
if (rowCount === 0) return -1;
|
|
109
|
-
if (current < 0) return direction > 0 ? 0 : rowCount - 1;
|
|
110
|
-
return (current + direction + rowCount) % rowCount;
|
|
111
|
-
});
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (event.key === "Enter") {
|
|
115
|
-
event.preventDefault();
|
|
116
|
-
if (open && activeIndex >= 0) {
|
|
117
|
-
activateRow(activeIndex);
|
|
118
|
-
} else if (exactOption) {
|
|
119
|
-
chooseOption(exactOption);
|
|
120
|
-
} else {
|
|
121
|
-
void create();
|
|
122
|
-
}
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
if (event.key === "Escape") {
|
|
126
|
-
setDraftValue(null);
|
|
127
|
-
setInputError("");
|
|
128
|
-
setOpen(false);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
59
|
+
onChange(key);
|
|
60
|
+
setCreating(false);
|
|
61
|
+
setName("");
|
|
62
|
+
requestAnimationFrame(() => selectRef.current?.focus());
|
|
63
|
+
if (!choices.some((o) => o.actionKey === key && o.persisted))
|
|
64
|
+
void onCreate(key);
|
|
65
|
+
}
|
|
132
66
|
return (
|
|
133
|
-
<div
|
|
134
|
-
|
|
135
|
-
className="
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
role="combobox"
|
|
149
|
-
aria-label={t("Rule action")}
|
|
150
|
-
aria-autocomplete="list"
|
|
151
|
-
aria-haspopup="dialog"
|
|
152
|
-
aria-expanded={open}
|
|
153
|
-
aria-controls={popupId}
|
|
154
|
-
aria-describedby={inputError || mutationError ? errorId : undefined}
|
|
155
|
-
onFocus={() => setOpen(true)}
|
|
156
|
-
onChange={(event) => {
|
|
157
|
-
setDraftValue(event.target.value);
|
|
158
|
-
setInputError("");
|
|
159
|
-
setOpen(true);
|
|
160
|
-
setActiveIndex(-1);
|
|
161
|
-
}}
|
|
162
|
-
onKeyDown={handleKeyDown}
|
|
163
|
-
className="w-full"
|
|
164
|
-
placeholder={t("Action (required)")}
|
|
165
|
-
/>
|
|
166
|
-
{open ? (
|
|
167
|
-
<div
|
|
168
|
-
id={popupId}
|
|
169
|
-
role="dialog"
|
|
170
|
-
aria-label={t("Guard action catalog")}
|
|
171
|
-
className="absolute z-20 mt-1 max-h-60 w-full overflow-auto rounded-lg border bg-popover p-1 text-popover-foreground shadow-md"
|
|
67
|
+
<div className="grid gap-2">
|
|
68
|
+
<Label htmlFor="policy-guard-action">{t("Rule action")}</Label>
|
|
69
|
+
<div className="flex flex-wrap gap-2">
|
|
70
|
+
<Select
|
|
71
|
+
value={value}
|
|
72
|
+
disabled={disabled || !choices.length}
|
|
73
|
+
onValueChange={(action) => {
|
|
74
|
+
onChange(action);
|
|
75
|
+
if (
|
|
76
|
+
!choices.some(
|
|
77
|
+
(option) => option.actionKey === action && option.persisted,
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
void onCreate(action);
|
|
81
|
+
}}
|
|
172
82
|
>
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
)
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}`}
|
|
83
|
+
<SelectTrigger
|
|
84
|
+
ref={selectRef}
|
|
85
|
+
id="policy-guard-action"
|
|
86
|
+
className="min-w-40 flex-1"
|
|
87
|
+
>
|
|
88
|
+
<SelectValue placeholder={t("Select an action")} />
|
|
89
|
+
</SelectTrigger>
|
|
90
|
+
<SelectContent>
|
|
91
|
+
{choices.map((o) => (
|
|
92
|
+
<SelectItem key={o.actionKey} value={o.actionKey}>
|
|
93
|
+
{o.actionKey}
|
|
94
|
+
</SelectItem>
|
|
95
|
+
))}
|
|
96
|
+
</SelectContent>
|
|
97
|
+
</Select>
|
|
98
|
+
{!disabled && !creating && (
|
|
99
|
+
<Button
|
|
100
|
+
ref={newActionRef}
|
|
101
|
+
variant="outline"
|
|
102
|
+
size="sm"
|
|
103
|
+
onClick={() => {
|
|
104
|
+
setCreating(true);
|
|
105
|
+
setError("");
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<Plus />
|
|
109
|
+
{t("New action")}
|
|
110
|
+
</Button>
|
|
111
|
+
)}
|
|
112
|
+
</div>
|
|
113
|
+
{creating && !disabled && (
|
|
114
|
+
<div className="grid gap-2 rounded-md border p-3">
|
|
115
|
+
<Label htmlFor="policy-new-action">{t("Reusable action name")}</Label>
|
|
116
|
+
<Input
|
|
117
|
+
id="policy-new-action"
|
|
118
|
+
autoFocus
|
|
119
|
+
value={name}
|
|
120
|
+
aria-invalid={Boolean(error)}
|
|
121
|
+
aria-describedby={error ? "policy-action-error" : undefined}
|
|
122
|
+
onChange={(e) => {
|
|
123
|
+
setName(e.target.value);
|
|
124
|
+
setError("");
|
|
125
|
+
}}
|
|
126
|
+
onKeyDown={(e) => {
|
|
127
|
+
if (e.key === "Enter") {
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
add();
|
|
130
|
+
} else if (e.key === "Escape") {
|
|
131
|
+
cancelCreation();
|
|
132
|
+
}
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
{error && (
|
|
136
|
+
<p
|
|
137
|
+
id="policy-action-error"
|
|
138
|
+
role="alert"
|
|
139
|
+
className="text-sm text-destructive"
|
|
231
140
|
>
|
|
232
|
-
{t(
|
|
233
|
-
</button>
|
|
234
|
-
) : null}
|
|
235
|
-
{filteredOptions.length === 0 && !showCreate ? (
|
|
236
|
-
<p className="px-3 py-2 text-sm text-muted-foreground">
|
|
237
|
-
{t("No matching actions")}
|
|
141
|
+
{t(error)}
|
|
238
142
|
</p>
|
|
239
|
-
)
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
<span>{t(inputError || mutationError || "")}</span>
|
|
249
|
-
{mutationError && onRetry ? (
|
|
250
|
-
<button
|
|
251
|
-
type="button"
|
|
252
|
-
onClick={() => void onRetry()}
|
|
253
|
-
className="underline"
|
|
254
|
-
>
|
|
255
|
-
{t("Retry")}
|
|
256
|
-
</button>
|
|
257
|
-
) : null}
|
|
143
|
+
)}
|
|
144
|
+
<div className="flex gap-2">
|
|
145
|
+
<Button size="sm" onClick={add}>
|
|
146
|
+
{t("Use action")}
|
|
147
|
+
</Button>
|
|
148
|
+
<Button size="sm" variant="ghost" onClick={cancelCreation}>
|
|
149
|
+
{t("Cancel")}
|
|
150
|
+
</Button>
|
|
151
|
+
</div>
|
|
258
152
|
</div>
|
|
259
|
-
)
|
|
153
|
+
)}
|
|
260
154
|
</div>
|
|
261
155
|
);
|
|
262
156
|
}
|
|
@@ -31,9 +31,7 @@ export function mergeGuardActionOptions(
|
|
|
31
31
|
actionKey: item.actionKey,
|
|
32
32
|
persisted: true,
|
|
33
33
|
}))
|
|
34
|
-
.sort((left, right) =>
|
|
35
|
-
left.actionKey.localeCompare(right.actionKey, "en"),
|
|
36
|
-
);
|
|
34
|
+
.sort((left, right) => left.actionKey.localeCompare(right.actionKey, "en"));
|
|
37
35
|
const exactValues = new Set(options.map((option) => option.actionKey));
|
|
38
36
|
|
|
39
37
|
for (const actionKey of currentPolicyValues) {
|
|
@@ -47,10 +45,10 @@ export function mergeGuardActionOptions(
|
|
|
47
45
|
return options;
|
|
48
46
|
}
|
|
49
47
|
|
|
50
|
-
export function filterGuardActionOptions(
|
|
51
|
-
options:
|
|
48
|
+
export function filterGuardActionOptions<T extends { actionKey: string }>(
|
|
49
|
+
options: T[],
|
|
52
50
|
query: string,
|
|
53
|
-
):
|
|
51
|
+
): T[] {
|
|
54
52
|
const normalizedQuery = query.toLocaleLowerCase();
|
|
55
53
|
return options.filter((option) =>
|
|
56
54
|
option.actionKey.toLocaleLowerCase().includes(normalizedQuery),
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
"Детали обновления": "Update details",
|
|
208
208
|
"Метаданные, политика доставки и управление публикацией.": "Metadata, delivery policy and release management.",
|
|
209
209
|
"Загрузка...": "Loading...",
|
|
210
|
-
"⚠️ Rollback активен в этом канале/платформе.": "
|
|
210
|
+
"⚠️ Rollback активен в этом канале/платформе.": "Rollback is active in this channel/platform.",
|
|
211
211
|
"Сейчас раздаётся updateId: ": "Currently serving update ID: ",
|
|
212
212
|
"Новые апдейты автоматически игнорируются до выполнения Promote.": "New updates are ignored until Promote is performed.",
|
|
213
213
|
"Этот апдейт сейчас не доставляется.": "This update is not being delivered.",
|
|
@@ -484,5 +484,136 @@
|
|
|
484
484
|
"OTA distribution is globally blocked. Disable the emergency switch before starting distribution.": "OTA distribution is globally blocked. Disable the emergency switch before starting distribution.",
|
|
485
485
|
"policy.guard.action: must be trimmed, contain 1-100 characters, and have no control characters": "policy.guard.action: must be trimmed, contain 1-100 characters, and have no control characters",
|
|
486
486
|
"policy.guard.payload: must not exceed 16384 UTF-8 bytes": "policy.guard.payload: must not exceed 16384 UTF-8 bytes",
|
|
487
|
-
"policy.guard.payload: JSON depth must not exceed 10": "policy.guard.payload: JSON depth must not exceed 10"
|
|
487
|
+
"policy.guard.payload: JSON depth must not exceed 10": "policy.guard.payload: JSON depth must not exceed 10",
|
|
488
|
+
"Analytics": "Analytics",
|
|
489
|
+
"Overview": "Overview",
|
|
490
|
+
"Versions": "Versions",
|
|
491
|
+
"Cohorts": "Cohorts",
|
|
492
|
+
"Registry": "Registry",
|
|
493
|
+
"New installations": "New installations",
|
|
494
|
+
"First seen during this period": "First seen during this period",
|
|
495
|
+
"Reported versions": "Reported versions",
|
|
496
|
+
"Distinct version combinations": "Distinct version combinations",
|
|
497
|
+
"{0} filters applied": "{0} filters applied",
|
|
498
|
+
"Versions and activity reported by app installations.": "Versions and activity reported by app installations.",
|
|
499
|
+
"Shares across all installations in the selected period.": "Shares across all installations in the selected period.",
|
|
500
|
+
"Search embedded builds": "Search builds by ID, version, platform or channel",
|
|
501
|
+
"Matching build": "Matching build",
|
|
502
|
+
"Destination release": "Destination release",
|
|
503
|
+
"Manage release audiences, delivery policies and rollbacks.": "Manage release audiences, delivery policies and rollbacks.",
|
|
504
|
+
"Release history": "Release history",
|
|
505
|
+
"Search releases": "Search releases",
|
|
506
|
+
"Search by comment, update ID, version or channel": "Search by comment, update ID, version or channel",
|
|
507
|
+
"All runtimes": "All runtimes",
|
|
508
|
+
"All statuses": "All statuses",
|
|
509
|
+
"All audiences": "All audiences",
|
|
510
|
+
"Showing the previous results.": "Showing the previous results.",
|
|
511
|
+
"Release": "Release",
|
|
512
|
+
"Compatibility": "Compatibility",
|
|
513
|
+
"Audience": "Audience",
|
|
514
|
+
"No matching releases": "No matching releases",
|
|
515
|
+
"Release {0}": "Release {0}",
|
|
516
|
+
"All devices": "All devices",
|
|
517
|
+
"Page {0} of {1}": "Page {0} of {1}",
|
|
518
|
+
"Release sections": "Release sections",
|
|
519
|
+
"Metadata": "Metadata",
|
|
520
|
+
"My favorites": "My favorites",
|
|
521
|
+
"Bookmark a recipient below to reuse it across releases.": "Bookmark a recipient below to reuse it across releases.",
|
|
522
|
+
"Target is no longer in the registry": "Target is no longer in the registry",
|
|
523
|
+
"{0} is selected": "{0} is selected",
|
|
524
|
+
"Add {0} to audience": "Add {0} to audience",
|
|
525
|
+
"Remove {0} from favorites": "Remove {0} from favorites",
|
|
526
|
+
"Bookmark {0}": "Bookmark {0}",
|
|
527
|
+
"Selected": "Selected",
|
|
528
|
+
"Add": "Add",
|
|
529
|
+
"Save favorite": "Save favorite",
|
|
530
|
+
"Only your account sees this name.": "Only your account sees this name.",
|
|
531
|
+
"Bookmark target": "Bookmark target",
|
|
532
|
+
"Favorite name": "Favorite name",
|
|
533
|
+
"Favorites unavailable": "Favorites unavailable",
|
|
534
|
+
"Invalid favorite name": "Invalid favorite name",
|
|
535
|
+
"Invalid favorite target": "Invalid favorite target",
|
|
536
|
+
"Could not remove favorite": "Could not remove favorite",
|
|
537
|
+
"Could not save favorite": "Could not save favorite",
|
|
538
|
+
"Optional update": "Optional update",
|
|
539
|
+
"Users can download the update, restart to apply it, or continue with their current version.": "Users can download the update, restart to apply it, or continue with their current version.",
|
|
540
|
+
"Background update": "Background update",
|
|
541
|
+
"The app downloads the update silently and applies it on the next launch.": "The app downloads the update silently and applies it on the next launch.",
|
|
542
|
+
"Required OTA update": "Required OTA update",
|
|
543
|
+
"The app blocks access and downloads this update. Users restart to continue.": "The app blocks access and downloads this update. Users restart to continue.",
|
|
544
|
+
"Require a store update": "Require a store update",
|
|
545
|
+
"The app blocks access and opens the configured store link when the user chooses to upgrade.": "The app blocks access and opens the configured store link when the user chooses to upgrade.",
|
|
546
|
+
"Custom guard": "Custom guard",
|
|
547
|
+
"The app runs the selected action. Access stays blocked unless the app’s handler allows it.": "The app runs the selected action. Access stays blocked unless the app’s handler allows it.",
|
|
548
|
+
"Choose how this release reaches users.": "Choose how this release reaches users.",
|
|
549
|
+
"Your role has read-only access to this policy.": "Your role has read-only access to this policy.",
|
|
550
|
+
"Update behavior": "Update behavior",
|
|
551
|
+
"Default store link": "Default store link",
|
|
552
|
+
"iOS store link": "iOS store link",
|
|
553
|
+
"Android store link": "Android store link",
|
|
554
|
+
"The app uses its platform link first, then the default link. Use https, market or itms-apps links.": "The app uses its platform link first, then the default link. Use https, market or itms-apps links.",
|
|
555
|
+
"Edit the existing store payload in advanced settings to preserve its structure.": "Edit the existing store payload in advanced settings to preserve its structure.",
|
|
556
|
+
"Advanced settings": "Advanced settings",
|
|
557
|
+
"When OTA is allowed, the default client lets the user choose when to download and restart. They can postpone the update.": "When OTA is allowed, the default client lets the user choose when to download and restart. They can postpone the update.",
|
|
558
|
+
"When OTA is allowed, the app downloads it silently during use. It takes effect on the next full launch. For an automatic restart, select Immediate required update.": "When OTA is allowed, the app downloads it silently during use. It takes effect on the next full launch. For an automatic restart, select Immediate required update.",
|
|
559
|
+
"This release requires an update from the store. Both delivery modes show the store button and block the OTA download.": "This release requires an update from the store. Both delivery modes show the store button and block the OTA download.",
|
|
560
|
+
"Delivery starts only after the app’s custom action allows the update.": "Delivery starts only after the app’s custom action allows the update.",
|
|
561
|
+
"Unsaved changes": "Unsaved changes",
|
|
562
|
+
"Discard changes": "Discard changes",
|
|
563
|
+
"Select an action": "Select an action",
|
|
564
|
+
"New action": "New action",
|
|
565
|
+
"Use action": "Use action",
|
|
566
|
+
"Choose the corresponding built-in behavior for this action.": "Choose the corresponding built-in behavior for this action.",
|
|
567
|
+
"Enter a valid store link for this platform or a default store link.": "Enter a valid store link for this platform or a default store link.",
|
|
568
|
+
"Reload saved policy": "Reload saved policy",
|
|
569
|
+
"Search action catalog": "Search action catalog",
|
|
570
|
+
"Activated at": "Activated at",
|
|
571
|
+
"Public delivery": "Public delivery",
|
|
572
|
+
"Current and previous releases served to all devices in each scope.": "Current and previous releases served to all devices in each scope.",
|
|
573
|
+
"Find a delivery scope": "Find a delivery scope",
|
|
574
|
+
"No matching scopes": "No matching scopes",
|
|
575
|
+
"No public release history yet": "No public release history yet",
|
|
576
|
+
"Try another runtime, channel or platform.": "Try another runtime, channel or platform.",
|
|
577
|
+
"Manually activate a release for all devices to start its history.": "Manually activate a release for all devices to start its history.",
|
|
578
|
+
"Delivery scope": "Delivery scope",
|
|
579
|
+
"Currently serving": "Currently serving",
|
|
580
|
+
"Previous public release": "Previous public release",
|
|
581
|
+
"No active release": "No active release",
|
|
582
|
+
"No previous release": "No previous release",
|
|
583
|
+
"Restore": "Restore",
|
|
584
|
+
"Restore release": "Restore release",
|
|
585
|
+
"Resume public delivery of {0} in {1}?": "Resume public delivery of {0} in {1}?",
|
|
586
|
+
"Restored {0} in {1}.": "Restored {0} in {1}.",
|
|
587
|
+
"Delivery changed. Review the refreshed scope before restoring.": "Delivery changed. Review the refreshed scope before restoring.",
|
|
588
|
+
"Could not restore release.": "Could not restore release.",
|
|
589
|
+
"Unable to load delivery history.": "Unable to load delivery history.",
|
|
590
|
+
"Download on postpone": "Download on postpone",
|
|
591
|
+
"Offer the update first. If the user postpones it, download silently and apply it on the next full launch.": "Offer the update first. If the user postpones it, download silently and apply it on the next full launch.",
|
|
592
|
+
"Immediate required update": "Immediate required update",
|
|
593
|
+
"The app silently downloads this update and restarts as soon as it is active and ready. Users can retry if the update fails.": "The app silently downloads this update and restarts as soon as it is active and ready. Users can retry if the update fails.",
|
|
594
|
+
"Delete this release and its files from storage.": "Delete this release and its files from storage.",
|
|
595
|
+
"Who should receive this update?": "Who should receive this update?",
|
|
596
|
+
"Selected recipients": "Selected recipients",
|
|
597
|
+
"Add recipients": "Add recipients",
|
|
598
|
+
"Favorites": "Favorites",
|
|
599
|
+
"Paste IDs": "Paste IDs",
|
|
600
|
+
"No recipients match your search.": "No recipients match your search.",
|
|
601
|
+
"No installations registered for {0} yet.": "No installations registered for {0} yet.",
|
|
602
|
+
"Showing up to 50 matches from the latest 500 installations.": "Showing up to 50 matches from the latest 500 installations.",
|
|
603
|
+
"Device or installation IDs": "Device or installation IDs",
|
|
604
|
+
"Add to selection": "Add to selection",
|
|
605
|
+
"Unrecognized ID “{0}”.": "Unrecognized ID “{0}”.",
|
|
606
|
+
"Up to {0} device IDs and {0} installation IDs per audience.": "Up to {0} device IDs and {0} installation IDs per audience.",
|
|
607
|
+
"These recipients are already selected.": "These recipients are already selected.",
|
|
608
|
+
"Recipients added to the selection.": "Recipients added to the selection.",
|
|
609
|
+
"Remove {0} from selection": "Remove {0} from selection",
|
|
610
|
+
"Add at least one recipient to save this audience.": "Add at least one recipient to save this audience.",
|
|
611
|
+
"Changes apply at the next update check. Previously downloaded updates stay on the device.": "Changes apply at the next update check. Previously downloaded updates stay on the device.",
|
|
612
|
+
"Saving sets the audience. Activate the release when you are ready to distribute it.": "Saving sets the audience. Activate the release when you are ready to distribute it.",
|
|
613
|
+
"Add the entered IDs or clear the field before saving.": "Add the entered IDs or clear the field before saving.",
|
|
614
|
+
"Audience saved.": "Audience saved.",
|
|
615
|
+
"Bookmark a recipient in the registry to reuse it across releases.": "Bookmark a recipient in the registry to reuse it across releases.",
|
|
616
|
+
"Saving makes this the public release for this platform, channel and runtime, replacing any current public release.": "Saving makes this the public release for this platform, channel and runtime, replacing any current public release.",
|
|
617
|
+
"Device ID (64 hex characters) keeps targeting the device after reinstall. Installation ID (UUID) targets one installation. Separate IDs with a comma, space or new line.": "Device ID (64 hex characters) keeps targeting the device after reinstall. Installation ID (UUID) targets one installation. Separate IDs with a comma, space or new line.",
|
|
618
|
+
"{0} · Channel {1} · Runtime {2}": "{0} · Channel {1} · Runtime {2}"
|
|
488
619
|
}
|
|
@@ -3,6 +3,7 @@ import { act } from "react";
|
|
|
3
3
|
import { createRoot, type Root } from "react-dom/client";
|
|
4
4
|
import { renderToString } from "react-dom/server";
|
|
5
5
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
|
+
import { AdminRoleContext } from "@/components/admin/admin-role";
|
|
6
7
|
import { LanguageSwitcher } from "@/components/admin/language-switcher";
|
|
7
8
|
import EmergencyRedirectsPage from "@/app/updates/emergency-redirects/page";
|
|
8
9
|
import UpdatePolicyEditor from "@/src/client/update-policy-editor";
|
|
@@ -44,6 +45,11 @@ const redirect = {
|
|
|
44
45
|
expectedUpdateId: "22222222-2222-4222-8222-222222222222",
|
|
45
46
|
};
|
|
46
47
|
beforeEach(() => {
|
|
48
|
+
vi.stubGlobal("ResizeObserver", class {
|
|
49
|
+
observe() {}
|
|
50
|
+
unobserve() {}
|
|
51
|
+
disconnect() {}
|
|
52
|
+
});
|
|
47
53
|
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
48
54
|
container = document.createElement("div");
|
|
49
55
|
document.body.append(container);
|
|
@@ -79,7 +85,7 @@ async function switchTo(locale: Locale) {
|
|
|
79
85
|
}
|
|
80
86
|
async function click(text: string) {
|
|
81
87
|
const button = [...container.querySelectorAll("button")].find(
|
|
82
|
-
(b) => b.textContent === text,
|
|
88
|
+
(b) => b.textContent?.trim() === text,
|
|
83
89
|
);
|
|
84
90
|
expect(button, text).toBeDefined();
|
|
85
91
|
await act(async () => button!.click());
|
|
@@ -130,7 +136,7 @@ describe("language switching", () => {
|
|
|
130
136
|
expect(container.textContent).toContain("Аварийный маршрут обновлён");
|
|
131
137
|
await switchTo("uk");
|
|
132
138
|
expect(container.textContent).toContain("Аварійний маршрут оновлено");
|
|
133
|
-
expect(container.
|
|
139
|
+
expect(container.querySelector("form")).toBeNull();
|
|
134
140
|
expect(container.textContent).toContain("Увімкнено");
|
|
135
141
|
expect(container.textContent).toContain(redirect.name);
|
|
136
142
|
expect(document.documentElement.lang).toBe("uk");
|
|
@@ -200,18 +206,21 @@ describe("language switching", () => {
|
|
|
200
206
|
root.render(
|
|
201
207
|
<LocaleProvider initialLocale="ru">
|
|
202
208
|
<LanguageSwitcher />
|
|
203
|
-
<UpdatePolicyEditor encodedKey="test" onSaved={async () => {}}
|
|
209
|
+
<AdminRoleContext.Provider value="operator"><UpdatePolicyEditor encodedKey="test" onSaved={async () => {}} /></AdminRoleContext.Provider>
|
|
204
210
|
</LocaleProvider>,
|
|
205
211
|
),
|
|
206
212
|
);
|
|
207
213
|
expect(container.textContent).toContain("Политика обновления");
|
|
208
214
|
expect(container.textContent).toContain("Каталог действий");
|
|
215
|
+
await click("Каталог действий");
|
|
209
216
|
await switchTo("uk");
|
|
210
217
|
expect(container.textContent).toContain("Політика оновлення");
|
|
211
218
|
expect(container.textContent).toContain("Додати дію до каталогу");
|
|
212
219
|
api.putUpdatePolicy.mockRejectedValue(
|
|
213
220
|
new Error("Update policy is immutable after publication."),
|
|
214
221
|
);
|
|
222
|
+
const background = container.querySelector<HTMLButtonElement>('#behavior-background')!;
|
|
223
|
+
await act(async () => background.click());
|
|
215
224
|
await click("Зберегти політику");
|
|
216
225
|
expect(container.textContent).toContain(
|
|
217
226
|
"Політику оновлення не можна змінити після публікації.",
|