Skip to content
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

fix: Avatar disabling when it is set to Default #34160

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ type UserAvatarEditorProps = {
setAvatarObj: (obj: AvatarObject) => void;
disabled?: boolean;
etag: IUser['avatarETag'];
avatarValue?: AvatarObject;
};

function UserAvatarEditor({ currentUsername, username, setAvatarObj, disabled, etag }: UserAvatarEditorProps): ReactElement {
function UserAvatarEditor({ currentUsername, username, setAvatarObj, disabled, etag, avatarValue }: UserAvatarEditorProps): ReactElement {
const { t } = useTranslation();
const rotateImages = useSetting('FileUpload_RotateImages');
const [avatarFromUrl, setAvatarFromUrl] = useState('');
Expand Down Expand Up @@ -90,7 +91,13 @@ function UserAvatarEditor({ currentUsername, username, setAvatarObj, disabled, e
/>
<Box display='flex' flexDirection='column' flexGrow='1' justifyContent='space-between' mis={4}>
<Box display='flex' flexDirection='row' mbs='none'>
<Button square disabled={disabled} mi={4} title={t('Accounts_SetDefaultAvatar')} onClick={clickReset}>
<Button
square
disabled={avatarValue === 'reset' || disabled}
mi={4}
title={t('Accounts_SetDefaultAvatar')}
onClick={clickReset}
>
<Avatar url={`/avatar/%40${username}`} />
</Button>
<IconButton icon='upload' secondary disabled={disabled} title={t('Upload')} mi={4} onClick={clickUpload} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,14 @@ const AccountProfileForm = (props: AllHTMLAttributes<HTMLFormElement>): ReactEle
<Controller
control={control}
name='avatar'
render={({ field: { onChange } }) => (
render={({ field: { onChange, value } }) => (
<UserAvatarEditor
etag={user?.avatarETag}
currentUsername={user?.username}
username={username}
setAvatarObj={onChange}
disabled={!allowUserAvatarChange}
dougfabris marked this conversation as resolved.
Show resolved Hide resolved
avatarValue={value}
/>
)}
/>
Expand Down
Loading