4a91a7d2e2
* fix repo in api client Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: re-organise files to match their interface Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * core: include version in script tags Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * cleanup maybe broken Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * revert rename Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: get rid of Client.ts Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * move more to common Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * more moving Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * format Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * unfuck files that vscode fucked, thanks Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * move more Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * finish moving (maybe) Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * ok more moving Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix more stuff that vs code destroyed Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * get rid "web" prefix for virtual package Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix locales Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * use custom base element Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix css file Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * don't run autoDetectLanguage when importing locale Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix circular dependencies Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: fix build Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
69 lines
2.7 KiB
TypeScript
69 lines
2.7 KiB
TypeScript
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import "@goauthentik/elements/CodeMirror";
|
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
|
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
|
|
|
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 { NotificationWebhookMapping, PropertymappingsApi } from "@goauthentik/api";
|
|
|
|
@customElement("ak-property-mapping-notification-form")
|
|
export class PropertyMappingNotification extends ModelForm<NotificationWebhookMapping, string> {
|
|
loadInstance(pk: string): Promise<NotificationWebhookMapping> {
|
|
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsNotificationRetrieve({
|
|
pmUuid: pk,
|
|
});
|
|
}
|
|
|
|
getSuccessMessage(): string {
|
|
if (this.instance) {
|
|
return t`Successfully updated mapping.`;
|
|
} else {
|
|
return t`Successfully created mapping.`;
|
|
}
|
|
}
|
|
|
|
send = (data: NotificationWebhookMapping): Promise<NotificationWebhookMapping> => {
|
|
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`<form class="pf-c-form pf-m-horizontal">
|
|
<ak-form-element-horizontal label=${t`Name`} ?required=${true} name="name">
|
|
<input
|
|
type="text"
|
|
value="${ifDefined(this.instance?.name)}"
|
|
class="pf-c-form-control"
|
|
required
|
|
/>
|
|
</ak-form-element-horizontal>
|
|
<ak-form-element-horizontal label=${t`Expression`} ?required=${true} name="expression">
|
|
<ak-codemirror mode="python" value="${ifDefined(this.instance?.expression)}">
|
|
</ak-codemirror>
|
|
<p class="pf-c-form__helper-text">
|
|
${t`Expression using Python.`}
|
|
<a
|
|
target="_blank"
|
|
href="https://goauthentik.io/docs/property-mappings/expression?utm_source=authentik"
|
|
>
|
|
${t`See documentation for a list of all variables.`}
|
|
</a>
|
|
</p>
|
|
</ak-form-element-horizontal>
|
|
</form>`;
|
|
}
|
|
}
|