Files
govoplan-core/webui/src/components/PolicyPathHelp.tsx
T
zemion c61abe154c
Dependency Audit / dependency-audit (push) Has been cancelled
Module Matrix / module-matrix (push) Has been cancelled
Add module event producer coverage
2026-07-10 18:40:38 +02:00

33 lines
1.0 KiB
TypeScript

import type { ReactNode } from "react";
import type { PolicySourcePathItem } from "./PolicySourcePath";
export type PolicyPathHelpProps = {
lines: ReactNode[];
className?: string;
lineClassName?: string;
};
export type NormalizedPolicySourcePathItem = {
label: string;
policy?: unknown;
};
export default function PolicyPathHelp({ lines, className = "", lineClassName = "" }: PolicyPathHelpProps) {
return (
<span className={["policy-path-help", className].filter(Boolean).join(" ")}>
{lines.map((line, index) =>
<span className={["policy-path-help-line", lineClassName].filter(Boolean).join(" ")} key={`${String(line)}-${index}`}>
{line}
</span>
)}
</span>);
}
export function normalizePolicySourcePathItems(items: PolicySourcePathItem[]): NormalizedPolicySourcePathItem[] {
return items.map((item) => {
if (typeof item === "string") return { label: item };
return { label: item.label, policy: item.policy };
}).filter((item) => item.label.trim());
}