web: use constants for custom event names

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-03-23 15:16:56 +01:00
parent 56344cadeb
commit 068d281b19
18 changed files with 38 additions and 19 deletions

View File

@ -17,7 +17,7 @@ import CodeMirrorTheme from "codemirror/theme/monokai.css";
import { convertToSlug } from "../../utils";
import { SpinnerButton } from "./SpinnerButton";
import { PRIMARY_CLASS } from "../../constants";
import { PRIMARY_CLASS, EVENT_REFRESH } from "../../constants";
import { showMessage } from "../messages/MessageContainer";
@customElement("ak-modal-button")
@ -113,7 +113,7 @@ export class ModalButton extends LitElement {
this.open = false;
console.debug("authentik/modalbutton: successful submit");
this.dispatchEvent(
new CustomEvent("ak-refresh", {
new CustomEvent(EVENT_REFRESH, {
bubbles: true,
composed: true,
})

View File

@ -1,5 +1,6 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { EVENT_REFRESH } from "../../constants";
import { ModalButton } from "../buttons/ModalButton";
import { showMessage } from "../messages/MessageContainer";
@ -22,7 +23,7 @@ export class ConfirmationForm extends ModalButton {
this.onSuccess();
this.open = false;
this.dispatchEvent(
new CustomEvent("ak-refresh", {
new CustomEvent(EVENT_REFRESH, {
bubbles: true,
composed: true,
})

View File

@ -1,5 +1,6 @@
import { gettext } from "django";
import { customElement, html, property, TemplateResult } from "lit-element";
import { EVENT_REFRESH } from "../../constants";
import { ModalButton } from "../buttons/ModalButton";
import { showMessage } from "../messages/MessageContainer";
@ -20,7 +21,7 @@ export class DeleteForm extends ModalButton {
this.onSuccess();
this.open = false;
this.dispatchEvent(
new CustomEvent("ak-refresh", {
new CustomEvent(EVENT_REFRESH, {
bubbles: true,
composed: true,
})

View File

@ -2,6 +2,7 @@ import { CSSResult, customElement, html, LitElement, TemplateResult } from "lit-
import PFBase from "@patternfly/patternfly/patternfly-base.css";
import PFDropdown from "@patternfly/patternfly/components/Dropdown/dropdown.css";
import FA from "@fortawesome/fontawesome-free/css/fontawesome.css";
import { EVENT_NOTIFICATION_TOGGLE } from "../../constants";
@customElement("ak-notification-trigger")
export class NotificationRule extends LitElement {
@ -14,7 +15,7 @@ export class NotificationRule extends LitElement {
super();
this.addEventListener("click", () => {
this.dispatchEvent(
new CustomEvent("ak-notification-toggle", {
new CustomEvent(EVENT_NOTIFICATION_TOGGLE, {
bubbles: true,
composed: true,
})

View File

@ -2,6 +2,7 @@ import { css, CSSResult, customElement, html, LitElement, TemplateResult } from
import PFBase from "@patternfly/patternfly/patternfly-base.css";
import PFButton from "@patternfly/patternfly/components/Button/button.css";
import AKGlobal from "../../authentik.css";
import { EVENT_SIDEBAR_TOGGLE } from "../../constants";
@customElement("ak-sidebar-hamburger")
export class SidebarHamburger extends LitElement {
@ -21,7 +22,7 @@ export class SidebarHamburger extends LitElement {
onClick(): void {
this.dispatchEvent(
new CustomEvent("ak-sidebar-toggle", {
new CustomEvent(EVENT_SIDEBAR_TOGGLE, {
bubbles: true,
composed: true,
})

View File

@ -13,6 +13,7 @@ import AKGlobal from "../../authentik.css";
import "./TablePagination";
import "../EmptyState";
import { EVENT_REFRESH } from "../../constants";
export class TableColumn {
@ -120,7 +121,7 @@ export abstract class Table<T> extends LitElement {
constructor() {
super();
this.addEventListener("ak-refresh", () => {
this.addEventListener(EVENT_REFRESH, () => {
this.fetch();
});
}