import { BasePolicyForm } from "@goauthentik/admin/policies/BasePolicyForm"; import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import "@goauthentik/elements/forms/FormGroup"; import "@goauthentik/elements/forms/HorizontalFormElement"; import { msg } from "@lit/localize"; import { TemplateResult, html } from "lit"; import { customElement } from "lit/decorators.js"; import { ifDefined } from "lit/directives/if-defined.js"; import { DummyPolicy, PoliciesApi } from "@goauthentik/api"; @customElement("ak-policy-dummy-form") export class DummyPolicyForm extends BasePolicyForm { loadInstance(pk: string): Promise { return new PoliciesApi(DEFAULT_CONFIG).policiesDummyRetrieve({ policyUuid: pk, }); } async send(data: DummyPolicy): Promise { if (this.instance) { return new PoliciesApi(DEFAULT_CONFIG).policiesDummyUpdate({ policyUuid: this.instance.pk || "", dummyPolicyRequest: data, }); } return new PoliciesApi(DEFAULT_CONFIG).policiesDummyCreate({ dummyPolicyRequest: data, }); } renderForm(): TemplateResult { return html` ${msg( "A policy used for testing. Always returns the same result as specified below after waiting a random duration.", )}

${msg( "When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged.", )}

${msg("Policy-specific settings")}

${msg( "The policy takes a random time to execute. This controls the minimum time it will take.", )}

`; } } declare global { interface HTMLElementTagNameMap { "ak-policy-dummy-form": DummyPolicyForm; } }