Current User: Adds Current User workspace modal#22268
Conversation
…7/feature/current-user-workspace
…7/feature/current-user-workspace
…7/feature/current-user-workspace
…7/feature/current-user-workspace
AndyButland
left a comment
There was a problem hiding this comment.
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.
AndyButland
left a comment
There was a problem hiding this comment.
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.
Co-authored-by: Andy Butland <abutland73@gmail.com>
…erRequestModel.cs Co-authored-by: Andy Butland <abutland73@gmail.com>
…iceCrudTests.Update.cs Co-authored-by: Andy Butland <abutland73@gmail.com>
Co-authored-by: Andy Butland <abutland73@gmail.com>
…entication check from controllers
…7/feature/current-user-workspace
|
Thanks @AndyButland , I updated |
Align validation for user profile update with update user service method. Controller tidy-up of dependencies.
There was a problem hiding this comment.
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?
|
@AndyButland: I noticed that on the user page, changing the avatar is also applied immediately. |
|
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) |
…om/umbraco/Umbraco-CMS into v17/feature/current-user-workspace
nielslyngsoe
left a comment
There was a problem hiding this comment.
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.
as no longer used.
- 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
# 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
left a comment
There was a problem hiding this comment.
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.
The modal has now been implemented as a (non-routable) workspace.
Prerequisites
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:
umb-current-user-edit-profile-modal) otherwise, with two sections: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.
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
IUserService.UpdateProfileAsync(userKey, UserUpdateProfileModel)andIUserPresentationFactory.CreateUpdateProfileModelAsync(...), both with default interface implementations (to be removed in V19).UserServiceCrudTests.Updatecover the happy path, language-only update (other fields unchanged), and ISO-code validation.How to test