* 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.
* web: clean up and remove redundant alias '@goauthentik/app'
The path alias `@goauthentik/app` has been a thorn in our side for a long time, as it conflicts with
or is redundant with all the *other* aliases in `tsconfig.json`, such as `@goauthentik/elements` and
`@goauthentik/locales`.
This commit *replaces* `@goauthentik/app` with `@goauthentik/authentik` for a single use case: the
locale codes file in the project root. That also helps reserve the subproject name `authentik` in
case we ever do go the monorepo root.
Other than that, all the rest have been removed with the following mechanical refactor:
```
perl -pi.bak -e 's{\@goauthentik/app/}{\@goauthentik/}' $(rg -l '@goauthentik/app/' ./src/)
```
* web: separate the sizing enum from a specific component implementation (#8890)
The PFSizes enum is used by more than just the Spinner, but has been left inside the Spinner for all
this time, making refactoring the Spinner for Patternfly 5 a little harder (okay, an annoying amount
harder) than it should be.
This commit moves this UI-specific, widely-use enum into its own folder in `common`, and refactors
everything else to use it. As is often the case, the refactor is mechanical:
```
perl -pi.bak -e 's{import \{ PFSize \} from "\@goauthentik/elements/Spinner";}{import \{ PFSize \}
from "\@goauthentik/common/enums.js";}' \\
$(rg -l 'import.*PFSize')
```
**Note:** This commit is dependent upon the ["clean up and remove redundant alias `@goauthentik/app`" PR](https://github.com/goauthentik/authentik/pull/8889)
185 lines
8.1 KiB
TypeScript
185 lines
8.1 KiB
TypeScript
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
|
import { EVENT_REFRESH } from "@goauthentik/common/constants";
|
|
import { AKElement, rootInterface } from "@goauthentik/elements/Base";
|
|
import "@goauthentik/elements/Tabs";
|
|
import "@goauthentik/elements/user/SessionList";
|
|
import "@goauthentik/elements/user/UserConsentList";
|
|
import "@goauthentik/elements/user/sources/SourceSettings";
|
|
import { UserInterface } from "@goauthentik/user/UserInterface";
|
|
import "@goauthentik/user/user-settings/details/UserPassword";
|
|
import "@goauthentik/user/user-settings/details/UserSettingsFlowExecutor";
|
|
import "@goauthentik/user/user-settings/mfa/MFADevicesPage";
|
|
import "@goauthentik/user/user-settings/tokens/UserTokenList";
|
|
|
|
import { localized, msg } from "@lit/localize";
|
|
import { CSSResult, TemplateResult, css, html } from "lit";
|
|
import { customElement, state } from "lit/decorators.js";
|
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
|
|
import PFCard from "@patternfly/patternfly/components/Card/card.css";
|
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
|
import PFDescriptionList from "@patternfly/patternfly/components/DescriptionList/description-list.css";
|
|
import PFForm from "@patternfly/patternfly/components/Form/form.css";
|
|
import PFFormControl from "@patternfly/patternfly/components/FormControl/form-control.css";
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
import PFGallery from "@patternfly/patternfly/layouts/Gallery/gallery.css";
|
|
import PFStack from "@patternfly/patternfly/layouts/Stack/stack.css";
|
|
import PFBase from "@patternfly/patternfly/patternfly-base.css";
|
|
import PFDisplay from "@patternfly/patternfly/utilities/Display/display.css";
|
|
import PFSizing from "@patternfly/patternfly/utilities/Sizing/sizing.css";
|
|
|
|
import { StagesApi, UserSetting } from "@goauthentik/api";
|
|
|
|
@localized()
|
|
@customElement("ak-user-settings")
|
|
export class UserSettingsPage extends AKElement {
|
|
static get styles(): CSSResult[] {
|
|
return [
|
|
PFBase,
|
|
PFPage,
|
|
PFDisplay,
|
|
PFGallery,
|
|
PFContent,
|
|
PFCard,
|
|
PFDescriptionList,
|
|
PFSizing,
|
|
PFForm,
|
|
PFFormControl,
|
|
PFStack,
|
|
css`
|
|
.pf-c-page {
|
|
--pf-c-page--BackgroundColor: transparent;
|
|
}
|
|
.pf-c-page__main-section {
|
|
--pf-c-page__main-section--BackgroundColor: transparent;
|
|
}
|
|
:host([theme="dark"]) .pf-c-page {
|
|
--pf-c-page--BackgroundColor: transparent;
|
|
}
|
|
:host([theme="dark"]) .pf-c-page__main-section {
|
|
--pf-c-page__main-section--BackgroundColor: transparent;
|
|
}
|
|
@media screen and (min-width: 1200px) {
|
|
:host {
|
|
width: 90rem;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
}
|
|
`,
|
|
];
|
|
}
|
|
|
|
@state()
|
|
userSettings?: UserSetting[];
|
|
|
|
constructor() {
|
|
super();
|
|
this.addEventListener(EVENT_REFRESH, () => {
|
|
this.firstUpdated();
|
|
});
|
|
}
|
|
|
|
async firstUpdated(): Promise<void> {
|
|
this.userSettings = await new StagesApi(DEFAULT_CONFIG).stagesAllUserSettingsList();
|
|
}
|
|
|
|
render(): TemplateResult {
|
|
const pwStage =
|
|
this.userSettings?.filter((stage) => stage.component === "ak-user-settings-password") ||
|
|
[];
|
|
return html`<div class="pf-c-page">
|
|
<main role="main" class="pf-c-page__main" tabindex="-1">
|
|
<ak-tabs ?vertical="${true}">
|
|
<section
|
|
slot="page-details"
|
|
data-tab-title="${msg("User details")}"
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
>
|
|
<div class="pf-l-stack pf-m-gutter">
|
|
<div class="pf-l-stack__item">
|
|
<ak-user-settings-flow-executor></ak-user-settings-flow-executor>
|
|
</div>
|
|
<div class="pf-l-stack__item">
|
|
${pwStage.length > 0
|
|
? html`<ak-user-settings-password
|
|
configureUrl=${ifDefined(pwStage[0].configureUrl)}
|
|
></ak-user-settings-password>`
|
|
: html``}
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<section
|
|
slot="page-sessions"
|
|
data-tab-title="${msg("Sessions")}"
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
>
|
|
<div class="pf-c-card">
|
|
<div class="pf-c-card__body">
|
|
<ak-user-session-list
|
|
targetUser=${ifDefined(
|
|
rootInterface<UserInterface>()?.me?.user.username,
|
|
)}
|
|
></ak-user-session-list>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<section
|
|
slot="page-consents"
|
|
data-tab-title="${msg("Consent")}"
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
>
|
|
<div class="pf-c-card">
|
|
<div class="pf-c-card__body">
|
|
<ak-user-consent-list
|
|
userId=${ifDefined(rootInterface<UserInterface>()?.me?.user.pk)}
|
|
></ak-user-consent-list>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<section
|
|
slot="page-mfa"
|
|
data-tab-title="${msg("MFA Devices")}"
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
>
|
|
<div class="pf-c-card">
|
|
<div class="pf-c-card__body">
|
|
<ak-user-settings-mfa
|
|
.userSettings=${this.userSettings}
|
|
></ak-user-settings-mfa>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
<section
|
|
slot="page-sources"
|
|
data-tab-title="${msg("Connected services")}"
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
>
|
|
<div class="pf-c-card">
|
|
<div class="pf-c-card__title">
|
|
${msg(
|
|
"Connect your user account to the services listed below, to allow you to login using the service instead of traditional credentials.",
|
|
)}
|
|
</div>
|
|
<ak-user-settings-source
|
|
userId=${ifDefined(rootInterface<UserInterface>()?.me?.user.pk)}
|
|
></ak-user-settings-source>
|
|
</div>
|
|
</section>
|
|
<section
|
|
slot="page-tokens"
|
|
data-tab-title="${msg("Tokens and App passwords")}"
|
|
class="pf-c-page__main-section pf-m-no-padding-mobile"
|
|
>
|
|
<div class="pf-c-card">
|
|
<div class="pf-c-card__body">
|
|
<ak-user-token-list></ak-user-token-list>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</ak-tabs>
|
|
</main>
|
|
</div>`;
|
|
}
|
|
}
|