Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+19
-5
@@ -43,13 +43,14 @@ export type HrAdminAnnouncementsActions = {
|
||||
export type HrAdminAnnouncementsPageProps = {
|
||||
rows: readonly AdminAnnouncementRow[];
|
||||
audiences: readonly string[];
|
||||
audienceOptions: readonly { kind: "team" | "location"; ref: string; label: string }[];
|
||||
submitting: boolean;
|
||||
actions: HrAdminAnnouncementsActions;
|
||||
};
|
||||
|
||||
const EMPTY = { title: "", body: "", audienceRef: "", requiresAck: false, pinned: false };
|
||||
|
||||
export function HrAdminAnnouncementsPage({ rows, audiences, submitting, actions }: HrAdminAnnouncementsPageProps) {
|
||||
export function HrAdminAnnouncementsPage({ rows, audiences, audienceOptions, submitting, actions }: HrAdminAnnouncementsPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [form, setForm] = useState({ ...EMPTY, audienceKind: audiences[0] ?? "all" });
|
||||
@@ -124,7 +125,7 @@ export function HrAdminAnnouncementsPage({ rows, audiences, submitting, actions
|
||||
label={t("hr.announcements.field.audience")}
|
||||
showLabel
|
||||
value={form.audienceKind}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, audienceKind: value }))}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, audienceKind: value, audienceRef: "" }))}
|
||||
>
|
||||
{audiences.map((a) => (
|
||||
<Select.Item key={a} value={a}>
|
||||
@@ -132,9 +133,22 @@ export function HrAdminAnnouncementsPage({ rows, audiences, submitting, actions
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput label={t("hr.announcements.field.audienceRef")} showLabel>
|
||||
<TextInput.Input value={form.audienceRef} onChange={(e) => setForm((s) => ({ ...s, audienceRef: e.target.value }))} />
|
||||
</TextInput>
|
||||
{form.audienceKind !== "all" ? (
|
||||
<Select
|
||||
label={t("hr.announcements.field.audienceRef")}
|
||||
showLabel
|
||||
value={form.audienceRef}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, audienceRef: value }))}
|
||||
>
|
||||
{audienceOptions
|
||||
.filter((option) => option.kind === form.audienceKind)
|
||||
.map((option) => (
|
||||
<Select.Item key={`${option.kind}:${option.ref}`} value={option.ref}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
<DateField label={t("hr.announcements.field.publishAt")} name="publishAt" />
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import "@testing-library/jest-dom";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { buildAdminVaultListVM } from "@hivegrid/view-models";
|
||||
import { HrAdminPasswordSafePage } from "./HrAdminPasswordSafePage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
describe("HrAdminPasswordSafePage", () => {
|
||||
it("keeps archived vaults visible and offers a restore action", () => {
|
||||
const onArchiveVault = vi.fn();
|
||||
const onRestoreVault = vi.fn();
|
||||
const vm = buildAdminVaultListVM({
|
||||
rows: [
|
||||
{ id: "active", name: "Active vault", entryCount: 2, accessCount: 3, archived: false, detailHref: "/acme/passwords/active" },
|
||||
{ id: "archived", name: "Archived vault", entryCount: 1, accessCount: 2, archived: true, detailHref: "/acme/passwords/archived" },
|
||||
{ id: "metadata", name: "Metadata only", entryCount: 4, accessCount: 1, archived: false, detailHref: null },
|
||||
],
|
||||
});
|
||||
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<HrAdminPasswordSafePage vm={vm} submitting={false} actions={{ onArchiveVault, onRestoreVault, onSearch: vi.fn() }} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(screen.getByRole("link", { name: "Active vault" })).toHaveAttribute("href", "/acme/passwords/active");
|
||||
expect(screen.queryByRole("link", { name: "Archived vault" })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("link", { name: "Metadata only" })).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.click(screen.getByRole("button", { name: "hr.admin.passwordSafe.action.restore" }));
|
||||
expect(onRestoreVault).toHaveBeenCalledWith("archived");
|
||||
|
||||
fireEvent.click(screen.getAllByRole("button", { name: "hr.admin.passwordSafe.action.archive" })[0]!);
|
||||
expect(onArchiveVault).toHaveBeenCalledWith("active");
|
||||
});
|
||||
});
|
||||
+140
-60
@@ -4,91 +4,171 @@
|
||||
// content access (no secret values reachable here). Archive runs through the
|
||||
// injected action. Final Subframe optics = tracked design-nachzug.
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
import { FeatherArchive, FeatherLock, FeatherRotateCcw } from "@subframe/core";
|
||||
import type { AdminVaultListVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { FacetFilterBar } from "../shared/FacetFilterBar";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { useLiveFilter } from "~/hooks/use-live-filter";
|
||||
|
||||
export type HrAdminPasswordSafeActions = {
|
||||
onArchiveVault: (vaultId: string) => void;
|
||||
onRestoreVault: (vaultId: string) => void;
|
||||
onSearch: (query: string) => void;
|
||||
};
|
||||
|
||||
export type HrAdminPasswordSafePageProps = {
|
||||
vm: AdminVaultListVM;
|
||||
submitting: boolean;
|
||||
actionFeedback?: { status: "success" | "error"; messageKey: string } | null;
|
||||
actions: HrAdminPasswordSafeActions;
|
||||
};
|
||||
|
||||
export function HrAdminPasswordSafePage({ vm, submitting, actions }: HrAdminPasswordSafePageProps) {
|
||||
export function HrAdminPasswordSafePage({ vm, submitting, actionFeedback, actions }: HrAdminPasswordSafePageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [query, setQuery] = useState(vm.status === "ready" ? vm.data.searchQuery : "");
|
||||
// Free text settles before the server round-trip. Declared before the
|
||||
// not-ready return so hook order stays stable.
|
||||
const appliedQuery = vm.status === "ready" ? vm.data.searchQuery : "";
|
||||
useLiveFilter(query.trim(), appliedQuery, () => actions.onSearch(query.trim()));
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.admin.passwordSafe" />;
|
||||
return (
|
||||
<PageShell uiId="ui.hr.admin.passwordSafe">
|
||||
<PageHeader
|
||||
icon={<FeatherLock className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.admin.passwordSafe.title")}
|
||||
subtitle={t("hr.admin.passwordSafe.subtitle")}
|
||||
subtitleTone="secondary"
|
||||
/>
|
||||
<PageBody>
|
||||
<EmptyState
|
||||
title={t(vm.status === "error" ? vm.error.messageKey : "hr.passwordSafe.loading")}
|
||||
body={t(vm.status === "error" ? "hr.passwordSafe.notReadyBody" : "hr.passwordSafe.loadingBody")}
|
||||
/>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
const { rows, emptyHeadlineKey, emptyBodyKey } = vm.data;
|
||||
const { rows, activityRows, emptyHeadlineKey, emptyBodyKey } = vm.data;
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.admin.passwordSafe">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.admin.passwordSafe.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.admin.passwordSafe.subtitle")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.admin.passwordSafe.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.admin.passwordSafe.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.name")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.entries")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.access")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.status")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{rows.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-archived={row.archived}>
|
||||
<Table.Cell>
|
||||
<a href={row.detailHref} className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default">
|
||||
{row.name}
|
||||
</a>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{row.entryCount}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{row.accessCount}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<BadgeFeedback farbe={row.archived ? "subtle-neutral" : "subtle-positive"} size="small">
|
||||
{row.archived ? t("hr.admin.passwordSafe.status.archived") : t("hr.admin.passwordSafe.status.active")}
|
||||
</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{!row.archived ? (
|
||||
<PageShell uiId="ui.hr.admin.passwordSafe">
|
||||
<PageHeader
|
||||
icon={<FeatherLock className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.admin.passwordSafe.title")}
|
||||
subtitle={t("hr.admin.passwordSafe.subtitle")}
|
||||
subtitleTone="secondary"
|
||||
/>
|
||||
{/* --- Filter bar: the same shared strip the vault list wears, so both
|
||||
password screens filter alike. No facets - the admin table is narrowed
|
||||
by name, not by category. --- */}
|
||||
<FacetFilterBar
|
||||
uiId="ui.hr.admin.passwordSafe.filter"
|
||||
facets={[]}
|
||||
onToggle={() => undefined}
|
||||
search={query}
|
||||
onSearchChange={setQuery}
|
||||
searchPlaceholder={t("hr.passwordSafe.searchPlaceholder")}
|
||||
onReset={() => {
|
||||
setQuery("");
|
||||
actions.onSearch("");
|
||||
}}
|
||||
labels={{ reset: t("hr.passwordSafe.filter.reset"), removeChip: t("hr.passwordSafe.filter.removeChip") }}
|
||||
/>
|
||||
<PageBody>
|
||||
{actionFeedback ? (
|
||||
<Alert
|
||||
variant={actionFeedback.status}
|
||||
notDismissible
|
||||
title={t(actionFeedback.messageKey)}
|
||||
data-ui-id={`ui.hr.admin.passwordSafe.feedback.${actionFeedback.status}`}
|
||||
/>
|
||||
) : null}
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.admin.passwordSafe.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.admin.passwordSafe.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.name")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.entries")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.access")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.admin.passwordSafe.column.status")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{rows.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-archived={row.archived}>
|
||||
<Table.Cell>
|
||||
{row.archived || !row.detailHref ? (
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">{row.name}</span>
|
||||
) : (
|
||||
<Link to={row.detailHref} className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default">
|
||||
{row.name}
|
||||
</Link>
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{row.entryCount}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{row.accessCount}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<BadgeFeedback farbe={row.archived ? "subtle-neutral" : "subtle-positive"} size="small">
|
||||
{row.archived ? t("hr.admin.passwordSafe.status.archived") : t("hr.admin.passwordSafe.status.active")}
|
||||
</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex justify-end">
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchiveVault(row.id)}>
|
||||
{t("hr.admin.passwordSafe.action.archive")}
|
||||
</Button>
|
||||
{row.archived ? (
|
||||
<Button icon={<FeatherRotateCcw />} variant="tertiary" size="small" loading={submitting} onClick={() => actions.onRestoreVault(row.id)}>
|
||||
{t("hr.admin.passwordSafe.action.restore")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button icon={<FeatherArchive />} variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchiveVault(row.id)}>
|
||||
{t("hr.admin.passwordSafe.action.archive")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
<section className="flex w-full flex-col gap-3" data-ui-id="ui.hr.admin.passwordSafe.activities">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.passwordSafe.tabs.activities")}</h2>
|
||||
{activityRows.length === 0 ? (
|
||||
<EmptyState title={t("hr.passwordSafe.activity.emptyTitle")} body={t("hr.passwordSafe.activity.emptyBody")} />
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
{activityRows.map((activity) => (
|
||||
<div key={activity.id} className="border-border-default flex flex-wrap items-center justify-between gap-2 rounded-md border p-3">
|
||||
<span className="text-body-default-medium-0 text-text-neutral-primary">{t(activity.actionLabelKey)}</span>
|
||||
<span className="text-body-small-regular-0 text-text-neutral-secondary">
|
||||
{activity.actorLabel} · {activity.createdAtLabel}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+69
-22
@@ -6,12 +6,13 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type PayslipPreviewRow = {
|
||||
@@ -26,16 +27,26 @@ export type PayslipPreviewRow = {
|
||||
|
||||
export type PayslipAdminRow = { id: string; employeeLabel: string; periodLabel: string; isRead: boolean };
|
||||
|
||||
export type PayslipMemberOption = {
|
||||
userId: string;
|
||||
displayName: string;
|
||||
team: string | null;
|
||||
roleNames: readonly string[];
|
||||
};
|
||||
|
||||
export type HrAdminPayslipsActions = {
|
||||
onMatch: (input: { periodYear: string; periodMonth: string; files: string }) => void;
|
||||
onConfirm: (input: { fileId: string; employeeUserId: string; periodYear: string; periodMonth: string }) => void;
|
||||
onMatch: (input: { periodYear: string; periodMonth: string; files: readonly File[] }) => void;
|
||||
onConfirm: (input: { file: File; employeeUserId: string; periodYear: string; periodMonth: string }) => void;
|
||||
};
|
||||
|
||||
export type HrAdminPayslipsPageProps = {
|
||||
rows: readonly PayslipAdminRow[];
|
||||
preview: readonly PayslipPreviewRow[];
|
||||
memberOptions: readonly PayslipMemberOption[];
|
||||
period: { year: string; month: string };
|
||||
submitting: boolean;
|
||||
errorKey: string | null;
|
||||
feedbackKey: string | null;
|
||||
actions: HrAdminPayslipsActions;
|
||||
};
|
||||
|
||||
@@ -45,11 +56,12 @@ function toneFarbe(tone: string): "subtle-positive" | "subtle-warning" | "subtle
|
||||
return "subtle-neutral";
|
||||
}
|
||||
|
||||
export function HrAdminPayslipsPage({ rows, preview, period, submitting, actions }: HrAdminPayslipsPageProps) {
|
||||
export function HrAdminPayslipsPage({ rows, preview, memberOptions, period, submitting, errorKey, feedbackKey, actions }: HrAdminPayslipsPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [year, setYear] = useState("");
|
||||
const [month, setMonth] = useState("");
|
||||
const [files, setFiles] = useState("");
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
const [matchedFiles, setMatchedFiles] = useState<File[]>([]);
|
||||
const [assignees, setAssignees] = useState<Record<string, string>>({});
|
||||
|
||||
return (
|
||||
@@ -70,15 +82,38 @@ export function HrAdminPayslipsPage({ rows, preview, period, submitting, actions
|
||||
<TextInput.Input type="number" value={month} onChange={(e) => setMonth(e.target.value)} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextArea label={t("hr.payslips.field.filesHint")} showLabel className="w-full">
|
||||
<TextArea.Input value={files} onChange={(e) => setFiles(e.target.value)} />
|
||||
</TextArea>
|
||||
<label className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("hr.payslips.field.filesHint")}</span>
|
||||
<input
|
||||
type="file"
|
||||
accept="application/pdf,.pdf"
|
||||
multiple
|
||||
onChange={(event) => setFiles(Array.from(event.target.files ?? []))}
|
||||
className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary file:mr-3 file:rounded-[4px] file:border file:border-solid file:border-border-default file:bg-transparent file:px-3 file:py-1.5 file:text-text-neutral-primary"
|
||||
data-ui-id="ui.hr.admin.payslips.files"
|
||||
/>
|
||||
</label>
|
||||
{files.length > 0 ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary" data-ui-id="ui.hr.admin.payslips.files.selected">
|
||||
{t("hr.payslips.upload.selected", { count: files.length })}
|
||||
</span>
|
||||
) : null}
|
||||
{errorKey ? <Alert variant="error" description={t(errorKey)} notDismissible data-ui-id="ui.hr.admin.payslips.error" /> : null}
|
||||
{submitting ? (
|
||||
<Alert variant="information" description={t("hr.payslips.upload.checking")} notDismissible data-ui-id="ui.hr.admin.payslips.loading" />
|
||||
) : null}
|
||||
{!submitting && feedbackKey ? (
|
||||
<Alert variant="success" description={t(feedbackKey)} notDismissible data-ui-id="ui.hr.admin.payslips.success" />
|
||||
) : null}
|
||||
<div className="flex justify-end">
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={submitting}
|
||||
disabled={!year.trim() || !month.trim() || !files.trim()}
|
||||
onClick={() => actions.onMatch({ periodYear: year, periodMonth: month, files })}
|
||||
disabled={!year.trim() || !month.trim() || files.length === 0}
|
||||
onClick={() => {
|
||||
setMatchedFiles(files);
|
||||
actions.onMatch({ periodYear: year, periodMonth: month, files });
|
||||
}}
|
||||
data-ui-id="ui.hr.admin.payslips.match.submit"
|
||||
>
|
||||
{t("hr.payslips.action.match")}
|
||||
@@ -91,7 +126,7 @@ export function HrAdminPayslipsPage({ rows, preview, period, submitting, actions
|
||||
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.admin.payslips.preview">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("hr.payslips.match.title")}</span>
|
||||
{preview.map((row) => (
|
||||
<Card key={row.fileId} data-row-id={row.fileId} data-confidence={row.confidence}>
|
||||
<Card key={row.fileId} data-confidence={row.confidence}>
|
||||
<div className="flex w-full flex-col gap-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.fileName}</span>
|
||||
@@ -99,23 +134,35 @@ export function HrAdminPayslipsPage({ rows, preview, period, submitting, actions
|
||||
{t(row.confidenceKey)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<div className="flex items-end gap-2">
|
||||
<TextInput label={t("hr.payslips.field.employee")} showLabel fillContainer className="max-w-none">
|
||||
<TextInput.Input
|
||||
value={assignees[row.fileId] ?? row.employeeUserId ?? ""}
|
||||
onChange={(e) => setAssignees((s) => ({ ...s, [row.fileId]: e.target.value }))}
|
||||
/>
|
||||
</TextInput>
|
||||
<div className="flex items-end gap-2 mobile:flex-col mobile:items-stretch">
|
||||
<Select
|
||||
label={t("hr.payslips.field.employee")}
|
||||
showLabel
|
||||
triggerAriaLabel={t("hr.payslips.field.employee")}
|
||||
value={assignees[row.fileId] ?? row.employeeUserId ?? undefined}
|
||||
placeholder={t("hr.payslips.field.employeePlaceholder")}
|
||||
onValueChange={(employeeUserId: string) => setAssignees((current) => ({ ...current, [row.fileId]: employeeUserId }))}
|
||||
className="max-w-none grow"
|
||||
>
|
||||
{memberOptions.map((member) => (
|
||||
<Select.Item key={member.userId} value={member.userId}>
|
||||
{member.displayName} · {member.team ?? t("hr.picker.noTeam")} · {member.roleNames.join(", ") || t("hr.picker.noRole")}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Button
|
||||
loading={submitting}
|
||||
onClick={() =>
|
||||
disabled={!(assignees[row.fileId] ?? row.employeeUserId) || !matchedFiles[Number(row.fileId)]}
|
||||
onClick={() => {
|
||||
const file = matchedFiles[Number(row.fileId)];
|
||||
if (!file) return;
|
||||
actions.onConfirm({
|
||||
fileId: row.fileId,
|
||||
file,
|
||||
employeeUserId: assignees[row.fileId] ?? row.employeeUserId ?? "",
|
||||
periodYear: period.year,
|
||||
periodMonth: period.month,
|
||||
})
|
||||
}
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("hr.payslips.action.assign")}
|
||||
</Button>
|
||||
|
||||
+65
-9
@@ -16,29 +16,46 @@ import { Select } from "~/ui/components/Select";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type HrAdminRequestTemplatesActions = {
|
||||
onCreate: (input: { requestKind: string; defaultApproverUserId: string; title: string; description: string }) => void;
|
||||
onCreate: (input: { requestKind: string; defaultApproverUserId: string; title: string; description: string; linkedFormId: string }) => void;
|
||||
onToggle: (templateId: string, isActive: boolean) => void;
|
||||
onArchive: (templateId: string) => void;
|
||||
};
|
||||
|
||||
/** Select sentinel — ~/ui Select items need a non-empty value. */
|
||||
const NO_LINKED_FORM = "__none__";
|
||||
const NO_APPROVER = "__none__";
|
||||
|
||||
export type HrAdminMemberOption = {
|
||||
userId: string;
|
||||
displayName: string;
|
||||
team: string | null;
|
||||
roleNames: readonly string[];
|
||||
};
|
||||
|
||||
export type HrAdminRequestTemplatesPageProps = {
|
||||
vm: HrRequestTemplateListVM;
|
||||
kinds: readonly HrRequestKind[];
|
||||
memberOptions: readonly HrAdminMemberOption[];
|
||||
submitting: boolean;
|
||||
actions: HrAdminRequestTemplatesActions;
|
||||
};
|
||||
|
||||
export function HrAdminRequestTemplatesPage({ vm, kinds, submitting, actions }: HrAdminRequestTemplatesPageProps) {
|
||||
export function HrAdminRequestTemplatesPage({ vm, kinds, memberOptions, submitting, actions }: HrAdminRequestTemplatesPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [form, setForm] = useState({ requestKind: kinds[0] ?? "expense", defaultApproverUserId: "", title: "", description: "" });
|
||||
const [form, setForm] = useState({ requestKind: kinds[0] ?? "expense", defaultApproverUserId: NO_APPROVER, title: "", description: "", linkedFormId: NO_LINKED_FORM });
|
||||
const rows = vm.data?.rows ?? [];
|
||||
const linkableForms = vm.data?.linkableForms ?? [];
|
||||
|
||||
function submit() {
|
||||
if (!form.title.trim()) return;
|
||||
actions.onCreate(form);
|
||||
actions.onCreate({
|
||||
...form,
|
||||
defaultApproverUserId: form.defaultApproverUserId === NO_APPROVER ? "" : form.defaultApproverUserId,
|
||||
linkedFormId: form.linkedFormId === NO_LINKED_FORM ? "" : form.linkedFormId,
|
||||
});
|
||||
setOpen(false);
|
||||
setForm({ requestKind: kinds[0] ?? "expense", defaultApproverUserId: "", title: "", description: "" });
|
||||
setForm({ requestKind: kinds[0] ?? "expense", defaultApproverUserId: NO_APPROVER, title: "", description: "", linkedFormId: NO_LINKED_FORM });
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -72,6 +89,11 @@ export function HrAdminRequestTemplatesPage({ vm, kinds, submitting, actions }:
|
||||
{t("hr.requests.templates.inactive")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
{row.linkedFormLabel ? (
|
||||
<BadgeFeedback farbe="subtle-positive" size="small" data-ui-id="ui.hr.admin.requestTemplates.linkedForm">
|
||||
{t("hr.requests.templates.linkedForm", { name: row.linkedFormLabel })}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onToggle(row.id, !row.isActive)}>
|
||||
@@ -92,7 +114,13 @@ export function HrAdminRequestTemplatesPage({ vm, kinds, submitting, actions }:
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.requests.templates.action.create")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<Select label={t("hr.requests.field.kind")} showLabel value={form.requestKind} onValueChange={(v: string) => setForm((s) => ({ ...s, requestKind: v as HrRequestKind }))}>
|
||||
<Select
|
||||
label={t("hr.requests.field.kind")}
|
||||
showLabel
|
||||
triggerAriaLabel={t("hr.requests.field.kind")}
|
||||
value={form.requestKind}
|
||||
onValueChange={(v: string) => setForm((s) => ({ ...s, requestKind: v as HrRequestKind }))}
|
||||
>
|
||||
{kinds.map((kind) => (
|
||||
<Select.Item key={kind} value={kind}>
|
||||
{t(`hr.requests.kind.${kind}`)}
|
||||
@@ -105,9 +133,37 @@ export function HrAdminRequestTemplatesPage({ vm, kinds, submitting, actions }:
|
||||
<TextInput label={t("hr.requests.field.description")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.description} onChange={(e) => setForm((s) => ({ ...s, description: e.target.value }))} />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.requests.field.approver")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.defaultApproverUserId} onChange={(e) => setForm((s) => ({ ...s, defaultApproverUserId: e.target.value }))} />
|
||||
</TextInput>
|
||||
<Select
|
||||
label={t("hr.requests.field.approver")}
|
||||
showLabel
|
||||
triggerAriaLabel={t("hr.requests.field.approver")}
|
||||
value={form.defaultApproverUserId}
|
||||
onValueChange={(defaultApproverUserId: string) => setForm((current) => ({ ...current, defaultApproverUserId }))}
|
||||
>
|
||||
<Select.Item value={NO_APPROVER}>{t("hr.picker.noApprover")}</Select.Item>
|
||||
{memberOptions.map((member) => (
|
||||
<Select.Item key={member.userId} value={member.userId}>
|
||||
{member.displayName} · {member.team ?? t("hr.picker.noTeam")} · {member.roleNames.join(", ") || t("hr.picker.noRole")}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
{linkableForms.length > 0 ? (
|
||||
<Select
|
||||
label={t("hr.requests.field.linkedForm")}
|
||||
showLabel
|
||||
triggerAriaLabel={t("hr.requests.field.linkedForm")}
|
||||
value={form.linkedFormId}
|
||||
onValueChange={(v: string) => setForm((s) => ({ ...s, linkedFormId: v }))}
|
||||
data-ui-id="ui.hr.admin.requestTemplates.new.linkedForm"
|
||||
>
|
||||
<Select.Item value={NO_LINKED_FORM}>{t("hr.requests.field.noLinkedForm")}</Select.Item>
|
||||
{linkableForms.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setOpen(false)}>
|
||||
|
||||
+64
-53
@@ -3,13 +3,15 @@
|
||||
// unread filter. Final Subframe optics = tracked design-nachzug.
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPin } from "@subframe/core";
|
||||
import { FeatherMegaphone, FeatherPin } from "@subframe/core";
|
||||
import type { HrAnnouncementFeedVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { LinkButton } from "~/ui/components/LinkButton";
|
||||
import { Tabs } from "~/ui/components/Tabs";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
|
||||
export type HrAnnouncementsFeedPageProps = { vm: HrAnnouncementFeedVM };
|
||||
|
||||
@@ -17,64 +19,73 @@ export function HrAnnouncementsFeedPage({ vm }: HrAnnouncementsFeedPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const data = vm.data;
|
||||
if (vm.status !== "ready" || !data) {
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.announcements" />;
|
||||
return (
|
||||
<PageShell uiId="ui.hr.announcements">
|
||||
<PageHeader
|
||||
icon={<FeatherMegaphone className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.announcements.title")}
|
||||
subtitle={t("hr.announcements.subtitle")}
|
||||
/>
|
||||
<PageBody>{null}</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.announcements">
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.announcements.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.announcements.subtitle")}
|
||||
</span>
|
||||
<PageShell uiId="ui.hr.announcements">
|
||||
<PageHeader
|
||||
icon={<FeatherMegaphone className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.announcements.title")}
|
||||
subtitle={t("hr.announcements.subtitle")}
|
||||
actions={
|
||||
data.canManage ? (
|
||||
<AppLink href={data.manageHref} className="contents no-underline" data-ui-id="ui.hr.announcements.manage">
|
||||
<LinkButton variant="subtle">{t("hr.announcements.action.manage")}</LinkButton>
|
||||
</AppLink>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
<div data-ui-id="ui.hr.announcements.filter">
|
||||
<Tabs>
|
||||
<AppLink href="?" className="contents no-underline">
|
||||
<Tabs.Item active={!data.unreadOnly}>{t("hr.announcements.filter.all")}</Tabs.Item>
|
||||
</AppLink>
|
||||
<AppLink href="?unread=1" className="contents no-underline">
|
||||
<Tabs.Item active={data.unreadOnly}>{t("hr.announcements.filter.unread")}</Tabs.Item>
|
||||
</AppLink>
|
||||
</Tabs>
|
||||
</div>
|
||||
{data.canManage ? (
|
||||
<a href={data.manageHref} className="contents no-underline" data-ui-id="ui.hr.announcements.manage">
|
||||
<LinkButton variant="subtle">{t("hr.announcements.action.manage")}</LinkButton>
|
||||
</a>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div data-ui-id="ui.hr.announcements.filter">
|
||||
<Tabs>
|
||||
<a href="?" className="contents no-underline">
|
||||
<Tabs.Item active={!data.unreadOnly}>{t("hr.announcements.filter.all")}</Tabs.Item>
|
||||
</a>
|
||||
<a href="?unread=1" className="contents no-underline">
|
||||
<Tabs.Item active={data.unreadOnly}>{t("hr.announcements.filter.unread")}</Tabs.Item>
|
||||
</a>
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
{data.rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.announcements.empty">
|
||||
<EmptyState title={t("hr.announcements.empty.headline")} body={t("hr.announcements.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.announcements.list">
|
||||
{data.rows.map((row) => (
|
||||
<a key={row.id} href={row.detailHref} className="no-underline" data-row-id={row.id} data-pinned={row.pinned} data-read={row.isRead}>
|
||||
<Card>
|
||||
<div className="flex w-full flex-col gap-1">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-2">
|
||||
{row.pinned ? <FeatherPin className="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary" /> : null}
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
|
||||
{data.rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.announcements.empty">
|
||||
<EmptyState title={t("hr.announcements.empty.headline")} body={t("hr.announcements.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.announcements.list">
|
||||
{data.rows.map((row) => (
|
||||
<AppLink key={row.id} href={row.detailHref} className="no-underline" data-row-id={row.id} data-pinned={row.pinned} data-read={row.isRead}>
|
||||
<Card>
|
||||
<div className="flex w-full flex-col gap-1">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="flex items-center gap-2">
|
||||
{row.pinned ? <FeatherPin className="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary" /> : null}
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
|
||||
</div>
|
||||
{row.requiresAcknowledgement && !row.isAcknowledged ? (
|
||||
<BadgeFeedback farbe="subtle-warning" size="small">
|
||||
{t("hr.announcements.ackRequired")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
{row.requiresAcknowledgement && !row.isAcknowledged ? (
|
||||
<BadgeFeedback farbe="subtle-warning" size="small">
|
||||
{t("hr.announcements.ackRequired")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
<span className="line-clamp-2 text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{row.snippet}</span>
|
||||
</div>
|
||||
<span className="line-clamp-2 text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{row.snippet}</span>
|
||||
</div>
|
||||
</Card>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
</AppLink>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+4
-20
@@ -1,13 +1,12 @@
|
||||
// AK-P17a Interim-UI (AD-28) — employee detail screen composed from ~/ui (D-HR
|
||||
// "MA-Detail", archetype A3). Pure presentational: master data, inline self-edit
|
||||
// of the self-editable fields (position/team), and an ON-DEMAND emergency-contact
|
||||
// of the self-editable position, and an ON-DEMAND emergency-contact
|
||||
// reveal (self or hr.read_all only, audited server-side). The route owns the
|
||||
// fetchers and injects callbacks + revealed data; this screen never fetches.
|
||||
// Final Subframe optics = tracked design-nachzug.
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
@@ -18,7 +17,7 @@ export type RevealedEmergencyContact = { name: string; phone: string; relation:
|
||||
|
||||
export type HrDirectoryDetailActions = {
|
||||
/** POSTs intent=update-own-profile with the self-editable fields. */
|
||||
onSaveProfile: (input: { position: string; team: string }) => void;
|
||||
onSaveProfile: (input: { position: string }) => void;
|
||||
/** POSTs intent=reveal-emergency (audited). */
|
||||
onRevealEmergency: () => void;
|
||||
/** POSTs intent=set-emergency; stores the envelope-encrypted contact. */
|
||||
@@ -54,7 +53,6 @@ function DataRow({ label, value }: { label: string; value: string }) {
|
||||
}
|
||||
|
||||
export function HrDirectoryDetailPage({
|
||||
backHref,
|
||||
name,
|
||||
email,
|
||||
position,
|
||||
@@ -71,7 +69,6 @@ export function HrDirectoryDetailPage({
|
||||
}: HrDirectoryDetailPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [positionDraft, setPositionDraft] = useState(position ?? "");
|
||||
const [teamDraft, setTeamDraft] = useState(team ?? "");
|
||||
const [emergencyOpen, setEmergencyOpen] = useState(false);
|
||||
const [emergencyDraft, setEmergencyDraft] = useState<RevealedEmergencyContact>({ name: "", phone: "", relation: "" });
|
||||
|
||||
@@ -88,13 +85,6 @@ export function HrDirectoryDetailPage({
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.directory.detail">
|
||||
<Breadcrumbs>
|
||||
<a href={backHref} className="contents no-underline" data-ui-id="ui.hr.directory.detail.back">
|
||||
<Breadcrumbs.Item>{t("hr.directory.detail.back")}</Breadcrumbs.Item>
|
||||
</a>
|
||||
<Breadcrumbs.Divider />
|
||||
<Breadcrumbs.Item active>{name}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{name}</span>
|
||||
@@ -114,17 +104,11 @@ export function HrDirectoryDetailPage({
|
||||
data-ui-id="ui.hr.directory.detail.position"
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.directory.column.team")} showLabel fillContainer>
|
||||
<TextInput.Input
|
||||
value={teamDraft}
|
||||
onChange={(event) => setTeamDraft(event.target.value)}
|
||||
data-ui-id="ui.hr.directory.detail.team"
|
||||
/>
|
||||
</TextInput>
|
||||
<DataRow label={t("hr.directory.column.team")} value={team ?? "—"} />
|
||||
<div className="flex justify-end">
|
||||
<Button
|
||||
loading={saving}
|
||||
onClick={() => actions.onSaveProfile({ position: positionDraft, team: teamDraft })}
|
||||
onClick={() => actions.onSaveProfile({ position: positionDraft })}
|
||||
data-ui-id="ui.hr.directory.detail.save"
|
||||
>
|
||||
{t("hr.directory.detail.save")}
|
||||
|
||||
+80
-69
@@ -6,8 +6,10 @@
|
||||
// tracked design-nachzug.
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherMail } from "@subframe/core";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
import { FeatherMail, FeatherUser } from "@subframe/core";
|
||||
import type { HrDirectoryVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { Avatar } from "~/ui/components/Avatar";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { IconButton } from "~/ui/components/IconButton";
|
||||
@@ -28,78 +30,87 @@ export function HrDirectoryPage({ vm }: HrDirectoryPageProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.directory" />;
|
||||
return (
|
||||
<PageShell uiId="ui.hr.directory">
|
||||
<PageHeader
|
||||
icon={<FeatherUser className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.directory.title")}
|
||||
subtitle={t("hr.directory.subtitle")}
|
||||
/>
|
||||
<PageBody>{null}</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
const { rows, emptyHeadlineKey, emptyBodyKey } = vm.data;
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.directory">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.directory.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.directory.subtitle")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.directory.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.directory.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.directory.column.name")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.directory.column.position")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.directory.column.team")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.directory.column.location")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{rows.map((row) => (
|
||||
<Table.Row key={row.userId} data-row-id={row.userId}>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center gap-3">
|
||||
<Avatar size="small">{initials(row.name)}</Avatar>
|
||||
<a
|
||||
href={row.detailHref}
|
||||
className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default"
|
||||
>
|
||||
{row.name}
|
||||
</a>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.position ?? "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.team ?? "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.locationName ?? "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{row.email ? (
|
||||
<a href={`mailto:${row.email}`} className="contents no-underline" aria-label={t("hr.directory.action.mail")}>
|
||||
<IconButton size="small" icon={<FeatherMail />} />
|
||||
</a>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<PageShell uiId="ui.hr.directory">
|
||||
<PageHeader
|
||||
icon={<FeatherUser className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.directory.title")}
|
||||
subtitle={t("hr.directory.subtitle")}
|
||||
/>
|
||||
<PageBody>
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.directory.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.directory.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.directory.column.name")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.directory.column.position")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.directory.column.team")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.directory.column.location")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{rows.map((row) => (
|
||||
<Table.Row key={row.userId} data-row-id={row.userId}>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center gap-3">
|
||||
<Avatar size="small">{initials(row.name)}</Avatar>
|
||||
<AppLink
|
||||
href={row.detailHref}
|
||||
className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default"
|
||||
>
|
||||
{row.name}
|
||||
</AppLink>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.position ?? "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.team ?? "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.locationName ?? "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{row.email ? (
|
||||
<a href={`mailto:${row.email}`} className="contents no-underline" aria-label={t("hr.directory.action.mail")}>
|
||||
<IconButton size="small" icon={<FeatherMail />} />
|
||||
</a>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+108
@@ -0,0 +1,108 @@
|
||||
import "@testing-library/jest-dom";
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { buildHrHubVM, type HrHubHrefs } from "@hivegrid/view-models";
|
||||
|
||||
import { HrHubPage } from "./HrHubPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: { count?: number }) =>
|
||||
values?.count === undefined ? key : `${key}:${values.count}`,
|
||||
}),
|
||||
}));
|
||||
|
||||
const ids = [
|
||||
"leave",
|
||||
"sick",
|
||||
"documents",
|
||||
"payslips",
|
||||
"announcements",
|
||||
"requests",
|
||||
"surveys",
|
||||
"teamDirectory",
|
||||
"teamLeave",
|
||||
"leaveApprovals",
|
||||
"requestApprovals",
|
||||
"directory",
|
||||
"locations",
|
||||
"announcementAdmin",
|
||||
"payslipAdmin",
|
||||
"requestTemplates",
|
||||
"uploadReminders",
|
||||
"surveyAdmin",
|
||||
] as const;
|
||||
const hrefs = Object.fromEntries(ids.map((id) => [id, `/acme/hr/${id}`])) as HrHubHrefs;
|
||||
|
||||
function vm(capabilities = {
|
||||
canReadAll: false,
|
||||
canWrite: false,
|
||||
canApproveLeave: false,
|
||||
canViewSurveyResults: false,
|
||||
}) {
|
||||
return buildHrHubVM({
|
||||
moduleActive: true,
|
||||
hrefs,
|
||||
counts: {
|
||||
ownLeave: 1,
|
||||
ownSick: 0,
|
||||
ownRequests: 1,
|
||||
pendingLeaveApprovals: 0,
|
||||
pendingRequestApprovals: 0,
|
||||
visibleTeamMembers: 0,
|
||||
},
|
||||
capabilities,
|
||||
});
|
||||
}
|
||||
|
||||
describe("HrHubPage interim UI", () => {
|
||||
it("renders priority and employee sections from the VM without admin leakage", () => {
|
||||
const { container } = render(<HrHubPage vm={vm()} />);
|
||||
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.hub.priority"]')).toBeInTheDocument();
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.hub.section.forMe"]')).toBeInTheDocument();
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.hub.section.myTeam"]')).not.toBeInTheDocument();
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.hub.section.administration"]')).not.toBeInTheDocument();
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.hub.item.sick"]')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders the administration section only when the VM contains it", () => {
|
||||
const { container } = render(
|
||||
<HrHubPage
|
||||
vm={vm({
|
||||
canReadAll: true,
|
||||
canWrite: true,
|
||||
canApproveLeave: true,
|
||||
canViewSurveyResults: true,
|
||||
})}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.hub.section.administration"]')).toBeInTheDocument();
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.hub.item.payslipAdmin"]')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders a clear locked state for a disabled module", () => {
|
||||
const locked = buildHrHubVM({
|
||||
moduleActive: false,
|
||||
hrefs,
|
||||
counts: {
|
||||
ownLeave: 0,
|
||||
ownSick: 0,
|
||||
ownRequests: 0,
|
||||
pendingLeaveApprovals: 0,
|
||||
pendingRequestApprovals: 0,
|
||||
visibleTeamMembers: 0,
|
||||
},
|
||||
capabilities: {
|
||||
canReadAll: false,
|
||||
canWrite: false,
|
||||
canApproveLeave: false,
|
||||
canViewSurveyResults: false,
|
||||
},
|
||||
});
|
||||
const { container } = render(<HrHubPage vm={locked} />);
|
||||
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.hub.locked"]')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+178
-55
@@ -1,74 +1,197 @@
|
||||
// AK-P17a Interim-UI (AD-28) — HR hub launchpad composed from ~/ui (D-HR
|
||||
// "HR-Hub-Start", archetype A1/A6). Pure presentational: the loader gates the
|
||||
// connector + permission and passes the resolved quick-link list in as a prop;
|
||||
// this screen only renders. The richer hub widgets (announcements, pending
|
||||
// duties, birthdays) arrive with their data in follow-up tickets; the interim
|
||||
// screen renders exactly what the loader provides. Final Subframe optics = a
|
||||
// tracked design-nachzug once David's D-HR delta ships.
|
||||
// R-UX3 Interim-UI (AD-28) — task-oriented personnel hub composed from ~/ui.
|
||||
// Visibility, counts and allowed actions arrive in the VM; this component has
|
||||
// no role names, permissions or client-side data filtering.
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherArrowRight, FeatherLock } from "@subframe/core";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
import {
|
||||
FeatherArrowRight,
|
||||
FeatherBell,
|
||||
FeatherBriefcase,
|
||||
FeatherClipboard,
|
||||
FeatherLock,
|
||||
FeatherUser,
|
||||
} from "@subframe/core";
|
||||
import type { HrHubItem, HrHubSection, HrHubVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "../shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
|
||||
export type HrHubLink = {
|
||||
/** i18n key for the link label (e.g. "hr.nav.directory"). */
|
||||
readonly labelKey: string;
|
||||
readonly href: string;
|
||||
};
|
||||
|
||||
export type HrHubPageProps = {
|
||||
/** False when the tenant has the HR module gated off (locked state). */
|
||||
moduleActive: boolean;
|
||||
links: readonly HrHubLink[];
|
||||
vm: HrHubVM;
|
||||
};
|
||||
|
||||
export function HrHubPage({ moduleActive, links }: HrHubPageProps) {
|
||||
function TaskCount({ count }: { count: number }) {
|
||||
const { t } = useTranslation();
|
||||
if (count <= 0) return null;
|
||||
return (
|
||||
<BadgeFeedback farbe="subtle-warning" size="small">
|
||||
{t("hr.hub.openCount", { count })}
|
||||
</BadgeFeedback>
|
||||
);
|
||||
}
|
||||
|
||||
if (!moduleActive) {
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.hub">
|
||||
<div className="flex items-center gap-2 text-text-neutral-tertiary" data-ui-id="ui.hr.hub.locked">
|
||||
<FeatherLock className="text-heading-3 font-heading-3" />
|
||||
<EmptyState title={t("hr.hub.locked.headline")} body={t("hr.hub.locked.body")} />
|
||||
function HubItemCard({ item, priority = false }: { item: HrHubItem; priority?: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<AppLink
|
||||
href={item.href}
|
||||
className="group/item min-w-0 no-underline"
|
||||
data-row-id={item.id}
|
||||
data-ui-id={`ui.hr.hub.item.${item.id}`}
|
||||
>
|
||||
<Card>
|
||||
<div
|
||||
className={
|
||||
priority
|
||||
? "flex min-h-28 w-full items-start justify-between gap-4"
|
||||
: "flex min-h-24 w-full items-start justify-between gap-4"
|
||||
}
|
||||
>
|
||||
<div className="flex min-w-0 grow flex-col gap-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-body-large-medium-0 font-body-large-medium-0 text-text-neutral-primary">
|
||||
{t(item.labelKey)}
|
||||
</span>
|
||||
<TaskCount count={item.count} />
|
||||
</div>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
{t(item.descriptionKey)}
|
||||
</span>
|
||||
</div>
|
||||
<FeatherArrowRight
|
||||
aria-hidden="true"
|
||||
className="mt-1 shrink-0 text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary transition-transform group-hover/item:translate-x-0.5"
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</AppLink>
|
||||
);
|
||||
}
|
||||
|
||||
function HubSectionView({
|
||||
section,
|
||||
icon,
|
||||
}: {
|
||||
section: HrHubSection;
|
||||
icon: ReactNode;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
if (!section.visible) return null;
|
||||
return (
|
||||
<section
|
||||
className="flex w-full flex-col gap-4"
|
||||
aria-labelledby={`hr-hub-${section.id}`}
|
||||
data-ui-id={`ui.hr.hub.section.${section.id}`}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<span className="mt-0.5 text-heading-3 font-heading-3 text-icon-brand-primary">
|
||||
{icon}
|
||||
</span>
|
||||
<div className="flex min-w-0 grow flex-col gap-1">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<h2
|
||||
id={`hr-hub-${section.id}`}
|
||||
className="text-heading-3 font-heading-3 text-text-neutral-primary"
|
||||
>
|
||||
{t(section.labelKey)}
|
||||
</h2>
|
||||
<TaskCount count={section.count} />
|
||||
</div>
|
||||
<p className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
{t(section.descriptionKey)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3">
|
||||
{section.items.map((item) => (
|
||||
<HubItemCard key={item.id} item={item} />
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function HrHubPage({ vm }: HrHubPageProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
if (!vm.moduleActive) {
|
||||
return (
|
||||
<PageShell uiId="ui.hr.hub">
|
||||
<PageHeader
|
||||
icon={<FeatherUser className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.hub.title")}
|
||||
subtitle={t("hr.hub.subtitle")}
|
||||
/>
|
||||
<PageBody>
|
||||
<div className="flex items-center gap-2 text-text-neutral-tertiary" data-ui-id="ui.hr.hub.locked">
|
||||
<FeatherLock className="text-heading-3 font-heading-3" />
|
||||
<EmptyState
|
||||
title={t("hr.hub.locked.headline")}
|
||||
body={t("hr.hub.locked.body")}
|
||||
/>
|
||||
</div>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.hub">
|
||||
{/* Header: title + description (0px rhythm) */}
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.hub.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.hub.subtitle")}
|
||||
</span>
|
||||
</div>
|
||||
<PageShell uiId="ui.hr.hub">
|
||||
<PageHeader
|
||||
icon={<FeatherUser className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.hub.title")}
|
||||
subtitle={t("hr.hub.subtitle")}
|
||||
actions={<TaskCount count={vm.openTaskCount} />}
|
||||
/>
|
||||
<PageBody>
|
||||
<section
|
||||
className="flex w-full flex-col gap-4"
|
||||
aria-labelledby="hr-hub-priority"
|
||||
data-ui-id="ui.hr.hub.priority"
|
||||
>
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2
|
||||
id="hr-hub-priority"
|
||||
className="text-heading-3 font-heading-3 text-text-neutral-primary"
|
||||
>
|
||||
{t("hr.hub.priority.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
{t(
|
||||
vm.openTaskCount > 0
|
||||
? "hr.hub.priority.body"
|
||||
: "hr.hub.priority.emptyBody",
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
{vm.priorityActions.map((item) => (
|
||||
<HubItemCard key={item.id} item={item} priority />
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<nav
|
||||
className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"
|
||||
data-ui-id="ui.hr.hub.links"
|
||||
>
|
||||
{links.map((link) => (
|
||||
<a
|
||||
key={link.labelKey}
|
||||
href={link.href}
|
||||
className="no-underline"
|
||||
data-row-id={link.labelKey}
|
||||
>
|
||||
<Card>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t(link.labelKey)}
|
||||
</span>
|
||||
<FeatherArrowRight className="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary" />
|
||||
</div>
|
||||
</Card>
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
</div>
|
||||
<HubSectionView
|
||||
section={vm.forMe}
|
||||
icon={<FeatherClipboard aria-hidden="true" />}
|
||||
/>
|
||||
<HubSectionView
|
||||
section={vm.myTeam}
|
||||
icon={<FeatherBell aria-hidden="true" />}
|
||||
/>
|
||||
<HubSectionView
|
||||
section={vm.administration}
|
||||
icon={<FeatherBriefcase aria-hidden="true" />}
|
||||
/>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+93
-141
@@ -6,25 +6,29 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus } from "@subframe/core";
|
||||
import type { HrLeaveApproverVM, HrLeaveOwnVM, HrVacationRequestKind } from "@hivegrid/view-models";
|
||||
import { FeatherCalendar, FeatherPlus } from "@subframe/core";
|
||||
import type { HrLeaveApproverVM, HrLeaveOwnVM } from "@hivegrid/view-models";
|
||||
import type { FormDefinition } from "@hivegrid/form-widget";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Tabs } from "~/ui/components/Tabs";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { DateField } from "~/components/screens/tasks/DateField";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
import {
|
||||
InternalFormRenderer,
|
||||
type InternalFormValues,
|
||||
} from "~/modules/forms/internal/InternalFormRenderer";
|
||||
|
||||
export type HrLeaveTab = "own" | "approvals" | "team";
|
||||
export type HrLeaveTeamAbsence = { id: string; employeeLabel: string; source: string; kind: string; startIso: string; endIso: string };
|
||||
|
||||
export type HrLeaveActions = {
|
||||
onSubmit: (input: { requestKind: string; approverUserId: string; startDate: string; endDate: string; note: string }) => void;
|
||||
onSubmit: (values: InternalFormValues) => void;
|
||||
onWithdraw: (requestId: string) => void;
|
||||
onReply: (requestId: string, reply: string) => void;
|
||||
onApprove: (requestId: string) => void;
|
||||
@@ -38,7 +42,7 @@ export type HrLeavePageProps = {
|
||||
ownVm: HrLeaveOwnVM;
|
||||
approverVm: HrLeaveApproverVM;
|
||||
team: readonly HrLeaveTeamAbsence[];
|
||||
kinds: readonly HrVacationRequestKind[];
|
||||
formDefinition: FormDefinition;
|
||||
tabHref: (tab: HrLeaveTab) => string;
|
||||
submitting: boolean;
|
||||
actions: HrLeaveActions;
|
||||
@@ -50,156 +54,104 @@ type DialogState =
|
||||
| { type: "clarify"; requestId: string }
|
||||
| null;
|
||||
|
||||
export function HrLeavePage({ tab, canApprove, ownVm, approverVm, team, kinds, tabHref, submitting, actions }: HrLeavePageProps) {
|
||||
export function HrLeavePage({ tab, canApprove, ownVm, approverVm, team, formDefinition, tabHref, submitting, actions }: HrLeavePageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [dialog, setDialog] = useState<DialogState>(null);
|
||||
const [form, setForm] = useState({ requestKind: kinds[0] ?? "vacation", approverUserId: "", startDate: "", endDate: "", note: "" });
|
||||
const [text, setText] = useState("");
|
||||
|
||||
const tabs: HrLeaveTab[] = canApprove ? ["own", "approvals", "team"] : ["own", "team"];
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.leave">
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.leave.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.leave.subtitle")}
|
||||
</span>
|
||||
<PageShell uiId="ui.hr.leave">
|
||||
<PageHeader
|
||||
icon={<FeatherCalendar className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.leave.title")}
|
||||
subtitle={t("hr.leave.subtitle")}
|
||||
actions={
|
||||
tab === "own" && ownVm.data?.canCreate ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "new" })} data-ui-id="ui.hr.leave.new">
|
||||
{t("hr.leave.action.new")}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
<div data-ui-id="ui.hr.leave.tabs">
|
||||
<Tabs>
|
||||
{tabs.map((entry) => (
|
||||
<AppLink key={entry} href={tabHref(entry)} className="contents no-underline">
|
||||
<Tabs.Item active={tab === entry}>{t(`hr.leave.tab.${entry === "approvals" ? "approvals" : entry}`)}</Tabs.Item>
|
||||
</AppLink>
|
||||
))}
|
||||
</Tabs>
|
||||
</div>
|
||||
{tab === "own" && ownVm.data?.canCreate ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "new" })} data-ui-id="ui.hr.leave.new">
|
||||
{t("hr.leave.action.new")}
|
||||
</Button>
|
||||
|
||||
{tab === "own" ? (
|
||||
<OwnList vm={ownVm} submitting={submitting} onWithdraw={actions.onWithdraw} onReply={(id) => { setText(""); setDialog({ type: "reply", requestId: id }); }} />
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div data-ui-id="ui.hr.leave.tabs">
|
||||
<Tabs>
|
||||
{tabs.map((entry) => (
|
||||
<a key={entry} href={tabHref(entry)} className="contents no-underline">
|
||||
<Tabs.Item active={tab === entry}>{t(`hr.leave.tab.${entry === "approvals" ? "approvals" : entry}`)}</Tabs.Item>
|
||||
</a>
|
||||
))}
|
||||
</Tabs>
|
||||
</div>
|
||||
{tab === "approvals" ? (
|
||||
<ApproverList
|
||||
vm={approverVm}
|
||||
submitting={submitting}
|
||||
onApprove={actions.onApprove}
|
||||
onReject={actions.onReject}
|
||||
onClarify={(id) => { setText(""); setDialog({ type: "clarify", requestId: id }); }}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{tab === "own" ? (
|
||||
<OwnList vm={ownVm} submitting={submitting} onWithdraw={actions.onWithdraw} onReply={(id) => { setText(""); setDialog({ type: "reply", requestId: id }); }} />
|
||||
) : null}
|
||||
{tab === "team" ? <TeamList team={team} /> : null}
|
||||
|
||||
{tab === "approvals" ? (
|
||||
<ApproverList
|
||||
vm={approverVm}
|
||||
submitting={submitting}
|
||||
onApprove={actions.onApprove}
|
||||
onReject={actions.onReject}
|
||||
onClarify={(id) => { setText(""); setDialog({ type: "clarify", requestId: id }); }}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{tab === "team" ? <TeamList team={team} /> : null}
|
||||
|
||||
{/* New request dialog */}
|
||||
<Dialog open={dialog?.type === "new"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.leave.newDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.leave.action.new")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<Select
|
||||
label={t("hr.leave.field.kind")}
|
||||
showLabel
|
||||
value={form.requestKind}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, requestKind: value as HrVacationRequestKind }))}
|
||||
>
|
||||
{kinds.map((kind) => (
|
||||
<Select.Item key={kind} value={kind}>
|
||||
{t(`hr.leave.kind.${kind}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
<DateField label={t("hr.leave.field.start")} name="startDate" />
|
||||
<DateField label={t("hr.leave.field.end")} name="endDate" />
|
||||
</div>
|
||||
<TextInput label={t("hr.leave.field.approver")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.approverUserId} onChange={(e) => setForm((s) => ({ ...s, approverUserId: e.target.value }))} />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.leave.field.note")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.note} onChange={(e) => setForm((s) => ({ ...s, note: e.target.value }))} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setDialog(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<NewRequestSubmit form={form} submitting={submitting} onSubmit={actions.onSubmit} onDone={() => setDialog(null)} />
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
{/* Reply / clarify text dialog */}
|
||||
<Dialog open={dialog?.type === "reply" || dialog?.type === "clarify"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.leave.textDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{dialog?.type === "reply" ? t("hr.leave.action.reply") : t("hr.leave.action.clarify")}
|
||||
</span>
|
||||
<TextArea label={dialog?.type === "reply" ? t("hr.leave.field.reply") : t("hr.leave.field.question")} showLabel className="w-full">
|
||||
<TextArea.Input value={text} onChange={(e) => setText(e.target.value)} />
|
||||
</TextArea>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setDialog(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
disabled={text.trim().length === 0}
|
||||
onClick={() => {
|
||||
if (dialog?.type === "reply") actions.onReply(dialog.requestId, text);
|
||||
if (dialog?.type === "clarify") actions.onClarify(dialog.requestId, text);
|
||||
{/* New request dialog */}
|
||||
<Dialog open={dialog?.type === "new"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.leave.newDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.leave.action.new")}</span>
|
||||
<InternalFormRenderer
|
||||
definition={formDefinition}
|
||||
submitting={submitting}
|
||||
uiId="ui.hr.leave.m05"
|
||||
onCancel={() => setDialog(null)}
|
||||
onSubmit={(values) => {
|
||||
actions.onSubmit(values);
|
||||
setDialog(null);
|
||||
}}
|
||||
>
|
||||
{t("hr.action.confirm")}
|
||||
</Button>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
// The DateField uses native inputs (uncontrolled); read them from the dialog DOM on submit.
|
||||
function NewRequestSubmit({
|
||||
form,
|
||||
submitting,
|
||||
onSubmit,
|
||||
onDone,
|
||||
}: {
|
||||
form: { requestKind: string; approverUserId: string; note: string; startDate: string; endDate: string };
|
||||
submitting: boolean;
|
||||
onSubmit: HrLeaveActions["onSubmit"];
|
||||
onDone: () => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Button
|
||||
loading={submitting}
|
||||
onClick={(event) => {
|
||||
const dialogEl = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.leave.newDialog']");
|
||||
const start = dialogEl?.querySelector<HTMLInputElement>("input[name='startDate']")?.value ?? "";
|
||||
const end = dialogEl?.querySelector<HTMLInputElement>("input[name='endDate']")?.value ?? "";
|
||||
if (!start || !end) return;
|
||||
onSubmit({ requestKind: form.requestKind, approverUserId: form.approverUserId, startDate: start, endDate: end, note: form.note });
|
||||
onDone();
|
||||
}}
|
||||
data-ui-id="ui.hr.leave.newDialog.submit"
|
||||
>
|
||||
{t("hr.leave.action.submit")}
|
||||
</Button>
|
||||
{/* Reply / clarify text dialog */}
|
||||
<Dialog open={dialog?.type === "reply" || dialog?.type === "clarify"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.leave.textDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{dialog?.type === "reply" ? t("hr.leave.action.reply") : t("hr.leave.action.clarify")}
|
||||
</span>
|
||||
<TextArea label={dialog?.type === "reply" ? t("hr.leave.field.reply") : t("hr.leave.field.question")} showLabel className="w-full">
|
||||
<TextArea.Input value={text} onChange={(e) => setText(e.target.value)} />
|
||||
</TextArea>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setDialog(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
disabled={text.trim().length === 0}
|
||||
onClick={() => {
|
||||
if (dialog?.type === "reply") actions.onReply(dialog.requestId, text);
|
||||
if (dialog?.type === "clarify") actions.onClarify(dialog.requestId, text);
|
||||
setDialog(null);
|
||||
}}
|
||||
>
|
||||
{t("hr.action.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+112
-101
@@ -7,8 +7,10 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus } from "@subframe/core";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
import { FeatherGlobe, FeatherPlus } from "@subframe/core";
|
||||
import type { HrLocationListVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
@@ -37,7 +39,16 @@ export function HrLocationsPage({ vm, submitting, actions }: HrLocationsPageProp
|
||||
const [isDefault, setIsDefault] = useState(false);
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.locations" />;
|
||||
return (
|
||||
<PageShell uiId="ui.hr.locations">
|
||||
<PageHeader
|
||||
icon={<FeatherGlobe className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.locations.title")}
|
||||
subtitle={t("hr.locations.subtitle")}
|
||||
/>
|
||||
<PageBody>{null}</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
const { rows, canManage, emptyHeadlineKey, emptyBodyKey } = vm.data;
|
||||
@@ -51,109 +62,109 @@ export function HrLocationsPage({ vm, submitting, actions }: HrLocationsPageProp
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.locations">
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.locations.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.locations.subtitle")}
|
||||
</span>
|
||||
</div>
|
||||
{canManage ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setCreateOpen(true)} data-ui-id="ui.hr.locations.new">
|
||||
{t("hr.locations.action.new")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.locations.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.locations.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.locations.column.name")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.locations.column.city")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.locations.column.employees")}</Table.HeaderCell>
|
||||
{canManage ? <Table.HeaderCell> </Table.HeaderCell> : null}
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{rows.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-default={row.isDefault}>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center gap-2">
|
||||
<a
|
||||
href={row.detailHref}
|
||||
className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default"
|
||||
>
|
||||
{row.name}
|
||||
</a>
|
||||
{row.isDefault ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("hr.locations.default")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.city ?? "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.employeeCount}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
{canManage ? (
|
||||
<PageShell uiId="ui.hr.locations">
|
||||
<PageHeader
|
||||
icon={<FeatherGlobe className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.locations.title")}
|
||||
subtitle={t("hr.locations.subtitle")}
|
||||
actions={
|
||||
canManage ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setCreateOpen(true)} data-ui-id="ui.hr.locations.new">
|
||||
{t("hr.locations.action.new")}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.locations.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.locations.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.locations.column.name")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.locations.column.city")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.locations.column.employees")}</Table.HeaderCell>
|
||||
{canManage ? <Table.HeaderCell> </Table.HeaderCell> : null}
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{rows.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-default={row.isDefault}>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
{!row.isDefault ? (
|
||||
<Button variant="tertiary" size="small" onClick={() => actions.onSetDefault(row.id)}>
|
||||
{t("hr.locations.action.setDefault")}
|
||||
</Button>
|
||||
<div className="flex items-center gap-2">
|
||||
<AppLink
|
||||
href={row.detailHref}
|
||||
className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default"
|
||||
>
|
||||
{row.name}
|
||||
</AppLink>
|
||||
{row.isDefault ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("hr.locations.default")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
<Button variant="tertiary" size="small" onClick={() => actions.onArchive(row.id)}>
|
||||
{t("hr.locations.action.archive")}
|
||||
</Button>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
) : null}
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Dialog open={createOpen} onOpenChange={setCreateOpen}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.locations.create">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.locations.create.title")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.locations.field.name")} showLabel fillContainer>
|
||||
<TextInput.Input value={name} onChange={(event) => setName(event.target.value)} data-ui-id="ui.hr.locations.create.name" />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.locations.field.city")} showLabel fillContainer>
|
||||
<TextInput.Input value={city} onChange={(event) => setCity(event.target.value)} data-ui-id="ui.hr.locations.create.city" />
|
||||
</TextInput>
|
||||
<Checkbox label={t("hr.locations.field.isDefault")} checked={isDefault} onCheckedChange={(checked: boolean) => setIsDefault(checked)} />
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setCreateOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={name.trim().length === 0} onClick={submitCreate} data-ui-id="ui.hr.locations.create.submit">
|
||||
{t("hr.locations.create.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.city ?? "—"}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{row.employeeCount}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
{canManage ? (
|
||||
<Table.Cell>
|
||||
<div className="flex items-center justify-end gap-2">
|
||||
{!row.isDefault ? (
|
||||
<Button variant="tertiary" size="small" onClick={() => actions.onSetDefault(row.id)}>
|
||||
{t("hr.locations.action.setDefault")}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button variant="tertiary" size="small" onClick={() => actions.onArchive(row.id)}>
|
||||
{t("hr.locations.action.archive")}
|
||||
</Button>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
) : null}
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Dialog open={createOpen} onOpenChange={setCreateOpen}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.locations.create">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.locations.create.title")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.locations.field.name")} showLabel fillContainer>
|
||||
<TextInput.Input value={name} onChange={(event) => setName(event.target.value)} data-ui-id="ui.hr.locations.create.name" />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.locations.field.city")} showLabel fillContainer>
|
||||
<TextInput.Input value={city} onChange={(event) => setCity(event.target.value)} data-ui-id="ui.hr.locations.create.city" />
|
||||
</TextInput>
|
||||
<Checkbox label={t("hr.locations.field.isDefault")} checked={isDefault} onCheckedChange={(checked: boolean) => setIsDefault(checked)} />
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setCreateOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={name.trim().length === 0} onClick={submitCreate} data-ui-id="ui.hr.locations.create.submit">
|
||||
{t("hr.locations.create.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+186
-173
@@ -9,8 +9,10 @@
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherUpload } from "@subframe/core";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
import { FeatherFileText, FeatherUpload } from "@subframe/core";
|
||||
import type { HrDocumentKind, HrDocumentListVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell, PageToolbar } from "../shared/PageShell";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
@@ -19,6 +21,7 @@ import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { APP_TIME_ZONE } from "~/locale/format";
|
||||
|
||||
/** Injected upload state (owned by the route, which posts the file multipart). */
|
||||
export type HrDocumentUploadState = {
|
||||
@@ -71,11 +74,20 @@ export function HrMyDocumentsPage({ vm, submitting, upload, actions }: HrMyDocum
|
||||
}, [upload.status, uploadOpen]);
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.documents" />;
|
||||
return (
|
||||
<PageShell uiId="ui.hr.documents">
|
||||
<PageHeader
|
||||
icon={<FeatherFileText className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.documents.title")}
|
||||
subtitle={t("hr.documents.subtitle")}
|
||||
/>
|
||||
<PageBody>{null}</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
const { rows, canUpload, emptyHeadlineKey, emptyBodyKey } = vm.data;
|
||||
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium" });
|
||||
const dateFormatter = new Intl.DateTimeFormat(i18n.language, { timeZone: APP_TIME_ZONE, dateStyle: "medium" });
|
||||
const visible = rows.filter((row) => (kind ? row.documentKind === kind : true));
|
||||
const busy = upload.status === "uploading";
|
||||
|
||||
@@ -85,181 +97,182 @@ export function HrMyDocumentsPage({ vm, submitting, upload, actions }: HrMyDocum
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.documents">
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.documents.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.documents.subtitle")}
|
||||
</span>
|
||||
</div>
|
||||
{canUpload ? (
|
||||
<Button
|
||||
icon={<FeatherUpload />}
|
||||
onClick={() => {
|
||||
actions.onResetUpload();
|
||||
setUploadOpen(true);
|
||||
}}
|
||||
data-ui-id="ui.hr.documents.upload"
|
||||
>
|
||||
{t("hr.documents.upload.button")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<PageShell uiId="ui.hr.documents">
|
||||
<PageHeader
|
||||
icon={<FeatherFileText className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.documents.title")}
|
||||
subtitle={t("hr.documents.subtitle")}
|
||||
actions={
|
||||
canUpload ? (
|
||||
<Button
|
||||
icon={<FeatherUpload />}
|
||||
onClick={() => {
|
||||
actions.onResetUpload();
|
||||
setUploadOpen(true);
|
||||
}}
|
||||
data-ui-id="ui.hr.documents.upload"
|
||||
>
|
||||
{t("hr.documents.upload.button")}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
{/* --- Filter bar: full-bleed page chrome, same strip as the other list
|
||||
screens. Still only shown when there is something to filter. --- */}
|
||||
{rows.length > 0 ? (
|
||||
<div className="flex flex-wrap items-end gap-4" data-ui-id="ui.hr.documents.filter">
|
||||
<Select
|
||||
className="max-w-[240px]"
|
||||
label={t("hr.documents.filter.kind")}
|
||||
showLabel
|
||||
value={kind ?? FILTER_ALL}
|
||||
onValueChange={(value: string) => setKind(value === FILTER_ALL ? null : (value as HrDocumentKind))}
|
||||
>
|
||||
<Select.Item value={FILTER_ALL}>{t("hr.documents.filter.all")}</Select.Item>
|
||||
{KINDS.map((entry) => (
|
||||
<Select.Item key={entry} value={entry}>
|
||||
{t(`hr.document.kind.${entry}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<PageToolbar uiId="ui.hr.documents.filter">
|
||||
<Select
|
||||
className="max-w-[240px]"
|
||||
label={t("hr.documents.filter.kind")}
|
||||
showLabel
|
||||
value={kind ?? FILTER_ALL}
|
||||
onValueChange={(value: string) => setKind(value === FILTER_ALL ? null : (value as HrDocumentKind))}
|
||||
>
|
||||
<Select.Item value={FILTER_ALL}>{t("hr.documents.filter.all")}</Select.Item>
|
||||
{KINDS.map((entry) => (
|
||||
<Select.Item key={entry} value={entry}>
|
||||
{t(`hr.document.kind.${entry}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
</PageToolbar>
|
||||
) : null}
|
||||
<PageBody>
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.documents.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : visible.length === 0 ? (
|
||||
<EmptyState variant="no-results" title={t("hr.documents.noMatches")} body={t(emptyBodyKey)} />
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.documents.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.documents.column.title")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.kind")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.date")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.validity")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{visible.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-readonly={row.readOnly}>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center gap-2">
|
||||
<AppLink href={row.fileHref} className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default">
|
||||
{row.title}
|
||||
</AppLink>
|
||||
{row.readOnly ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("hr.documents.status.readOnly")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{t(row.kindKey)}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{dateFormatter.format(new Date(row.createdAtIso))}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{row.validUntilIso ? (
|
||||
row.isExpired ? (
|
||||
<BadgeFeedback farbe="subtle-negative" size="small">
|
||||
{t("hr.documents.status.expired")}
|
||||
</BadgeFeedback>
|
||||
) : (
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{dateFormatter.format(new Date(row.validUntilIso))}
|
||||
</span>
|
||||
)
|
||||
) : (
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">—</span>
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{!row.readOnly ? (
|
||||
<div className="flex justify-end">
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchive(row.id)}>
|
||||
{t("hr.documents.action.archive")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.documents.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : visible.length === 0 ? (
|
||||
<EmptyState variant="no-results" title={t("hr.documents.noMatches")} body={t(emptyBodyKey)} />
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.documents.table"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.documents.column.title")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.kind")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.date")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("hr.documents.column.validity")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{visible.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-readonly={row.readOnly}>
|
||||
<Table.Cell>
|
||||
<div className="flex items-center gap-2">
|
||||
<a href={row.fileHref} className="text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-link-default">
|
||||
{row.title}
|
||||
</a>
|
||||
{row.readOnly ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("hr.documents.status.readOnly")}
|
||||
</BadgeFeedback>
|
||||
{/* Upload dialog (self-service). The route drives the chunked upload + link. */}
|
||||
<Dialog open={uploadOpen} onOpenChange={(next) => { if (!busy) setUploadOpen(next); }}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.documents.uploadDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.documents.upload.dialog.title")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.documents.upload.field.title")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} data-ui-id="ui.hr.documents.upload.title" />
|
||||
</TextInput>
|
||||
<Select
|
||||
label={t("hr.documents.upload.field.kind")}
|
||||
showLabel
|
||||
value={form.documentKind}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, documentKind: value as HrDocumentKind }))}
|
||||
>
|
||||
{KINDS.map((entry) => (
|
||||
<Select.Item key={entry} value={entry}>
|
||||
{t(`hr.document.kind.${entry}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<label className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("hr.documents.upload.field.validUntil")}</span>
|
||||
<input
|
||||
type="date"
|
||||
value={form.validUntil}
|
||||
onChange={(e) => setForm((s) => ({ ...s, validUntil: e.target.value }))}
|
||||
className="h-9 rounded-[4px] border border-solid border-border-default bg-transparent px-3 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary outline-none"
|
||||
/>
|
||||
</label>
|
||||
<label className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("hr.documents.upload.field.file")}</span>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
onChange={(e) => setFile(e.target.files?.[0] ?? null)}
|
||||
className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary file:mr-3 file:rounded-[4px] file:border file:border-solid file:border-border-default file:bg-transparent file:px-3 file:py-1.5 file:text-text-neutral-primary"
|
||||
data-ui-id="ui.hr.documents.upload.file"
|
||||
/>
|
||||
</label>
|
||||
|
||||
{upload.status !== "idle" ? (
|
||||
<div className="flex flex-col gap-2" data-ui-id="ui.hr.documents.upload.progress" data-status={upload.status}>
|
||||
{upload.status === "error" ? (
|
||||
<Alert variant="error" textSize="small" description={t(upload.errorKey ?? "hr.documents.upload.error.generic")} notDismissible />
|
||||
) : upload.status === "uploading" ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("hr.documents.upload.status.uploading")}</span>
|
||||
) : null}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{t(row.kindKey)}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{dateFormatter.format(new Date(row.createdAtIso))}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{row.validUntilIso ? (
|
||||
row.isExpired ? (
|
||||
<BadgeFeedback farbe="subtle-negative" size="small">
|
||||
{t("hr.documents.status.expired")}
|
||||
</BadgeFeedback>
|
||||
) : (
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">
|
||||
{dateFormatter.format(new Date(row.validUntilIso))}
|
||||
</span>
|
||||
)
|
||||
) : (
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">—</span>
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{!row.readOnly ? (
|
||||
<div className="flex justify-end">
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onArchive(row.id)}>
|
||||
{t("hr.documents.action.archive")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Upload dialog (self-service). The route drives the chunked upload + link. */}
|
||||
<Dialog open={uploadOpen} onOpenChange={(next) => { if (!busy) setUploadOpen(next); }}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.documents.uploadDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.documents.upload.dialog.title")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.documents.upload.field.title")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} data-ui-id="ui.hr.documents.upload.title" />
|
||||
</TextInput>
|
||||
<Select
|
||||
label={t("hr.documents.upload.field.kind")}
|
||||
showLabel
|
||||
value={form.documentKind}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, documentKind: value as HrDocumentKind }))}
|
||||
>
|
||||
{KINDS.map((entry) => (
|
||||
<Select.Item key={entry} value={entry}>
|
||||
{t(`hr.document.kind.${entry}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<label className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("hr.documents.upload.field.validUntil")}</span>
|
||||
<input
|
||||
type="date"
|
||||
value={form.validUntil}
|
||||
onChange={(e) => setForm((s) => ({ ...s, validUntil: e.target.value }))}
|
||||
className="h-9 rounded-[4px] border border-solid border-border-default bg-transparent px-3 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-primary outline-none"
|
||||
/>
|
||||
</label>
|
||||
<label className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("hr.documents.upload.field.file")}</span>
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
onChange={(e) => setFile(e.target.files?.[0] ?? null)}
|
||||
className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary file:mr-3 file:rounded-[4px] file:border file:border-solid file:border-border-default file:bg-transparent file:px-3 file:py-1.5 file:text-text-neutral-primary"
|
||||
data-ui-id="ui.hr.documents.upload.file"
|
||||
/>
|
||||
</label>
|
||||
|
||||
{upload.status !== "idle" ? (
|
||||
<div className="flex flex-col gap-2" data-ui-id="ui.hr.documents.upload.progress" data-status={upload.status}>
|
||||
{upload.status === "error" ? (
|
||||
<Alert variant="error" textSize="small" description={t(upload.errorKey ?? "hr.documents.upload.error.generic")} notDismissible />
|
||||
) : upload.status === "uploading" ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("hr.documents.upload.status.uploading")}</span>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" disabled={busy} onClick={() => setUploadOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={busy} disabled={!file || form.title.trim().length === 0} onClick={submitUpload} data-ui-id="ui.hr.documents.upload.submit">
|
||||
{t("hr.documents.upload.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" disabled={busy} onClick={() => setUploadOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={busy} disabled={!file || form.title.trim().length === 0} onClick={submitUpload} data-ui-id="ui.hr.documents.upload.submit">
|
||||
{t("hr.documents.upload.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
import "@testing-library/jest-dom";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { buildVaultListVM } from "@hivegrid/view-models";
|
||||
import { HrPasswordSafeListPage } from "./HrPasswordSafeListPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
describe("HrPasswordSafeListPage", () => {
|
||||
it("uses client navigation and shows the caller's actual vault access", () => {
|
||||
const vm = buildVaultListVM({
|
||||
canCreate: true,
|
||||
createHref: "/acme/passwords",
|
||||
rows: [
|
||||
{
|
||||
id: "vault-1",
|
||||
name: "Operations",
|
||||
description: null,
|
||||
accessLevel: "admin",
|
||||
detailHref: "/acme/passwords/vault-1",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<HrPasswordSafeListPage vm={vm} submitting={false} actions={{ onCreateVault: vi.fn(), onSearch: vi.fn() }} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(screen.getByRole("link", { name: /Operations/ })).toHaveAttribute("href", "/acme/passwords/vault-1");
|
||||
expect(screen.getByText("hr.passwordSafe.access.admin")).toBeInTheDocument();
|
||||
expect(screen.getByText("hr.passwordSafe.card.noDescription")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+140
-63
@@ -6,32 +6,64 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus } from "@subframe/core";
|
||||
import { Link } from "react-router";
|
||||
import { FeatherChevronRight, FeatherLock, FeatherPlus, FeatherShield } from "@subframe/core";
|
||||
import type { VaultListVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { FacetFilterBar } from "../shared/FacetFilterBar";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { useLiveFilter } from "~/hooks/use-live-filter";
|
||||
|
||||
export type HrPasswordSafeListActions = {
|
||||
onCreateVault: (input: { name: string; description: string }) => void;
|
||||
onSearch: (query: string) => void;
|
||||
};
|
||||
|
||||
export type HrPasswordSafeListPageProps = {
|
||||
vm: VaultListVM;
|
||||
submitting: boolean;
|
||||
actionFeedback?: { status: "success" | "error"; messageKey: string } | null;
|
||||
actions: HrPasswordSafeListActions;
|
||||
};
|
||||
|
||||
export function HrPasswordSafeListPage({ vm, submitting, actions }: HrPasswordSafeListPageProps) {
|
||||
export function HrPasswordSafeListPage({ vm, submitting, actionFeedback, actions }: HrPasswordSafeListPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [name, setName] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [query, setQuery] = useState(vm.status === "ready" ? vm.data.searchQuery : "");
|
||||
// Free text settles before the server round-trip; the applied value is
|
||||
// compared so the effect neither fires on mount nor re-fires after the
|
||||
// loader answered. Declared before the not-ready return so hook order stays
|
||||
// stable.
|
||||
const appliedQuery = vm.status === "ready" ? vm.data.searchQuery : "";
|
||||
useLiveFilter(query.trim(), appliedQuery, () => actions.onSearch(query.trim()));
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.passwordSafe" />;
|
||||
return (
|
||||
<PageShell uiId="ui.hr.passwordSafe">
|
||||
<PageHeader
|
||||
icon={<FeatherLock className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.passwordSafe.title")}
|
||||
subtitle={t("hr.passwordSafe.subtitle")}
|
||||
subtitleTone="secondary"
|
||||
/>
|
||||
<PageBody>
|
||||
<div data-ui-id="ui.hr.passwordSafe.notReady">
|
||||
<EmptyState
|
||||
title={t(vm.status === "error" ? vm.error.messageKey : "hr.passwordSafe.loading")}
|
||||
body={t(vm.status === "error" ? "hr.passwordSafe.notReadyBody" : "hr.passwordSafe.loadingBody")}
|
||||
/>
|
||||
</div>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
const { rows, canCreate, emptyHeadlineKey, emptyBodyKey } = vm.data;
|
||||
@@ -44,67 +76,112 @@ export function HrPasswordSafeListPage({ vm, submitting, actions }: HrPasswordSa
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.passwordSafe">
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.passwordSafe.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.passwordSafe.subtitle")}
|
||||
</span>
|
||||
</div>
|
||||
{canCreate ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setCreateOpen(true)} data-ui-id="ui.hr.passwordSafe.new">
|
||||
{t("hr.passwordSafe.action.newVault")}
|
||||
</Button>
|
||||
<PageShell uiId="ui.hr.passwordSafe">
|
||||
<PageHeader
|
||||
icon={<FeatherLock className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.passwordSafe.title")}
|
||||
subtitle={t("hr.passwordSafe.subtitle")}
|
||||
subtitleTone="secondary"
|
||||
actions={
|
||||
canCreate ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setCreateOpen(true)} data-ui-id="ui.hr.passwordSafe.new">
|
||||
{t("hr.passwordSafe.action.newVault")}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
{/* --- Filter bar: the shared strip every list wears. This one carries no
|
||||
facets - a vault has nothing to narrow by beyond its name - so it is
|
||||
the search box and the way to clear it. The term settles before the
|
||||
server round-trip, as it does on the other lists. --- */}
|
||||
<FacetFilterBar
|
||||
uiId="ui.hr.passwordSafe.filter"
|
||||
facets={[]}
|
||||
onToggle={() => undefined}
|
||||
search={query}
|
||||
onSearchChange={setQuery}
|
||||
searchPlaceholder={t("hr.passwordSafe.searchPlaceholder")}
|
||||
onReset={() => {
|
||||
setQuery("");
|
||||
actions.onSearch("");
|
||||
}}
|
||||
labels={{ reset: t("hr.passwordSafe.filter.reset"), removeChip: t("hr.passwordSafe.filter.removeChip") }}
|
||||
/>
|
||||
<PageBody>
|
||||
{actionFeedback ? (
|
||||
<Alert
|
||||
variant={actionFeedback.status}
|
||||
notDismissible
|
||||
title={t(actionFeedback.messageKey)}
|
||||
data-ui-id={`ui.hr.passwordSafe.feedback.${actionFeedback.status}`}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.passwordSafe.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3" data-ui-id="ui.hr.passwordSafe.list">
|
||||
{rows.map((row) => (
|
||||
<a key={row.id} href={row.detailHref} className="no-underline" data-row-id={row.id}>
|
||||
<Card>
|
||||
<div className="flex w-full flex-col gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.name}</span>
|
||||
{row.description ? (
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{row.description}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
</Card>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Dialog open={createOpen} onOpenChange={setCreateOpen}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.passwordSafe.create">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.passwordSafe.create.title")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.passwordSafe.field.vaultName")} showLabel fillContainer>
|
||||
<TextInput.Input value={name} onChange={(event) => setName(event.target.value)} data-ui-id="ui.hr.passwordSafe.create.name" />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.passwordSafe.field.description")} showLabel fillContainer>
|
||||
<TextInput.Input value={description} onChange={(event) => setDescription(event.target.value)} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setCreateOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={name.trim().length === 0} onClick={submitCreate} data-ui-id="ui.hr.passwordSafe.create.submit">
|
||||
{t("hr.passwordSafe.create.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.passwordSafe.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3" data-ui-id="ui.hr.passwordSafe.list">
|
||||
{rows.map((row) => (
|
||||
<Link key={row.id} to={row.detailHref} className="group/vault min-w-0 no-underline" data-row-id={row.id}>
|
||||
<Card className="group-hover/vault:border-border-strong group-focus-visible/vault:shadow-focus h-full min-h-40 transition-[border-color,box-shadow,transform] duration-200 group-hover/vault:-translate-y-0.5 group-hover/vault:shadow-md">
|
||||
<div className="flex w-full items-start gap-4">
|
||||
<span
|
||||
className="bg-brand-brand-surface-subtle-default text-icon-brand-primary flex size-10 shrink-0 items-center justify-center rounded-md"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<FeatherLock className="size-5" />
|
||||
</span>
|
||||
<div className="flex min-w-0 grow flex-col gap-2">
|
||||
<span className="text-body-large-medium-0 font-body-large-medium-0 text-text-neutral-primary truncate">{row.name}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary line-clamp-2">
|
||||
{row.description || t("hr.passwordSafe.card.noDescription")}
|
||||
</span>
|
||||
</div>
|
||||
<FeatherChevronRight
|
||||
className="text-icon-neutral-tertiary group-hover/vault:text-icon-neutral-primary mt-2 size-5 shrink-0 transition-transform duration-200 group-hover/vault:translate-x-0.5"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-auto flex w-full items-center justify-between gap-3">
|
||||
<BadgeFeedback farbe="subtle-positive" size="small">
|
||||
<FeatherShield className="size-3.5" aria-hidden="true" />
|
||||
{t("hr.passwordSafe.card.protected")}
|
||||
</BadgeFeedback>
|
||||
<span className="text-body-small-medium-150 font-body-small-medium-150 text-text-neutral-secondary">
|
||||
{t(`hr.passwordSafe.access.${row.accessLevel}`)}
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Dialog open={createOpen} onOpenChange={setCreateOpen} title={t("hr.passwordSafe.create.title")}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.passwordSafe.create">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.passwordSafe.create.title")}</h2>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.passwordSafe.field.vaultName")} showLabel fillContainer>
|
||||
<TextInput.Input value={name} onChange={(event) => setName(event.target.value)} data-ui-id="ui.hr.passwordSafe.create.name" />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.passwordSafe.field.description")} showLabel fillContainer>
|
||||
<TextInput.Input value={description} onChange={(event) => setDescription(event.target.value)} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setCreateOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={name.trim().length === 0} onClick={submitCreate} data-ui-id="ui.hr.passwordSafe.create.submit">
|
||||
{t("hr.passwordSafe.create.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+61
-49
@@ -4,8 +4,9 @@
|
||||
// Subframe optics = tracked design-nachzug.
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherExternalLink } from "@subframe/core";
|
||||
import { FeatherExternalLink, FeatherFileText } from "@subframe/core";
|
||||
import type { HrPayslipOwnVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
@@ -24,56 +25,67 @@ export function HrPayslipsPage({ vm, submitting, actions }: HrPayslipsPageProps)
|
||||
const rows = vm.data?.rows ?? [];
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.payslips" />;
|
||||
return (
|
||||
<PageShell uiId="ui.hr.payslips">
|
||||
<PageHeader
|
||||
icon={<FeatherFileText className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.payslips.title")}
|
||||
subtitle={t("hr.payslips.subtitle")}
|
||||
/>
|
||||
<PageBody>{null}</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.payslips">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.payslips.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.payslips.subtitle")}</span>
|
||||
</div>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.payslips.empty">
|
||||
<EmptyState title={t("hr.payslips.own.empty.headline")} body={t("hr.payslips.own.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.payslips.list"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.payslips.column.period")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{rows.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-read={row.isRead}>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.periodLabel}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{!row.isRead ? (
|
||||
<BadgeFeedback farbe="subtle-warning" size="small">
|
||||
{t("hr.payslips.unread")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex justify-end">
|
||||
<Button variant="tertiary" size="small" icon={<FeatherExternalLink />} loading={submitting} onClick={() => actions.onOpen(row.id)}>
|
||||
{t("hr.payslips.action.open")}
|
||||
</Button>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<PageShell uiId="ui.hr.payslips">
|
||||
<PageHeader
|
||||
icon={<FeatherFileText className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.payslips.title")}
|
||||
subtitle={t("hr.payslips.subtitle")}
|
||||
/>
|
||||
<PageBody>
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.payslips.empty">
|
||||
<EmptyState title={t("hr.payslips.own.empty.headline")} body={t("hr.payslips.own.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
data-ui-id="ui.hr.payslips.list"
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("hr.payslips.column.period")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{rows.map((row) => (
|
||||
<Table.Row key={row.id} data-row-id={row.id} data-read={row.isRead}>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.periodLabel}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{!row.isRead ? (
|
||||
<BadgeFeedback farbe="subtle-warning" size="small">
|
||||
{t("hr.payslips.unread")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex justify-end">
|
||||
<Button variant="tertiary" size="small" icon={<FeatherExternalLink />} loading={submitting} onClick={() => actions.onOpen(row.id)}>
|
||||
{t("hr.payslips.action.open")}
|
||||
</Button>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+128
@@ -0,0 +1,128 @@
|
||||
import "@testing-library/jest-dom";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { buildHrHubVM, buildHrRequestTemplateListVM, type HrHubHrefs } from "@hivegrid/view-models";
|
||||
import { expectNoAxeViolations, runAxe } from "@hivegrid/ui-app/test-setup/axe";
|
||||
import { HrAdminPayslipsPage } from "./HrAdminPayslipsPage";
|
||||
import { HrAdminRequestTemplatesPage } from "./HrAdminRequestTemplatesPage";
|
||||
import { HrHubPage } from "./HrHubPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) =>
|
||||
values ? `${key}:${Object.values(values).join("/")}` : key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
const ids = [
|
||||
"leave", "sick", "documents", "payslips", "announcements", "requests",
|
||||
"surveys", "teamDirectory", "teamLeave", "leaveApprovals", "requestApprovals",
|
||||
"directory", "locations", "announcementAdmin", "payslipAdmin",
|
||||
"requestTemplates", "uploadReminders", "surveyAdmin",
|
||||
] as const;
|
||||
const hrefs = Object.fromEntries(ids.map((id) => [id, `/acme/hr/${id}`])) as HrHubHrefs;
|
||||
const hubVm = buildHrHubVM({
|
||||
moduleActive: true,
|
||||
hrefs,
|
||||
counts: {
|
||||
ownLeave: 1,
|
||||
ownSick: 0,
|
||||
ownRequests: 1,
|
||||
pendingLeaveApprovals: 2,
|
||||
pendingRequestApprovals: 1,
|
||||
visibleTeamMembers: 6,
|
||||
},
|
||||
capabilities: {
|
||||
canReadAll: true,
|
||||
canWrite: true,
|
||||
canApproveLeave: true,
|
||||
canViewSurveyResults: true,
|
||||
},
|
||||
});
|
||||
|
||||
describe("R-UX3 personnel accessibility and ID freedom", () => {
|
||||
it("exposes the role-aware hub as labelled sections without critical axe violations", async () => {
|
||||
const { container } = render(<HrHubPage vm={hubVm} />);
|
||||
expect(screen.getByRole("heading", { name: "hr.hub.section.forMe.label" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: "hr.hub.section.myTeam.label" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("heading", { name: "hr.hub.section.administration.label" })).toBeInTheDocument();
|
||||
expect((await runAxe(container)).violations).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps payslip file and employee ids out of visible controls", async () => {
|
||||
const { container } = render(
|
||||
<HrAdminPayslipsPage
|
||||
rows={[]}
|
||||
preview={[{
|
||||
fileId: "opaque-file-id",
|
||||
fileName: "Mira-Muster-2026-07.pdf",
|
||||
confidence: "hard",
|
||||
confidenceKey: "hr.payslips.match.confidence.hard",
|
||||
confidenceTone: "success",
|
||||
employeeUserId: "opaque-user-id",
|
||||
employeeLabel: "Mira Muster",
|
||||
}]}
|
||||
memberOptions={[{
|
||||
userId: "opaque-user-id",
|
||||
displayName: "Mira Muster",
|
||||
team: "Montage",
|
||||
roleNames: ["Mitarbeitende"],
|
||||
}]}
|
||||
period={{ year: "2026", month: "7" }}
|
||||
submitting={false}
|
||||
errorKey={null}
|
||||
feedbackKey="hr.payslips.upload.checked"
|
||||
actions={{ onMatch: vi.fn(), onConfirm: vi.fn() }}
|
||||
/>,
|
||||
);
|
||||
const fileInput = screen.getByLabelText("hr.payslips.field.filesHint");
|
||||
expect(fileInput).toHaveAttribute("accept", "application/pdf,.pdf");
|
||||
fireEvent.change(fileInput, {
|
||||
target: {
|
||||
files: [
|
||||
new File(["%PDF-1.7"], "mira.pdf", { type: "application/pdf" }),
|
||||
new File(["%PDF-1.7"], "jo.pdf", { type: "application/pdf" }),
|
||||
],
|
||||
},
|
||||
});
|
||||
expect(screen.getByText("hr.payslips.upload.selected:2")).toBeInTheDocument();
|
||||
expect(screen.getByRole("combobox", { name: "hr.payslips.field.employee" })).toBeInTheDocument();
|
||||
expect(container.textContent).toContain("Mira Muster");
|
||||
expect(container.textContent).not.toContain("opaque-user-id");
|
||||
expect(container.textContent).not.toContain("opaque-file-id");
|
||||
await expectNoAxeViolations(
|
||||
<HrAdminPayslipsPage
|
||||
rows={[]}
|
||||
preview={[]}
|
||||
memberOptions={[]}
|
||||
period={{ year: "", month: "" }}
|
||||
submitting={false}
|
||||
errorKey={null}
|
||||
feedbackKey={null}
|
||||
actions={{ onMatch: vi.fn(), onConfirm: vi.fn() }}
|
||||
/>,
|
||||
);
|
||||
});
|
||||
|
||||
it("uses named team context in the request-template approver picker", () => {
|
||||
const { container } = render(
|
||||
<HrAdminRequestTemplatesPage
|
||||
vm={buildHrRequestTemplateListVM({ rows: [], createHref: "/acme/hr/admin/request-templates" })}
|
||||
kinds={["expense"]}
|
||||
memberOptions={[{
|
||||
userId: "opaque-approver-id",
|
||||
displayName: "Mira Muster",
|
||||
team: "Montage",
|
||||
roleNames: ["Teamleitung"],
|
||||
}]}
|
||||
submitting={false}
|
||||
actions={{ onCreate: vi.fn(), onToggle: vi.fn(), onArchive: vi.fn() }}
|
||||
/>,
|
||||
);
|
||||
fireEvent.click(screen.getByRole("button", { name: "hr.requests.templates.action.create" }));
|
||||
fireEvent.click(screen.getByRole("combobox", { name: "hr.requests.field.approver" }));
|
||||
expect(screen.getByText("Mira Muster · Montage · Teamleitung")).toBeInTheDocument();
|
||||
expect(container.textContent).not.toContain("opaque-approver-id");
|
||||
});
|
||||
});
|
||||
+159
-161
@@ -5,8 +5,10 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus } from "@subframe/core";
|
||||
import { FeatherClipboard, FeatherPlus } from "@subframe/core";
|
||||
import type { HrRequestApproverVM, HrRequestKind, HrRequestOwnVM } from "@hivegrid/view-models";
|
||||
import type { FormDefinition } from "@hivegrid/form-widget";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
@@ -15,13 +17,17 @@ import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Tabs } from "~/ui/components/Tabs";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
import {
|
||||
InternalFormRenderer,
|
||||
type InternalFormValues,
|
||||
} from "~/modules/forms/internal/InternalFormRenderer";
|
||||
|
||||
export type HrRequestsTab = "own" | "approvals";
|
||||
export type HrRequestTemplateOption = { id: string; title: string; requestKind: HrRequestKind };
|
||||
export type HrRequestTemplateOption = { id: string; title: string; requestKind: HrRequestKind; definition: FormDefinition };
|
||||
|
||||
export type HrRequestsActions = {
|
||||
onSubmit: (input: { templateId: string; requestKind: string; approverUserId: string; title: string; details: string }) => void;
|
||||
onSubmit: (input: { templateId: string; values: InternalFormValues }) => void;
|
||||
onWithdraw: (requestId: string) => void;
|
||||
onApprove: (requestId: string) => void;
|
||||
onReject: (requestId: string) => void;
|
||||
@@ -34,7 +40,7 @@ export type HrRequestsPageProps = {
|
||||
ownVm: HrRequestOwnVM;
|
||||
approverVm: HrRequestApproverVM;
|
||||
templates: readonly HrRequestTemplateOption[];
|
||||
kinds: readonly HrRequestKind[];
|
||||
defaultFormDefinition: FormDefinition;
|
||||
tabHref: (tab: HrRequestsTab) => string;
|
||||
submitting: boolean;
|
||||
actions: HrRequestsActions;
|
||||
@@ -42,182 +48,174 @@ export type HrRequestsPageProps = {
|
||||
|
||||
const NO_TEMPLATE = "__none__";
|
||||
|
||||
export function HrRequestsPage({ tab, canApprove, ownVm, approverVm, templates, kinds, tabHref, submitting, actions }: HrRequestsPageProps) {
|
||||
export function HrRequestsPage({ tab, canApprove, ownVm, approverVm, templates, defaultFormDefinition, tabHref, submitting, actions }: HrRequestsPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [newOpen, setNewOpen] = useState(false);
|
||||
const [clarifyFor, setClarifyFor] = useState<string | null>(null);
|
||||
const [text, setText] = useState("");
|
||||
const [form, setForm] = useState({ templateId: NO_TEMPLATE, requestKind: kinds[0] ?? "expense", approverUserId: "", title: "", details: "" });
|
||||
const [templateId, setTemplateId] = useState(NO_TEMPLATE);
|
||||
|
||||
const tabs: HrRequestsTab[] = canApprove ? ["own", "approvals"] : ["own"];
|
||||
const ownRows = ownVm.data?.rows ?? [];
|
||||
const approverRows = approverVm.data?.rows ?? [];
|
||||
|
||||
function submitNew() {
|
||||
if (!form.title.trim()) return;
|
||||
actions.onSubmit({ ...form, templateId: form.templateId === NO_TEMPLATE ? "" : form.templateId });
|
||||
setNewOpen(false);
|
||||
setForm({ templateId: NO_TEMPLATE, requestKind: kinds[0] ?? "expense", approverUserId: "", title: "", details: "" });
|
||||
}
|
||||
const selectedTemplate =
|
||||
templateId === NO_TEMPLATE
|
||||
? null
|
||||
: templates.find((template) => template.id === templateId) ?? null;
|
||||
const activeDefinition = selectedTemplate?.definition ?? defaultFormDefinition;
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.requests">
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.requests.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.requests.subtitle")}</span>
|
||||
<PageShell uiId="ui.hr.requests">
|
||||
<PageHeader
|
||||
icon={<FeatherClipboard className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.requests.title")}
|
||||
subtitle={t("hr.requests.subtitle")}
|
||||
actions={
|
||||
tab === "own" ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setNewOpen(true)} data-ui-id="ui.hr.requests.new">
|
||||
{t("hr.requests.action.new")}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
<div data-ui-id="ui.hr.requests.tabs">
|
||||
<Tabs>
|
||||
{tabs.map((entry) => (
|
||||
<AppLink key={entry} href={tabHref(entry)} className="contents no-underline">
|
||||
<Tabs.Item active={tab === entry}>{t(`hr.requests.tab.${entry}`)}</Tabs.Item>
|
||||
</AppLink>
|
||||
))}
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
{tab === "own" ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setNewOpen(true)} data-ui-id="ui.hr.requests.new">
|
||||
{t("hr.requests.action.new")}
|
||||
</Button>
|
||||
ownRows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.requests.own.empty">
|
||||
<EmptyState title={t("hr.requests.own.empty.headline")} body={t("hr.requests.own.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.requests.own.list">
|
||||
{ownRows.map((row) => (
|
||||
<Card key={row.id} data-row-id={row.id}>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{t(row.kindLabelKey)}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t(row.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
{row.canWithdraw ? (
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onWithdraw(row.id)}>
|
||||
{t("hr.requests.action.withdraw")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<div data-ui-id="ui.hr.requests.tabs">
|
||||
<Tabs>
|
||||
{tabs.map((entry) => (
|
||||
<a key={entry} href={tabHref(entry)} className="contents no-underline">
|
||||
<Tabs.Item active={tab === entry}>{t(`hr.requests.tab.${entry}`)}</Tabs.Item>
|
||||
</a>
|
||||
))}
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
{tab === "own" ? (
|
||||
ownRows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.requests.own.empty">
|
||||
<EmptyState title={t("hr.requests.own.empty.headline")} body={t("hr.requests.own.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.requests.own.list">
|
||||
{ownRows.map((row) => (
|
||||
<Card key={row.id} data-row-id={row.id}>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{t(row.kindLabelKey)}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t(row.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
{row.canWithdraw ? (
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onWithdraw(row.id)}>
|
||||
{t("hr.requests.action.withdraw")}
|
||||
{tab === "approvals" ? (
|
||||
approverRows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.requests.approvals.empty">
|
||||
<EmptyState title={t("hr.requests.approver.empty.headline")} body={t("hr.requests.approver.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.requests.approvals.list">
|
||||
{approverRows.map((row) => (
|
||||
<Card key={row.id} data-row-id={row.id}>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{row.employeeLabel} · {t(row.kindLabelKey)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button variant="tertiary" size="small" onClick={() => { setText(""); setClarifyFor(row.id); }}>
|
||||
{t("hr.requests.action.clarify")}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button variant="destructive" size="small" loading={submitting} onClick={() => actions.onReject(row.id)}>
|
||||
{t("hr.requests.action.reject")}
|
||||
</Button>
|
||||
<Button size="small" loading={submitting} onClick={() => actions.onApprove(row.id)}>
|
||||
{t("hr.requests.action.approve")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
|
||||
{tab === "approvals" ? (
|
||||
approverRows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.requests.approvals.empty">
|
||||
<EmptyState title={t("hr.requests.approver.empty.headline")} body={t("hr.requests.approver.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.requests.approvals.list">
|
||||
{approverRows.map((row) => (
|
||||
<Card key={row.id} data-row-id={row.id}>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{row.employeeLabel} · {t(row.kindLabelKey)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button variant="tertiary" size="small" onClick={() => { setText(""); setClarifyFor(row.id); }}>
|
||||
{t("hr.requests.action.clarify")}
|
||||
</Button>
|
||||
<Button variant="destructive" size="small" loading={submitting} onClick={() => actions.onReject(row.id)}>
|
||||
{t("hr.requests.action.reject")}
|
||||
</Button>
|
||||
<Button size="small" loading={submitting} onClick={() => actions.onApprove(row.id)}>
|
||||
{t("hr.requests.action.approve")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
|
||||
{/* New request dialog */}
|
||||
<Dialog open={newOpen} onOpenChange={setNewOpen}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.requests.newDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.requests.action.new")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<Select label={t("hr.requests.field.template")} showLabel value={form.templateId} onValueChange={(v: string) => setForm((s) => ({ ...s, templateId: v }))}>
|
||||
<Select.Item value={NO_TEMPLATE}>{t("hr.requests.field.noTemplate")}</Select.Item>
|
||||
{templates.map((tpl) => (
|
||||
<Select.Item key={tpl.id} value={tpl.id}>
|
||||
{tpl.title}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select label={t("hr.requests.field.kind")} showLabel value={form.requestKind} onValueChange={(v: string) => setForm((s) => ({ ...s, requestKind: v as HrRequestKind }))}>
|
||||
{kinds.map((kind) => (
|
||||
<Select.Item key={kind} value={kind}>
|
||||
{t(`hr.requests.kind.${kind}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput label={t("hr.requests.field.title")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.requests.field.approver")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.approverUserId} onChange={(e) => setForm((s) => ({ ...s, approverUserId: e.target.value }))} />
|
||||
</TextInput>
|
||||
<TextArea label={t("hr.requests.field.details")} showLabel className="w-full">
|
||||
<TextArea.Input value={form.details} onChange={(e) => setForm((s) => ({ ...s, details: e.target.value }))} />
|
||||
</TextArea>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setNewOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={!form.title.trim()} onClick={submitNew} data-ui-id="ui.hr.requests.newDialog.submit">
|
||||
{t("hr.requests.action.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
)
|
||||
) : null}
|
||||
|
||||
{/* Clarify dialog */}
|
||||
<Dialog open={clarifyFor !== null} onOpenChange={(open) => !open && setClarifyFor(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.requests.clarifyDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.requests.action.clarify")}</span>
|
||||
<TextArea label={t("hr.requests.field.question")} showLabel className="w-full">
|
||||
<TextArea.Input value={text} onChange={(e) => setText(e.target.value)} />
|
||||
</TextArea>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setClarifyFor(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
disabled={text.trim().length === 0}
|
||||
onClick={() => {
|
||||
if (clarifyFor) actions.onClarify(clarifyFor, text);
|
||||
setClarifyFor(null);
|
||||
{/* New request dialog */}
|
||||
<Dialog open={newOpen} onOpenChange={setNewOpen}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.requests.newDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.requests.action.new")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<Select label={t("hr.requests.field.template")} showLabel value={templateId} onValueChange={setTemplateId}>
|
||||
<Select.Item value={NO_TEMPLATE}>{t("hr.requests.field.noTemplate")}</Select.Item>
|
||||
{templates.map((tpl) => (
|
||||
<Select.Item key={tpl.id} value={tpl.id}>
|
||||
{tpl.title}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
</div>
|
||||
<InternalFormRenderer
|
||||
key={templateId}
|
||||
definition={activeDefinition}
|
||||
submitting={submitting}
|
||||
uiId="ui.hr.requests.m05"
|
||||
onCancel={() => setNewOpen(false)}
|
||||
onSubmit={(values) => {
|
||||
actions.onSubmit({
|
||||
templateId: selectedTemplate?.id ?? "",
|
||||
values,
|
||||
});
|
||||
setNewOpen(false);
|
||||
setTemplateId(NO_TEMPLATE);
|
||||
}}
|
||||
>
|
||||
{t("hr.action.confirm")}
|
||||
</Button>
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
{/* Clarify dialog */}
|
||||
<Dialog open={clarifyFor !== null} onOpenChange={(open) => !open && setClarifyFor(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.requests.clarifyDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.requests.action.clarify")}</span>
|
||||
<TextArea label={t("hr.requests.field.question")} showLabel className="w-full">
|
||||
<TextArea.Input value={text} onChange={(e) => setText(e.target.value)} />
|
||||
</TextArea>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setClarifyFor(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
disabled={text.trim().length === 0}
|
||||
onClick={() => {
|
||||
if (clarifyFor) actions.onClarify(clarifyFor, text);
|
||||
setClarifyFor(null);
|
||||
}}
|
||||
>
|
||||
{t("hr.action.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+167
-169
@@ -6,23 +6,29 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus } from "@subframe/core";
|
||||
import { FeatherBell, FeatherPlus } from "@subframe/core";
|
||||
import type { HrSickLeaveOfficeVM, HrSickLeaveOwnVM, HrSickLeaveRow } from "@hivegrid/view-models";
|
||||
import type { FormDefinition } from "@hivegrid/form-widget";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Tabs } from "~/ui/components/Tabs";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { DateField } from "~/components/screens/tasks/DateField";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
import {
|
||||
InternalFormRenderer,
|
||||
type InternalFormValues,
|
||||
} from "~/modules/forms/internal/InternalFormRenderer";
|
||||
|
||||
export type HrSickTab = "own" | "office";
|
||||
|
||||
export type HrSickActions = {
|
||||
onReport: (input: { startDate: string; expectedReturnDate: string }) => void;
|
||||
onReportFor: (input: { employeeUserId: string; startDate: string }) => void;
|
||||
onAttach: (reportId: string, certificateFileId: string) => void;
|
||||
onReport: (values: InternalFormValues) => void;
|
||||
onReportFor: (values: InternalFormValues) => void;
|
||||
onAttach: (reportId: string, certificate: File) => void;
|
||||
onRevealCertificate: (reportId: string) => void;
|
||||
onClose: (reportId: string, returnDate: string) => void;
|
||||
};
|
||||
@@ -32,6 +38,8 @@ export type HrSickPageProps = {
|
||||
canManage: boolean;
|
||||
ownVm: HrSickLeaveOwnVM;
|
||||
officeVm: HrSickLeaveOfficeVM;
|
||||
ownFormDefinition: FormDefinition;
|
||||
officeFormDefinition: FormDefinition;
|
||||
tabHref: (tab: HrSickTab) => string;
|
||||
submitting: boolean;
|
||||
actions: HrSickActions;
|
||||
@@ -48,187 +56,177 @@ function readDate(el: HTMLElement | null, name: string): string {
|
||||
return el?.querySelector<HTMLInputElement>(`input[name='${name}']`)?.value ?? "";
|
||||
}
|
||||
|
||||
export function HrSickPage({ tab, canManage, ownVm, officeVm, tabHref, submitting, actions }: HrSickPageProps) {
|
||||
export function HrSickPage({ tab, canManage, ownVm, officeVm, ownFormDefinition, officeFormDefinition, tabHref, submitting, actions }: HrSickPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [dialog, setDialog] = useState<DialogState>(null);
|
||||
const [text, setText] = useState("");
|
||||
const [certificate, setCertificate] = useState<File | null>(null);
|
||||
|
||||
const tabs: HrSickTab[] = canManage ? ["own", "office"] : ["own"];
|
||||
const ownRows = ownVm.data?.rows ?? [];
|
||||
const officeRows = officeVm.data?.rows ?? [];
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.sick">
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.sick.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.sick.subtitle")}</span>
|
||||
<PageShell uiId="ui.hr.sick">
|
||||
<PageHeader
|
||||
icon={<FeatherBell className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.sick.title")}
|
||||
subtitle={t("hr.sick.subtitle")}
|
||||
actions={
|
||||
tab === "own" ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "report" })} data-ui-id="ui.hr.sick.report">
|
||||
{t("hr.sick.action.report")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "reportFor" })} data-ui-id="ui.hr.sick.reportFor">
|
||||
{t("hr.sick.action.reportFor")}
|
||||
</Button>
|
||||
)
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
<div data-ui-id="ui.hr.sick.tabs">
|
||||
<Tabs>
|
||||
{tabs.map((entry) => (
|
||||
<AppLink key={entry} href={tabHref(entry)} className="contents no-underline">
|
||||
<Tabs.Item active={tab === entry}>{t(`hr.sick.tab.${entry}`)}</Tabs.Item>
|
||||
</AppLink>
|
||||
))}
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
{tab === "own" ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "report" })} data-ui-id="ui.hr.sick.report">
|
||||
{t("hr.sick.action.report")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setDialog({ type: "reportFor" })} data-ui-id="ui.hr.sick.reportFor">
|
||||
{t("hr.sick.action.reportFor")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
ownRows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.sick.own.empty">
|
||||
<EmptyState title={t("hr.sick.own.empty.headline")} body={t("hr.sick.own.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.sick.own.list">
|
||||
{ownRows.map((row) => (
|
||||
<SickCard
|
||||
key={row.id}
|
||||
row={row}
|
||||
submitting={submitting}
|
||||
onReveal={() => actions.onRevealCertificate(row.id)}
|
||||
onAttach={() => setDialog({ type: "attach", reportId: row.id })}
|
||||
onClose={() => setDialog({ type: "close", reportId: row.id })}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
|
||||
<div data-ui-id="ui.hr.sick.tabs">
|
||||
<Tabs>
|
||||
{tabs.map((entry) => (
|
||||
<a key={entry} href={tabHref(entry)} className="contents no-underline">
|
||||
<Tabs.Item active={tab === entry}>{t(`hr.sick.tab.${entry}`)}</Tabs.Item>
|
||||
</a>
|
||||
))}
|
||||
</Tabs>
|
||||
</div>
|
||||
|
||||
{tab === "own" ? (
|
||||
ownRows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.sick.own.empty">
|
||||
<EmptyState title={t("hr.sick.own.empty.headline")} body={t("hr.sick.own.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3" data-ui-id="ui.hr.sick.own.list">
|
||||
{ownRows.map((row) => (
|
||||
<SickCard
|
||||
key={row.id}
|
||||
row={row}
|
||||
submitting={submitting}
|
||||
onReveal={() => actions.onRevealCertificate(row.id)}
|
||||
onAttach={() => { setText(""); setDialog({ type: "attach", reportId: row.id }); }}
|
||||
onClose={() => setDialog({ type: "close", reportId: row.id })}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
|
||||
{tab === "office" ? (
|
||||
officeRows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.sick.office.empty">
|
||||
<EmptyState title={t("hr.sick.office.empty.headline")} body={t("hr.sick.office.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.sick.office.list">
|
||||
{officeRows.map((row) => (
|
||||
<Card key={row.id} data-row-id={row.id}>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.employeeLabel}</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{row.startDateIso}</span>
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t(row.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
{tab === "office" ? (
|
||||
officeRows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.sick.office.empty">
|
||||
<EmptyState title={t("hr.sick.office.empty.headline")} body={t("hr.sick.office.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.sick.office.list">
|
||||
{officeRows.map((row) => (
|
||||
<Card key={row.id} data-row-id={row.id}>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.employeeLabel}</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{row.startDateIso}</span>
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t(row.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
) : null}
|
||||
|
||||
{/* Report dialog (own or office) */}
|
||||
<Dialog open={dialog?.type === "report" || dialog?.type === "reportFor"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.reportDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{dialog?.type === "reportFor" ? t("hr.sick.action.reportFor") : t("hr.sick.action.report")}
|
||||
</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
{dialog?.type === "reportFor" ? (
|
||||
<TextInput label={t("hr.sick.field.employee")} showLabel fillContainer>
|
||||
<TextInput.Input value={text} onChange={(e) => setText(e.target.value)} />
|
||||
</TextInput>
|
||||
) : null}
|
||||
<div className="flex flex-wrap gap-4">
|
||||
<DateField label={t("hr.sick.field.start")} name="startDate" />
|
||||
{dialog?.type === "report" ? <DateField label={t("hr.sick.field.expectedReturn")} name="expectedReturnDate" /> : null}
|
||||
{/* Report dialog (own or office) */}
|
||||
<Dialog open={dialog?.type === "report" || dialog?.type === "reportFor"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.reportDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{dialog?.type === "reportFor" ? t("hr.sick.action.reportFor") : t("hr.sick.action.report")}
|
||||
</span>
|
||||
<InternalFormRenderer
|
||||
definition={
|
||||
dialog?.type === "reportFor"
|
||||
? officeFormDefinition
|
||||
: ownFormDefinition
|
||||
}
|
||||
submitting={submitting}
|
||||
uiId="ui.hr.sick.m05"
|
||||
onCancel={() => setDialog(null)}
|
||||
onSubmit={(values) => {
|
||||
if (dialog?.type === "reportFor") actions.onReportFor(values);
|
||||
else actions.onReport(values);
|
||||
setDialog(null);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
{/* Attach certificate dialog */}
|
||||
<Dialog open={dialog?.type === "attach"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.attachDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.sick.action.attachCertificate")}</span>
|
||||
<label className="flex w-full flex-col gap-2 text-body-small-medium-0 text-text-neutral-secondary">
|
||||
{t("hr.sick.field.certificateFileId")}
|
||||
<input
|
||||
type="file"
|
||||
accept=".pdf,image/*"
|
||||
onChange={(event) => setCertificate(event.target.files?.[0] ?? null)}
|
||||
data-ui-id="ui.hr.sick.attachDialog.file"
|
||||
/>
|
||||
</label>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setDialog(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
disabled={!certificate}
|
||||
onClick={() => {
|
||||
if (dialog?.type === "attach" && certificate) actions.onAttach(dialog.reportId, certificate);
|
||||
setCertificate(null);
|
||||
setDialog(null);
|
||||
}}
|
||||
>
|
||||
{t("hr.action.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setDialog(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
onClick={(event) => {
|
||||
const el = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.sick.reportDialog']");
|
||||
const start = readDate(el as HTMLElement, "startDate");
|
||||
if (!start) return;
|
||||
if (dialog?.type === "reportFor") {
|
||||
if (!text.trim()) return;
|
||||
actions.onReportFor({ employeeUserId: text, startDate: start });
|
||||
} else {
|
||||
actions.onReport({ startDate: start, expectedReturnDate: readDate(el as HTMLElement, "expectedReturnDate") });
|
||||
}
|
||||
setDialog(null);
|
||||
}}
|
||||
data-ui-id="ui.hr.sick.reportDialog.submit"
|
||||
>
|
||||
{t("hr.action.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
{/* Attach certificate dialog */}
|
||||
<Dialog open={dialog?.type === "attach"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.attachDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.sick.action.attachCertificate")}</span>
|
||||
<TextInput label={t("hr.sick.field.certificateFileId")} showLabel fillContainer>
|
||||
<TextInput.Input value={text} onChange={(e) => setText(e.target.value)} />
|
||||
</TextInput>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setDialog(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
disabled={text.trim().length === 0}
|
||||
onClick={() => {
|
||||
if (dialog?.type === "attach") actions.onAttach(dialog.reportId, text);
|
||||
setDialog(null);
|
||||
}}
|
||||
>
|
||||
{t("hr.action.confirm")}
|
||||
</Button>
|
||||
{/* Close dialog */}
|
||||
<Dialog open={dialog?.type === "close"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.closeDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.sick.action.close")}</span>
|
||||
<DateField label={t("hr.sick.field.returnDate")} name="returnDate" />
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setDialog(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
onClick={(event) => {
|
||||
const el = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.sick.closeDialog']");
|
||||
const ret = readDate(el as HTMLElement, "returnDate");
|
||||
if (!ret || dialog?.type !== "close") return;
|
||||
actions.onClose(dialog.reportId, ret);
|
||||
setDialog(null);
|
||||
}}
|
||||
>
|
||||
{t("hr.action.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
{/* Close dialog */}
|
||||
<Dialog open={dialog?.type === "close"} onOpenChange={(open) => !open && setDialog(null)}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.sick.closeDialog">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.sick.action.close")}</span>
|
||||
<DateField label={t("hr.sick.field.returnDate")} name="returnDate" />
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setDialog(null)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
onClick={(event) => {
|
||||
const el = (event.currentTarget as HTMLElement).closest("[data-ui-id='ui.hr.sick.closeDialog']");
|
||||
const ret = readDate(el as HTMLElement, "returnDate");
|
||||
if (!ret || dialog?.type !== "close") return;
|
||||
actions.onClose(dialog.reportId, ret);
|
||||
setDialog(null);
|
||||
}}
|
||||
>
|
||||
{t("hr.action.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+136
-103
@@ -5,8 +5,10 @@
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus } from "@subframe/core";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
import { FeatherColumns, FeatherPlus } from "@subframe/core";
|
||||
import type { HrSurveyListVM } from "@hivegrid/view-models";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
@@ -20,7 +22,7 @@ import { TextInput } from "~/ui/components/TextInput";
|
||||
const VISIBILITIES = ["admins", "participants", "everyone"] as const;
|
||||
|
||||
export type HrSurveysListActions = {
|
||||
onCreate: (input: { title: string; description: string; isAnonymous: boolean; resultVisibility: string }) => void;
|
||||
onCreate: (input: { title: string; description: string; isAnonymous: boolean; resultVisibility: string; audienceKind: string; audienceRef: string }) => void;
|
||||
onSetStatus: (surveyId: string, status: "open" | "close") => void;
|
||||
onArchive: (surveyId: string) => void;
|
||||
};
|
||||
@@ -28,122 +30,153 @@ export type HrSurveysListActions = {
|
||||
export type HrSurveysListPageProps = {
|
||||
vm: HrSurveyListVM;
|
||||
canManage: boolean;
|
||||
audienceOptions: readonly { kind: "team" | "location"; ref: string; label: string }[];
|
||||
submitting: boolean;
|
||||
actions: HrSurveysListActions;
|
||||
};
|
||||
|
||||
export function HrSurveysListPage({ vm, canManage, submitting, actions }: HrSurveysListPageProps) {
|
||||
export function HrSurveysListPage({ vm, canManage, audienceOptions, submitting, actions }: HrSurveysListPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
const [form, setForm] = useState({ title: "", description: "", isAnonymous: false, resultVisibility: "admins" });
|
||||
const [form, setForm] = useState({ title: "", description: "", isAnonymous: false, resultVisibility: "admins", audienceKind: "all", audienceRef: "" });
|
||||
const rows = vm.data?.rows ?? [];
|
||||
|
||||
function submit() {
|
||||
if (!form.title.trim()) return;
|
||||
actions.onCreate(form);
|
||||
setOpen(false);
|
||||
setForm({ title: "", description: "", isAnonymous: false, resultVisibility: "admins" });
|
||||
setForm({ title: "", description: "", isAnonymous: false, resultVisibility: "admins", audienceKind: "all", audienceRef: "" });
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.surveys">
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("hr.surveys.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{t("hr.surveys.subtitle")}</span>
|
||||
</div>
|
||||
{canManage ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setOpen(true)} data-ui-id="ui.hr.surveys.newBtn">
|
||||
{t("hr.surveys.action.create")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.surveys.empty">
|
||||
<EmptyState title={t("hr.surveys.empty.headline")} body={t("hr.surveys.empty.body")} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.surveys.list">
|
||||
{rows.map((row) => (
|
||||
<Card key={row.id} data-row-id={row.id} data-status={row.status}>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
|
||||
<BadgeFeedback farbe={row.status === "open" ? "subtle-positive" : "subtle-neutral"} size="small">
|
||||
{t(row.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
{row.isAnonymous ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("hr.surveys.anonymous")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{row.status === "open" && !row.hasSubmitted ? (
|
||||
<a href={row.participateHref} className="contents no-underline">
|
||||
<LinkButton variant="subtle">{t("hr.surveys.action.participate")}</LinkButton>
|
||||
</a>
|
||||
) : null}
|
||||
{row.canViewResults ? (
|
||||
<a href={row.resultsHref} className="contents no-underline">
|
||||
<LinkButton variant="subtle">{t("hr.surveys.action.results")}</LinkButton>
|
||||
</a>
|
||||
) : null}
|
||||
{canManage ? (
|
||||
<>
|
||||
{row.status !== "open" ? (
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onSetStatus(row.id, "open")}>
|
||||
{t("hr.surveys.action.open")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onSetStatus(row.id, "close")}>
|
||||
{t("hr.surveys.action.close")}
|
||||
</Button>
|
||||
)}
|
||||
<a href={row.participateHref} className="contents no-underline">
|
||||
<LinkButton variant="subtle">{t("hr.surveys.action.edit")}</LinkButton>
|
||||
</a>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.surveys.new">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.surveys.action.create")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.surveys.field.title")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.surveys.field.description")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.description} onChange={(e) => setForm((s) => ({ ...s, description: e.target.value }))} />
|
||||
</TextInput>
|
||||
<Select label={t("hr.surveys.field.resultVisibility")} showLabel value={form.resultVisibility} onValueChange={(v: string) => setForm((s) => ({ ...s, resultVisibility: v }))}>
|
||||
{VISIBILITIES.map((v) => (
|
||||
<Select.Item key={v} value={v}>
|
||||
{t(`hr.surveys.visibility.${v}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Checkbox label={t("hr.surveys.field.anonymous")} checked={form.isAnonymous} onCheckedChange={(c: boolean) => setForm((s) => ({ ...s, isAnonymous: c }))} />
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={!form.title.trim()} onClick={submit} data-ui-id="ui.hr.surveys.new.submit">
|
||||
{t("hr.surveys.action.create")}
|
||||
</Button>
|
||||
</div>
|
||||
<PageShell uiId="ui.hr.surveys">
|
||||
<PageHeader
|
||||
icon={<FeatherColumns className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.surveys.title")}
|
||||
subtitle={t("hr.surveys.subtitle")}
|
||||
actions={
|
||||
canManage ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setOpen(true)} data-ui-id="ui.hr.surveys.newBtn">
|
||||
{t("hr.surveys.action.create")}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.surveys.empty">
|
||||
<EmptyState title={t("hr.surveys.empty.headline")} body={t("hr.surveys.empty.body")} />
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-2" data-ui-id="ui.hr.surveys.list">
|
||||
{rows.map((row) => (
|
||||
<Card key={row.id} data-row-id={row.id} data-status={row.status}>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{row.title}</span>
|
||||
<BadgeFeedback farbe={row.status === "open" ? "subtle-positive" : "subtle-neutral"} size="small">
|
||||
{t(row.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
{row.isAnonymous ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("hr.surveys.anonymous")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
{row.status === "open" && !row.hasSubmitted ? (
|
||||
<AppLink href={row.participateHref} className="contents no-underline">
|
||||
<LinkButton variant="subtle">{t("hr.surveys.action.participate")}</LinkButton>
|
||||
</AppLink>
|
||||
) : null}
|
||||
{row.canViewResults ? (
|
||||
<AppLink href={row.resultsHref} className="contents no-underline">
|
||||
<LinkButton variant="subtle">{t("hr.surveys.action.results")}</LinkButton>
|
||||
</AppLink>
|
||||
) : null}
|
||||
{canManage ? (
|
||||
<>
|
||||
{row.status !== "open" ? (
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onSetStatus(row.id, "open")}>
|
||||
{t("hr.surveys.action.open")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => actions.onSetStatus(row.id, "close")}>
|
||||
{t("hr.surveys.action.close")}
|
||||
</Button>
|
||||
)}
|
||||
<AppLink href={row.participateHref} className="contents no-underline">
|
||||
<LinkButton variant="subtle">{t("hr.surveys.action.edit")}</LinkButton>
|
||||
</AppLink>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.surveys.new">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.surveys.action.create")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.surveys.field.title")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.title} onChange={(e) => setForm((s) => ({ ...s, title: e.target.value }))} />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.surveys.field.description")} showLabel fillContainer>
|
||||
<TextInput.Input value={form.description} onChange={(e) => setForm((s) => ({ ...s, description: e.target.value }))} />
|
||||
</TextInput>
|
||||
<Select label={t("hr.surveys.field.resultVisibility")} showLabel value={form.resultVisibility} onValueChange={(v: string) => setForm((s) => ({ ...s, resultVisibility: v }))}>
|
||||
{VISIBILITIES.map((v) => (
|
||||
<Select.Item key={v} value={v}>
|
||||
{t(`hr.surveys.visibility.${v}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
label={t("hr.surveys.field.audience")}
|
||||
showLabel
|
||||
value={form.audienceKind}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, audienceKind: value, audienceRef: "" }))}
|
||||
>
|
||||
{(["all", "team", "location"] as const).map((kind) => (
|
||||
<Select.Item key={kind} value={kind}>
|
||||
{t(`hr.audience.${kind}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
{form.audienceKind !== "all" ? (
|
||||
<Select
|
||||
label={t("hr.surveys.field.audienceRef")}
|
||||
showLabel
|
||||
value={form.audienceRef}
|
||||
onValueChange={(value: string) => setForm((s) => ({ ...s, audienceRef: value }))}
|
||||
>
|
||||
{audienceOptions
|
||||
.filter((option) => option.kind === form.audienceKind)
|
||||
.map((option) => (
|
||||
<Select.Item key={`${option.kind}:${option.ref}`} value={option.ref}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
) : null}
|
||||
<Checkbox label={t("hr.surveys.field.anonymous")} checked={form.isAnonymous} onCheckedChange={(c: boolean) => setForm((s) => ({ ...s, isAnonymous: c }))} />
|
||||
</div>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={!form.title.trim()} onClick={submit} data-ui-id="ui.hr.surveys.new.submit">
|
||||
{t("hr.surveys.action.create")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+88
@@ -0,0 +1,88 @@
|
||||
import "@testing-library/jest-dom";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { buildVaultDetailVM } from "@hivegrid/view-models";
|
||||
import { expectNoAxeViolations, runAxe } from "@hivegrid/ui-app/test-setup/axe";
|
||||
import { HrVaultDetailPage, type HrVaultDetailActions } from "./HrVaultDetailPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key, i18n: { language: "de" } }),
|
||||
}));
|
||||
|
||||
const vm = buildVaultDetailVM({
|
||||
vaultId: "vault-1",
|
||||
vaultName: "Betrieb",
|
||||
accessLevel: "admin",
|
||||
canExport: true,
|
||||
exportHref: "/acme/passwords/vault-1/export",
|
||||
rows: [{
|
||||
id: "entry-1",
|
||||
title: "Router",
|
||||
tags: [],
|
||||
url: null,
|
||||
hasUsername: true,
|
||||
hasPassword: true,
|
||||
hasNotes: true,
|
||||
revealHref: "/acme/passwords/vault-1/reveal",
|
||||
}],
|
||||
accessRows: [{
|
||||
userId: "opaque-user-id",
|
||||
displayName: "Mira Beispiel",
|
||||
email: "mira@example.test",
|
||||
roleNames: ["Mitarbeitende"],
|
||||
permissionLevel: "write",
|
||||
}],
|
||||
});
|
||||
|
||||
const actions: HrVaultDetailActions = {
|
||||
onReveal: vi.fn(async () => "temporary"),
|
||||
onCopy: vi.fn(async () => "temporary"),
|
||||
onCreateEntry: vi.fn(),
|
||||
onUpdateEntry: vi.fn(),
|
||||
onArchiveEntry: vi.fn(),
|
||||
onRestoreEntry: vi.fn(),
|
||||
onGrantAccess: vi.fn(),
|
||||
onRevokeAccess: vi.fn(),
|
||||
onExport: vi.fn(async () => true),
|
||||
};
|
||||
|
||||
describe("password manager accessibility and ID freedom", () => {
|
||||
it("exposes named secret controls, keyboard tabs and no visible raw user ids", async () => {
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<HrVaultDetailPage vm={vm} submitting={false} actions={actions} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
expect(screen.getByRole("button", { name: "hr.passwordSafe.field.username: hr.passwordSafe.detail.reveal" })).toBeInTheDocument();
|
||||
expect(screen.getByRole("button", { name: "hr.passwordSafe.field.password: hr.passwordSafe.detail.copy" })).toBeInTheDocument();
|
||||
const entriesTab = screen.getByRole("tab", { name: "hr.passwordSafe.tabs.entries" });
|
||||
const accessTab = screen.getByRole("tab", { name: "hr.passwordSafe.tabs.access" });
|
||||
entriesTab.focus();
|
||||
fireEvent.keyDown(entriesTab, { key: "ArrowRight" });
|
||||
expect(accessTab).toHaveAttribute("aria-selected", "true");
|
||||
expect(accessTab).toHaveFocus();
|
||||
expect(screen.getByText("Mira Beispiel")).toBeInTheDocument();
|
||||
expect(screen.getByRole("combobox", { name: "Mira Beispiel: hr.passwordSafe.field.permissionLevel" })).toBeInTheDocument();
|
||||
expect(container.textContent).not.toContain("opaque-user-id");
|
||||
expect((await runAxe(container)).violations).toEqual([]);
|
||||
});
|
||||
|
||||
it("has no critical static axe violations", async () => {
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<HrVaultDetailPage vm={vm} submitting={false} actions={actions} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
expect(
|
||||
Array.from(container.querySelectorAll("h1, h2, h3, h4, h5, h6"))
|
||||
.filter((heading) => !heading.textContent?.trim())
|
||||
.map((heading) => heading.outerHTML)
|
||||
).toEqual([]);
|
||||
await expectNoAxeViolations(
|
||||
<MemoryRouter>
|
||||
<HrVaultDetailPage vm={vm} submitting={false} actions={actions} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
});
|
||||
+161
-10
@@ -1,6 +1,6 @@
|
||||
import { vi, describe, it, expect } from "vitest";
|
||||
import "@testing-library/jest-dom";
|
||||
import { render, fireEvent, waitFor } from "@testing-library/react";
|
||||
import { act, render, fireEvent, waitFor } from "@testing-library/react";
|
||||
import { BrowserRouter as Router } from "react-router";
|
||||
import { buildVaultDetailVM } from "@hivegrid/view-models";
|
||||
|
||||
@@ -15,9 +15,19 @@ function vault(overrides: Record<string, unknown> = {}) {
|
||||
vaultId: "v1",
|
||||
vaultName: "Team Vault",
|
||||
accessLevel: "admin",
|
||||
exportHref: "/acme/hr/password-safe/v1/export",
|
||||
exportHref: "/acme/passwords/v1/export",
|
||||
canExport: true,
|
||||
rows: [
|
||||
{ id: "e1", title: "GitHub", tags: ["dev"], url: "https://github.com", hasUsername: true, hasPassword: true, hasNotes: false, revealHref: "/acme/hr/password-safe/v1/reveal" },
|
||||
{
|
||||
id: "e1",
|
||||
title: "GitHub",
|
||||
tags: ["dev"],
|
||||
url: "https://github.com",
|
||||
hasUsername: true,
|
||||
hasPassword: true,
|
||||
hasNotes: false,
|
||||
revealHref: "/acme/passwords/v1/reveal",
|
||||
},
|
||||
],
|
||||
...overrides,
|
||||
});
|
||||
@@ -25,17 +35,22 @@ function vault(overrides: Record<string, unknown> = {}) {
|
||||
|
||||
const noopActions = {
|
||||
onReveal: vi.fn(async () => null),
|
||||
onCopy: vi.fn(async () => null),
|
||||
onCreateEntry: vi.fn(),
|
||||
onUpdateEntry: vi.fn(),
|
||||
onArchiveEntry: vi.fn(),
|
||||
onRestoreEntry: vi.fn(),
|
||||
onGrantAccess: vi.fn(),
|
||||
onRevokeAccess: vi.fn(),
|
||||
onExport: vi.fn(async () => true),
|
||||
};
|
||||
|
||||
describe("HrVaultDetailPage (interim-UI, security-critical)", () => {
|
||||
it("never renders secret values in the entry list — only reveal controls", () => {
|
||||
const { container, queryByText } = render(
|
||||
<Router>
|
||||
<HrVaultDetailPage vm={vault()} backHref=".." submitting={false} actions={noopActions} />
|
||||
</Router>,
|
||||
<HrVaultDetailPage vm={vault()} submitting={false} actions={noopActions} />
|
||||
</Router>
|
||||
);
|
||||
// The entry surface renders...
|
||||
expect(container.querySelector('[data-row-id="e1"]')).toBeInTheDocument();
|
||||
@@ -49,16 +64,152 @@ describe("HrVaultDetailPage (interim-UI, security-critical)", () => {
|
||||
const onReveal = vi.fn(async () => "s3cret");
|
||||
const { container, findByText } = render(
|
||||
<Router>
|
||||
<HrVaultDetailPage vm={vault()} backHref=".." submitting={false} actions={{ ...noopActions, onReveal }} />
|
||||
</Router>,
|
||||
<HrVaultDetailPage vm={vault()} submitting={false} actions={{ ...noopActions, onReveal }} />
|
||||
</Router>
|
||||
);
|
||||
const revealBtn = container.querySelector('[data-ui-id="ui.hr.vault.reveal"]') as HTMLElement;
|
||||
fireEvent.click(revealBtn);
|
||||
await waitFor(() => expect(onReveal).toHaveBeenCalledWith("e1", "username"));
|
||||
// The plaintext now appears next to a copy control; the 30s clipboard wipe is
|
||||
// driven by that CopyToClipboardButton's onCopy (exercised end-to-end in the
|
||||
// browser — the Subframe copy primitive is not reliably triggerable in jsdom).
|
||||
// The plaintext now appears next to a separately audited copy control.
|
||||
expect(await findByText("s3cret")).toBeInTheDocument();
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.vault.revealed"]')).toBeInTheDocument();
|
||||
expect(container.querySelector('[data-ui-id="ui.hr.vault.fieldActions"]')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("removes revealed plaintext after 30 seconds and immediately in the background", async () => {
|
||||
vi.useFakeTimers();
|
||||
const visibilityDescriptor = Object.getOwnPropertyDescriptor(document, "visibilityState");
|
||||
try {
|
||||
const onReveal = vi.fn(async () => "short-lived-secret");
|
||||
const { container, queryByText } = render(
|
||||
<Router>
|
||||
<HrVaultDetailPage vm={vault()} submitting={false} actions={{ ...noopActions, onReveal }} />
|
||||
</Router>
|
||||
);
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(container.querySelector('[data-ui-id="ui.hr.vault.reveal"]')!);
|
||||
});
|
||||
expect(queryByText("short-lived-secret")).toBeInTheDocument();
|
||||
act(() => vi.advanceTimersByTime(30_000));
|
||||
expect(queryByText("short-lived-secret")).not.toBeInTheDocument();
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(container.querySelector('[data-ui-id="ui.hr.vault.reveal"]')!);
|
||||
});
|
||||
expect(queryByText("short-lived-secret")).toBeInTheDocument();
|
||||
Object.defineProperty(document, "visibilityState", { configurable: true, value: "hidden" });
|
||||
fireEvent(document, new Event("visibilitychange"));
|
||||
expect(queryByText("short-lived-secret")).not.toBeInTheDocument();
|
||||
} finally {
|
||||
if (visibilityDescriptor) Object.defineProperty(document, "visibilityState", visibilityDescriptor);
|
||||
else Reflect.deleteProperty(document, "visibilityState");
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("copies only through the audited command and clears the clipboard best-effort after 30 seconds", async () => {
|
||||
vi.useFakeTimers();
|
||||
const clipboardDescriptor = Object.getOwnPropertyDescriptor(navigator, "clipboard");
|
||||
const writeText = vi.fn(async () => undefined);
|
||||
Object.defineProperty(navigator, "clipboard", { configurable: true, value: { writeText } });
|
||||
try {
|
||||
const onCopy = vi.fn(async () => "copy-once-secret");
|
||||
const { getByRole, getByText } = render(
|
||||
<Router>
|
||||
<HrVaultDetailPage vm={vault()} submitting={false} actions={{ ...noopActions, onCopy }} />
|
||||
</Router>
|
||||
);
|
||||
|
||||
await act(async () => {
|
||||
fireEvent.click(getByRole("button", { name: "hr.passwordSafe.field.username: hr.passwordSafe.detail.copy" }));
|
||||
});
|
||||
expect(onCopy).toHaveBeenCalledWith("e1", "username");
|
||||
expect(writeText).toHaveBeenCalledWith("copy-once-secret");
|
||||
expect(getByText("hr.passwordSafe.detail.copyCleared")).toBeInTheDocument();
|
||||
|
||||
act(() => vi.advanceTimersByTime(30_000));
|
||||
expect(writeText).toHaveBeenLastCalledWith("");
|
||||
} finally {
|
||||
if (clipboardDescriptor) Object.defineProperty(navigator, "clipboard", clipboardDescriptor);
|
||||
else Reflect.deleteProperty(navigator, "clipboard");
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it("requires explicit confirmation before invoking export", async () => {
|
||||
const onExport = vi.fn(async () => true);
|
||||
const { getByRole } = render(
|
||||
<Router>
|
||||
<HrVaultDetailPage vm={vault()} submitting={false} actions={{ ...noopActions, onExport }} />
|
||||
</Router>
|
||||
);
|
||||
fireEvent.click(getByRole("button", { name: "hr.passwordSafe.detail.export" }));
|
||||
expect(onExport).not.toHaveBeenCalled();
|
||||
fireEvent.click(document.querySelector('[data-ui-id="ui.hr.vault.exportConfirm.submit"]')!);
|
||||
await waitFor(() => expect(onExport).toHaveBeenCalledOnce());
|
||||
});
|
||||
|
||||
it("keeps the export confirmation open and shows a clear failure state when export is denied", async () => {
|
||||
const onExport = vi.fn(async () => false);
|
||||
const { getByRole } = render(
|
||||
<Router>
|
||||
<HrVaultDetailPage vm={vault()} submitting={false} actions={{ ...noopActions, onExport }} />
|
||||
</Router>
|
||||
);
|
||||
fireEvent.click(getByRole("button", { name: "hr.passwordSafe.detail.export" }));
|
||||
fireEvent.click(document.querySelector('[data-ui-id="ui.hr.vault.exportConfirm.submit"]')!);
|
||||
await waitFor(() => expect(document.querySelector('[data-ui-id="ui.hr.vault.export.error"]')).toBeInTheDocument());
|
||||
expect(document.querySelector('[data-ui-id="ui.hr.vault.exportConfirm"]')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows a clear secret-action error instead of an empty result", async () => {
|
||||
const onReveal = vi.fn(async () => null);
|
||||
const { container, findByText } = render(
|
||||
<Router>
|
||||
<HrVaultDetailPage vm={vault()} submitting={false} actions={{ ...noopActions, onReveal }} />
|
||||
</Router>
|
||||
);
|
||||
fireEvent.click(container.querySelector('[data-ui-id="ui.hr.vault.reveal"]')!);
|
||||
expect(await findByText("hr.passwordSafe.detail.secretActionFailed")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("archives an entry only after a clear confirmation", () => {
|
||||
const onArchiveEntry = vi.fn();
|
||||
const confirm = vi.spyOn(window, "confirm").mockReturnValueOnce(false).mockReturnValueOnce(true);
|
||||
const { getByRole } = render(
|
||||
<Router>
|
||||
<HrVaultDetailPage vm={vault()} submitting={false} actions={{ ...noopActions, onArchiveEntry }} />
|
||||
</Router>
|
||||
);
|
||||
const archive = getByRole("button", { name: "hr.passwordSafe.detail.archiveEntry" });
|
||||
fireEvent.click(archive);
|
||||
expect(onArchiveEntry).not.toHaveBeenCalled();
|
||||
fireEvent.click(archive);
|
||||
expect(onArchiveEntry).toHaveBeenCalledWith("e1");
|
||||
confirm.mockRestore();
|
||||
});
|
||||
|
||||
it("keeps archived entries reachable and restores them through the injected action", () => {
|
||||
const onRestoreEntry = vi.fn();
|
||||
const archived = {
|
||||
id: "e2",
|
||||
title: "Old router",
|
||||
tags: [],
|
||||
url: null,
|
||||
hasUsername: true,
|
||||
hasPassword: true,
|
||||
hasNotes: false,
|
||||
revealHref: "/acme/passwords/v1/reveal",
|
||||
};
|
||||
const { container } = render(
|
||||
<Router>
|
||||
<HrVaultDetailPage vm={vault({ archivedRows: [archived] })} submitting={false} actions={{ ...noopActions, onRestoreEntry }} />
|
||||
</Router>
|
||||
);
|
||||
expect(container.querySelector('[data-archived-row-id="e2"]')).toBeInTheDocument();
|
||||
fireEvent.click(container.querySelector('[data-ui-id="ui.hr.vault.restoreEntry"]')!);
|
||||
expect(onRestoreEntry).toHaveBeenCalledWith("e2");
|
||||
expect(container.querySelector('[data-archived-row-id="e2"] [data-ui-id="ui.hr.vault.reveal"]')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+431
-197
@@ -1,114 +1,170 @@
|
||||
// AK-P17a Interim-UI (AD-28) — vault detail composed from ~/ui (D-HR
|
||||
// "Passwort-Safe Detail", archetype A3 + reveal). SECURITY-CRITICAL: secret
|
||||
// values are NEVER in the list — each entry shows only "hasX" flags. A value is
|
||||
// fetched ONLY on an explicit, audited reveal (route action) and, once copied, the
|
||||
// clipboard is wiped after copyAutoClearMs (30s, DoD #3). Create-entry / grant-
|
||||
// access run through injected actions. Final Subframe optics = design-nachzug.
|
||||
// R-UX4 interim UI (AD-28). The screen receives a secret-free VM and injected
|
||||
// commands. Reveal/copy plaintext exists only in short-lived component state.
|
||||
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus } from "@subframe/core";
|
||||
import { FeatherArchive, FeatherLock, FeatherPlus, FeatherRotateCcw } from "@subframe/core";
|
||||
import type { EntryRow, VaultDetailVM } from "@hivegrid/view-models";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "../shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { CopyToClipboardButton } from "~/ui/components/CopyToClipboardButton";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { LinkButton } from "~/ui/components/LinkButton";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Tabs } from "~/ui/components/Tabs";
|
||||
import { Tag_Label } from "~/ui/components/Tag_Label";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type VaultSecretField = "username" | "password" | "notes";
|
||||
export type VaultAccessLevel = "read" | "write" | "admin";
|
||||
|
||||
type EntryDraft = {
|
||||
entryId?: string;
|
||||
title: string;
|
||||
url: string;
|
||||
username: string;
|
||||
password: string;
|
||||
notes: string;
|
||||
};
|
||||
|
||||
export type HrVaultDetailActions = {
|
||||
/** Reveal ONE field of ONE entry (audited server-side); resolves the plaintext. */
|
||||
onReveal: (entryId: string, field: VaultSecretField) => Promise<string | null>;
|
||||
onCreateEntry: (input: { title: string; url: string; username: string; password: string; notes: string }) => void;
|
||||
onCopy: (entryId: string, field: VaultSecretField) => Promise<string | null>;
|
||||
onCreateEntry: (input: Omit<EntryDraft, "entryId">) => void;
|
||||
onUpdateEntry: (input: EntryDraft & { entryId: string }) => void;
|
||||
onArchiveEntry: (entryId: string) => void;
|
||||
onRestoreEntry: (entryId: string) => void;
|
||||
onGrantAccess: (input: { targetUserId: string; permissionLevel: VaultAccessLevel }) => void;
|
||||
onRevokeAccess: (targetUserId: string) => void;
|
||||
onExport: () => Promise<boolean>;
|
||||
};
|
||||
|
||||
export type HrVaultDetailPageProps = {
|
||||
vm: VaultDetailVM;
|
||||
backHref: string;
|
||||
submitting: boolean;
|
||||
actionFeedback?: { status: "success" | "error"; messageKey: string } | null;
|
||||
actions: HrVaultDetailActions;
|
||||
};
|
||||
|
||||
/** One revealable secret field: reveal on demand, copy, wipe clipboard after the
|
||||
* VM-supplied window (30s). The value is held only in local component state. */
|
||||
function SecretField({
|
||||
entryId,
|
||||
field,
|
||||
labelKey,
|
||||
autoClearMs,
|
||||
onReveal,
|
||||
onCopy,
|
||||
}: {
|
||||
entryId: string;
|
||||
field: VaultSecretField;
|
||||
labelKey: string;
|
||||
autoClearMs: number;
|
||||
onReveal: HrVaultDetailActions["onReveal"];
|
||||
onCopy: HrVaultDetailActions["onCopy"];
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [value, setValue] = useState<string | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [copied, setCopied] = useState(false);
|
||||
const clearTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const [error, setError] = useState(false);
|
||||
const revealTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
const clipboardTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
useEffect(() => () => {
|
||||
if (clearTimer.current) clearTimeout(clearTimer.current);
|
||||
function hide() {
|
||||
setValue(null);
|
||||
if (revealTimer.current) clearTimeout(revealTimer.current);
|
||||
revealTimer.current = null;
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
const onVisibilityChange = () => {
|
||||
if (document.visibilityState === "hidden") hide();
|
||||
};
|
||||
document.addEventListener("visibilitychange", onVisibilityChange);
|
||||
return () => {
|
||||
document.removeEventListener("visibilitychange", onVisibilityChange);
|
||||
if (revealTimer.current) clearTimeout(revealTimer.current);
|
||||
if (clipboardTimer.current) clearTimeout(clipboardTimer.current);
|
||||
};
|
||||
}, []);
|
||||
|
||||
async function reveal() {
|
||||
setLoading(true);
|
||||
setError(false);
|
||||
try {
|
||||
setValue(await onReveal(entryId, field));
|
||||
const revealed = await onReveal(entryId, field);
|
||||
if (revealed == null) {
|
||||
setError(true);
|
||||
return;
|
||||
}
|
||||
setValue(revealed);
|
||||
if (revealTimer.current) clearTimeout(revealTimer.current);
|
||||
revealTimer.current = setTimeout(hide, autoClearMs);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleClipboardWipe() {
|
||||
setCopied(true);
|
||||
if (clearTimer.current) clearTimeout(clearTimer.current);
|
||||
clearTimer.current = setTimeout(() => {
|
||||
// Wipe the clipboard so a copied secret does not linger (DoD #3).
|
||||
void navigator.clipboard?.writeText("").catch(() => {});
|
||||
setCopied(false);
|
||||
}, autoClearMs);
|
||||
async function copy() {
|
||||
setLoading(true);
|
||||
setError(false);
|
||||
try {
|
||||
const copyValue = await onCopy(entryId, field);
|
||||
if (copyValue == null) {
|
||||
setError(true);
|
||||
return;
|
||||
}
|
||||
if (!navigator.clipboard) {
|
||||
setError(true);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await navigator.clipboard.writeText(copyValue);
|
||||
} catch {
|
||||
setError(true);
|
||||
return;
|
||||
}
|
||||
setCopied(true);
|
||||
if (clipboardTimer.current) clearTimeout(clipboardTimer.current);
|
||||
clipboardTimer.current = setTimeout(() => {
|
||||
void navigator.clipboard?.writeText("").catch(() => {});
|
||||
setCopied(false);
|
||||
}, autoClearMs);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-between gap-3" data-ui-id={`ui.hr.vault.field.${field}`}>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">{t(labelKey)}</span>
|
||||
{value === null ? (
|
||||
<Button variant="tertiary" size="small" loading={loading} onClick={reveal} data-ui-id="ui.hr.vault.reveal">
|
||||
{t("hr.passwordSafe.detail.reveal")}
|
||||
</Button>
|
||||
) : (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="font-mono text-body-default-regular-0 text-text-neutral-primary" data-ui-id="ui.hr.vault.revealed">
|
||||
{value}
|
||||
</span>
|
||||
<CopyToClipboardButton
|
||||
clipboardText={value}
|
||||
tooltipText={t("hr.passwordSafe.detail.copy")}
|
||||
onCopy={scheduleClipboardWipe}
|
||||
/>
|
||||
<Button variant="tertiary" size="small" onClick={() => setValue(null)}>
|
||||
<div className="border-border-default grid w-full gap-3 rounded-md border p-3 sm:grid-cols-[8rem_minmax(0,1fr)_auto]" data-ui-id={`ui.hr.vault.field.${field}`}>
|
||||
<span className="text-body-small-medium-150 text-text-neutral-secondary">{t(labelKey)}</span>
|
||||
<span className="text-body-default-regular-0 text-text-neutral-primary min-w-0 break-all font-mono" data-ui-id={value == null ? undefined : "ui.hr.vault.revealed"}>
|
||||
{value ?? t("hr.passwordSafe.detail.concealed")}
|
||||
</span>
|
||||
<div className="flex flex-wrap justify-end gap-2" data-ui-id="ui.hr.vault.fieldActions">
|
||||
{value == null ? (
|
||||
<Button variant="tertiary" size="small" loading={loading} onClick={reveal} aria-label={`${t(labelKey)}: ${t("hr.passwordSafe.detail.reveal")}`} data-ui-id="ui.hr.vault.reveal">
|
||||
{t("hr.passwordSafe.detail.reveal")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button variant="tertiary" size="small" onClick={hide} aria-label={`${t(labelKey)}: ${t("hr.passwordSafe.detail.hide")}`}>
|
||||
{t("hr.passwordSafe.detail.hide")}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{copied ? (
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-warning" data-ui-id="ui.hr.vault.copyHint">
|
||||
{t("hr.passwordSafe.detail.copyCleared")}
|
||||
</span>
|
||||
) : null}
|
||||
)}
|
||||
<Button variant="tertiary" size="small" loading={loading} onClick={copy} aria-label={`${t(labelKey)}: ${t("hr.passwordSafe.detail.copy")}`} data-ui-id="ui.hr.vault.copy">
|
||||
{t("hr.passwordSafe.detail.copy")}
|
||||
</Button>
|
||||
</div>
|
||||
<span className="text-body-small-regular-0 text-text-feedback-warning sm:col-start-2" aria-live="polite">
|
||||
{error
|
||||
? t("hr.passwordSafe.detail.secretActionFailed")
|
||||
: copied
|
||||
? t("hr.passwordSafe.detail.copyCleared")
|
||||
: value != null
|
||||
? t("hr.passwordSafe.detail.revealExpires")
|
||||
: ""}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -118,201 +174,379 @@ function EntryCard({
|
||||
autoClearMs,
|
||||
canWrite,
|
||||
submitting,
|
||||
onReveal,
|
||||
onArchive,
|
||||
actions,
|
||||
onEdit,
|
||||
}: {
|
||||
entry: EntryRow;
|
||||
autoClearMs: number;
|
||||
canWrite: boolean;
|
||||
submitting: boolean;
|
||||
onReveal: HrVaultDetailActions["onReveal"];
|
||||
onArchive: (entryId: string) => void;
|
||||
actions: HrVaultDetailActions;
|
||||
onEdit: (entry: EntryRow) => void;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card data-row-id={entry.id}>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{entry.title}</span>
|
||||
{entry.url ? (
|
||||
<a href={entry.url} target="_blank" rel="noreferrer" className="text-body-small-regular-0 font-body-small-regular-0 text-text-feedback-link-default">
|
||||
{entry.url}
|
||||
</a>
|
||||
) : null}
|
||||
{entry.tags.length > 0 ? (
|
||||
<div className="flex flex-wrap items-center gap-1">
|
||||
{entry.tags.map((tag) => (
|
||||
<Tag_Label key={tag} tone="neutral-subtle" size="small" noAction>
|
||||
{tag}
|
||||
</Tag_Label>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="flex w-full flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex min-w-0 flex-col gap-2">
|
||||
<span className="text-body-default-medium-0 text-text-neutral-primary">{entry.title}</span>
|
||||
{entry.url ? <a href={entry.url} target="_blank" rel="noreferrer" className="text-text-feedback-link-default break-all">{entry.url}</a> : null}
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{entry.tags.map((tag) => <Tag_Label key={tag} tone="neutral-subtle" size="small" noAction>{tag}</Tag_Label>)}
|
||||
</div>
|
||||
</div>
|
||||
{canWrite ? (
|
||||
<Button variant="tertiary" size="small" loading={submitting} onClick={() => onArchive(entry.id)} data-ui-id="ui.hr.vault.archiveEntry">
|
||||
{t("hr.passwordSafe.detail.archiveEntry")}
|
||||
</Button>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="tertiary" size="small" onClick={() => onEdit(entry)}>{t("hr.passwordSafe.detail.editEntry")}</Button>
|
||||
<Button
|
||||
icon={<FeatherArchive />}
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
loading={submitting}
|
||||
onClick={() => {
|
||||
if (window.confirm(t("hr.passwordSafe.confirm.archiveEntry", { title: entry.title }))) actions.onArchiveEntry(entry.id);
|
||||
}}
|
||||
>
|
||||
{t("hr.passwordSafe.detail.archiveEntry")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
{entry.hasUsername ? (
|
||||
<SecretField entryId={entry.id} field="username" labelKey="hr.passwordSafe.field.username" autoClearMs={autoClearMs} onReveal={onReveal} />
|
||||
) : null}
|
||||
{entry.hasPassword ? (
|
||||
<SecretField entryId={entry.id} field="password" labelKey="hr.passwordSafe.field.password" autoClearMs={autoClearMs} onReveal={onReveal} />
|
||||
) : null}
|
||||
{entry.hasNotes ? (
|
||||
<SecretField entryId={entry.id} field="notes" labelKey="hr.passwordSafe.field.notes" autoClearMs={autoClearMs} onReveal={onReveal} />
|
||||
) : null}
|
||||
{entry.hasUsername ? <SecretField entryId={entry.id} field="username" labelKey="hr.passwordSafe.field.username" autoClearMs={autoClearMs} onReveal={actions.onReveal} onCopy={actions.onCopy} /> : null}
|
||||
{entry.hasPassword ? <SecretField entryId={entry.id} field="password" labelKey="hr.passwordSafe.field.password" autoClearMs={autoClearMs} onReveal={actions.onReveal} onCopy={actions.onCopy} /> : null}
|
||||
{entry.hasNotes ? <SecretField entryId={entry.id} field="notes" labelKey="hr.passwordSafe.field.notes" autoClearMs={autoClearMs} onReveal={actions.onReveal} onCopy={actions.onCopy} /> : null}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export function HrVaultDetailPage({ vm, backHref, submitting, actions }: HrVaultDetailPageProps) {
|
||||
export function HrVaultDetailPage({ vm, submitting, actionFeedback, actions }: HrVaultDetailPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const [tab, setTab] = useState<"entries" | "access" | "activities">("entries");
|
||||
const [entryOpen, setEntryOpen] = useState(false);
|
||||
const [accessOpen, setAccessOpen] = useState(false);
|
||||
const [entry, setEntry] = useState({ title: "", url: "", username: "", password: "", notes: "" });
|
||||
const [exportOpen, setExportOpen] = useState(false);
|
||||
const [exporting, setExporting] = useState(false);
|
||||
const [exportStatus, setExportStatus] = useState<"success" | "error" | null>(null);
|
||||
const [entry, setEntry] = useState<EntryDraft>({ title: "", url: "", username: "", password: "", notes: "" });
|
||||
const [access, setAccess] = useState<{ targetUserId: string; permissionLevel: VaultAccessLevel }>({ targetUserId: "", permissionLevel: "read" });
|
||||
|
||||
if (vm.status !== "ready" || !vm.data) {
|
||||
return <div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.vault" />;
|
||||
return (
|
||||
<PageShell uiId="ui.hr.vault">
|
||||
<PageHeader
|
||||
icon={<FeatherLock className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("hr.passwordSafe.title")}
|
||||
subtitle={t("hr.passwordSafe.detail.subtitle")}
|
||||
subtitleTone="secondary"
|
||||
/>
|
||||
<PageBody>
|
||||
<EmptyState title={t(vm.status === "error" ? vm.error.messageKey : "hr.passwordSafe.loading")} body={t("hr.passwordSafe.loadingBody")} />
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
const { vaultName, rows, canWrite, canManageAccess, copyAutoClearMs, exportHref, emptyHeadlineKey, emptyBodyKey } = vm.data;
|
||||
const data = vm.data;
|
||||
const availableMembers = data.memberOptions.filter((member) => !member.hasAccess);
|
||||
const tabItems = ["entries", "access", "activities"] as const;
|
||||
|
||||
function submitEntry() {
|
||||
actions.onCreateEntry(entry);
|
||||
setEntryOpen(false);
|
||||
function resetEntry() {
|
||||
setEntry({ title: "", url: "", username: "", password: "", notes: "" });
|
||||
}
|
||||
function submitAccess() {
|
||||
actions.onGrantAccess(access);
|
||||
setAccessOpen(false);
|
||||
setAccess({ targetUserId: "", permissionLevel: "read" });
|
||||
|
||||
function submitEntry() {
|
||||
if (entry.entryId) actions.onUpdateEntry({ ...entry, entryId: entry.entryId });
|
||||
else actions.onCreateEntry(entry);
|
||||
setEntryOpen(false);
|
||||
resetEntry();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.vault">
|
||||
<Breadcrumbs>
|
||||
<a href={backHref} className="contents no-underline" data-ui-id="ui.hr.vault.back">
|
||||
<Breadcrumbs.Item>{t("hr.passwordSafe.detail.back")}</Breadcrumbs.Item>
|
||||
</a>
|
||||
<Breadcrumbs.Divider />
|
||||
<Breadcrumbs.Item active>{vaultName}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
|
||||
<div className="flex flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex flex-col gap-0">
|
||||
<span className="text-heading-2 font-heading-2 text-text-neutral-primary">{vaultName}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("hr.passwordSafe.detail.subtitle")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<a href={exportHref} className="contents no-underline" data-ui-id="ui.hr.vault.export">
|
||||
<LinkButton variant="subtle">{t("hr.passwordSafe.detail.export")}</LinkButton>
|
||||
</a>
|
||||
{canManageAccess ? (
|
||||
<Button variant="secondary" onClick={() => setAccessOpen(true)} data-ui-id="ui.hr.vault.manageAccess">
|
||||
{t("hr.passwordSafe.detail.manageAccess")}
|
||||
</Button>
|
||||
) : null}
|
||||
{canWrite ? (
|
||||
<Button icon={<FeatherPlus />} onClick={() => setEntryOpen(true)} data-ui-id="ui.hr.vault.newEntry">
|
||||
{t("hr.passwordSafe.detail.newEntry")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{rows.length === 0 ? (
|
||||
<div data-ui-id="ui.hr.vault.empty">
|
||||
<EmptyState title={t(emptyHeadlineKey)} body={t(emptyBodyKey)} />
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-4" data-ui-id="ui.hr.vault.entries">
|
||||
{rows.map((row) => (
|
||||
<EntryCard
|
||||
key={row.id}
|
||||
entry={row}
|
||||
autoClearMs={copyAutoClearMs}
|
||||
canWrite={canWrite}
|
||||
submitting={submitting}
|
||||
onReveal={actions.onReveal}
|
||||
onArchive={actions.onArchiveEntry}
|
||||
/>
|
||||
<PageShell uiId="ui.hr.vault">
|
||||
<PageHeader
|
||||
icon={<FeatherLock className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={data.vaultName}
|
||||
subtitle={t("hr.passwordSafe.detail.subtitle")}
|
||||
subtitleTone="secondary"
|
||||
actions={
|
||||
<>
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">{t(`hr.passwordSafe.access.${data.accessLevel}`)}</BadgeFeedback>
|
||||
{data.canExport ? <Button variant="secondary" onClick={() => setExportOpen(true)}>{t("hr.passwordSafe.detail.export")}</Button> : null}
|
||||
{data.canManageAccess ? <Button variant="secondary" onClick={() => setAccessOpen(true)}>{t("hr.passwordSafe.detail.manageAccess")}</Button> : null}
|
||||
{data.canWrite ? <Button icon={<FeatherPlus />} onClick={() => { resetEntry(); setEntryOpen(true); }}>{t("hr.passwordSafe.detail.newEntry")}</Button> : null}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
{actionFeedback ? (
|
||||
<Alert
|
||||
variant={actionFeedback.status}
|
||||
notDismissible
|
||||
title={t(actionFeedback.messageKey)}
|
||||
data-ui-id={`ui.hr.vault.feedback.${actionFeedback.status}`}
|
||||
/>
|
||||
) : null}
|
||||
{exportStatus ? (
|
||||
<Alert
|
||||
variant={exportStatus}
|
||||
notDismissible
|
||||
title={t(`hr.passwordSafe.export.${exportStatus}`)}
|
||||
data-ui-id={`ui.hr.vault.export.${exportStatus}`}
|
||||
/>
|
||||
) : null}
|
||||
<Tabs role="tablist" aria-label={t("hr.passwordSafe.tabs.label")}>
|
||||
{tabItems.map((item, index) => (
|
||||
<Tabs.Item
|
||||
key={item}
|
||||
id={`password-safe-tab-${item}`}
|
||||
active={tab === item}
|
||||
role="tab"
|
||||
tabIndex={tab === item ? 0 : -1}
|
||||
aria-selected={tab === item}
|
||||
aria-controls={`password-safe-panel-${item}`}
|
||||
onClick={() => setTab(item)}
|
||||
onKeyDown={(event) => {
|
||||
if (event.key === "Enter" || event.key === " ") {
|
||||
event.preventDefault();
|
||||
setTab(item);
|
||||
return;
|
||||
}
|
||||
if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
|
||||
event.preventDefault();
|
||||
const offset = event.key === "ArrowRight" ? 1 : -1;
|
||||
const nextIndex = (index + offset + tabItems.length) % tabItems.length;
|
||||
setTab(tabItems[nextIndex]);
|
||||
const tabs = event.currentTarget.parentElement?.querySelectorAll<HTMLElement>('[role="tab"]');
|
||||
tabs?.[nextIndex]?.focus();
|
||||
}}
|
||||
>
|
||||
{t(`hr.passwordSafe.tabs.${item}`)}
|
||||
</Tabs.Item>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Tabs>
|
||||
|
||||
{/* New entry dialog (canWrite) */}
|
||||
<Dialog open={entryOpen} onOpenChange={setEntryOpen}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.vault.createEntry">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.passwordSafe.detail.newEntry")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.passwordSafe.field.entryTitle")} showLabel fillContainer>
|
||||
<TextInput.Input value={entry.title} onChange={(e) => setEntry((s) => ({ ...s, title: e.target.value }))} data-ui-id="ui.hr.vault.createEntry.title" />
|
||||
{tab === "entries" ? (
|
||||
<section
|
||||
id="password-safe-panel-entries"
|
||||
className="flex w-full flex-col gap-4"
|
||||
role="tabpanel"
|
||||
aria-labelledby="password-safe-tab-entries"
|
||||
data-ui-id="ui.hr.vault.entries"
|
||||
>
|
||||
{data.rows.length === 0 && data.archivedRows.length === 0 ? (
|
||||
<EmptyState title={t(data.emptyHeadlineKey)} body={t(data.canWrite ? "hr.passwordSafe.entries.empty.writerBody" : data.emptyBodyKey)} />
|
||||
) : null}
|
||||
{data.rows.map((row) => (
|
||||
<EntryCard
|
||||
key={row.id}
|
||||
entry={row}
|
||||
autoClearMs={data.copyAutoClearMs}
|
||||
canWrite={data.canWrite}
|
||||
submitting={submitting}
|
||||
actions={actions}
|
||||
onEdit={(selected) => {
|
||||
setEntry({ entryId: selected.id, title: selected.title, url: selected.url ?? "", username: "", password: "", notes: "" });
|
||||
setEntryOpen(true);
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
{data.canWrite && data.archivedRows.length > 0 ? (
|
||||
<section className="bg-surface-neutral-secondary border-border-default flex flex-col gap-3 rounded-md border p-4">
|
||||
<h2 className="text-heading-3 text-text-neutral-primary">{t("hr.passwordSafe.detail.archivedEntries")}</h2>
|
||||
{data.archivedRows.map((row) => (
|
||||
<Card key={row.id} data-archived-row-id={row.id}>
|
||||
<div className="flex w-full items-center justify-between gap-3">
|
||||
<span>{row.title}</span>
|
||||
<Button icon={<FeatherRotateCcw />} variant="tertiary" size="small" onClick={() => actions.onRestoreEntry(row.id)} data-ui-id="ui.hr.vault.restoreEntry">
|
||||
{t("hr.passwordSafe.detail.restoreEntry")}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</section>
|
||||
) : null}
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{tab === "access" ? (
|
||||
<section
|
||||
id="password-safe-panel-access"
|
||||
className="flex w-full flex-col gap-3"
|
||||
role="tabpanel"
|
||||
aria-labelledby="password-safe-tab-access"
|
||||
data-ui-id="ui.hr.vault.access"
|
||||
>
|
||||
{!data.canManageAccess ? (
|
||||
<EmptyState title={t("hr.passwordSafe.accessDeniedTitle")} body={t("hr.passwordSafe.accessDeniedBody")} />
|
||||
) : data.accessRows.length === 0 ? (
|
||||
<EmptyState title={t("hr.passwordSafe.accessEmptyTitle")} body={t("hr.passwordSafe.accessEmptyBody")} />
|
||||
) : (
|
||||
data.accessRows.map((row) => (
|
||||
<Card key={row.userId}>
|
||||
<div className="flex w-full flex-wrap items-center justify-between gap-3">
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<span className="text-body-default-medium-0 text-text-neutral-primary">{row.displayName}</span>
|
||||
<span className="text-body-small-regular-0 text-text-neutral-secondary">{row.email}</span>
|
||||
<span className="text-body-small-regular-0 text-text-neutral-tertiary">{row.roleNames.join(", ") || t("hr.passwordSafe.noRole")}</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Select
|
||||
value={row.permissionLevel}
|
||||
highContrastText
|
||||
triggerAriaLabel={`${row.displayName}: ${t("hr.passwordSafe.field.permissionLevel")}`}
|
||||
onValueChange={(permissionLevel: string) =>
|
||||
actions.onGrantAccess({ targetUserId: row.userId, permissionLevel: permissionLevel as VaultAccessLevel })
|
||||
}
|
||||
>
|
||||
<Select.Item value="read">{t("hr.passwordSafe.access.read")}</Select.Item>
|
||||
<Select.Item value="write">{t("hr.passwordSafe.access.write")}</Select.Item>
|
||||
<Select.Item value="admin">{t("hr.passwordSafe.access.admin")}</Select.Item>
|
||||
</Select>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="small"
|
||||
onClick={() => {
|
||||
if (window.confirm(t("hr.passwordSafe.confirm.revokeAccess", { name: row.displayName }))) actions.onRevokeAccess(row.userId);
|
||||
}}
|
||||
>
|
||||
{t("hr.passwordSafe.revokeAccess")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))
|
||||
)}
|
||||
</section>
|
||||
) : null}
|
||||
|
||||
{tab === "activities" ? (
|
||||
<section
|
||||
id="password-safe-panel-activities"
|
||||
className="flex w-full flex-col gap-3"
|
||||
role="tabpanel"
|
||||
aria-labelledby="password-safe-tab-activities"
|
||||
data-ui-id="ui.hr.vault.activities"
|
||||
>
|
||||
{data.activityRows.length === 0 ? (
|
||||
<EmptyState title={t("hr.passwordSafe.activity.emptyTitle")} body={t("hr.passwordSafe.activity.emptyBody")} />
|
||||
) : (
|
||||
data.activityRows.map((activity) => (
|
||||
<Card key={activity.id}>
|
||||
<div className="flex w-full flex-wrap items-center justify-between gap-2">
|
||||
<span className="text-body-default-medium-0 text-text-neutral-primary">{t(activity.actionLabelKey)}</span>
|
||||
<span className="text-body-small-regular-0 text-text-neutral-secondary">{activity.actorLabel} · {activity.createdAtLabel}</span>
|
||||
</div>
|
||||
</Card>
|
||||
))
|
||||
)}
|
||||
</section>
|
||||
) : null}
|
||||
</PageBody>
|
||||
|
||||
<Dialog
|
||||
open={entryOpen}
|
||||
onOpenChange={setEntryOpen}
|
||||
title={t(entry.entryId ? "hr.passwordSafe.detail.editEntry" : "hr.passwordSafe.detail.newEntry")}
|
||||
>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.vault.entryDialog">
|
||||
<div className="flex flex-col gap-5 p-2">
|
||||
<h2 className="text-heading-3 text-text-neutral-primary">{t(entry.entryId ? "hr.passwordSafe.detail.editEntry" : "hr.passwordSafe.detail.newEntry")}</h2>
|
||||
{(["title", "url", "username", "password", "notes"] as const).map((field) => (
|
||||
<TextInput key={field} label={t(`hr.passwordSafe.field.${field === "title" ? "entryTitle" : field}`)} showLabel fillContainer>
|
||||
<TextInput.Input
|
||||
type={field === "password" ? "password" : "text"}
|
||||
value={entry[field]}
|
||||
onChange={(event) => setEntry((current) => ({ ...current, [field]: event.target.value }))}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.passwordSafe.field.url")} showLabel fillContainer>
|
||||
<TextInput.Input value={entry.url} onChange={(e) => setEntry((s) => ({ ...s, url: e.target.value }))} />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.passwordSafe.field.username")} showLabel fillContainer>
|
||||
<TextInput.Input value={entry.username} onChange={(e) => setEntry((s) => ({ ...s, username: e.target.value }))} />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.passwordSafe.field.password")} showLabel fillContainer type="password">
|
||||
<TextInput.Input type="password" value={entry.password} onChange={(e) => setEntry((s) => ({ ...s, password: e.target.value }))} />
|
||||
</TextInput>
|
||||
<TextInput label={t("hr.passwordSafe.field.notes")} showLabel fillContainer>
|
||||
<TextInput.Input value={entry.notes} onChange={(e) => setEntry((s) => ({ ...s, notes: e.target.value }))} />
|
||||
</TextInput>
|
||||
</div>
|
||||
))}
|
||||
{entry.entryId ? <p className="text-body-small-regular-0 text-text-neutral-secondary">{t("hr.passwordSafe.detail.editSecretsHint")}</p> : null}
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setEntryOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={entry.title.trim().length === 0} onClick={submitEntry} data-ui-id="ui.hr.vault.createEntry.submit">
|
||||
{t("hr.passwordSafe.detail.createEntry.submit")}
|
||||
</Button>
|
||||
<Button variant="neutral" onClick={() => setEntryOpen(false)}>{t("hr.action.cancel")}</Button>
|
||||
<Button loading={submitting} disabled={!entry.title.trim()} onClick={submitEntry}>{t("hr.action.save")}</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
{/* Grant access dialog (canManageAccess) */}
|
||||
<Dialog open={accessOpen} onOpenChange={setAccessOpen}>
|
||||
<Dialog open={accessOpen} onOpenChange={setAccessOpen} title={t("hr.passwordSafe.detail.manageAccess")}>
|
||||
<Dialog.Content className="w-full max-w-[560px] p-4" data-ui-id="ui.hr.vault.grantAccess">
|
||||
<div className="flex w-full flex-col gap-6 p-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("hr.passwordSafe.detail.manageAccess")}</span>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput label={t("hr.passwordSafe.field.targetUser")} showLabel fillContainer>
|
||||
<TextInput.Input value={access.targetUserId} onChange={(e) => setAccess((s) => ({ ...s, targetUserId: e.target.value }))} data-ui-id="ui.hr.vault.grantAccess.user" />
|
||||
</TextInput>
|
||||
<Select
|
||||
label={t("hr.passwordSafe.field.permissionLevel")}
|
||||
showLabel
|
||||
value={access.permissionLevel}
|
||||
onValueChange={(value: string) => setAccess((s) => ({ ...s, permissionLevel: value as VaultAccessLevel }))}
|
||||
>
|
||||
<Select.Item value="read">{t("hr.passwordSafe.access.read")}</Select.Item>
|
||||
<Select.Item value="write">{t("hr.passwordSafe.access.write")}</Select.Item>
|
||||
<Select.Item value="admin">{t("hr.passwordSafe.access.admin")}</Select.Item>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="flex flex-col gap-5 p-2">
|
||||
<h2 className="text-heading-3 text-text-neutral-primary">{t("hr.passwordSafe.detail.manageAccess")}</h2>
|
||||
<Select
|
||||
label={t("hr.passwordSafe.field.targetUser")}
|
||||
triggerAriaLabel={t("hr.passwordSafe.field.targetUser")}
|
||||
highContrastText
|
||||
showLabel
|
||||
value={access.targetUserId}
|
||||
onValueChange={(targetUserId: string) => setAccess((current) => ({ ...current, targetUserId }))}
|
||||
>
|
||||
{availableMembers.map((member) => (
|
||||
<Select.Item key={member.userId} value={member.userId}>{member.displayName} · {member.email} · {member.roleNames.join(", ") || t("hr.passwordSafe.noRole")}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
label={t("hr.passwordSafe.field.permissionLevel")}
|
||||
triggerAriaLabel={t("hr.passwordSafe.field.permissionLevel")}
|
||||
highContrastText
|
||||
showLabel
|
||||
value={access.permissionLevel}
|
||||
onValueChange={(permissionLevel: string) => setAccess((current) => ({ ...current, permissionLevel: permissionLevel as VaultAccessLevel }))}
|
||||
>
|
||||
<Select.Item value="read">{t("hr.passwordSafe.access.read")}</Select.Item>
|
||||
<Select.Item value="write">{t("hr.passwordSafe.access.write")}</Select.Item>
|
||||
<Select.Item value="admin">{t("hr.passwordSafe.access.admin")}</Select.Item>
|
||||
</Select>
|
||||
{availableMembers.length === 0 ? <p>{t("hr.passwordSafe.allMembersGranted")}</p> : null}
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setAccessOpen(false)}>
|
||||
{t("hr.action.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={access.targetUserId.trim().length === 0} onClick={submitAccess} data-ui-id="ui.hr.vault.grantAccess.submit">
|
||||
<Button variant="neutral" onClick={() => setAccessOpen(false)}>{t("hr.action.cancel")}</Button>
|
||||
<Button
|
||||
loading={submitting}
|
||||
disabled={!access.targetUserId}
|
||||
onClick={() => {
|
||||
actions.onGrantAccess(access);
|
||||
setAccessOpen(false);
|
||||
setAccess({ targetUserId: "", permissionLevel: "read" });
|
||||
}}
|
||||
>
|
||||
{t("hr.passwordSafe.detail.grantAccess.submit")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
|
||||
<Dialog open={exportOpen} onOpenChange={setExportOpen} title={t("hr.passwordSafe.export.title")}>
|
||||
<Dialog.Content className="w-full max-w-[520px] p-4" data-ui-id="ui.hr.vault.exportConfirm">
|
||||
<div className="flex flex-col gap-5 p-2">
|
||||
<h2 className="text-heading-3 text-text-neutral-primary">{t("hr.passwordSafe.export.title")}</h2>
|
||||
<p className="text-body-default-regular-0 text-text-neutral-secondary">{t("hr.passwordSafe.export.body")}</p>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={() => setExportOpen(false)}>{t("hr.action.cancel")}</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
loading={submitting || exporting}
|
||||
onClick={async () => {
|
||||
setExporting(true);
|
||||
setExportStatus(null);
|
||||
try {
|
||||
const exported = await actions.onExport();
|
||||
setExportStatus(exported ? "success" : "error");
|
||||
if (exported) setExportOpen(false);
|
||||
} finally {
|
||||
setExporting(false);
|
||||
}
|
||||
}}
|
||||
data-ui-id="ui.hr.vault.exportConfirm.submit"
|
||||
>
|
||||
{t("hr.passwordSafe.export.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`R-UX4 password manager interim visual baseline > captures list, entry detail and metadata-only admin at desktop/mobile breakpoints 1`] = `"<main data-ui-id="ui.passwords.interim.visualBaseline"><div class="flex w-full flex-col items-start" data-ui-id="ui.hr.passwordSafe"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">hr.passwordSafe.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">hr.passwordSafe.subtitle</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none bg-brand-brand-surface-solid-default px-4 py-2.5 text-left hover:bg-brand-brand-surface-solid-hover active:bg-brand-brand-surface-solid-active focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled" type="button" data-ui-id="ui.hr.passwordSafe.new"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">hr.passwordSafe.action.newVault</span></button></div></div><div class="group/f2cf6974 flex w-full flex-col items-start gap-2 bg-surface-neutral-secondary rounded-none border-b border-solid border-border-default px-6 py-2.5 mobile:rounded-none mobile:px-4" data-ui-id="ui.hr.passwordSafe.filter"><div class="flex w-full flex-wrap items-center gap-1"><div class="flex items-center gap-1.5"><span class="text-body-small-regular-150 font-body-small-regular-150 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><input class="subframe-text-input-control w-40 flex-none border-none bg-transparent px-0 py-0 text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary outline-none placeholder:text-text-neutral-subtle" placeholder="hr.passwordSafe.searchPlaceholder" data-ui-id="ui.hr.passwordSafe.filter.search" type="text" value=""></div><div class="flex h-5 w-px flex-none items-start bg-border-default"></div><div class="items-start contents"></div></div><div class="hidden w-full flex-wrap items-center gap-1.5 border-t border-solid border-border-default pt-2"><div class="items-start contents"></div></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3" data-ui-id="ui.hr.passwordSafe.list"><a class="group/vault min-w-0 no-underline" data-row-id="vault-1" href="/acme/passwords/vault-1" data-discover="true"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm group-hover/vault:border-border-strong group-focus-visible/vault:shadow-focus h-full min-h-40 transition-[border-color,box-shadow,transform] duration-200 group-hover/vault:-translate-y-0.5 group-hover/vault:shadow-md"><div class="flex w-full items-start gap-4"><span class="bg-brand-brand-surface-subtle-default text-icon-brand-primary flex size-10 shrink-0 items-center justify-center rounded-md" aria-hidden="true"><span class="size-5 icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="flex min-w-0 grow flex-col gap-2"><span class="text-body-large-medium-0 font-body-large-medium-0 text-text-neutral-primary truncate">Betrieb</span><span class="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary line-clamp-2">Geteilte Zugangsdaten</span></div><span class="text-icon-neutral-tertiary group-hover/vault:text-icon-neutral-primaLine truncated
|
||||
|
||||
exports[`R-UX4 password manager interim visual baseline > captures loading, not-ready, empty, permission and action feedback states 1`] = `"<main data-ui-id="ui.passwords.interim.stateBaseline"><div class="flex w-full flex-col items-start" data-ui-id="ui.hr.passwordSafe"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">hr.passwordSafe.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">hr.passwordSafe.subtitle</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div data-ui-id="ui.hr.passwordSafe.notReady"><div class="group/9fcf03a9 flex w-full items-center justify-center gap-4 px-4 py-8"><div class="flex w-full max-w-[384px] flex-col items-center gap-6"><div class="flex flex-col items-center gap-7"><img class="h-12 w-12 flex-none object-cover" alt="" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiBjbGFzcz0iZmxleC1ub25lIiBkYXRhLW5vZGUtaWQ9IjM3YmE4ZTQ2Ij48cGF0aCBkPSJNMzcuNSAyMVYzNy42NjY3QzM3LjUgMzguMDIwMyAzNy4zNTk1IDM4LjM1OTQgMzcuMTA5NSAzOC42MDk1QzM2Ljg1OTQgMzguODU5NSAzNi41MjAzIDM5IDM2LjE2NjcgMzlINy41QzcuMTAyMTggMzkgNi43MjA2NCAzOC44NDIgNi40MzkzNCAzOC41NjA3QzYuMTU4MDQgMzguMjc5NCA2IDM3Ljg5NzggNiAzNy41VjE2LjVDNiAxNi4xMDIyIDYuMTU4MDQgMTUuNzIwNiA2LjQzOTM0IDE1LjQzOTNDNi43MjA2NCAxNS4xNTggNy4xMDIxOCAxNSA3LjUgMTVIMTZDMTYuMzI0NiAxNSAxNi42NDA0IDE1LjEwNTMgMTYuOSAxNS4zTDIyLjEgMTkuMkMyMi4zNTk2IDE5LjM5NDcgMjIuNjc1NCAxOS41IDIzIDE5LjVIMzZDMzYuMzk3OCAxOS41IDM2Ljc3OTQgMTkuNjU4IDM3LjA2MDcgMTkuOTM5M0MzNy4zNDIgMjAuMjIwNiAzNy41IDIwLjYwMjIgMzcuNSAyMVoiIHN0cm9rZT0iIzg1ODU4OSIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgZGF0YS1ub2RlLWlkPSI4MzBkNDBlZi05N2E3LTRjMjYtODQwZi0yNDQzMTEwNjYwMjgiPjwvcGF0aD48cGF0aCBkPSJNMTIgMTVWMTAuNUMxMiAxMC4xMDIyIDEyLjE1OCA5LjcyMDY0IDEyLjQzOTMgOS40MzkzNEMxMi43MjA2IDkuMTU4MDQgMTMuMTAyMiA5IDEzLjUgOUgyMkMyMi4zMjQ2IDkgMjIuNjQwNCA5LjEwNTI3IDIyLjkgOS4zTDI4LjEgMTMuMkMyOC4zNTk2IDEzLjM5NDcgMjguNjc1NCAxMy41IDI5IDEzLjVINDJDNDIuMzk3OCAxMy41IDQyLjc3OTQgMTMuNjU4IDQzLjA2MDcgMTMuOTM5M0M0My4zNDIgMTQuMjIwNiA0My41IDE0LjYwMjIgNDMuNSAxNVYzMS42NjY3QzQzLjUgMzEuODQxOCA0My40NjU1IDMyLjAxNTEgNDMuMzk4NSAzMi4xNzY5QzQzLjMzMTUgMzIuMzM4NyA0My4yMzMzIDMyLjQ4NTcgNDMuMTA5NSAzMi42MDk1QzQyLjk4NTcgMzIuNzMzMyA0Mi44Mzg3IDMyLjgzMTUgNDIuNjc2OSAzMi44OTg1QzQyLjUxNTEgMzIuOTY1NSA0Mi4zNDE4IDMzIDQyLjE2NjcgMzNIMzcuNSIgc3Ryb2tlPSIjODU4NTg5IiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBkYXRhLW5vZGUtaWQ9IjJiZDUxMmE0LWI3YzQtNDg5MS05N2NmLTliNjkyZTc1MTNkMSI+PC9wYXRoPjwvc3ZnPg=="><img class="hidden h-12 w-12 flex-none object-cover" alt="" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMjEuNzUgMzcuNUMzMC40NDg1IDM3LjUgMzcuNSAzMC40NDg1IDM3LjUgMjEuNzVDMzcuNSAxMy4wNTE1IDMwLjQ0ODUgNiAyMS43NSA2QzEzLjA1MTUgNiA2IDEzLjA1MTUgNiAyMS43NUM2IDMwLjQ0ODUgMTMuMDUxNSAzNy41IDIxLjc1IDM3LjVaIiBzdHJva2U9IiM4NTg1ODkiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+PHBhdGggZD0iTTMyLjg4NjMgMzIuODg2N0w0MS45OTg5IDQxLjk5OTMiIHN0cm9rZT0iIzg1ODU4OSIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz48L3N2Zz4="><img class="hidden h-12 w-12 flex-none object-cover" alt="" src="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cGF0aCBkPSJNMjQgMTkuNVYyNyIgc3Ryb2tlPSIjQzUyMDIwIiBzdHJva2Utd2lkdGg9IjIiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIvPjxwYXRoIGQ9Ik0yMS40MDM2IDcuNDk3MTNMNC45MDgwNCAzNS45OTU3QzQuNjQ0MDkgMzYuNDUxNyA0LjUwNDg5IDM2Ljk2OTIgNC41MDQ0NiAzNy40OTYxQzQuNTA0MDIgMzguMDIzIDQuNjQyMzYgMzguNTQwNyA0LjkwNTU1IDM4Ljk5NzFDNS4xNjg3NSAzOS40NTM2IDUuNTQ3NTEgMzkuODMyNyA2LjAwMzc0IDQwLjA5NjJDNi40NTk5NyA0MC4zNTk4IDYuOTc3NTcgNDAuNDk4NiA3LjUwNDQ3IDQwLjQ5ODZINDAuNDk1NkM0MS4wMjI0IDQwLjQ5ODYgNDEuNTQgNDAuMzU5OCA0MS45OTYzIDQwLjA5NjJDNDIuNDUyNSAzOS44MzI3IDQyLjgzMTMgMzkuNDUzNiA0My4wOTQ1IDM4Ljk5NzFDNDMuMzU3NyAzOC41NDA3IDQzLjQ5NiAzOC4wMjMgNDMuNDk1NiAzNy40OTYxQzQzLjQ5NTEgMzYuOTY5MiA0My4zNTU5IDM2LjQ1MTcgNDMuMDkyIDM1Ljk5NTdMMjYuNTk2NCA3LjQ5NzEzQzI2LjMzMjkgNy4wNDE4NSAyNS45NTQzIDYuNjYzODcgMjUuNDk4NiA2LjQwMTFDMjUuMDQyOSA2LjEzODMyIDI0LjUyNjEgNiAyNCA2QzIzLjQ3NCA2IDIyLjk1NzIgNi4xMzgzMiAyMi41MDE0IDYuNDAxMUMyMi4wNDU3IDYuNjYzODcgMjEuNjY3MSA3LjA0MTg1IDIxLjQwMzYgNy40OTcxM1Y3LjQ5NzEzWiIgc3Ryb2tLine truncated
|
||||
|
||||
exports[`R-UX4 password manager interim visual baseline > captures named access, redacted activity and confirmed export states 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.hr.vault"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">Betrieb</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">hr.passwordSafe.detail.subtitle</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><div class="group/896531e4 flex items-center gap-2 rounded-round px-2.5 h-5 py-0.5 bg-surface-feedback-subtle-neutral"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-neutral-on-subtle"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-on-subtle">hr.passwordSafe.access.admin</span></div><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-brand-brand-secondary-surface-subtle-default hover:bg-brand-brand-secondary-surface-subtle-hover active:bg-brand-brand-secondary-surface-subtle-active" type="button"><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">hr.passwordSafe.detail.export</span></button><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-brand-brand-secondary-surface-subtle-default hover:bg-brand-brand-secondary-surface-subtle-hover active:bg-brand-brand-secondary-surface-subtle-active" type="button"><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">hr.passwordSafe.detail.manageAccess</span></button><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none bg-brand-brand-surface-solid-default px-4 py-2.5 text-left hover:bg-brand-brand-surface-solid-hover active:bg-brand-brand-surface-solid-active focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 fLine truncated
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`R-UX3 personnel interim visual baseline > captures employee and HR task hubs for desktop/mobile breakpoints 1`] = `"<main data-ui-id="ui.hr.personnel.visualBaseline"><div class="flex w-full flex-col items-start" data-ui-id="ui.hr.hub"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">hr.hub.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">hr.hub.subtitle</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><div class="group/896531e4 flex items-center gap-2 rounded-round px-2.5 h-5 py-0.5 bg-surface-feedback-subtle-warning"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-warning"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-on-subtle">hr.hub.openCount:3</span></div></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><section class="flex w-full flex-col gap-4" aria-labelledby="hr-hub-priority" data-ui-id="ui.hr.hub.priority"><div class="flex flex-col gap-1"><h2 id="hr-hub-priority" class="text-heading-3 font-heading-3 text-text-neutral-primary">hr.hub.priority.title</h2><p class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">hr.hub.priority.body</p></div><div class="grid grid-cols-1 gap-4 sm:grid-cols-2"><a href="/acme/hr/sick" class="group/item min-w-0 no-underline" data-row-id="sick" data-ui-id="ui.hr.hub.item.sick"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex min-h-28 w-full items-start justify-between gap-4"><div class="flex min-w-0 grow flex-col gap-2"><div class="flex flex-wrap items-center gap-2"><span class="text-body-large-medium-0 font-body-large-medium-0 text-text-neutral-primary">hr.hub.item.sick.label</span></div><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">hr.hub.item.sick.description</span></div><span class="mt-1 shrink-0 text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary transition-transform group-hover/item:translate-x-0.5 icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span></div></div></a><a href="/acme/hr/leave" class="group/item min-w-0 no-underline" data-row-id="leave" data-ui-id="ui.hr.hub.item.leave"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex min-h-28 w-full items-start justify-between gap-4"><div class="flex min-w-0 grow flex-col gap-2"><div class="flex flex-wrap items-center gap-2"><span class="text-body-large-medium-0 font-body-large-medium-0 text-text-neutral-primary">hr.hub.item.leave.label</span><div class="group/896531e4 flex items-center gap-2 rounded-round px-2.5 h-5 py-0.5 bg-surface-feedback-subtle-warning"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-warning"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-on-subtle">hr.hub.openCount:1</span></div></div><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">hr.hub.item.leave.description</span></div><span class="mt-1 shrink-0 text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary transition-transform group-hover/item:translate-x-0.5 icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span></div></div></a></div></section><section class="flex w-full flex-col gap-4" aria-labelledby="hr-hub-forMe" data-ui-id="ui.hr.hub.section.forMe"><div class="flex items-start gap-3"><span class="mt-0.5 text-heading-3 font-heading-3 text-icon-brand-primary"><span class="icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span></span><div class="flex min-w-0 grow flex-col gap-1"><div class="flex flex-wrap items-center gap-2"><h2 id="hr-hub-forMe" class="text-heading-3 font-heading-3 text-text-neutral-primary">hr.hub.section.forMe.label</h2><div class="group/896531e4 flex items-center gap-2 rounded-round px-2.5 h-5 py-0.5 bg-surface-feedback-subtle-warning"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-warning"></div><span class="whitespace-nowrap Line truncated
|
||||
|
||||
exports[`R-UX3 personnel interim visual baseline > captures named payslip upload, matching, loading, empty and error states 1`] = `"<div class="flex w-full flex-col gap-6 p-6" data-ui-id="ui.hr.admin.payslips"><div class="flex flex-col gap-0"><span class="text-heading-2 font-heading-2 text-text-neutral-primary">hr.payslips.admin.title</span><span class="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">hr.payslips.admin.subtitle</span></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full flex-col gap-4" data-ui-id="ui.hr.admin.payslips.match"><div class="flex flex-wrap gap-4"><label class="group/be48ca43 flex h-full w-full min-w-[192px] max-w-[320px] cursor-pointer flex-col items-start justify-center gap-4"><div class="flex-col items-start gap-3 flex"><span class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">hr.payslips.field.year</span></div><div class="flex h-9 w-full min-w-[80px] flex-none items-center gap-2 rounded-sm border border-solid border-border-strong bg-surface-neutral-primary px-3 group-hover/be48ca43:border group-hover/be48ca43:border-solid group-hover/be48ca43:border-brand-brand-border-solid-hover group-hover/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:shadow-focus"><div class="flex grow shrink-0 basis-0 items-center self-stretch"><div class="hidden items-center gap-2 pr-2"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div><div class="flex grow shrink-0 basis-0 flex-col items-start self-stretch"><input class="group/b0d608f7 subframe-text-input-control h-full w-full border-none bg-transparent px-0 py-0 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary outline-none placeholder:text-text-neutral-subtle" style="box-shadow: none;" type="number" value=""></div><div class="hidden items-center gap-1 pl-2"></div></div><div class="group/39db4fac h-5 w-5 cursor-pointer flex-col items-center justify-center gap-4 hidden"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-primary group-hover/39db4fac:text-body-large-0 group-hover/39db4fac:font-body-large-0 group-active/39db4fac:text-body-default-regular-0 group-active/39db4fac:font-body-default-regular-0 icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></label><label class="group/be48ca43 flex h-full w-full min-w-[192px] max-w-[320px] cursor-pointer flex-col items-start justify-center gap-4"><div class="flex-col items-start gap-3 flex"><span class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">hr.payslips.field.month</span></div><div class="flex h-9 w-full min-w-[80px] flex-none items-center gap-2 rounded-sm border border-solid border-border-strong bg-surface-neutral-primary px-3 group-hover/be48ca43:border group-hover/be48ca43:border-solid group-hover/be48ca43:border-brand-brand-border-solid-hover group-hover/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:shadow-focus"><div class="flex grow shrink-0 basis-0 items-center self-stretch"><div class="hidden items-center gap-2 pr-2"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div><div class="flex grow shrink-0 basis-0 flex-col items-start self-stretch"><input class="group/b0d608f7 subframe-text-input-control h-full w-full border-none bg-transparent px-0 py-0 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary outline-none placeholder:text-text-neutral-subtle" style="box-shadow: none;" type="number" value=""></div><div class="hidden items-center gap-1 pl-2"></div></div><div class="group/39db4fac h-5 w-5 cursor-pointer flex-col items-center justify-center gap-4 hidden"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-primary group-hover/39db4fac:text-body-large-0 group-hover/39db4fac:font-body-large-0 group-active/39db4fac:text-body-default-regular-0 group-active/39db4fac:font-body-default-regular-0 icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></label></div><label class="flex flex-col gap-1"><span class="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">hr.payslips.field.filesHint</span><input accept="application/pdf,.pdf" multiple="" class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary file:mr-3 file:rounded-[4px] file:border file:border-solid file:border-border-default filLine truncated
|
||||
+174
@@ -0,0 +1,174 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
buildAdminVaultListVM,
|
||||
buildVaultDetailVM,
|
||||
buildVaultListVM,
|
||||
type AdminVaultListVM,
|
||||
type VaultDetailVM,
|
||||
type VaultListVM,
|
||||
} from "@hivegrid/view-models";
|
||||
import { HrAdminPasswordSafePage } from "./HrAdminPasswordSafePage";
|
||||
import { HrPasswordSafeListPage } from "./HrPasswordSafeListPage";
|
||||
import { HrVaultDetailPage, type HrVaultDetailActions } from "./HrVaultDetailPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) => (values ? `${key}:${Object.values(values).join("/")}` : key),
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
const actions: HrVaultDetailActions = {
|
||||
onReveal: vi.fn(async () => "short-lived"),
|
||||
onCopy: vi.fn(async () => "short-lived"),
|
||||
onCreateEntry: vi.fn(),
|
||||
onUpdateEntry: vi.fn(),
|
||||
onArchiveEntry: vi.fn(),
|
||||
onRestoreEntry: vi.fn(),
|
||||
onGrantAccess: vi.fn(),
|
||||
onRevokeAccess: vi.fn(),
|
||||
onExport: vi.fn(async () => true),
|
||||
};
|
||||
|
||||
function detailVm() {
|
||||
return buildVaultDetailVM({
|
||||
vaultId: "vault-1",
|
||||
vaultName: "Betrieb",
|
||||
accessLevel: "admin",
|
||||
canExport: true,
|
||||
exportHref: "/acme/passwords/vault-1/export",
|
||||
rows: [{
|
||||
id: "entry-1",
|
||||
title: "Router",
|
||||
tags: ["Netzwerk"],
|
||||
url: "https://router.example.test",
|
||||
hasUsername: true,
|
||||
hasPassword: true,
|
||||
hasNotes: false,
|
||||
revealHref: "/acme/passwords/vault-1/reveal",
|
||||
}],
|
||||
accessRows: [{
|
||||
userId: "user-1",
|
||||
displayName: "Raffael Beispiel",
|
||||
email: "raffael@example.test",
|
||||
roleNames: ["Admin"],
|
||||
permissionLevel: "admin",
|
||||
}],
|
||||
memberOptions: [{
|
||||
userId: "user-2",
|
||||
displayName: "Mira Beispiel",
|
||||
email: "mira@example.test",
|
||||
roleNames: ["Mitarbeitende"],
|
||||
hasAccess: false,
|
||||
}],
|
||||
activityRows: [{
|
||||
id: "activity-1",
|
||||
createdAtLabel: "25.07.26, 10:30",
|
||||
actionLabelKey: "hr.passwordSafe.activity.entry_create",
|
||||
actorLabel: "Raffael Beispiel",
|
||||
successful: true,
|
||||
}],
|
||||
});
|
||||
}
|
||||
|
||||
function stableMarkup(markup: string): string {
|
||||
return markup.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
}
|
||||
|
||||
describe("R-UX4 password manager interim visual baseline", () => {
|
||||
it("captures list, entry detail and metadata-only admin at desktop/mobile breakpoints", () => {
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<main data-ui-id="ui.passwords.interim.visualBaseline">
|
||||
<HrPasswordSafeListPage
|
||||
vm={buildVaultListVM({
|
||||
canCreate: true,
|
||||
createHref: "/acme/passwords",
|
||||
searchQuery: "",
|
||||
rows: [{ id: "vault-1", name: "Betrieb", description: "Geteilte Zugangsdaten", accessLevel: "admin", detailHref: "/acme/passwords/vault-1" }],
|
||||
})}
|
||||
submitting={false}
|
||||
actions={{ onCreateVault: vi.fn(), onSearch: vi.fn() }}
|
||||
/>
|
||||
<HrVaultDetailPage vm={detailVm()} submitting={false} actions={actions} />
|
||||
<HrAdminPasswordSafePage
|
||||
vm={buildAdminVaultListVM({
|
||||
rows: [
|
||||
{ id: "vault-1", name: "Betrieb", entryCount: 1, accessCount: 1, archived: false, detailHref: "/acme/passwords/vault-1" },
|
||||
{ id: "vault-2", name: "Nur Metadaten", entryCount: 3, accessCount: 2, archived: false, detailHref: null },
|
||||
],
|
||||
activityRows: [],
|
||||
})}
|
||||
submitting={false}
|
||||
actions={{ onArchiveVault: vi.fn(), onRestoreVault: vi.fn(), onSearch: vi.fn() }}
|
||||
/>
|
||||
</main>
|
||||
</MemoryRouter>
|
||||
);
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.passwordSafe.list']")).toBeInTheDocument();
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.vault.entries']")).toBeInTheDocument();
|
||||
expect(screen.queryByRole("link", { name: "Nur Metadaten" })).not.toBeInTheDocument();
|
||||
expect(stableMarkup(container.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("captures named access, redacted activity and confirmed export states", () => {
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<HrVaultDetailPage vm={detailVm()} submitting={false} actions={actions} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
fireEvent.click(screen.getByRole("tab", { name: "hr.passwordSafe.tabs.access" }));
|
||||
expect(screen.getByText("Raffael Beispiel")).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("tab", { name: "hr.passwordSafe.tabs.activities" }));
|
||||
expect(screen.getByText("hr.passwordSafe.activity.entry_create")).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: "hr.passwordSafe.detail.export" }));
|
||||
expect(document.querySelector("[data-ui-id='ui.hr.vault.exportConfirm']")).toBeInTheDocument();
|
||||
expect(stableMarkup(`${container.innerHTML}${document.body.innerHTML}`)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("captures loading, not-ready, empty, permission and action feedback states", () => {
|
||||
const loadingList: VaultListVM = { status: "loading" };
|
||||
const errorList: VaultListVM = { status: "error", error: { messageKey: "hr.passwordSafe.notReady" } };
|
||||
const loadingAdmin: AdminVaultListVM = { status: "loading" };
|
||||
const readOnlyEmptyDetail: VaultDetailVM = buildVaultDetailVM({
|
||||
vaultId: "vault-read",
|
||||
vaultName: "Lesetresor",
|
||||
accessLevel: "read",
|
||||
exportHref: "/acme/passwords/vault-read/export",
|
||||
rows: [],
|
||||
});
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<main data-ui-id="ui.passwords.interim.stateBaseline">
|
||||
<HrPasswordSafeListPage vm={loadingList} submitting={false} actions={{ onCreateVault: vi.fn(), onSearch: vi.fn() }} />
|
||||
<HrPasswordSafeListPage vm={errorList} submitting={false} actions={{ onCreateVault: vi.fn(), onSearch: vi.fn() }} />
|
||||
<HrPasswordSafeListPage
|
||||
vm={buildVaultListVM({ rows: [], canCreate: false, createHref: "/acme/passwords" })}
|
||||
submitting={false}
|
||||
actionFeedback={{ status: "success", messageKey: "hr.passwordSafe.feedback.vaultCreated" }}
|
||||
actions={{ onCreateVault: vi.fn(), onSearch: vi.fn() }}
|
||||
/>
|
||||
<HrVaultDetailPage
|
||||
vm={readOnlyEmptyDetail}
|
||||
submitting={false}
|
||||
actionFeedback={{ status: "error", messageKey: "hr.error.lastVaultAdmin" }}
|
||||
actions={actions}
|
||||
/>
|
||||
<HrAdminPasswordSafePage
|
||||
vm={loadingAdmin}
|
||||
submitting={false}
|
||||
actions={{ onArchiveVault: vi.fn(), onRestoreVault: vi.fn(), onSearch: vi.fn() }}
|
||||
/>
|
||||
</main>
|
||||
</MemoryRouter>
|
||||
);
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.passwordSafe.notReady']")).toBeInTheDocument();
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.passwordSafe.empty']")).toBeInTheDocument();
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.vault.feedback.error']")).toBeInTheDocument();
|
||||
expect(stableMarkup(container.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+130
@@ -0,0 +1,130 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { buildHrHubVM, type HrHubHrefs } from "@hivegrid/view-models";
|
||||
import { HrAdminPayslipsPage } from "./HrAdminPayslipsPage";
|
||||
import { HrHubPage } from "./HrHubPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) =>
|
||||
values ? `${key}:${Object.values(values).join("/")}` : key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
const hubIds = [
|
||||
"leave",
|
||||
"sick",
|
||||
"documents",
|
||||
"payslips",
|
||||
"announcements",
|
||||
"requests",
|
||||
"surveys",
|
||||
"teamDirectory",
|
||||
"teamLeave",
|
||||
"leaveApprovals",
|
||||
"requestApprovals",
|
||||
"directory",
|
||||
"locations",
|
||||
"announcementAdmin",
|
||||
"payslipAdmin",
|
||||
"requestTemplates",
|
||||
"uploadReminders",
|
||||
"surveyAdmin",
|
||||
] as const;
|
||||
const hrefs = Object.fromEntries(
|
||||
hubIds.map((id) => [id, `/acme/hr/${id}`]),
|
||||
) as HrHubHrefs;
|
||||
|
||||
function hubVm(admin: boolean) {
|
||||
return buildHrHubVM({
|
||||
moduleActive: true,
|
||||
hrefs,
|
||||
counts: {
|
||||
ownLeave: 1,
|
||||
ownSick: 0,
|
||||
ownRequests: 2,
|
||||
pendingLeaveApprovals: admin ? 3 : 0,
|
||||
pendingRequestApprovals: admin ? 1 : 0,
|
||||
visibleTeamMembers: admin ? 8 : 0,
|
||||
},
|
||||
capabilities: {
|
||||
canReadAll: admin,
|
||||
canWrite: admin,
|
||||
canApproveLeave: admin,
|
||||
canViewSurveyResults: admin,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function stableMarkup(markup: string): string {
|
||||
return markup.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>',
|
||||
);
|
||||
}
|
||||
|
||||
describe("R-UX3 personnel interim visual baseline", () => {
|
||||
it("captures employee and HR task hubs for desktop/mobile breakpoints", () => {
|
||||
const { container } = render(
|
||||
<main data-ui-id="ui.hr.personnel.visualBaseline">
|
||||
<HrHubPage vm={hubVm(false)} />
|
||||
<HrHubPage vm={hubVm(true)} />
|
||||
</main>,
|
||||
);
|
||||
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.hub.section.forMe']")).toBeInTheDocument();
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.hub.section.myTeam']")).toBeInTheDocument();
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.hub.section.administration']")).toBeInTheDocument();
|
||||
expect(container.textContent).not.toContain("password");
|
||||
expect(stableMarkup(container.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("captures named payslip upload, matching, loading, empty and error states", () => {
|
||||
const { container } = render(
|
||||
<HrAdminPayslipsPage
|
||||
rows={[
|
||||
{
|
||||
id: "payslip-1",
|
||||
employeeLabel: "Mira Muster",
|
||||
periodLabel: "2026-07",
|
||||
isRead: false,
|
||||
},
|
||||
]}
|
||||
preview={[
|
||||
{
|
||||
fileId: "opaque-file-id",
|
||||
fileName: "2026-07-Mira-Muster.pdf",
|
||||
confidence: "hard",
|
||||
confidenceKey: "hr.payslips.match.confidence.hard",
|
||||
confidenceTone: "success",
|
||||
employeeUserId: "opaque-user-id",
|
||||
employeeLabel: "Mira Muster",
|
||||
},
|
||||
]}
|
||||
memberOptions={[
|
||||
{
|
||||
userId: "opaque-user-id",
|
||||
displayName: "Mira Muster",
|
||||
team: "Montage",
|
||||
roleNames: ["Mitarbeitende"],
|
||||
},
|
||||
]}
|
||||
period={{ year: "2026", month: "7" }}
|
||||
submitting
|
||||
errorKey="hr.payslips.upload.rejected"
|
||||
feedbackKey="hr.payslips.upload.checked"
|
||||
actions={{ onMatch: vi.fn(), onConfirm: vi.fn() }}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.admin.payslips.files']")).toHaveAttribute("multiple");
|
||||
expect(container.querySelector("[data-ui-id='ui.hr.admin.payslips.error']")).toBeInTheDocument();
|
||||
expect(container.textContent).toContain("Mira Muster");
|
||||
expect(container.textContent).not.toContain("opaque-user-id");
|
||||
expect(container.textContent).not.toContain("opaque-file-id");
|
||||
expect(stableMarkup(container.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user