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
+53
@@ -0,0 +1,53 @@
|
||||
// Guards the contract the Gruppen tab relies on after "Gruppe erstellen" moved
|
||||
// from a slide-over sub-page into a popup: the dialog reports name, description,
|
||||
// colour and the picked members, and it defaults to a real colour — the old
|
||||
// slide-over let an empty select post NaN into the group's colour column.
|
||||
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { Colors } from "~/application/enums/shared/Colors";
|
||||
import { GroupNewDialog, type GroupNewInput } from "./GroupNewDialog";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (s: string) => s, i18n: { language: "de" } }),
|
||||
}));
|
||||
|
||||
const CANDIDATES = [
|
||||
{ userId: "u1", name: "Birgit Büro", email: "buero@hivegrid.de" },
|
||||
{ userId: "u2", name: "Murat Monteur", email: "monteur@hivegrid.de" },
|
||||
];
|
||||
|
||||
function renderDialog() {
|
||||
const onCreate = vi.fn<(input: GroupNewInput) => void>();
|
||||
render(<GroupNewDialog open onOpenChange={() => undefined} candidates={CANDIDATES} submitting={false} onCreate={onCreate} />);
|
||||
return { onCreate };
|
||||
}
|
||||
|
||||
function submitButton(): HTMLButtonElement {
|
||||
return document.querySelector("[data-ui-id='ui.settings.groups.newDialog.submit']") as HTMLButtonElement;
|
||||
}
|
||||
|
||||
describe("GroupNewDialog", () => {
|
||||
it("reports name, description, default colour and the picked members", () => {
|
||||
const { onCreate } = renderDialog();
|
||||
fireEvent.change(screen.getByLabelText("models.group.name"), { target: { value: " Montage Nord " } });
|
||||
fireEvent.change(screen.getByLabelText("models.group.description"), { target: { value: " Team Nord " } });
|
||||
fireEvent.click(screen.getByText("Murat Monteur"));
|
||||
fireEvent.click(submitButton());
|
||||
|
||||
expect(onCreate).toHaveBeenCalledWith({
|
||||
name: "Montage Nord",
|
||||
description: "Team Nord",
|
||||
color: Colors.BLUE,
|
||||
userIds: ["u2"],
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the submit disabled without a name", () => {
|
||||
renderDialog();
|
||||
expect(submitButton()).toBeDisabled();
|
||||
fireEvent.change(screen.getByLabelText("models.group.name"), { target: { value: "Montage Nord" } });
|
||||
expect(submitButton()).not.toBeDisabled();
|
||||
});
|
||||
});
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
// "Gruppe erstellen" as a popup on the Gruppen tab, replacing the slide-over
|
||||
// sub-page that still wore the old boilerplate form controls (FormGroup,
|
||||
// InputText, InputSelector). Same chrome as every other form popup (FormDialog)
|
||||
// and the same ~/ui controls the rest of the settings screens use.
|
||||
//
|
||||
// Presentational: the route owns the fetcher and posts the unchanged create
|
||||
// contract of settings/team/groups/new (action=create, name, description,
|
||||
// color, users[]).
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus } from "@subframe/core";
|
||||
import ColorBadge from "~/components/ui/badges/ColorBadge";
|
||||
import { Colors } from "~/application/enums/shared/Colors";
|
||||
import { getColors } from "~/utils/shared/ColorUtils";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { FormDialog } from "../shared/FormDialog";
|
||||
|
||||
export type GroupCandidateUser = {
|
||||
userId: string;
|
||||
name: string;
|
||||
email: string;
|
||||
};
|
||||
|
||||
export type GroupNewInput = {
|
||||
name: string;
|
||||
description: string;
|
||||
color: number;
|
||||
userIds: string[];
|
||||
};
|
||||
|
||||
/** Colour is a required column on the group; the slide-over let it post NaN. */
|
||||
const DEFAULT_COLOR = Colors.BLUE;
|
||||
|
||||
export function GroupNewDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
candidates,
|
||||
submitting,
|
||||
onCreate,
|
||||
}: {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
candidates: readonly GroupCandidateUser[];
|
||||
submitting: boolean;
|
||||
onCreate: (input: GroupNewInput) => void;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [name, setName] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [color, setColor] = useState<number>(DEFAULT_COLOR);
|
||||
const [userIds, setUserIds] = useState<ReadonlySet<string>>(new Set());
|
||||
|
||||
function toggleUser(userId: string, checked: boolean) {
|
||||
setUserIds((prev) => {
|
||||
const next = new Set(prev);
|
||||
if (checked) next.add(userId);
|
||||
else next.delete(userId);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<FormDialog
|
||||
open={open}
|
||||
onOpenChange={onOpenChange}
|
||||
uiId="ui.settings.groups.newDialog"
|
||||
title={t("settings.members.groups.createTitle")}
|
||||
subtitle={t("settings.members.groups.subtitle")}
|
||||
footer={
|
||||
<>
|
||||
<Button className="mobile:w-full" type="button" variant="tertiary" onClick={() => onOpenChange(false)}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
type="button"
|
||||
icon={<FeatherPlus />}
|
||||
loading={submitting}
|
||||
disabled={name.trim().length === 0}
|
||||
onClick={() => onCreate({ name: name.trim(), description: description.trim(), color, userIds: [...userIds] })}
|
||||
data-ui-id="ui.settings.groups.newDialog.submit"
|
||||
>
|
||||
{t("shared.create")}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<TextInput className="w-full max-w-full" label={t("models.group.name")} showLabel>
|
||||
<TextInput.Input value={name} onChange={(event) => setName(event.target.value)} required autoFocus autoComplete="off" />
|
||||
</TextInput>
|
||||
<TextArea className="w-full max-w-full" label={t("models.group.description")} showLabel>
|
||||
<TextArea.Input value={description} onChange={(event) => setDescription(event.target.value)} />
|
||||
</TextArea>
|
||||
<Select
|
||||
className="w-full max-w-full"
|
||||
label={t("models.group.color")}
|
||||
showLabel
|
||||
value={String(color)}
|
||||
onValueChange={(value: string) => setColor(Number(value))}
|
||||
>
|
||||
{getColors().map((option) => (
|
||||
<Select.Item key={option} value={String(option)}>
|
||||
<span className="flex items-center gap-2">
|
||||
<ColorBadge color={option} />
|
||||
{t(`app.shared.colors.${Colors[option]}`)}
|
||||
</span>
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
<div className="flex w-full flex-col gap-2" role="group" aria-labelledby="ui-settings-groups-new-members">
|
||||
<span
|
||||
id="ui-settings-groups-new-members"
|
||||
className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary"
|
||||
>
|
||||
{t("models.user.plural")}
|
||||
</span>
|
||||
{candidates.length === 0 ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.members.groups.noCandidates")}
|
||||
</span>
|
||||
) : (
|
||||
candidates.map((candidate) => (
|
||||
<Checkbox
|
||||
key={candidate.userId}
|
||||
// The kit checkbox is justify-between and would otherwise strand
|
||||
// each label at the far edge of the dialog.
|
||||
className="w-fit"
|
||||
label={candidate.name || candidate.email}
|
||||
description={candidate.name ? candidate.email : undefined}
|
||||
checked={userIds.has(candidate.userId)}
|
||||
onCheckedChange={(checked: boolean) => toggleUser(candidate.userId, checked)}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</FormDialog>
|
||||
);
|
||||
}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
// Guards the contract the Mitarbeiter tab relies on after the invite moved from
|
||||
// its own sub-page into a popup: the dialog reports trimmed field values through
|
||||
// onInvite (the route turns those into the unchanged members/new form fields),
|
||||
// and the plan seat limit still blocks the submit the way CheckPlanFeatureLimit
|
||||
// did on the sub-page.
|
||||
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { PlanFeatureUsageDto } from "~/application/dtos/subscriptions/PlanFeatureUsageDto";
|
||||
import { InviteMemberDialog, type InviteMemberInput } from "./InviteMemberDialog";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (s: string) => s, i18n: { language: "de" } }),
|
||||
}));
|
||||
|
||||
function renderDialog(featurePlanUsage?: PlanFeatureUsageDto) {
|
||||
const onInvite = vi.fn<(input: InviteMemberInput) => void>();
|
||||
render(
|
||||
<InviteMemberDialog
|
||||
open
|
||||
onOpenChange={() => undefined}
|
||||
featurePlanUsage={featurePlanUsage}
|
||||
submitting={false}
|
||||
errorMessage={null}
|
||||
onInvite={onInvite}
|
||||
/>
|
||||
);
|
||||
return { onInvite };
|
||||
}
|
||||
|
||||
function submitButton(): HTMLButtonElement {
|
||||
return document.querySelector("[data-ui-id='ui.settings.members.new.submit']") as HTMLButtonElement;
|
||||
}
|
||||
|
||||
function fill(labelKey: string, value: string) {
|
||||
fireEvent.change(screen.getByLabelText(labelKey), { target: { value } });
|
||||
}
|
||||
|
||||
describe("InviteMemberDialog", () => {
|
||||
it("reports the trimmed invite fields", () => {
|
||||
const { onInvite } = renderDialog();
|
||||
fill("models.user.email", " neu@hivegrid.de ");
|
||||
fill("models.user.firstName", " Nina ");
|
||||
fill("models.user.lastName", " Neu ");
|
||||
fireEvent.click(submitButton());
|
||||
|
||||
expect(onInvite).toHaveBeenCalledWith({
|
||||
email: "neu@hivegrid.de",
|
||||
firstName: "Nina",
|
||||
lastName: "Neu",
|
||||
sendInvitationEmail: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the submit disabled until e-mail and first name are set", () => {
|
||||
renderDialog();
|
||||
expect(submitButton()).toBeDisabled();
|
||||
fill("models.user.email", "neu@hivegrid.de");
|
||||
expect(submitButton()).toBeDisabled();
|
||||
fill("models.user.firstName", "Nina");
|
||||
expect(submitButton()).not.toBeDisabled();
|
||||
});
|
||||
|
||||
it("blocks the invite when the plan has no seat left", () => {
|
||||
renderDialog({ name: "users", message: "shared.planLimitReached", enabled: false } as PlanFeatureUsageDto);
|
||||
fill("models.user.email", "neu@hivegrid.de");
|
||||
fill("models.user.firstName", "Nina");
|
||||
expect(submitButton()).toBeDisabled();
|
||||
});
|
||||
});
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
// "Mitglied hinzufügen" as a popup on the Mitarbeiter tab, replacing the
|
||||
// separate sub-page. The sub-page existed because the hub's members tab is an
|
||||
// index route and can carry no children, so the tab's Dialog outlet never
|
||||
// received the form — posting the create contract with a fetcher sidesteps the
|
||||
// routing constraint entirely and keeps settings/team/members/new as the action.
|
||||
//
|
||||
// Presentational: the route owns the fetcher. Field contract unchanged
|
||||
// (email / first-name / last-name / send-invitation-email + csrf).
|
||||
//
|
||||
// Role-at-invite from David's wireframe is still NOT built: the invitation
|
||||
// backend stores no role — roles are assigned in the list (D01) after acceptance.
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus } from "@subframe/core";
|
||||
import type { PlanFeatureUsageDto } from "~/application/dtos/subscriptions/PlanFeatureUsageDto";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { FormDialog } from "../shared/FormDialog";
|
||||
|
||||
export type InviteMemberInput = {
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
sendInvitationEmail: boolean;
|
||||
};
|
||||
|
||||
export function InviteMemberDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
featurePlanUsage,
|
||||
submitting,
|
||||
errorMessage,
|
||||
onInvite,
|
||||
}: {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
/** Seat limit of the plan; when exhausted the form is replaced by the upgrade hint. */
|
||||
featurePlanUsage: PlanFeatureUsageDto | undefined;
|
||||
submitting: boolean;
|
||||
errorMessage: string | null;
|
||||
onInvite: (input: InviteMemberInput) => void;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [email, setEmail] = useState("");
|
||||
const [firstName, setFirstName] = useState("");
|
||||
const [lastName, setLastName] = useState("");
|
||||
const [sendEmail, setSendEmail] = useState(false);
|
||||
|
||||
// Fresh fields on every open; the dialog stays mounted between invites.
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
setEmail("");
|
||||
setFirstName("");
|
||||
setLastName("");
|
||||
setSendEmail(false);
|
||||
}, [open]);
|
||||
|
||||
const seatsExhausted = Boolean(featurePlanUsage && !featurePlanUsage.enabled);
|
||||
const canSubmit = !seatsExhausted && email.trim().length > 0 && firstName.trim().length > 0;
|
||||
|
||||
return (
|
||||
<FormDialog
|
||||
open={open}
|
||||
onOpenChange={onOpenChange}
|
||||
uiId="ui.settings.members.new.dialog"
|
||||
title={t("settings.members.form.newTitle")}
|
||||
subtitle={t("settings.members.form.newDescription")}
|
||||
footer={
|
||||
<>
|
||||
<Button className="mobile:w-full" type="button" variant="tertiary" onClick={() => onOpenChange(false)} data-ui-id="ui.settings.members.new.cancel">
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
type="button"
|
||||
icon={<FeatherPlus />}
|
||||
loading={submitting}
|
||||
disabled={!canSubmit}
|
||||
onClick={() =>
|
||||
onInvite({
|
||||
email: email.trim(),
|
||||
firstName: firstName.trim(),
|
||||
lastName: lastName.trim(),
|
||||
sendInvitationEmail: sendEmail,
|
||||
})
|
||||
}
|
||||
data-ui-id="ui.settings.members.new.submit"
|
||||
>
|
||||
{t("settings.members.actions.new")}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{seatsExhausted ? (
|
||||
<Alert
|
||||
variant="warning"
|
||||
notDismissible
|
||||
// Same label the sub-page's CheckPlanFeatureLimit banner showed.
|
||||
title={(featurePlanUsage?.entity ? t(featurePlanUsage.entity.titlePlural) : (featurePlanUsage?.name ?? "")).toUpperCase()}
|
||||
description={featurePlanUsage?.message ? t(featurePlanUsage.message) : ""}
|
||||
/>
|
||||
) : null}
|
||||
{errorMessage ? <Alert variant="error" notDismissible title={errorMessage} /> : null}
|
||||
|
||||
<TextInput className="w-full max-w-full" label={t("models.user.email")} showLabel>
|
||||
<TextInput.Input
|
||||
type="email"
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
required
|
||||
autoFocus
|
||||
autoComplete="off"
|
||||
disabled={seatsExhausted}
|
||||
/>
|
||||
</TextInput>
|
||||
<div className="mobile:flex-col flex w-full gap-4">
|
||||
<TextInput className="w-full max-w-full" label={t("models.user.firstName")} showLabel>
|
||||
<TextInput.Input value={firstName} onChange={(event) => setFirstName(event.target.value)} required autoComplete="off" disabled={seatsExhausted} />
|
||||
</TextInput>
|
||||
<TextInput className="w-full max-w-full" label={t("models.user.lastName")} showLabel>
|
||||
<TextInput.Input value={lastName} onChange={(event) => setLastName(event.target.value)} autoComplete="off" disabled={seatsExhausted} />
|
||||
</TextInput>
|
||||
</div>
|
||||
{/* w-fit, because the kit checkbox is justify-between and would otherwise
|
||||
stretch across the dialog and strand its label at the far edge. */}
|
||||
<Checkbox
|
||||
className="w-fit"
|
||||
label={t("settings.members.sendInvitationEmail.title")}
|
||||
description={t("settings.members.sendInvitationEmail.description")}
|
||||
checked={sendEmail}
|
||||
onCheckedChange={setSendEmail}
|
||||
disabled={seatsExhausted}
|
||||
/>
|
||||
</FormDialog>
|
||||
);
|
||||
}
|
||||
-69
@@ -1,69 +0,0 @@
|
||||
// R-P2b — D-P2 "WF-P2 Admin RBAC" M01 "Mitarbeiter einladen" form in David's
|
||||
// Subframe optics (real Dialog content, S 560 — the members route wraps the
|
||||
// outlet in Dialog.Content). Posts to the existing members/new action, keeping
|
||||
// the invite contract (fields email/first-name/last-name/send-invitation-email,
|
||||
// csrf, data-ui-id ui.settings.members.new.form) untouched.
|
||||
// Role-at-invite from David's wireframe is NOT built: the invitation backend
|
||||
// stores no role — roles are assigned in the list (D01) after acceptance.
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, useActionData, useNavigation } from "react-router";
|
||||
import toast from "react-hot-toast";
|
||||
import type { NewMemberActionData } from "~/routes/app.$tenant/settings/members/new";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export function InviteMemberForm({ onClose }: { onClose: () => void }) {
|
||||
const { t } = useTranslation();
|
||||
const actionData = useActionData<NewMemberActionData>();
|
||||
const navigation = useNavigation();
|
||||
const rootData = useRootData();
|
||||
const loading = navigation.state === "submitting";
|
||||
// ~/ui Checkbox is controlled-only — mirror it into a hidden field for the action.
|
||||
const [sendEmail, setSendEmail] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (actionData?.error) toast.error(actionData.error);
|
||||
}, [actionData]);
|
||||
|
||||
return (
|
||||
<Form method="post" className="flex w-full flex-col gap-6" data-ui-id="ui.settings.members.new.form">
|
||||
{rootData.csrf && <input type="hidden" name="csrf" value={rootData.csrf} />}
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("settings.members.form.newTitle")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("settings.members.form.newDescription")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput className="w-full" label={t("models.user.email")} showLabel>
|
||||
<TextInput.Input name="email" type="email" required autoComplete="off" defaultValue={actionData?.fields?.email} />
|
||||
</TextInput>
|
||||
<div className="flex w-full gap-4">
|
||||
<TextInput className="w-full" label={t("models.user.firstName")} showLabel>
|
||||
<TextInput.Input name="first-name" required autoComplete="off" defaultValue={actionData?.fields?.firstName} />
|
||||
</TextInput>
|
||||
<TextInput className="w-full" label={t("models.user.lastName")} showLabel>
|
||||
<TextInput.Input name="last-name" autoComplete="off" defaultValue={actionData?.fields?.lastName} />
|
||||
</TextInput>
|
||||
</div>
|
||||
{/* Radix renders the form-proxy input for `name` (posts "on" when checked). */}
|
||||
<Checkbox name="send-invitation-email" label={t("settings.members.sendInvitationEmail.title")} checked={sendEmail} onCheckedChange={setSendEmail} />
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("settings.members.sendInvitationEmail.description")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full items-center justify-end gap-2">
|
||||
<Button type="button" variant="tertiary" onClick={onClose} data-ui-id="ui.settings.members.new.cancel">
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button type="submit" loading={loading} data-ui-id="ui.settings.members.new.submit">
|
||||
{t("settings.members.actions.new")}
|
||||
</Button>
|
||||
</div>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
+127
-124
@@ -12,10 +12,11 @@ import { useEffect, useState } from "react";
|
||||
import { Link } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import * as SubframeCore from "@subframe/core";
|
||||
import { FeatherChevronDown, FeatherMoreHorizontal, FeatherPlus, FeatherTrash, FeatherUserCheck, FeatherUserX } from "@subframe/core";
|
||||
import { FeatherChevronDown, FeatherKey, FeatherMoreHorizontal, FeatherShield, FeatherTrash, FeatherUserCheck, FeatherUserX } from "@subframe/core";
|
||||
import type { MembersListRow, MembersListVM } from "@hivegrid/view-models";
|
||||
import { EMPTY_MEMBERS_FILTER, filterMembersRows, type MembersListFilterState, type MemberStatus } from "@hivegrid/view-models";
|
||||
import { roleDisplayName } from "~/components/core/roles/roleDisplay";
|
||||
import { FacetFilterBar, type ClientFacet } from "../shared/FacetFilterBar";
|
||||
import { Avatar } from "~/ui/components/Avatar";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
@@ -24,13 +25,8 @@ import { Dialog } from "~/ui/components/Dialog";
|
||||
import { DropdownMenu } from "~/ui/components/DropdownMenu";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { IconButton } from "~/ui/components/IconButton";
|
||||
import { SearchInput } from "~/ui/components/SearchInput";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { Tabs } from "~/ui/components/Tabs";
|
||||
|
||||
// Non-empty sentinel for the "any" option (empty string is not a valid Select value).
|
||||
const FILTER_ALL = "__all__";
|
||||
const STATUS_OPTIONS: readonly MemberStatus[] = ["active", "invited", "inactive"];
|
||||
|
||||
export type MembersActions = {
|
||||
@@ -83,82 +79,77 @@ export function MembersPage({ vm, actions, rolesTabHref, editRouteFor, submittin
|
||||
const rows = filterMembersRows(data.rows, filter);
|
||||
const hasAnyRows = data.rows.length > 0 || data.pendingInvitations.length > 0;
|
||||
|
||||
// Single-select facets on a multi-select control: picking the active option
|
||||
// again clears it, which is what the chip's X does too.
|
||||
const allFacets: ClientFacet[] = [
|
||||
{
|
||||
key: "role",
|
||||
label: t("settings.members.filters.role"),
|
||||
icon: <FeatherShield />,
|
||||
tone: "violet-subtle",
|
||||
options: data.assignableRoles.map((role) => ({ value: role.id, label: roleDisplayName(role, t) })),
|
||||
selected: new Set(filter.roleId ? [filter.roleId] : []),
|
||||
},
|
||||
{
|
||||
key: "status",
|
||||
label: t("settings.members.columns.status"),
|
||||
icon: <FeatherUserCheck />,
|
||||
tone: "blue-subtle",
|
||||
options: STATUS_OPTIONS.map((status) => ({
|
||||
value: status,
|
||||
label: t(`settings.members.status.${status === "inactive" ? "deactivated" : status}`),
|
||||
})),
|
||||
selected: new Set(filter.status ? [filter.status] : []),
|
||||
},
|
||||
{
|
||||
key: "mfa",
|
||||
label: t("settings.members.columns.twoFactor"),
|
||||
icon: <FeatherKey />,
|
||||
tone: "sky-subtle",
|
||||
options: [
|
||||
{ value: "on", label: t("settings.members.twoFactor.on") },
|
||||
{ value: "off", label: t("settings.members.twoFactor.off") },
|
||||
],
|
||||
selected: new Set(filter.mfa === null ? [] : [filter.mfa ? "on" : "off"]),
|
||||
},
|
||||
];
|
||||
// A facet with nothing to pick is a dead button; a workspace may have no
|
||||
// assignable roles beyond the built-in ones yet.
|
||||
const facets = allFacets.filter((facet) => facet.options.length > 0);
|
||||
|
||||
function toggleFacet(facetKey: string, value: string) {
|
||||
if (facetKey === "role") {
|
||||
return setFilter((prev) => ({ ...prev, roleId: prev.roleId === value ? null : value }));
|
||||
}
|
||||
if (facetKey === "status") {
|
||||
return setFilter((prev) => ({ ...prev, status: prev.status === value ? null : (value as MemberStatus) }));
|
||||
}
|
||||
if (facetKey === "mfa") {
|
||||
const next = value === "on";
|
||||
return setFilter((prev) => ({ ...prev, mfa: prev.mfa === next ? null : next }));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6" data-ui-id="ui.settings.members.page">
|
||||
{/* Header: title + description (0px rhythm) + invite CTA (M01) */}
|
||||
<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("settings.members.title")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("settings.members.description")}
|
||||
</span>
|
||||
</div>
|
||||
{data.canInvite ? (
|
||||
<Button icon={<FeatherPlus />} onClick={actions.onInvite} data-ui-id="ui.settings.members.invite">
|
||||
{t("settings.members.actions.new")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
{/* The page header (title + invite CTA) is rendered by the route above the layout. */}
|
||||
|
||||
{/* Tabs: Mitarbeiter | Rollen und Berechtigungen (David's S01 structure) */}
|
||||
{rolesTabHref ? (
|
||||
<Tabs>
|
||||
<Tabs.Item active>{t("settings.members.tabs.members")}</Tabs.Item>
|
||||
<Link to={rolesTabHref} className="contents no-underline" data-ui-id="ui.settings.members.tab.roles">
|
||||
<Tabs.Item>{t("settings.members.tabs.rolesAndPermissions")}</Tabs.Item>
|
||||
</Link>
|
||||
</Tabs>
|
||||
) : null}
|
||||
{/* AK-SET-01: the Team-Hub renders the tab bar this screen used to carry. */}
|
||||
|
||||
{/* Toolbar: search (name/email/phone) + role/status/2FA filters */}
|
||||
<div className="flex flex-wrap items-end gap-4" data-ui-id="ui.settings.members.search">
|
||||
<SearchInput
|
||||
className="max-w-[320px]"
|
||||
placeholder={t("settings.members.filters.searchPlaceholder")}
|
||||
hideShortcut
|
||||
value={filter.query}
|
||||
onChange={(event) => setFilter((prev) => ({ ...prev, query: event.target.value }))}
|
||||
/>
|
||||
<Select
|
||||
className="max-w-[200px]"
|
||||
label={t("settings.members.filters.role")}
|
||||
showLabel
|
||||
value={filter.roleId ?? FILTER_ALL}
|
||||
onValueChange={(value: string) => setFilter((prev) => ({ ...prev, roleId: value === FILTER_ALL ? null : value }))}
|
||||
>
|
||||
<Select.Item value={FILTER_ALL}>{t("settings.members.filters.all")}</Select.Item>
|
||||
{data.assignableRoles.map((role) => (
|
||||
<Select.Item key={role.id} value={role.id}>
|
||||
{roleDisplayName(role, t)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
className="max-w-[180px]"
|
||||
label={t("settings.members.columns.status")}
|
||||
showLabel
|
||||
value={filter.status ?? FILTER_ALL}
|
||||
onValueChange={(value: string) => setFilter((prev) => ({ ...prev, status: value === FILTER_ALL ? null : (value as MemberStatus) }))}
|
||||
>
|
||||
<Select.Item value={FILTER_ALL}>{t("settings.members.filters.all")}</Select.Item>
|
||||
{STATUS_OPTIONS.map((status) => (
|
||||
<Select.Item key={status} value={status}>
|
||||
{t(`settings.members.status.${status === "inactive" ? "deactivated" : status}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
className="max-w-[160px]"
|
||||
label={t("settings.members.columns.twoFactor")}
|
||||
showLabel
|
||||
value={filter.mfa === null ? FILTER_ALL : filter.mfa ? "on" : "off"}
|
||||
onValueChange={(value: string) => setFilter((prev) => ({ ...prev, mfa: value === FILTER_ALL ? null : value === "on" }))}
|
||||
>
|
||||
<Select.Item value={FILTER_ALL}>{t("settings.members.filters.all")}</Select.Item>
|
||||
<Select.Item value="on">{t("settings.members.twoFactor.on")}</Select.Item>
|
||||
<Select.Item value="off">{t("settings.members.twoFactor.off")}</Select.Item>
|
||||
</Select>
|
||||
</div>
|
||||
{/* --- Filter bar: the shared facet strip every list wears - free-text
|
||||
box, facet buttons, chips for what is active and one reset. Filtering
|
||||
happens on the loaded member list, so a facet takes effect at once. --- */}
|
||||
<FacetFilterBar
|
||||
uiId="ui.settings.members.filter"
|
||||
facets={facets}
|
||||
onToggle={toggleFacet}
|
||||
search={filter.query}
|
||||
onSearchChange={(value) => setFilter((prev) => ({ ...prev, query: value }))}
|
||||
searchPlaceholder={t("settings.members.filters.searchPlaceholder")}
|
||||
onReset={() => setFilter({ query: "", roleId: null, status: null, mfa: null })}
|
||||
labels={{ reset: t("settings.members.filters.reset"), removeChip: t("settings.members.filters.removeChip") }}
|
||||
/>
|
||||
|
||||
{!hasAnyRows ? (
|
||||
<div data-ui-id="ui.settings.members.empty">
|
||||
@@ -171,6 +162,7 @@ export function MembersPage({ vm, actions, rolesTabHref, editRouteFor, submittin
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("models.user.object")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("models.role.object")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.members.columns.seat")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.members.columns.status")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("settings.members.columns.twoFactor")}</Table.HeaderCell>
|
||||
<Table.HeaderCell> </Table.HeaderCell>
|
||||
@@ -207,23 +199,26 @@ export function MembersPage({ vm, actions, rolesTabHref, editRouteFor, submittin
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-subtle">—</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-subtle">—</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<BadgeFeedback farbe="subtle-warning">{t("settings.members.status.invited")}</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-subtle">—</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex grow shrink-0 basis-0 items-center justify-end">
|
||||
{data.canManageMembers ? (
|
||||
<IconButton
|
||||
icon={<FeatherTrash />}
|
||||
title={t("shared.delete")}
|
||||
onClick={() => actions.onDeleteInvitation({ invitationId: invitation.id })}
|
||||
data-ui-id="ui.settings.members.invitation.delete"
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<Table.Cell variant="align-right">
|
||||
{data.canManageMembers ? (
|
||||
<IconButton
|
||||
variant="ghost"
|
||||
size="small"
|
||||
icon={<FeatherTrash />}
|
||||
title={t("shared.delete")}
|
||||
onClick={() => actions.onDeleteInvitation({ invitationId: invitation.id })}
|
||||
data-ui-id="ui.settings.members.invitation.delete"
|
||||
/>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
@@ -371,6 +366,10 @@ function MemberRow({
|
||||
</span>
|
||||
)}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{/* Effective seat type (Fundament C): office (Büro) vs field (Baustelle) — read-only. */}
|
||||
<BadgeFeedback farbe={row.seatType === "office" ? "subtle-brand-primary" : "subtle-warning"}>{t(row.seatLabelKey)}</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<BadgeFeedback farbe={badge}>{t(row.statusLabelKey)}</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
@@ -379,41 +378,45 @@ function MemberRow({
|
||||
{row.mfaEnabled ? t("settings.members.twoFactor.on") : t("settings.members.twoFactor.off")}
|
||||
</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex grow shrink-0 basis-0 items-center justify-end">
|
||||
{data.canManageMembers || data.canEditRoles ? (
|
||||
<SubframeCore.DropdownMenu.Root>
|
||||
<SubframeCore.DropdownMenu.Trigger asChild>
|
||||
<IconButton icon={<FeatherMoreHorizontal />} data-ui-id="ui.settings.members.rowActions" />
|
||||
</SubframeCore.DropdownMenu.Trigger>
|
||||
<SubframeCore.DropdownMenu.Portal>
|
||||
<SubframeCore.DropdownMenu.Content side="bottom" align="end" sideOffset={4} asChild>
|
||||
<DropdownMenu>
|
||||
{row.canDeactivate ? (
|
||||
<DropdownMenu.DropdownItem icon={<FeatherUserX />} onClick={onAskDeactivate} data-ui-id="ui.settings.members.menu.deactivate">
|
||||
{t("settings.members.menu.deactivate")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
{row.canReactivate ? (
|
||||
<DropdownMenu.DropdownItem
|
||||
icon={<FeatherUserCheck />}
|
||||
onClick={() => actions.onReactivate({ userId: row.userId })}
|
||||
data-ui-id="ui.settings.members.menu.reactivate"
|
||||
>
|
||||
{t("settings.members.menu.reactivate")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
{data.canManageMembers ? (
|
||||
<Link to={editRouteFor(row.tenantUserId)} className="no-underline">
|
||||
<DropdownMenu.DropdownItem icon={<FeatherTrash />}>{t("settings.members.menu.remove")}</DropdownMenu.DropdownItem>
|
||||
</Link>
|
||||
) : null}
|
||||
</DropdownMenu>
|
||||
</SubframeCore.DropdownMenu.Content>
|
||||
</SubframeCore.DropdownMenu.Portal>
|
||||
</SubframeCore.DropdownMenu.Root>
|
||||
) : null}
|
||||
</div>
|
||||
<Table.Cell variant="align-right">
|
||||
{data.canManageMembers || data.canEditRoles ? (
|
||||
<SubframeCore.DropdownMenu.Root>
|
||||
<SubframeCore.DropdownMenu.Trigger asChild>
|
||||
<IconButton
|
||||
variant="ghost"
|
||||
size="small"
|
||||
icon={<FeatherMoreHorizontal />}
|
||||
aria-label={`${t("shared.actions")}: ${row.name}`}
|
||||
data-ui-id="ui.settings.members.rowActions"
|
||||
/>
|
||||
</SubframeCore.DropdownMenu.Trigger>
|
||||
<SubframeCore.DropdownMenu.Portal>
|
||||
<SubframeCore.DropdownMenu.Content side="bottom" align="end" sideOffset={4} asChild>
|
||||
<DropdownMenu>
|
||||
{row.canDeactivate ? (
|
||||
<DropdownMenu.DropdownItem icon={<FeatherUserX />} onClick={onAskDeactivate} data-ui-id="ui.settings.members.menu.deactivate">
|
||||
{t("settings.members.menu.deactivate")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
{row.canReactivate ? (
|
||||
<DropdownMenu.DropdownItem
|
||||
icon={<FeatherUserCheck />}
|
||||
onClick={() => actions.onReactivate({ userId: row.userId })}
|
||||
data-ui-id="ui.settings.members.menu.reactivate"
|
||||
>
|
||||
{t("settings.members.menu.reactivate")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
{data.canManageMembers ? (
|
||||
<Link to={editRouteFor(row.tenantUserId)} className="no-underline">
|
||||
<DropdownMenu.DropdownItem icon={<FeatherTrash />}>{t("settings.members.menu.remove")}</DropdownMenu.DropdownItem>
|
||||
</Link>
|
||||
) : null}
|
||||
</DropdownMenu>
|
||||
</SubframeCore.DropdownMenu.Content>
|
||||
</SubframeCore.DropdownMenu.Portal>
|
||||
</SubframeCore.DropdownMenu.Root>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
);
|
||||
|
||||
+222
-207
@@ -12,30 +12,27 @@
|
||||
// preloaded into the editor (same audited createWorkspaceRole path).
|
||||
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Link } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import * as SubframeCore from "@subframe/core";
|
||||
import { FeatherCopy, FeatherEdit2, FeatherMoreHorizontal, FeatherPlus, FeatherTrash } from "@subframe/core";
|
||||
import { FeatherCopy, FeatherEdit2, FeatherMoreHorizontal, FeatherPlus, FeatherShield, FeatherTrash, FeatherUserCheck } from "@subframe/core";
|
||||
import type { RoleEditorInputPermission, RolesListRow, RolesListVM, RoleTypeKey } from "@hivegrid/view-models";
|
||||
import { buildRoleEditorVM, filterRoleEditorSections, togglePermission, EMPTY_ROLES_FILTER, filterRolesRows, type RolesListFilterState } from "@hivegrid/view-models";
|
||||
import { permissionDisplayDescription, permissionDisplayName, roleDisplayDescription, roleDisplayName } from "~/components/core/roles/roleDisplay";
|
||||
import { FacetFilterBar, type ClientFacet } from "../shared/FacetFilterBar";
|
||||
import { PageIntro } from "../shared/PageShell";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { FormDialog } from "../shared/FormDialog";
|
||||
import { DropdownMenu } from "~/ui/components/DropdownMenu";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { IconButton } from "~/ui/components/IconButton";
|
||||
import { SearchInput } from "~/ui/components/SearchInput";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Switch } from "~/ui/components/Switch";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { Tabs } from "~/ui/components/Tabs";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
const FILTER_ALL = "__all__";
|
||||
|
||||
export type RoleMutationInput = { name: string; description: string; permissionNames: string[] };
|
||||
|
||||
export type RolesActions = {
|
||||
@@ -54,7 +51,6 @@ export type RolesPageProps = {
|
||||
/** roleId → assigned permission names (editor prefill + M04B duplication). */
|
||||
rolePermissionNames: Readonly<Record<string, readonly string[]>>;
|
||||
/** Tab bar back to S01 (members). */
|
||||
membersTabHref: string;
|
||||
actions: RolesActions;
|
||||
submitting: boolean;
|
||||
errorMessage: string | null;
|
||||
@@ -74,7 +70,7 @@ type EditorState = {
|
||||
enabled: ReadonlySet<string>;
|
||||
};
|
||||
|
||||
export function RolesPage({ vm, editorCatalog, rolePermissionNames, membersTabHref, actions, submitting, errorMessage, closeSignal }: RolesPageProps) {
|
||||
export function RolesPage({ vm, editorCatalog, rolePermissionNames, actions, submitting, errorMessage, closeSignal }: RolesPageProps) {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const [filter, setFilter] = useState<RolesListFilterState>(EMPTY_ROLES_FILTER);
|
||||
@@ -97,6 +93,42 @@ export function RolesPage({ vm, editorCatalog, rolePermissionNames, membersTabHr
|
||||
const data = vm.data;
|
||||
const rows = filterRolesRows(data.rows, filter);
|
||||
|
||||
const facets: ClientFacet[] = [
|
||||
{
|
||||
key: "type",
|
||||
label: t("settings.rolesAndPermissions.columns.type"),
|
||||
icon: <FeatherShield />,
|
||||
tone: "violet-subtle",
|
||||
options: [
|
||||
{ value: "system", label: t("settings.rolesAndPermissions.type.system") },
|
||||
{ value: "custom", label: t("settings.rolesAndPermissions.type.custom") },
|
||||
],
|
||||
selected: new Set(filter.type ? [filter.type] : []),
|
||||
},
|
||||
{
|
||||
key: "inUse",
|
||||
label: t("settings.rolesAndPermissions.filters.inUse"),
|
||||
icon: <FeatherUserCheck />,
|
||||
tone: "blue-subtle",
|
||||
options: [
|
||||
{ value: "yes", label: t("settings.rolesAndPermissions.filters.inUseYes") },
|
||||
{ value: "no", label: t("settings.rolesAndPermissions.filters.inUseNo") },
|
||||
],
|
||||
selected: new Set(filter.inUse === null ? [] : [filter.inUse ? "yes" : "no"]),
|
||||
},
|
||||
];
|
||||
|
||||
function toggleFacet(facetKey: string, value: string) {
|
||||
if (facetKey === "type") {
|
||||
return setFilter((prev) => ({ ...prev, type: prev.type === value ? null : (value as RoleTypeKey) }));
|
||||
}
|
||||
if (facetKey === "inUse") {
|
||||
const next = value === "yes";
|
||||
return setFilter((prev) => ({ ...prev, inUse: prev.inUse === next ? null : next }));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function openEditorFor(row: RolesListRow) {
|
||||
setEditor({
|
||||
roleId: row.id,
|
||||
@@ -120,14 +152,14 @@ export function RolesPage({ vm, editorCatalog, rolePermissionNames, membersTabHr
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6" data-ui-id="ui.settings.rolesAndPermissions.roles">
|
||||
{/* Header: title + subtitle (0px rhythm) + create CTA (M04A) */}
|
||||
<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("settings.members.tabs.rolesAndPermissions")}</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("settings.rolesAndPermissions.subtitle")}
|
||||
</span>
|
||||
</div>
|
||||
{/* The page header (title + subtitle) is rendered by the route above the layout, like Mitglieder. */}
|
||||
|
||||
{/* AK-SET-01: the Team-Hub renders the tab bar this screen used to carry. */}
|
||||
|
||||
{/* Intro + create CTA on one row, exactly as the Mitglieder tab next door
|
||||
hosts its own; the hub header above carries only title and subtitle. */}
|
||||
<div className="mobile:flex-col mobile:items-start flex w-full items-start justify-between gap-4">
|
||||
<PageIntro uiId="ui.settings.rolesAndPermissions.intro">{t("settings.rolesAndPermissions.subtitle")}</PageIntro>
|
||||
{data.canCreate ? (
|
||||
<Button
|
||||
icon={<FeatherPlus />}
|
||||
@@ -139,46 +171,23 @@ export function RolesPage({ vm, editorCatalog, rolePermissionNames, membersTabHr
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{/* Tabs: Mitarbeiter | Rollen und Berechtigungen (shared with S01) */}
|
||||
<Tabs>
|
||||
<Link to={membersTabHref} className="contents no-underline" data-ui-id="ui.settings.rolesAndPermissions.tab.members">
|
||||
<Tabs.Item>{t("settings.members.tabs.members")}</Tabs.Item>
|
||||
</Link>
|
||||
<Tabs.Item active>{t("settings.members.tabs.rolesAndPermissions")}</Tabs.Item>
|
||||
</Tabs>
|
||||
|
||||
{/* Toolbar: search (name/description) + type/in-use filters */}
|
||||
<div className="flex flex-wrap items-end gap-4" data-ui-id="ui.settings.rolesAndPermissions.roles.filter">
|
||||
<SearchInput
|
||||
className="max-w-[320px]"
|
||||
placeholder={t("settings.rolesAndPermissions.filters.searchPlaceholder")}
|
||||
hideShortcut
|
||||
value={filter.query}
|
||||
onChange={(event) => setFilter((prev) => ({ ...prev, query: event.target.value }))}
|
||||
/>
|
||||
<Select
|
||||
className="max-w-[200px]"
|
||||
label={t("settings.rolesAndPermissions.columns.type")}
|
||||
showLabel
|
||||
value={filter.type ?? FILTER_ALL}
|
||||
onValueChange={(value: string) => setFilter((prev) => ({ ...prev, type: value === FILTER_ALL ? null : (value as RoleTypeKey) }))}
|
||||
>
|
||||
<Select.Item value={FILTER_ALL}>{t("settings.members.filters.all")}</Select.Item>
|
||||
<Select.Item value="system">{t("settings.rolesAndPermissions.type.system")}</Select.Item>
|
||||
<Select.Item value="custom">{t("settings.rolesAndPermissions.type.custom")}</Select.Item>
|
||||
</Select>
|
||||
<Select
|
||||
className="max-w-[200px]"
|
||||
label={t("settings.rolesAndPermissions.filters.inUse")}
|
||||
showLabel
|
||||
value={filter.inUse === null ? FILTER_ALL : filter.inUse ? "yes" : "no"}
|
||||
onValueChange={(value: string) => setFilter((prev) => ({ ...prev, inUse: value === FILTER_ALL ? null : value === "yes" }))}
|
||||
>
|
||||
<Select.Item value={FILTER_ALL}>{t("settings.members.filters.all")}</Select.Item>
|
||||
<Select.Item value="yes">{t("settings.rolesAndPermissions.filters.inUseYes")}</Select.Item>
|
||||
<Select.Item value="no">{t("settings.rolesAndPermissions.filters.inUseNo")}</Select.Item>
|
||||
</Select>
|
||||
</div>
|
||||
{/* --- Filter bar: the shared facet strip the sibling tabs and the board
|
||||
lists wear - free-text box, facet buttons, chips for what is active
|
||||
and one reset. Both facets are single-select, so picking the active
|
||||
option again clears it, just as the chip's X does. --- */}
|
||||
<FacetFilterBar
|
||||
uiId="ui.settings.rolesAndPermissions.roles.filter"
|
||||
facets={facets}
|
||||
onToggle={toggleFacet}
|
||||
search={filter.query}
|
||||
onSearchChange={(value) => setFilter((prev) => ({ ...prev, query: value }))}
|
||||
searchPlaceholder={t("settings.rolesAndPermissions.filters.searchPlaceholder")}
|
||||
onReset={() => setFilter(EMPTY_ROLES_FILTER)}
|
||||
labels={{
|
||||
reset: t("settings.rolesAndPermissions.filters.reset"),
|
||||
removeChip: t("settings.rolesAndPermissions.filters.removeChip"),
|
||||
}}
|
||||
/>
|
||||
|
||||
{data.rows.length === 0 ? (
|
||||
<div data-ui-id="ui.settings.rolesAndPermissions.roles.empty">
|
||||
@@ -225,46 +234,50 @@ export function RolesPage({ vm, editorCatalog, rolePermissionNames, membersTabHr
|
||||
{t("models.permission.count", { count: row.permissionCount, formattedCount: formatters.number(row.permissionCount) })}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex grow shrink-0 basis-0 items-center justify-end">
|
||||
{row.canEdit || row.canDuplicate || row.canDelete ? (
|
||||
<SubframeCore.DropdownMenu.Root>
|
||||
<SubframeCore.DropdownMenu.Trigger asChild>
|
||||
<IconButton icon={<FeatherMoreHorizontal />} data-ui-id="ui.settings.rolesAndPermissions.roles.rowActions" />
|
||||
</SubframeCore.DropdownMenu.Trigger>
|
||||
<SubframeCore.DropdownMenu.Portal>
|
||||
<SubframeCore.DropdownMenu.Content side="bottom" align="end" sideOffset={4} asChild>
|
||||
<DropdownMenu>
|
||||
{row.canEdit ? (
|
||||
<DropdownMenu.DropdownItem icon={<FeatherEdit2 />} onClick={() => openEditorFor(row)}>
|
||||
{t("shared.edit")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
{row.canDuplicate ? (
|
||||
<DropdownMenu.DropdownItem
|
||||
icon={<FeatherCopy />}
|
||||
onClick={() =>
|
||||
setBasics({
|
||||
source: row,
|
||||
name: t("settings.rolesAndPermissions.duplicate.copyName", { name: row.name }),
|
||||
description: row.description,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("settings.rolesAndPermissions.duplicate.action")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
{row.canDelete ? (
|
||||
<DropdownMenu.DropdownItem icon={<FeatherTrash />} onClick={() => setDeleteRow(row)}>
|
||||
{t("shared.delete")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
</DropdownMenu>
|
||||
</SubframeCore.DropdownMenu.Content>
|
||||
</SubframeCore.DropdownMenu.Portal>
|
||||
</SubframeCore.DropdownMenu.Root>
|
||||
) : null}
|
||||
</div>
|
||||
<Table.Cell variant="align-right">
|
||||
{row.canEdit || row.canDuplicate || row.canDelete ? (
|
||||
<SubframeCore.DropdownMenu.Root>
|
||||
<SubframeCore.DropdownMenu.Trigger asChild>
|
||||
<IconButton
|
||||
variant="ghost"
|
||||
size="small"
|
||||
icon={<FeatherMoreHorizontal />}
|
||||
aria-label={`${t("shared.actions")}: ${roleDisplayName({ name: row.name, description: row.description }, t)}`}
|
||||
data-ui-id="ui.settings.rolesAndPermissions.roles.rowActions"
|
||||
/>
|
||||
</SubframeCore.DropdownMenu.Trigger>
|
||||
<SubframeCore.DropdownMenu.Portal>
|
||||
<SubframeCore.DropdownMenu.Content side="bottom" align="end" sideOffset={4} asChild>
|
||||
<DropdownMenu>
|
||||
{row.canEdit ? (
|
||||
<DropdownMenu.DropdownItem icon={<FeatherEdit2 />} onClick={() => openEditorFor(row)}>
|
||||
{t("shared.edit")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
{row.canDuplicate ? (
|
||||
<DropdownMenu.DropdownItem
|
||||
icon={<FeatherCopy />}
|
||||
onClick={() =>
|
||||
setBasics({
|
||||
source: row,
|
||||
name: t("settings.rolesAndPermissions.duplicate.copyName", { name: row.name }),
|
||||
description: row.description,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("settings.rolesAndPermissions.duplicate.action")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
{row.canDelete ? (
|
||||
<DropdownMenu.DropdownItem icon={<FeatherTrash />} onClick={() => setDeleteRow(row)}>
|
||||
{t("shared.delete")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
</DropdownMenu>
|
||||
</SubframeCore.DropdownMenu.Content>
|
||||
</SubframeCore.DropdownMenu.Portal>
|
||||
</SubframeCore.DropdownMenu.Root>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
@@ -278,71 +291,61 @@ export function RolesPage({ vm, editorCatalog, rolePermissionNames, membersTabHr
|
||||
)}
|
||||
|
||||
{/* M04A / M04B — basics step (S 560) */}
|
||||
<Dialog open={basics !== null} onOpenChange={(open: boolean) => (open ? undefined : setBasics(null))}>
|
||||
<Dialog.Content className="w-[560px] max-w-[90vw] p-6">
|
||||
{basics ? <RoleBasicsDialog state={basics} onChange={setBasics} onContinue={continueToPermissions} onCancel={() => setBasics(null)} /> : <div />}
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
{basics ? (
|
||||
<RoleBasicsDialog state={basics} onChange={setBasics} onContinue={continueToPermissions} onCancel={() => setBasics(null)} />
|
||||
) : null}
|
||||
|
||||
{/* M02 — large permission editor (L 1200) */}
|
||||
<Dialog open={editor !== null} onOpenChange={(open: boolean) => (open ? undefined : setEditor(null))}>
|
||||
<Dialog.Content className="w-[1200px] max-w-[95vw] p-6">
|
||||
{editor ? (
|
||||
<RoleEditorDialog
|
||||
state={editor}
|
||||
onChange={setEditor}
|
||||
editorCatalog={editorCatalog}
|
||||
submitting={submitting}
|
||||
errorMessage={errorMessage}
|
||||
onCancel={() => setEditor(null)}
|
||||
onSave={() => {
|
||||
const input = { name: editor.name, description: editor.description, permissionNames: [...editor.enabled] };
|
||||
if (editor.roleId) actions.onUpdate(editor.roleId, input);
|
||||
else actions.onCreate(input);
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<div />
|
||||
)}
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
{editor ? (
|
||||
<RoleEditorDialog
|
||||
state={editor}
|
||||
onChange={setEditor}
|
||||
editorCatalog={editorCatalog}
|
||||
submitting={submitting}
|
||||
errorMessage={errorMessage}
|
||||
onCancel={() => setEditor(null)}
|
||||
onSave={() => {
|
||||
const input = { name: editor.name, description: editor.description, permissionNames: [...editor.enabled] };
|
||||
if (editor.roleId) actions.onUpdate(editor.roleId, input);
|
||||
else actions.onCreate(input);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
{/* Delete confirm / D03 blocker (XS 420) */}
|
||||
<Dialog open={deleteRow !== null} onOpenChange={(open: boolean) => (open ? undefined : setDeleteRow(null))}>
|
||||
<Dialog.Content className="w-[420px] max-w-[90vw] p-4">
|
||||
{deleteRow ? (
|
||||
<div className="flex w-full flex-col gap-6" data-ui-id="ui.settings.rolesAndPermissions.roles.deleteConfirm">
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{deleteRow.deleteBlockedInUse ? t("settings.rolesAndPermissions.deleteBlocked.title") : t("settings.rolesAndPermissions.delete.title")}
|
||||
</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{deleteRow.deleteBlockedInUse
|
||||
? t("settings.rolesAndPermissions.deleteBlocked.description", { name: deleteRow.name, count: deleteRow.memberCount })
|
||||
: t("settings.rolesAndPermissions.delete.description", { name: deleteRow.name })}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full items-center justify-end gap-2">
|
||||
<Button variant="tertiary" onClick={() => setDeleteRow(null)}>
|
||||
{deleteRow.deleteBlockedInUse ? t("shared.close") : t("shared.cancel")}
|
||||
{deleteRow ? (
|
||||
<FormDialog
|
||||
open
|
||||
onOpenChange={(open: boolean) => (open ? undefined : setDeleteRow(null))}
|
||||
size="xs"
|
||||
uiId="ui.settings.rolesAndPermissions.roles.deleteConfirm"
|
||||
title={deleteRow.deleteBlockedInUse ? t("settings.rolesAndPermissions.deleteBlocked.title") : t("settings.rolesAndPermissions.delete.title")}
|
||||
footer={
|
||||
<>
|
||||
<Button className="mobile:w-full" variant="tertiary" onClick={() => setDeleteRow(null)}>
|
||||
{deleteRow.deleteBlockedInUse ? t("shared.close") : t("shared.cancel")}
|
||||
</Button>
|
||||
{!deleteRow.deleteBlockedInUse ? (
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
variant="destructive"
|
||||
loading={submitting}
|
||||
onClick={() => actions.onDelete(deleteRow.id)}
|
||||
data-ui-id="ui.settings.rolesAndPermissions.roles.deleteSubmit"
|
||||
>
|
||||
{t("shared.delete")}
|
||||
</Button>
|
||||
{!deleteRow.deleteBlockedInUse ? (
|
||||
<Button
|
||||
variant="destructive"
|
||||
loading={submitting}
|
||||
onClick={() => actions.onDelete(deleteRow.id)}
|
||||
data-ui-id="ui.settings.rolesAndPermissions.roles.deleteSubmit"
|
||||
>
|
||||
{t("shared.delete")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<div />
|
||||
)}
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
) : null}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{deleteRow.deleteBlockedInUse
|
||||
? t("settings.rolesAndPermissions.deleteBlocked.description", { name: deleteRow.name, count: deleteRow.memberCount })
|
||||
: t("settings.rolesAndPermissions.delete.description", { name: deleteRow.name })}
|
||||
</span>
|
||||
</FormDialog>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -363,34 +366,39 @@ function RoleBasicsDialog({
|
||||
const nameMissing = state.name.trim().length === 0;
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6" data-ui-id="ui.settings.rolesAndPermissions.roles.basics">
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{isDuplicate ? t("settings.rolesAndPermissions.duplicate.title") : t("settings.rolesAndPermissions.createDialog.title")}
|
||||
</span>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{isDuplicate
|
||||
? t("settings.rolesAndPermissions.duplicate.hint", { name: state.source?.name ?? "" })
|
||||
: t("settings.rolesAndPermissions.createDialog.description")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput className="w-full" label={t("models.role.name")} showLabel>
|
||||
<TextInput.Input value={state.name} onChange={(event) => onChange({ ...state, name: event.target.value })} required />
|
||||
</TextInput>
|
||||
<TextArea className="w-full" label={t("models.role.description")} showLabel>
|
||||
<TextArea.Input value={state.description} onChange={(event) => onChange({ ...state, description: event.target.value })} />
|
||||
</TextArea>
|
||||
</div>
|
||||
<div className="flex w-full items-center justify-end gap-2">
|
||||
<Button variant="tertiary" onClick={onCancel}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button disabled={nameMissing} onClick={() => onContinue(state)} data-ui-id="ui.settings.rolesAndPermissions.roles.basics.continue">
|
||||
{t("settings.rolesAndPermissions.editor.continue")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<FormDialog
|
||||
open
|
||||
onOpenChange={(open: boolean) => (open ? undefined : onCancel())}
|
||||
uiId="ui.settings.rolesAndPermissions.roles.basics"
|
||||
title={isDuplicate ? t("settings.rolesAndPermissions.duplicate.title") : t("settings.rolesAndPermissions.createDialog.title")}
|
||||
subtitle={
|
||||
isDuplicate
|
||||
? t("settings.rolesAndPermissions.duplicate.hint", { name: state.source?.name ?? "" })
|
||||
: t("settings.rolesAndPermissions.createDialog.description")
|
||||
}
|
||||
footer={
|
||||
<>
|
||||
<Button className="mobile:w-full" variant="tertiary" onClick={onCancel}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
disabled={nameMissing}
|
||||
onClick={() => onContinue(state)}
|
||||
data-ui-id="ui.settings.rolesAndPermissions.roles.basics.continue"
|
||||
>
|
||||
{t("settings.rolesAndPermissions.editor.continue")}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<TextInput className="w-full max-w-full" label={t("models.role.name")} showLabel>
|
||||
<TextInput.Input value={state.name} onChange={(event) => onChange({ ...state, name: event.target.value })} required autoFocus />
|
||||
</TextInput>
|
||||
<TextArea className="w-full max-w-full" label={t("models.role.description")} showLabel>
|
||||
<TextArea.Input value={state.description} onChange={(event) => onChange({ ...state, description: event.target.value })} />
|
||||
</TextArea>
|
||||
</FormDialog>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -431,18 +439,34 @@ function RoleEditorDialog({
|
||||
const nameMissing = state.name.trim().length === 0;
|
||||
|
||||
return (
|
||||
<div className="flex w-full flex-col gap-6" data-ui-id="ui.settings.rolesAndPermissions.roles.editor">
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{state.roleId ? t("settings.rolesAndPermissions.editor.title") : t("settings.rolesAndPermissions.createDialog.title")}
|
||||
</span>
|
||||
{state.duplicatedFromName ? (
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("settings.rolesAndPermissions.duplicate.hint", { name: state.duplicatedFromName })}
|
||||
</span>
|
||||
) : null}
|
||||
{errorMessage ? <Alert variant="error" title={errorMessage} /> : null}
|
||||
</div>
|
||||
<FormDialog
|
||||
open
|
||||
onOpenChange={(open: boolean) => (open ? undefined : onCancel())}
|
||||
size="large"
|
||||
uiId="ui.settings.rolesAndPermissions.roles.editor"
|
||||
title={state.roleId ? t("settings.rolesAndPermissions.editor.title") : t("settings.rolesAndPermissions.createDialog.title")}
|
||||
subtitle={state.duplicatedFromName ? t("settings.rolesAndPermissions.duplicate.hint", { name: state.duplicatedFromName }) : undefined}
|
||||
// The editor's permission column scrolls on its own, so the body must not
|
||||
// add a second scroll container around it.
|
||||
bodyClassName="max-h-none overflow-visible"
|
||||
footer={
|
||||
<>
|
||||
<Button className="mobile:w-full" variant="tertiary" onClick={onCancel}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
loading={submitting}
|
||||
disabled={nameMissing}
|
||||
onClick={onSave}
|
||||
data-ui-id="ui.settings.rolesAndPermissions.roles.editor.save"
|
||||
>
|
||||
{t("shared.save")}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{errorMessage ? <Alert variant="error" title={errorMessage} /> : null}
|
||||
|
||||
<div className="flex w-full gap-6 mobile:flex-col">
|
||||
{/* Sidebar: search + sections (Apple-settings pattern from David's M02) */}
|
||||
@@ -517,15 +541,6 @@ function RoleEditorDialog({
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full items-center justify-end gap-2">
|
||||
<Button variant="tertiary" onClick={onCancel}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button loading={submitting} disabled={nameMissing} onClick={onSave} data-ui-id="ui.settings.rolesAndPermissions.roles.editor.save">
|
||||
{t("shared.save")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</FormDialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user