-
Notifications
You must be signed in to change notification settings - Fork 157
feat: Issue #1 - Add ability to remove profile picture #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Issue #1 - Add ability to remove profile picture #22
Conversation
- Add 'Remove' button to account settings UI below profile picture - Button only appears when user has an uploaded profile picture - Clicking button removes picture and reverts to default avatar - Update update_profile() helper to handle profile field deletion - Style button with button-danger class for consistent UI Changes: * UITabAccount.js: Add remove button UI, click handler, and show/hide logic * helpers.js: Update update_profile() to delete fields when value is null The button is styled as a danger action (red background, white text) and disappears after removing the picture or when no picture exists.
- Add translations for all 38 supported languages
- Add UIAlert confirmation dialog when user attempts to remove profile picture - Implement flag to prevent multiple simultaneous removal operations - Add backdrop overlay to block interactions during confirmation - Change remove button style from 'primary' to 'danger' for better UX - Add 'confirm_remove_profile_picture' translation key to all 37 language files Changes: - src/gui/src/UI/Settings/UITabAccount.js: * Import UIAlert component * Add is_removing_profile_picture flag to prevent race conditions * Wrap removal logic in try-finally block for proper cleanup * Add confirmation dialog with backdrop and danger-styled button - src/gui/src/i18n/translations/*.js: * Add confirmation message in 37 languages * Message: 'Are you sure you want to remove your profile picture?'
| profile[key] = key_vals[key]; | ||
| // update window.user.profile | ||
| window.user.profile[key] = key_vals[key]; | ||
| if (key_vals[key] === null || key_vals[key] === undefined || key_vals[key] === '') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: null , undefined and '' are falsy values, which means we can substitute code above by
| if (key_vals[key] === null || key_vals[key] === undefined || key_vals[key] === '') { | |
| if (!!key_vals[key]) { |
| h += `<div class="profile-picture change-profile-picture" style="background-image: url('${html_encode(window.user?.profile?.picture ?? window.icons['profile.svg'])}');">`; | ||
| h += `</div>`; | ||
| h += `</div>`; | ||
| h += `<div style="text-align: center; margin-bottom: 20px;">`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Let's make sure we are being consistent with styles here. We should establish a boundary when to use inline-styles vs css.
inline-styles can be beneficial for referring to javascript code such as the profile picture online 39.
|
|
||
| $el_window.find('.remove-profile-picture').on('click', async function (e) { | ||
| // Prevent multiple simultaneous operations | ||
| if(is_removing_profile_picture) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
Ideally, instead of deduping this call, we should disable the remove profile picture button while the picture is being deleted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good to me. Great job Prayag. PR description is pretty descriptive. Thank you.
Description
This PR adds a "Remove" button to account settings, which allows users to delete their profile picture and revert to the default avatar.
Before
After
Implementation
Related Issue
Closes Issue #1 - Add ability to remove profile picture #5
Changes Made
Core Functionality
update_profile()helper function to support field deletionbutton-dangerclass) for consistencyInternationalization
remove_profile_picture/confirm_remove_profile_picturetranslation key to all 38 supported languagesImplementation Details
{picture: null}toupdate_profile()picturefield from/{username}/Public/.profileJSON fileTesting Performed
Files Modified
src/gui/src/helpers.js- Profile deletion logicsrc/gui/src/UI/Settings/UITabAccount.js- UI components and event handlerssrc/gui/src/i18n/translations/*.js- All 38 translation files