import { CoreApi, FlowsApi, FlowsInstancesListDesignationEnum, Tenant } 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 "../../elements/forms/HorizontalFormElement"; import "../../elements/forms/FormGroup"; import { first } from "../../utils"; import { ModelForm } from "../../elements/forms/ModelForm"; import { until } from "lit-html/directives/until"; import { DefaultTenant } from "../../elements/sidebar/SidebarBrand"; @customElement("ak-tenant-form") export class TenantForm extends ModelForm { loadInstance(pk: string): Promise { return new CoreApi(DEFAULT_CONFIG).coreTenantsRetrieve({ tenantUuid: pk }); } getSuccessMessage(): string { if (this.instance) { return t`Successfully updated tenant.`; } else { return t`Successfully created tenant.`; } } send = (data: Tenant): Promise => { if (this.instance?.tenantUuid) { return new CoreApi(DEFAULT_CONFIG).coreTenantsUpdate({ tenantUuid: this.instance.tenantUuid, tenantRequest: data }); } else { return new CoreApi(DEFAULT_CONFIG).coreTenantsCreate({ tenantRequest: data }); } }; renderForm(): TemplateResult { return html`

${t`Use this tenant for each domain that doesn't have a dedicated tenant.`}

${t`Branding settings`}

${t`Branding shown in page title and several other places.`}

${t`Icon shown in sidebar/header and flow executor.`}

${t`Icon shown in the browser tab.`}

${t`Default flows`}

${t`Flow used to authenticate users. If left empty, the first applicable flow sorted by the slug is used.`}

${t`Flow used to logout. If left empty, the first applicable flow sorted by the slug is used.`}

${t`Recovery flow. If left empty, the first applicable flow sorted by the slug is used.`}

${t`If set, users are able to unenroll themselves using this flow. If no flow is set, option is not shown.`}

`; } }