Skip to content

Commit

Permalink
Merge pull request #453 from ONLYOFFICE/bugfix/fix-bug-53415
Browse files Browse the repository at this point in the history
Fixed Bug 53415: Fixed save avatar click
  • Loading branch information
AlexeySafronov authored Nov 10, 2021
2 parents 09520f6 + cab7603 commit 776dd08
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 24 deletions.
22 changes: 1 addition & 21 deletions packages/asc-web-components/avatar-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,14 @@ class AvatarEditor extends React.Component {
};

onSaveButtonClick = () => {
this.props.onSave && this.props.onSave();
this.avatarEditorBodyRef.current.onSaveImage();
//this.saveAvatar();
};

onCancelButtonClick = () => {
this.props.onCancel();
};

saveAvatar = () => {
if (!this.state.existImage) {
this.props.onSave(this.state.existImage);
return;
}

this.props.onSave(
this.state.existImage,
{
x: this.state.x,
y: this.state.y,
width: this.state.width,
height: this.state.height,
},
this.state.croppedImage
);
};

onClose = () => {
this.setState({ visible: false });
this.props.onClose();
Expand Down Expand Up @@ -156,7 +138,6 @@ class AvatarEditor extends React.Component {
onLoadFileError={this.onLoadFileError}
onLoadFile={this.onLoadFile}
deleteImage={this.onDeleteImage}
saveAvatar={this.saveAvatar}
maxSize={maxSize * 1000000} // megabytes to bytes
accept={accept}
image={image}
Expand Down Expand Up @@ -189,7 +170,6 @@ class AvatarEditor extends React.Component {
onLoadFileError={this.onLoadFileError}
onLoadFile={this.onLoadFile}
deleteImage={this.onDeleteImage}
saveAvatar={this.saveAvatar}
maxSize={maxSize * 1000000} // megabytes to bytes
accept={accept}
image={image}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,8 @@ class CreateUserForm extends React.Component {
onValidateEmailField = (value) =>
this.setState({ errors: { ...this.state.errors, email: !value.isValid } });

onSaveClick = () => this.setState({ isLoading: true });

render() {
const { isLoading, errors, profile, selector, isMobile } = this.state;
const {
Expand Down Expand Up @@ -480,7 +482,7 @@ class CreateUserForm extends React.Component {
image={createdAvatar.image}
visible={this.state.visibleAvatarEditor}
onClose={this.onCloseAvatarEditor}
onSave={this.onSaveAvatar}
onSave={this.onSaveClick}
onLoadFile={this.onLoadFileAvatar}
headerLabel={t("AddPhoto")}
selectNewPhotoLabel={t("Translations:selectNewPhotoLabel")}
Expand All @@ -489,6 +491,7 @@ class CreateUserForm extends React.Component {
maxSizeFileError={t("Translations:maxSizeFileError")}
unknownError={t("Common:Error")}
saveButtonLabel={t("Common:SaveButton")}
saveButtonLoading={this.state.isLoading}
/>
</AvatarContainer>
<MainFieldsContainer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class UpdateUserForm extends React.Component {

this.openAvatarEditor = this.openAvatarEditor.bind(this);
this.openAvatarEditorPage = this.openAvatarEditorPage.bind(this);
this.onSaveAvatar = this.onSaveAvatar.bind(this);
this.onCloseAvatarEditor = this.onCloseAvatarEditor.bind(this);
this.onLoadFileAvatar = this.onLoadFileAvatar.bind(this);

Expand Down Expand Up @@ -602,6 +601,8 @@ class UpdateUserForm extends React.Component {
this.setIsEdit();
}

onSaveClick = () => this.setState({ isLoading: true });

render() {
const {
isLoading,
Expand Down Expand Up @@ -735,7 +736,7 @@ class UpdateUserForm extends React.Component {
image={this.state.avatar.image}
visible={this.state.visibleAvatarEditor}
onClose={this.onCloseAvatarEditor}
onSave={this.onSaveAvatar}
onSave={this.onSaveClick}
onLoadFile={this.onLoadFileAvatar}
headerLabel={t("EditPhoto")}
selectNewPhotoLabel={t("Translations:selectNewPhotoLabel")}
Expand Down

0 comments on commit 776dd08

Please sign in to comment.