Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web/admin: auto-prefill user path for new users based on selected path #12070

Merged
merged 1 commit into from
Nov 19, 2024
Merged
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: 4 additions & 1 deletion web/src/admin/users/UserForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ export class UserForm extends ModelForm<User, number> {
@property({ attribute: false })
group?: Group;

@property()
defaultPath: string = "users";

static get defaultUserAttributes(): { [key: string]: unknown } {
return {};
}
Expand Down Expand Up @@ -172,7 +175,7 @@ export class UserForm extends ModelForm<User, number> {
<ak-form-element-horizontal label=${msg("Path")} ?required=${true} name="path">
<input
type="text"
value="${first(this.instance?.path, "users")}"
value="${first(this.instance?.path, this.defaultPath)}"
class="pf-c-form-control"
required
/>
Expand Down
5 changes: 4 additions & 1 deletion web/src/admin/users/UserListPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export class UserListPage extends WithBrandConfig(WithCapabilitiesConfig(TablePa
<ak-forms-modal>
<span slot="submit"> ${msg("Create")} </span>
<span slot="header"> ${msg("Create User")} </span>
<ak-user-form slot="form"> </ak-user-form>
<ak-user-form defaultPath=${this.activePath} slot="form"> </ak-user-form>
<button slot="trigger" class="pf-c-button pf-m-primary">${msg("Create")}</button>
</ak-forms-modal>
<ak-forms-modal .closeAfterSuccessfulSubmit=${false} .cancelText=${msg("Close")}>
Expand All @@ -417,6 +417,9 @@ export class UserListPage extends WithBrandConfig(WithCapabilitiesConfig(TablePa
<ak-treeview
.items=${this.userPaths?.paths || []}
activePath=${this.activePath}
@ak-refresh=${(ev: CustomEvent<{ path: string }>) => {
this.activePath = ev.detail.path;
}}
></ak-treeview>
</div>
</div>
Expand Down
3 changes: 3 additions & 0 deletions web/src/elements/TreeView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export class TreeViewNode extends AKElement {
new CustomEvent(EVENT_REFRESH, {
bubbles: true,
composed: true,
detail: {
path: this.fullPath,
},
}),
);
}}
Expand Down
Loading