33 lines
1.0 KiB
TypeScript
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());
|
|
}
|