From afcc6fe6f165ddeeb8bf5e6d15ee5012e1aafaad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=81=A5=E8=BE=89?= <40563566+WangJianhui666@users.noreply.github.com> Date: Tue, 9 Apr 2019 12:00:01 +0800 Subject: [PATCH] create tag when tagging file (#3223) --- .../components/dialog/edit-filetag-dialog.js | 110 ++++++++++++------ 1 file changed, 77 insertions(+), 33 deletions(-) diff --git a/frontend/src/components/dialog/edit-filetag-dialog.js b/frontend/src/components/dialog/edit-filetag-dialog.js index 073ddaabd4..ef4da5ba7b 100644 --- a/frontend/src/components/dialog/edit-filetag-dialog.js +++ b/frontend/src/components/dialog/edit-filetag-dialog.js @@ -1,10 +1,11 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { gettext } from '../../utils/constants'; import { seafileAPI } from '../../utils/seafile-api'; import { Utils } from '../../utils/utils'; import RepoTag from '../../models/repo-tag'; +import CreateTagDialog from './create-tag-dialog'; require('../../css/repo-tag.css'); const TagItemPropTypes = { @@ -12,7 +13,7 @@ const TagItemPropTypes = { repoTag: PropTypes.object.isRequired, filePath: PropTypes.string.isRequired, fileTagList: PropTypes.array.isRequired, - onEditFileTag: PropTypes.func.isRequired, + onFileTagChanged: PropTypes.func.isRequired, }; class TagItem extends React.Component { @@ -52,7 +53,7 @@ class TagItem extends React.Component { let id = repoTag.id; seafileAPI.addFileTag(repoID, filePath, id).then(() => { repoTagIdList = this.getRepoTagIdList(); - this.props.onEditFileTag(); + this.props.onFileTagChanged(); }); } else { let fileTag = null; @@ -65,7 +66,7 @@ class TagItem extends React.Component { } seafileAPI.deleteFileTag(repoID, fileTag.id).then(() => { repoTagIdList = this.getRepoTagIdList(); - this.props.onEditFileTag(); + this.props.onFileTagChanged(); }); } } @@ -91,15 +92,16 @@ class TagItem extends React.Component { TagItem.propTypes = TagItemPropTypes; -const propTypes = { +const TagListPropTypes = { repoID: PropTypes.string.isRequired, filePath: PropTypes.string.isRequired, fileTagList: PropTypes.array.isRequired, onFileTagChanged: PropTypes.func.isRequired, toggleCancel: PropTypes.func.isRequired, + createNewTag: PropTypes.func.isRequired, }; -class EditFileTagDialog extends React.Component { +class TagList extends React.Component { constructor(props) { super(props); this.state = { @@ -125,39 +127,81 @@ class EditFileTagDialog extends React.Component { }); } - toggle = () => { - this.props.toggleCancel(); + render() { + return ( + + {gettext('Select Tags')} + + + {gettext('Create a new tag')} + + + + + + ); + } +} + +TagList.propTypes = TagListPropTypes; + +const propTypes = { + repoID: PropTypes.string.isRequired, + filePath: PropTypes.string.isRequired, + fileTagList: PropTypes.array.isRequired, + toggleCancel: PropTypes.func.isRequired, + onFileTagChanged: PropTypes.func.isRequired, +}; + +class EditFileTagDialog extends React.Component { + constructor(props) { + super(props); + this.state = { + isCreateRepoTagShow: false, + isListRepoTagShow: true, + }; } - onEditFileTag = () => { - this.props.onFileTagChanged(); + createNewTag = () => { + this.setState({ + isCreateRepoTagShow: !this.state.isCreateRepoTagShow, + isListRepoTagShow: !this.state.isListRepoTagShow, + }); } render() { return ( - - {gettext('Select Tags')} - - { - - } - - - - + + {this.state.isListRepoTagShow && + + } + {this.state.isCreateRepoTagShow && + + } ); }