Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,22 @@
|
||||
import { ReactNode } from "react";
|
||||
import CommandPalette from "../ui/commandPalettes/CommandPalette";
|
||||
import SubframeAppShell from "./SubframeAppShell";
|
||||
import SkipToContent from "../core/SkipToContent";
|
||||
|
||||
interface Props {
|
||||
layout: "app" | "admin" | "docs";
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export default function AppLayout({ layout, children }: Props) {
|
||||
// D-D0a: App-Rahmen ist jetzt Davids Subframe-Shell (SidebarWithSections + Topbar) statt der
|
||||
// shadcn-Shell. Der CommandPalette-Wrapper bleibt (liefert den useCommandPalette-Kontext fuer die Topbar).
|
||||
return (
|
||||
<div>
|
||||
<SkipToContent />
|
||||
<CommandPalette key={layout} layout={layout}>
|
||||
<SubframeAppShell layout={layout}>{children}</SubframeAppShell>
|
||||
</CommandPalette>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
import { useState } from "react";
|
||||
import { useFetcher, Link } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AlertTriangleIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
type Props = {
|
||||
changePasswordHref: string;
|
||||
};
|
||||
|
||||
// Phase 01 / #27 — soft-banner that surfaces after a successful login when
|
||||
// the submitted password no longer satisfies the current policy. Wraps the
|
||||
// existing yellow `WarningBanner` palette to stay visually consistent with
|
||||
// other tenant-dashboard banners, but adds two interactive controls:
|
||||
//
|
||||
// - "Change password now" → deep-links to the existing
|
||||
// /app/<tenant>/settings/profile page (anchored to the password
|
||||
// section).
|
||||
// - "Remind me in 7 days" → POSTs to a tiny resource route which sets a
|
||||
// short-lived UX cookie. While that cookie is in the future the tenant
|
||||
// layout omits the banner entirely.
|
||||
//
|
||||
// The banner also offers a local "dismiss for this page-load" close button
|
||||
// so the user can hide it without committing to either action.
|
||||
export default function PasswordPolicyBanner({ changePasswordHref }: Props) {
|
||||
const { t } = useTranslation("auth");
|
||||
const fetcher = useFetcher();
|
||||
const [locallyDismissed, setLocallyDismissed] = useState(false);
|
||||
|
||||
if (locallyDismissed) return null;
|
||||
if (fetcher.state !== "idle" && fetcher.formAction === "/api/password-policy-remind") {
|
||||
// Optimistically hide while the remind cookie is being set so the user
|
||||
// gets immediate feedback on click.
|
||||
return null;
|
||||
}
|
||||
if (fetcher.data && typeof fetcher.data === "object" && (fetcher.data as { ok?: boolean }).ok === true) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<section
|
||||
role="status"
|
||||
data-testid="password-policy-banner"
|
||||
className="not-prose rounded-md border border-yellow-300 bg-yellow-50"
|
||||
>
|
||||
<div className="rounded-md p-4">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
||||
<div className="flex">
|
||||
<div className="shrink-0">
|
||||
<AlertTriangleIcon className="h-5 w-5 text-yellow-400" aria-hidden="true" />
|
||||
</div>
|
||||
<div className="ml-3">
|
||||
<h3 className="text-sm font-medium leading-5 text-yellow-900">{t("passwordPolicyBanner.title")}</h3>
|
||||
<div className="mt-2 text-sm leading-5 text-yellow-800">{t("passwordPolicyBanner.body")}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2 sm:ml-3 sm:shrink-0">
|
||||
<Link
|
||||
to={changePasswordHref}
|
||||
data-testid="password-policy-banner-change"
|
||||
className="inline-flex items-center justify-center rounded-md border border-yellow-400 bg-yellow-100 px-3 py-1.5 text-xs font-semibold text-yellow-900 shadow-sm hover:bg-yellow-200 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2 focus:ring-offset-yellow-50"
|
||||
>
|
||||
{t("passwordPolicyBanner.changeNow")}
|
||||
</Link>
|
||||
<fetcher.Form method="post" action="/api/password-policy-remind">
|
||||
<button
|
||||
type="submit"
|
||||
data-testid="password-policy-banner-remind"
|
||||
className="inline-flex items-center justify-center rounded-md border border-yellow-300 bg-white px-3 py-1.5 text-xs font-medium text-yellow-900 shadow-sm hover:bg-yellow-50 focus:outline-none focus:ring-2 focus:ring-yellow-500 focus:ring-offset-2 focus:ring-offset-yellow-50"
|
||||
>
|
||||
{t("passwordPolicyBanner.remindLater")}
|
||||
</button>
|
||||
</fetcher.Form>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="password-policy-banner-dismiss"
|
||||
aria-label={t("passwordPolicyBanner.dismiss")}
|
||||
onClick={() => setLocallyDismissed(true)}
|
||||
className="inline-flex h-7 w-7 items-center justify-center rounded-md text-yellow-700 hover:bg-yellow-100 focus:outline-none focus:ring-2 focus:ring-yellow-500"
|
||||
>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link, useParams } from "react-router";
|
||||
import UserDisplayUtils from "~/utils/app/UserDisplayUtils";
|
||||
import { UserWithoutPassword } from "~/utils/db/users.db.server";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import { GlobeIcon } from "~/components/ui/icons/vendor";
|
||||
|
||||
interface Props {
|
||||
user: UserWithoutPassword;
|
||||
}
|
||||
|
||||
export default function ProfileBanner({ user }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const params = useParams();
|
||||
return (
|
||||
<div className="mx-auto max-w-5xl px-4 sm:px-8">
|
||||
<div className="py-2 md:flex md:items-center md:justify-between">
|
||||
<div className="min-w-0 flex-1">
|
||||
{/*Profile */}
|
||||
<div className="flex items-center">
|
||||
<Link to={UrlUtils.currentTenantUrl(params, `settings/profile`)} aria-label={t("models.user.avatarAlt")}>
|
||||
{user?.avatar && <img className="hidden h-12 w-12 rounded-full sm:block" src={user?.avatar} alt={t("models.user.avatarAlt")} />}
|
||||
</Link>
|
||||
<div>
|
||||
<div className="flex items-center">
|
||||
<div>
|
||||
{(() => {
|
||||
if (user?.avatar) {
|
||||
return <img className="h-12 w-12 rounded-sm sm:hidden" src={user?.avatar} alt={t("models.user.avatarAlt")} />;
|
||||
} else {
|
||||
return (
|
||||
<span className="inline-flex h-12 w-12 items-center justify-center rounded-sm bg-slate-800 shadow-xl sm:hidden">
|
||||
<span className="text-sm font-medium leading-none text-white">{UserDisplayUtils.avatarText(user)}</span>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
})()}
|
||||
</div>
|
||||
<h1 className="text-foreground ml-3 text-lg font-bold leading-7 sm:truncate sm:leading-9">
|
||||
{t("shared.hi")} {user?.firstName && <span>{user?.firstName} 👋!</span>}
|
||||
</h1>
|
||||
</div>
|
||||
<dl className="flex flex-col sm:ml-3 sm:flex-row sm:flex-wrap">
|
||||
<dt className="sr-only">{t("models.user.email")}</dt>
|
||||
<dd className="text-muted-foreground flex items-center text-xs font-medium lowercase sm:mr-6">
|
||||
<GlobeIcon className="text-muted-foreground mr-0.5 h-3.5 w-3.5 shrink-0" aria-hidden="true" />
|
||||
{user?.email}
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
import "@testing-library/jest-dom";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { createMemoryRouter, RouterProvider } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { UI_ACTION_IDS, UI_SURFACE_IDS, getSidebarSurfaceId, type UiLayout } from "~/application/ui/uiRegistry";
|
||||
import SubframeAppShell from "./SubframeAppShell";
|
||||
|
||||
// D-D0a — Contract-Test der neuen Subframe-App-Shell: stabile Shell-Surface-/Action-data-ui-ids
|
||||
// (analog zum bisherigen ShadcnSidebarLayout-Test), damit der Reachability-Kontrakt erhalten bleibt.
|
||||
|
||||
vi.mock("~/components/ui/commandPalettes/CommandPalette", () => ({
|
||||
useCommandPalette: () => ({ toggle: vi.fn() }),
|
||||
}));
|
||||
|
||||
vi.mock("~/modules/onboarding/components/OnboardingSession", () => ({ default: () => null }));
|
||||
|
||||
vi.mock("~/utils/data/useTitleData", () => ({ useTitleData: () => "Dashboard" }));
|
||||
|
||||
vi.mock("~/utils/data/useAppOrAdminData", () => ({
|
||||
useAppOrAdminData: () => ({
|
||||
user: { email: "u@example.test", firstName: "U", lastName: "Ser", avatar: null },
|
||||
currentTenant: null,
|
||||
myTenants: [],
|
||||
entities: [],
|
||||
entityGroups: [],
|
||||
productAccess: {},
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/data/useRootData", () => ({
|
||||
useRootData: () => ({ userSession: { lightOrDarkMode: "light" }, csrf: "x", appConfiguration: {}, routing: {} }),
|
||||
}));
|
||||
|
||||
vi.mock("../layouts/sidebars/shadcn/nav-actions", () => ({
|
||||
NavActions: () => <button data-ui-id="ui.action.shell.search">Search</button>,
|
||||
}));
|
||||
|
||||
vi.mock("~/application/sidebar/AppSidebar", () => ({ AppSidebar: () => [] }));
|
||||
vi.mock("~/application/sidebar/AdminSidebar", () => ({ AdminSidebar: () => [] }));
|
||||
vi.mock("~/application/sidebar/DocsSidebar", () => ({ DocsSidebar: () => [] }));
|
||||
|
||||
describe("SubframeAppShell UI IDs", () => {
|
||||
function renderShell(layout: UiLayout) {
|
||||
const router = createMemoryRouter(
|
||||
[
|
||||
{
|
||||
path: "/",
|
||||
element: (
|
||||
<SubframeAppShell layout={layout}>
|
||||
<section>Page content</section>
|
||||
</SubframeAppShell>
|
||||
),
|
||||
},
|
||||
],
|
||||
{ initialEntries: ["/"] }
|
||||
);
|
||||
render(<RouterProvider router={router} />);
|
||||
}
|
||||
|
||||
function expectNoDuplicateDataUiIds() {
|
||||
const ids = [...document.querySelectorAll("[data-ui-id]")].map((element) => element.getAttribute("data-ui-id"));
|
||||
expect(new Set(ids).size).toBe(ids.length);
|
||||
}
|
||||
|
||||
it.each<UiLayout>(["app", "admin", "docs"])("renders stable %s shell surface and action IDs", (layout) => {
|
||||
renderShell(layout);
|
||||
|
||||
expect(document.querySelector(`[data-ui-id="${UI_SURFACE_IDS.shell}"]`)).toBeInTheDocument();
|
||||
expect(document.querySelector(`[data-ui-id="${UI_SURFACE_IDS.shellInset}"]`)).toBeInTheDocument();
|
||||
expect(document.querySelector(`[data-ui-id="${getSidebarSurfaceId(layout)}"]`)).toBeInTheDocument();
|
||||
expect(document.querySelector(`[data-ui-id="${UI_SURFACE_IDS.shellHeader}"]`)).toBeInTheDocument();
|
||||
expect(document.querySelector(`[data-ui-id="${UI_SURFACE_IDS.shellBreadcrumb}"]`)).toBeInTheDocument();
|
||||
expect(document.querySelector(`[data-ui-id="${UI_SURFACE_IDS.shellBreadcrumbCurrent}"]`)).toHaveTextContent("Dashboard");
|
||||
expect(document.querySelector(`[data-ui-id="${UI_SURFACE_IDS.shellNavActions}"]`)).toBeInTheDocument();
|
||||
expect(document.querySelector(`[data-ui-id="${UI_ACTION_IDS.sidebarTrigger}"]`)).toBeInTheDocument();
|
||||
expect(document.querySelector(`[data-ui-id="${UI_ACTION_IDS.search}"]`)).toBeInTheDocument();
|
||||
expect(document.querySelector(`[data-ui-id="${UI_SURFACE_IDS.shellMain}"]`)).toContainElement(screen.getByText("Page content"));
|
||||
expectNoDuplicateDataUiIds();
|
||||
});
|
||||
});
|
||||
+327
@@ -0,0 +1,327 @@
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import { useFetcher, useLocation, useNavigate, useParams, useSearchParams, useSubmit } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
FeatherBell,
|
||||
FeatherLogOut,
|
||||
FeatherMenu,
|
||||
FeatherMoon,
|
||||
FeatherSettings,
|
||||
FeatherSun,
|
||||
FeatherUserSearch,
|
||||
} from "@subframe/core";
|
||||
import * as SubframeCore from "@subframe/core";
|
||||
|
||||
import { SidebarWithSections } from "~/ui/components/SidebarWithSections";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { SearchInput } from "~/ui/components/SearchInput";
|
||||
import { IconButton } from "~/ui/components/IconButton";
|
||||
import { Avatar } from "~/ui/components/Avatar";
|
||||
import { DropdownMenu } from "~/ui/components/DropdownMenu";
|
||||
|
||||
import { useCommandPalette } from "~/components/ui/commandPalettes/CommandPalette";
|
||||
import { useTitleData } from "~/utils/data/useTitleData";
|
||||
import { useAppOrAdminData } from "~/utils/data/useAppOrAdminData";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { UI_ACTION_IDS, UI_SURFACE_IDS, getSidebarSurfaceId } from "~/application/ui/uiRegistry";
|
||||
import { AppSidebar } from "~/application/sidebar/AppSidebar";
|
||||
import { AdminSidebar } from "~/application/sidebar/AdminSidebar";
|
||||
import { DocsSidebar } from "~/application/sidebar/DocsSidebar";
|
||||
import { SideBarItem } from "~/application/sidebar/SidebarItem";
|
||||
import { SidebarGroupDto } from "~/application/sidebar/SidebarGroupDto";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import UserDisplayUtils from "~/utils/app/UserDisplayUtils";
|
||||
import { getUserHasPermission } from "~/utils/helpers/PermissionsHelper";
|
||||
import { appPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { TenantUserType } from "~/application/enums/tenants/TenantUserType";
|
||||
import { DARK_MODE_IN_APP } from "~/application/Constants";
|
||||
|
||||
type UiLayout = "app" | "admin" | "docs";
|
||||
|
||||
// D-D0a — App-Shell nach Davids Subframe-Design (DefaultPageLayout: SidebarWithSections + HeaderNavigation).
|
||||
// Ersetzt die shadcn-Shell. Sidebar mit funktionierendem Collapse-Toggle; Topbar = Breadcrumb + Suchfeld
|
||||
// (-> Cmd+K) + Notification-Bell + User-Avatar-Dropdown (Profil/Theme/Logout + "Arbeitsbereich wechseln"
|
||||
// = Tenant-Switcher). Nav-Items + Gating kommen aus der bestehenden AppSidebar-Config (getMenu).
|
||||
// Shell-data-ui-ids bleiben erhalten (uiRegistry).
|
||||
|
||||
export default function SubframeAppShell({ children, layout, menuItems }: { children: React.ReactNode; layout: UiLayout; menuItems?: SideBarItem[] }) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const params = useParams();
|
||||
const location = useLocation();
|
||||
const appData = useAppOrAdminData();
|
||||
const rootData = useRootData();
|
||||
const title = useTitleData() ?? "";
|
||||
const commandPalette = useCommandPalette();
|
||||
const fetcher = useFetcher();
|
||||
const submit = useSubmit();
|
||||
const navigate = useNavigate();
|
||||
const [searchParams] = useSearchParams();
|
||||
const mainElement = useRef<HTMLElement>(null);
|
||||
|
||||
const [collapsed, setCollapsed] = useState(false); // Desktop-Collapse (Davids Toggle)
|
||||
const [mobileOpen, setMobileOpen] = useState(false); // Mobile-Drawer
|
||||
|
||||
const sidebarSurfaceId = getSidebarSurfaceId(layout);
|
||||
|
||||
// ---- Menü bauen (identisches Gating wie shadcn-Shell) ----
|
||||
function getPath(item: SideBarItem): string {
|
||||
return UrlUtils.replaceVariables(params, item.path) ?? "";
|
||||
}
|
||||
function normalizePath(path: string): string {
|
||||
return path.length > 1 ? path.replace(/\/+$/, "") : path;
|
||||
}
|
||||
function pathMatchesCurrent(path: string, exact?: boolean): boolean {
|
||||
if (!path) return false;
|
||||
const currentPath = normalizePath(location.pathname);
|
||||
const itemPath = normalizePath(path);
|
||||
return exact ? currentPath === itemPath : currentPath === itemPath || currentPath.startsWith(`${itemPath}/`);
|
||||
}
|
||||
function isCurrent(item: SideBarItem): boolean {
|
||||
return pathMatchesCurrent(getPath(item), item.exact);
|
||||
}
|
||||
function currentIsChild(item: SideBarItem): boolean {
|
||||
return item.items?.some((child) => isCurrent(child) || currentIsChild(child)) ?? false;
|
||||
}
|
||||
function prepareMenuItem(item: SideBarItem): SideBarItem {
|
||||
const childItems = item.isCollapsible === false ? [] : item.items?.map((child) => prepareMenuItem(child));
|
||||
const prepared: SideBarItem = {
|
||||
...item,
|
||||
path: UrlUtils.replaceVariables(params, item.path) ?? item.path,
|
||||
redirectTo: item.redirectTo ? (UrlUtils.replaceVariables(params, item.redirectTo) ?? item.redirectTo) : item.redirectTo,
|
||||
items: childItems,
|
||||
};
|
||||
return { ...prepared, isActive: prepared.isActive || isCurrent(prepared) || currentIsChild(prepared) };
|
||||
}
|
||||
function allowCurrentUserType(item: SideBarItem) {
|
||||
return !item.adminOnly || Boolean(appData?.user?.admin);
|
||||
}
|
||||
function allowCurrentTenantUserType(item: SideBarItem) {
|
||||
const currentRole = "currentRole" in appData ? (appData.currentRole as TenantUserType) : null;
|
||||
return !item.tenantUserTypes || (currentRole !== null && item.tenantUserTypes.includes(currentRole));
|
||||
}
|
||||
function checkUserRolePermissions(item: SideBarItem) {
|
||||
return !item.permission || getUserHasPermission(appData, item.permission);
|
||||
}
|
||||
function getVisibleItem(item: SideBarItem): SideBarItem | null {
|
||||
if (item.hidden === true || !allowCurrentUserType(item) || !allowCurrentTenantUserType(item)) return null;
|
||||
const items = item.items?.map((child) => getVisibleItem(child)).filter((c): c is SideBarItem => c !== null) ?? [];
|
||||
const hasPermission = checkUserRolePermissions(item);
|
||||
if (!hasPermission && items.length === 0) return null;
|
||||
return { ...item, path: hasPermission ? item.path : "", redirectTo: hasPermission ? item.redirectTo : undefined, items };
|
||||
}
|
||||
function getMenuItems(): SideBarItem[] {
|
||||
let menu: SideBarItem[] = [];
|
||||
if (menuItems) menu = menuItems;
|
||||
else if (layout === "admin") menu = AdminSidebar({ t, appConfiguration: rootData.appConfiguration, routing: rootData.routing });
|
||||
else if (layout === "app")
|
||||
menu = AppSidebar({
|
||||
t,
|
||||
i18n,
|
||||
tenantId: params.tenant ?? "",
|
||||
entities: appData?.entities ?? [],
|
||||
entityGroups: appData?.entityGroups ?? [],
|
||||
appConfiguration: rootData.appConfiguration,
|
||||
routing: rootData.routing,
|
||||
productAccess: appData?.productAccess,
|
||||
});
|
||||
else if (layout === "docs") menu = DocsSidebar();
|
||||
return menu.map((item) => prepareMenuItem(item));
|
||||
}
|
||||
|
||||
const menu: SidebarGroupDto[] = useMemo(() => {
|
||||
const groups: SidebarGroupDto[] = [];
|
||||
getMenuItems().forEach((group) => {
|
||||
const items = group.items?.map((item) => getVisibleItem(item)).filter((item): item is SideBarItem => item !== null) ?? [];
|
||||
if (group.hidden === true || items.length === 0) return;
|
||||
const type: SidebarGroupDto["type"] = group.isSecondary ? "secondary" : group.isQuickLink ? "quick-link" : "main";
|
||||
groups.push({ id: group.id, uiIdPattern: group.uiIdPattern, uiIdParams: group.uiIdParams, title: group.title.toString(), items, type });
|
||||
});
|
||||
return groups.filter((g) => g.items.length > 0);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [layout, menuItems, location.pathname, params.tenant, appData?.productAccess, appData?.entities, appData?.entityGroups]);
|
||||
|
||||
const navMain = menu.filter((g) => g.type === "main");
|
||||
const navSecondary = menu.filter((g) => g.type === "secondary");
|
||||
|
||||
// ---- User + Theme-Toggle + Tenant-Switch ----
|
||||
const isDarkMode = rootData.userSession?.lightOrDarkMode === "dark";
|
||||
function onThemeToggle() {
|
||||
const form = new FormData();
|
||||
form.set("action", "toggleLightOrDarkMode");
|
||||
form.set("redirect", location.pathname + "?" + searchParams.toString());
|
||||
if (rootData.csrf) form.set("csrf", rootData.csrf);
|
||||
fetcher.submit(form, { method: "post", action: "/preferences", preventScrollReset: true });
|
||||
}
|
||||
// Logout per useSubmit (nicht verschachteltes <Form>): das Radix-Dropdown schliesst beim Klick und wuerde
|
||||
// ein natives Form-Submit verschlucken; useSubmit triggert die Navigation imperativ + ueberlebt das Unmount.
|
||||
function onLogout() {
|
||||
const form = new FormData();
|
||||
if (rootData.csrf) form.set("csrf", rootData.csrf);
|
||||
submit(form, { method: "post", action: "/logout" });
|
||||
}
|
||||
const user = appData?.user;
|
||||
const currentTenant = "currentTenant" in appData ? appData.currentTenant : null;
|
||||
const myTenants = appData?.myTenants ?? [];
|
||||
|
||||
function renderNavItem(item: SideBarItem) {
|
||||
const href = item.redirectTo || item.path;
|
||||
const label = item.title?.toString() ?? "";
|
||||
return (
|
||||
<a key={item.id ?? href ?? label} href={href || undefined} title={label} className="w-full no-underline" {...uiIdAttrs(item)}>
|
||||
<SidebarWithSections.NavItem
|
||||
icon={item.icon}
|
||||
selected={item.isActive}
|
||||
variant={collapsed ? "icon-only" : "icon-and-text"}
|
||||
className={item.disabled ? "pointer-events-none opacity-50" : undefined}
|
||||
>
|
||||
{label}
|
||||
</SidebarWithSections.NavItem>
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex h-screen w-full items-stretch bg-surface-neutral-primary" data-ui-id={UI_SURFACE_IDS.shell}>
|
||||
{/* Mobile-Backdrop */}
|
||||
{mobileOpen ? <div className="fixed inset-0 z-40 bg-surface-neutral-overlay md:hidden" onClick={() => setMobileOpen(false)} aria-hidden /> : null}
|
||||
|
||||
<SidebarWithSections
|
||||
data-ui-id={sidebarSurfaceId}
|
||||
data-ui-layout={layout}
|
||||
variant={collapsed ? "closed" : "open"}
|
||||
onToggleCollapse={() => setCollapsed((v) => !v)}
|
||||
className={SubframeCore.twClassNames(
|
||||
"z-50 max-md:fixed max-md:inset-y-0 max-md:left-0 max-md:transition-transform",
|
||||
mobileOpen ? "max-md:translate-x-0" : "max-md:-translate-x-full"
|
||||
)}
|
||||
>
|
||||
<div data-ui-id={`${sidebarSurfaceId}.content`} className="flex w-full flex-col gap-1">
|
||||
{navMain.map((group) => (
|
||||
<SidebarWithSections.NavSection
|
||||
key={group.id ?? group.title}
|
||||
label={group.title}
|
||||
showLabel={!collapsed && !!group.title}
|
||||
{...uiIdAttrs(group)}
|
||||
>
|
||||
{group.items.map((item) => renderNavItem(item))}
|
||||
</SidebarWithSections.NavSection>
|
||||
))}
|
||||
{navSecondary.length > 0 ? <SidebarWithSections.NavDivider /> : null}
|
||||
{navSecondary.flatMap((group) => group.items.map((item) => renderNavItem(item)))}
|
||||
</div>
|
||||
</SidebarWithSections>
|
||||
|
||||
<div className="flex h-full min-w-0 grow flex-col" data-ui-id={UI_SURFACE_IDS.shellInset}>
|
||||
{/* Topbar (Davids HeaderNavigation: Breadcrumb + Suche + Bell + Avatar) */}
|
||||
<header
|
||||
className="flex h-14 w-full shrink-0 items-center justify-between gap-2 border-b border-solid border-border-default bg-surface-neutral-secondary pl-6 pr-3 py-3 mobile:px-4"
|
||||
data-ui-id={UI_SURFACE_IDS.shellHeader}
|
||||
>
|
||||
<div className="flex min-w-0 items-center gap-3" data-ui-id={UI_SURFACE_IDS.shellBreadcrumb}>
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex h-8 w-8 items-center justify-center rounded-md text-icon-neutral-secondary hover:bg-surface-neutral-tertiary md:hidden"
|
||||
onClick={() => setMobileOpen((v) => !v)}
|
||||
aria-label={t("shared.menu")}
|
||||
data-ui-id={UI_ACTION_IDS.sidebarTrigger}
|
||||
>
|
||||
<FeatherMenu />
|
||||
</button>
|
||||
<Breadcrumbs>
|
||||
{currentTenant ? (
|
||||
<>
|
||||
<Breadcrumbs.Item>{currentTenant.name}</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider />
|
||||
</>
|
||||
) : null}
|
||||
<Breadcrumbs.Item active data-ui-id={UI_SURFACE_IDS.shellBreadcrumbCurrent}>
|
||||
{title || t("app.sidebar.dashboard")}
|
||||
</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 self-stretch pl-1" data-ui-id={UI_SURFACE_IDS.shellNavActions}>
|
||||
<button
|
||||
type="button"
|
||||
className="hidden md:flex md:min-w-[192px] md:max-w-[320px] md:grow"
|
||||
onClick={() => commandPalette.toggle()}
|
||||
aria-label={t("shared.search")}
|
||||
data-ui-id={UI_ACTION_IDS.search}
|
||||
>
|
||||
<SearchInput className="pointer-events-none h-auto w-full" size="small" placeholder={t("shared.searchPlaceholder")} />
|
||||
</button>
|
||||
<a href={params.tenant ? UrlUtils.currentTenantUrl(params, "notifications") : "#"} aria-label={t("app.sidebar.notifications", { defaultValue: "Notifications" })} data-ui-id={UI_ACTION_IDS.notifications}>
|
||||
<IconButton variant="ghost" size="small" icon={<FeatherBell />} />
|
||||
</a>
|
||||
|
||||
{user ? (
|
||||
<SubframeCore.DropdownMenu.Root>
|
||||
<SubframeCore.DropdownMenu.Trigger asChild>
|
||||
<Avatar className="cursor-pointer" border image={user.avatar ?? undefined} data-ui-id={UI_ACTION_IDS.more}>
|
||||
{UserDisplayUtils.avatarText(user)}
|
||||
</Avatar>
|
||||
</SubframeCore.DropdownMenu.Trigger>
|
||||
<SubframeCore.DropdownMenu.Portal>
|
||||
<SubframeCore.DropdownMenu.Content side="bottom" align="end" sideOffset={4} asChild>
|
||||
<DropdownMenu className="min-w-56">
|
||||
<DropdownMenu.DropdownUserItem title={UserDisplayUtils.fullName(user)} subtitle={user.email} image={user.avatar ?? undefined} />
|
||||
<DropdownMenu.DropdownDivider />
|
||||
{layout === "app" && params.tenant ? (
|
||||
<DropdownMenu.DropdownItem
|
||||
icon={<FeatherSettings />}
|
||||
onClick={() => navigate(UrlUtils.currentTenantUrl(params, "settings/profile"))}
|
||||
data-ui-id={UI_ACTION_IDS.profile}
|
||||
>
|
||||
{t("app.navbar.profile")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
{DARK_MODE_IN_APP ? (
|
||||
<DropdownMenu.DropdownItem icon={isDarkMode ? <FeatherSun /> : <FeatherMoon />} onClick={onThemeToggle}>
|
||||
{isDarkMode ? t("settings.profile.session.switchToLightMode") : t("settings.profile.session.switchToDarkMode")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
) : null}
|
||||
<DropdownMenu.DropdownItem icon={<FeatherLogOut />} onClick={onLogout} data-ui-id={UI_ACTION_IDS.signOut}>
|
||||
{t("app.navbar.signOut")}
|
||||
</DropdownMenu.DropdownItem>
|
||||
{layout === "app" && currentTenant && myTenants.length > 0 ? (
|
||||
<>
|
||||
<DropdownMenu.DropdownDivider />
|
||||
<DropdownMenu.DropdownNestedItem label={t("account.selectTenant.title")} icon={<FeatherUserSearch />}>
|
||||
{myTenants.map((tenant) => (
|
||||
<a key={tenant.id} href={appPath({ tenantSlug: tenant.slug, path: "dashboard", mode: "host-aware" })} className="no-underline">
|
||||
<DropdownMenu.DropdownItem selected={tenant.id === currentTenant.id}>{tenant.name}</DropdownMenu.DropdownItem>
|
||||
</a>
|
||||
))}
|
||||
</DropdownMenu.DropdownNestedItem>
|
||||
</>
|
||||
) : null}
|
||||
</DropdownMenu>
|
||||
</SubframeCore.DropdownMenu.Content>
|
||||
</SubframeCore.DropdownMenu.Portal>
|
||||
</SubframeCore.DropdownMenu.Root>
|
||||
) : null}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main id="main-content" ref={mainElement} className="flex-1 overflow-auto focus:outline-hidden" tabIndex={-1} data-ui-id={UI_SURFACE_IDS.shellMain}>
|
||||
<div key={params.tenant} className="pb-20 sm:pb-0">
|
||||
{children}
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// data-ui-id-Attribute (id + Pattern + Params) wie getUiIdAttributes der shadcn-Shell.
|
||||
function uiIdAttrs(item: Pick<SideBarItem, "id" | "uiIdPattern" | "uiIdParams">): Record<string, string> {
|
||||
const attrs: Record<string, string> = {};
|
||||
if (item.id) attrs["data-ui-id"] = item.id;
|
||||
if (item.uiIdPattern) attrs["data-ui-id-pattern"] = item.uiIdPattern;
|
||||
if (item.uiIdParams) {
|
||||
Object.entries(item.uiIdParams).forEach(([key, value]) => {
|
||||
attrs[`data-ui-id-param-${key.replace(/[^a-zA-Z0-9]/g, "").toLowerCase()}`] = String(value);
|
||||
});
|
||||
}
|
||||
return attrs;
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import Modal from "~/components/ui/modals/Modal";
|
||||
import { LogWithDetails } from "~/utils/db/logs.db.server";
|
||||
import { redactDiagnosticJsonString } from "~/utils/redaction";
|
||||
|
||||
export default function LogDetailsButton({ item }: { item: LogWithDetails }) {
|
||||
const { t } = useTranslation();
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
function stringifyDetails() {
|
||||
return redactDiagnosticJsonString(item.details);
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<div className="flex space-x-2">
|
||||
{item.details !== null && (
|
||||
<button type="button" onClick={() => setOpen(true)} className="hover:text-foreground italic underline">
|
||||
{t("models.log.details")}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Modal className="sm:max-w-md" open={open} setOpen={setOpen}>
|
||||
<div className="flex justify-between space-x-2">
|
||||
<div className="text-foreground text-lg font-medium">{t("models.log.details")}</div>
|
||||
<div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(stringifyDetails());
|
||||
}}
|
||||
className="bg-theme-100 text-theme-700 hover:bg-theme-200 focus:ring-ring inline-flex items-center rounded-md border border-transparent px-3 py-2 text-sm font-medium leading-4 focus:outline-hidden focus:ring-2 focus:ring-offset-2"
|
||||
>
|
||||
{t("shared.copy")}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div className="prose bg-foreground/90 border-border mt-2 rounded-lg border-2 border-dashed">
|
||||
<pre>{stringifyDetails()}</pre>
|
||||
</div>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useMemo } from "react";
|
||||
import type { Log } from "@toolctrl/db/prisma-browser";
|
||||
import { LogWithDetails } from "~/utils/db/logs.db.server";
|
||||
import { PaginationDto } from "~/application/dtos/data/PaginationDto";
|
||||
import TableSimple from "~/components/ui/tables/TableSimple";
|
||||
import { RowHeaderDisplayDto } from "~/application/dtos/data/RowHeaderDisplayDto";
|
||||
import { Link } from "react-router";
|
||||
import LogDetailsButton from "./LogDetailsButton";
|
||||
import { absoluteAppPath } from "~/utils/app/CrossHostUrls";
|
||||
import { useRootData } from "~/utils/data/useRootData";
|
||||
import { createLocaleFormatters } from "~/locale/format";
|
||||
import { getLogActionI18nKey } from "./logActionI18n";
|
||||
|
||||
export type LogsTableItem = Log & {
|
||||
user?: LogWithDetails["user"] | { id: string; email: string; firstName?: string | null; lastName?: string | null } | null;
|
||||
apiKey?: LogWithDetails["apiKey"] | { id: string; alias: string } | null;
|
||||
tenant?: LogWithDetails["tenant"] | { id: string; name: string; slug?: string | null } | null;
|
||||
comment?: LogWithDetails["comment"] | { id: string; value: string } | null;
|
||||
};
|
||||
|
||||
interface Props {
|
||||
items: LogsTableItem[];
|
||||
withTenant: boolean;
|
||||
pagination: PaginationDto;
|
||||
}
|
||||
|
||||
export default function LogsTable({ withTenant, items, pagination }: Props) {
|
||||
const { i18n, t } = useTranslation();
|
||||
const formatters = useMemo(() => createLocaleFormatters(i18n.language), [i18n.language]);
|
||||
const rootData = useRootData();
|
||||
|
||||
const headers = useMemo(() => {
|
||||
let headers: RowHeaderDisplayDto<LogsTableItem>[] = [];
|
||||
if (withTenant) {
|
||||
headers.push({
|
||||
name: "tenant",
|
||||
title: t("models.tenant.object"),
|
||||
value: (item) => (
|
||||
<div>
|
||||
{item.tenant ? (
|
||||
<Link
|
||||
to={absoluteAppPath(rootData.routing, item.tenant.slug ?? item.tenant.id)}
|
||||
className="focus:bg-secondary/90 hover:border-border rounded-md border-b border-dashed border-transparent"
|
||||
>
|
||||
{item.tenant.name}
|
||||
</Link>
|
||||
) : (
|
||||
<div>-</div>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
breakpoint: "sm",
|
||||
});
|
||||
}
|
||||
headers = [
|
||||
...headers,
|
||||
{
|
||||
name: "action",
|
||||
title: t("models.log.action"),
|
||||
value: (item) => (
|
||||
<div>
|
||||
{t(getLogActionI18nKey(item.action) ?? item.action, {
|
||||
defaultValue: item.action,
|
||||
})}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "url",
|
||||
title: t("models.log.url"),
|
||||
value: (item) => <div>{item.url}</div>,
|
||||
},
|
||||
{
|
||||
name: "details",
|
||||
title: t("models.log.details"),
|
||||
value: (item) => <LogDetailsButton item={item as LogWithDetails} />,
|
||||
},
|
||||
{
|
||||
name: "createdBy",
|
||||
title: t("shared.createdBy"),
|
||||
value: (item) => (
|
||||
<div>
|
||||
{item.user && (
|
||||
<span>
|
||||
{item.user.firstName} {item.user.lastName} <span className="text-muted-foreground text-xs">({item.user.email})</span>
|
||||
</span>
|
||||
)}
|
||||
{item.apiKey && (
|
||||
<span>
|
||||
{t("models.apiKey.object")} <span className="text-muted-foreground text-xs">({item.apiKey.alias})</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "createdAt",
|
||||
title: t("shared.createdAt"),
|
||||
value: (item) => formatters.relativeDate(item.createdAt),
|
||||
formattedValue: (item) => (
|
||||
<div className="flex flex-col">
|
||||
<div>{formatters.date(item.createdAt, { dateStyle: "medium" })}</div>
|
||||
<div className="text-xs">{formatters.relativeDate(item.createdAt)}</div>
|
||||
</div>
|
||||
),
|
||||
className: "text-muted-foreground text-xs",
|
||||
breakpoint: "sm",
|
||||
sortable: true,
|
||||
},
|
||||
];
|
||||
return headers;
|
||||
}, [formatters, rootData.routing, t, withTenant]);
|
||||
|
||||
return <TableSimple items={items} headers={headers} pagination={pagination} className={() => "text-sm"} />;
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { getLogActionI18nKey, LOG_ACTION_I18N_KEYS } from "./logActionI18n";
|
||||
|
||||
const repoRoot = process.cwd();
|
||||
|
||||
describe("log action i18n", () => {
|
||||
it.each([
|
||||
["Admin Settings Updated", "models.log.actions.adminSettingsUpdated"],
|
||||
["admin.settings.updated", "models.log.actions.adminSettingsUpdated"],
|
||||
["API Key Created", "models.log.actions.apiKeyCreated"],
|
||||
["API Key Updated", "models.log.actions.apiKeyUpdated"],
|
||||
["API Key Rotated", "models.log.actions.apiKeyRotated"],
|
||||
["API Key Deleted", "models.log.actions.apiKeyDeleted"],
|
||||
["admin.apiKeys.created", "models.log.actions.apiKeyCreated"],
|
||||
["admin.apiKeys.updated", "models.log.actions.apiKeyUpdated"],
|
||||
["admin.apiKeys.deleted", "models.log.actions.apiKeyDeleted"],
|
||||
["plugin.settings_frame.violation", "models.log.actions.pluginSettingsFrameViolation"],
|
||||
["settings.apiKeys.created", "models.log.actions.apiKeyCreated"],
|
||||
["settings.apiKeys.updated", "models.log.actions.apiKeyUpdated"],
|
||||
["settings.apiKeys.rotated", "models.log.actions.apiKeyRotated"],
|
||||
["settings.apiKeys.deleted", "models.log.actions.apiKeyDeleted"],
|
||||
["admin.accountUserRoles.created", "models.log.actions.created"],
|
||||
["admin.accountUserRoles.deleted", "models.log.actions.deleted"],
|
||||
["admin.adminUserRoles.created", "models.log.actions.created"],
|
||||
["admin.adminUserRoles.deleted", "models.log.actions.deleted"],
|
||||
["admin.permissions.created", "models.log.actions.created"],
|
||||
["admin.permissions.updated", "models.log.actions.updated"],
|
||||
["admin.permissions.deleted", "models.log.actions.deleted"],
|
||||
["admin.roles.created", "models.log.actions.created"],
|
||||
["admin.roles.updated", "models.log.actions.updated"],
|
||||
["admin.roles.deleted", "models.log.actions.deleted"],
|
||||
["Created", "models.log.actions.created"],
|
||||
["Created pricing plan", "models.log.actions.createdPricingPlan"],
|
||||
["admin.pricing.plan.created", "models.log.actions.createdPricingPlan"],
|
||||
["admin.pricing.createdPlan", "models.log.actions.createdPricingPlan"],
|
||||
["Created pricing plans", "models.log.actions.createdPricingPlans"],
|
||||
["admin.pricing.createdPlans", "models.log.actions.createdPricingPlans"],
|
||||
["Deleted", "models.log.actions.deleted"],
|
||||
["Deleted pricing plan", "models.log.actions.deletedPricingPlan"],
|
||||
["admin.pricing.deletedPlan", "models.log.actions.deletedPricingPlan"],
|
||||
["Subscribed", "models.log.actions.subscribed"],
|
||||
["settings.groups.created", "models.log.actions.created"],
|
||||
["settings.groups.updated", "models.log.actions.updated"],
|
||||
["settings.groups.deleted", "models.log.actions.deleted"],
|
||||
["settings.memberRoles.created", "models.log.actions.created"],
|
||||
["settings.memberRoles.deleted", "models.log.actions.deleted"],
|
||||
["settings.rolesAndPermissions.userRoles.created", "models.log.actions.created"],
|
||||
["settings.rolesAndPermissions.userRoles.deleted", "models.log.actions.deleted"],
|
||||
["settings.tenant.updateDetails", "models.log.actions.updateTenantDetails"],
|
||||
["Update tenant details", "models.log.actions.updateTenantDetails"],
|
||||
["Updated", "models.log.actions.updated"],
|
||||
["Updated AI overage configuration", "models.log.actions.updatedAiOverageConfiguration"],
|
||||
["admin.pricing.aiOverage.updated", "models.log.actions.updatedAiOverageConfiguration"],
|
||||
["Updated pricing plan", "models.log.actions.updatedPricingPlan"],
|
||||
["portal.pricing.plan.updated", "models.log.actions.updatedPricingPlan"],
|
||||
["Workspace Role Created", "models.log.actions.workspaceRoleCreated"],
|
||||
["Workspace Role Updated", "models.log.actions.workspaceRoleUpdated"],
|
||||
["Workspace Role Deleted", "models.log.actions.workspaceRoleDeleted"],
|
||||
["upload.rejected.scan", "models.log.actions.uploadRejectedScan"],
|
||||
])("maps %s to %s", (action, key) => {
|
||||
expect(getLogActionI18nKey(action)).toBe(key);
|
||||
});
|
||||
|
||||
it("leaves unknown actions available for the original-value fallback", () => {
|
||||
expect(getLogActionI18nKey("Custom Billing Export")).toBeUndefined();
|
||||
});
|
||||
|
||||
it("keeps every mapped audit action backed by English and German locale copy", () => {
|
||||
const en = readTranslations("en");
|
||||
const de = readTranslations("de");
|
||||
|
||||
for (const key of Object.values(LOG_ACTION_I18N_KEYS)) {
|
||||
expect(readTranslationValue(en, key), `en:${key}`).toEqual(expect.any(String));
|
||||
expect(readTranslationValue(de, key), `de:${key}`).toEqual(expect.any(String));
|
||||
expect(readTranslationValue(en, key)?.trim(), `en:${key}`).not.toBe("");
|
||||
expect(readTranslationValue(de, key)?.trim(), `de:${key}`).not.toBe("");
|
||||
}
|
||||
});
|
||||
|
||||
it("maps every literal createLog/createAdminLog action in route code", () => {
|
||||
const routeFiles = listRouteSourceFiles(path.join(repoRoot, "apps/web/app/routes"));
|
||||
const actions = routeFiles.flatMap((file) => {
|
||||
const source = fs.readFileSync(file, "utf8");
|
||||
return Array.from(source.matchAll(/create(?:Admin)?Log\(\s*[^,\n]+,\s*(?:[^,\n]+,\s*)?"([^"]+)"/gu))
|
||||
.map((match) => match[1])
|
||||
.filter((action): action is string => typeof action === "string");
|
||||
});
|
||||
|
||||
expect(actions).toEqual(expect.arrayContaining(["admin.pricing.plan.created", "portal.pricing.plan.updated"]));
|
||||
for (const action of actions) {
|
||||
expect(getLogActionI18nKey(action), action).toBeDefined();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function listRouteSourceFiles(directory: string): string[] {
|
||||
return fs.readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
|
||||
const absolutePath = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) {
|
||||
return listRouteSourceFiles(absolutePath);
|
||||
}
|
||||
if (!/\.(ts|tsx)$/u.test(entry.name) || /\.test\./u.test(entry.name)) {
|
||||
return [];
|
||||
}
|
||||
return [absolutePath];
|
||||
});
|
||||
}
|
||||
|
||||
function readTranslations(locale: "de" | "en") {
|
||||
return JSON.parse(fs.readFileSync(path.join(repoRoot, "apps/web/public/locales", locale, "translations.json"), "utf8")) as Record<string, unknown>;
|
||||
}
|
||||
|
||||
function readTranslationValue(translations: Record<string, unknown>, key: string): string | undefined {
|
||||
const value = key.split(".").reduce<unknown>((current, segment) => {
|
||||
if (!current || typeof current !== "object" || !(segment in current)) {
|
||||
return undefined;
|
||||
}
|
||||
return (current as Record<string, unknown>)[segment];
|
||||
}, translations);
|
||||
|
||||
return typeof value === "string" ? value : undefined;
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
export const LOG_ACTION_I18N_KEYS = {
|
||||
"Admin Settings Updated": "models.log.actions.adminSettingsUpdated",
|
||||
"admin.settings.updated": "models.log.actions.adminSettingsUpdated",
|
||||
"API Key Created": "models.log.actions.apiKeyCreated",
|
||||
"API Key Updated": "models.log.actions.apiKeyUpdated",
|
||||
"API Key Rotated": "models.log.actions.apiKeyRotated",
|
||||
"API Key Deleted": "models.log.actions.apiKeyDeleted",
|
||||
"admin.apiKeys.created": "models.log.actions.apiKeyCreated",
|
||||
"admin.apiKeys.updated": "models.log.actions.apiKeyUpdated",
|
||||
"admin.apiKeys.deleted": "models.log.actions.apiKeyDeleted",
|
||||
"plugin.settings_frame.violation": "models.log.actions.pluginSettingsFrameViolation",
|
||||
"settings.apiKeys.created": "models.log.actions.apiKeyCreated",
|
||||
"settings.apiKeys.updated": "models.log.actions.apiKeyUpdated",
|
||||
"settings.apiKeys.rotated": "models.log.actions.apiKeyRotated",
|
||||
"settings.apiKeys.deleted": "models.log.actions.apiKeyDeleted",
|
||||
"admin.accountUserRoles.created": "models.log.actions.created",
|
||||
"admin.accountUserRoles.deleted": "models.log.actions.deleted",
|
||||
"admin.adminUserRoles.created": "models.log.actions.created",
|
||||
"admin.adminUserRoles.deleted": "models.log.actions.deleted",
|
||||
"admin.permissions.created": "models.log.actions.created",
|
||||
"admin.permissions.updated": "models.log.actions.updated",
|
||||
"admin.permissions.deleted": "models.log.actions.deleted",
|
||||
"admin.roles.created": "models.log.actions.created",
|
||||
"admin.roles.updated": "models.log.actions.updated",
|
||||
"admin.roles.deleted": "models.log.actions.deleted",
|
||||
"Created": "models.log.actions.created",
|
||||
"Created pricing plan": "models.log.actions.createdPricingPlan",
|
||||
"admin.pricing.plan.created": "models.log.actions.createdPricingPlan",
|
||||
"admin.pricing.createdPlan": "models.log.actions.createdPricingPlan",
|
||||
"Created pricing plans": "models.log.actions.createdPricingPlans",
|
||||
"admin.pricing.createdPlans": "models.log.actions.createdPricingPlans",
|
||||
"Deleted": "models.log.actions.deleted",
|
||||
"Deleted pricing plan": "models.log.actions.deletedPricingPlan",
|
||||
"admin.pricing.deletedPlan": "models.log.actions.deletedPricingPlan",
|
||||
"Subscribed": "models.log.actions.subscribed",
|
||||
"settings.groups.created": "models.log.actions.created",
|
||||
"settings.groups.updated": "models.log.actions.updated",
|
||||
"settings.groups.deleted": "models.log.actions.deleted",
|
||||
"settings.memberRoles.created": "models.log.actions.created",
|
||||
"settings.memberRoles.deleted": "models.log.actions.deleted",
|
||||
"settings.rolesAndPermissions.userRoles.created": "models.log.actions.created",
|
||||
"settings.rolesAndPermissions.userRoles.deleted": "models.log.actions.deleted",
|
||||
"settings.tenant.updateDetails": "models.log.actions.updateTenantDetails",
|
||||
"Update tenant details": "models.log.actions.updateTenantDetails",
|
||||
"Updated": "models.log.actions.updated",
|
||||
"Updated AI overage configuration": "models.log.actions.updatedAiOverageConfiguration",
|
||||
"admin.pricing.aiOverage.updated": "models.log.actions.updatedAiOverageConfiguration",
|
||||
"Updated pricing plan": "models.log.actions.updatedPricingPlan",
|
||||
"portal.pricing.plan.updated": "models.log.actions.updatedPricingPlan",
|
||||
"Workspace Role Created": "models.log.actions.workspaceRoleCreated",
|
||||
"Workspace Role Updated": "models.log.actions.workspaceRoleUpdated",
|
||||
"Workspace Role Deleted": "models.log.actions.workspaceRoleDeleted",
|
||||
"upload.rejected.scan": "models.log.actions.uploadRejectedScan",
|
||||
} as const;
|
||||
|
||||
export function getLogActionI18nKey(action: string): string | undefined {
|
||||
return LOG_ACTION_I18N_KEYS[action as keyof typeof LOG_ACTION_I18N_KEYS];
|
||||
}
|
||||
Reference in new issue
Block a user