e28babb0b8
* rename consent permission Signed-off-by: Jens Langhammer <jens@goauthentik.io> * the user version Signed-off-by: Jens Langhammer <jens@goauthentik.io> t Signed-off-by: Jens Langhammer <jens@goauthentik.io> * initial role Signed-off-by: Jens Langhammer <jens@goauthentik.io> * start form Signed-off-by: Jens Langhammer <jens@goauthentik.io> * some minor table refactoring Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix user, add assign Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add roles ui Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix backend Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add assign API for roles Signed-off-by: Jens Langhammer <jens@goauthentik.io> * start adding toggle buttons Signed-off-by: Jens Langhammer <jens@goauthentik.io> * start view page Signed-off-by: Jens Langhammer <jens@goauthentik.io> * exclude add_ permission for per-object perms Signed-off-by: Jens Langhammer <jens@goauthentik.io> * small cleanup Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add permission list for roles Signed-off-by: Jens Langhammer <jens@goauthentik.io> * make sidebar update Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix page header not re-rendering? Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fixup Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add search Signed-off-by: Jens Langhammer <jens@goauthentik.io> * show first category in table groupBy except when its empty Signed-off-by: Jens Langhammer <jens@goauthentik.io> * make model and object PK optional but required together Signed-off-by: Jens Langhammer <jens@goauthentik.io> * allow for setting global perms Signed-off-by: Jens Langhammer <jens@goauthentik.io> * exclude non-authentik permissions Signed-off-by: Jens Langhammer <jens@goauthentik.io> * exclude models which aren't allowed (base models etc) Signed-off-by: Jens Langhammer <jens@goauthentik.io> * ensure all models have verbose_name set, exclude some more internal objects Signed-off-by: Jens Langhammer <jens@goauthentik.io> * lint fix Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix role perm assign Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add unasign for global perms Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add meta changes Signed-off-by: Jens Langhammer <jens@goauthentik.io> * clear modal state after submit Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add roles to our group Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix duplicate url names Signed-off-by: Jens Langhammer <jens@goauthentik.io> * make recursive group query more usable Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add name field to role itself and move group creation to signal Signed-off-by: Jens Langhammer <jens@goauthentik.io> * start sync Signed-off-by: Jens Langhammer <jens@goauthentik.io> * move rbac stuff to separate django app Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix lint and such Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix go Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update Signed-off-by: Jens Langhammer <jens@goauthentik.io> * start API changes Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add more API tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * make admin interface not require superuser for now, improve error handling Signed-off-by: Jens Langhammer <jens@goauthentik.io> * replace some IsAdminUser where applicable Signed-off-by: Jens Langhammer <jens@goauthentik.io> * migrate flow inspector perms to actual permission Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix license not being a serializermodel Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add permission modal to models without view page Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add additional permissions to assign/unassign permissions Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add action to unassign user permissions Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add permissions tab to remaining view pages Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix flow inspector permission check Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix codecov config? Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add more API tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * ensure viewsets have an order set Signed-off-by: Jens Langhammer <jens@goauthentik.io> * hopefully the last api name change Signed-off-by: Jens Langhammer <jens@goauthentik.io> * make perm modal less confusing Signed-off-by: Jens Langhammer <jens@goauthentik.io> * start user view permission page Signed-off-by: Jens Langhammer <jens@goauthentik.io> * only make delete bulk form expandable if usedBy is set Signed-off-by: Jens Langhammer <jens@goauthentik.io> * expand permission tables Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add more things Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add user global permission table Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix lint Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix tests' url names Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add tests for assign perms Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add unassign tests Signed-off-by: Jens Langhammer <jens@goauthentik.io> * rebuild permissions Signed-off-by: Jens Langhammer <jens@goauthentik.io> * prevent assigning/unassigning permissions to internal service accounts Signed-off-by: Jens Langhammer <jens@goauthentik.io> * only enable default api browser in debug Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix role object permissions showing duplicate Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix role link on role object permissions table Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix object permission modal having duplicate close buttons Signed-off-by: Jens Langhammer <jens@goauthentik.io> * return error if user has no global perm and no object perms also improve error display on table Signed-off-by: Jens Langhammer <jens@goauthentik.io> * small optimisation Signed-off-by: Jens Langhammer <jens@goauthentik.io> * optimise even more Signed-off-by: Jens Langhammer <jens@goauthentik.io> * update locale Signed-off-by: Jens Langhammer <jens@goauthentik.io> * add system permission for non-object permissions Signed-off-by: Jens Langhammer <jens@goauthentik.io> * allow access to admin interface based on perm Signed-off-by: Jens Langhammer <jens@goauthentik.io> * clean Signed-off-by: Jens Langhammer <jens@goauthentik.io> * don't exclude base models Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
198 lines
6.5 KiB
TypeScript
198 lines
6.5 KiB
TypeScript
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import {
|
|
EVENT_API_DRAWER_TOGGLE,
|
|
EVENT_NOTIFICATION_DRAWER_TOGGLE,
|
|
EVENT_SIDEBAR_TOGGLE,
|
|
EVENT_WS_MESSAGE,
|
|
TITLE_DEFAULT,
|
|
} from "@goauthentik/common/constants";
|
|
import { currentInterface } from "@goauthentik/common/sentry";
|
|
import { me } from "@goauthentik/common/users";
|
|
import { AKElement, rootInterface } from "@goauthentik/elements/Base";
|
|
import "@patternfly/elements/pf-tooltip/pf-tooltip.js";
|
|
|
|
import { msg } from "@lit/localize";
|
|
import { CSSResult, TemplateResult, css, html } from "lit";
|
|
import { customElement, property, state } from "lit/decorators.js";
|
|
|
|
import PFButton from "@patternfly/patternfly/components/Button/button.css";
|
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
|
|
|
import { EventsApi } from "@goauthentik/api";
|
|
|
|
@customElement("ak-page-header")
|
|
export class PageHeader extends AKElement {
|
|
@property()
|
|
icon?: string;
|
|
|
|
@property({ type: Boolean })
|
|
iconImage = false;
|
|
|
|
@property({ type: Boolean })
|
|
hasNotifications = false;
|
|
|
|
@property()
|
|
set header(value: string) {
|
|
const tenant = rootInterface()?.tenant;
|
|
const currentIf = currentInterface();
|
|
let title = tenant?.brandingTitle || TITLE_DEFAULT;
|
|
if (currentIf === "admin") {
|
|
title = `${msg("Admin")} - ${title}`;
|
|
}
|
|
if (value !== "") {
|
|
title = `${value} - ${title}`;
|
|
}
|
|
document.title = title;
|
|
this._header = value;
|
|
}
|
|
|
|
get header(): string {
|
|
return this._header;
|
|
}
|
|
|
|
@property()
|
|
description?: string;
|
|
|
|
@state()
|
|
_header = "";
|
|
|
|
static get styles(): CSSResult[] {
|
|
return [
|
|
PFBase,
|
|
PFButton,
|
|
PFPage,
|
|
PFContent,
|
|
css`
|
|
.bar {
|
|
display: flex;
|
|
flex-direction: row;
|
|
min-height: 114px;
|
|
}
|
|
.pf-c-button.pf-m-plain {
|
|
background-color: transparent;
|
|
border-radius: 0px;
|
|
}
|
|
.pf-c-page__main-section.pf-m-light {
|
|
background-color: transparent;
|
|
}
|
|
.pf-c-page__main-section {
|
|
flex-grow: 1;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
}
|
|
img.pf-icon {
|
|
max-height: 24px;
|
|
}
|
|
.sidebar-trigger,
|
|
.notification-trigger {
|
|
font-size: 24px;
|
|
}
|
|
.notification-trigger.has-notifications {
|
|
color: var(--pf-global--active-color--100);
|
|
}
|
|
h1 {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center !important;
|
|
}
|
|
`,
|
|
];
|
|
}
|
|
|
|
constructor() {
|
|
super();
|
|
window.addEventListener(EVENT_WS_MESSAGE, () => {
|
|
this.firstUpdated();
|
|
});
|
|
}
|
|
|
|
firstUpdated(): void {
|
|
me().then((user) => {
|
|
new EventsApi(DEFAULT_CONFIG)
|
|
.eventsNotificationsList({
|
|
seen: false,
|
|
ordering: "-created",
|
|
pageSize: 1,
|
|
user: user.user.pk,
|
|
})
|
|
.then((r) => {
|
|
this.hasNotifications = r.pagination.count > 0;
|
|
});
|
|
});
|
|
}
|
|
|
|
renderIcon(): TemplateResult {
|
|
if (this.icon) {
|
|
if (this.iconImage && !this.icon.startsWith("fa://")) {
|
|
return html`<img class="pf-icon" src="${this.icon}" alt="page icon" />`;
|
|
}
|
|
const icon = this.icon.replaceAll("fa://", "fa ");
|
|
return html`<i class=${icon}></i>`;
|
|
}
|
|
return html``;
|
|
}
|
|
|
|
render(): TemplateResult {
|
|
return html` <ak-enterprise-status interface="admin"></ak-enterprise-status>
|
|
<div class="bar">
|
|
<button
|
|
class="sidebar-trigger pf-c-button pf-m-plain"
|
|
@click=${() => {
|
|
this.dispatchEvent(
|
|
new CustomEvent(EVENT_SIDEBAR_TOGGLE, {
|
|
bubbles: true,
|
|
composed: true,
|
|
}),
|
|
);
|
|
}}
|
|
>
|
|
<i class="fas fa-bars"></i>
|
|
</button>
|
|
<section class="pf-c-page__main-section pf-m-light">
|
|
<div class="pf-c-content">
|
|
<h1>
|
|
<slot name="icon">${this.renderIcon()}</slot>
|
|
<slot name="header">${this.header}</slot>
|
|
</h1>
|
|
${this.description ? html`<p>${this.description}</p>` : html``}
|
|
</div>
|
|
</section>
|
|
<button
|
|
class="notification-trigger pf-c-button pf-m-plain"
|
|
@click=${() => {
|
|
this.dispatchEvent(
|
|
new CustomEvent(EVENT_API_DRAWER_TOGGLE, {
|
|
bubbles: true,
|
|
composed: true,
|
|
}),
|
|
);
|
|
}}
|
|
>
|
|
<pf-tooltip position="top" content=${msg("Open API drawer")}>
|
|
<i class="fas fa-code"></i>
|
|
</pf-tooltip>
|
|
</button>
|
|
<button
|
|
class="notification-trigger pf-c-button pf-m-plain ${this.hasNotifications
|
|
? "has-notifications"
|
|
: ""}"
|
|
@click=${() => {
|
|
this.dispatchEvent(
|
|
new CustomEvent(EVENT_NOTIFICATION_DRAWER_TOGGLE, {
|
|
bubbles: true,
|
|
composed: true,
|
|
}),
|
|
);
|
|
}}
|
|
>
|
|
<pf-tooltip position="top" content=${msg("Open Notification drawer")}>
|
|
<i class="fas fa-bell"></i>
|
|
</pf-tooltip>
|
|
</button>
|
|
</div>`;
|
|
}
|
|
}
|