import React from 'react'; import PropTypes from 'prop-types'; import { Modal, ModalHeader, ModalBody } from 'reactstrap'; import { seafileAPI } from '../../utils/seafile-api'; import { gettext } from '../../utils/constants'; import { Utils } from '../../utils/utils'; import toaster from '../toast'; const propTypes = { repoID: PropTypes.string.isRequired, commitID: PropTypes.string.isRequired, toggleCancel: PropTypes.func.isRequired, }; class FileUpdateDetailDialog extends React.Component { constructor(props) { super(props); this.state = { time: '', renamed: [], deldir: [], modified: [], newdir: [], newfile: [], removed: [], }; } componentDidMount() { seafileAPI.orgAdminGetFileUpdateDetail(this.props.repoID, this.props.commitID).then(res => { this.setState({ time: res.data.date_time, renamed: this.state.renamed.concat(res.data.renamed), deldir: this.state.deldir.concat(res.data.deldir), modified: this.state.modified.concat(res.data.modified), newdir: this.state.newdir.concat(res.data.newdir), newfile: this.state.newfile.concat(res.data.new), removed: this.state.removed.concat(res.data.removed), }); }).catch(error => { let errMessage = Utils.getErrorMsg(error); toaster.danger(errMessage); }); } renderContentItem = (items) => { let con = ''; con += ''; return {__html: con}; } renderContent = () => { if (this.state.newfile.length > 0) { return (

{gettext('New files')}

{this.state.time}

); } if (this.state.removed.length > 0) { return (

{gettext('Deleted files')}

{this.state.time}

); } if (this.state.renamed.length > 0) { return (

{gettext('Renamed or Moved files')}

{this.state.time}

); } if (this.state.modified.length > 0) { return (

{gettext('Modified files')}

{this.state.time}

); } if (this.state.newdir.length > 0) { return (

{gettext('New directories')}

{this.state.time}

); } if (this.state.deldir.length > 0) { return (

{gettext('Deleted directories')}

{this.state.time}

); } } render() { return ( {gettext('Modification Details')} {this.renderContent()} ); } } FileUpdateDetailDialog.propTypes = propTypes; export default FileUpdateDetailDialog;