1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 19:08:21 +00:00

Wiki page trash (#6423)

* add wiki page trash

* update css

* update ui

* redesign

* update ui

* optimize code

* Update views.py

* Update models.py

* update notes

* Update mysql.sql

* change wiki trash UI

* redesign2

* update

* update

---------

Co-authored-by: 孙永强 <11704063+s-yongqiang@user.noreply.gitee.com>
Co-authored-by: r350178982 <32759763+r350178982@users.noreply.github.com>
Co-authored-by: Michael An <2331806369@qq.com>
This commit is contained in:
awu0403
2024-08-16 10:17:54 +08:00
committed by GitHub
parent 2b1c9cc8df
commit 6d0680f4b4
16 changed files with 800 additions and 73 deletions

View File

@@ -0,0 +1,86 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import CreatableSelect from 'react-select/creatable';
import { gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import toaster from '../toast';
import wikiAPI from '../../utils/wiki-api';
const propTypes = {
wikiId: PropTypes.string.isRequired,
refreshTrash: PropTypes.func.isRequired,
toggleDialog: PropTypes.func.isRequired
};
class WikiCleanTrash extends React.Component {
constructor(props) {
super(props);
this.options = [
{ label: gettext('3 days ago'), value: 3 },
{ label: gettext('1 week ago'), value: 7 },
{ label: gettext('1 month ago'), value: 30 },
{ label: gettext('all'), value: 0 }
];
this.state = {
inputValue: this.options[0],
submitBtnDisabled: false
};
}
handleInputChange = (value) => {
this.setState({
inputValue: value
});
};
formSubmit = () => {
const inputValue = this.state.inputValue;
const { wikiId } = this.props;
this.setState({
submitBtnDisabled: true
});
wikiAPI.cleanWikiTrash(wikiId, inputValue.value).then((res) => {
toaster.success(gettext('Clean succeeded.'));
this.props.refreshTrash();
this.props.toggleDialog();
}).catch((error) => {
let errorMsg = Utils.getErrorMsg(error);
this.setState({
formErrorMsg: errorMsg,
submitBtnDisabled: false
});
});
};
render() {
const { formErrorMsg } = this.state;
return (
<Modal isOpen={true} centered={true} toggle={this.props.toggleDialog}>
<ModalHeader toggle={this.props.toggleDialog}>{gettext('Clean')}</ModalHeader>
<ModalBody>
<React.Fragment>
<p>{gettext('Clear files in trash and history')}</p>
<CreatableSelect
defaultValue={this.options[0]}
options={this.options}
autoFocus={false}
onChange={this.handleInputChange}
placeholder=''
/>
{formErrorMsg && <p className="error m-0 mt-2">{formErrorMsg}</p>}
</React.Fragment>
</ModalBody>
<ModalFooter>
<button className="btn btn-primary" disabled={this.state.submitBtnDisabled} onClick={this.formSubmit}>{gettext('Submit')}</button>
</ModalFooter>
</Modal>
);
}
}
WikiCleanTrash.propTypes = propTypes;
export default WikiCleanTrash;