mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-17 19:09:11 +03:00
fadc14eddc
* web: Fix stale clipboard tokens, untranslated labels. * Fix tooltip. * Fix type error. * Update types. * Fix types. Clean up composite. * Fix label names. * Fix broken HTML. * Fix labels, formatters. * Clean up properties, lifecyle.
97 lines
3.2 KiB
TypeScript
97 lines
3.2 KiB
TypeScript
import "#elements/chips/Chip";
|
|
import "#elements/chips/ChipGroup";
|
|
import "#elements/forms/DeleteBulkForm";
|
|
|
|
import { aki } from "#common/api/client";
|
|
|
|
import { PaginatedResponse, Table, TableColumn, Timestamp } from "#elements/table/Table";
|
|
import { SlottedTemplateResult } from "#elements/types";
|
|
|
|
import { CoreApi, UserConsent } from "@goauthentik/api";
|
|
|
|
import { msg } from "@lit/localize";
|
|
import { html, TemplateResult } from "lit";
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
@customElement("ak-user-consent-list")
|
|
export class UserConsentList extends Table<UserConsent> {
|
|
public static override verboseName = msg("Consent");
|
|
public static override verboseNamePlural = msg("Consents");
|
|
|
|
@property({ type: Number })
|
|
userId?: number;
|
|
|
|
async apiEndpoint(): Promise<PaginatedResponse<UserConsent>> {
|
|
return aki(CoreApi).coreUserConsentList({
|
|
...(await this.defaultEndpointConfig()),
|
|
user: this.userId,
|
|
});
|
|
}
|
|
|
|
checkbox = true;
|
|
clearOnRefresh = true;
|
|
order = "-expires";
|
|
|
|
protected override rowLabel(item: UserConsent): string | null {
|
|
return item.application?.name ?? null;
|
|
}
|
|
|
|
protected columns: TableColumn[] = [
|
|
[msg("Application"), "application"],
|
|
[msg("Expires"), "expires"],
|
|
[msg("Permissions"), "permissions"],
|
|
];
|
|
|
|
renderToolbarSelected(): TemplateResult {
|
|
const disabled = this.selectedElements.length < 1;
|
|
return html`<ak-forms-delete-bulk
|
|
object-label=${msg("Consent(s)")}
|
|
.objects=${this.selectedElements}
|
|
.metadata=${(item: UserConsent) => {
|
|
return [
|
|
{ key: msg("Application"), value: item.application.name },
|
|
{
|
|
key: msg("Expires"),
|
|
value: Timestamp(item.expires && item.expiring ? item.expires : null),
|
|
},
|
|
{ key: msg("Permissions"), value: item.permissions ?? "-" },
|
|
];
|
|
}}
|
|
.usedBy=${(item: UserConsent) => {
|
|
return aki(CoreApi).coreUserConsentUsedByList({
|
|
id: item.pk,
|
|
});
|
|
}}
|
|
.delete=${(item: UserConsent) => {
|
|
return aki(CoreApi).coreUserConsentDestroy({
|
|
id: item.pk,
|
|
});
|
|
}}
|
|
>
|
|
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
|
|
${msg("Delete")}
|
|
</button>
|
|
</ak-forms-delete-bulk>`;
|
|
}
|
|
|
|
row(item: UserConsent): SlottedTemplateResult[] {
|
|
return [
|
|
html`${item.application.name}`,
|
|
Timestamp(item.expires && item.expiring ? item.expires : null),
|
|
html`${item.permissions
|
|
? html`<ak-chip-group>
|
|
${item.permissions.split(" ").map((perm) => {
|
|
return html`<ak-chip .removable=${false}>${perm}</ak-chip>`;
|
|
})}
|
|
</ak-chip-group>`
|
|
: html`-`}`,
|
|
];
|
|
}
|
|
}
|
|
|
|
declare global {
|
|
interface HTMLElementTagNameMap {
|
|
"ak-user-consent-list": UserConsentList;
|
|
}
|
|
}
|