feat(spx-gui): add username editing to user profile#2903
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
f2e5536 to
bb7ac3f
Compare
| if (trimmed.length > 100) | ||
| return t({ | ||
| en: 'The username is too long (maximum is 100 characters)', | ||
| zh: '用户名长度超出限制(最多 100 个字符)' |
There was a problem hiding this comment.
我们其实还没限制过 username 的长度,因为后端认为直接从 idp 那边拿的 username 都是可信的,所以就没加任何校验逻辑
感觉还是要限制一下,我先按照跟 project name 相同的长度来了,不过对 username 来说可能不太合理,我在纠结多少合适
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Summary of ChangesThis pull request introduces the capability for users to modify their usernames, enhancing user account management. It establishes a robust and user-friendly workflow for this sensitive operation, ensuring data integrity through comprehensive validation and consistent application state. The changes streamline the user experience by providing clear warnings about the impacts of a username change and dynamically updating relevant parts of the application, such as routing and cached user data. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
|
|
Clean two-step flow with good separation of concerns. The
|
There was a problem hiding this comment.
Pull request overview
Adds a two-step username modification flow to the profile editing experience in spx-gui, including a shared warning modal and associated state/cache updates.
Changes:
- Introduces a reusable
ModificationWarningModaland wires it into project rename + username modification flows. - Adds username modification UI (warning step + input/validation modal) and integrates it into
EditProfileModal. - Extends user store/API/OpenAPI to support updating and caching
username, plus query invalidation for old/new usernames.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spx-gui/src/stores/user/signed-in.ts | Cache username in user state; add helper to modify username and invalidate old/new user query keys. |
| spx-gui/src/components/project/index.ts | Switch project rename warning to shared ModificationWarningModal with configurable content. |
| spx-gui/src/components/community/user/index.ts | Add useModifyUsername hook to run warning step then open username modification modal. |
| spx-gui/src/components/community/user/UserHeader.vue | After edit flow completes, replace current route when username changes (preserving suffix/query/hash). |
| spx-gui/src/components/community/user/ModifyUsernameModal.vue | New modal to validate and submit username changes (format/length/dup-check). |
| spx-gui/src/components/community/user/EditProfileUsernameField.vue | Extract username field into a dedicated component that triggers the modify flow. |
| spx-gui/src/components/community/user/EditProfileModal.vue | Embed the extracted username field into profile editing modal. |
| spx-gui/src/components/common/ModificationWarningModal.vue | Generalize warning modal props for reuse across different modification flows. |
| spx-gui/src/apis/user.ts | Extend UpdateSignedInUserParams to allow username updates. |
| docs/openapi.yaml | Add username to PATCH /user request body schema. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
There was a problem hiding this comment.
Code Review
This pull request introduces a feature to modify usernames within the profile editing section. The implementation includes a two-step modification flow with a warning modal, validation for the new username, and updates to the API and frontend state management.
The refactoring of the warning modal into a reusable component is a good improvement. The logic for updating the URL after a username change and for managing cache invalidation is also well-handled.
I've identified a potential data loss issue in the profile edit modal and a point for improving user experience and code simplification in the username modification modal. My comments provide specific suggestions to address these points.
| if (trimmed.length > 100) | ||
| return t({ | ||
| en: 'The username is too long (maximum is 100 characters)', | ||
| zh: '用户名长度超出限制(最多 100 个字符)' |
| v-radar="{ name: 'Display name input', desc: 'Input field for user display name' }" | ||
| /> | ||
| </UIFormItem> | ||
| <EditProfileUsernameField :username="props.user.username" @modified="handleUsernameModified" /> |
There was a problem hiding this comment.
这个 field 有点别扭,它很像是这个 UIForm 的一部分,但是它的修改 & 提交又不跟着这个 form 一起
感觉把这个 field 在视觉上跟其他属于 form 的内容更明确地区分开会好点
There was a problem hiding this comment.
24afeec to
055c9cf
Compare
Add a two-step username modification flow to profile editing and update profile surfaces to show the username inline with copy actions. - Add `username` to `PATCH /user`, frontend update params, and signed-in user state - Add `useModifySignedInUsername` to invalidate old and new user caches and preserve the current route after rename - Add `ModifyUsernameModal` with validation and a shared warning modal - Rework `EditProfileModal` and `UserHeader` around a shared `UserUsernameInline` display with copy and modify actions - Add `copyAltFilled` to `UIIcon` and remove the joined-at icon to match the updated design Signed-off-by: Aofei Sheng <[email protected]>
Add a two-step username modification flow to profile editing and update profile surfaces to show the username inline with copy actions.
usernametoPATCH /user, frontend update params, and signed-in user stateuseModifySignedInUsernameto invalidate old and new user caches and preserve the current route after renameModifyUsernameModalwith validation and a shared warning modalEditProfileModalandUserHeaderaround a sharedUserUsernameInlinedisplay with copy and modify actionscopyAltFilledtoUIIconand remove the joined-at icon to match the updated design