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 { PropertymappingsApi, ScopeMapping } 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-scope-form") export class PropertyMappingScopeForm extends ModelForm { loadInstance(pk: string): Promise { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsScopeRetrieve({ pmUuid: pk, }); } getSuccessMessage(): string { if (this.instance) { return t`Successfully updated mapping.`; } else { return t`Successfully created mapping.`; } } send = (data: ScopeMapping): Promise => { if (this.instance) { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsScopeUpdate({ pmUuid: this.instance.pk || "", scopeMappingRequest: data, }); } else { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsScopeCreate({ scopeMappingRequest: data, }); } }; renderForm(): TemplateResult { return html`

${t`Scope which the client can specify to access these properties.`}

${t`Description shown to the user when consenting. If left empty, the user won't be informed.`}

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

`; } }