import { Flow, FlowDesignationEnum, FlowPolicyEngineModeEnum, FlowsApi } from "authentik-api"; import { t } from "@lingui/macro"; import { customElement } from "lit-element"; import { html, TemplateResult } from "lit-html"; import { DEFAULT_CONFIG } from "../../api/Config"; import { ifDefined } from "lit-html/directives/if-defined"; import "../../elements/forms/HorizontalFormElement"; import { ModelForm } from "../../elements/forms/ModelForm"; @customElement("ak-flow-form") export class FlowForm extends ModelForm { loadInstance(pk: string): Promise { return new FlowsApi(DEFAULT_CONFIG).flowsInstancesRead({ slug: pk, }); } getSuccessMessage(): string { if (this.instance) { return t`Successfully updated flow.`; } else { return t`Successfully created flow.`; } } send = (data: Flow): Promise => { let writeOp: Promise; if (this.instance) { writeOp = new FlowsApi(DEFAULT_CONFIG).flowsInstancesUpdate({ slug: this.instance.slug, data: data }); } else { writeOp = new FlowsApi(DEFAULT_CONFIG).flowsInstancesCreate({ data: data }); } const background = this.getFormFile(); if (background) { return writeOp.then(flow => { return new FlowsApi(DEFAULT_CONFIG).flowsInstancesSetBackground({ slug: flow.slug, file: background }); }); } return writeOp; }; renderDesignations(): TemplateResult { return html` `; } renderForm(): TemplateResult { return html`

${t`Shown as the Title in Flow pages.`}

${t`Visible in the URL.`}

${t`Decides what this Flow is used for. For example, the Authentication flow is redirect to when an un-authenticated user visits authentik.`}

${t`Background shown during execution.`}

`; } }