import { t } from "@lingui/macro"; import { customElement, html, property, TemplateResult } from "lit-element"; import { AKResponse } from "../../api/Client"; import { TablePage } from "../../elements/table/TablePage"; import "../../elements/forms/DeleteBulkForm"; import "../../elements/buttons/SpinnerButton"; import { TableColumn } from "../../elements/table/Table"; import { PAGE_SIZE } from "../../constants"; import { CoreApi, Group } from "@goauthentik/api"; import { DEFAULT_CONFIG } from "../../api/Config"; import "../../elements/forms/ModalForm"; import "./GroupForm"; @customElement("ak-group-list") export class GroupListPage extends TablePage { checkbox = true; searchEnabled(): boolean { return true; } pageTitle(): string { return t`Groups`; } pageDescription(): string { return t`Group users together and give them permissions based on the membership.`; } pageIcon(): string { return "pf-icon pf-icon-users"; } @property() order = "slug"; apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreGroupsList({ ordering: this.order, page: page, pageSize: PAGE_SIZE, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn(t`Name`, "name"), new TableColumn(t`Parent`, "parent"), new TableColumn(t`Members`), new TableColumn(t`Superuser privileges?`), new TableColumn(t`Actions`), ]; } renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; return html` { return new CoreApi(DEFAULT_CONFIG).coreGroupsUsedByList({ groupUuid: item.pk, }); }} .delete=${(item: Group) => { return new CoreApi(DEFAULT_CONFIG).coreGroupsDestroy({ groupUuid: item.pk, }); }} > `; } row(item: Group): TemplateResult[] { return [ html`${item.name}`, html`${item.parent || "-"}`, html`${Array.from(item.users || []).length}`, html`${item.isSuperuser ? t`Yes` : t`No`}`, html` ${t`Update`} ${t`Update Group`} `, ]; } renderToolbar(): TemplateResult { return html` ${t`Create`} ${t`Create Group`} ${super.renderToolbar()} `; } }