import { DummyPolicy, PoliciesApi } from "@goauthentik/api"; import { t } from "@lingui/macro"; import { customElement } from "lit/decorators"; import { html, TemplateResult } from "lit"; import { DEFAULT_CONFIG } from "../../../api/Config"; import { ifDefined } from "lit/directives/if-defined"; import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/FormGroup"; import { first } from "../../../utils"; import { ModelForm } from "../../../elements/forms/ModelForm"; @customElement("ak-policy-dummy-form") export class DummyPolicyForm extends ModelForm { loadInstance(pk: string): Promise { return new PoliciesApi(DEFAULT_CONFIG).policiesDummyRetrieve({ policyUuid: pk, }); } getSuccessMessage(): string { if (this.instance) { return t`Successfully updated policy.`; } else { return t`Successfully created policy.`; } } send = (data: DummyPolicy): Promise => { if (this.instance) { return new PoliciesApi(DEFAULT_CONFIG).policiesDummyUpdate({ policyUuid: this.instance.pk || "", dummyPolicyRequest: data, }); } else { return new PoliciesApi(DEFAULT_CONFIG).policiesDummyCreate({ dummyPolicyRequest: data, }); } }; renderForm(): TemplateResult { return html`
${t`A policy used for testing. Always returns the same result as specified below after waiting a random duration.`}

${t`When this option is enabled, all executions of this policy will be logged. By default, only execution errors are logged.`}

${t`Policy-specific settings`}

${t`The policy takes a random time to execute. This controls the minimum time it will take.`}

`; } }