1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-03 07:55:36 +00:00

optimize save button's status

This commit is contained in:
LeoSirius
2019-04-19 11:57:07 +08:00
parent cdc9d4865e
commit fad00989f1
3 changed files with 39 additions and 14 deletions

View File

@@ -43,7 +43,9 @@ class ViewFileText extends React.Component {
constructor(props) {
super(props);
this.state = {
content: fileContent
content: fileContent,
isContentChangedButNotSaved: false,
isSaving: false,
};
this.onSaveChangedContent=this.onSaveChangedContent.bind(this);
}
@@ -51,7 +53,8 @@ class ViewFileText extends React.Component {
updateContent = (newContent) => {
this.setState({
content: newContent
isContentChangedButNotSaved: true,
content: newContent,
});
}
@@ -60,6 +63,9 @@ class ViewFileText extends React.Component {
return (
seafileAPI.getUpdateLink(repoID, dirPath).then((res) => {
const uploadLink = res.data;
this.setState({
isSaving: true
});
return seafileAPI.updateFile(
uploadLink,
filePath,
@@ -69,6 +75,10 @@ class ViewFileText extends React.Component {
toaster.success(gettext('Successfully saved'), {
duration: 3
});
this.setState({
isSaving: false,
isContentChangedButNotSaved: false
});
})
})
);
@@ -83,6 +93,8 @@ class ViewFileText extends React.Component {
updateContent={this.updateContent}
/>
}
isSaving={this.state.isSaving}
isContentChangedButNotSaved={this.state.isContentChangedButNotSaved}
onSaveChangedContent={this.onSaveChangedContent}
/>
);