web: re-format with prettier
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
@ -1,4 +1,10 @@
|
||||
import { CoreApi, PolicyTestRequest, PropertyMapping, PropertymappingsApi, PropertyMappingTestResult } from "authentik-api";
|
||||
import {
|
||||
CoreApi,
|
||||
PolicyTestRequest,
|
||||
PropertyMapping,
|
||||
PropertymappingsApi,
|
||||
PropertyMappingTestResult,
|
||||
} from "authentik-api";
|
||||
import { t } from "@lingui/macro";
|
||||
import { customElement, property } from "lit-element";
|
||||
import { html, TemplateResult } from "lit-html";
|
||||
@ -13,11 +19,10 @@ import { first } from "../../utils";
|
||||
|
||||
@customElement("ak-property-mapping-test-form")
|
||||
export class PolicyTestForm extends Form<PolicyTestRequest> {
|
||||
|
||||
@property({attribute: false})
|
||||
@property({ attribute: false })
|
||||
mapping?: PropertyMapping;
|
||||
|
||||
@property({ attribute: false})
|
||||
@property({ attribute: false })
|
||||
result?: PropertyMappingTestResult;
|
||||
|
||||
@property({ attribute: false })
|
||||
@ -29,52 +34,62 @@ export class PolicyTestForm extends Form<PolicyTestRequest> {
|
||||
|
||||
send = (data: PolicyTestRequest): Promise<PropertyMappingTestResult> => {
|
||||
this.request = data;
|
||||
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllTestCreate({
|
||||
pmUuid: this.mapping?.pk || "",
|
||||
policyTestRequest: data,
|
||||
formatResult: true,
|
||||
}).then(result => this.result = result);
|
||||
return new PropertymappingsApi(DEFAULT_CONFIG)
|
||||
.propertymappingsAllTestCreate({
|
||||
pmUuid: this.mapping?.pk || "",
|
||||
policyTestRequest: data,
|
||||
formatResult: true,
|
||||
})
|
||||
.then((result) => (this.result = result));
|
||||
};
|
||||
|
||||
renderResult(): TemplateResult {
|
||||
return html`<ak-form-element-horizontal
|
||||
label=${t`Result`}>
|
||||
${this.result?.successful ?
|
||||
html`<ak-codemirror mode="javascript" ?readOnly=${true} value="${ifDefined(this.result?.result)}">
|
||||
</ak-codemirror>`:
|
||||
html`
|
||||
<div class="pf-c-form__group-label">
|
||||
<div class="c-form__horizontal-group">
|
||||
<span class="pf-c-form__label-text">${this.result?.result}</span>
|
||||
</div>
|
||||
</div>`}
|
||||
return html`<ak-form-element-horizontal label=${t`Result`}>
|
||||
${this.result?.successful
|
||||
? html`<ak-codemirror
|
||||
mode="javascript"
|
||||
?readOnly=${true}
|
||||
value="${ifDefined(this.result?.result)}"
|
||||
>
|
||||
</ak-codemirror>`
|
||||
: html` <div class="pf-c-form__group-label">
|
||||
<div class="c-form__horizontal-group">
|
||||
<span class="pf-c-form__label-text">${this.result?.result}</span>
|
||||
</div>
|
||||
</div>`}
|
||||
</ak-form-element-horizontal>`;
|
||||
}
|
||||
|
||||
renderForm(): TemplateResult {
|
||||
return html`<form class="pf-c-form pf-m-horizontal">
|
||||
<ak-form-element-horizontal
|
||||
label=${t`User`}
|
||||
?required=${true}
|
||||
name="user">
|
||||
<ak-form-element-horizontal label=${t`User`} ?required=${true} name="user">
|
||||
<select class="pf-c-form-control">
|
||||
${until(new CoreApi(DEFAULT_CONFIG).coreUsersList({
|
||||
ordering: "username",
|
||||
}).then(users => {
|
||||
return users.results.map(user => {
|
||||
return html`<option ?selected=${this.request?.user.toString() === user.pk.toString()} value=${user.pk}>${user.username}</option>`;
|
||||
});
|
||||
}), html`<option>${t`Loading...`}</option>`)}
|
||||
${until(
|
||||
new CoreApi(DEFAULT_CONFIG)
|
||||
.coreUsersList({
|
||||
ordering: "username",
|
||||
})
|
||||
.then((users) => {
|
||||
return users.results.map((user) => {
|
||||
return html`<option
|
||||
?selected=${this.request?.user.toString() ===
|
||||
user.pk.toString()}
|
||||
value=${user.pk}
|
||||
>
|
||||
${user.username}
|
||||
</option>`;
|
||||
});
|
||||
}),
|
||||
html`<option>${t`Loading...`}</option>`,
|
||||
)}
|
||||
</select>
|
||||
</ak-form-element-horizontal>
|
||||
<ak-form-element-horizontal
|
||||
label=${t`Context`}
|
||||
name="context">
|
||||
<ak-codemirror mode="yaml" value=${YAML.stringify(first(this.request?.context, {}))}>>
|
||||
<ak-form-element-horizontal label=${t`Context`} name="context">
|
||||
<ak-codemirror mode="yaml" value=${YAML.stringify(first(this.request?.context, {}))}
|
||||
>>
|
||||
</ak-codemirror>
|
||||
</ak-form-element-horizontal>
|
||||
${this.result ? this.renderResult(): html``}
|
||||
${this.result ? this.renderResult() : html``}
|
||||
</form>`;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user