import { DEFAULT_CONFIG } from "@goauthentik/common/api/config"; import { uiConfig } from "@goauthentik/common/ui/config"; import "@goauthentik/elements/forms/DeleteBulkForm"; import { PaginatedResponse } from "@goauthentik/elements/table/Table"; import { Table, TableColumn } from "@goauthentik/elements/table/Table"; import { t } from "@lingui/macro"; import { TemplateResult, html } from "lit"; import { customElement, property } from "lit/decorators.js"; import { CoreApi, UserConsent } from "@goauthentik/api"; @customElement("ak-user-consent-list") export class UserConsentList extends Table { @property({ type: Number }) userId?: number; async apiEndpoint(page: number): Promise> { return new CoreApi(DEFAULT_CONFIG).coreUserConsentList({ user: this.userId, ordering: this.order, page: page, pageSize: (await uiConfig()).pagination.perPage, }); } checkbox = true; order = "-expires"; columns(): TableColumn[] { return [ new TableColumn(t`Application`, "application"), new TableColumn(t`Expires`, "expires"), new TableColumn(t`Permissions`, "permissions"), ]; } renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; return html` { return new CoreApi(DEFAULT_CONFIG).coreUserConsentUsedByList({ id: item.pk, }); }} .delete=${(item: UserConsent) => { return new CoreApi(DEFAULT_CONFIG).coreUserConsentDestroy({ id: item.pk, }); }} > `; } row(item: UserConsent): TemplateResult[] { return [ html`${item.application.name}`, html`${item.expires?.toLocaleString()}`, html`${item.permissions || "-"}`, ]; } }