1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 08:28:11 +00:00
Files
seahub/frontend/src/components/dialog/confirm-apply-folder-properties-dialog.js
Alex Happy 1976ebd0c6 Sync apply folder ex props (#5666)
* 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
2023-10-07 14:55:16 +08:00

68 lines
2.0 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import { Button, Modal, ModalBody, ModalFooter, ModalHeader } from 'reactstrap';
import { gettext } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api';
import toaster from '../toast';
import { Utils } from '../../utils/utils';
import Loading from '../loading';
import '../../css/apply-folder-properties.css';
const propTypes = {
toggle: PropTypes.func,
repoID: PropTypes.string,
path: PropTypes.string
};
class ConfirmApplyFolderPropertiesDialog extends React.Component {
constructor(props) {
super(props);
this.state = {
submitting: false
};
}
submit = () => {
const { repoID, path } = this.props;
this.setState({ submitting: true });
seafileAPI.applyFolderExtendedProperties(repoID, path).then(() => {
toaster.success('Applied folder properties');
this.props.toggle();
}).catch(error => {
let errorMsg = Utils.getErrorMsg(error);
toaster.danger(errorMsg);
this.setState({ submitting: false });
});
};
render() {
const { submitting } = this.state;
return (
<Modal isOpen={true} toggle={this.props.toggle} className="apply-properties-dialog">
<ModalHeader toggle={this.props.toggle}>
{gettext('Apply properties')}
</ModalHeader>
<ModalBody>
<p>
{gettext('Are you sure to apply properties to all files inside the folder?')}
</p>
</ModalBody>
<ModalFooter>
<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>
</ModalFooter>
</Modal>
);
}
}
ConfirmApplyFolderPropertiesDialog.propTypes = propTypes;
export default ConfirmApplyFolderPropertiesDialog;