import { t } from "@lingui/macro"; import { customElement } from "@lit/reactive-element/decorators/custom-element.js"; import { CSSResult, LitElement, TemplateResult, html } from "lit"; import { property } from "lit/decorators.js"; import AKGlobal from "../../authentik.css"; import PFButton from "@patternfly/patternfly/components/Button/button.css"; import PFRadio from "@patternfly/patternfly/components/Radio/radio.css"; import PFBase from "@patternfly/patternfly/patternfly-base.css"; import { PoliciesApi, TypeCreate } from "@goauthentik/api"; import { DEFAULT_CONFIG } from "../../api/Config"; import "../../elements/forms/ProxyForm"; import "../../elements/wizard/FormWizardPage"; import "../../elements/wizard/Wizard"; import { WizardPage } from "../../elements/wizard/WizardPage"; import "./dummy/DummyPolicyForm"; import "./event_matcher/EventMatcherPolicyForm"; import "./expiry/ExpiryPolicyForm"; import "./expression/ExpressionPolicyForm"; import "./hibp/HaveIBeenPwnedPolicyForm"; import "./password/PasswordPolicyForm"; import "./reputation/ReputationPolicyForm"; @customElement("ak-policy-wizard-initial") export class InitialPolicyWizardPage extends WizardPage { @property({ attribute: false }) policyTypes: TypeCreate[] = []; static get styles(): CSSResult[] { return [PFBase, PFButton, AKGlobal, PFRadio]; } render(): TemplateResult { return html` ${this.policyTypes.map((type) => { return html`
{ this.host.setSteps( "initial", `type-${type.component}-${type.modelName}`, ); this._isValid = true; }} /> ${type.description}
`; })} `; } } @customElement("ak-policy-wizard") export class PolicyWizard extends LitElement { static get styles(): CSSResult[] { return [PFBase, PFButton, AKGlobal, PFRadio]; } @property() createText = t`Create`; @property({ attribute: false }) policyTypes: TypeCreate[] = []; firstUpdated(): void { new PoliciesApi(DEFAULT_CONFIG).policiesAllTypesList().then((types) => { this.policyTypes = types; }); } render(): TemplateResult { return html` t`Select type`} .policyTypes=${this.policyTypes} > ${this.policyTypes.map((type) => { return html` t`Create ${type.name}`} > `; })} `; } }