import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { uiConfig } from "@goauthentik/common/ui/config"; import { first } from "@goauthentik/common/utils"; import { PFColor } from "@goauthentik/elements/Label"; import "@goauthentik/elements/buttons/SpinnerButton"; import { PaginatedResponse } from "@goauthentik/elements/table/Table"; import { TableColumn } from "@goauthentik/elements/table/Table"; import { TableModal } from "@goauthentik/elements/table/TableModal"; import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { CoreApi, User } from "@goauthentik/api"; @customElement("ak-group-member-select-table") export class MemberSelectTable extends TableModal { checkbox = true; checkboxChip = true; searchEnabled(): boolean { return true; } @property() confirm!: (selectedItems: User[]) => Promise; order = "username"; async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreUsersList({ ordering: this.order, page: page, pageSize: (await uiConfig()).pagination.perPage, search: this.search || "", }); } columns(): TableColumn[] { return [ new TableColumn(t`Name`, "username"), new TableColumn(t`Active`, "active"), new TableColumn(t`Last login`, "last_login"), ]; } row(item: User): TemplateResult[] { return [ html`
${item.username}
${item.name}
`, html` ${item.isActive ? t`Yes` : t`No`} `, html`${first(item.lastLogin?.toLocaleString(), t`-`)}`, ]; } renderSelectedChip(item: User): TemplateResult { return html`${item.username}`; } renderModalInner(): TemplateResult { return html`

${t`Select users to add`}

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