WebUI module split; docs

This commit is contained in:
2026-06-24 10:18:47 +02:00
parent 30c11a6dcf
commit 44516a03aa
8 changed files with 558 additions and 74 deletions

View File

@@ -3,17 +3,20 @@ import { Navigate } from "react-router-dom";
import type { AuthInfo } from "../types";
import { isApiError } from "../api/client";
import DismissibleAlert from "./DismissibleAlert";
import { hasAnyScope } from "../utils/permissions";
import { hasAnyScope, hasScope } from "../utils/permissions";
type PermissionBoundaryProps = {
auth: AuthInfo;
anyOf: string[];
anyOf?: string[];
allOf?: string[];
fallback: string;
children: ReactNode;
};
export function PermissionBoundary({ auth, anyOf, fallback, children }: PermissionBoundaryProps) {
return hasAnyScope(auth, anyOf) ? <>{children}</> : <Navigate to={fallback} replace />;
export function PermissionBoundary({ auth, anyOf = [], allOf = [], fallback, children }: PermissionBoundaryProps) {
if (allOf.length && !allOf.every((scope) => hasScope(auth, scope))) return <Navigate to={fallback} replace />;
if (anyOf.length && !hasAnyScope(auth, anyOf)) return <Navigate to={fallback} replace />;
return <>{children}</>;
}
type ResourceAccessBoundaryProps = {