
* web: fix esbuild issue with style sheets Getting ESBuild, Lit, and Storybook to all agree on how to read and parse stylesheets is a serious pain. This fix better identifies the value types (instances) being passed from various sources in the repo to the three *different* kinds of style processors we're using (the native one, the polyfill one, and whatever the heck Storybook does internally). Falling back to using older CSS instantiating techniques one era at a time seems to do the trick. It's ugly, but in the face of the aggressive styling we use to avoid Flashes of Unstyled Content (FLoUC), it's the logic with which we're left. In standard mode, the following warning appears on the console when running a Flow: ``` Autofocus processing was blocked because a document already has a focused element. ``` In compatibility mode, the following **error** appears on the console when running a Flow: ``` crawler-inject.js:1106 Uncaught TypeError: Failed to execute 'observe' on 'MutationObserver': parameter 1 is not of type 'Node'. at initDomMutationObservers (crawler-inject.js:1106:18) at crawler-inject.js:1114:24 at Array.forEach (<anonymous>) at initDomMutationObservers (crawler-inject.js:1114:10) at crawler-inject.js:1549:1 initDomMutationObservers @ crawler-inject.js:1106 (anonymous) @ crawler-inject.js:1114 initDomMutationObservers @ crawler-inject.js:1114 (anonymous) @ crawler-inject.js:1549 ``` Despite this error, nothing seems to be broken and flows work as anticipated. * Intermediate; prepping for remove that may fail. * web: provide a default table endpoint configuration This commit finds 19 places where the exact same configuration is used to describe a table's API endpoint, and replaces that configuration with a provided default from a parent class. While examining the logs for our build, I noted that this particular sequence is duplicated multiple times throughout our code base, accounting for a bloat of 169 lines or so of the estimated 5552 lines of bloat. By providing a default endpoint configuration and substituting it (mechanically) wherever the default is required, we reduce our code duplication issue from 9.26% of the codesabe to 8.99%. ... which is a start. * Didn't need the duplication. * remove page argument while we're at it Signed-off-by: Jens Langhammer <jens@goauthentik.io> * actually use it everywhere Signed-off-by: Jens Langhammer <jens@goauthentik.io> * web: fix inconsistent method signature for LogViewer Removed the `_page` parameter from LogViewer's apiEndpoint() method. The `page: number` parameter is no longer a part of this method's signature. * web: restore reduced page size to Overview:Recent Events card --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
135 lines
5.0 KiB
TypeScript
135 lines
5.0 KiB
TypeScript
import "@goauthentik/admin/events/RuleForm";
|
|
import "@goauthentik/admin/policies/BoundPoliciesList";
|
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import { severityToLabel } from "@goauthentik/common/labels";
|
|
import "@goauthentik/elements/buttons/SpinnerButton";
|
|
import "@goauthentik/elements/forms/DeleteBulkForm";
|
|
import "@goauthentik/elements/forms/ModalForm";
|
|
import "@goauthentik/elements/rbac/ObjectPermissionModal";
|
|
import "@goauthentik/elements/rbac/ObjectPermissionModal";
|
|
import { PaginatedResponse } from "@goauthentik/elements/table/Table";
|
|
import { TableColumn } from "@goauthentik/elements/table/Table";
|
|
import { TablePage } from "@goauthentik/elements/table/TablePage";
|
|
import "@patternfly/elements/pf-tooltip/pf-tooltip.js";
|
|
|
|
import { msg } from "@lit/localize";
|
|
import { TemplateResult, html } from "lit";
|
|
import { customElement, property } from "lit/decorators.js";
|
|
|
|
import {
|
|
EventsApi,
|
|
NotificationRule,
|
|
RbacPermissionsAssignedByUsersListModelEnum,
|
|
} from "@goauthentik/api";
|
|
|
|
@customElement("ak-event-rule-list")
|
|
export class RuleListPage extends TablePage<NotificationRule> {
|
|
expandable = true;
|
|
checkbox = true;
|
|
clearOnRefresh = true;
|
|
|
|
searchEnabled(): boolean {
|
|
return true;
|
|
}
|
|
pageTitle(): string {
|
|
return msg("Notification Rules");
|
|
}
|
|
pageDescription(): string {
|
|
return msg(
|
|
"Send notifications whenever a specific Event is created and matched by policies.",
|
|
);
|
|
}
|
|
pageIcon(): string {
|
|
return "pf-icon pf-icon-attention-bell";
|
|
}
|
|
|
|
@property()
|
|
order = "name";
|
|
|
|
async apiEndpoint(): Promise<PaginatedResponse<NotificationRule>> {
|
|
return new EventsApi(DEFAULT_CONFIG).eventsRulesList(await this.defaultEndpointConfig());
|
|
}
|
|
|
|
columns(): TableColumn[] {
|
|
return [
|
|
new TableColumn(msg("Name"), "name"),
|
|
new TableColumn(msg("Severity"), "severity"),
|
|
new TableColumn(msg("Sent to group"), "group"),
|
|
new TableColumn(msg("Actions")),
|
|
];
|
|
}
|
|
|
|
renderToolbarSelected(): TemplateResult {
|
|
const disabled = this.selectedElements.length < 1;
|
|
return html`<ak-forms-delete-bulk
|
|
objectLabel=${msg("Notification rule(s)")}
|
|
.objects=${this.selectedElements}
|
|
.usedBy=${(item: NotificationRule) => {
|
|
return new EventsApi(DEFAULT_CONFIG).eventsRulesUsedByList({
|
|
pbmUuid: item.pk,
|
|
});
|
|
}}
|
|
.delete=${(item: NotificationRule) => {
|
|
return new EventsApi(DEFAULT_CONFIG).eventsRulesDestroy({
|
|
pbmUuid: item.pk,
|
|
});
|
|
}}
|
|
>
|
|
<button ?disabled=${disabled} slot="trigger" class="pf-c-button pf-m-danger">
|
|
${msg("Delete")}
|
|
</button>
|
|
</ak-forms-delete-bulk>`;
|
|
}
|
|
|
|
row(item: NotificationRule): TemplateResult[] {
|
|
return [
|
|
html`${item.name}`,
|
|
html`${severityToLabel(item.severity)}`,
|
|
html`${item.groupObj
|
|
? html`<a href="#/identity/groups/${item.groupObj.pk}">${item.groupObj.name}</a>`
|
|
: msg("None (rule disabled)")}`,
|
|
html`<ak-forms-modal>
|
|
<span slot="submit"> ${msg("Update")} </span>
|
|
<span slot="header"> ${msg("Update Notification Rule")} </span>
|
|
<ak-event-rule-form slot="form" .instancePk=${item.pk}> </ak-event-rule-form>
|
|
<button slot="trigger" class="pf-c-button pf-m-plain">
|
|
<pf-tooltip position="top" content=${msg("Edit")}>
|
|
<i class="fas fa-edit"></i>
|
|
</pf-tooltip>
|
|
</button>
|
|
</ak-forms-modal>
|
|
|
|
<ak-rbac-object-permission-modal
|
|
model=${RbacPermissionsAssignedByUsersListModelEnum.EventsNotificationrule}
|
|
objectPk=${item.pk}
|
|
>
|
|
</ak-rbac-object-permission-modal>`,
|
|
];
|
|
}
|
|
|
|
renderObjectCreate(): TemplateResult {
|
|
return html`
|
|
<ak-forms-modal>
|
|
<span slot="submit"> ${msg("Create")} </span>
|
|
<span slot="header"> ${msg("Create Notification Rule")} </span>
|
|
<ak-event-rule-form slot="form"> </ak-event-rule-form>
|
|
<button slot="trigger" class="pf-c-button pf-m-primary">${msg("Create")}</button>
|
|
</ak-forms-modal>
|
|
`;
|
|
}
|
|
|
|
renderExpanded(item: NotificationRule): TemplateResult {
|
|
return html` <td role="cell" colspan="4">
|
|
<div class="pf-c-table__expandable-row-content">
|
|
<p>
|
|
${msg(
|
|
`These bindings control upon which events this rule triggers.
|
|
Bindings to groups/users are checked against the user of the event.`,
|
|
)}
|
|
</p>
|
|
<ak-bound-policies-list .target=${item.pk}> </ak-bound-policies-list>
|
|
</div>
|
|
</td>`;
|
|
}
|
|
}
|