import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { LDAPPropertyMapping, PropertymappingsApi } from "@goauthentik/api"; import { DEFAULT_CONFIG } from "../../api/Config"; import "../../elements/CodeMirror"; import "../../elements/forms/HorizontalFormElement"; import { ModelForm } from "../../elements/forms/ModelForm"; @customElement("ak-property-mapping-ldap-form") export class PropertyMappingLDAPForm extends ModelForm { loadInstance(pk: string): Promise { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsLdapRetrieve({ pmUuid: pk, }); } getSuccessMessage(): string { if (this.instance) { return t`Successfully updated mapping.`; } else { return t`Successfully created mapping.`; } } send = (data: LDAPPropertyMapping): Promise => { if (this.instance) { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsLdapUpdate({ pmUuid: this.instance.pk || "", lDAPPropertyMappingRequest: data, }); } else { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsLdapCreate({ lDAPPropertyMappingRequest: data, }); } }; renderForm(): TemplateResult { return html`

${t`Field of the user object this value is written to.`}

${t`Expression using Python.`} ${t`See documentation for a list of all variables.`}

`; } }