From 92700a2fa6fdbac5c41a1058a5a5fa6bd47067bd Mon Sep 17 00:00:00 2001 From: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com> Date: Fri, 8 May 2026 01:47:50 +0200 Subject: [PATCH] web: Fix issue where default user path is not preferred. --- web/src/admin/users/UserForm.ts | 5 +- web/src/admin/users/UserListPage.ts | 66 +++++++++++++-------------- web/src/admin/users/ak-user-wizard.ts | 6 ++- 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/web/src/admin/users/UserForm.ts b/web/src/admin/users/UserForm.ts index 5b696c9dfa..e908012d9e 100644 --- a/web/src/admin/users/UserForm.ts +++ b/web/src/admin/users/UserForm.ts @@ -7,6 +7,7 @@ import "#components/ak-radio-input"; import "#components/ak-switch-input"; import { DEFAULT_CONFIG } from "#common/api/config"; +import { DefaultUIConfig } from "#common/ui/config"; import { ModelForm } from "#elements/forms/ModelForm"; import { RadioOption } from "#elements/forms/Radio"; @@ -58,8 +59,8 @@ export class UserForm extends ModelForm { @property({ attribute: false }) public targetRole: Role | null = null; - @property({ type: String, attribute: "default-path" }) - public defaultPath: string = "users"; + @property({ type: String, attribute: "default-path", useDefault: true }) + public defaultPath: string = DefaultUIConfig.defaults.userPath; @property({ attribute: false }) public userType: UserTypeEnum | null = null; diff --git a/web/src/admin/users/UserListPage.ts b/web/src/admin/users/UserListPage.ts index b426d08107..756d8c2df6 100644 --- a/web/src/admin/users/UserListPage.ts +++ b/web/src/admin/users/UserListPage.ts @@ -91,15 +91,15 @@ export class UserListPage extends WithLicenseSummary( public override searchPlaceholder = msg("Search by username, email, etc..."); public override searchLabel = msg("User Search"); - public pageTitle = msg("Users"); - public pageDescription = ""; - public pageIcon = "pf-icon pf-icon-user"; + public override pageTitle = msg("Users"); + public override pageDescription = ""; + public override pageIcon = "pf-icon pf-icon-user"; @property({ type: String }) public order = "-last_login"; - @property({ type: String }) - public activePath: string; + @property({ type: String, useDefault: true }) + public activePath: string = DefaultUIConfig.defaults.userPath; @state() protected hideDeactivated = getURLParam("hideDeactivated", false); @@ -107,27 +107,23 @@ export class UserListPage extends WithLicenseSummary( @state() protected userPaths: UserPath | null = null; - constructor() { - super(); - - const defaultPath = DefaultUIConfig.defaults.userPath; - - this.activePath = getURLParam("path", defaultPath); - - if (this.uiConfig.defaults.userPath !== defaultPath) { - this.activePath = this.uiConfig.defaults.userPath; - } - } - protected canImpersonate = false; public override connectedCallback(): void { super.connectedCallback(); this.canImpersonate = this.can(CapabilitiesEnum.CanImpersonate); + + const initialDefaultUserPath = DefaultUIConfig.defaults.userPath; + const brandDefaultUserPath = this.uiConfig.defaults.userPath; + + this.activePath = getURLParam( + "path", + brandDefaultUserPath || initialDefaultUserPath, + ); } - async apiEndpoint(): Promise> { + protected override async apiEndpoint(): Promise> { const users = await this.#api.coreUsersList({ ...(await this.defaultEndpointConfig()), pathStartswith: this.activePath, @@ -142,6 +138,18 @@ export class UserListPage extends WithLicenseSummary( return users; } + protected buildExportParams = async (): Promise => { + return { + ...(await this.defaultEndpointConfig()), + pathStartswith: this.activePath, + isActive: this.hideDeactivated ? true : undefined, + }; + }; + + protected createExport = (params: CoreUsersExportCreateRequest) => { + return this.#api.coreUsersExportCreate(params); + }; + protected override rowLabel(item: User): string { if (item.name) { return msg(str`${item.username} (${item.name})`); @@ -159,6 +167,8 @@ export class UserListPage extends WithLicenseSummary( [msg("Actions"), null, msg("Row Actions")], ]; + //#region Renderering + protected override renderToolbarSelected(): TemplateResult { const disabled = this.selectedElements.length < 1; const { currentUser, originalUser } = this; @@ -249,7 +259,7 @@ export class UserListPage extends WithLicenseSummary( `; } - protected row(item: User) { + protected override row(item: User): SlottedTemplateResult[] { const { currentUser } = this; const showImpersonation = this.canImpersonate && currentUser && item.pk !== currentUser.pk; @@ -294,7 +304,7 @@ export class UserListPage extends WithLicenseSummary( ]; } - renderExpanded(item: User): TemplateResult { + protected override renderExpanded(item: User): SlottedTemplateResult { return html`
@@ -335,18 +345,6 @@ export class UserListPage extends WithLicenseSummary(
`; } - protected buildExportParams = async () => { - return { - ...(await this.defaultEndpointConfig()), - pathStartswith: this.activePath, - isActive: this.hideDeactivated ? true : undefined, - }; - }; - - protected createExport = (params: CoreUsersExportCreateRequest) => { - return this.#api.coreUsersExportCreate(params); - }; - protected renderObjectCreate(): SlottedTemplateResult { const { activePath } = this; @@ -370,7 +368,7 @@ export class UserListPage extends WithLicenseSummary( }); } - protected renderSidebarBefore(): TemplateResult { + protected renderSidebarBefore(): SlottedTemplateResult { return html``; } + + //#endregion } declare global { diff --git a/web/src/admin/users/ak-user-wizard.ts b/web/src/admin/users/ak-user-wizard.ts index 0d62239d64..6b4246872d 100644 --- a/web/src/admin/users/ak-user-wizard.ts +++ b/web/src/admin/users/ak-user-wizard.ts @@ -6,6 +6,8 @@ import "#elements/wizard/FormWizardPage"; import "#elements/wizard/TypeCreateWizardPage"; import "#elements/wizard/Wizard"; +import { DefaultUIConfig } from "#common/ui/config"; + import { LitPropertyRecord, SlottedTemplateResult } from "#elements/types"; import { CreateWizard } from "#elements/wizard/CreateWizard"; import { TypeCreateWizardPageLayouts } from "#elements/wizard/TypeCreateWizardPage"; @@ -115,8 +117,8 @@ export class AKUserWizard extends CreateWizard { /** * Default path to assign to new users created via the wizard. */ - @property({ type: String, attribute: "default-path" }) - public defaultPath: string = "users"; + @property({ type: String, attribute: "default-path", useDefault: true }) + public defaultPath: string = DefaultUIConfig.defaults.userPath; protected apiEndpoint(): Promise { return Promise.resolve(DEFAULT_USER_TYPES);