1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-09 10:50:24 +00:00

[dir view] Tags: don't send the 'get tags' request when open the 'tags' popover/dialog (handled 6 cases); removed the repeated 'get tags' request after creating a new tag; improved the 'no tags' tip (#5936)

This commit is contained in:
llj
2024-02-02 20:52:58 +08:00
committed by GitHub
parent 631419c436
commit 23785bb28b
14 changed files with 83 additions and 81 deletions

View File

@@ -4,7 +4,6 @@ import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap';
import { gettext } from '../../utils/constants'; import { gettext } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api'; import { seafileAPI } from '../../utils/seafile-api';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import RepoTag from '../../models/repo-tag';
import CreateTagDialog from './create-tag-dialog'; import CreateTagDialog from './create-tag-dialog';
import toaster from '../toast'; import toaster from '../toast';
require('../../css/repo-tag.css'); require('../../css/repo-tag.css');
@@ -103,6 +102,7 @@ TagItem.propTypes = TagItemPropTypes;
const TagListPropTypes = { const TagListPropTypes = {
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
repoTags: PropTypes.array.isRequired,
filePath: PropTypes.string.isRequired, filePath: PropTypes.string.isRequired,
fileTagList: PropTypes.array.isRequired, fileTagList: PropTypes.array.isRequired,
onFileTagChanged: PropTypes.func.isRequired, onFileTagChanged: PropTypes.func.isRequired,
@@ -111,39 +111,15 @@ const TagListPropTypes = {
}; };
class TagList extends React.Component { class TagList extends React.Component {
constructor(props) {
super(props);
this.state = {
repotagList: [],
};
}
componentDidMount() {
this.getRepoTagList();
}
getRepoTagList = () => {
let repoID = this.props.repoID;
seafileAPI.listRepoTags(repoID).then(res => {
let repotagList = [];
res.data.repo_tags.forEach(item => {
let repoTag = new RepoTag(item);
repotagList.push(repoTag);
});
this.setState({repotagList: repotagList});
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
};
render() { render() {
const { repoTags } = this.props;
return ( return (
<Fragment> <Fragment>
<ModalHeader toggle={this.props.toggleCancel}>{gettext('Select Tags')}</ModalHeader> <ModalHeader toggle={this.props.toggleCancel}>{gettext('Select Tags')}</ModalHeader>
<ModalBody className="px-0"> <ModalBody className="px-0">
<ul className="tag-list tag-list-container"> <ul className="tag-list tag-list-container">
{this.state.repotagList.map((repoTag) => { {repoTags.map((repoTag) => {
return ( return (
<TagItem <TagItem
key={repoTag.id} key={repoTag.id}
@@ -177,6 +153,7 @@ TagList.propTypes = TagListPropTypes;
const propTypes = { const propTypes = {
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
repoTags: PropTypes.array.isRequired,
filePath: PropTypes.string.isRequired, filePath: PropTypes.string.isRequired,
fileTagList: PropTypes.array.isRequired, fileTagList: PropTypes.array.isRequired,
toggleCancel: PropTypes.func.isRequired, toggleCancel: PropTypes.func.isRequired,
@@ -215,6 +192,7 @@ class EditFileTagDialog extends React.Component {
{this.state.isListRepoTagShow && {this.state.isListRepoTagShow &&
<TagList <TagList
repoID={this.props.repoID} repoID={this.props.repoID}
repoTags={this.props.repoTags}
filePath={this.props.filePath} filePath={this.props.filePath}
fileTagList={this.props.fileTagList} fileTagList={this.props.fileTagList}
onFileTagChanged={this.props.onFileTagChanged} onFileTagChanged={this.props.onFileTagChanged}

View File

@@ -64,6 +64,7 @@ const propTypes = {
onItemsMove: PropTypes.func.isRequired, onItemsMove: PropTypes.func.isRequired,
onItemsCopy: PropTypes.func.isRequired, onItemsCopy: PropTypes.func.isRequired,
onItemsDelete: PropTypes.func.isRequired, onItemsDelete: PropTypes.func.isRequired,
repoTags: PropTypes.array.isRequired,
onFileTagChanged: PropTypes.func, onFileTagChanged: PropTypes.func,
showDirentDetail: PropTypes.func.isRequired, showDirentDetail: PropTypes.func.isRequired,
fullDirentList: PropTypes.array, fullDirentList: PropTypes.array,
@@ -226,6 +227,7 @@ class DirColumnView extends React.Component {
onItemsMove={this.props.onItemsMove} onItemsMove={this.props.onItemsMove}
onItemsCopy={this.props.onItemsCopy} onItemsCopy={this.props.onItemsCopy}
onItemsDelete={this.props.onItemsDelete} onItemsDelete={this.props.onItemsDelete}
repoTags={this.props.repoTags}
onFileTagChanged={this.props.onFileTagChanged} onFileTagChanged={this.props.onFileTagChanged}
showDirentDetail={this.props.showDirentDetail} showDirentDetail={this.props.showDirentDetail}
/> />

View File

@@ -29,6 +29,7 @@ const propTypes = {
updateDirent: PropTypes.func.isRequired, updateDirent: PropTypes.func.isRequired,
showDirentDetail: PropTypes.func.isRequired, showDirentDetail: PropTypes.func.isRequired,
onAddFolder: PropTypes.func.isRequired, onAddFolder: PropTypes.func.isRequired,
repoTags: PropTypes.array.isRequired,
onFileTagChanged: PropTypes.func, onFileTagChanged: PropTypes.func,
onItemRename: PropTypes.func.isRequired, onItemRename: PropTypes.func.isRequired,
fullDirentList: PropTypes.array, fullDirentList: PropTypes.array,
@@ -81,6 +82,7 @@ class DirGridView extends React.Component {
isDirentDetailShow={this.props.isDirentDetailShow} isDirentDetailShow={this.props.isDirentDetailShow}
onItemRename={this.props.onItemRename} onItemRename={this.props.onItemRename}
onAddFolder={this.props.onAddFolder} onAddFolder={this.props.onAddFolder}
repoTags={this.props.repoTags}
onFileTagChanged={this.props.onFileTagChanged} onFileTagChanged={this.props.onFileTagChanged}
/> />
</Fragment> </Fragment>

View File

@@ -12,6 +12,7 @@ const propTypes = {
userPerm: PropTypes.string, userPerm: PropTypes.string,
enableDirPrivateShare: PropTypes.bool.isRequired, enableDirPrivateShare: PropTypes.bool.isRequired,
isRepoInfoBarShow: PropTypes.bool.isRequired, isRepoInfoBarShow: PropTypes.bool.isRequired,
repoTags: PropTypes.array.isRequired,
usedRepoTags: PropTypes.array.isRequired, usedRepoTags: PropTypes.array.isRequired,
draftCounts: PropTypes.number, draftCounts: PropTypes.number,
updateUsedRepoTags: PropTypes.func.isRequired, updateUsedRepoTags: PropTypes.func.isRequired,
@@ -99,6 +100,7 @@ class DirListView extends React.Component {
onItemsDelete={this.props.onItemsDelete} onItemsDelete={this.props.onItemsDelete}
onAddFile={this.props.onAddFile} onAddFile={this.props.onAddFile}
onAddFolder={this.props.onAddFolder} onAddFolder={this.props.onAddFolder}
repoTags={this.props.repoTags}
onFileTagChanged={this.props.onFileTagChanged} onFileTagChanged={this.props.onFileTagChanged}
showDirentDetail={this.props.showDirentDetail} showDirentDetail={this.props.showDirentDetail}
loadDirentList={this.props.loadDirentList} loadDirentList={this.props.loadDirentList}

View File

@@ -44,6 +44,7 @@ const propTypes = {
updateDirent: PropTypes.func.isRequired, updateDirent: PropTypes.func.isRequired,
isDirentDetailShow: PropTypes.bool.isRequired, isDirentDetailShow: PropTypes.bool.isRequired,
onGridItemClick: PropTypes.func, onGridItemClick: PropTypes.func,
repoTags: PropTypes.array.isRequired,
onFileTagChanged: PropTypes.func, onFileTagChanged: PropTypes.func,
onAddFolder: PropTypes.func.isRequired, onAddFolder: PropTypes.func.isRequired,
showDirentDetail: PropTypes.func.isRequired, showDirentDetail: PropTypes.func.isRequired,
@@ -626,6 +627,7 @@ class DirentGridView extends React.Component {
fileTagList={dirent.file_tags} fileTagList={dirent.file_tags}
filePath={direntPath} filePath={direntPath}
toggleCancel={this.onEditFileTagToggle} toggleCancel={this.onEditFileTagToggle}
repoTags={this.props.repoTags}
onFileTagChanged={this.onFileTagChanged} onFileTagChanged={this.onFileTagChanged}
/> />
} }

View File

@@ -51,6 +51,7 @@ const propTypes = {
selectedDirentList: PropTypes.array.isRequired, selectedDirentList: PropTypes.array.isRequired,
activeDirent: PropTypes.object, activeDirent: PropTypes.object,
getDirentItemMenuList: PropTypes.func.isRequired, getDirentItemMenuList: PropTypes.func.isRequired,
repoTags: PropTypes.array.isRequired,
onFileTagChanged: PropTypes.func, onFileTagChanged: PropTypes.func,
enableDirPrivateShare: PropTypes.bool.isRequired, enableDirPrivateShare: PropTypes.bool.isRequired,
showDirentDetail: PropTypes.func.isRequired, showDirentDetail: PropTypes.func.isRequired,
@@ -892,6 +893,7 @@ class DirentListItem extends React.Component {
{this.state.isEditFileTagShow && {this.state.isEditFileTagShow &&
<EditFileTagPopover <EditFileTagPopover
repoID={this.props.repoID} repoID={this.props.repoID}
repoTags={this.props.repoTags}
fileTagList={dirent.file_tags} fileTagList={dirent.file_tags}
filePath={direntPath} filePath={direntPath}
toggleCancel={this.onEditFileTagToggle} toggleCancel={this.onEditFileTagToggle}
@@ -905,6 +907,7 @@ class DirentListItem extends React.Component {
{this.state.isEditFileTagShow && {this.state.isEditFileTagShow &&
<EditFileTagDialog <EditFileTagDialog
repoID={this.props.repoID} repoID={this.props.repoID}
repoTags={this.props.repoTags}
fileTagList={dirent.file_tags} fileTagList={dirent.file_tags}
filePath={direntPath} filePath={direntPath}
toggleCancel={this.onEditFileTagToggle} toggleCancel={this.onEditFileTagToggle}

View File

@@ -44,6 +44,7 @@ const propTypes = {
onItemsCopy: PropTypes.func.isRequired, onItemsCopy: PropTypes.func.isRequired,
onItemConvert: PropTypes.func.isRequired, onItemConvert: PropTypes.func.isRequired,
onItemsDelete: PropTypes.func.isRequired, onItemsDelete: PropTypes.func.isRequired,
repoTags: PropTypes.array.isRequired,
onFileTagChanged: PropTypes.func, onFileTagChanged: PropTypes.func,
enableDirPrivateShare: PropTypes.bool.isRequired, enableDirPrivateShare: PropTypes.bool.isRequired,
isGroupOwnedRepo: PropTypes.bool.isRequired, isGroupOwnedRepo: PropTypes.bool.isRequired,
@@ -671,6 +672,7 @@ class DirentListView extends React.Component {
onItemContextMenu={this.onItemContextMenu} onItemContextMenu={this.onItemContextMenu}
selectedDirentList={this.props.selectedDirentList} selectedDirentList={this.props.selectedDirentList}
activeDirent={this.state.activeDirent} activeDirent={this.state.activeDirent}
repoTags={this.props.repoTags}
onFileTagChanged={this.props.onFileTagChanged} onFileTagChanged={this.props.onFileTagChanged}
getDirentItemMenuList={this.getDirentItemMenuList} getDirentItemMenuList={this.getDirentItemMenuList}
showDirentDetail={this.props.showDirentDetail} showDirentDetail={this.props.showDirentDetail}

View File

@@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { gettext } from '../../utils/constants'; import { gettext } from '../../utils/constants';
import { seafileAPI } from '../../utils/seafile-api'; import { seafileAPI } from '../../utils/seafile-api';
import { Utils } from '../../utils/utils'; import { Utils } from '../../utils/utils';
import RepoTag from '../../models/repo-tag';
import toaster from '../toast'; import toaster from '../toast';
import CommonAddTool from '../common/common-add-tool'; import CommonAddTool from '../common/common-add-tool';
import SearchInput from '../common/search-input'; import SearchInput from '../common/search-input';
@@ -19,35 +18,15 @@ class EditFileTagPopover extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
repotagList: [],
searchVal: '', searchVal: '',
highlightIndex: -1, highlightIndex: -1,
}; };
} }
componentDidMount() {
this.getRepoTagList();
}
setHighlightIndex = (highlightIndex) => { setHighlightIndex = (highlightIndex) => {
this.setState({ highlightIndex }); this.setState({ highlightIndex });
}; };
getRepoTagList = () => {
let repoID = this.props.repoID;
seafileAPI.listRepoTags(repoID).then(res => {
let repotagList = [];
res.data.repo_tags.forEach(item => {
let repoTag = new RepoTag(item);
repotagList.push(repoTag);
});
this.setState({repotagList: repotagList});
}).catch(error => {
let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage);
});
};
generateRandomColor = () => { generateRandomColor = () => {
return TAG_COLORS[Math.floor(Math.random() * TAG_COLORS.length)]; return TAG_COLORS[Math.floor(Math.random() * TAG_COLORS.length)];
}; };
@@ -64,7 +43,6 @@ class EditFileTagPopover extends React.Component {
searchVal: '', searchVal: '',
highlightIndex: -1, highlightIndex: -1,
}); });
this.getRepoTagList();
}).catch((error) => { }).catch((error) => {
let errMessage = Utils.getErrorMsg(error); let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage); toaster.danger(errMessage);
@@ -116,13 +94,14 @@ class EditFileTagPopover extends React.Component {
}; };
onKeyDown = (e) => { onKeyDown = (e) => {
const { repoTags } = this.props;
if (e.keyCode === KeyCodes.ChineseInputMethod || e.keyCode === KeyCodes.LeftArrow || e.keyCode === KeyCodes.RightArrow) { if (e.keyCode === KeyCodes.ChineseInputMethod || e.keyCode === KeyCodes.LeftArrow || e.keyCode === KeyCodes.RightArrow) {
e.stopPropagation(); e.stopPropagation();
} }
else if (e.keyCode === KeyCodes.Enter) { else if (e.keyCode === KeyCodes.Enter) {
const searchText = this.state.searchVal.trim(); const searchText = this.state.searchVal.trim();
const repotagList = this.state.repotagList.filter(item => item.name.includes(searchText)); const repoTagList = repoTags.filter(item => item.name.includes(searchText));
const tag = repotagList[this.state.highlightIndex]; const tag = repoTagList[this.state.highlightIndex];
if (tag) { if (tag) {
this.onEditFileTag(tag); this.onEditFileTag(tag);
} }
@@ -134,8 +113,8 @@ class EditFileTagPopover extends React.Component {
} }
else if (e.keyCode === KeyCodes.DownArrow) { else if (e.keyCode === KeyCodes.DownArrow) {
const searchText = this.state.searchVal.trim(); const searchText = this.state.searchVal.trim();
const repotagList = this.state.repotagList.filter(item => item.name.includes(searchText)); const repoTagList = repoTags.filter(item => item.name.includes(searchText));
if (this.state.highlightIndex < repotagList.length) { if (this.state.highlightIndex < repoTagList.length) {
this.setHighlightIndex(this.state.highlightIndex + 1); this.setHighlightIndex(this.state.highlightIndex + 1);
} }
} }
@@ -148,8 +127,21 @@ class EditFileTagPopover extends React.Component {
render() { render() {
const searchText = this.state.searchVal.trim(); const searchText = this.state.searchVal.trim();
const repotagList = this.state.repotagList.filter(item => item.name.includes(searchText)); const { repoTags: repoTagList } = this.props;
const showAddTool = searchText && !this.state.repotagList.find(item => item.name === searchText); const filteredRepoTagList = repoTagList.filter(item => item.name.includes(searchText));
const showAddTool = searchText && !repoTagList.find(item => item.name === searchText);
let noTagsTip = '';
if (!searchText) {
if (repoTagList.length == 0) {
noTagsTip = gettext('No tags');
}
} else {
if (filteredRepoTagList.length == 0) {
noTagsTip = gettext('Tag not found');
}
}
return ( return (
<SeahubPopover <SeahubPopover
popoverClassName="edit-filetag-popover" popoverClassName="edit-filetag-popover"
@@ -165,11 +157,9 @@ class EditFileTagPopover extends React.Component {
onChange={this.onChangeSearch} onChange={this.onChangeSearch}
autoFocus={true} autoFocus={true}
/> />
{noTagsTip ? <div className='tag-not-found my-4 mx-1'>{noTagsTip}</div> :
<ul className="tag-list-container"> <ul className="tag-list-container">
{repotagList.length === 0 && {filteredRepoTagList.map((repoTag, index) => {
<div className='tag-not-found mt-2 mb-4 mx-1'>{gettext('Tag not found')}</div>
}
{repotagList.length > 0 && repotagList.map((repoTag, index) => {
return ( return (
<TagItem <TagItem
index={index} index={index}
@@ -185,6 +175,7 @@ class EditFileTagPopover extends React.Component {
); );
})} })}
</ul> </ul>
}
{showAddTool && {showAddTool &&
<CommonAddTool <CommonAddTool
callBack={this.createNewTag} callBack={this.createNewTag}
@@ -201,6 +192,7 @@ EditFileTagPopover.propTypes = {
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
filePath: PropTypes.string.isRequired, filePath: PropTypes.string.isRequired,
fileTagList: PropTypes.array.isRequired, fileTagList: PropTypes.array.isRequired,
repoTags: PropTypes.array.isRequired,
toggleCancel: PropTypes.func.isRequired, toggleCancel: PropTypes.func.isRequired,
onFileTagChanged: PropTypes.func.isRequired, onFileTagChanged: PropTypes.func.isRequired,
}; };

View File

@@ -25,6 +25,7 @@ const propTypes = {
userPerm: PropTypes.string.isRequired, userPerm: PropTypes.string.isRequired,
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
repoEncrypted: PropTypes.bool.isRequired, repoEncrypted: PropTypes.bool.isRequired,
repoTags: PropTypes.array.isRequired,
selectedDirentList: PropTypes.array.isRequired, selectedDirentList: PropTypes.array.isRequired,
onItemsMove: PropTypes.func.isRequired, onItemsMove: PropTypes.func.isRequired,
onItemsCopy: PropTypes.func.isRequired, onItemsCopy: PropTypes.func.isRequired,
@@ -328,7 +329,7 @@ class MultipleDirOperationToolbar extends React.Component {
render() { render() {
const { repoID, userPerm } = this.props; const { repoID, repoTags, userPerm } = this.props;
const dirent = this.props.selectedDirentList[0]; const dirent = this.props.selectedDirentList[0];
const direntPath = this.getDirentPath(dirent); const direntPath = this.getDirentPath(dirent);
@@ -458,6 +459,7 @@ class MultipleDirOperationToolbar extends React.Component {
<ModalPortal> <ModalPortal>
<EditFileTagDialog <EditFileTagDialog
repoID={repoID} repoID={repoID}
repoTags={repoTags}
filePath={direntPath} filePath={direntPath}
fileTagList={this.state.fileTagList} fileTagList={this.state.fileTagList}
toggleCancel={this.toggleCancel} toggleCancel={this.toggleCancel}

View File

@@ -12,6 +12,7 @@ import EditFileTagDialog from '../dialog/edit-filetag-dialog';
const propTypes = { const propTypes = {
path: PropTypes.string.isRequired, path: PropTypes.string.isRequired,
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
repoTags: PropTypes.array.isRequired,
userPerm: PropTypes.string.isRequired, userPerm: PropTypes.string.isRequired,
repoEncrypted: PropTypes.bool.isRequired, repoEncrypted: PropTypes.bool.isRequired,
enableDirPrivateShare: PropTypes.bool.isRequired, enableDirPrivateShare: PropTypes.bool.isRequired,
@@ -127,6 +128,7 @@ class ViewFileToolbar extends React.Component {
<EditFileTagDialog <EditFileTagDialog
filePath={this.props.path} filePath={this.props.path}
repoID={this.props.repoID} repoID={this.props.repoID}
repoTags={this.props.repoTags}
fileTagList={this.props.fileTags} fileTagList={this.props.fileTags}
toggleCancel={this.onEditFileTagToggle} toggleCancel={this.onEditFileTagToggle}
onFileTagChanged={this.props.onFileTagChanged} onFileTagChanged={this.props.onFileTagChanged}

View File

@@ -15,7 +15,7 @@
padding: 10px 0; padding: 10px 0;
} }
.edit-filetag-popover .tag-list-container .tag-not-found { .edit-filetag-popover .tag-not-found {
opacity: 0.5; opacity: 0.5;
} }

View File

@@ -51,6 +51,7 @@ const propTypes = {
onAddFolderNode: PropTypes.func.isRequired, onAddFolderNode: PropTypes.func.isRequired,
// repo content // repo content
draftCounts: PropTypes.number, draftCounts: PropTypes.number,
repoTags: PropTypes.array.isRequired,
usedRepoTags: PropTypes.array.isRequired, usedRepoTags: PropTypes.array.isRequired,
updateUsedRepoTags: PropTypes.func.isRequired, updateUsedRepoTags: PropTypes.func.isRequired,
// list // list
@@ -211,6 +212,7 @@ class LibContentContainer extends React.Component {
userPerm={this.props.userPerm} userPerm={this.props.userPerm}
enableDirPrivateShare={this.props.enableDirPrivateShare} enableDirPrivateShare={this.props.enableDirPrivateShare}
isRepoInfoBarShow={isRepoInfoBarShow} isRepoInfoBarShow={isRepoInfoBarShow}
repoTags={this.props.repoTags}
usedRepoTags={this.props.usedRepoTags} usedRepoTags={this.props.usedRepoTags}
draftCounts={this.props.draftCounts} draftCounts={this.props.draftCounts}
updateUsedRepoTags={this.props.updateUsedRepoTags} updateUsedRepoTags={this.props.updateUsedRepoTags}
@@ -252,6 +254,7 @@ class LibContentContainer extends React.Component {
enableDirPrivateShare={this.props.enableDirPrivateShare} enableDirPrivateShare={this.props.enableDirPrivateShare}
onRenameNode={this.props.onRenameNode} onRenameNode={this.props.onRenameNode}
isRepoInfoBarShow={isRepoInfoBarShow} isRepoInfoBarShow={isRepoInfoBarShow}
repoTags={this.props.repoTags}
usedRepoTags={this.props.usedRepoTags} usedRepoTags={this.props.usedRepoTags}
draftCounts={this.props.draftCounts} draftCounts={this.props.draftCounts}
updateUsedRepoTags={this.props.updateUsedRepoTags} updateUsedRepoTags={this.props.updateUsedRepoTags}
@@ -304,6 +307,7 @@ class LibContentContainer extends React.Component {
latestContributor={this.props.latestContributor} latestContributor={this.props.latestContributor}
onLinkClick={this.props.onLinkClick} onLinkClick={this.props.onLinkClick}
isRepoInfoBarShow={isRepoInfoBarShow} isRepoInfoBarShow={isRepoInfoBarShow}
repoTags={this.props.repoTags}
usedRepoTags={this.props.usedRepoTags} usedRepoTags={this.props.usedRepoTags}
draftCounts={this.props.draftCounts} draftCounts={this.props.draftCounts}
updateUsedRepoTags={this.props.updateUsedRepoTags} updateUsedRepoTags={this.props.updateUsedRepoTags}

View File

@@ -20,6 +20,7 @@ const propTypes = {
// mutiple-dir // mutiple-dir
isDirentSelected: PropTypes.bool.isRequired, isDirentSelected: PropTypes.bool.isRequired,
repoID: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired,
repoTags: PropTypes.array.isRequired,
path: PropTypes.string.isRequired, path: PropTypes.string.isRequired,
selectedDirentList: PropTypes.array.isRequired, selectedDirentList: PropTypes.array.isRequired,
onItemsMove: PropTypes.func.isRequired, onItemsMove: PropTypes.func.isRequired,
@@ -77,6 +78,7 @@ class LibContentToolbar extends React.Component {
fileTags={this.props.fileTags} fileTags={this.props.fileTags}
onFileTagChanged={this.props.onFileTagChanged} onFileTagChanged={this.props.onFileTagChanged}
showShareBtn={this.props.showShareBtn} showShareBtn={this.props.showShareBtn}
repoTags={this.props.repoTags}
/> />
<ViewModeToolbar currentMode={this.props.currentMode} switchViewMode={this.props.switchViewMode} isCustomPermission={isCustomPermission} /> <ViewModeToolbar currentMode={this.props.currentMode} switchViewMode={this.props.switchViewMode} isCustomPermission={isCustomPermission} />
</div> </div>
@@ -101,6 +103,7 @@ class LibContentToolbar extends React.Component {
path={this.props.path} path={this.props.path}
userPerm={this.props.userPerm} userPerm={this.props.userPerm}
repoEncrypted={this.props.repoEncrypted} repoEncrypted={this.props.repoEncrypted}
repoTags={this.props.repoTags}
selectedDirentList={this.props.selectedDirentList} selectedDirentList={this.props.selectedDirentList}
direntList={this.props.direntList} direntList={this.props.direntList}
onItemsMove={this.props.onItemsMove} onItemsMove={this.props.onItemsMove}

View File

@@ -51,6 +51,7 @@ class LibContentView extends React.Component {
fileTags: [], fileTags: [],
draftID: '', draftID: '',
draftCounts: 0, draftCounts: 0,
repoTags: [],
usedRepoTags: [], usedRepoTags: [],
isTreeDataLoading: true, isTreeDataLoading: true,
treeData: treeHelper.buildTree(), treeData: treeHelper.buildTree(),
@@ -266,14 +267,19 @@ class LibContentView extends React.Component {
updateUsedRepoTags = () => { updateUsedRepoTags = () => {
let repoID = this.props.repoID; let repoID = this.props.repoID;
seafileAPI.listRepoTags(repoID).then(res => { seafileAPI.listRepoTags(repoID).then(res => {
let repoTags = [];
let usedRepoTags = []; let usedRepoTags = [];
res.data.repo_tags.forEach(item => { res.data.repo_tags.forEach(item => {
let usedRepoTag = new RepoTag(item); const repoTag = new RepoTag(item);
if (usedRepoTag.fileCount > 0) { repoTags.push(repoTag);
usedRepoTags.push(usedRepoTag); if (repoTag.fileCount > 0) {
usedRepoTags.push(repoTag);
} }
}); });
this.setState({usedRepoTags: usedRepoTags}); this.setState({
repoTags: repoTags,
usedRepoTags: usedRepoTags
});
}).catch(error => { }).catch(error => {
let errMessage = Utils.getErrorMsg(error); let errMessage = Utils.getErrorMsg(error);
toaster.danger(errMessage); toaster.danger(errMessage);
@@ -2018,6 +2024,7 @@ class LibContentView extends React.Component {
showDirentDetail={this.showDirentDetail} showDirentDetail={this.showDirentDetail}
unSelectDirent={this.unSelectDirent} unSelectDirent={this.unSelectDirent}
onFilesTagChanged={this.onFileTagChanged} onFilesTagChanged={this.onFileTagChanged}
repoTags={this.state.repoTags}
/> />
</div> </div>
<div className="main-panel-center flex-row"> <div className="main-panel-center flex-row">
@@ -2057,6 +2064,7 @@ class LibContentView extends React.Component {
onRenameNode={this.onRenameTreeNode} onRenameNode={this.onRenameTreeNode}
onDeleteNode={this.onDeleteTreeNode} onDeleteNode={this.onDeleteTreeNode}
draftCounts={this.state.draftCounts} draftCounts={this.state.draftCounts}
repoTags={this.state.repoTags}
usedRepoTags={this.state.usedRepoTags} usedRepoTags={this.state.usedRepoTags}
updateUsedRepoTags={this.updateUsedRepoTags} updateUsedRepoTags={this.updateUsedRepoTags}
isDirentListLoading={this.state.isDirentListLoading} isDirentListLoading={this.state.isDirentListLoading}