mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-17 07:41:26 +00:00
Merge pull request #2677 from haiwen/tag
[tag popup] improvements: 'add tag link', 'more colors', 'darker color'
This commit is contained in:
@@ -3,6 +3,7 @@ import { gettext, siteRoot } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import PropTypes from 'prop-types';
|
||||
import ModalPortal from '../modal-portal';
|
||||
import { Modal } from 'reactstrap';
|
||||
import ListTagDialog from '../dialog/list-tag-dialog';
|
||||
import CreateTagDialog from '../dialog/create-tag-dialog';
|
||||
import UpdateTagDialog from '../dialog/update-tag-dialog';
|
||||
@@ -20,6 +21,7 @@ class DirTool extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isRepoTagDialogShow: false,
|
||||
currentTag: null,
|
||||
isListRepoTagShow: false,
|
||||
isUpdateRepoTagShow: false,
|
||||
@@ -28,8 +30,24 @@ class DirTool extends React.Component {
|
||||
};
|
||||
}
|
||||
|
||||
onListRepoTagToggle = () => {
|
||||
this.setState({isListRepoTagShow: !this.state.isListRepoTagShow});
|
||||
onShowListRepoTag = () => {
|
||||
this.setState({
|
||||
isRepoTagDialogShow: true,
|
||||
isListRepoTagShow: true,
|
||||
isUpdateRepoTagShow: false,
|
||||
isCreateRepoTagShow: false,
|
||||
isListTaggedFileShow: false
|
||||
});
|
||||
}
|
||||
|
||||
onCloseRepoTagDialog = () => {
|
||||
this.setState({
|
||||
isRepoTagDialogShow: false,
|
||||
isListRepoTagShow: false,
|
||||
isUpdateRepoTagShow: false,
|
||||
isCreateRepoTagShow: false,
|
||||
isListTaggedFileShow: false
|
||||
});
|
||||
}
|
||||
|
||||
onCreateRepoTagToggle = () => {
|
||||
@@ -70,45 +88,50 @@ class DirTool extends React.Component {
|
||||
return (
|
||||
<Fragment>
|
||||
<ul className="path-toolbar">
|
||||
<li className="toolbar-item"><a className="op-link sf2-icon-tag" onClick={this.onListRepoTagToggle} title={gettext('Tags')} aria-label={gettext('Tags')}></a></li>
|
||||
<li className="toolbar-item"><a className="op-link sf2-icon-tag" onClick={this.onShowListRepoTag} title={gettext('Tags')} aria-label={gettext('Tags')}></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>
|
||||
</ul>
|
||||
{this.state.isListRepoTagShow && (
|
||||
|
||||
{this.state.isRepoTagDialogShow && (
|
||||
<ModalPortal>
|
||||
<ListTagDialog
|
||||
repoID={repoID}
|
||||
onListTagCancel={this.onListRepoTagToggle}
|
||||
onCreateRepoTag={this.onCreateRepoTagToggle}
|
||||
onUpdateRepoTag={this.onUpdateRepoTagToggle}
|
||||
onListTaggedFiles={this.onListTaggedFileToggle}
|
||||
/>
|
||||
</ModalPortal>
|
||||
)}
|
||||
{this.state.isCreateRepoTagShow && (
|
||||
<ModalPortal>
|
||||
<CreateTagDialog
|
||||
repoID={repoID}
|
||||
toggleCancel={this.onCreateRepoTagToggle}
|
||||
/>
|
||||
</ModalPortal>
|
||||
)}
|
||||
{this.state.isUpdateRepoTagShow && (
|
||||
<ModalPortal>
|
||||
<UpdateTagDialog
|
||||
repoID={repoID}
|
||||
currentTag={this.state.currentTag}
|
||||
toggleCancel={this.onUpdateRepoTagToggle}
|
||||
/>
|
||||
</ModalPortal>
|
||||
)}
|
||||
{this.state.isListTaggedFileShow && (
|
||||
<ModalPortal>
|
||||
<ListTaggedFilesDialog
|
||||
repoID={this.props.repoID}
|
||||
currentTag={this.state.currentTag}
|
||||
toggleCancel={this.onListTaggedFileToggle}
|
||||
/>
|
||||
<Modal isOpen={true}>
|
||||
{this.state.isListRepoTagShow && (
|
||||
<ListTagDialog
|
||||
repoID={repoID}
|
||||
onListTagCancel={this.onCloseRepoTagDialog}
|
||||
onCreateRepoTag={this.onCreateRepoTagToggle}
|
||||
onUpdateRepoTag={this.onUpdateRepoTagToggle}
|
||||
onListTaggedFiles={this.onListTaggedFileToggle}
|
||||
/>
|
||||
)}
|
||||
|
||||
{this.state.isCreateRepoTagShow && (
|
||||
<CreateTagDialog
|
||||
repoID={repoID}
|
||||
onClose={this.onCloseRepoTagDialog}
|
||||
toggleCancel={this.onCreateRepoTagToggle}
|
||||
/>
|
||||
)}
|
||||
|
||||
{this.state.isUpdateRepoTagShow && (
|
||||
<UpdateTagDialog
|
||||
repoID={repoID}
|
||||
currentTag={this.state.currentTag}
|
||||
onClose={this.onCloseRepoTagDialog}
|
||||
toggleCancel={this.onUpdateRepoTagToggle}
|
||||
/>
|
||||
)}
|
||||
|
||||
{this.state.isListTaggedFileShow && (
|
||||
<ListTaggedFilesDialog
|
||||
repoID={this.props.repoID}
|
||||
currentTag={this.state.currentTag}
|
||||
onClose={this.onCloseRepoTagDialog}
|
||||
toggleCancel={this.onListTaggedFileToggle}
|
||||
/>
|
||||
)}
|
||||
</Modal>
|
||||
</ModalPortal>
|
||||
)}
|
||||
</Fragment>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter, Input } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
@@ -7,6 +7,7 @@ import { seafileAPI } from '../../utils/seafile-api';
|
||||
const propTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
toggleCancel: PropTypes.func.isRequired,
|
||||
onClose: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
class CreateTagDialog extends React.Component {
|
||||
@@ -16,7 +17,7 @@ class CreateTagDialog extends React.Component {
|
||||
tagName: '',
|
||||
tagColor: '',
|
||||
newTag: {},
|
||||
colorList: ['lime', 'teal', 'azure', 'green', 'blue', 'purple', 'pink', 'indigo'],
|
||||
colorList: ['blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan', 'gray']
|
||||
};
|
||||
this.newInput = React.createRef();
|
||||
}
|
||||
@@ -24,7 +25,7 @@ class CreateTagDialog extends React.Component {
|
||||
inputNewName = (e) => {
|
||||
this.setState({
|
||||
tagName: e.target.value,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
selectTagcolor = (e) => {
|
||||
@@ -33,7 +34,7 @@ class CreateTagDialog extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
createTag = () => {
|
||||
createTag = () => {
|
||||
let name = this.state.tagName;
|
||||
let color = this.state.tagColor;
|
||||
let repoID = this.props.repoID;
|
||||
@@ -45,11 +46,7 @@ class CreateTagDialog extends React.Component {
|
||||
handleKeyPress = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.createTag();
|
||||
}
|
||||
}
|
||||
|
||||
toggle = () => {
|
||||
this.props.toggleCancel();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
@@ -63,8 +60,11 @@ class CreateTagDialog extends React.Component {
|
||||
render() {
|
||||
let colorList = this.state.colorList;
|
||||
return (
|
||||
<Modal isOpen={true} toggle={this.toggle}>
|
||||
<ModalHeader toggle={this.toggle}>{gettext('New Tag')}</ModalHeader>
|
||||
<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('New Tag')}
|
||||
</ModalHeader>
|
||||
<ModalBody>
|
||||
<div role="form" className="tag-create">
|
||||
<div className="form-group">
|
||||
@@ -79,7 +79,7 @@ class CreateTagDialog extends React.Component {
|
||||
return (
|
||||
<div key={index} className="col-auto" onChange={this.selectTagcolor}>
|
||||
<label className="colorinput">
|
||||
{index===0 ?
|
||||
{index===0 ?
|
||||
<input name="color" type="radio" value={item} className="colorinput-input" defaultChecked onClick={this.selectTagcolor}></input> :
|
||||
<input name="color" type="radio" value={item} className="colorinput-input" onClick={this.selectTagcolor}></input>}
|
||||
<span className={className}></span>
|
||||
@@ -94,9 +94,9 @@ class CreateTagDialog extends React.Component {
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<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>
|
||||
</Modal>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import RepoTag from '../../models/repo-tag';
|
||||
|
||||
import '../../css/repo-tag.css';
|
||||
|
||||
const tagListItemPropTypes = {
|
||||
@@ -14,6 +15,25 @@ const tagListItemPropTypes = {
|
||||
|
||||
class TagListItem extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
showSelectedTag: false
|
||||
};
|
||||
}
|
||||
|
||||
onMouseOver = () => {
|
||||
this.setState({
|
||||
showSelectedTag: true
|
||||
});
|
||||
}
|
||||
|
||||
onMouseOut = () => {
|
||||
this.setState({
|
||||
showSelectedTag: false
|
||||
});
|
||||
}
|
||||
|
||||
onTagUpdate = () => {
|
||||
this.props.onTagUpdate(this.props.item);
|
||||
}
|
||||
@@ -24,15 +44,16 @@ class TagListItem extends React.Component {
|
||||
|
||||
render() {
|
||||
let color = this.props.item.color;
|
||||
return(
|
||||
return (
|
||||
<li className="tag-list-item">
|
||||
<span className={`tag-demo bg-${color}`}>
|
||||
<div className={`tag-demo bg-${color}`} onMouseOver={this.onMouseOver} onMouseOut={this.onMouseOut}>
|
||||
<span className={`bg-${color}-dark ${this.state.showSelectedTag ? 'show-tag-selected': ''}`}></span>
|
||||
<span className="tag-name">{this.props.item.name}</span>
|
||||
<span className="tag-files" onClick={this.onListTaggedFiles}>
|
||||
{/* todo 0 file 2 files */}
|
||||
{this.props.item.fileCount}{' '}{'files'}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
<i className="tag-edit fa fa-pencil" onClick={this.onTagUpdate}></i>
|
||||
</li>
|
||||
);
|
||||
@@ -75,37 +96,33 @@ class ListTagDialog extends React.Component {
|
||||
this.props.onListTagCancel();
|
||||
}
|
||||
|
||||
createNewTag = (e) => {
|
||||
e.preventDefault();
|
||||
this.props.onCreateRepoTag();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Fragment>
|
||||
<Modal isOpen={true} toggle={this.toggle}>
|
||||
<ModalHeader toggle={this.toggle}>{gettext('Tags')}</ModalHeader>
|
||||
<ModalBody>
|
||||
{this.state.repotagList.length === 0 && (
|
||||
<div className="tag-list tag-list-container">
|
||||
{gettext('Click new tag button to create tags.')}
|
||||
</div>
|
||||
)}
|
||||
{this.state.repotagList.length > 0 && (
|
||||
<ul className="tag-list tag-list-container">
|
||||
{this.state.repotagList.map((repoTag, index) => {
|
||||
return (
|
||||
<TagListItem
|
||||
key={index}
|
||||
item={repoTag}
|
||||
onTagUpdate={this.props.onUpdateRepoTag}
|
||||
onListTaggedFiles={this.props.onListTaggedFiles}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" onClick={this.props.onCreateRepoTag}>{gettext('New Tag')}</Button>
|
||||
<Button color="secondary" onClick={this.toggle}>{gettext('Close')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
<ModalHeader toggle={this.toggle}>{gettext('Tags')}</ModalHeader>
|
||||
<ModalBody>
|
||||
<ul className="tag-list tag-list-container">
|
||||
{this.state.repotagList.map((repoTag, index) => {
|
||||
return (
|
||||
<TagListItem
|
||||
key={index}
|
||||
item={repoTag}
|
||||
onTagUpdate={this.props.onUpdateRepoTag}
|
||||
onListTaggedFiles={this.props.onListTaggedFiles}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
<a href="#" className="add-tag-link" onClick={this.createNewTag}>{gettext('Create a new tag')}</a>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="secondary" onClick={this.toggle}>{gettext('Close')}</Button>
|
||||
</ModalFooter>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import React from 'react';
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
|
||||
import { gettext, siteRoot } from '../../utils/constants';
|
||||
@@ -10,6 +10,7 @@ const propTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
currentTag: PropTypes.object.isRequired,
|
||||
toggleCancel: PropTypes.func.isRequired,
|
||||
onClose: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
class ListTaggedFilesDialog extends React.Component {
|
||||
@@ -40,15 +41,14 @@ class ListTaggedFilesDialog extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
toggle = () => {
|
||||
this.props.toggleCancel();
|
||||
}
|
||||
|
||||
render() {
|
||||
let taggedFileList = this.state.taggedFileList;
|
||||
return (
|
||||
<Modal isOpen={true} toggle={this.toggle}>
|
||||
<ModalHeader toggle={this.toggle}>{gettext('Tagged Files')}</ModalHeader>
|
||||
<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('Tagged Files')}
|
||||
</ModalHeader>
|
||||
<ModalBody className="dialog-list-container">
|
||||
<table>
|
||||
<thead className="table-thread-hidden">
|
||||
@@ -81,9 +81,9 @@ class ListTaggedFilesDialog extends React.Component {
|
||||
</table>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" onClick={this.toggle}>{gettext('Close')}</Button>
|
||||
<Button color="primary" onClick={this.props.toggleCancel}>{gettext('Close')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ const propTypes = {
|
||||
currentTag: PropTypes.object,
|
||||
repoID: PropTypes.string.isRequired,
|
||||
toggleCancel: PropTypes.func.isRequired,
|
||||
onClose: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
class UpdateTagDialog extends React.Component {
|
||||
@@ -17,7 +18,7 @@ class UpdateTagDialog extends React.Component {
|
||||
deleteRepoTag: false,
|
||||
newName: this.props.currentTag.name,
|
||||
newColor: this.props.currentTag.color,
|
||||
colorList: ['lime', 'teal', 'azure', 'green', 'blue', 'purple', 'pink', 'indigo'],
|
||||
colorList: ['blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan', 'gray']
|
||||
};
|
||||
this.newInput = React.createRef();
|
||||
}
|
||||
@@ -39,7 +40,7 @@ class UpdateTagDialog extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
updateTag = () => {
|
||||
updateTag = () => {
|
||||
let tag_id = this.props.currentTag.id;
|
||||
let name = this.state.newName;
|
||||
let color = this.state.newColor;
|
||||
@@ -52,11 +53,7 @@ class UpdateTagDialog extends React.Component {
|
||||
handleKeyPress = (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
this.updateTag();
|
||||
}
|
||||
}
|
||||
|
||||
toggle = () => {
|
||||
this.props.toggleCancel();
|
||||
}
|
||||
}
|
||||
|
||||
deleteTagClick = (item) => {
|
||||
@@ -77,39 +74,40 @@ class UpdateTagDialog extends React.Component {
|
||||
let colorList = this.state.colorList;
|
||||
return (
|
||||
<Fragment>
|
||||
<Modal isOpen={true} toggle={this.toggle}>
|
||||
<ModalHeader toggle={this.toggle}>{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;}} placeholder="newName" 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)=>{
|
||||
var className = 'colorinput-color bg-' + item;
|
||||
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={className}></span>
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<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;}} placeholder="newName" 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)=>{
|
||||
var className = 'colorinput-color bg-' + item;
|
||||
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={className}></span>
|
||||
</label>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" onClick={this.updateTag}>{gettext('Save')}</Button>
|
||||
<Button color="danger" onClick={this.onDeleteTag}>{gettext('Delete')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
</div>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" onClick={this.updateTag}>{gettext('Save')}</Button>
|
||||
<Button color="danger" onClick={this.onDeleteTag}>{gettext('Delete')}</Button>
|
||||
</ModalFooter>
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user