From eb19b0b9afe60b1b7274ce52e0e9dbe33ae0232f Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 10 Apr 2024 17:32:48 +0200 Subject: [PATCH] remove the hardcoded 'Edit' and 'Change password' buttons --- ...t-user-profile-user-profile-app.element.ts | 55 +------------------ 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/profile/current-user-profile-user-profile-app.element.ts b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/profile/current-user-profile-user-profile-app.element.ts index 5cc0d8e8f4..cc257c97df 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/user/current-user/profile/current-user-profile-user-profile-app.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/user/current-user/profile/current-user-profile-user-profile-app.element.ts @@ -1,65 +1,12 @@ -import { html, customElement, state, css } from '@umbraco-cms/backoffice/external/lit'; +import { html, customElement, css } from '@umbraco-cms/backoffice/external/lit'; import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; -import { UMB_CHANGE_PASSWORD_MODAL, UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal'; -import { UMB_CURRENT_USER_CONTEXT, type UmbCurrentUserModel } from '@umbraco-cms/backoffice/current-user'; import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; @customElement('umb-current-user-profile-user-profile-app') export class UmbCurrentUserProfileUserProfileAppElement extends UmbLitElement { - @state() - private _currentUser?: UmbCurrentUserModel; - - #currentUserContext?: typeof UMB_CURRENT_USER_CONTEXT.TYPE; - - constructor() { - super(); - - this.consumeContext(UMB_CURRENT_USER_CONTEXT, (instance) => { - this.#currentUserContext = instance; - this._observeCurrentUser(); - }); - } - - private async _observeCurrentUser() { - if (!this.#currentUserContext) return; - - this.observe( - this.#currentUserContext.currentUser, - (currentUser) => { - this._currentUser = currentUser; - }, - 'umbCurrentUserObserver', - ); - } - - private _edit() { - if (!this._currentUser) return; - - history.pushState(null, '', 'section/user-management/view/users/user/edit/' + this._currentUser.unique); //TODO Change to a tag with href and make dynamic - //TODO Implement modal routing for the current-user-modal, so that the modal closes when navigating to the edit profile page - } - async #changePassword() { - if (!this._currentUser) throw new Error('Current User not found'); - - const modalManager = await this.getContext(UMB_MODAL_MANAGER_CONTEXT); - modalManager.open(this, UMB_CHANGE_PASSWORD_MODAL, { - data: { - user: { - unique: this._currentUser.unique, - }, - }, - }); - } - render() { return html` - - ${this.localize.term('general_edit')} - - - ${this.localize.term('general_changePassword')} - `;