mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-15 23:00:57 +00:00
[tags] removed unused code and file
This commit is contained in:
@@ -6,12 +6,10 @@ import ModalPortal from '../modal-portal';
|
|||||||
import { Modal } from 'reactstrap';
|
import { Modal } from 'reactstrap';
|
||||||
import ListTagDialog from '../dialog/list-tag-dialog';
|
import ListTagDialog from '../dialog/list-tag-dialog';
|
||||||
import CreateTagDialog from '../dialog/create-tag-dialog';
|
import CreateTagDialog from '../dialog/create-tag-dialog';
|
||||||
import UpdateTagDialog from '../dialog/update-tag-dialog';
|
|
||||||
import ListTaggedFilesDialog from '../dialog/list-taggedfiles-dialog';
|
import ListTaggedFilesDialog from '../dialog/list-taggedfiles-dialog';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
repoID: PropTypes.string.isRequired,
|
repoID: PropTypes.string.isRequired,
|
||||||
repoName: PropTypes.string.isRequired,
|
|
||||||
userPerm: PropTypes.string,
|
userPerm: PropTypes.string,
|
||||||
currentPath: PropTypes.string.isRequired,
|
currentPath: PropTypes.string.isRequired,
|
||||||
updateUsedRepoTags: PropTypes.func.isRequired,
|
updateUsedRepoTags: PropTypes.func.isRequired,
|
||||||
@@ -26,7 +24,6 @@ class DirTool extends React.Component {
|
|||||||
isRepoTagDialogShow: false,
|
isRepoTagDialogShow: false,
|
||||||
currentTag: null,
|
currentTag: null,
|
||||||
isListRepoTagShow: false,
|
isListRepoTagShow: false,
|
||||||
isUpdateRepoTagShow: false,
|
|
||||||
isCreateRepoTagShow: false,
|
isCreateRepoTagShow: false,
|
||||||
isListTaggedFileShow: false,
|
isListTaggedFileShow: false,
|
||||||
};
|
};
|
||||||
@@ -37,7 +34,6 @@ class DirTool extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
isRepoTagDialogShow: true,
|
isRepoTagDialogShow: true,
|
||||||
isListRepoTagShow: true,
|
isListRepoTagShow: true,
|
||||||
isUpdateRepoTagShow: false,
|
|
||||||
isCreateRepoTagShow: false,
|
isCreateRepoTagShow: false,
|
||||||
isListTaggedFileShow: false
|
isListTaggedFileShow: false
|
||||||
});
|
});
|
||||||
@@ -47,7 +43,6 @@ class DirTool extends React.Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
isRepoTagDialogShow: false,
|
isRepoTagDialogShow: false,
|
||||||
isListRepoTagShow: false,
|
isListRepoTagShow: false,
|
||||||
isUpdateRepoTagShow: false,
|
|
||||||
isCreateRepoTagShow: false,
|
isCreateRepoTagShow: false,
|
||||||
isListTaggedFileShow: false
|
isListTaggedFileShow: false
|
||||||
});
|
});
|
||||||
@@ -60,14 +55,6 @@ class DirTool extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
onUpdateRepoTagToggle = (currentTag) => {
|
|
||||||
this.setState({
|
|
||||||
currentTag: currentTag,
|
|
||||||
isListRepoTagShow: !this.state.isListRepoTagShow,
|
|
||||||
isUpdateRepoTagShow: !this.state.isUpdateRepoTagShow,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onListTaggedFileToggle = (currentTag) => {
|
onListTaggedFileToggle = (currentTag) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
currentTag: currentTag,
|
currentTag: currentTag,
|
||||||
@@ -82,7 +69,7 @@ class DirTool extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let { repoID, repoName, userPerm, currentPath } = this.props;
|
let { repoID, userPerm, currentPath } = this.props;
|
||||||
let isFile = this.isMarkdownFile(currentPath);
|
let isFile = this.isMarkdownFile(currentPath);
|
||||||
let name = Utils.getFileName(currentPath);
|
let name = Utils.getFileName(currentPath);
|
||||||
let trashUrl = siteRoot + 'repo/' + repoID + '/trash/';
|
let trashUrl = siteRoot + 'repo/' + repoID + '/trash/';
|
||||||
@@ -122,16 +109,6 @@ class DirTool extends React.Component {
|
|||||||
toggleCancel={this.onCreateRepoTagToggle}
|
toggleCancel={this.onCreateRepoTagToggle}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{this.state.isUpdateRepoTagShow && (
|
|
||||||
<UpdateTagDialog
|
|
||||||
repoID={repoID}
|
|
||||||
currentTag={this.state.currentTag}
|
|
||||||
onClose={this.onCloseRepoTagDialog}
|
|
||||||
toggleCancel={this.onUpdateRepoTagToggle}
|
|
||||||
onDeleteRepoTag={this.props.onDeleteRepoTag}
|
|
||||||
updateUsedRepoTags={this.props.updateUsedRepoTags}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{this.state.isListTaggedFileShow && (
|
{this.state.isListTaggedFileShow && (
|
||||||
<ListTaggedFilesDialog
|
<ListTaggedFilesDialog
|
||||||
repoID={this.props.repoID}
|
repoID={this.props.repoID}
|
||||||
|
@@ -1,134 +0,0 @@
|
|||||||
import React, { Fragment } from 'react';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
import { Button, ModalHeader, ModalBody, ModalFooter, Input } from 'reactstrap';
|
|
||||||
import { gettext } from '../../utils/constants';
|
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
|
||||||
import { Utils } from '../../utils/utils';
|
|
||||||
import toaster from '../toast';
|
|
||||||
|
|
||||||
const propTypes = {
|
|
||||||
currentTag: PropTypes.object,
|
|
||||||
repoID: PropTypes.string.isRequired,
|
|
||||||
toggleCancel: PropTypes.func.isRequired,
|
|
||||||
onDeleteRepoTag: PropTypes.func.isRequired,
|
|
||||||
updateUsedRepoTags: PropTypes.func.isRequired,
|
|
||||||
onClose: PropTypes.func.isRequired
|
|
||||||
};
|
|
||||||
|
|
||||||
class UpdateTagDialog extends React.Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
deleteRepoTag: false,
|
|
||||||
newName: this.props.currentTag.name,
|
|
||||||
newColor: this.props.currentTag.color,
|
|
||||||
colorList: ['#FFA8A8', '#FFA94D', '#FFD43B', '#A0EC50', '#A9E34B', '#63E6BE', '#4FD2C9', '#72C3FC', '#91A7FF', '#E599F7', '#B197FC', '#F783AC', '#CED4DA'],
|
|
||||||
};
|
|
||||||
this.newInput = React.createRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.newInput.focus();
|
|
||||||
this.newInput.setSelectionRange(0, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
inputNewName = (e) => {
|
|
||||||
this.setState({
|
|
||||||
newName: e.target.value,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
selectNewcolor = (e) => {
|
|
||||||
this.setState({
|
|
||||||
newColor: e.target.value,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
updateTag = () => {
|
|
||||||
let tag_id = this.props.currentTag.id;
|
|
||||||
let name = this.state.newName;
|
|
||||||
let color = this.state.newColor;
|
|
||||||
let repoID = this.props.repoID;
|
|
||||||
seafileAPI.updateRepoTag(repoID, tag_id, name, color).then(() => {
|
|
||||||
this.props.toggleCancel();
|
|
||||||
this.props.updateUsedRepoTags();
|
|
||||||
}).catch((error) => {
|
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errMessage);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
handleKeyPress = (e) => {
|
|
||||||
if (e.key === 'Enter') {
|
|
||||||
this.updateTag();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteTagClick = (item) => {
|
|
||||||
this.setState({
|
|
||||||
deleteRepoTag: !this.state.deleteRepoTag,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
onDeleteTag = () => {
|
|
||||||
let tag = this.props.currentTag;
|
|
||||||
let repoID = this.props.repoID;
|
|
||||||
seafileAPI.deleteRepoTag(repoID, tag.id).then((res) => {
|
|
||||||
this.props.toggleCancel();
|
|
||||||
if (res.data.success === 'true') {
|
|
||||||
this.props.onDeleteRepoTag(tag.id);
|
|
||||||
}
|
|
||||||
}).catch((error) => {
|
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errMessage);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
let colorList = this.state.colorList;
|
|
||||||
if (colorList.indexOf(this.props.currentTag.color)===-1) {
|
|
||||||
colorList.push(this.props.currentTag.color);
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<Fragment>
|
|
||||||
<ModalHeader toggle={this.props.onClose}>
|
|
||||||
<span className="tag-dialog-back fas fa-sm fa-arrow-left" onClick={this.props.toggleCancel} aria-label={gettext('Back')}></span>
|
|
||||||
{gettext('Edit Tag')}
|
|
||||||
</ModalHeader>
|
|
||||||
<ModalBody>
|
|
||||||
<div className="tag-edit">
|
|
||||||
<div className="form-group">
|
|
||||||
<label className="form-label">{gettext('Name')}</label>
|
|
||||||
<Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newInput = input;}} value={this.state.newName} onChange={this.inputNewName}/>
|
|
||||||
</div>
|
|
||||||
<div className="form-group">
|
|
||||||
<label className="form-label">{gettext('Select a color')}</label>
|
|
||||||
<div className="row gutters-xs">
|
|
||||||
{colorList.map((item, index)=>{
|
|
||||||
return (
|
|
||||||
<div key={index} className="col-auto" onChange={this.selectNewcolor}>
|
|
||||||
<label className="colorinput">
|
|
||||||
{item===this.props.currentTag.color ?
|
|
||||||
<input name="color" type="radio" value={item} className="colorinput-input" defaultChecked onChange={this.selectNewcolor}></input> :
|
|
||||||
<input name="color" type="radio" value={item} className="colorinput-input" onChange={this.selectNewcolor}></input>}
|
|
||||||
<span className="colorinput-color" style={{backgroundColor:item}}></span>
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ModalBody>
|
|
||||||
<ModalFooter>
|
|
||||||
<Button color="danger" onClick={this.onDeleteTag}>{gettext('Delete')}</Button>
|
|
||||||
<Button color="primary" onClick={this.updateTag}>{gettext('Save')}</Button>
|
|
||||||
</ModalFooter>
|
|
||||||
</Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateTagDialog.propTypes = propTypes;
|
|
||||||
|
|
||||||
export default UpdateTagDialog;
|
|
Reference in New Issue
Block a user