import { Link } from "react-router"; import type { AuthInfo, WizardDirectoryEntry } from "../types"; import { usePlatformLanguage } from "../i18n/LanguageContext"; import { hasAnyScope, hasScope } from "../utils/permissions"; import Card from "./Card"; export type WizardDirectoryProps = { entries: WizardDirectoryEntry[]; auth: AuthInfo; emptyText?: string; }; function canOpenWizard(auth: AuthInfo, entry: WizardDirectoryEntry): boolean { if (entry.available === false) return false; if (entry.allOf?.some((scope) => !hasScope(auth, scope))) return false; if (entry.anyOf?.length && !hasAnyScope(auth, entry.anyOf)) return false; return true; } export default function WizardDirectory({ entries, auth, emptyText = "No guided workflows are available." }: WizardDirectoryProps) { const { translateText } = usePlatformLanguage(); const visibleEntries = entries.filter( (entry) => !entry.anyOf?.length || hasAnyScope(auth, entry.anyOf) || entry.available === false ); if (!visibleEntries.length) { return
{translateText(emptyText)}
; } return ({translateText(entry.description)}
} {!available && entry.unavailableReason && ({translateText(entry.unavailableReason)}
)}