web/admin: auto-prefill user path for new users based on selected path (#12070)
web/admin: auto-select user path based on selected path Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
@ -20,6 +20,9 @@ export class UserForm extends ModelForm<User, number> {
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
group?: Group;
|
group?: Group;
|
||||||
|
|
||||||
|
@property()
|
||||||
|
defaultPath: string = "users";
|
||||||
|
|
||||||
static get defaultUserAttributes(): { [key: string]: unknown } {
|
static get defaultUserAttributes(): { [key: string]: unknown } {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@ -172,7 +175,7 @@ export class UserForm extends ModelForm<User, number> {
|
|||||||
<ak-form-element-horizontal label=${msg("Path")} ?required=${true} name="path">
|
<ak-form-element-horizontal label=${msg("Path")} ?required=${true} name="path">
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value="${first(this.instance?.path, "users")}"
|
value="${first(this.instance?.path, this.defaultPath)}"
|
||||||
class="pf-c-form-control"
|
class="pf-c-form-control"
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
@ -395,7 +395,7 @@ export class UserListPage extends WithBrandConfig(WithCapabilitiesConfig(TablePa
|
|||||||
<ak-forms-modal>
|
<ak-forms-modal>
|
||||||
<span slot="submit"> ${msg("Create")} </span>
|
<span slot="submit"> ${msg("Create")} </span>
|
||||||
<span slot="header"> ${msg("Create User")} </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>
|
<button slot="trigger" class="pf-c-button pf-m-primary">${msg("Create")}</button>
|
||||||
</ak-forms-modal>
|
</ak-forms-modal>
|
||||||
<ak-forms-modal .closeAfterSuccessfulSubmit=${false} .cancelText=${msg("Close")}>
|
<ak-forms-modal .closeAfterSuccessfulSubmit=${false} .cancelText=${msg("Close")}>
|
||||||
@ -417,6 +417,9 @@ export class UserListPage extends WithBrandConfig(WithCapabilitiesConfig(TablePa
|
|||||||
<ak-treeview
|
<ak-treeview
|
||||||
.items=${this.userPaths?.paths || []}
|
.items=${this.userPaths?.paths || []}
|
||||||
activePath=${this.activePath}
|
activePath=${this.activePath}
|
||||||
|
@ak-refresh=${(ev: CustomEvent<{ path: string }>) => {
|
||||||
|
this.activePath = ev.detail.path;
|
||||||
|
}}
|
||||||
></ak-treeview>
|
></ak-treeview>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -89,6 +89,9 @@ export class TreeViewNode extends AKElement {
|
|||||||
new CustomEvent(EVENT_REFRESH, {
|
new CustomEvent(EVENT_REFRESH, {
|
||||||
bubbles: true,
|
bubbles: true,
|
||||||
composed: true,
|
composed: true,
|
||||||
|
detail: {
|
||||||
|
path: this.fullPath,
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
Reference in New Issue
Block a user