import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { CoreApi, Group } from "@goauthentik/api"; import { AKResponse } from "../../api/Client"; import { DEFAULT_CONFIG } from "../../api/Config"; import { uiConfig } from "../../common/config"; import { PFColor } from "../../elements/Label"; import "../../elements/buttons/SpinnerButton"; import { TableColumn } from "../../elements/table/Table"; import { TableModal } from "../../elements/table/TableModal"; @customElement("ak-user-group-select-table") export class GroupSelectModal extends TableModal { checkbox = true; checkboxChip = true; searchEnabled(): boolean { return true; } @property() confirm!: (selectedItems: Group[]) => Promise; order = "name"; async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreGroupsList({ ordering: this.order, page: page, pageSize: (await uiConfig()).pagination.perPage / 2, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn(t`Name`, "username"), new TableColumn(t`Superuser`, "is_superuser"), new TableColumn(t`Members`, ""), ]; } row(item: Group): TemplateResult[] { return [ html`
${item.name}
`, html` ${item.isSuperuser ? t`Yes` : t`No`} `, html`${item.users.length}`, ]; } renderSelectedChip(item: Group): TemplateResult { return html`${item.name}`; } renderModalInner(): TemplateResult { return html`

${t`Select groups to add user to`}

${this.renderTable()}
`; } }