Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions web/src/admin/users/UserForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -58,8 +59,8 @@ export class UserForm extends ModelForm<User, number> {
@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;
Expand Down
66 changes: 33 additions & 33 deletions web/src/admin/users/UserListPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,43 +91,39 @@ 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<boolean>("hideDeactivated", false);

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

constructor() {
super();

const defaultPath = DefaultUIConfig.defaults.userPath;

this.activePath = getURLParam<string>("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<string>(
"path",
brandDefaultUserPath || initialDefaultUserPath,
);
}

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

protected buildExportParams = async (): Promise<CoreUsersExportCreateRequest> => {
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})`);
Expand All @@ -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;
Expand Down Expand Up @@ -249,7 +259,7 @@ export class UserListPage extends WithLicenseSummary(
</div>`;
}

protected row(item: User) {
protected override row(item: User): SlottedTemplateResult[] {
const { currentUser } = this;

const showImpersonation = this.canImpersonate && currentUser && item.pk !== currentUser.pk;
Expand Down Expand Up @@ -294,7 +304,7 @@ export class UserListPage extends WithLicenseSummary(
];
}

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

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;

Expand All @@ -370,7 +368,7 @@ export class UserListPage extends WithLicenseSummary(
});
}

protected renderSidebarBefore(): TemplateResult {
protected renderSidebarBefore(): SlottedTemplateResult {
return html`<aside aria-labelledby="sidebar-left-panel-header" class="pf-c-sidebar__panel">
<div class="pf-c-card tree">
<div
Expand All @@ -394,6 +392,8 @@ export class UserListPage extends WithLicenseSummary(
</div>
</aside>`;
}

//#endregion
}

declare global {
Expand Down
6 changes: 4 additions & 2 deletions web/src/admin/users/ak-user-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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<TypeCreate[]> {
return Promise.resolve(DEFAULT_USER_TYPES);
Expand Down
Loading