1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-17 15:53:28 +00:00

[tag popup] don't show new popup; added 'back' icon

This commit is contained in:
llj
2018-12-20 18:45:31 +08:00
parent 3d324389f7
commit 983bf03c10
6 changed files with 146 additions and 109 deletions

View File

@@ -3,6 +3,7 @@ import { gettext, siteRoot } from '../../utils/constants';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import ModalPortal from '../modal-portal'; import ModalPortal from '../modal-portal';
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 UpdateTagDialog from '../dialog/update-tag-dialog';
@@ -20,6 +21,7 @@ class DirTool extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
showTagPopup: false,
currentTag: null, currentTag: null,
isListRepoTagShow: false, isListRepoTagShow: false,
isUpdateRepoTagShow: false, isUpdateRepoTagShow: false,
@@ -29,7 +31,10 @@ class DirTool extends React.Component {
} }
onListRepoTagToggle = () => { onListRepoTagToggle = () => {
this.setState({isListRepoTagShow: !this.state.isListRepoTagShow}); this.setState({
showTagPopup: !this.state.showTagPopup,
isListRepoTagShow: !this.state.isListRepoTagShow
});
} }
onCreateRepoTagToggle = () => { onCreateRepoTagToggle = () => {
@@ -39,6 +44,13 @@ class DirTool extends React.Component {
}); });
} }
onCreateRepoTagPopupToggle = () => {
this.setState({
isCreateRepoTagShow: !this.state.isCreateRepoTagShow,
showTagPopup: !this.state.showTagPopup
});
}
onUpdateRepoTagToggle = (currentTag) => { onUpdateRepoTagToggle = (currentTag) => {
this.setState({ this.setState({
currentTag: currentTag, currentTag: currentTag,
@@ -47,6 +59,13 @@ class DirTool extends React.Component {
}); });
} }
onUpdateRepoTagPopupToggle = () => {
this.setState({
isUpdateRepoTagShow: !this.state.isUpdateRepoTagShow,
showTagPopup: !this.state.showTagPopup
});
}
onListTaggedFileToggle = (currentTag) => { onListTaggedFileToggle = (currentTag) => {
this.setState({ this.setState({
currentTag: currentTag, currentTag: currentTag,
@@ -55,6 +74,13 @@ class DirTool extends React.Component {
}); });
} }
onListTaggedFilePopupToggle = () => {
this.setState({
isListTaggedFileShow: !this.state.isListTaggedFileShow,
showTagPopup: !this.state.showTagPopup
});
}
isMarkdownFile(filePath) { isMarkdownFile(filePath) {
let name = Utils.getFileName(filePath); let name = Utils.getFileName(filePath);
return name.indexOf('.md') > -1 ? true : false; return name.indexOf('.md') > -1 ? true : false;
@@ -74,41 +100,46 @@ class DirTool extends React.Component {
<li className="toolbar-item"><a className="op-link sf2-icon-trash" href={trashUrl} title={gettext('Trash')} aria-label={gettext('Trash')}></a></li> <li className="toolbar-item"><a className="op-link sf2-icon-trash" href={trashUrl} title={gettext('Trash')} aria-label={gettext('Trash')}></a></li>
<li className="toolbar-item"><a className="op-link sf2-icon-history" href={historyUrl} title={gettext('History')} aria-label={gettext('History')}></a></li> <li className="toolbar-item"><a className="op-link sf2-icon-history" href={historyUrl} title={gettext('History')} aria-label={gettext('History')}></a></li>
</ul> </ul>
{this.state.isListRepoTagShow && (
{this.state.showTagPopup && (
<ModalPortal> <ModalPortal>
<ListTagDialog <Modal isOpen={true}>
repoID={repoID} {this.state.isListRepoTagShow && (
onListTagCancel={this.onListRepoTagToggle} <ListTagDialog
onCreateRepoTag={this.onCreateRepoTagToggle} repoID={repoID}
onUpdateRepoTag={this.onUpdateRepoTagToggle} onListTagCancel={this.onListRepoTagToggle}
onListTaggedFiles={this.onListTaggedFileToggle} onCreateRepoTag={this.onCreateRepoTagToggle}
/> onUpdateRepoTag={this.onUpdateRepoTagToggle}
</ModalPortal> onListTaggedFiles={this.onListTaggedFileToggle}
)} />
{this.state.isCreateRepoTagShow && ( )}
<ModalPortal>
<CreateTagDialog {this.state.isCreateRepoTagShow && (
repoID={repoID} <CreateTagDialog
toggleCancel={this.onCreateRepoTagToggle} repoID={repoID}
/> togglePopup={this.onCreateRepoTagPopupToggle}
</ModalPortal> toggleCancel={this.onCreateRepoTagToggle}
)} />
{this.state.isUpdateRepoTagShow && ( )}
<ModalPortal>
<UpdateTagDialog {this.state.isUpdateRepoTagShow && (
repoID={repoID} <UpdateTagDialog
currentTag={this.state.currentTag} repoID={repoID}
toggleCancel={this.onUpdateRepoTagToggle} currentTag={this.state.currentTag}
/> togglePopup={this.onUpdateRepoTagPopupToggle}
</ModalPortal> toggleCancel={this.onUpdateRepoTagToggle}
)} />
{this.state.isListTaggedFileShow && ( )}
<ModalPortal>
<ListTaggedFilesDialog {this.state.isListTaggedFileShow && (
repoID={this.props.repoID} <ListTaggedFilesDialog
currentTag={this.state.currentTag} repoID={this.props.repoID}
toggleCancel={this.onListTaggedFileToggle} currentTag={this.state.currentTag}
/> togglePopup={this.onListTaggedFilePopupToggle}
toggleCancel={this.onListTaggedFileToggle}
/>
)}
</Modal>
</ModalPortal> </ModalPortal>
)} )}
</Fragment> </Fragment>

View File

@@ -1,4 +1,4 @@
import React from 'react'; import React, { Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input } from 'reactstrap'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input } from 'reactstrap';
import { gettext } from '../../utils/constants'; import { gettext } from '../../utils/constants';
@@ -7,6 +7,7 @@ import { seafileAPI } from '../../utils/seafile-api';
const propTypes = { const propTypes = {
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
toggleCancel: PropTypes.func.isRequired, toggleCancel: PropTypes.func.isRequired,
togglePopup: PropTypes.func.isRequired
}; };
class CreateTagDialog extends React.Component { class CreateTagDialog extends React.Component {
@@ -48,10 +49,6 @@ class CreateTagDialog extends React.Component {
} }
} }
toggle = () => {
this.props.toggleCancel();
}
componentDidMount() { componentDidMount() {
this.setState({ this.setState({
tagColor: this.state.colorList[0] tagColor: this.state.colorList[0]
@@ -63,8 +60,11 @@ class CreateTagDialog extends React.Component {
render() { render() {
let colorList = this.state.colorList; let colorList = this.state.colorList;
return ( return (
<Modal isOpen={true} toggle={this.toggle}> <Fragment>
<ModalHeader toggle={this.toggle}>{gettext('New Tag')}</ModalHeader> <ModalHeader toggle={this.props.togglePopup}>
<span className="tag-popup-back fas fa-sm fa-arrow-left" onClick={this.props.toggleCancel} aria-label={gettext('Back')}></span>
{gettext('New Tag')}
</ModalHeader>
<ModalBody> <ModalBody>
<div role="form" className="tag-create"> <div role="form" className="tag-create">
<div className="form-group"> <div className="form-group">
@@ -94,9 +94,9 @@ class CreateTagDialog extends React.Component {
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button color="primary" onClick={this.createTag}>{gettext('Save')}</Button> <Button color="primary" onClick={this.createTag}>{gettext('Save')}</Button>
<Button color="secondary" onClick={this.toggle}>{gettext('Cancel')}</Button> <Button color="secondary" onClick={this.props.toggleCancel}>{gettext('Cancel')}</Button>
</ModalFooter> </ModalFooter>
</Modal> </Fragment>
); );
} }
} }

View File

@@ -103,27 +103,25 @@ class ListTagDialog extends React.Component {
render() { render() {
return ( return (
<Fragment> <Fragment>
<Modal isOpen={true} toggle={this.toggle}> <ModalHeader toggle={this.toggle}>{gettext('Tags')}</ModalHeader>
<ModalHeader toggle={this.toggle}>{gettext('Tags')}</ModalHeader> <ModalBody>
<ModalBody> <ul className="tag-list tag-list-container">
<ul className="tag-list tag-list-container"> {this.state.repotagList.map((repoTag, index) => {
{this.state.repotagList.map((repoTag, index) => { return (
return ( <TagListItem
<TagListItem key={index}
key={index} item={repoTag}
item={repoTag} onTagUpdate={this.props.onUpdateRepoTag}
onTagUpdate={this.props.onUpdateRepoTag} onListTaggedFiles={this.props.onListTaggedFiles}
onListTaggedFiles={this.props.onListTaggedFiles} />
/> );
); })}
})} </ul>
</ul> <a href="#" className="add-tag-link" onClick={this.createNewTag}>{gettext('Create a new tag')}</a>
<a href="#" className="add-tag-link" onClick={this.createNewTag}>{gettext('Create a new tag')}</a> </ModalBody>
</ModalBody> <ModalFooter>
<ModalFooter> <Button color="secondary" onClick={this.toggle}>{gettext('Close')}</Button>
<Button color="secondary" onClick={this.toggle}>{gettext('Close')}</Button> </ModalFooter>
</ModalFooter>
</Modal>
</Fragment> </Fragment>
); );
} }

View File

@@ -1,4 +1,4 @@
import React from 'react'; import React, { Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { gettext, siteRoot } from '../../utils/constants'; import { gettext, siteRoot } from '../../utils/constants';
@@ -10,6 +10,7 @@ const propTypes = {
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
currentTag: PropTypes.object.isRequired, currentTag: PropTypes.object.isRequired,
toggleCancel: PropTypes.func.isRequired, toggleCancel: PropTypes.func.isRequired,
togglePopup: PropTypes.func.isRequired
}; };
class ListTaggedFilesDialog extends React.Component { class ListTaggedFilesDialog extends React.Component {
@@ -40,15 +41,14 @@ class ListTaggedFilesDialog extends React.Component {
}); });
} }
toggle = () => {
this.props.toggleCancel();
}
render() { render() {
let taggedFileList = this.state.taggedFileList; let taggedFileList = this.state.taggedFileList;
return ( return (
<Modal isOpen={true} toggle={this.toggle}> <Fragment>
<ModalHeader toggle={this.toggle}>{gettext('Tagged Files')}</ModalHeader> <ModalHeader toggle={this.props.togglePopup}>
<span className="tag-popup-back fas fa-sm fa-arrow-left" onClick={this.props.toggleCancel} aria-label={gettext('Back')}></span>
{gettext('Tagged Files')}
</ModalHeader>
<ModalBody className="dialog-list-container"> <ModalBody className="dialog-list-container">
<table> <table>
<thead className="table-thread-hidden"> <thead className="table-thread-hidden">
@@ -81,9 +81,9 @@ class ListTaggedFilesDialog extends React.Component {
</table> </table>
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button color="primary" onClick={this.toggle}>{gettext('Close')}</Button> <Button color="primary" onClick={this.props.toggleCancel}>{gettext('Close')}</Button>
</ModalFooter> </ModalFooter>
</Modal> </Fragment>
); );
} }
} }

View File

@@ -8,6 +8,7 @@ const propTypes = {
currentTag: PropTypes.object, currentTag: PropTypes.object,
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
toggleCancel: PropTypes.func.isRequired, toggleCancel: PropTypes.func.isRequired,
togglePopup: PropTypes.func.isRequired
}; };
class UpdateTagDialog extends React.Component { class UpdateTagDialog extends React.Component {
@@ -55,10 +56,6 @@ class UpdateTagDialog extends React.Component {
} }
} }
toggle = () => {
this.props.toggleCancel();
}
deleteTagClick = (item) => { deleteTagClick = (item) => {
this.setState({ this.setState({
deleteRepoTag: !this.state.deleteRepoTag, deleteRepoTag: !this.state.deleteRepoTag,
@@ -77,39 +74,40 @@ class UpdateTagDialog extends React.Component {
let colorList = this.state.colorList; let colorList = this.state.colorList;
return ( return (
<Fragment> <Fragment>
<Modal isOpen={true} toggle={this.toggle}> <ModalHeader toggle={this.props.togglePopup}>
<ModalHeader toggle={this.toggle}>{gettext('Edit Tag')}</ModalHeader> <span className="tag-popup-back fas fa-sm fa-arrow-left" onClick={this.props.toggleCancel} aria-label={gettext('Back')}></span>
<ModalBody> {gettext('Edit Tag')}
<div className="tag-edit"> </ModalHeader>
<div className="form-group"> <ModalBody>
<label className="form-label">{gettext('Name')}</label> <div className="tag-edit">
<Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newInput = input;}} placeholder="newName" value={this.state.newName} onChange={this.inputNewName}/> <div className="form-group">
</div> <label className="form-label">{gettext('Name')}</label>
<div className="form-group"> <Input onKeyPress={this.handleKeyPress} innerRef={input => {this.newInput = input;}} placeholder="newName" value={this.state.newName} onChange={this.inputNewName}/>
<label className="form-label">{gettext('Select a color')}</label> </div>
<div className="row gutters-xs"> <div className="form-group">
{colorList.map((item, index)=>{ <label className="form-label">{gettext('Select a color')}</label>
var className = 'colorinput-color bg-' + item; <div className="row gutters-xs">
return ( {colorList.map((item, index)=>{
<div key={index} className="col-auto" onChange={this.selectNewcolor}> var className = 'colorinput-color bg-' + item;
<label className="colorinput"> return (
{item===this.props.currentTag.color ? <div key={index} className="col-auto" onChange={this.selectNewcolor}>
<input name="color" type="radio" value={item} className="colorinput-input" defaultChecked onChange={this.selectNewcolor}></input> : <label className="colorinput">
<input name="color" type="radio" value={item} className="colorinput-input" onChange={this.selectNewcolor}></input>} {item===this.props.currentTag.color ?
<span className={className}></span> <input name="color" type="radio" value={item} className="colorinput-input" defaultChecked onChange={this.selectNewcolor}></input> :
</label> <input name="color" type="radio" value={item} className="colorinput-input" onChange={this.selectNewcolor}></input>}
</div> <span className={className}></span>
); </label>
})} </div>
</div> );
})}
</div> </div>
</div> </div>
</ModalBody> </div>
<ModalFooter> </ModalBody>
<Button color="primary" onClick={this.updateTag}>{gettext('Save')}</Button> <ModalFooter>
<Button color="danger" onClick={this.onDeleteTag}>{gettext('Delete')}</Button> <Button color="primary" onClick={this.updateTag}>{gettext('Save')}</Button>
</ModalFooter> <Button color="danger" onClick={this.onDeleteTag}>{gettext('Delete')}</Button>
</Modal> </ModalFooter>
</Fragment> </Fragment>
); );
} }

View File

@@ -92,3 +92,13 @@
.file-tag-item:hover { .file-tag-item:hover {
background-color: #bbb; background-color: #bbb;
} }
.tag-popup-back {
color: #888;
cursor: pointer;
margin-right: 10px;
}
.tag-popup-back:hover,
.tag-popup-back:focus {
color: #444;
}