import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import "@goauthentik/elements/CodeMirror"; import { CodeMirrorMode } from "@goauthentik/elements/CodeMirror"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { ModelForm } from "@goauthentik/elements/forms/ModelForm"; import "@goauthentik/elements/forms/Radio"; import "@goauthentik/elements/forms/SearchSelect"; import { ApplicationEntitlement, CoreApi } from "@goauthentik/api"; import YAML from "yaml"; import { msg } from "@lit/localize"; import { CSSResult } from "lit"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import PFContent from "@patternfly/patternfly/components/Content/content.css"; @customElement("ak-application-entitlement-form") export class ApplicationEntitlementForm extends ModelForm { async loadInstance(pk: string): Promise { return new CoreApi(DEFAULT_CONFIG).coreApplicationEntitlementsRetrieve({ pbmUuid: pk, }); } @property() targetPk?: string; getSuccessMessage(): string { if (this.instance?.pbmUuid) { return msg("Successfully updated entitlement."); } return msg("Successfully created entitlement."); } static get styles(): CSSResult[] { return [...super.styles, PFContent]; } send(data: ApplicationEntitlement): Promise { if (this.targetPk) { data.app = this.targetPk; } if (this.instance?.pbmUuid) { return new CoreApi(DEFAULT_CONFIG).coreApplicationEntitlementsUpdate({ pbmUuid: this.instance.pbmUuid || "", applicationEntitlementRequest: data, }); } return new CoreApi(DEFAULT_CONFIG).coreApplicationEntitlementsCreate({ applicationEntitlementRequest: data, }); } renderForm(): TemplateResult { return html`

${msg("Set custom attributes using YAML or JSON.")}

`; } } declare global { interface HTMLElementTagNameMap { "ak-application-entitlement-form": ApplicationEntitlementForm; } }