web/pages: use DeleteForm for all lists

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-03-18 12:14:27 +01:00
parent dae60b5a08
commit 48443e3e09
20 changed files with 233 additions and 108 deletions

View File

@ -17,6 +17,10 @@ export class DeleteForm extends ModalButton {
confirm(): void {
this.delete().then(() => {
showMessage({
message: gettext(`Successfully deleted ${this.objectLabel} ${this.obj?.name}`),
level_tag: "success",
});
this.open = false;
this.dispatchEvent(
new CustomEvent("ak-refresh", {
@ -28,8 +32,8 @@ export class DeleteForm extends ModalButton {
showMessage({
message: gettext(`Failed to delete ${this.objectLabel}: ${e.toString()}`),
level_tag: "error",
})
})
});
});
}
renderModalInner(): TemplateResult {

View File

@ -4,6 +4,7 @@ import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../../elements/table/Table";
import { PoliciesApi, PolicyBinding } from "authentik-api";
import "../../elements/forms/DeleteForm";
import "../../elements/Tabs";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
@ -90,13 +91,18 @@ export class BoundPoliciesList extends Table<PolicyBinding> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.policyBindings(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Policy binding")}
.delete=${() => {
return new PoliciesApi(DEFAULT_CONFIG).policiesBindingsDelete({
policyBindingUuid: item.pk || "",
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete Binding")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -4,6 +4,7 @@ import { AKResponse } from "../../api/Client";
import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/forms/DeleteForm";
import "../../elements/buttons/SpinnerButton";
import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants";
@ -82,13 +83,18 @@ export class ApplicationListPage extends TablePage<Application> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.applications(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Application")}
.delete=${() => {
return new CoreApi(DEFAULT_CONFIG).coreApplicationsDelete({
slug: item.slug || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -7,6 +7,7 @@ import { CryptoApi, CertificateKeyPair } from "authentik-api";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm";
import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants";
import { AdminURLManager } from "../../api/legacy";
@ -62,13 +63,18 @@ export class CertificateKeyPairListPage extends TablePage<CertificateKeyPair> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.cryptoCertificates(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Certificate-Key Pair")}
.delete=${() => {
return new CryptoApi(DEFAULT_CONFIG).cryptoCertificatekeypairsDelete({
kpUuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -11,6 +11,7 @@ import { PAGE_SIZE } from "../../constants";
import { EventsApi, NotificationRule } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import { AdminURLManager } from "../../api/legacy";
import "../../elements/forms/DeleteForm";
@customElement("ak-event-rule-list")
export class RuleListPage extends TablePage<NotificationRule> {
@ -62,13 +63,18 @@ export class RuleListPage extends TablePage<NotificationRule> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.eventRules(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Notification rule")}
.delete=${() => {
return new EventsApi(DEFAULT_CONFIG).eventsRulesDelete({
pbmUuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -11,6 +11,7 @@ import { PAGE_SIZE } from "../../constants";
import { EventsApi, NotificationTransport } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import { AdminURLManager } from "../../api/legacy";
import "../../elements/forms/DeleteForm";
@customElement("ak-event-transport-list")
export class TransportListPage extends TablePage<NotificationTransport> {
@ -66,13 +67,18 @@ export class TransportListPage extends TablePage<NotificationTransport> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.eventTransports(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Notifications Transport")}
.delete=${() => {
return new EventsApi(DEFAULT_CONFIG).eventsTransportsDelete({
uuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -3,6 +3,7 @@ import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client";
import { Table, TableColumn } from "../../elements/table/Table";
import "../../elements/forms/DeleteForm";
import "../../elements/Tabs";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
@ -57,13 +58,18 @@ export class BoundStagesList extends Table<FlowStageBinding> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.stageBindings(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Stage binding")}
.delete=${() => {
return new FlowsApi(DEFAULT_CONFIG).flowsBindingsDelete({
fsbUuid: item.pk || "",
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete Binding")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -5,6 +5,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm";
import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants";
import { Flow, FlowsApi } from "authentik-api";
@ -65,12 +66,18 @@ export class FlowListPage extends TablePage<Flow> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.flows(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Flow")}
.delete=${() => {
return new FlowsApi(DEFAULT_CONFIG).flowsInstancesDelete({
slug: item.slug || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
</button>
</ak-forms-delete>
<a class="pf-c-button pf-m-secondary ak-root-link" href="${AdminURLManager.flows(`${item.pk}/execute/?next=/%23${window.location.href}`)}">
${gettext("Execute")}
</a>

View File

@ -9,6 +9,7 @@ import "./OutpostHealth";
import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/TokenCopyButton";
import "../../elements/forms/DeleteForm";
import { PAGE_SIZE } from "../../constants";
import { Outpost, OutpostsApi } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
@ -63,12 +64,18 @@ export class OutpostListPage extends TablePage<Outpost> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>&nbsp;
<ak-modal-button href="${AdminURLManager.outposts(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Outpost")}
.delete=${() => {
return new OutpostsApi(DEFAULT_CONFIG).outpostsOutpostsDelete({
uuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
</button>
</ak-forms-delete>
<ak-modal-button>
<button slot="trigger" class="pf-c-button pf-m-tertiary">
${gettext("View Deployment Info")}

View File

@ -9,6 +9,7 @@ import "./OutpostHealth";
import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/Dropdown";
import "../../elements/forms/DeleteForm";
import { until } from "lit-html/directives/until";
import { PAGE_SIZE } from "../../constants";
import { OutpostsApi, ServiceConnection } from "authentik-api";
@ -73,12 +74,18 @@ export class OutpostServiceConnectionListPage extends TablePage<ServiceConnectio
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.outpostServiceConnections(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Outpost Service-connection")}
.delete=${() => {
return new OutpostsApi(DEFAULT_CONFIG).outpostsServiceConnectionsAllDelete({
uuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -6,6 +6,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/Dropdown";
import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm";
import { TableColumn } from "../../elements/table/Table";
import { until } from "lit-html/directives/until";
import { PAGE_SIZE } from "../../constants";
@ -74,13 +75,18 @@ export class PolicyListPage extends TablePage<Policy> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.policies(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Policy")}
.delete=${() => {
return new PoliciesApi(DEFAULT_CONFIG).policiesAllDelete({
policyUuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -6,6 +6,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/Dropdown";
import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm";
import { TableColumn } from "../../elements/table/Table";
import { until } from "lit-html/directives/until";
import { PAGE_SIZE } from "../../constants";
@ -69,13 +70,18 @@ export class PropertyMappingListPage extends TablePage<PropertyMapping> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.propertyMappings(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Property Mapping")}
.delete=${() => {
return new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsAllDelete({
pmUuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -6,6 +6,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/Dropdown";
import "../../elements/forms/DeleteForm";
import { TableColumn } from "../../elements/table/Table";
import { until } from "lit-html/directives/until";
import { PAGE_SIZE } from "../../constants";
@ -68,13 +69,18 @@ export class ProviderListPage extends TablePage<Provider> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.providers(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Source")}
.delete=${() => {
return new ProvidersApi(DEFAULT_CONFIG).providersAllDelete({
id: item.pk || 0
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -7,6 +7,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/Dropdown";
import "../../elements/forms/DeleteForm";
import { until } from "lit-html/directives/until";
import { PAGE_SIZE } from "../../constants";
import { Source, SourcesApi } from "authentik-api";
@ -62,13 +63,18 @@ export class SourceListPage extends TablePage<Source> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.sources(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Source")}
.delete=${() => {
return new SourcesApi(DEFAULT_CONFIG).sourcesAllDelete({
slug: item.slug || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -5,6 +5,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm";
import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants";
import { Invitation, StagesApi } from "authentik-api";
@ -53,12 +54,18 @@ export class InvitationListPage extends TablePage<Invitation> {
html`${item.createdBy?.username}`,
html`${item.expires?.toLocaleString()}`,
html`
<ak-modal-button href="${AdminURLManager.stageInvitations(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Prompt")}
.delete=${() => {
return new StagesApi(DEFAULT_CONFIG).stagesInvitationInvitationsDelete({
inviteUuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -5,6 +5,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import "../../elements/forms/DeleteForm";
import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants";
import { Prompt, StagesApi } from "authentik-api";
@ -65,12 +66,18 @@ export class PromptListPage extends TablePage<Prompt> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.stagePrompts(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Prompt")}
.delete=${() => {
return new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsDelete({
promptUuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -7,6 +7,7 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/SpinnerButton";
import "../../elements/buttons/Dropdown";
import "../../elements/forms/DeleteForm";
import { until } from "lit-html/directives/until";
import { PAGE_SIZE } from "../../constants";
import { Stage, StagesApi } from "authentik-api";
@ -66,13 +67,18 @@ export class StageListPage extends TablePage<Stage> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.stages(`${item.pk}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Group")}
.delete=${() => {
return new StagesApi(DEFAULT_CONFIG).stagesAllDelete({
stageUuid: item.pk || ""
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
`,
</button>
</ak-forms-delete>`,
];
}

View File

@ -6,11 +6,11 @@ import { TablePage } from "../../elements/table/TablePage";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/Dropdown";
import "../../elements/buttons/TokenCopyButton";
import "../../elements/forms/DeleteForm";
import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants";
import { CoreApi, Token } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import { AdminURLManager } from "../../api/legacy";
@customElement("ak-token-list")
export class TokenListPage extends TablePage<Token> {
@ -56,12 +56,18 @@ export class TokenListPage extends TablePage<Token> {
html`${item.expiring ? "Yes" : "No"}`,
html`${item.expiring ? item.expires?.toLocaleString() : "-"}`,
html`
<ak-modal-button href="${AdminURLManager.tokens(`${item.identifier}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Token")}
.delete=${() => {
return new CoreApi(DEFAULT_CONFIG).coreTokensDelete({
identifier: item.identifier
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
</button>
</ak-forms-delete>
<ak-token-copy-button identifier="${item.identifier}">
${gettext("Copy Key")}
</ak-token-copy-button>

View File

@ -2,6 +2,7 @@ import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { AKResponse } from "../../api/Client";
import "../../elements/forms/DeleteForm";
import "../../elements/buttons/ModalButton";
import "../../elements/buttons/Dropdown";
import "../../elements/buttons/TokenCopyButton";
@ -95,12 +96,18 @@ export class UserTokenList extends Table<Token> {
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
<ak-modal-button href="${AdminURLManager.tokens(`${item.identifier}/delete/`)}">
<ak-spinner-button slot="trigger" class="pf-m-danger">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("Token")}
.delete=${() => {
return new CoreApi(DEFAULT_CONFIG).coreTokensDelete({
identifier: item.identifier
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</ak-spinner-button>
<div slot="modal"></div>
</ak-modal-button>
</button>
</ak-forms-delete>
<ak-token-copy-button identifier="${item.identifier}">
${gettext("Copy Key")}
</ak-token-copy-button>

View File

@ -11,6 +11,7 @@ import { PAGE_SIZE } from "../../constants";
import { CoreApi, User } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import { AdminURLManager } from "../../api/legacy";
import "../../elements/forms/DeleteForm";
@customElement("ak-user-list")
export class UserListPage extends TablePage<User> {
@ -86,12 +87,18 @@ export class UserListPage extends TablePage<User> {
</li>
<li class="pf-c-divider" role="separator"></li>
<li>
<ak-modal-button href="${AdminURLManager.users(`${item.pk}/delete/`)}">
<button slot="trigger" class="pf-c-dropdown__menu-item">
<ak-forms-delete
.obj=${item}
objectLabel=${gettext("User")}
.delete=${() => {
return new CoreApi(DEFAULT_CONFIG).coreUsersDelete({
id: item.pk || 0
});
}}>
<button slot="trigger" class="pf-c-button pf-m-danger">
${gettext("Delete")}
</button>
<div slot="modal"></div>
</ak-modal-button>
</ak-forms-delete>
</li>
</ul>
</ak-dropdown>