web: implement bulk-delete form

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-08-12 22:03:13 +02:00
parent 9430a2eea2
commit d1403f6f7d
32 changed files with 365 additions and 367 deletions

View file

@ -4,7 +4,6 @@ import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../table/Table"; import { Table, TableColumn } from "../table/Table";
import { Event, EventsApi } from "authentik-api"; import { Event, EventsApi } from "authentik-api";
import "../forms/DeleteForm";
import "../Tabs"; import "../Tabs";
import "../buttons/ModalButton"; import "../buttons/ModalButton";
import "../buttons/SpinnerButton"; import "../buttons/SpinnerButton";

View file

@ -4,7 +4,6 @@ import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../table/Table"; import { Table, TableColumn } from "../table/Table";
import { Event, EventsApi } from "authentik-api"; import { Event, EventsApi } from "authentik-api";
import "../forms/DeleteForm";
import "../Tabs"; import "../Tabs";
import "../buttons/ModalButton"; import "../buttons/ModalButton";
import "../buttons/SpinnerButton"; import "../buttons/SpinnerButton";

View file

@ -12,29 +12,28 @@ import { Table, TableColumn } from "../table/Table";
import { AKResponse } from "../../api/Client"; import { AKResponse } from "../../api/Client";
import { PFSize } from "../Spinner"; import { PFSize } from "../Spinner";
export interface AKObject<T extends string | number> { type BulkDeleteMetadata = { key: string; value: string }[];
pk: T;
slug?: string;
name?: string;
[key: string]: unknown;
}
@customElement("ak-delete-objects-table") @customElement("ak-delete-objects-table")
export class DeleteObjectsTable<ObjPkT extends string | number> extends Table<AKObject<ObjPkT>> { export class DeleteObjectsTable<T> extends Table<T> {
expandable = true; expandable = true;
paginated = false; paginated = false;
@property({ attribute: false }) @property({ attribute: false })
objects: AKObject<ObjPkT>[] = []; objects: T[] = [];
@property({ attribute: false }) @property({ attribute: false })
usedBy?: (item: AKObject<ObjPkT>) => Promise<UsedBy[]>; metadata!: (item: T) => BulkDeleteMetadata;
@property({ attribute: false })
usedBy?: (item: T) => Promise<UsedBy[]>;
static get styles(): CSSResult[] { static get styles(): CSSResult[] {
return super.styles.concat(PFList); return super.styles.concat(PFList);
} }
apiEndpoint(page: number): Promise<AKResponse<AKObject<ObjPkT>>> { // eslint-disable-next-line @typescript-eslint/no-unused-vars
apiEndpoint(page: number): Promise<AKResponse<T>> {
return Promise.resolve({ return Promise.resolve({
pagination: { pagination: {
count: this.objects.length, count: this.objects.length,
@ -48,77 +47,93 @@ export class DeleteObjectsTable<ObjPkT extends string | number> extends Table<AK
} }
columns(): TableColumn[] { columns(): TableColumn[] {
return [new TableColumn(t`Name`), new TableColumn(t`ID`)]; return this.metadata(this.objects[0]).map((element) => {
return new TableColumn(element.key);
});
} }
row(item: AKObject<ObjPkT>): TemplateResult[] { row(item: T): TemplateResult[] {
return [html`${item.name}`, html`${item.pk}`]; return this.metadata(item).map((element) => {
return html`${element.value}`;
});
} }
renderToolbarContainer(): TemplateResult { renderToolbarContainer(): TemplateResult {
return html``; return html``;
} }
renderExpanded(item: AKObject<ObjPkT>): TemplateResult { renderExpanded(item: T): TemplateResult {
return html`${this.usedBy
? until(
this.usedBy(item).then((usedBy) => {
return this.renderUsedBy(item, usedBy);
}),
html`<ak-spinner size=${PFSize.XLarge}></ak-spinner>`,
)
: html``}`;
}
renderUsedBy(item: AKObject<ObjPkT>, usedBy: UsedBy[]): TemplateResult {
if (usedBy.length < 1) {
return html`<td role="cell" colspan="2">
<div class="pf-c-table__expandable-row-content">
<span>${t`Not used by any other object.`}</span>
</div>
</td>`;
}
return html`<td role="cell" colspan="2"> return html`<td role="cell" colspan="2">
<div class="pf-c-table__expandable-row-content"> <div class="pf-c-table__expandable-row-content">
<p>${t`The following objects use ${item.name}:`}</p> ${this.usedBy
<ul class="pf-c-list"> ? until(
${usedBy.map((ub) => { this.usedBy(item).then((usedBy) => {
let consequence = ""; return this.renderUsedBy(usedBy);
switch (ub.action) { }),
case UsedByActionEnum.Cascade: html`<ak-spinner size=${PFSize.XLarge}></ak-spinner>`,
consequence = t`object will be DELETED`; )
break; : html``}
case UsedByActionEnum.CascadeMany:
consequence = t`connection will be deleted`;
break;
case UsedByActionEnum.SetDefault:
consequence = t`reference will be reset to default value`;
break;
case UsedByActionEnum.SetNull:
consequence = t`reference will be set to an empty value`;
break;
}
return html`<li>${t`${ub.name} (${consequence})`}</li>`;
})}
</ul>
</div> </div>
</td> `; </td>`;
}
renderUsedBy(usedBy: UsedBy[]): TemplateResult {
if (usedBy.length < 1) {
return html` <span>${t`Not used by any other object.`}</span>`;
}
return html`<ul class="pf-c-list">
${usedBy.map((ub) => {
let consequence = "";
switch (ub.action) {
case UsedByActionEnum.Cascade:
consequence = t`object will be DELETED`;
break;
case UsedByActionEnum.CascadeMany:
consequence = t`connection will be deleted`;
break;
case UsedByActionEnum.SetDefault:
consequence = t`reference will be reset to default value`;
break;
case UsedByActionEnum.SetNull:
consequence = t`reference will be set to an empty value`;
break;
}
return html`<li>${t`${ub.name} (${consequence})`}</li>`;
})}
</ul>`;
} }
} }
@customElement("ak-forms-delete-bulk") @customElement("ak-forms-delete-bulk")
export class DeleteBulkForm<ObjPkT extends string | number> extends ModalButton { export class DeleteBulkForm extends ModalButton {
@property({ attribute: false }) @property({ attribute: false })
objects: AKObject<ObjPkT>[] = []; // eslint-disable-next-line @typescript-eslint/no-explicit-any
objects: any[] = [];
@property() @property()
objectLabel?: string; objectLabel?: string;
@property({ attribute: false }) @property({ attribute: false })
usedBy?: (itemPk: AKObject<ObjPkT>) => Promise<UsedBy[]>; // eslint-disable-next-line @typescript-eslint/no-explicit-any
metadata: (item: any) => BulkDeleteMetadata = (item: any) => {
const rec = item as Record<string, unknown>;
const meta = [];
if (Object.prototype.hasOwnProperty.call(rec, "name")) {
meta.push({ key: t`Name`, value: rec.name as string });
}
if (Object.prototype.hasOwnProperty.call(rec, "pk")) {
meta.push({ key: t`ID`, value: rec.pk as string });
}
return meta;
};
@property({ attribute: false }) @property({ attribute: false })
delete!: (itemPk: AKObject<ObjPkT>) => Promise<unknown>; // eslint-disable-next-line @typescript-eslint/no-explicit-any
usedBy?: (item: any) => Promise<UsedBy[]>;
@property({ attribute: false })
// eslint-disable-next-line @typescript-eslint/no-explicit-any
delete!: (item: any) => Promise<any>;
confirm(): Promise<void> { confirm(): Promise<void> {
return Promise.all( return Promise.all(
@ -170,7 +185,11 @@ export class DeleteBulkForm<ObjPkT extends string | number> extends ModalButton
</form> </form>
</section> </section>
<section class="pf-c-page__main-section"> <section class="pf-c-page__main-section">
<ak-delete-objects-table .objects=${this.objects} .usedBy=${this.usedBy}> <ak-delete-objects-table
.objects=${this.objects}
.usedBy=${this.usedBy}
.metadata=${this.metadata}
>
</ak-delete-objects-table> </ak-delete-objects-table>
</section> </section>
<footer class="pf-c-modal-box__footer"> <footer class="pf-c-modal-box__footer">

View file

@ -3,7 +3,7 @@ import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client"; import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../table/Table"; import { Table, TableColumn } from "../table/Table";
import "../forms/DeleteForm"; import "../forms/DeleteBulkForm";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
import { ExpiringBaseGrantModel, Oauth2Api } from "authentik-api"; import { ExpiringBaseGrantModel, Oauth2Api } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config"; import { DEFAULT_CONFIG } from "../../api/Config";
@ -34,17 +34,16 @@ export class UserOAuthCodeList extends Table<ExpiringBaseGrantModel> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Authorization Code(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Authorization Code`} .usedBy=${(item: ExpiringBaseGrantModel) => {
.usedBy=${() => {
return new Oauth2Api(DEFAULT_CONFIG).oauth2AuthorizationCodesUsedByList({ return new Oauth2Api(DEFAULT_CONFIG).oauth2AuthorizationCodesUsedByList({
id: item.pk, id: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: ExpiringBaseGrantModel) => {
return new Oauth2Api(DEFAULT_CONFIG).oauth2AuthorizationCodesDestroy({ return new Oauth2Api(DEFAULT_CONFIG).oauth2AuthorizationCodesDestroy({
id: item.pk, id: item.pk,
}); });
@ -53,7 +52,7 @@ export class UserOAuthCodeList extends Table<ExpiringBaseGrantModel> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: ExpiringBaseGrantModel): TemplateResult[] { row(item: ExpiringBaseGrantModel): TemplateResult[] {

View file

@ -4,9 +4,9 @@ import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../table/Table"; import { Table, TableColumn } from "../table/Table";
import PFFlex from "@patternfly/patternfly/layouts/Flex/flex.css"; import PFFlex from "@patternfly/patternfly/layouts/Flex/flex.css";
import "../forms/DeleteForm"; import "../forms/DeleteBulkForm";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
import { RefreshTokenModel, Oauth2Api } from "authentik-api"; import { RefreshTokenModel, Oauth2Api, ExpiringBaseGrantModel } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config"; import { DEFAULT_CONFIG } from "../../api/Config";
@customElement("ak-user-oauth-refresh-list") @customElement("ak-user-oauth-refresh-list")
@ -57,17 +57,16 @@ export class UserOAuthRefreshList extends Table<RefreshTokenModel> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Refresh Code(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Refresh Code`} .usedBy=${(item: ExpiringBaseGrantModel) => {
.usedBy=${() => {
return new Oauth2Api(DEFAULT_CONFIG).oauth2RefreshTokensUsedByList({ return new Oauth2Api(DEFAULT_CONFIG).oauth2RefreshTokensUsedByList({
id: item.pk, id: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: ExpiringBaseGrantModel) => {
return new Oauth2Api(DEFAULT_CONFIG).oauth2RefreshTokensDestroy({ return new Oauth2Api(DEFAULT_CONFIG).oauth2RefreshTokensDestroy({
id: item.pk, id: item.pk,
}); });
@ -76,7 +75,7 @@ export class UserOAuthRefreshList extends Table<RefreshTokenModel> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: RefreshTokenModel): TemplateResult[] { row(item: RefreshTokenModel): TemplateResult[] {

View file

@ -3,7 +3,7 @@ import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client"; import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../table/Table"; import { Table, TableColumn } from "../table/Table";
import "../forms/DeleteForm"; import "../forms/DeleteBulkForm";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
import { CoreApi, AuthenticatedSession } from "authentik-api"; import { CoreApi, AuthenticatedSession } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config"; import { DEFAULT_CONFIG } from "../../api/Config";
@ -35,26 +35,25 @@ export class AuthenticatedSessionList extends Table<AuthenticatedSession> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Session(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Session`} .usedBy=${(item: AuthenticatedSession) => {
.usedBy=${() => {
return new CoreApi(DEFAULT_CONFIG).coreAuthenticatedSessionsUsedByList({ return new CoreApi(DEFAULT_CONFIG).coreAuthenticatedSessionsUsedByList({
uuid: item.uuid || "", uuid: item.uuid || "",
}); });
}} }}
.delete=${() => { .delete=${(item: AuthenticatedSession) => {
return new CoreApi(DEFAULT_CONFIG).coreAuthenticatedSessionsDestroy({ return new CoreApi(DEFAULT_CONFIG).coreAuthenticatedSessionsDestroy({
uuid: item.uuid || "", uuid: item.uuid || "",
}); });
}} }}
> >
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete Session`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: AuthenticatedSession): TemplateResult[] { row(item: AuthenticatedSession): TemplateResult[] {

View file

@ -3,7 +3,7 @@ import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client"; import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../table/Table"; import { Table, TableColumn } from "../table/Table";
import "../forms/DeleteForm"; import "../forms/DeleteBulkForm";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
import { CoreApi, UserConsent } from "authentik-api"; import { CoreApi, UserConsent } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config"; import { DEFAULT_CONFIG } from "../../api/Config";
@ -33,26 +33,25 @@ export class UserConsentList extends Table<UserConsent> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Consent(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Consent`} .usedBy=${(item: UserConsent) => {
.usedBy=${() => {
return new CoreApi(DEFAULT_CONFIG).coreUserConsentUsedByList({ return new CoreApi(DEFAULT_CONFIG).coreUserConsentUsedByList({
id: item.pk, id: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: UserConsent) => {
return new CoreApi(DEFAULT_CONFIG).coreUserConsentDestroy({ return new CoreApi(DEFAULT_CONFIG).coreUserConsentDestroy({
id: item.pk, id: item.pk,
}); });
}} }}
> >
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete Consent`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: UserConsent): TemplateResult[] { row(item: UserConsent): TemplateResult[] {

View file

@ -284,7 +284,7 @@ msgstr ""
msgid "Are you sure you want to delete {0} {1}?" msgid "Are you sure you want to delete {0} {1}?"
msgstr "Are you sure you want to delete {0} {1}?" msgstr "Are you sure you want to delete {0} {1}?"
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "Are you sure you want to delete {0} {objName} ?" msgid "Are you sure you want to delete {0} {objName} ?"
msgstr "Are you sure you want to delete {0} {objName} ?" msgstr "Are you sure you want to delete {0} {objName} ?"
@ -487,7 +487,7 @@ msgstr "Browser"
msgid "Build hash:" msgid "Build hash:"
msgstr "Build hash:" msgstr "Build hash:"
#: #:
#~ msgid "Build hash: {0}" #~ msgid "Build hash: {0}"
#~ msgstr "Build hash: {0}" #~ msgstr "Build hash: {0}"
@ -518,7 +518,7 @@ msgstr "Can be in the format of 'unix://' when connecting to a local docker daem
#: src/elements/forms/ConfirmationForm.ts #: src/elements/forms/ConfirmationForm.ts
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/ModalForm.ts #: src/elements/forms/ModalForm.ts
#: src/pages/groups/MemberSelectModal.ts #: src/pages/groups/MemberSelectModal.ts
#: src/pages/users/GroupSelectModal.ts #: src/pages/users/GroupSelectModal.ts
@ -1091,7 +1091,7 @@ msgid "Define how notifications are sent to users, like Email or Webhook."
msgstr "Define how notifications are sent to users, like Email or Webhook." msgstr "Define how notifications are sent to users, like Email or Webhook."
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/oauth/UserCodeList.ts #: src/elements/oauth/UserCodeList.ts
#: src/elements/oauth/UserRefreshList.ts #: src/elements/oauth/UserRefreshList.ts
#: src/pages/applications/ApplicationListPage.ts #: src/pages/applications/ApplicationListPage.ts
@ -1119,7 +1119,7 @@ msgstr "Define how notifications are sent to users, like Email or Webhook."
msgid "Delete" msgid "Delete"
msgstr "Delete" msgstr "Delete"
#: #:
#~ msgid "Delete Authorization Code" #~ msgid "Delete Authorization Code"
#~ msgstr "Delete Authorization Code" #~ msgstr "Delete Authorization Code"
@ -1132,7 +1132,7 @@ msgstr "Delete Binding"
msgid "Delete Consent" msgid "Delete Consent"
msgstr "Delete Consent" msgstr "Delete Consent"
#: #:
#~ msgid "Delete Refresh Code" #~ msgid "Delete Refresh Code"
#~ msgstr "Delete Refresh Code" #~ msgstr "Delete Refresh Code"
@ -1165,7 +1165,7 @@ msgstr ""
"confirmation. Use a consent stage to ensure the user is aware of their actions." "confirmation. Use a consent stage to ensure the user is aware of their actions."
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "Delete {0}" msgid "Delete {0}"
msgstr "Delete {0}" msgstr "Delete {0}"
@ -1230,8 +1230,8 @@ msgstr "Digest algorithm"
msgid "Digits" msgid "Digits"
msgstr "Digits" msgstr "Digits"
#: #:
#: #:
#~ msgid "Disable" #~ msgid "Disable"
#~ msgstr "Disable" #~ msgstr "Disable"
@ -1382,8 +1382,8 @@ msgstr "Email: Text field with Email type."
msgid "Embedded outpost is not configured correctly." msgid "Embedded outpost is not configured correctly."
msgstr "Embedded outpost is not configured correctly." msgstr "Embedded outpost is not configured correctly."
#: #:
#: #:
#~ msgid "Enable" #~ msgid "Enable"
#~ msgstr "Enable" #~ msgstr "Enable"
@ -1607,7 +1607,7 @@ msgid "Failed to delete policy cache"
msgstr "Failed to delete policy cache" msgstr "Failed to delete policy cache"
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "Failed to delete {0}: {1}" msgid "Failed to delete {0}: {1}"
msgstr "Failed to delete {0}: {1}" msgstr "Failed to delete {0}: {1}"
@ -2702,7 +2702,7 @@ msgstr "Only fail the policy, don't invalidate user's password."
msgid "Only send notification once, for example when sending a webhook into a chat channel." msgid "Only send notification once, for example when sending a webhook into a chat channel."
msgstr "Only send notification once, for example when sending a webhook into a chat channel." msgstr "Only send notification once, for example when sending a webhook into a chat channel."
#: #:
#~ msgid "Open application" #~ msgid "Open application"
#~ msgstr "Open application" #~ msgstr "Open application"
@ -2779,7 +2779,7 @@ msgstr "Outpost"
msgid "Outpost Deployment Info" msgid "Outpost Deployment Info"
msgstr "Outpost Deployment Info" msgstr "Outpost Deployment Info"
#: #:
#~ msgid "Outpost Service-connection" #~ msgid "Outpost Service-connection"
#~ msgstr "Outpost Service-connection" #~ msgstr "Outpost Service-connection"
@ -3419,7 +3419,7 @@ msgstr "Select which transports should be used to notify the user. If none are s
msgid "Selected policies are executed when the stage is submitted to validate the data." msgid "Selected policies are executed when the stage is submitted to validate the data."
msgstr "Selected policies are executed when the stage is submitted to validate the data." msgstr "Selected policies are executed when the stage is submitted to validate the data."
#: #:
#~ msgid "Selecting a service-connection enables the management of the outpost by authentik." #~ msgid "Selecting a service-connection enables the management of the outpost by authentik."
#~ msgstr "Selecting a service-connection enables the management of the outpost by authentik." #~ msgstr "Selecting a service-connection enables the management of the outpost by authentik."
@ -3476,7 +3476,7 @@ msgstr "Server name for which this provider's certificate is valid for."
msgid "Server validation of credential failed: {err}" msgid "Server validation of credential failed: {err}"
msgstr "Server validation of credential failed: {err}" msgstr "Server validation of credential failed: {err}"
#: #:
#~ msgid "Service Connections" #~ msgid "Service Connections"
#~ msgstr "Service Connections" #~ msgstr "Service Connections"
@ -3484,8 +3484,8 @@ msgstr "Server validation of credential failed: {err}"
msgid "Service Provider Binding" msgid "Service Provider Binding"
msgstr "Service Provider Binding" msgstr "Service Provider Binding"
#: #:
#: #:
#~ msgid "Service connection" #~ msgid "Service connection"
#~ msgstr "Service connection" #~ msgstr "Service connection"
@ -3804,8 +3804,8 @@ msgstr "Successfully created provider."
msgid "Successfully created rule." msgid "Successfully created rule."
msgstr "Successfully created rule." msgstr "Successfully created rule."
#: #:
#: #:
#~ msgid "Successfully created service-connection." #~ msgid "Successfully created service-connection."
#~ msgstr "Successfully created service-connection." #~ msgstr "Successfully created service-connection."
@ -3854,7 +3854,7 @@ msgid "Successfully created user."
msgstr "Successfully created user." msgstr "Successfully created user."
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "Successfully deleted {0} {1}" msgid "Successfully deleted {0} {1}"
msgstr "Successfully deleted {0} {1}" msgstr "Successfully deleted {0} {1}"
@ -3958,8 +3958,8 @@ msgstr "Successfully updated provider."
msgid "Successfully updated rule." msgid "Successfully updated rule."
msgstr "Successfully updated rule." msgstr "Successfully updated rule."
#: #:
#: #:
#~ msgid "Successfully updated service-connection." #~ msgid "Successfully updated service-connection."
#~ msgstr "Successfully updated service-connection." #~ msgstr "Successfully updated service-connection."
@ -4151,7 +4151,7 @@ msgstr "The external URL you'll authenticate at. Can be the same domain as authe
msgid "The following objects use {0}:" msgid "The following objects use {0}:"
msgstr "The following objects use {0}:" msgstr "The following objects use {0}:"
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "The following objects use {objName}" msgid "The following objects use {objName}"
msgstr "The following objects use {objName}" msgstr "The following objects use {objName}"
@ -4396,7 +4396,7 @@ msgstr "Unhealthy outposts"
msgid "Unknown" msgid "Unknown"
msgstr "Unknown" msgstr "Unknown"
#: #:
#~ msgid "Unmanaged" #~ msgid "Unmanaged"
#~ msgstr "Unmanaged" #~ msgstr "Unmanaged"
@ -4924,7 +4924,7 @@ msgstr "authentik Builtin Database"
msgid "authentik LDAP Backend" msgid "authentik LDAP Backend"
msgstr "authentik LDAP Backend" msgstr "authentik LDAP Backend"
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "connecting object will be deleted" msgid "connecting object will be deleted"
msgstr "connecting object will be deleted" msgstr "connecting object will be deleted"
@ -4937,17 +4937,17 @@ msgid "no tabs defined"
msgstr "no tabs defined" msgstr "no tabs defined"
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "object will be DELETED" msgid "object will be DELETED"
msgstr "object will be DELETED" msgstr "object will be DELETED"
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "reference will be reset to default value" msgid "reference will be reset to default value"
msgstr "reference will be reset to default value" msgstr "reference will be reset to default value"
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "reference will be set to an empty value" msgid "reference will be set to an empty value"
msgstr "reference will be set to an empty value" msgstr "reference will be set to an empty value"
@ -4965,7 +4965,7 @@ msgid "{0} ({1})"
msgstr "{0} ({1})" msgstr "{0} ({1})"
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "{0} ({consequence})" msgid "{0} ({consequence})"
msgstr "{0} ({consequence})" msgstr "{0} ({consequence})"

View file

@ -280,7 +280,7 @@ msgstr ""
msgid "Are you sure you want to delete {0} {1}?" msgid "Are you sure you want to delete {0} {1}?"
msgstr "" msgstr ""
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "Are you sure you want to delete {0} {objName} ?" msgid "Are you sure you want to delete {0} {objName} ?"
msgstr "" msgstr ""
@ -483,7 +483,7 @@ msgstr ""
msgid "Build hash:" msgid "Build hash:"
msgstr "" msgstr ""
#: #:
#~ msgid "Build hash: {0}" #~ msgid "Build hash: {0}"
#~ msgstr "" #~ msgstr ""
@ -514,7 +514,7 @@ msgstr ""
#: src/elements/forms/ConfirmationForm.ts #: src/elements/forms/ConfirmationForm.ts
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/ModalForm.ts #: src/elements/forms/ModalForm.ts
#: src/pages/groups/MemberSelectModal.ts #: src/pages/groups/MemberSelectModal.ts
#: src/pages/users/GroupSelectModal.ts #: src/pages/users/GroupSelectModal.ts
@ -1085,7 +1085,7 @@ msgid "Define how notifications are sent to users, like Email or Webhook."
msgstr "" msgstr ""
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/oauth/UserCodeList.ts #: src/elements/oauth/UserCodeList.ts
#: src/elements/oauth/UserRefreshList.ts #: src/elements/oauth/UserRefreshList.ts
#: src/pages/applications/ApplicationListPage.ts #: src/pages/applications/ApplicationListPage.ts
@ -1113,7 +1113,7 @@ msgstr ""
msgid "Delete" msgid "Delete"
msgstr "" msgstr ""
#: #:
#~ msgid "Delete Authorization Code" #~ msgid "Delete Authorization Code"
#~ msgstr "" #~ msgstr ""
@ -1126,7 +1126,7 @@ msgstr ""
msgid "Delete Consent" msgid "Delete Consent"
msgstr "" msgstr ""
#: #:
#~ msgid "Delete Refresh Code" #~ msgid "Delete Refresh Code"
#~ msgstr "" #~ msgstr ""
@ -1157,7 +1157,7 @@ msgid ""
msgstr "" msgstr ""
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "Delete {0}" msgid "Delete {0}"
msgstr "" msgstr ""
@ -1222,8 +1222,8 @@ msgstr ""
msgid "Digits" msgid "Digits"
msgstr "" msgstr ""
#: #:
#: #:
#~ msgid "Disable" #~ msgid "Disable"
#~ msgstr "" #~ msgstr ""
@ -1374,8 +1374,8 @@ msgstr ""
msgid "Embedded outpost is not configured correctly." msgid "Embedded outpost is not configured correctly."
msgstr "" msgstr ""
#: #:
#: #:
#~ msgid "Enable" #~ msgid "Enable"
#~ msgstr "" #~ msgstr ""
@ -1599,7 +1599,7 @@ msgid "Failed to delete policy cache"
msgstr "" msgstr ""
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "Failed to delete {0}: {1}" msgid "Failed to delete {0}: {1}"
msgstr "" msgstr ""
@ -2694,7 +2694,7 @@ msgstr ""
msgid "Only send notification once, for example when sending a webhook into a chat channel." msgid "Only send notification once, for example when sending a webhook into a chat channel."
msgstr "" msgstr ""
#: #:
#~ msgid "Open application" #~ msgid "Open application"
#~ msgstr "" #~ msgstr ""
@ -2771,7 +2771,7 @@ msgstr ""
msgid "Outpost Deployment Info" msgid "Outpost Deployment Info"
msgstr "" msgstr ""
#: #:
#~ msgid "Outpost Service-connection" #~ msgid "Outpost Service-connection"
#~ msgstr "" #~ msgstr ""
@ -3411,7 +3411,7 @@ msgstr ""
msgid "Selected policies are executed when the stage is submitted to validate the data." msgid "Selected policies are executed when the stage is submitted to validate the data."
msgstr "" msgstr ""
#: #:
#~ msgid "Selecting a service-connection enables the management of the outpost by authentik." #~ msgid "Selecting a service-connection enables the management of the outpost by authentik."
#~ msgstr "" #~ msgstr ""
@ -3468,7 +3468,7 @@ msgstr ""
msgid "Server validation of credential failed: {err}" msgid "Server validation of credential failed: {err}"
msgstr "" msgstr ""
#: #:
#~ msgid "Service Connections" #~ msgid "Service Connections"
#~ msgstr "" #~ msgstr ""
@ -3476,8 +3476,8 @@ msgstr ""
msgid "Service Provider Binding" msgid "Service Provider Binding"
msgstr "" msgstr ""
#: #:
#: #:
#~ msgid "Service connection" #~ msgid "Service connection"
#~ msgstr "" #~ msgstr ""
@ -3796,8 +3796,8 @@ msgstr ""
msgid "Successfully created rule." msgid "Successfully created rule."
msgstr "" msgstr ""
#: #:
#: #:
#~ msgid "Successfully created service-connection." #~ msgid "Successfully created service-connection."
#~ msgstr "" #~ msgstr ""
@ -3846,7 +3846,7 @@ msgid "Successfully created user."
msgstr "" msgstr ""
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "Successfully deleted {0} {1}" msgid "Successfully deleted {0} {1}"
msgstr "" msgstr ""
@ -3950,8 +3950,8 @@ msgstr ""
msgid "Successfully updated rule." msgid "Successfully updated rule."
msgstr "" msgstr ""
#: #:
#: #:
#~ msgid "Successfully updated service-connection." #~ msgid "Successfully updated service-connection."
#~ msgstr "" #~ msgstr ""
@ -4143,7 +4143,7 @@ msgstr ""
msgid "The following objects use {0}:" msgid "The following objects use {0}:"
msgstr "" msgstr ""
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "The following objects use {objName}" msgid "The following objects use {objName}"
msgstr "" msgstr ""
@ -4381,7 +4381,7 @@ msgstr ""
msgid "Unknown" msgid "Unknown"
msgstr "" msgstr ""
#: #:
#~ msgid "Unmanaged" #~ msgid "Unmanaged"
#~ msgstr "" #~ msgstr ""
@ -4907,7 +4907,7 @@ msgstr ""
msgid "authentik LDAP Backend" msgid "authentik LDAP Backend"
msgstr "" msgstr ""
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "connecting object will be deleted" msgid "connecting object will be deleted"
msgstr "" msgstr ""
@ -4920,17 +4920,17 @@ msgid "no tabs defined"
msgstr "" msgstr ""
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "object will be DELETED" msgid "object will be DELETED"
msgstr "" msgstr ""
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "reference will be reset to default value" msgid "reference will be reset to default value"
msgstr "" msgstr ""
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "reference will be set to an empty value" msgid "reference will be set to an empty value"
msgstr "" msgstr ""
@ -4948,7 +4948,7 @@ msgid "{0} ({1})"
msgstr "" msgstr ""
#: src/elements/forms/DeleteBulkForm.ts #: src/elements/forms/DeleteBulkForm.ts
#: src/elements/forms/DeleteForm.ts #: src/elements/forms/DeleteBulkForm.ts
msgid "{0} ({consequence})" msgid "{0} ({consequence})"
msgstr "" msgstr ""

View file

@ -5,7 +5,7 @@ import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage"; import { TablePage } from "../../elements/table/TablePage";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import { TableColumn } from "../../elements/table/Table"; import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
@ -69,17 +69,16 @@ export class ApplicationListPage extends TablePage<Application> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Application(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Application`} .usedBy=${(item: Application) => {
.usedBy=${() => {
return new CoreApi(DEFAULT_CONFIG).coreApplicationsUsedByList({ return new CoreApi(DEFAULT_CONFIG).coreApplicationsUsedByList({
slug: item.slug, slug: item.slug,
}); });
}} }}
.delete=${() => { .delete=${(item: Application) => {
return new CoreApi(DEFAULT_CONFIG).coreApplicationsDestroy({ return new CoreApi(DEFAULT_CONFIG).coreApplicationsDestroy({
slug: item.slug, slug: item.slug,
}); });
@ -88,7 +87,7 @@ export class ApplicationListPage extends TablePage<Application> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Application): TemplateResult[] { row(item: Application): TemplateResult[] {

View file

@ -8,7 +8,7 @@ import { CryptoApi, CertificateKeyPair } from "authentik-api";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "./CertificateKeyPairForm"; import "./CertificateKeyPairForm";
import "./CertificateGenerateForm"; import "./CertificateGenerateForm";
import { TableColumn } from "../../elements/table/Table"; import { TableColumn } from "../../elements/table/Table";
@ -59,17 +59,22 @@ export class CertificateKeyPairListPage extends TablePage<CertificateKeyPair> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Certificate-Key Pair(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Certificate-Key Pair`} .metadata=${(item: CertificateKeyPair) => {
.usedBy=${() => { return [
{ key: t`Name`, value: item.name },
{ key: t`Expiry`, value: item.certExpiry.toLocaleString() },
];
}}
.usedBy=${(item: CertificateKeyPair) => {
return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsUsedByList({ return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsUsedByList({
kpUuid: item.pk, kpUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: CertificateKeyPair) => {
return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsDestroy({ return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsDestroy({
kpUuid: item.pk, kpUuid: item.pk,
}); });
@ -78,7 +83,7 @@ export class CertificateKeyPairListPage extends TablePage<CertificateKeyPair> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: CertificateKeyPair): TemplateResult[] { row(item: CertificateKeyPair): TemplateResult[] {

View file

@ -10,7 +10,7 @@ import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
import { EventsApi, NotificationRule } from "authentik-api"; import { EventsApi, NotificationRule } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config"; import { DEFAULT_CONFIG } from "../../api/Config";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "./RuleForm"; import "./RuleForm";
@customElement("ak-event-rule-list") @customElement("ak-event-rule-list")
@ -53,17 +53,16 @@ export class RuleListPage extends TablePage<NotificationRule> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Notification rule(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Notification rule`} .usedBy=${(item: NotificationRule) => {
.usedBy=${() => {
return new EventsApi(DEFAULT_CONFIG).eventsRulesUsedByList({ return new EventsApi(DEFAULT_CONFIG).eventsRulesUsedByList({
pbmUuid: item.pk, pbmUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: NotificationRule) => {
return new EventsApi(DEFAULT_CONFIG).eventsRulesDestroy({ return new EventsApi(DEFAULT_CONFIG).eventsRulesDestroy({
pbmUuid: item.pk, pbmUuid: item.pk,
}); });
@ -72,7 +71,7 @@ export class RuleListPage extends TablePage<NotificationRule> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: NotificationRule): TemplateResult[] { row(item: NotificationRule): TemplateResult[] {

View file

@ -10,7 +10,7 @@ import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
import { EventsApi, NotificationTransport } from "authentik-api"; import { EventsApi, NotificationTransport } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config"; import { DEFAULT_CONFIG } from "../../api/Config";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "./TransportForm"; import "./TransportForm";
@customElement("ak-event-transport-list") @customElement("ak-event-transport-list")
@ -51,17 +51,16 @@ export class TransportListPage extends TablePage<NotificationTransport> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Notification transports(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Notifications Transport`} .usedBy=${(item: NotificationTransport) => {
.usedBy=${() => {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsUsedByList({ return new EventsApi(DEFAULT_CONFIG).eventsTransportsUsedByList({
uuid: item.pk, uuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: NotificationTransport) => {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsDestroy({ return new EventsApi(DEFAULT_CONFIG).eventsTransportsDestroy({
uuid: item.pk, uuid: item.pk,
}); });
@ -70,7 +69,7 @@ export class TransportListPage extends TablePage<NotificationTransport> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: NotificationTransport): TemplateResult[] { row(item: NotificationTransport): TemplateResult[] {

View file

@ -3,7 +3,7 @@ import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client"; import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../../elements/table/Table"; import { Table, TableColumn } from "../../elements/table/Table";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "../../elements/forms/ProxyForm"; import "../../elements/forms/ProxyForm";
import "./StageBindingForm"; import "./StageBindingForm";
@ -44,26 +44,25 @@ export class BoundStagesList extends Table<FlowStageBinding> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Stage binding(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Stage binding`} .usedBy=${(item: FlowStageBinding) => {
.usedBy=${() => {
return new FlowsApi(DEFAULT_CONFIG).flowsBindingsUsedByList({ return new FlowsApi(DEFAULT_CONFIG).flowsBindingsUsedByList({
fsbUuid: item.pk, fsbUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: FlowStageBinding) => {
return new FlowsApi(DEFAULT_CONFIG).flowsBindingsDestroy({ return new FlowsApi(DEFAULT_CONFIG).flowsBindingsDestroy({
fsbUuid: item.pk, fsbUuid: item.pk,
}); });
}} }}
> >
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete Binding`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: FlowStageBinding): TemplateResult[] { row(item: FlowStageBinding): TemplateResult[] {

View file

@ -4,7 +4,7 @@ import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage"; import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "../../elements/forms/ConfirmationForm"; import "../../elements/forms/ConfirmationForm";
import "./FlowForm"; import "./FlowForm";
@ -55,17 +55,16 @@ export class FlowListPage extends TablePage<Flow> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Flow(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Flow`} .usedBy=${(item: Flow) => {
.usedBy=${() => {
return new FlowsApi(DEFAULT_CONFIG).flowsInstancesUsedByList({ return new FlowsApi(DEFAULT_CONFIG).flowsInstancesUsedByList({
slug: item.slug, slug: item.slug,
}); });
}} }}
.delete=${() => { .delete=${(item: Flow) => {
return new FlowsApi(DEFAULT_CONFIG).flowsInstancesDestroy({ return new FlowsApi(DEFAULT_CONFIG).flowsInstancesDestroy({
slug: item.slug, slug: item.slug,
}); });
@ -74,7 +73,7 @@ export class FlowListPage extends TablePage<Flow> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Flow): TemplateResult[] { row(item: Flow): TemplateResult[] {

View file

@ -3,7 +3,7 @@ import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client"; import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage"; import { TablePage } from "../../elements/table/TablePage";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import { TableColumn } from "../../elements/table/Table"; import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
@ -51,17 +51,16 @@ export class GroupListPage extends TablePage<Group> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Group(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Group`} .usedBy=${(item: Group) => {
.usedBy=${() => {
return new CoreApi(DEFAULT_CONFIG).coreGroupsUsedByList({ return new CoreApi(DEFAULT_CONFIG).coreGroupsUsedByList({
groupUuid: item.pk, groupUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: Group) => {
return new CoreApi(DEFAULT_CONFIG).coreGroupsDestroy({ return new CoreApi(DEFAULT_CONFIG).coreGroupsDestroy({
groupUuid: item.pk, groupUuid: item.pk,
}); });
@ -70,7 +69,7 @@ export class GroupListPage extends TablePage<Group> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Group): TemplateResult[] { row(item: Group): TemplateResult[] {

View file

@ -12,7 +12,7 @@ import "./OutpostForm";
import "./OutpostDeploymentModal"; import "./OutpostDeploymentModal";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
import { Outpost, OutpostsApi } from "authentik-api"; import { Outpost, OutpostsApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config"; import { DEFAULT_CONFIG } from "../../api/Config";
@ -139,17 +139,16 @@ export class OutpostListPage extends TablePage<Outpost> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Outpost(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Outpost`} .usedBy=${(item: Outpost) => {
.usedBy=${() => {
return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesUsedByList({ return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesUsedByList({
uuid: item.pk, uuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: Outpost) => {
return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesDestroy({ return new OutpostsApi(DEFAULT_CONFIG).outpostsInstancesDestroy({
uuid: item.pk, uuid: item.pk,
}); });
@ -158,7 +157,7 @@ export class OutpostListPage extends TablePage<Outpost> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
renderToolbar(): TemplateResult { renderToolbar(): TemplateResult {

View file

@ -8,7 +8,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "./OutpostHealth"; import "./OutpostHealth";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/Dropdown"; import "../../elements/buttons/Dropdown";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "./ServiceConnectionKubernetesForm"; import "./ServiceConnectionKubernetesForm";
import "./ServiceConnectionDockerForm"; import "./ServiceConnectionDockerForm";
@ -102,17 +102,16 @@ export class OutpostServiceConnectionListPage extends TablePage<ServiceConnectio
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Outpost integration(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Outpost integration`} .usedBy=${(item: ServiceConnection) => {
.usedBy=${() => {
return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllUsedByList({ return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllUsedByList({
uuid: item.pk, uuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: ServiceConnection) => {
return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllDestroy({ return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllDestroy({
uuid: item.pk, uuid: item.pk,
}); });
@ -121,7 +120,7 @@ export class OutpostServiceConnectionListPage extends TablePage<ServiceConnectio
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
renderToolbar(): TemplateResult { renderToolbar(): TemplateResult {

View file

@ -4,7 +4,7 @@ import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../../elements/table/Table"; import { Table, TableColumn } from "../../elements/table/Table";
import { PoliciesApi, PolicyBinding } from "authentik-api"; import { PoliciesApi, PolicyBinding } from "authentik-api";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/Tabs"; import "../../elements/Tabs";
import "../../elements/forms/ProxyForm"; import "../../elements/forms/ProxyForm";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
@ -96,26 +96,25 @@ export class BoundPoliciesList extends Table<PolicyBinding> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Policy binding(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Policy binding`} .usedBy=${(item: PolicyBinding) => {
.usedBy=${() => {
return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsUsedByList({ return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsUsedByList({
policyBindingUuid: item.pk, policyBindingUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: PolicyBinding) => {
return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsDestroy({ return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsDestroy({
policyBindingUuid: item.pk, policyBindingUuid: item.pk,
}); });
}} }}
> >
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete Binding`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: PolicyBinding): TemplateResult[] { row(item: PolicyBinding): TemplateResult[] {

View file

@ -5,7 +5,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/Dropdown"; import "../../elements/buttons/Dropdown";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "../../elements/forms/ProxyForm"; import "../../elements/forms/ProxyForm";
import "../../elements/forms/ConfirmationForm"; import "../../elements/forms/ConfirmationForm";
@ -99,31 +99,25 @@ export class PolicyListPage extends TablePage<Policy> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Policy / Policies`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Policy`} .usedBy=${(item: Policy) => {
.usedBy=${() => {
return new PoliciesApi(DEFAULT_CONFIG).policiesAllUsedByList({ return new PoliciesApi(DEFAULT_CONFIG).policiesAllUsedByList({
policyUuid: item.pk, policyUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: Policy) => {
return new PoliciesApi(DEFAULT_CONFIG).policiesAllDestroy({ return new PoliciesApi(DEFAULT_CONFIG).policiesAllDestroy({
policyUuid: item.pk, policyUuid: item.pk,
}); });
}} }}
> >
<button <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
?disabled=${disabled}
slot="trigger"
type="button"
class="pf-c-button pf-m-danger ${disabled && "pf-m-disabled"}"
>
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
renderToolbar(): TemplateResult { renderToolbar(): TemplateResult {

View file

@ -5,7 +5,7 @@ import { TablePage } from "../../../elements/table/TablePage";
import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/ModalButton";
import "../../../elements/buttons/SpinnerButton"; import "../../../elements/buttons/SpinnerButton";
import "../../../elements/forms/DeleteForm"; import "../../../elements/forms/DeleteBulkForm";
import "../../../elements/forms/ModalForm"; import "../../../elements/forms/ModalForm";
import { TableColumn } from "../../../elements/table/Table"; import { TableColumn } from "../../../elements/table/Table";
import { PAGE_SIZE } from "../../../constants"; import { PAGE_SIZE } from "../../../constants";
@ -50,17 +50,16 @@ export class IPReputationListPage extends TablePage<IPReputation> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete
.obj=${item}
objectLabel=${t`IP Reputation`} objectLabel=${t`IP Reputation`}
.usedBy=${() => { .objects=${this.selectedElements}
.usedBy=${(item: IPReputation) => {
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationIpsUsedByList({ return new PoliciesApi(DEFAULT_CONFIG).policiesReputationIpsUsedByList({
id: item.pk, id: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: IPReputation) => {
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationIpsDestroy({ return new PoliciesApi(DEFAULT_CONFIG).policiesReputationIpsDestroy({
id: item.pk, id: item.pk,
}); });
@ -69,7 +68,7 @@ export class IPReputationListPage extends TablePage<IPReputation> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: IPReputation): TemplateResult[] { row(item: IPReputation): TemplateResult[] {

View file

@ -5,7 +5,7 @@ import { TablePage } from "../../../elements/table/TablePage";
import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/ModalButton";
import "../../../elements/buttons/SpinnerButton"; import "../../../elements/buttons/SpinnerButton";
import "../../../elements/forms/DeleteForm"; import "../../../elements/forms/DeleteBulkForm";
import "../../../elements/forms/ModalForm"; import "../../../elements/forms/ModalForm";
import { TableColumn } from "../../../elements/table/Table"; import { TableColumn } from "../../../elements/table/Table";
import { PAGE_SIZE } from "../../../constants"; import { PAGE_SIZE } from "../../../constants";
@ -46,17 +46,16 @@ export class UserReputationListPage extends TablePage<UserReputation> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete
.obj=${item}
objectLabel=${t`User Reputation`} objectLabel=${t`User Reputation`}
.usedBy=${() => { .objects=${this.selectedElements}
.usedBy=${(item: UserReputation) => {
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationUsersUsedByList({ return new PoliciesApi(DEFAULT_CONFIG).policiesReputationUsersUsedByList({
id: item.pk, id: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: UserReputation) => {
return new PoliciesApi(DEFAULT_CONFIG).policiesReputationUsersDestroy({ return new PoliciesApi(DEFAULT_CONFIG).policiesReputationUsersDestroy({
id: item.pk, id: item.pk,
}); });
@ -65,7 +64,7 @@ export class UserReputationListPage extends TablePage<UserReputation> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: UserReputation): TemplateResult[] { row(item: UserReputation): TemplateResult[] {

View file

@ -5,7 +5,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/Dropdown"; import "../../elements/buttons/Dropdown";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "../../elements/forms/ProxyForm"; import "../../elements/forms/ProxyForm";
import "./PropertyMappingTestForm"; import "./PropertyMappingTestForm";
@ -61,17 +61,16 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html` <ak-forms-delete objectLabel=${t`Property Mapping(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Property Mapping`} .usedBy=${(item: PropertyMapping) => {
.usedBy=${() => {
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllUsedByList({ return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllUsedByList({
pmUuid: item.pk, pmUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: PropertyMapping) => {
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllDestroy({ return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllDestroy({
pmUuid: item.pk, pmUuid: item.pk,
}); });
@ -80,7 +79,7 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: PropertyMapping): TemplateResult[] { row(item: PropertyMapping): TemplateResult[] {

View file

@ -5,7 +5,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/Dropdown"; import "../../elements/buttons/Dropdown";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "../../elements/forms/ProxyForm"; import "../../elements/forms/ProxyForm";
import "./ldap/LDAPProviderForm"; import "./ldap/LDAPProviderForm";
@ -59,17 +59,16 @@ export class ProviderListPage extends TablePage<Provider> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Provider(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Provider`} .usedBy=${(item: Provider) => {
.usedBy=${() => {
return new ProvidersApi(DEFAULT_CONFIG).providersAllUsedByList({ return new ProvidersApi(DEFAULT_CONFIG).providersAllUsedByList({
id: item.pk, id: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: Provider) => {
return new ProvidersApi(DEFAULT_CONFIG).providersAllDestroy({ return new ProvidersApi(DEFAULT_CONFIG).providersAllDestroy({
id: item.pk, id: item.pk,
}); });
@ -78,7 +77,7 @@ export class ProviderListPage extends TablePage<Provider> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Provider): TemplateResult[] { row(item: Provider): TemplateResult[] {

View file

@ -6,7 +6,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/Dropdown"; import "../../elements/buttons/Dropdown";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import "../../elements/forms/ProxyForm"; import "../../elements/forms/ProxyForm";
import { until } from "lit-html/directives/until"; import { until } from "lit-html/directives/until";
@ -53,17 +53,16 @@ export class SourceListPage extends TablePage<Source> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Source(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Source`} .usedBy=${(item: Source) => {
.usedBy=${() => {
return new SourcesApi(DEFAULT_CONFIG).sourcesAllUsedByList({ return new SourcesApi(DEFAULT_CONFIG).sourcesAllUsedByList({
slug: item.slug, slug: item.slug,
}); });
}} }}
.delete=${() => { .delete=${(item: Source) => {
return new SourcesApi(DEFAULT_CONFIG).sourcesAllDestroy({ return new SourcesApi(DEFAULT_CONFIG).sourcesAllDestroy({
slug: item.slug, slug: item.slug,
}); });
@ -72,7 +71,7 @@ export class SourceListPage extends TablePage<Source> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Source): TemplateResult[] { row(item: Source): TemplateResult[] {

View file

@ -6,7 +6,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/Dropdown"; import "../../elements/buttons/Dropdown";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/forms/ProxyForm"; import "../../elements/forms/ProxyForm";
import "../../elements/forms/ModalForm"; import "../../elements/forms/ModalForm";
import { until } from "lit-html/directives/until"; import { until } from "lit-html/directives/until";
@ -72,17 +72,16 @@ export class StageListPage extends TablePage<Stage> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Stage(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${item?.verboseName} .usedBy=${(item: Stage) => {
.usedBy=${() => {
return new StagesApi(DEFAULT_CONFIG).stagesAllUsedByList({ return new StagesApi(DEFAULT_CONFIG).stagesAllUsedByList({
stageUuid: item.pk, stageUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: Stage) => {
return new StagesApi(DEFAULT_CONFIG).stagesAllDestroy({ return new StagesApi(DEFAULT_CONFIG).stagesAllDestroy({
stageUuid: item.pk, stageUuid: item.pk,
}); });
@ -91,7 +90,7 @@ export class StageListPage extends TablePage<Stage> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Stage): TemplateResult[] { row(item: Stage): TemplateResult[] {

View file

@ -5,7 +5,7 @@ import { TablePage } from "../../../elements/table/TablePage";
import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/ModalButton";
import "../../../elements/buttons/SpinnerButton"; import "../../../elements/buttons/SpinnerButton";
import "../../../elements/forms/DeleteForm"; import "../../../elements/forms/DeleteBulkForm";
import "../../../elements/forms/ModalForm"; import "../../../elements/forms/ModalForm";
import "./InvitationForm"; import "./InvitationForm";
import "./InvitationListLink"; import "./InvitationListLink";
@ -54,17 +54,16 @@ export class InvitationListPage extends TablePage<Invitation> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Invitation(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Invitation`} .usedBy=${(item: Invitation) => {
.usedBy=${() => {
return new StagesApi(DEFAULT_CONFIG).stagesInvitationInvitationsUsedByList({ return new StagesApi(DEFAULT_CONFIG).stagesInvitationInvitationsUsedByList({
inviteUuid: item.pk, inviteUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: Invitation) => {
return new StagesApi(DEFAULT_CONFIG).stagesInvitationInvitationsDestroy({ return new StagesApi(DEFAULT_CONFIG).stagesInvitationInvitationsDestroy({
inviteUuid: item.pk, inviteUuid: item.pk,
}); });
@ -73,7 +72,7 @@ export class InvitationListPage extends TablePage<Invitation> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Invitation): TemplateResult[] { row(item: Invitation): TemplateResult[] {

View file

@ -5,7 +5,7 @@ import { TablePage } from "../../../elements/table/TablePage";
import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/ModalButton";
import "../../../elements/buttons/SpinnerButton"; import "../../../elements/buttons/SpinnerButton";
import "../../../elements/forms/DeleteForm"; import "../../../elements/forms/DeleteBulkForm";
import "../../../elements/forms/ModalForm"; import "../../../elements/forms/ModalForm";
import "./PromptForm"; import "./PromptForm";
import { TableColumn } from "../../../elements/table/Table"; import { TableColumn } from "../../../elements/table/Table";
@ -54,17 +54,16 @@ export class PromptListPage extends TablePage<Prompt> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Prompt(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Prompt`} .usedBy=${(item: Prompt) => {
.usedBy=${() => {
return new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsUsedByList({ return new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsUsedByList({
promptUuid: item.pk, promptUuid: item.pk,
}); });
}} }}
.delete=${() => { .delete=${(item: Prompt) => {
return new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsDestroy({ return new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsDestroy({
promptUuid: item.pk, promptUuid: item.pk,
}); });
@ -73,7 +72,7 @@ export class PromptListPage extends TablePage<Prompt> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Prompt): TemplateResult[] { row(item: Prompt): TemplateResult[] {

View file

@ -3,7 +3,7 @@ import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client"; import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage"; import { TablePage } from "../../elements/table/TablePage";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import "../../elements/buttons/SpinnerButton"; import "../../elements/buttons/SpinnerButton";
import { TableColumn } from "../../elements/table/Table"; import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
@ -50,17 +50,16 @@ export class TenantListPage extends TablePage<Tenant> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Tenant(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Tenant`} .usedBy=${(item: Tenant) => {
.usedBy=${() => {
return new CoreApi(DEFAULT_CONFIG).coreTenantsUsedByList({ return new CoreApi(DEFAULT_CONFIG).coreTenantsUsedByList({
tenantUuid: item.tenantUuid, tenantUuid: item.tenantUuid,
}); });
}} }}
.delete=${() => { .delete=${(item: Tenant) => {
return new CoreApi(DEFAULT_CONFIG).coreTenantsDestroy({ return new CoreApi(DEFAULT_CONFIG).coreTenantsDestroy({
tenantUuid: item.tenantUuid, tenantUuid: item.tenantUuid,
}); });
@ -69,7 +68,7 @@ export class TenantListPage extends TablePage<Tenant> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Tenant): TemplateResult[] { row(item: Tenant): TemplateResult[] {

View file

@ -5,7 +5,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/Dropdown"; import "../../elements/buttons/Dropdown";
import "../../elements/buttons/TokenCopyButton"; import "../../elements/buttons/TokenCopyButton";
import "../../elements/forms/DeleteForm"; import "../../elements/forms/DeleteBulkForm";
import { TableColumn } from "../../elements/table/Table"; import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants"; import { PAGE_SIZE } from "../../constants";
import { CoreApi, Token } from "authentik-api"; import { CoreApi, Token } from "authentik-api";
@ -51,17 +51,16 @@ export class TokenListPage extends TablePage<Token> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Token(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Token`} .usedBy=${(item: Token) => {
.usedBy=${() => {
return new CoreApi(DEFAULT_CONFIG).coreTokensUsedByList({ return new CoreApi(DEFAULT_CONFIG).coreTokensUsedByList({
identifier: item.identifier, identifier: item.identifier,
}); });
}} }}
.delete=${() => { .delete=${(item: Token) => {
return new CoreApi(DEFAULT_CONFIG).coreTokensDestroy({ return new CoreApi(DEFAULT_CONFIG).coreTokensDestroy({
identifier: item.identifier, identifier: item.identifier,
}); });
@ -70,7 +69,7 @@ export class TokenListPage extends TablePage<Token> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Token): TemplateResult[] { row(item: Token): TemplateResult[] {

View file

@ -3,7 +3,7 @@ import { CSSResult, customElement, html, property, TemplateResult } from "lit-el
import { AKResponse } from "../../../api/Client"; import { AKResponse } from "../../../api/Client";
import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css"; import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";
import "../../../elements/forms/DeleteForm"; import "../../../elements/forms/DeleteBulkForm";
import "../../../elements/forms/ModalForm"; import "../../../elements/forms/ModalForm";
import "../../../elements/buttons/ModalButton"; import "../../../elements/buttons/ModalButton";
import "../../../elements/buttons/Dropdown"; import "../../../elements/buttons/Dropdown";
@ -96,12 +96,11 @@ export class UserTokenList extends Table<Token> {
} }
renderToolbarSelected(): TemplateResult { renderToolbarSelected(): TemplateResult {
const disabled = this.selectedElements.length !== 1; const disabled = this.selectedElements.length < 1;
const item = this.selectedElements[0]; return html`<ak-forms-delete-bulk
return html`<ak-forms-delete objectLabel=${t`Token(s)`}
.obj=${item} .objects=${this.selectedElements}
objectLabel=${t`Token`} .delete=${(item: Token) => {
.delete=${() => {
return new CoreApi(DEFAULT_CONFIG).coreTokensDestroy({ return new CoreApi(DEFAULT_CONFIG).coreTokensDestroy({
identifier: item.identifier, identifier: item.identifier,
}); });
@ -110,7 +109,7 @@ export class UserTokenList extends Table<Token> {
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger"> <button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
${t`Delete`} ${t`Delete`}
</button> </button>
</ak-forms-delete>`; </ak-forms-delete-bulk>`;
} }
row(item: Token): TemplateResult[] { row(item: Token): TemplateResult[] {

View file

@ -75,14 +75,20 @@ export class UserListPage extends TablePage<User> {
return html` <ak-forms-delete-bulk return html` <ak-forms-delete-bulk
objectLabel=${t`User(s)`} objectLabel=${t`User(s)`}
.objects=${this.selectedElements} .objects=${this.selectedElements}
.usedBy=${(itemPk: number) => { .metadata=${(item: User) => {
return [
{ key: t`Username`, value: item.username },
{ key: t`ID`, value: item.pk.toString() },
];
}}
.usedBy=${(item: User) => {
return new CoreApi(DEFAULT_CONFIG).coreUsersUsedByList({ return new CoreApi(DEFAULT_CONFIG).coreUsersUsedByList({
id: itemPk, id: item.pk,
}); });
}} }}
.delete=${(itemPk: number) => { .delete=${(item: User) => {
return new CoreApi(DEFAULT_CONFIG).coreUsersDestroy({ return new CoreApi(DEFAULT_CONFIG).coreUsersDestroy({
id: itemPk, id: item.pk,
}); });
}} }}
> >