Compare commits
8 Commits
091a1a651d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 97c63ac25b | |||
| 62c569741f | |||
| 3ad0e56ecd | |||
| ada5d06dad | |||
| 3a57c0a77c | |||
| 9a896bb5f6 | |||
| 78f5afad35 | |||
| 27205c65ef |
+1
-1
@@ -72,7 +72,7 @@ const router = createBrowserRouter(
|
|||||||
<Route path="/authorities" element={<Navigate to="/authorities/person" replace />} />
|
<Route path="/authorities" element={<Navigate to="/authorities/person" replace />} />
|
||||||
<Route path="/authorities/:kind" element={<AuthoritiesPage />} />
|
<Route path="/authorities/:kind" element={<AuthoritiesPage />} />
|
||||||
<Route
|
<Route
|
||||||
path="/fields"
|
path="/fields/:key?"
|
||||||
element={
|
element={
|
||||||
<Suspense fallback={<ListSkeleton />}>
|
<Suspense fallback={<ListSkeleton />}>
|
||||||
<FieldsPage />
|
<FieldsPage />
|
||||||
|
|||||||
@@ -57,6 +57,31 @@ test("rejects an off-site from and falls back to /objects", async () => {
|
|||||||
expect(await screen.findByText("objects landing")).toBeInTheDocument();
|
expect(await screen.findByText("objects landing")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("shows Signing in… and disables the button while pending", async () => {
|
||||||
|
let release!: () => void;
|
||||||
|
const gate = new Promise<void>((r) => {
|
||||||
|
release = r;
|
||||||
|
});
|
||||||
|
|
||||||
|
server.use(
|
||||||
|
http.post("/api/admin/login", async () => {
|
||||||
|
await gate;
|
||||||
|
return new HttpResponse(null, { status: 204 });
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
renderApp(tree(), { route: "/login" });
|
||||||
|
await userEvent.type(screen.getByLabelText(/email/i), "editor@example.com");
|
||||||
|
await userEvent.type(screen.getByLabelText(/password/i), "pw-editor-123");
|
||||||
|
await userEvent.click(screen.getByRole("button", { name: /sign in/i }));
|
||||||
|
|
||||||
|
const pending = await screen.findByRole("button", { name: /signing in/i });
|
||||||
|
expect(pending).toBeDisabled();
|
||||||
|
|
||||||
|
release();
|
||||||
|
expect(await screen.findByText("objects landing")).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
test("disables submit until both fields are filled", async () => {
|
test("disables submit until both fields are filled", async () => {
|
||||||
renderApp(tree(), { route: "/login" });
|
renderApp(tree(), { route: "/login" });
|
||||||
const button = screen.getByRole("button", { name: /sign in/i });
|
const button = screen.getByRole("button", { name: /sign in/i });
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export function LoginPage() {
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
<Button type="submit" className="w-full" disabled={login.isPending || !email.trim() || !password}>
|
<Button type="submit" className="w-full" disabled={login.isPending || !email.trim() || !password}>
|
||||||
{t("auth.signIn")}
|
{login.isPending ? t("auth.signingIn") : t("auth.signIn")}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,6 +20,31 @@ test("delete-in-use shows the in-use count and keeps the dialog open", async ()
|
|||||||
expect(dialog.getByText("Delete this term?")).toBeInTheDocument();
|
expect(dialog.getByText("Delete this term?")).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("confirm is disabled and labelled Deleting… while pending", async () => {
|
||||||
|
let resolve!: () => void;
|
||||||
|
const onConfirm = vi.fn(
|
||||||
|
() =>
|
||||||
|
new Promise<void>((r) => {
|
||||||
|
resolve = r;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
renderApp(<DeleteConfirmDialog description="Delete this term?" onConfirm={onConfirm} />);
|
||||||
|
|
||||||
|
await userEvent.click(screen.getByRole("button", { name: /delete/i }));
|
||||||
|
|
||||||
|
const dialog = within(document.body);
|
||||||
|
const buttons = await dialog.findAllByRole("button", { name: /delete/i });
|
||||||
|
await userEvent.click(buttons[buttons.length - 1]);
|
||||||
|
|
||||||
|
const pending = await dialog.findByRole("button", { name: /deleting/i });
|
||||||
|
expect(pending).toBeDisabled();
|
||||||
|
expect(dialog.getByRole("button", { name: /cancel/i })).toBeDisabled();
|
||||||
|
expect(onConfirm).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
resolve();
|
||||||
|
await waitFor(() => expect(dialog.queryByText("Delete this term?")).toBeNull());
|
||||||
|
});
|
||||||
|
|
||||||
test("a clean confirm closes the dialog", async () => {
|
test("a clean confirm closes the dialog", async () => {
|
||||||
const onConfirm = vi.fn(() => Promise.resolve());
|
const onConfirm = vi.fn(() => Promise.resolve());
|
||||||
renderApp(<DeleteConfirmDialog description="Delete this term?" onConfirm={onConfirm} />);
|
renderApp(<DeleteConfirmDialog description="Delete this term?" onConfirm={onConfirm} />);
|
||||||
|
|||||||
@@ -28,10 +28,12 @@ export function DeleteConfirmDialog({
|
|||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
|
const [pending, setPending] = useState(false);
|
||||||
const [message, setMessage] = useState<string | null>(null);
|
const [message, setMessage] = useState<string | null>(null);
|
||||||
|
|
||||||
const confirm = async () => {
|
const confirm = async () => {
|
||||||
setMessage(null);
|
setMessage(null);
|
||||||
|
setPending(true);
|
||||||
try {
|
try {
|
||||||
await onConfirm();
|
await onConfirm();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -40,6 +42,8 @@ export function DeleteConfirmDialog({
|
|||||||
const { key, opts } = errorMessageKey(err);
|
const { key, opts } = errorMessageKey(err);
|
||||||
setMessage(t(key, opts));
|
setMessage(t(key, opts));
|
||||||
return;
|
return;
|
||||||
|
} finally {
|
||||||
|
setPending(false);
|
||||||
}
|
}
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
};
|
};
|
||||||
@@ -62,8 +66,10 @@ export function DeleteConfirmDialog({
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>{t("form.cancel")}</AlertDialogCancel>
|
<AlertDialogCancel disabled={pending}>{t("form.cancel")}</AlertDialogCancel>
|
||||||
<AlertDialogAction onClick={confirm}>{t("actions.delete")}</AlertDialogAction>
|
<AlertDialogAction disabled={pending} onClick={confirm}>
|
||||||
|
{pending ? t("actions.deleting") : t("actions.delete")}
|
||||||
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function AlertDialogContent({
|
|||||||
data-slot="alert-dialog-content"
|
data-slot="alert-dialog-content"
|
||||||
data-size={size}
|
data-size={size}
|
||||||
className={cn(
|
className={cn(
|
||||||
"group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
"group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 overscroll-y-contain rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ function ComboboxPopup({ className, ...props }: ComboboxPrimitive.Popup.Props) {
|
|||||||
<ComboboxPrimitive.Popup
|
<ComboboxPrimitive.Popup
|
||||||
data-slot="combobox-popup"
|
data-slot="combobox-popup"
|
||||||
className={cn(
|
className={cn(
|
||||||
"max-h-64 min-w-48 overflow-auto rounded border bg-popover p-1 text-sm text-popover-foreground shadow-md",
|
"max-h-64 min-w-48 overflow-auto overscroll-y-contain rounded border bg-popover p-1 text-sm text-popover-foreground shadow-md",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ function DrawerContent({ className, children, ...props }: DrawerPrimitive.Popup.
|
|||||||
<DrawerPrimitive.Popup
|
<DrawerPrimitive.Popup
|
||||||
data-slot="drawer-content"
|
data-slot="drawer-content"
|
||||||
className={cn(
|
className={cn(
|
||||||
"fixed inset-y-0 right-0 flex w-full max-w-md flex-col overflow-y-auto bg-background shadow-xl outline-none duration-200 data-open:animate-in data-open:slide-in-from-right data-closed:animate-out data-closed:slide-out-to-right",
|
"fixed inset-y-0 right-0 flex w-full max-w-md flex-col overflow-y-auto overscroll-y-contain bg-background shadow-xl outline-none duration-200 data-open:animate-in data-open:slide-in-from-right data-closed:animate-out data-closed:slide-out-to-right",
|
||||||
className,
|
className,
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export function PageTitle({ className, ...props }: ComponentProps<"h1">) {
|
|||||||
return (
|
return (
|
||||||
<h1
|
<h1
|
||||||
data-slot="page-title"
|
data-slot="page-title"
|
||||||
className={cn("text-2xl font-semibold tracking-tight", className)}
|
className={cn("text-2xl font-semibold tracking-tight text-balance", className)}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ function SelectContent({
|
|||||||
<SelectPrimitive.Popup
|
<SelectPrimitive.Popup
|
||||||
data-slot="select-content"
|
data-slot="select-content"
|
||||||
className={cn(
|
className={cn(
|
||||||
"max-h-[min(24rem,var(--available-height))] min-w-[var(--anchor-width)] overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md outline-none",
|
"max-h-[min(24rem,var(--available-height))] min-w-[var(--anchor-width)] overflow-y-auto overscroll-y-contain rounded-md border bg-popover p-1 text-popover-foreground shadow-md outline-none",
|
||||||
"data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
"data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ export function FieldForm({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{isEdit && <p className="text-xs text-muted-foreground">{t("fields.lockedNote")}</p>}
|
||||||
|
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
<Label htmlFor="field-key">{t("fields.key")}</Label>
|
<Label htmlFor="field-key">{t("fields.key")}</Label>
|
||||||
<Input
|
<Input
|
||||||
|
|||||||
@@ -90,18 +90,23 @@ export function FieldList({
|
|||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className={cn("flex flex-1 items-center gap-2 rounded-sm text-left", focusRing)}
|
className={cn(
|
||||||
|
"flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left",
|
||||||
|
focusRing,
|
||||||
|
)}
|
||||||
aria-pressed={def.key === selectedKey}
|
aria-pressed={def.key === selectedKey}
|
||||||
onClick={() => onSelect(def)}
|
onClick={() => onSelect(def)}
|
||||||
>
|
>
|
||||||
<span className="font-medium">{labelText(def.labels, lang)}</span>
|
<span className="min-w-0 truncate font-medium">
|
||||||
|
{labelText(def.labels, lang)}
|
||||||
|
</span>
|
||||||
<span className="text-xs text-muted-foreground">{def.key}</span>
|
<span className="text-xs text-muted-foreground">{def.key}</span>
|
||||||
<Badge variant="secondary">
|
<Badge variant="secondary" className="shrink-0">
|
||||||
{t(`fields.types.${def.data_type}`)}
|
{t(`fields.types.${def.data_type}`)}
|
||||||
</Badge>
|
</Badge>
|
||||||
{def.required && (
|
{def.required && (
|
||||||
<span
|
<span
|
||||||
className="text-xs text-destructive"
|
className="shrink-0 text-xs text-destructive"
|
||||||
title={t("fields.required")}
|
title={t("fields.required")}
|
||||||
aria-label={t("fields.required")}
|
aria-label={t("fields.required")}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
|
|
||||||
import type { components } from "../api/schema";
|
import { useFieldDefinitions } from "../api/queries";
|
||||||
import { FieldList } from "./field-list";
|
import { FieldList } from "./field-list";
|
||||||
import { FieldForm } from "./field-form";
|
import { FieldForm } from "./field-form";
|
||||||
import { useDocumentTitle } from "../lib/use-document-title";
|
import { useDocumentTitle } from "../lib/use-document-title";
|
||||||
import { useBreadcrumb } from "../shell/use-breadcrumb";
|
import { useBreadcrumb } from "../shell/use-breadcrumb";
|
||||||
import { PageTitle } from "@/components/ui/page-title";
|
import { PageTitle } from "@/components/ui/page-title";
|
||||||
|
|
||||||
type FieldDefinitionView = components["schemas"]["FieldDefinitionView"];
|
|
||||||
|
|
||||||
export function FieldsPage() {
|
export function FieldsPage() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [selected, setSelected] = useState<FieldDefinitionView | null>(null);
|
const navigate = useNavigate();
|
||||||
|
const { key } = useParams();
|
||||||
|
const { data } = useFieldDefinitions();
|
||||||
|
|
||||||
|
// Selection lives in the URL (/fields/:key) so it survives reload and can be
|
||||||
|
// shared, matching /vocabularies/:id. An unknown or absent key falls back to
|
||||||
|
// the create form. Same cached query as FieldList, so no extra fetch.
|
||||||
|
const selected = (key && data?.find((def) => def.key === key)) || null;
|
||||||
|
|
||||||
useDocumentTitle(t("fields.title"));
|
useDocumentTitle(t("fields.title"));
|
||||||
useBreadcrumb([{ label: t("nav.fields") }]);
|
useBreadcrumb([{ label: t("nav.fields") }]);
|
||||||
@@ -22,13 +27,16 @@ export function FieldsPage() {
|
|||||||
<PageTitle className="px-4 pt-4 pb-2">{t("fields.title")}</PageTitle>
|
<PageTitle className="px-4 pt-4 pb-2">{t("fields.title")}</PageTitle>
|
||||||
<div className="grid flex-1 grid-cols-1 overflow-auto lg:grid-cols-[20rem_1fr] lg:overflow-hidden">
|
<div className="grid flex-1 grid-cols-1 overflow-auto lg:grid-cols-[20rem_1fr] lg:overflow-hidden">
|
||||||
<div className="overflow-hidden border-b lg:border-r lg:border-b-0">
|
<div className="overflow-hidden border-b lg:border-r lg:border-b-0">
|
||||||
<FieldList selectedKey={selected?.key ?? null} onSelect={setSelected} />
|
<FieldList
|
||||||
|
selectedKey={selected?.key ?? null}
|
||||||
|
onSelect={(def) => navigate(`/fields/${encodeURIComponent(def.key)}`)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="overflow-hidden">
|
<div className="overflow-hidden">
|
||||||
<FieldForm
|
<FieldForm
|
||||||
key={selected?.key ?? "create"}
|
key={selected?.key ?? "create"}
|
||||||
editing={selected}
|
editing={selected}
|
||||||
onDone={() => setSelected(null)}
|
onDone={() => navigate("/fields")}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { FieldsPage } from "./fields-page";
|
|||||||
function tree() {
|
function tree() {
|
||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
<Route path="/fields" element={<FieldsPage />} />
|
<Route path="/fields/:key?" element={<FieldsPage />} />
|
||||||
</Routes>
|
</Routes>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -87,6 +87,40 @@ test("filter narrows the visible fields", async () => {
|
|||||||
expect(await screen.findByText(/no matches/i)).toBeInTheDocument();
|
expect(await screen.findByText(/no matches/i)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("deep link /fields/:key opens the edit form for that field", async () => {
|
||||||
|
renderApp(tree(), { route: "/fields/inscription" });
|
||||||
|
|
||||||
|
// edit mode: the key input is locked and prefilled from the URL. The form
|
||||||
|
// remounts when the defs query resolves, so re-query inside waitFor.
|
||||||
|
await waitFor(() => expect(screen.getByLabelText(/^key$/i)).toHaveValue("inscription"));
|
||||||
|
expect(screen.getByLabelText(/^key$/i)).toBeDisabled();
|
||||||
|
expect(screen.getByRole("button", { name: /cancel/i })).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("selecting a field switches to its edit form; cancel returns to create", async () => {
|
||||||
|
renderApp(tree(), { route: "/fields" });
|
||||||
|
|
||||||
|
await userEvent.click(await screen.findByRole("button", { name: /inscription/i }));
|
||||||
|
|
||||||
|
await waitFor(() => expect(screen.getByLabelText(/^key$/i)).toHaveValue("inscription"));
|
||||||
|
expect(screen.getByLabelText(/^key$/i)).toBeDisabled();
|
||||||
|
|
||||||
|
await userEvent.click(screen.getByRole("button", { name: /cancel/i }));
|
||||||
|
|
||||||
|
await waitFor(() => expect(screen.getByLabelText(/^key$/i)).toHaveValue(""));
|
||||||
|
expect(screen.getByLabelText(/^key$/i)).toBeEnabled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("an unknown key falls back to the create form", async () => {
|
||||||
|
renderApp(tree(), { route: "/fields/zzz-does-not-exist" });
|
||||||
|
|
||||||
|
await screen.findByText("Inscription");
|
||||||
|
|
||||||
|
const key = screen.getByLabelText(/^key$/i);
|
||||||
|
expect(key).toHaveValue("");
|
||||||
|
expect(key).toBeEnabled();
|
||||||
|
});
|
||||||
|
|
||||||
test("creates a text field — posts the body and clears the key input", async () => {
|
test("creates a text field — posts the body and clears the key input", async () => {
|
||||||
let body: { key: string; data_type: string } | undefined;
|
let body: { key: string; data_type: string } | undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"common": { "yes": "Yes", "no": "No", "close": "Close", "loading": "Loading", "filter": "Filter…", "noMatches": "No matches", "language": "Language", "skipToContent": "Skip to content", "clear": "Clear", "open": "Open" },
|
"common": { "yes": "Yes", "no": "No", "close": "Close", "loading": "Loading", "filter": "Filter…", "noMatches": "No matches", "language": "Language", "skipToContent": "Skip to content", "clear": "Clear", "open": "Open" },
|
||||||
"nav": { "objects": "Objects", "vocabularies": "Vocabularies", "authorities": "Authorities", "fields": "Fields", "search": "Search", "collapseSidebar": "Collapse sidebar", "expandSidebar": "Expand sidebar", "breadcrumb": "Breadcrumb" },
|
"nav": { "objects": "Objects", "vocabularies": "Vocabularies", "authorities": "Authorities", "fields": "Fields", "search": "Search", "collapseSidebar": "Collapse sidebar", "expandSidebar": "Expand sidebar", "breadcrumb": "Breadcrumb" },
|
||||||
"auth": { "email": "Email", "password": "Password", "signIn": "Sign in", "signOut": "Sign out", "invalid": "Invalid email or password", "networkError": "Could not reach the server", "sessionExpired": "Your session expired — please sign in again.", "signingOut": "Signing out…" },
|
"auth": { "email": "Email", "password": "Password", "signIn": "Sign in", "signingIn": "Signing in…", "signOut": "Sign out", "invalid": "Invalid email or password", "networkError": "Could not reach the server", "sessionExpired": "Your session expired — please sign in again.", "signingOut": "Signing out…" },
|
||||||
"objects": { "title": "Objects", "empty": "No objects yet", "loadError": "Could not load objects", "notFound": "Object not found", "prev": "Previous", "next": "Next", "of": "of", "new": "New object", "filter": "Filter objects…", "pageSize": "Per page", "columns": { "number": "Object №", "name": "Name", "visibility": "Visibility", "location": "Location", "count": "#", "updated": "Updated" }, "unknownRef": "(unknown)", "detailTitle": "Object detail", "tableLabel": "Objects" },
|
"objects": { "title": "Objects", "empty": "No objects yet", "loadError": "Could not load objects", "notFound": "Object not found", "prev": "Previous", "next": "Next", "of": "of", "new": "New object", "filter": "Filter objects…", "pageSize": "Per page", "columns": { "number": "Object №", "name": "Name", "visibility": "Visibility", "location": "Location", "count": "#", "updated": "Updated" }, "unknownRef": "(unknown)", "detailTitle": "Object detail", "tableLabel": "Objects" },
|
||||||
"fieldsLabels": { "objectNumber": "Object number", "objectName": "Name", "count": "Number of objects", "briefDescription": "Brief description", "currentLocation": "Current location", "currentOwner": "Current owner", "recorder": "Recorder", "recordingDate": "Recording date", "visibility": "Visibility" },
|
"fieldsLabels": { "objectNumber": "Object number", "objectName": "Name", "count": "Number of objects", "briefDescription": "Brief description", "currentLocation": "Current location", "currentOwner": "Current owner", "recorder": "Recorder", "recordingDate": "Recording date", "visibility": "Visibility" },
|
||||||
"visibility": { "draft": "Draft", "internal": "Internal", "public": "Public" },
|
"visibility": { "draft": "Draft", "internal": "Internal", "public": "Public" },
|
||||||
"form": { "selectPlaceholder": "— select —", "create": "Create object", "save": "Save", "cancel": "Cancel", "visibility": "Visibility", "draft": "Draft", "internal": "Internal", "required": "This field is required", "rejected": "The server rejected the changes — check required and referenced fields", "fieldRejected": "The field \"{{field}}\" was rejected — check its value", "createdButFieldRejected": "Object created, but a field was rejected — fix it below.", "flexibleHeading": "Catalogue fields", "saving": "Saving…", "createAnother": "Save & create another", "minCount": "Must be at least 1", "fieldError": { "type_mismatch": "Wrong type for this field", "unresolved": "Referenced value not found", "unknown": "Unknown field" }, "unsaved": { "title": "Discard unsaved changes?", "body": "You have unsaved changes that will be lost.", "stay": "Keep editing", "leave": "Discard" } },
|
"form": { "selectPlaceholder": "Select…", "create": "Create object", "save": "Save", "cancel": "Cancel", "visibility": "Visibility", "draft": "Draft", "internal": "Internal", "required": "This field is required", "rejected": "The server rejected the changes — check required and referenced fields", "fieldRejected": "The field \"{{field}}\" was rejected — check its value", "createdButFieldRejected": "Object created, but a field was rejected — fix it below.", "flexibleHeading": "Catalogue fields", "saving": "Saving…", "createAnother": "Save & create another", "minCount": "Must be at least 1", "fieldError": { "type_mismatch": "Wrong type for this field", "unresolved": "Referenced value not found", "unknown": "Unknown field" }, "unsaved": { "title": "Discard unsaved changes?", "body": "You have unsaved changes that will be lost.", "stay": "Keep editing", "leave": "Discard" } },
|
||||||
"actions": { "edit": "Edit", "delete": "Delete", "rename": "Rename", "save": "Save", "closeDetail": "Close detail", "confirmDelete": "Delete this object? This cannot be undone.", "confirmDeleteTerm": "Delete this term? This cannot be undone.", "confirmDeleteAuthority": "Delete this authority? This cannot be undone.", "confirmDeleteField": "Delete this field definition? This cannot be undone.", "confirmDeleteVocabulary": "Delete this vocabulary? This cannot be undone.", "inUse": "Can't delete — used by {{count}} object(s). Clear those fields first." },
|
"actions": { "deleting": "Deleting…", "edit": "Edit", "delete": "Delete", "rename": "Rename", "save": "Save", "closeDetail": "Close detail", "confirmDelete": "Delete this object? This cannot be undone.", "confirmDeleteTerm": "Delete this term? This cannot be undone.", "confirmDeleteAuthority": "Delete this authority? This cannot be undone.", "confirmDeleteField": "Delete this field definition? This cannot be undone.", "confirmDeleteVocabulary": "Delete this vocabulary? This cannot be undone.", "inUse": "Can't delete — used by {{count}} object(s). Clear those fields first." },
|
||||||
"labels": { "label": "Label", "externalUri": "External URI (optional)", "otherLanguages": "This entry also has labels in other languages, which are kept.", "uriPlaceholder": "https://…" },
|
"labels": { "label": "Label", "externalUri": "External URI (optional)", "otherLanguages": "This entry also has labels in other languages, which are kept.", "uriPlaceholder": "https://…" },
|
||||||
"theme": { "light": "Light", "dark": "Dark", "system": "System" },
|
"theme": { "light": "Light", "dark": "Dark", "system": "System" },
|
||||||
"vocab": {
|
"vocab": {
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
"authorityKind": "Authority kind",
|
"authorityKind": "Authority kind",
|
||||||
"anyKind": "Any",
|
"anyKind": "Any",
|
||||||
"group": "Group",
|
"group": "Group",
|
||||||
|
"lockedNote": "Key and type can't be changed after creation.",
|
||||||
"required": "Required",
|
"required": "Required",
|
||||||
"create": "Create field",
|
"create": "Create field",
|
||||||
"empty": "No field definitions yet",
|
"empty": "No field definitions yet",
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"common": { "yes": "Ja", "no": "Nej", "close": "Stäng", "loading": "Laddar", "filter": "Filtrera…", "noMatches": "Inga träffar", "language": "Språk", "skipToContent": "Hoppa till innehåll", "clear": "Rensa", "open": "Öppna" },
|
"common": { "yes": "Ja", "no": "Nej", "close": "Stäng", "loading": "Laddar", "filter": "Filtrera…", "noMatches": "Inga träffar", "language": "Språk", "skipToContent": "Hoppa till innehåll", "clear": "Rensa", "open": "Öppna" },
|
||||||
"nav": { "objects": "Föremål", "vocabularies": "Vokabulär", "authorities": "Auktoriteter", "fields": "Fält", "search": "Sök", "collapseSidebar": "Fäll ihop sidofältet", "expandSidebar": "Fäll ut sidofältet", "breadcrumb": "Brödsmulor" },
|
"nav": { "objects": "Föremål", "vocabularies": "Vokabulär", "authorities": "Auktoriteter", "fields": "Fält", "search": "Sök", "collapseSidebar": "Fäll ihop sidofältet", "expandSidebar": "Fäll ut sidofältet", "breadcrumb": "Brödsmulor" },
|
||||||
"auth": { "email": "E-post", "password": "Lösenord", "signIn": "Logga in", "signOut": "Logga ut", "invalid": "Fel e-post eller lösenord", "networkError": "Kunde inte nå servern", "sessionExpired": "Din session har gått ut — logga in igen.", "signingOut": "Loggar ut…" },
|
"auth": { "email": "E-post", "password": "Lösenord", "signIn": "Logga in", "signingIn": "Loggar in…", "signOut": "Logga ut", "invalid": "Fel e-post eller lösenord", "networkError": "Kunde inte nå servern", "sessionExpired": "Din session har gått ut — logga in igen.", "signingOut": "Loggar ut…" },
|
||||||
"objects": { "title": "Föremål", "empty": "Inga föremål ännu", "loadError": "Kunde inte ladda föremål", "notFound": "Föremålet hittades inte", "prev": "Föregående", "next": "Nästa", "of": "av", "new": "Nytt föremål", "filter": "Filtrera föremål…", "pageSize": "Per sida", "columns": { "number": "Föremålsnr", "name": "Namn", "visibility": "Synlighet", "location": "Plats", "count": "Antal", "updated": "Uppdaterad" }, "unknownRef": "(okänd)", "detailTitle": "Objektdetalj", "tableLabel": "Objekt" },
|
"objects": { "title": "Föremål", "empty": "Inga föremål ännu", "loadError": "Kunde inte ladda föremål", "notFound": "Föremålet hittades inte", "prev": "Föregående", "next": "Nästa", "of": "av", "new": "Nytt föremål", "filter": "Filtrera föremål…", "pageSize": "Per sida", "columns": { "number": "Föremålsnr", "name": "Namn", "visibility": "Synlighet", "location": "Plats", "count": "Antal", "updated": "Uppdaterad" }, "unknownRef": "(okänd)", "detailTitle": "Objektdetalj", "tableLabel": "Objekt" },
|
||||||
"fieldsLabels": { "objectNumber": "Föremålsnummer", "objectName": "Namn", "count": "Antal föremål", "briefDescription": "Kort beskrivning", "currentLocation": "Nuvarande plats", "currentOwner": "Nuvarande ägare", "recorder": "Registrerad av", "recordingDate": "Registreringsdatum", "visibility": "Synlighet" },
|
"fieldsLabels": { "objectNumber": "Föremålsnummer", "objectName": "Namn", "count": "Antal föremål", "briefDescription": "Kort beskrivning", "currentLocation": "Nuvarande plats", "currentOwner": "Nuvarande ägare", "recorder": "Registrerad av", "recordingDate": "Registreringsdatum", "visibility": "Synlighet" },
|
||||||
"visibility": { "draft": "Utkast", "internal": "Intern", "public": "Publik" },
|
"visibility": { "draft": "Utkast", "internal": "Intern", "public": "Publik" },
|
||||||
"form": { "selectPlaceholder": "— välj —", "create": "Skapa föremål", "save": "Spara", "cancel": "Avbryt", "visibility": "Synlighet", "draft": "Utkast", "internal": "Intern", "required": "Fältet är obligatoriskt", "rejected": "Servern avvisade ändringarna — kontrollera obligatoriska och refererade fält", "fieldRejected": "Fältet \"{{field}}\" avvisades — kontrollera värdet", "createdButFieldRejected": "Föremålet skapades, men ett fält avvisades — åtgärda nedan.", "flexibleHeading": "Katalogfält", "saving": "Sparar…", "createAnother": "Spara & skapa ny", "minCount": "Måste vara minst 1", "fieldError": { "type_mismatch": "Fel typ för detta fält", "unresolved": "Refererat värde hittades inte", "unknown": "Okänt fält" }, "unsaved": { "title": "Kasta osparade ändringar?", "body": "Du har osparade ändringar som går förlorade.", "stay": "Fortsätt redigera", "leave": "Kasta" } },
|
"form": { "selectPlaceholder": "Välj…", "create": "Skapa föremål", "save": "Spara", "cancel": "Avbryt", "visibility": "Synlighet", "draft": "Utkast", "internal": "Intern", "required": "Fältet är obligatoriskt", "rejected": "Servern avvisade ändringarna — kontrollera obligatoriska och refererade fält", "fieldRejected": "Fältet \"{{field}}\" avvisades — kontrollera värdet", "createdButFieldRejected": "Föremålet skapades, men ett fält avvisades — åtgärda nedan.", "flexibleHeading": "Katalogfält", "saving": "Sparar…", "createAnother": "Spara & skapa ny", "minCount": "Måste vara minst 1", "fieldError": { "type_mismatch": "Fel typ för detta fält", "unresolved": "Refererat värde hittades inte", "unknown": "Okänt fält" }, "unsaved": { "title": "Kasta osparade ändringar?", "body": "Du har osparade ändringar som går förlorade.", "stay": "Fortsätt redigera", "leave": "Kasta" } },
|
||||||
"actions": { "edit": "Redigera", "delete": "Ta bort", "rename": "Byt namn", "save": "Spara", "closeDetail": "Stäng detalj", "confirmDelete": "Ta bort detta föremål? Detta kan inte ångras.", "confirmDeleteTerm": "Ta bort denna term? Detta kan inte ångras.", "confirmDeleteAuthority": "Ta bort denna auktoritet? Detta kan inte ångras.", "confirmDeleteField": "Ta bort denna fältdefinition? Detta kan inte ångras.", "confirmDeleteVocabulary": "Ta bort denna vokabulär? Detta kan inte ångras.", "inUse": "Kan inte ta bort — används av {{count}} föremål. Rensa de fälten först." },
|
"actions": { "deleting": "Tar bort…", "edit": "Redigera", "delete": "Ta bort", "rename": "Byt namn", "save": "Spara", "closeDetail": "Stäng detalj", "confirmDelete": "Ta bort detta föremål? Detta kan inte ångras.", "confirmDeleteTerm": "Ta bort denna term? Detta kan inte ångras.", "confirmDeleteAuthority": "Ta bort denna auktoritet? Detta kan inte ångras.", "confirmDeleteField": "Ta bort denna fältdefinition? Detta kan inte ångras.", "confirmDeleteVocabulary": "Ta bort denna vokabulär? Detta kan inte ångras.", "inUse": "Kan inte ta bort — används av {{count}} föremål. Rensa de fälten först." },
|
||||||
"labels": { "label": "Etikett", "externalUri": "Extern URI (valfritt)", "otherLanguages": "Denna post har även etiketter på andra språk, som behålls.", "uriPlaceholder": "https://…" },
|
"labels": { "label": "Etikett", "externalUri": "Extern URI (valfritt)", "otherLanguages": "Denna post har även etiketter på andra språk, som behålls.", "uriPlaceholder": "https://…" },
|
||||||
"theme": { "light": "Ljust", "dark": "Mörkt", "system": "System" },
|
"theme": { "light": "Ljust", "dark": "Mörkt", "system": "System" },
|
||||||
"vocab": {
|
"vocab": {
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
"authorityKind": "Auktoritetstyp",
|
"authorityKind": "Auktoritetstyp",
|
||||||
"anyKind": "Alla",
|
"anyKind": "Alla",
|
||||||
"group": "Grupp",
|
"group": "Grupp",
|
||||||
|
"lockedNote": "Nyckel och typ kan inte ändras efter att fältet skapats.",
|
||||||
"required": "Obligatoriskt",
|
"required": "Obligatoriskt",
|
||||||
"create": "Skapa fält",
|
"create": "Skapa fält",
|
||||||
"empty": "Inga fältdefinitioner ännu",
|
"empty": "Inga fältdefinitioner ännu",
|
||||||
|
|||||||
@@ -99,6 +99,19 @@
|
|||||||
body {
|
body {
|
||||||
@apply bg-background text-foreground font-sans;
|
@apply bg-background text-foreground font-sans;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Collapse all animation/transition to a single frame for users who ask the
|
||||||
|
OS for reduced motion. Covers the kit's data-open/closed animations, the
|
||||||
|
skeleton pulse, and the sidebar width transition in one place. */
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
*,
|
||||||
|
::before,
|
||||||
|
::after {
|
||||||
|
animation-duration: 0.01ms !important;
|
||||||
|
animation-iteration-count: 1 !important;
|
||||||
|
transition-duration: 0.01ms !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer components {
|
@layer components {
|
||||||
|
|||||||
@@ -41,6 +41,35 @@ test("confirm delete: DELETE then navigate to the list", async () => {
|
|||||||
expect(deleted).toBe(true);
|
expect(deleted).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("confirm is disabled and labelled Deleting… while the DELETE is in flight", async () => {
|
||||||
|
let release!: () => void;
|
||||||
|
const gate = new Promise<void>((r) => {
|
||||||
|
release = r;
|
||||||
|
});
|
||||||
|
|
||||||
|
server.use(
|
||||||
|
http.delete("/api/admin/objects/:id", async () => {
|
||||||
|
await gate;
|
||||||
|
return new HttpResponse(null, { status: 204 });
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
renderApp(tree(), { route: "/objects/o-1" });
|
||||||
|
|
||||||
|
await userEvent.click(await screen.findByRole("button", { name: /delete/i }));
|
||||||
|
|
||||||
|
const dialog = await screen.findByRole("alertdialog");
|
||||||
|
|
||||||
|
await userEvent.click(within(dialog).getByRole("button", { name: /delete/i }));
|
||||||
|
|
||||||
|
const pending = await within(dialog).findByRole("button", { name: /deleting/i });
|
||||||
|
expect(pending).toBeDisabled();
|
||||||
|
expect(within(dialog).getByRole("button", { name: /cancel/i })).toBeDisabled();
|
||||||
|
|
||||||
|
release();
|
||||||
|
await waitFor(() => expect(screen.getByText("objects list")).toBeInTheDocument());
|
||||||
|
});
|
||||||
|
|
||||||
test("cancel does not delete", async () => {
|
test("cancel does not delete", async () => {
|
||||||
let deleted = false;
|
let deleted = false;
|
||||||
|
|
||||||
|
|||||||
@@ -54,9 +54,9 @@ export function DeleteObjectDialog({ id }: { id: string }) {
|
|||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>{t("form.cancel")}</AlertDialogCancel>
|
<AlertDialogCancel disabled={del.isPending}>{t("form.cancel")}</AlertDialogCancel>
|
||||||
<AlertDialogAction onClick={onConfirm}>
|
<AlertDialogAction disabled={del.isPending} onClick={onConfirm}>
|
||||||
{t("actions.delete")}
|
{del.isPending ? t("actions.deleting") : t("actions.delete")}
|
||||||
</AlertDialogAction>
|
</AlertDialogAction>
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ test("term field filters and selects from the vocabulary combobox", async () =>
|
|||||||
|
|
||||||
renderApp(<FormHarness defKey="material" onSubmit={(v) => submitted.push(v)} />);
|
renderApp(<FormHarness defKey="material" onSubmit={(v) => submitted.push(v)} />);
|
||||||
|
|
||||||
const input = await screen.findByPlaceholderText("— select —");
|
const input = await screen.findByPlaceholderText("Select…");
|
||||||
|
|
||||||
await user.click(input);
|
await user.click(input);
|
||||||
await user.type(input, "bro");
|
await user.type(input, "bro");
|
||||||
@@ -73,7 +73,7 @@ test("authority field filters and selects from the authority combobox", async ()
|
|||||||
|
|
||||||
renderApp(<FormHarness defKey="maker" onSubmit={(v) => submitted.push(v)} />);
|
renderApp(<FormHarness defKey="maker" onSubmit={(v) => submitted.push(v)} />);
|
||||||
|
|
||||||
const input = await screen.findByPlaceholderText("— select —");
|
const input = await screen.findByPlaceholderText("Select…");
|
||||||
|
|
||||||
await user.click(input);
|
await user.click(input);
|
||||||
await user.type(input, "ada");
|
await user.type(input, "ada");
|
||||||
|
|||||||
@@ -80,15 +80,16 @@ export function Sidebar() {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
onClick={toggle}
|
onClick={toggle}
|
||||||
disabled={narrow}
|
|
||||||
aria-expanded={!collapsed}
|
aria-expanded={!collapsed}
|
||||||
aria-label={t(collapsed ? "nav.expandSidebar" : "nav.collapseSidebar")}
|
aria-label={t(collapsed ? "nav.expandSidebar" : "nav.collapseSidebar")}
|
||||||
title={t(collapsed ? "nav.expandSidebar" : "nav.collapseSidebar")}
|
title={t(collapsed ? "nav.expandSidebar" : "nav.collapseSidebar")}
|
||||||
className={cn(
|
className={cn(
|
||||||
"flex items-center justify-center rounded-md p-1 outline-none",
|
// On narrow viewports the rail is forced collapsed, so the toggle
|
||||||
|
// is hidden rather than shown disabled (a grayed button reads as
|
||||||
|
// broken, not unavailable).
|
||||||
|
"hidden items-center justify-center rounded-md p-1 outline-none md:flex",
|
||||||
"hover:bg-accent",
|
"hover:bg-accent",
|
||||||
focusRing,
|
focusRing,
|
||||||
"disabled:pointer-events-none disabled:opacity-50",
|
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{collapsed ? (
|
{collapsed ? (
|
||||||
|
|||||||
Reference in New Issue
Block a user