2021-04-03 17:26:43 +00:00
|
|
|
import { t } from "@lingui/macro";
|
2021-02-03 20:18:31 +00:00
|
|
|
import { customElement, html, property, TemplateResult } from "lit-element";
|
2021-02-09 16:04:55 +00:00
|
|
|
import { AKResponse } from "../../api/Client";
|
2021-02-03 20:18:31 +00:00
|
|
|
import { TablePage } from "../../elements/table/TablePage";
|
|
|
|
|
|
|
|
import "../../elements/buttons/Dropdown";
|
|
|
|
import "../../elements/buttons/SpinnerButton";
|
2021-08-12 20:03:13 +00:00
|
|
|
import "../../elements/forms/DeleteBulkForm";
|
2021-03-30 15:53:43 +00:00
|
|
|
import "../../elements/forms/ModalForm";
|
2021-03-31 21:07:57 +00:00
|
|
|
import "../../elements/forms/ProxyForm";
|
2021-03-30 15:53:43 +00:00
|
|
|
import "./PropertyMappingTestForm";
|
2021-03-31 21:07:57 +00:00
|
|
|
import "./PropertyMappingScopeForm";
|
|
|
|
import "./PropertyMappingLDAPForm";
|
2021-03-31 21:31:24 +00:00
|
|
|
import "./PropertyMappingSAMLForm";
|
2021-02-03 20:18:31 +00:00
|
|
|
import { TableColumn } from "../../elements/table/Table";
|
2021-02-19 16:10:30 +00:00
|
|
|
import { until } from "lit-html/directives/until";
|
2021-03-02 14:12:26 +00:00
|
|
|
import { PAGE_SIZE } from "../../constants";
|
2021-08-15 19:32:28 +00:00
|
|
|
import { PropertyMapping, PropertymappingsApi } from "@goauthentik/api";
|
2021-03-08 10:14:00 +00:00
|
|
|
import { DEFAULT_CONFIG } from "../../api/Config";
|
2021-03-31 21:07:57 +00:00
|
|
|
import { ifDefined } from "lit-html/directives/if-defined";
|
2021-02-03 20:18:31 +00:00
|
|
|
|
|
|
|
@customElement("ak-property-mapping-list")
|
|
|
|
export class PropertyMappingListPage extends TablePage<PropertyMapping> {
|
|
|
|
searchEnabled(): boolean {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
pageTitle(): string {
|
2021-04-03 17:26:43 +00:00
|
|
|
return t`Property Mappings`;
|
2021-02-03 20:18:31 +00:00
|
|
|
}
|
|
|
|
pageDescription(): string {
|
2021-04-03 17:26:43 +00:00
|
|
|
return t`Control how authentik exposes and interprets information.`;
|
2021-02-03 20:18:31 +00:00
|
|
|
}
|
|
|
|
pageIcon(): string {
|
2021-03-20 15:06:56 +00:00
|
|
|
return "pf-icon pf-icon-blueprint";
|
2021-02-03 20:18:31 +00:00
|
|
|
}
|
|
|
|
|
2021-08-05 10:30:43 +00:00
|
|
|
checkbox = true;
|
|
|
|
|
2021-02-03 20:18:31 +00:00
|
|
|
@property()
|
|
|
|
order = "name";
|
|
|
|
|
2021-08-03 15:52:21 +00:00
|
|
|
@property({ type: Boolean })
|
2021-02-03 20:18:31 +00:00
|
|
|
hideManaged = false;
|
|
|
|
|
2021-02-09 16:04:55 +00:00
|
|
|
apiEndpoint(page: number): Promise<AKResponse<PropertyMapping>> {
|
2021-03-08 10:14:00 +00:00
|
|
|
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllList({
|
2021-02-03 20:18:31 +00:00
|
|
|
ordering: this.order,
|
|
|
|
page: page,
|
2021-03-08 10:14:00 +00:00
|
|
|
pageSize: PAGE_SIZE,
|
2021-02-03 20:18:31 +00:00
|
|
|
search: this.search || "",
|
2021-05-16 16:38:19 +00:00
|
|
|
managedIsnull: this.hideManaged ? true : undefined,
|
2021-02-03 20:18:31 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
columns(): TableColumn[] {
|
|
|
|
return [
|
2021-04-04 14:56:16 +00:00
|
|
|
new TableColumn(t`Name`, "name"),
|
|
|
|
new TableColumn(t`Type`, "type"),
|
2021-08-05 10:30:43 +00:00
|
|
|
new TableColumn(t`Actions`),
|
2021-02-03 20:18:31 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2021-08-05 10:30:43 +00:00
|
|
|
renderToolbarSelected(): TemplateResult {
|
2021-08-12 20:03:13 +00:00
|
|
|
const disabled = this.selectedElements.length < 1;
|
|
|
|
return html`<ak-forms-delete-bulk
|
|
|
|
objectLabel=${t`Property Mapping(s)`}
|
|
|
|
.objects=${this.selectedElements}
|
|
|
|
.usedBy=${(item: PropertyMapping) => {
|
2021-08-05 10:30:43 +00:00
|
|
|
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllUsedByList({
|
|
|
|
pmUuid: item.pk,
|
|
|
|
});
|
|
|
|
}}
|
2021-08-12 20:03:13 +00:00
|
|
|
.delete=${(item: PropertyMapping) => {
|
2021-08-05 10:30:43 +00:00
|
|
|
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllDestroy({
|
|
|
|
pmUuid: item.pk,
|
|
|
|
});
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
|
|
|
|
${t`Delete`}
|
|
|
|
</button>
|
2021-08-12 20:03:13 +00:00
|
|
|
</ak-forms-delete-bulk>`;
|
2021-08-05 10:30:43 +00:00
|
|
|
}
|
|
|
|
|
2021-02-03 20:18:31 +00:00
|
|
|
row(item: PropertyMapping): TemplateResult[] {
|
|
|
|
return [
|
|
|
|
html`${item.name}`,
|
2021-03-08 10:14:00 +00:00
|
|
|
html`${item.verboseName}`,
|
2021-08-03 15:52:21 +00:00
|
|
|
html` <ak-forms-modal>
|
|
|
|
<span slot="submit"> ${t`Update`} </span>
|
|
|
|
<span slot="header"> ${t`Update ${item.verboseName}`} </span>
|
|
|
|
<ak-proxy-form
|
|
|
|
slot="form"
|
|
|
|
.args=${{
|
|
|
|
instancePk: item.pk,
|
|
|
|
}}
|
|
|
|
type=${ifDefined(item.component)}
|
|
|
|
>
|
|
|
|
</ak-proxy-form>
|
2021-08-05 10:30:43 +00:00
|
|
|
<button slot="trigger" class="pf-c-button pf-m-plain">
|
|
|
|
<i class="fas fa-edit"></i>
|
|
|
|
</button>
|
2021-08-03 15:52:21 +00:00
|
|
|
</ak-forms-modal>
|
|
|
|
<ak-forms-modal .closeAfterSuccessfulSubmit=${false}>
|
|
|
|
<span slot="submit"> ${t`Test`} </span>
|
|
|
|
<span slot="header"> ${t`Test Property Mapping`} </span>
|
|
|
|
<ak-property-mapping-test-form slot="form" .mapping=${item}>
|
|
|
|
</ak-property-mapping-test-form>
|
2021-08-10 10:46:50 +00:00
|
|
|
<button slot="trigger" class="pf-c-button pf-m-plain">
|
2021-08-08 13:18:32 +00:00
|
|
|
<i class="fas fa-vial" aria-hidden="true"></i>
|
|
|
|
</button>
|
2021-08-05 10:30:43 +00:00
|
|
|
</ak-forms-modal>`,
|
2021-02-03 20:18:31 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
renderToolbar(): TemplateResult {
|
2021-08-03 15:52:21 +00:00
|
|
|
return html` <ak-dropdown class="pf-c-dropdown">
|
|
|
|
<button class="pf-m-primary pf-c-dropdown__toggle" type="button">
|
|
|
|
<span class="pf-c-dropdown__toggle-text">${t`Create`}</span>
|
|
|
|
<i class="fas fa-caret-down pf-c-dropdown__toggle-icon" aria-hidden="true"></i>
|
|
|
|
</button>
|
|
|
|
<ul class="pf-c-dropdown__menu" hidden>
|
|
|
|
${until(
|
|
|
|
new PropertymappingsApi(DEFAULT_CONFIG)
|
|
|
|
.propertymappingsAllTypesList()
|
|
|
|
.then((types) => {
|
|
|
|
return types.map((type) => {
|
|
|
|
return html`<li>
|
|
|
|
<ak-forms-modal>
|
|
|
|
<span slot="submit"> ${t`Create`} </span>
|
|
|
|
<span slot="header"> ${t`Create ${type.name}`} </span>
|
|
|
|
<ak-proxy-form slot="form" type=${type.component}>
|
|
|
|
</ak-proxy-form>
|
|
|
|
<button slot="trigger" class="pf-c-dropdown__menu-item">
|
|
|
|
${type.name}<br />
|
|
|
|
<small>${type.description}</small>
|
|
|
|
</button>
|
|
|
|
</ak-forms-modal>
|
|
|
|
</li>`;
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
html`<ak-spinner></ak-spinner>`,
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
</ak-dropdown>
|
|
|
|
${super.renderToolbar()}`;
|
2021-02-03 20:18:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
renderToolbarAfter(): TemplateResult {
|
2021-04-04 17:03:25 +00:00
|
|
|
return html`
|
2021-08-03 15:52:21 +00:00
|
|
|
<div class="pf-c-toolbar__group pf-m-filter-group">
|
|
|
|
<div class="pf-c-toolbar__item pf-m-search-filter">
|
|
|
|
<div class="pf-c-input-group">
|
|
|
|
<div class="pf-c-check">
|
|
|
|
<input
|
|
|
|
class="pf-c-check__input"
|
|
|
|
type="checkbox"
|
|
|
|
id="hide-managed"
|
|
|
|
name="hide-managed"
|
|
|
|
?checked=${this.hideManaged}
|
|
|
|
@change=${() => {
|
|
|
|
this.hideManaged = !this.hideManaged;
|
|
|
|
this.page = 1;
|
|
|
|
this.fetch();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
<label class="pf-c-check__label" for="hide-managed"
|
|
|
|
>${t`Hide managed mappings`}</label
|
|
|
|
>
|
|
|
|
</div>
|
2021-02-03 20:18:31 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-03 15:52:21 +00:00
|
|
|
</div>`;
|
2021-02-03 20:18:31 +00:00
|
|
|
}
|
|
|
|
}
|