Skip to content

Commit

Permalink
Sync apply folder ex props (#5666)
Browse files Browse the repository at this point in the history
* init sync apply folder ex-props

* clear worker-map

* opt apply and remove useless code

* use new sync-apply-folder-ex-props api

* opt try exception
  • Loading branch information
AlexCXC authored Oct 7, 2023
1 parent ce43942 commit 1976ebd
Show file tree
Hide file tree
Showing 6 changed files with 269 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,54 +20,16 @@ class ConfirmApplyFolderPropertiesDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
submitting: true
submitting: false
};
this.timer = null;
}

componentDidMount() {
const { repoID, path } = this.props;
seafileAPI.queryFolderItemsExtendedPropertiesStatus(repoID, path).then(res => {
if (res.data.is_finished) {
this.timer && clearInterval(this.timer);
this.setState({ submitting: false });
} else {
this.queryStatus();
}
}).catch(error => {
//
});
}

componentWillUnmount() {
this.timer && clearInterval(this.timer);
}

queryStatus = () =>{
const { repoID, path } = this.props;
this.timer = setInterval(() => {
seafileAPI.queryFolderItemsExtendedPropertiesStatus(repoID, path).then(res => {
if (res.data.is_finished === true) {
clearInterval(this.timer);
this.timer = null;
toaster.success(gettext('Applied folder properties'));
this.props.toggle();
}
}).catch(error => {
clearInterval(this.timer);
this.timer = null;
let errorMsg = Utils.getErrorMsg(error);
toaster.danger(errorMsg);
this.setState({ submitting: false });
});
}, 1000);
};

submit = () => {
const { repoID, path } = this.props;
this.setState({ submitting: true });
seafileAPI.setFolderItemsExtendedProperties(repoID, path).then(() => {
this.queryStatus();
seafileAPI.applyFolderExtendedProperties(repoID, path).then(() => {
toaster.success('Applied folder properties');
this.props.toggle();
}).catch(error => {
let errorMsg = Utils.getErrorMsg(error);
toaster.danger(errorMsg);
Expand All @@ -89,7 +51,7 @@ class ConfirmApplyFolderPropertiesDialog extends React.Component {
</p>
</ModalBody>
<ModalFooter>
<Button color='secondary' onClick={this.props.toggle}>{gettext('Cancel')}</Button>
<Button color='secondary' onClick={this.props.toggle} disabled={submitting}>{gettext('Cancel')}</Button>
<Button color='primary' className='flex-shrink-0 apply-properties' disabled={submitting} onClick={this.submit}>
{submitting ? (<Loading />) : (<>{gettext('Submit')}</>)}
</Button>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/lib-content-view/lib-content-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ class LibContentView extends React.Component {

this.addDirent(newFileName, 'file', res.data.size);
this.setState({isConvertLoading: false});
let message = gettext('Successfully converted file.')
let message = gettext('Successfully converted file.');
toaster.success(message);

}).catch((error) => {
Expand Down
Loading

0 comments on commit 1976ebd

Please sign in to comment.