create-expo-updates-server 0.1.6 → 0.2.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/dist/template/.dockerignore +16 -0
- package/dist/template/README.md +51 -660
- package/dist/template/app/api/admin/device-targets/route.test.ts +43 -0
- package/dist/template/app/api/admin/device-targets/route.ts +91 -0
- package/dist/template/app/api/admin/devices/route.test.ts +41 -0
- package/dist/template/app/api/admin/devices/route.ts +15 -0
- package/dist/template/app/api/admin/updates/[encodedKey]/audience/route.ts +75 -0
- package/dist/template/app/api/device-heartbeat/route.ts +2 -0
- package/dist/template/app/globals.css +114 -15
- package/dist/template/app/layout.tsx +12 -4
- package/dist/template/app/login/page.tsx +22 -18
- package/dist/template/app/updates/[encodedKey]/page.tsx +112 -88
- package/dist/template/app/updates/devices/page.tsx +264 -0
- package/dist/template/app/updates/embedded/page.tsx +102 -68
- package/dist/template/app/updates/emergency-redirects/page.tsx +144 -111
- package/dist/template/app/updates/layout.tsx +6 -1
- package/dist/template/app/updates/page.tsx +262 -212
- package/dist/template/components/admin/admin-shell.tsx +196 -0
- package/dist/template/components/admin/language-switcher.tsx +25 -0
- package/dist/template/components/admin/theme-provider.tsx +15 -0
- package/dist/template/components/ui/alert.tsx +65 -0
- package/dist/template/components/ui/badge.tsx +47 -0
- package/dist/template/components/ui/button.tsx +63 -0
- package/dist/template/components/ui/card.tsx +91 -0
- package/dist/template/components/ui/chart.tsx +373 -0
- package/dist/template/components/ui/checkbox.tsx +31 -0
- package/dist/template/components/ui/dialog.tsx +158 -0
- package/dist/template/components/ui/dropdown-menu.tsx +256 -0
- package/dist/template/components/ui/input.tsx +20 -0
- package/dist/template/components/ui/label.tsx +23 -0
- package/dist/template/components/ui/native-select.tsx +61 -0
- package/dist/template/components/ui/popover.tsx +88 -0
- package/dist/template/components/ui/scroll-area.tsx +57 -0
- package/dist/template/components/ui/select.tsx +189 -0
- package/dist/template/components/ui/separator.tsx +27 -0
- package/dist/template/components/ui/sheet.tsx +142 -0
- package/dist/template/components/ui/sidebar.tsx +736 -0
- package/dist/template/components/ui/skeleton.tsx +13 -0
- package/dist/template/components/ui/switch.tsx +34 -0
- package/dist/template/components/ui/table.tsx +115 -0
- package/dist/template/components/ui/tabs.tsx +90 -0
- package/dist/template/components/ui/textarea.tsx +17 -0
- package/dist/template/components/ui/tooltip.tsx +56 -0
- package/dist/template/components.json +22 -0
- package/dist/template/docs/admin-ui.md +35 -0
- package/dist/template/docs/device-targeting.md +129 -0
- package/dist/template/docs/doctor.md +137 -0
- package/dist/template/docs/expo-app-setup.md +174 -47
- package/dist/template/docs/getting-started.md +105 -146
- package/dist/template/docs/getting-started.ru.md +106 -191
- package/dist/template/docs/index.md +14 -33
- package/dist/template/docs/installation-telemetry.md +233 -0
- package/dist/template/docs/migrations/2026-10-16-manifest-identity.sql +89 -0
- package/dist/template/docs/migrations/2026-10-19-device-heartbeat.sql +131 -0
- package/dist/template/docs/migrations/2026-10-22-device-analytics.sql +264 -0
- package/dist/template/docs/migrations/2026-10-22-device-targeting-activation.sql +108 -0
- package/dist/template/docs/migrations/2026-10-22-device-targeting.sql +130 -0
- package/dist/template/docs/migrations/2026-10-22-device-version-metadata.sql +154 -0
- package/dist/template/docs/migrations/schema.sql +868 -6
- package/dist/template/docs/npm-installer.md +15 -30
- package/dist/template/docs/operations-guide.md +87 -0
- package/dist/template/docs/ota-client-lifecycle.md +263 -0
- package/dist/template/docs/ota-update-policy.md +36 -2
- package/dist/template/docs/supabase-setup.md +4 -0
- package/dist/template/hooks/use-mobile.ts +21 -0
- package/dist/template/lib/utils.ts +6 -0
- package/dist/template/package-lock.json +2325 -101
- package/dist/template/package.json +13 -3
- package/dist/template/scripts/configure-expo-app.mjs +11 -15
- package/dist/template/scripts/doctor.mjs +51 -0
- package/dist/template/scripts/ensure-test-bucket.mjs +21 -0
- package/dist/template/scripts/lib/device-identity.test.ts +29 -0
- package/dist/template/scripts/lib/doctor-probes.mjs +139 -0
- package/dist/template/scripts/lib/doctor.mjs +208 -0
- package/dist/template/scripts/lib/doctor.test.mjs +262 -0
- package/dist/template/scripts/lib/expo-app-configurator.mjs +14 -9
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +3 -2
- package/dist/template/scripts/lib/ota-client-configurator.mjs +69 -0
- package/dist/template/scripts/lib/ota-client-configurator.test.ts +88 -0
- package/dist/template/scripts/lib/ota-client.test.ts +55 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.mjs +173 -0
- package/dist/template/scripts/lib/ota-root-hook-patcher.test.ts +123 -0
- package/dist/template/scripts/lib/ota-update-controller.test.ts +231 -0
- package/dist/template/scripts/tests/device-analytics-migrations.mjs +80 -0
- package/dist/template/scripts/tests/device-analytics.mjs +126 -0
- package/dist/template/scripts/tests/device-heartbeat.mjs +86 -0
- package/dist/template/scripts/tests/device-targeting-activation.mjs +111 -0
- package/dist/template/scripts/tests/device-targeting.mjs +39 -0
- package/dist/template/scripts/tests/device-version-metadata.mjs +31 -0
- package/dist/template/scripts/tests/manifest-identity-concurrency.mjs +106 -0
- package/dist/template/scripts/tests/manifest-identity.sql +204 -0
- package/dist/template/src/client/admin-types.ts +1 -0
- package/dist/template/src/client/devices/analytics.tsx +429 -0
- package/dist/template/src/client/devices/device-name.tsx +82 -0
- package/dist/template/src/client/devices/registry.tsx +399 -0
- package/dist/template/src/client/devices/use-devices-report.ts +108 -0
- package/dist/template/src/client/devices/version-adoption-chart.tsx +269 -0
- package/dist/template/src/client/devices/version-groups.test.ts +57 -0
- package/dist/template/src/client/devices/version-groups.ts +101 -0
- package/dist/template/src/client/distribution-control.tsx +135 -81
- package/dist/template/src/client/guard-action-combobox.tsx +13 -24
- package/dist/template/src/client/i18n/en.json +286 -0
- package/dist/template/src/client/i18n/messages.test.ts +42 -0
- package/dist/template/src/client/i18n/messages.ts +31 -0
- package/dist/template/src/client/i18n/provider.tsx +55 -0
- package/dist/template/src/client/i18n/use-formatters.ts +38 -0
- package/dist/template/src/client/logout-button.tsx +3 -1
- package/dist/template/src/client/update-audience-editor.tsx +285 -0
- package/dist/template/src/client/update-policy-editor.tsx +53 -41
- package/dist/template/src/server/controllers/manifest.test.ts +250 -7
- package/dist/template/src/server/controllers/manifest.ts +39 -31
- package/dist/template/src/server/devices/audience.test.ts +48 -0
- package/dist/template/src/server/devices/audience.ts +86 -0
- package/dist/template/src/server/devices/heartbeat.test.ts +39 -0
- package/dist/template/src/server/devices/heartbeat.ts +75 -0
- package/dist/template/src/server/devices/report-types.ts +114 -0
- package/dist/template/src/server/devices/report.test.ts +29 -0
- package/dist/template/src/server/devices/report.ts +27 -0
- package/dist/template/src/server/lib/admin-audience-activation.test.ts +94 -0
- package/dist/template/src/server/lib/admin-updates.ts +32 -168
- package/dist/template/src/server/lib/supabase.js +10 -10
- package/dist/template/src/server/lib/supabase.test.ts +11 -0
- package/dist/template/src/server/manifest/manifest-identity.test.ts +30 -0
- package/dist/template/src/server/manifest/manifest-identity.ts +24 -0
- package/dist/template/src/server/manifest/manifest-repository.ts +31 -102
- package/dist/template/src/server/manifest/manifest-response.ts +1 -1
- package/dist/template/templates/expo-app/ota-client/README.md +59 -0
- package/dist/template/templates/expo-app/ota-client/controller.js +60 -0
- package/dist/template/templates/expo-app/ota-client/device-identity.js +26 -0
- package/dist/template/templates/expo-app/ota-client/docs/update-lifecycle.md +52 -0
- package/dist/template/templates/expo-app/ota-client/index.d.ts +47 -0
- package/dist/template/templates/expo-app/ota-client/index.js +3 -0
- package/dist/template/templates/expo-app/ota-client/model/hooks/useOtaUpdates.js +48 -0
- package/dist/template/templates/expo-app/ota-client/model/update-controller.js +182 -0
- package/dist/template/templates/expo-app/ota-client/runtime.js +112 -0
- package/dist/template/templates/expo-app/ota-client/ui/ota-update-gate.js +56 -0
- package/dist/template-manifest.json +578 -73
- package/lib/cli.mjs +4 -6
- package/package.json +1 -1
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { useI18n } from "@/src/client/i18n/provider";
|
|
3
|
+
|
|
4
|
+
import { Textarea } from "@/components/ui/textarea";
|
|
5
|
+
|
|
6
|
+
import { Button } from "@/components/ui/button";
|
|
7
|
+
import { Badge } from "@/components/ui/badge";
|
|
8
|
+
import { Card } from "@/components/ui/card";
|
|
9
|
+
import { ShieldCheck, ShieldAlert, ChevronDown, RefreshCw } from "lucide-react";
|
|
2
10
|
|
|
3
11
|
import {
|
|
4
12
|
AdminApiError,
|
|
@@ -9,6 +17,7 @@ import type { DistributionControlResponse } from "./admin-types";
|
|
|
9
17
|
import { useCallback, useEffect, useState } from "react";
|
|
10
18
|
|
|
11
19
|
export function useDistributionControlState() {
|
|
20
|
+
const { t } = useI18n();
|
|
12
21
|
const [state, setState] = useState<DistributionControlResponse | null>(null);
|
|
13
22
|
const [loading, setLoading] = useState(true);
|
|
14
23
|
const [error, setError] = useState("");
|
|
@@ -37,7 +46,7 @@ export function useDistributionControlState() {
|
|
|
37
46
|
return () => window.clearTimeout(timeoutId);
|
|
38
47
|
}, [refresh]);
|
|
39
48
|
|
|
40
|
-
return { state, setState, loading, error, setError, refresh };
|
|
49
|
+
return { state, setState, loading, error: t(error), setError, refresh };
|
|
41
50
|
}
|
|
42
51
|
|
|
43
52
|
function formatChangedBy(state: DistributionControlResponse): string {
|
|
@@ -54,20 +63,22 @@ export function DistributionControlBanner({
|
|
|
54
63
|
loading: boolean;
|
|
55
64
|
error: string;
|
|
56
65
|
}) {
|
|
66
|
+
const { t, formatLocale } = useI18n();
|
|
57
67
|
if (loading) {
|
|
58
68
|
return (
|
|
59
|
-
<section className="rounded-
|
|
60
|
-
Проверка глобального статуса OTA…
|
|
69
|
+
<section className="rounded-lg border bg-muted/30 p-4 text-sm text-muted-foreground">
|
|
70
|
+
{t("Проверка глобального статуса OTA…")}
|
|
61
71
|
</section>
|
|
62
72
|
);
|
|
63
73
|
}
|
|
64
74
|
|
|
65
75
|
if (error || !state) {
|
|
66
76
|
return (
|
|
67
|
-
<section className="rounded-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
77
|
+
<section className="rounded-lg border border-destructive/25 bg-destructive/5 p-4 text-sm text-destructive">
|
|
78
|
+
{t(
|
|
79
|
+
"Глобальный статус OTA недоступен. Распространяющие действия отключены до восстановления связи.",
|
|
80
|
+
)}
|
|
81
|
+
{error ? <p className="mt-1 text-xs">{t(error)}</p> : null}
|
|
71
82
|
</section>
|
|
72
83
|
);
|
|
73
84
|
}
|
|
@@ -77,11 +88,11 @@ export function DistributionControlBanner({
|
|
|
77
88
|
}
|
|
78
89
|
|
|
79
90
|
return (
|
|
80
|
-
<section className="rounded-
|
|
81
|
-
<p className="font-semibold"
|
|
91
|
+
<section className="rounded-lg border border-destructive/25 bg-destructive/5 p-4 text-destructive">
|
|
92
|
+
<p className="font-semibold">{t("Распространение OTA остановлено")}</p>
|
|
82
93
|
<p className="mt-1 text-sm">{state.reason}</p>
|
|
83
94
|
<p className="mt-2 text-xs">
|
|
84
|
-
{new Date(state.changedAt).toLocaleString(
|
|
95
|
+
{new Date(state.changedAt).toLocaleString(formatLocale)} ·{" "}
|
|
85
96
|
{formatChangedBy(state)}
|
|
86
97
|
</p>
|
|
87
98
|
</section>
|
|
@@ -89,11 +100,13 @@ export function DistributionControlBanner({
|
|
|
89
100
|
}
|
|
90
101
|
|
|
91
102
|
export default function DistributionControl() {
|
|
103
|
+
const { t, formatLocale } = useI18n();
|
|
92
104
|
const { state, setState, loading, error, setError, refresh } =
|
|
93
105
|
useDistributionControlState();
|
|
94
106
|
const [reason, setReason] = useState("");
|
|
95
107
|
const [saving, setSaving] = useState(false);
|
|
96
108
|
const [message, setMessage] = useState("");
|
|
109
|
+
const [expanded, setExpanded] = useState(false);
|
|
97
110
|
|
|
98
111
|
const changeState = async (blocked: boolean) => {
|
|
99
112
|
if (!state) {
|
|
@@ -108,8 +121,10 @@ export default function DistributionControl() {
|
|
|
108
121
|
|
|
109
122
|
const confirmed = window.confirm(
|
|
110
123
|
blocked
|
|
111
|
-
?
|
|
112
|
-
|
|
124
|
+
? t(
|
|
125
|
+
"Немедленно остановить выдачу manifest и всех OTA assets для всех клиентов?",
|
|
126
|
+
)
|
|
127
|
+
: t("Возобновить глобальное OTA-распространение?"),
|
|
113
128
|
);
|
|
114
129
|
if (!confirmed) {
|
|
115
130
|
return;
|
|
@@ -128,8 +143,8 @@ export default function DistributionControl() {
|
|
|
128
143
|
setReason("");
|
|
129
144
|
setMessage(
|
|
130
145
|
blocked
|
|
131
|
-
? "OTA-распространение остановлено."
|
|
132
|
-
: "OTA-распространение возобновлено.",
|
|
146
|
+
? t("OTA-распространение остановлено.")
|
|
147
|
+
: t("OTA-распространение возобновлено."),
|
|
133
148
|
);
|
|
134
149
|
} catch (saveError: unknown) {
|
|
135
150
|
if (saveError instanceof AdminApiError && saveError.status === 409) {
|
|
@@ -150,82 +165,121 @@ export default function DistributionControl() {
|
|
|
150
165
|
};
|
|
151
166
|
|
|
152
167
|
return (
|
|
153
|
-
<
|
|
154
|
-
className=
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
168
|
+
<Card className="gap-0 overflow-hidden py-0 shadow-none">
|
|
169
|
+
<div className="flex flex-wrap items-center justify-between gap-4 p-4">
|
|
170
|
+
<div className="flex items-start gap-3">
|
|
171
|
+
<div
|
|
172
|
+
className={`flex size-9 shrink-0 items-center justify-center rounded-lg ${state?.blocked || error ? "bg-destructive/10 text-destructive" : "bg-muted text-muted-foreground"}`}
|
|
173
|
+
>
|
|
174
|
+
{loading ? (
|
|
175
|
+
<RefreshCw className="size-4 animate-spin" />
|
|
176
|
+
) : state?.blocked || error ? (
|
|
177
|
+
<ShieldAlert className="size-4" />
|
|
178
|
+
) : (
|
|
179
|
+
<ShieldCheck className="size-4" />
|
|
180
|
+
)}
|
|
181
|
+
</div>
|
|
182
|
+
<div>
|
|
183
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
184
|
+
<h2 className="text-sm font-semibold">
|
|
185
|
+
{t("Распространение OTA")}
|
|
186
|
+
</h2>
|
|
187
|
+
<Badge
|
|
188
|
+
variant="secondary"
|
|
189
|
+
className={
|
|
190
|
+
state?.blocked || error
|
|
191
|
+
? "bg-destructive/10 text-destructive"
|
|
192
|
+
: ""
|
|
193
|
+
}
|
|
194
|
+
>
|
|
195
|
+
{loading
|
|
196
|
+
? t("Проверка…")
|
|
197
|
+
: error || !state
|
|
198
|
+
? t("Недоступно")
|
|
199
|
+
: state.blocked
|
|
200
|
+
? t("Остановлено")
|
|
201
|
+
: t("Работает")}
|
|
202
|
+
</Badge>
|
|
179
203
|
</div>
|
|
180
|
-
|
|
204
|
+
<p className="mt-1 text-xs text-muted-foreground">
|
|
205
|
+
{state?.blocked
|
|
206
|
+
? state.reason
|
|
207
|
+
: t("Глобальное управление выдачей manifest и assets.")}
|
|
208
|
+
</p>
|
|
209
|
+
</div>
|
|
181
210
|
</div>
|
|
182
|
-
|
|
183
211
|
{state?.canWrite ? (
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
212
|
+
<Button
|
|
213
|
+
variant="outline"
|
|
214
|
+
size="sm"
|
|
215
|
+
onClick={() => setExpanded((value) => !value)}
|
|
216
|
+
aria-expanded={expanded}
|
|
217
|
+
aria-controls="distribution-controls"
|
|
218
|
+
>
|
|
219
|
+
{t("Управление")}
|
|
220
|
+
<ChevronDown
|
|
221
|
+
className={`transition-transform ${expanded ? "rotate-180" : ""}`}
|
|
222
|
+
/>
|
|
223
|
+
</Button>
|
|
224
|
+
) : state ? (
|
|
225
|
+
<Badge variant="outline">Read only · updates:write</Badge>
|
|
226
|
+
) : null}
|
|
227
|
+
</div>
|
|
228
|
+
{expanded && state?.canWrite && (
|
|
229
|
+
<div
|
|
230
|
+
id="distribution-controls"
|
|
231
|
+
className="space-y-3 border-t bg-muted/20 p-4"
|
|
232
|
+
>
|
|
233
|
+
<p className="text-xs text-muted-foreground">
|
|
234
|
+
{t("Изменено: ")}
|
|
235
|
+
{new Date(state.changedAt).toLocaleString(formatLocale)} ·{" "}
|
|
236
|
+
{formatChangedBy(state)} · version {state.version}
|
|
237
|
+
</p>
|
|
238
|
+
{!state.blocked && (
|
|
239
|
+
<label className="block space-y-2 text-sm font-medium">
|
|
240
|
+
{t("Причина остановки")}
|
|
241
|
+
<Textarea
|
|
187
242
|
value={reason}
|
|
188
243
|
onChange={(event) => setReason(event.target.value)}
|
|
189
244
|
maxLength={500}
|
|
190
|
-
aria-label="Причина аварийной блокировки OTA"
|
|
191
|
-
placeholder=
|
|
192
|
-
|
|
245
|
+
aria-label={t("Причина аварийной блокировки OTA")}
|
|
246
|
+
placeholder={t(
|
|
247
|
+
"Обязательная причина остановки (до 500 символов)",
|
|
248
|
+
)}
|
|
249
|
+
className="block min-h-20 w-full max-w-2xl rounded-md border border-input bg-background p-3 text-sm font-normal outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
193
250
|
/>
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
) : null}
|
|
217
|
-
</div>
|
|
218
|
-
|
|
219
|
-
{error ? (
|
|
220
|
-
<p className="mt-3 rounded-md bg-red-100 p-2 text-sm text-red-900 dark:bg-red-950 dark:text-red-200">
|
|
221
|
-
{error}
|
|
251
|
+
</label>
|
|
252
|
+
)}
|
|
253
|
+
<Button
|
|
254
|
+
variant={state.blocked ? "default" : "destructive"}
|
|
255
|
+
size="sm"
|
|
256
|
+
disabled={saving || loading}
|
|
257
|
+
onClick={() => void changeState(!state.blocked)}
|
|
258
|
+
>
|
|
259
|
+
{saving
|
|
260
|
+
? t("Сохранение…")
|
|
261
|
+
: state.blocked
|
|
262
|
+
? t("Возобновить OTA")
|
|
263
|
+
: t("Остановить все OTA")}
|
|
264
|
+
</Button>
|
|
265
|
+
</div>
|
|
266
|
+
)}
|
|
267
|
+
{error && (
|
|
268
|
+
<p
|
|
269
|
+
role="alert"
|
|
270
|
+
className="border-t bg-destructive/5 px-4 py-3 text-sm text-destructive"
|
|
271
|
+
>
|
|
272
|
+
{t(error)}
|
|
222
273
|
</p>
|
|
223
|
-
)
|
|
224
|
-
{message
|
|
225
|
-
<p
|
|
274
|
+
)}
|
|
275
|
+
{message && (
|
|
276
|
+
<p
|
|
277
|
+
role="status"
|
|
278
|
+
className="border-t px-4 py-3 text-sm text-emerald-700 dark:text-emerald-400"
|
|
279
|
+
>
|
|
226
280
|
{message}
|
|
227
281
|
</p>
|
|
228
|
-
)
|
|
229
|
-
</
|
|
282
|
+
)}
|
|
283
|
+
</Card>
|
|
230
284
|
);
|
|
231
285
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { Input } from "@/components/ui/input";
|
|
4
|
+
|
|
3
5
|
import {
|
|
4
6
|
filterGuardActionOptions,
|
|
5
7
|
GuardActionOption,
|
|
6
8
|
normalizeCreatableGuardAction,
|
|
7
9
|
} from "./guard-action-options";
|
|
8
|
-
import {
|
|
9
|
-
KeyboardEvent,
|
|
10
|
-
useId,
|
|
11
|
-
useRef,
|
|
12
|
-
useState,
|
|
13
|
-
} from "react";
|
|
10
|
+
import { KeyboardEvent, useId, useRef, useState } from "react";
|
|
14
11
|
|
|
15
12
|
type Props = {
|
|
16
13
|
value: string;
|
|
@@ -141,7 +138,7 @@ export default function GuardActionCombobox({
|
|
|
141
138
|
}
|
|
142
139
|
}}
|
|
143
140
|
>
|
|
144
|
-
<
|
|
141
|
+
<Input
|
|
145
142
|
value={inputValue}
|
|
146
143
|
maxLength={100}
|
|
147
144
|
readOnly={selectionDisabled}
|
|
@@ -152,9 +149,7 @@ export default function GuardActionCombobox({
|
|
|
152
149
|
aria-haspopup="dialog"
|
|
153
150
|
aria-expanded={open}
|
|
154
151
|
aria-controls={popupId}
|
|
155
|
-
aria-describedby={
|
|
156
|
-
inputError || mutationError ? errorId : undefined
|
|
157
|
-
}
|
|
152
|
+
aria-describedby={inputError || mutationError ? errorId : undefined}
|
|
158
153
|
onFocus={() => setOpen(true)}
|
|
159
154
|
onChange={(event) => {
|
|
160
155
|
setDraftValue(event.target.value);
|
|
@@ -163,7 +158,7 @@ export default function GuardActionCombobox({
|
|
|
163
158
|
setActiveIndex(-1);
|
|
164
159
|
}}
|
|
165
160
|
onKeyDown={handleKeyDown}
|
|
166
|
-
className="w-full
|
|
161
|
+
className="w-full"
|
|
167
162
|
placeholder="Action (required)"
|
|
168
163
|
/>
|
|
169
164
|
{open ? (
|
|
@@ -171,24 +166,20 @@ export default function GuardActionCombobox({
|
|
|
171
166
|
id={popupId}
|
|
172
167
|
role="dialog"
|
|
173
168
|
aria-label="Guard action catalog"
|
|
174
|
-
className="absolute z-20 mt-1 max-h-60 w-full overflow-auto rounded-
|
|
169
|
+
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"
|
|
175
170
|
>
|
|
176
171
|
{filteredOptions.map((option, index) => (
|
|
177
172
|
<div
|
|
178
173
|
key={`${option.id || "policy"}:${option.actionKey}`}
|
|
179
174
|
className={`flex items-center rounded ${
|
|
180
|
-
activeIndex === index
|
|
181
|
-
? "bg-blue-50 dark:bg-blue-950"
|
|
182
|
-
: ""
|
|
175
|
+
activeIndex === index ? "bg-accent" : ""
|
|
183
176
|
}`}
|
|
184
177
|
>
|
|
185
178
|
<button
|
|
186
179
|
type="button"
|
|
187
180
|
tabIndex={-1}
|
|
188
181
|
disabled={selectionDisabled}
|
|
189
|
-
aria-current={
|
|
190
|
-
option.actionKey === value ? "true" : undefined
|
|
191
|
-
}
|
|
182
|
+
aria-current={option.actionKey === value ? "true" : undefined}
|
|
192
183
|
onMouseDown={(event) => event.preventDefault()}
|
|
193
184
|
onClick={() => chooseOption(option)}
|
|
194
185
|
className="min-w-0 flex-1 truncate px-3 py-2 text-left text-sm disabled:cursor-default"
|
|
@@ -206,7 +197,7 @@ export default function GuardActionCombobox({
|
|
|
206
197
|
event.stopPropagation();
|
|
207
198
|
void onDelete(option);
|
|
208
199
|
}}
|
|
209
|
-
className="m-1 rounded p-2 text-
|
|
200
|
+
className="m-1 rounded p-2 text-destructive hover:bg-destructive/10"
|
|
210
201
|
>
|
|
211
202
|
<svg
|
|
212
203
|
viewBox="0 0 24 24"
|
|
@@ -228,17 +219,15 @@ export default function GuardActionCombobox({
|
|
|
228
219
|
type="button"
|
|
229
220
|
onMouseDown={(event) => event.preventDefault()}
|
|
230
221
|
onClick={() => void create()}
|
|
231
|
-
className={`w-full rounded px-3 py-2 text-left text-sm font-medium text-
|
|
232
|
-
activeIndex === filteredOptions.length
|
|
233
|
-
? "bg-blue-50 dark:bg-blue-950"
|
|
234
|
-
: ""
|
|
222
|
+
className={`w-full rounded px-3 py-2 text-left text-sm font-medium text-primary ${
|
|
223
|
+
activeIndex === filteredOptions.length ? "bg-accent" : ""
|
|
235
224
|
}`}
|
|
236
225
|
>
|
|
237
226
|
Create “{creatableValue}”
|
|
238
227
|
</button>
|
|
239
228
|
) : null}
|
|
240
229
|
{filteredOptions.length === 0 && !showCreate ? (
|
|
241
|
-
<p className="px-3 py-2 text-sm text-
|
|
230
|
+
<p className="px-3 py-2 text-sm text-muted-foreground">
|
|
242
231
|
No matching actions
|
|
243
232
|
</p>
|
|
244
233
|
) : null}
|