Skip to content

Commit 92700a2

Browse files
committed
web: Fix issue where default user path is not preferred.
1 parent b4c7dea commit 92700a2

3 files changed

Lines changed: 40 additions & 37 deletions

File tree

web/src/admin/users/UserForm.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import "#components/ak-radio-input";
77
import "#components/ak-switch-input";
88

99
import { DEFAULT_CONFIG } from "#common/api/config";
10+
import { DefaultUIConfig } from "#common/ui/config";
1011

1112
import { ModelForm } from "#elements/forms/ModelForm";
1213
import { RadioOption } from "#elements/forms/Radio";
@@ -58,8 +59,8 @@ export class UserForm extends ModelForm<User, number> {
5859
@property({ attribute: false })
5960
public targetRole: Role | null = null;
6061

61-
@property({ type: String, attribute: "default-path" })
62-
public defaultPath: string = "users";
62+
@property({ type: String, attribute: "default-path", useDefault: true })
63+
public defaultPath: string = DefaultUIConfig.defaults.userPath;
6364

6465
@property({ attribute: false })
6566
public userType: UserTypeEnum | null = null;

web/src/admin/users/UserListPage.ts

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -91,43 +91,39 @@ export class UserListPage extends WithLicenseSummary(
9191
public override searchPlaceholder = msg("Search by username, email, etc...");
9292
public override searchLabel = msg("User Search");
9393

94-
public pageTitle = msg("Users");
95-
public pageDescription = "";
96-
public pageIcon = "pf-icon pf-icon-user";
94+
public override pageTitle = msg("Users");
95+
public override pageDescription = "";
96+
public override pageIcon = "pf-icon pf-icon-user";
9797

9898
@property({ type: String })
9999
public order = "-last_login";
100100

101-
@property({ type: String })
102-
public activePath: string;
101+
@property({ type: String, useDefault: true })
102+
public activePath: string = DefaultUIConfig.defaults.userPath;
103103

104104
@state()
105105
protected hideDeactivated = getURLParam<boolean>("hideDeactivated", false);
106106

107107
@state()
108108
protected userPaths: UserPath | null = null;
109109

110-
constructor() {
111-
super();
112-
113-
const defaultPath = DefaultUIConfig.defaults.userPath;
114-
115-
this.activePath = getURLParam<string>("path", defaultPath);
116-
117-
if (this.uiConfig.defaults.userPath !== defaultPath) {
118-
this.activePath = this.uiConfig.defaults.userPath;
119-
}
120-
}
121-
122110
protected canImpersonate = false;
123111

124112
public override connectedCallback(): void {
125113
super.connectedCallback();
126114

127115
this.canImpersonate = this.can(CapabilitiesEnum.CanImpersonate);
116+
117+
const initialDefaultUserPath = DefaultUIConfig.defaults.userPath;
118+
const brandDefaultUserPath = this.uiConfig.defaults.userPath;
119+
120+
this.activePath = getURLParam<string>(
121+
"path",
122+
brandDefaultUserPath || initialDefaultUserPath,
123+
);
128124
}
129125

130-
async apiEndpoint(): Promise<PaginatedResponse<User>> {
126+
protected override async apiEndpoint(): Promise<PaginatedResponse<User>> {
131127
const users = await this.#api.coreUsersList({
132128
...(await this.defaultEndpointConfig()),
133129
pathStartswith: this.activePath,
@@ -142,6 +138,18 @@ export class UserListPage extends WithLicenseSummary(
142138
return users;
143139
}
144140

141+
protected buildExportParams = async (): Promise<CoreUsersExportCreateRequest> => {
142+
return {
143+
...(await this.defaultEndpointConfig()),
144+
pathStartswith: this.activePath,
145+
isActive: this.hideDeactivated ? true : undefined,
146+
};
147+
};
148+
149+
protected createExport = (params: CoreUsersExportCreateRequest) => {
150+
return this.#api.coreUsersExportCreate(params);
151+
};
152+
145153
protected override rowLabel(item: User): string {
146154
if (item.name) {
147155
return msg(str`${item.username} (${item.name})`);
@@ -159,6 +167,8 @@ export class UserListPage extends WithLicenseSummary(
159167
[msg("Actions"), null, msg("Row Actions")],
160168
];
161169

170+
//#region Renderering
171+
162172
protected override renderToolbarSelected(): TemplateResult {
163173
const disabled = this.selectedElements.length < 1;
164174
const { currentUser, originalUser } = this;
@@ -249,7 +259,7 @@ export class UserListPage extends WithLicenseSummary(
249259
</div>`;
250260
}
251261

252-
protected row(item: User) {
262+
protected override row(item: User): SlottedTemplateResult[] {
253263
const { currentUser } = this;
254264

255265
const showImpersonation = this.canImpersonate && currentUser && item.pk !== currentUser.pk;
@@ -294,7 +304,7 @@ export class UserListPage extends WithLicenseSummary(
294304
];
295305
}
296306

297-
renderExpanded(item: User): TemplateResult {
307+
protected override renderExpanded(item: User): SlottedTemplateResult {
298308
return html`<dl class="pf-c-description-list pf-m-horizontal">
299309
<div class="pf-c-description-list__group">
300310
<dt class="pf-c-description-list__term">
@@ -335,18 +345,6 @@ export class UserListPage extends WithLicenseSummary(
335345
</dl>`;
336346
}
337347

338-
protected buildExportParams = async () => {
339-
return {
340-
...(await this.defaultEndpointConfig()),
341-
pathStartswith: this.activePath,
342-
isActive: this.hideDeactivated ? true : undefined,
343-
};
344-
};
345-
346-
protected createExport = (params: CoreUsersExportCreateRequest) => {
347-
return this.#api.coreUsersExportCreate(params);
348-
};
349-
350348
protected renderObjectCreate(): SlottedTemplateResult {
351349
const { activePath } = this;
352350

@@ -370,7 +368,7 @@ export class UserListPage extends WithLicenseSummary(
370368
});
371369
}
372370

373-
protected renderSidebarBefore(): TemplateResult {
371+
protected renderSidebarBefore(): SlottedTemplateResult {
374372
return html`<aside aria-labelledby="sidebar-left-panel-header" class="pf-c-sidebar__panel">
375373
<div class="pf-c-card tree">
376374
<div
@@ -394,6 +392,8 @@ export class UserListPage extends WithLicenseSummary(
394392
</div>
395393
</aside>`;
396394
}
395+
396+
//#endregion
397397
}
398398

399399
declare global {

web/src/admin/users/ak-user-wizard.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import "#elements/wizard/FormWizardPage";
66
import "#elements/wizard/TypeCreateWizardPage";
77
import "#elements/wizard/Wizard";
88

9+
import { DefaultUIConfig } from "#common/ui/config";
10+
911
import { LitPropertyRecord, SlottedTemplateResult } from "#elements/types";
1012
import { CreateWizard } from "#elements/wizard/CreateWizard";
1113
import { TypeCreateWizardPageLayouts } from "#elements/wizard/TypeCreateWizardPage";
@@ -115,8 +117,8 @@ export class AKUserWizard extends CreateWizard {
115117
/**
116118
* Default path to assign to new users created via the wizard.
117119
*/
118-
@property({ type: String, attribute: "default-path" })
119-
public defaultPath: string = "users";
120+
@property({ type: String, attribute: "default-path", useDefault: true })
121+
public defaultPath: string = DefaultUIConfig.defaults.userPath;
120122

121123
protected apiEndpoint(): Promise<TypeCreate[]> {
122124
return Promise.resolve(DEFAULT_USER_TYPES);

0 commit comments

Comments
 (0)