import { NotificationWebhookMapping, PropertymappingsApi } from "@goauthentik/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 "../../elements/CodeMirror"; import { ModelForm } from "../../elements/forms/ModelForm"; @customElement("ak-property-mapping-notification-form") export class PropertyMappingNotification extends ModelForm { loadInstance(pk: string): Promise { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsNotificationRetrieveRaw({ pmUuid: pk, }); } getSuccessMessage(): string { if (this.instance) { return t`Successfully updated mapping.`; } else { return t`Successfully created mapping.`; } } send = (data: NotificationWebhookMapping): Promise => { if (this.instance) { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsNotificationUpdate({ pmUuid: this.instance.pk || "", notificationWebhookMappingRequest: data, }); } else { return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsNotificationCreate({ notificationWebhookMappingRequest: data, }); } }; renderForm(): TemplateResult { return html`

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

`; } }