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

Merge pull request #2656 from haiwen/file-tag-improve

File tag improve
This commit is contained in:
Daniel Pan
2018-12-18 10:26:29 +08:00
committed by GitHub
7 changed files with 70 additions and 23 deletions

View File

@@ -82,7 +82,7 @@ class EditFileTagDialog extends React.Component {
let repoTagIdList = this.getRepoTagIdList(); let repoTagIdList = this.getRepoTagIdList();
return ( return (
<Modal isOpen={true} toggle={this.toggle}> <Modal isOpen={true} toggle={this.toggle}>
<ModalHeader toggle={this.toggle}>{gettext('File Tags')}</ModalHeader> <ModalHeader toggle={this.toggle}>{gettext('Select Tags')}</ModalHeader>
<ModalBody> <ModalBody>
{ {
<ul className="tag-list tag-list-container"> <ul className="tag-list tag-list-container">
@@ -102,7 +102,7 @@ class EditFileTagDialog extends React.Component {
} }
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Button color="primary" onClick={this.toggle}>{gettext('Close')}</Button> <Button onClick={this.toggle}>{gettext('Close')}</Button>
</ModalFooter> </ModalFooter>
</Modal> </Modal>
); );

View File

@@ -147,7 +147,7 @@ class DirPanel extends React.Component {
searchPlaceholder={'Search files in this library'} searchPlaceholder={'Search files in this library'}
/> />
</div> </div>
<div className="main-panel-center flex-direction-row"> <div className="main-panel-center flex-row">
{!this.props.libNeedDecrypt && {!this.props.libNeedDecrypt &&
<div className="cur-view-container"> <div className="cur-view-container">
<div className="cur-view-path"> <div className="cur-view-path">

View File

@@ -84,14 +84,14 @@ class DetailListView extends React.Component {
<ul className="file-tag-list"> <ul className="file-tag-list">
{fileTagList.map((fileTag) => { {fileTagList.map((fileTag) => {
return ( return (
<li key={fileTag.id}> <li key={fileTag.id} className="file-tag-item">
<span className={`file-tag bg-${fileTag.color}`}></span> <span className={`file-tag bg-${fileTag.color}`}></span>
<span className="tag-name">{fileTag.name}</span> <span className="tag-name" title={fileTag.name}>{fileTag.name}</span>
</li> </li>
); );
})} })}
</ul> </ul>
<i className='fa fa-pencil' onClick={this.onEditFileTagToggle}></i> <i className='fa fa-pencil tag-edit-icon' onClick={this.onEditFileTagToggle}></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>

View File

@@ -1,5 +1,7 @@
import React, { Fragment } from 'react'; import React, { Fragment } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import MD5 from 'MD5';
import { UncontrolledTooltip } from 'reactstrap';
import { gettext, siteRoot } from '../../utils/constants'; import { gettext, siteRoot } from '../../utils/constants';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import { seafileAPI } from '../../utils/seafile-api'; import { seafileAPI } from '../../utils/seafile-api';
@@ -48,6 +50,7 @@ class DirentListItem extends React.Component {
isCopyDialogShow: false, isCopyDialogShow: false,
isShareDialogShow: false, isShareDialogShow: false,
isMutipleOperation: false, isMutipleOperation: false,
isShowTagTooltip: false,
}; };
this.zipToken = null; this.zipToken = null;
} }
@@ -373,10 +376,22 @@ class DirentListItem extends React.Component {
return path === '/' ? path + dirent.name : path + '/' + dirent.name; return path === '/' ? path + dirent.name : path + '/' + dirent.name;
} }
onTagTooltipToggle = (e) => {
e.stopPropagation();
this.setState({isShowTagTooltip: !this.state.isShowTagTooltip})
}
render() { render() {
let { path, dirent } = this.props; let { path, dirent } = this.props;
let direntPath = Utils.joinPath(path, dirent.name); let direntPath = Utils.joinPath(path, dirent.name);
let href = siteRoot + 'wiki/lib/' + this.props.repoID + Utils.encodePath(direntPath); let href = siteRoot + 'wiki/lib/' + this.props.repoID + Utils.encodePath(direntPath);
let toolTipID = MD5(dirent.name).slice(0, 7);
let tagTitle = '';
if (dirent.file_tags && dirent.file_tags.length > 0) {
dirent.file_tags.forEach(item => {
tagTitle += item.name + ' ';
});
}
return ( return (
<Fragment> <Fragment>
<tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}> <tr className={this.state.highlight ? 'tr-highlight' : ''} onMouseEnter={this.onMouseEnter} onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
@@ -400,13 +415,21 @@ class DirentListItem extends React.Component {
} }
</td> </td>
<td> <td>
<div className="dirent-item tag-list tag-list-stacked "> {(dirent.type !== 'dir' && dirent.file_tags) && (
{ dirent.type !== 'dir' && dirent.file_tags.map((fileTag) => { <Fragment>
return ( <div id={`tag-list-title-${toolTipID}`} className="dirent-item tag-list tag-list-stacked">
<span className={`file-tag bg-${fileTag.color}`} key={fileTag.id} title={fileTag.name}></span> {dirent.file_tags.map((fileTag, index) => {
); let length = dirent.file_tags.length;
})} return (
</div> <span className={`file-tag bg-${fileTag.color}`} key={fileTag.id} style={{zIndex: length - index }}></span>
);
})}
</div>
<UncontrolledTooltip target={`tag-list-title-${toolTipID}`} placement="bottom">
{tagTitle}
</UncontrolledTooltip>
</Fragment>
)}
</td> </td>
<td className="operation"> <td className="operation">
{ {

View File

@@ -62,11 +62,11 @@ class DirentListView extends React.Component {
<th width="3%" className="select"> <th width="3%" className="select">
<input type="checkbox" className="vam" onChange={this.props.onAllItemSelected} checked={this.props.isAllItemSelected}/> <input type="checkbox" className="vam" onChange={this.props.onAllItemSelected} checked={this.props.isAllItemSelected}/>
</th> </th>
<th width="3%"></th> <th width="3%">{/*icon */}</th>
<th width="5%"></th> <th width="5%">{/*star */}</th>
<th width="35%">{gettext('Name')}</th> <th width="39%">{gettext('Name')}</th>
<th width="10%"></th> <th width="6%">{/*tag */}</th>
<th width="20%"></th> <th width="20%">{/*operation */}</th>
<th width="11%">{gettext('Size')}</th> <th width="11%">{gettext('Size')}</th>
<th width="13%">{gettext('Last Update')}</th> <th width="13%">{gettext('Last Update')}</th>
</tr> </tr>

View File

@@ -48,3 +48,26 @@
position: absolute; position: absolute;
right: 0.5rem; right: 0.5rem;
} }
.tag-edit-icon {
padding: 0 0.5rem;
color: #888;
cursor: pointer;
}
.tag-edit-icon:hover {
color: #333;
}
.file-tag-item {
margin: 0.25rem 0;
padding: 0 0.5rem;
width: max-content;
cursor: pointer;
background-color: #eee;
border-radius: 1rem;
}
.file-tag-item:hover {
background-color: #bbb;
}

View File

@@ -998,20 +998,20 @@ table .menu-toggle {
/* begin file-tag */ /* begin file-tag */
.tag-list { .tag-list {
position: relative; position: relative;
justify-content: flex-end;
} }
.tag-list .file-tag { .tag-list .file-tag {
margin-left: 0.25rem;
cursor: pointer; cursor: pointer;
} }
.tag-list .file-tag:first-child { .tag-list .file-tag:last-child {
margin-left: 0; margin-right: 0;
} }
.tag-list-stacked .file-tag{ .tag-list-stacked .file-tag{
margin-left: -0.5rem; margin-right: -0.5rem;
box-shadow: 0 0 0 2px #fff; border: 0.125rem solid #fff;
cursor: pointer; cursor: pointer;
} }
@@ -1028,6 +1028,7 @@ table .menu-toggle {
.dirent-item.tag-list { .dirent-item.tag-list {
display: flex; display: flex;
align-items: center; align-items: center;
width: max-content;
} }
.item-meta-info { .item-meta-info {