Skip to content

Current User: Adds Current User workspace modal#22268

Merged
leekelleher merged 30 commits into
mainfrom
v17/feature/current-user-workspace
Apr 28, 2026
Merged

Current User: Adds Current User workspace modal#22268
leekelleher merged 30 commits into
mainfrom
v17/feature/current-user-workspace

Conversation

@NguyenThuyLan

@NguyenThuyLan NguyenThuyLan commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

Prerequisites

  • I have added steps to test this contribution in the description below

If there's an existing issue for this PR then this fixes

Description

Adds a lightweight Edit Profile experience for the currently signed-in backoffice user, so non-admin users (who don't have access to the Users section) can manage their own avatar and change their UI language from the user menu.

Opening the Edit action from the current-user menu now:

  • Navigates to the full user workspace when the user has access to the Users section.
  • Opens a sidebar modal (umb-current-user-edit-profile-modal) otherwise, with two sections:
    • Avatar – upload or remove the profile photo.
    • Profile settings – change the UI language.

Save failures (avatar upload/delete, language update) surface a danger notification and the modal stays open so the user can retry. On successful avatar upload the current user is refreshed from the server so the store holds the real resized avatar URLs.

image

Management API endpoints

  • PUT /umbraco/management/api/v1/user/current/profile – update the current user's language preference (new).
  • DELETE /umbraco/management/api/v1/user/current/avatar – clear the current user's avatar (new).
  • POST /umbraco/management/api/v1/user/current/avatar – set the current user's avatar; now usable by any authenticated user for their own avatar.

Backend

  • New IUserService.UpdateProfileAsync(userKey, UserUpdateProfileModel) and IUserPresentationFactory.CreateUpdateProfileModelAsync(...), both with default interface implementations (to be removed in V19).
  • Integration tests in UserServiceCrudTests.Update cover the happy path, language-only update (other fields unchanged), and ISO-code validation.

How to test

  1. Log in as a non-admin backoffice user.
  2. Click the user avatar/name in the top bar.
  3. Click Edit – the Edit Profile modal should open with Avatar and Profile settings sections.
  4. Change the UI language and save – verify the change is persisted.
  5. Upload and remove an avatar – verify both actions work and that a notification is shown on success and failure.
  6. Log in as an admin user – the Edit button should open the full user editor instead of the modal.

@AndyButland AndyButland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this @NguyenThuyLan - it's looking good. I haven't had time to review closely or test yet, but I found a few things to consider with the back-end code. Could you look at those please, and then I'll take it for a spin tomorrow and provide feedback from testing.

Comment thread src/Umbraco.Core/Services/UserService.cs Outdated
Comment thread src/Umbraco.Cms.Api.Management/ViewModels/User/UpdateCurrentUserRequestModel.cs Outdated
Comment thread src/Umbraco.Core/Models/CurrentUserUpdateModel.cs Outdated
Comment thread src/Umbraco.Core/Services/IUserService.cs Outdated

@AndyButland AndyButland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few additional points and findings from testing.

We should have an update to the OpenApi.json file as part of the PR. You can get this following the link in the Swagger document and saving it to the solution, replacing the exiting file.

The avatar function doesn't seem to be working quite correctly:

  • After upload, the visual display in the circle doesn't update (instead I see the initial slide up out of view, but no display of the uploaded image). I have to save and re-render the dialog to see it.

  • There seems to be an update immediately after uploading the photo. Maybe we can't avoid that easily, but ideally it would only update when I hit the "Save" button. In other words, the "Change photo" and "Remove photo" should hold the changes within the dialog only, and only persist when the dialog is closed, otherwise the previous information should be retained.

@NguyenThuyLan

Copy link
Copy Markdown
Contributor Author

Thanks @AndyButland , I updated OpenApi.json, fixed the issue when uploading avatar, and made sure we update avatar only after clicking the Save button

Align validation for user profile update with update user service method.
Controller tidy-up of dependencies.

@AndyButland AndyButland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works very nicely @NguyenThuyLan - I've tested it out locally and can update my avatar and language, with both or neither updates being made as expected now, depending on whether I save or close the dialog.

I just pushed a small update to:

  • Align the validation of the language with what we do for a full user update.
  • Completely remove the concept of the "current" user from the user service (by renaming methods and models).

From a BE and testing side, this is all ✅. The FE all looks good to me too - but maybe @nielslyngsoe you'd like a look over before this is merged.

Maybe @nhudinh0309 you too could have a look at this and see what you think about adding acceptance tests for the functionality?

@nhudinh0309

Copy link
Copy Markdown
Contributor

@AndyButland: I noticed that on the user page, changing the avatar is also applied immediately.
Do you think we should create a separate task to make this behavior consistent across both places? It might be a bit confusing if one flow requires saving while the other doesn't.

@AndyButland

Copy link
Copy Markdown
Contributor

It's a good point - though I suspect we'll run into the same issue @NguyenThuyLan found when working on her other task around managing users from the user group, that there's currently no way to hook into the workspace save. So I don't think it's feasible at the moment.

Given it's a quite different user role for someone managing users and a general editor updating their avatar, I don't think the different behaviour will be too confusing. And likely within project, these will likely be managed either by the individuals, or by the user management, and not both.

But @nielslyngsoe - maybe you can consider this case along with the general case you've mentioned here: #22215 (comment)

@nielslyngsoe nielslyngsoe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the comment. This should be implemented like a Workspace, in the same way as other Workspaces.

Refactored the "Edit" (profile) button logic,
to handle the check whether the user has access to the Users section.
- Show danger notification when avatar upload/delete or profile update fails
- Refresh current user after avatar upload so the store holds server URLs, not a leaking local blob
- Element save() methods now return boolean; modal keeps itself open when a save fails and no longer double-submits
@leekelleher leekelleher changed the title Current user: Add current user workspace modal Current User: Adds Edit Profile modal Apr 22, 2026
# Conflicts:
#	src/Umbraco.Web.UI.Client/src/assets/lang/en.ts
#	src/Umbraco.Web.UI.Client/src/packages/core/backend-api/sdk.gen.ts

@leekelleher leekelleher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested out, works as described.

Replaces Umb.Modal.CurrentUserEditProfile with a workspace registered
against entityType 'current-user'. The UmbSubmittableWorkspaceContextBase
subclass owns the editable user model and pending avatar state; submit()
coordinates uploadAvatar / deleteAvatar / updateProfile and throws on
failure so the workspace stays open, relying on the repository's existing
danger notifications.

The current-user "Edit" action now opens UMB_WORKSPACE_MODAL (sidebar,
small) instead of the bespoke modal. Avatar and settings children become
presentational views wired to the workspace context.
- Await initial load promise in submit() to prevent a race where the save
  action fires before the first requestCurrentUser() resolves.
- Guard the avatar element's async observer setup against post-disconnect
  attachment.
- Document the split between #data (editable persisted state) and
  #pendingAvatar (transient UI state) in the workspace context.
- Remove stray JSDoc whitespace in current-user.server.data-source.ts.
@leekelleher leekelleher changed the title Current User: Adds Edit Profile modal Current User: Adds Current User workspace modal Apr 28, 2026
@leekelleher leekelleher dismissed nielslyngsoe’s stale review April 28, 2026 10:17

The modal has now been implemented as a (non-routable) workspace.

@leekelleher leekelleher merged commit 6bd3ede into main Apr 28, 2026
30 of 31 checks passed
@leekelleher leekelleher deleted the v17/feature/current-user-workspace branch April 28, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants