mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-06 01:12:03 +00:00
Illegal report by react (#3415)
* illegal report 1, add illegal report at shared file page 2, list all illegal reports at admin page * add ENABLE_SHARE_LINK_REPORT_ILLEGAL setting * UserRateThrottle -> AnonRateThrottle * use to_python_boolean * frontend by React * remove illegal report dialog in shared dir view * add migrations dir * add illegal_reports migrations * rename illegal to abuse in api * rename illegal to abuse in test * rename illegal to abuse in share file view * rename illegal to abuse in react * rename illegal to abuse in Backbone * add enableShareLinkReportAbuse in templates * add ReportAbuse * update ReportAbuse * update ReportAbuse urls * update ReportAbuse api-js * sysadmin_react_app.html * sysadmin.py * fix * fix * fix * can not abuse own file * Contact Information is required. * fix review * remove repo icon
This commit is contained in:
102
frontend/src/components/dialog/add-abuse-report-dialog.js
Normal file
102
frontend/src/components/dialog/add-abuse-report-dialog.js
Normal file
@@ -0,0 +1,102 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Form, FormGroup, Label, Input, Modal, ModalHeader, ModalBody, ModalFooter, Alert } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import toaster from '../toast';
|
||||
|
||||
const propTypes = {
|
||||
sharedToken: PropTypes.string.isRequired,
|
||||
filePath: PropTypes.string.isRequired,
|
||||
toggleAddAbuseReportDialog: PropTypes.func.isRequired,
|
||||
isAddAbuseReportDialogOpen: PropTypes.bool.isRequired,
|
||||
contactEmail: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
class AddAbuseReportDialog extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
abuseType: 'copyright',
|
||||
description: '',
|
||||
reporter: this.props.contactEmail,
|
||||
errMessage: '',
|
||||
};
|
||||
}
|
||||
|
||||
onAbuseReport = () => {
|
||||
if (!this.state.reporter) {
|
||||
this.setState({
|
||||
errMessage: gettext('Contact information is required.')
|
||||
});
|
||||
return;
|
||||
}
|
||||
seafileAPI.addAbuseReport(this.props.sharedToken, this.state.abuseType, this.state.description, this.state.reporter, this.props.filePath).then((res) => {
|
||||
this.props.toggleAddAbuseReportDialog();
|
||||
toaster.success(gettext('Success'), {duration: 2});
|
||||
}).catch((error) => {
|
||||
if (error.response) {
|
||||
this.setState({
|
||||
errMessage: error.response.data.error_msg
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
onAbuseTypeChange = (event) => {
|
||||
let type = event.target.value;
|
||||
if (type === this.state.abuseType) {
|
||||
return;
|
||||
}
|
||||
this.setState({abuseType: type});
|
||||
};
|
||||
|
||||
setReporter = (event) => {
|
||||
let reporter = event.target.value.trim();
|
||||
this.setState({reporter: reporter});
|
||||
};
|
||||
|
||||
setDescription = (event) => {
|
||||
let desc = event.target.value.trim();
|
||||
this.setState({description: desc});
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Modal isOpen={this.props.isAddAbuseReportDialogOpen} toggle={this.props.toggleAddAbuseReportDialog}>
|
||||
<ModalHeader toggle={this.props.toggleAddAbuseReportDialog}>{gettext('Report Abuse')}</ModalHeader>
|
||||
<ModalBody>
|
||||
<Form>
|
||||
<FormGroup>
|
||||
<Label for="abuse-type-select">{gettext('Abuse Type')}</Label>
|
||||
<Input type="select" id="abuse-type-select" onChange={(event) => this.onAbuseTypeChange(event)}>
|
||||
<option value='copyright'>{gettext('Copyright Infringement')}</option>
|
||||
<option value='virus'>{gettext('Virus')}</option>
|
||||
<option value='abuse_content'>{gettext('Abuse Content')}</option>
|
||||
<option value='other'>{gettext('Other')}</option>
|
||||
</Input>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Label>{gettext("Contact Information")}</Label>
|
||||
<Input type="text" value={this.state.reporter} onChange={(event) => this.setReporter(event)}/>
|
||||
</FormGroup>
|
||||
<FormGroup>
|
||||
<Label>{gettext("Description")}</Label>
|
||||
<Input type="textarea" onChange={(event) => this.setDescription(event)}/>
|
||||
</FormGroup>
|
||||
</Form>
|
||||
{this.state.errMessage && <Alert color="danger">{this.state.errMessage}</Alert>}
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="secondary" onClick={this.props.toggleAddAbuseReportDialog}>{gettext('Cancel')}</Button>
|
||||
<Button color="primary" onClick={this.onAbuseReport}>{gettext('Submit')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
AddAbuseReportDialog.propTypes = propTypes;
|
||||
|
||||
export default AddAbuseReportDialog;
|
Reference in New Issue
Block a user