import { Flow, FlowDesignationEnum, FlowPolicyEngineModeEnum, FlowsApi } from "authentik-api"; import { gettext } from "django"; import { customElement, property } from "lit-element"; import { html, TemplateResult } from "lit-html"; import { DEFAULT_CONFIG } from "../../api/Config"; import { Form } from "../../elements/forms/Form"; import { ifDefined } from "lit-html/directives/if-defined"; import "../../elements/forms/HorizontalFormElement"; @customElement("ak-flow-form") export class FlowForm extends Form { @property({attribute: false}) flow?: Flow; getSuccessMessage(): string { if (this.flow) { return gettext("Successfully updated flow."); } else { return gettext("Successfully created flow."); } } send = (data: Flow): Promise => { let writeOp: Promise; if (this.flow) { writeOp = new FlowsApi(DEFAULT_CONFIG).flowsInstancesUpdate({ slug: this.flow.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`

${gettext("Shown as the Title in Flow pages.")}

${gettext("Visible in the URL.")}

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

${gettext("Background shown during execution.")}

`; } }