diff --git a/frontend/src/components/repo-view/mylib-repo-view.js b/frontend/src/components/repo-view/mylib-repo-view.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/frontend/src/components/repo-view/share-repo-view.js b/frontend/src/components/repo-view/share-repo-view.js deleted file mode 100644 index 641642b2a3..0000000000 --- a/frontend/src/components/repo-view/share-repo-view.js +++ /dev/null @@ -1,91 +0,0 @@ -import React, { Fragment } from 'react'; -import PropTypes from 'prop-types'; -import { seafileAPI } from '../../utils/seafile-api'; -import RepoInfo from '../../models/repoInfo'; -import Loading from '../../components/loading'; -import CommonToolbar from '../../components/toolbar/common-toolbar'; -import RepoViewToolbar from '../../components/toolbar/repo-view-toobar'; -import CurRepoPath from '../../components/cur-repo-path/'; -import ShareRepoListView from '../../components/share-repo-list-view/share-repo-list-view'; - -const propTypes = { - isLoading: PropTypes.bool.isRequired, - isShowRepoOwner: PropTypes.bool.isRequired, - errMessage: PropTypes.string.isRequired, - currentTab: PropTypes.string.isRequired, - repoList: PropTypes.array.isRequired, - onShowSidePanel: PropTypes.func.isRequired, - emptyTip: PropTypes.object, - currentGroup: PropTypes.object, - onSearchedClick: PropTypes.func, -}; - -class ShareRepoView extends React.Component { - - constructor(props) { - super(props); - this.state = { - repoList: [], - }; - } - - componentWillReceiveProps(nextProps) { - this.setState({repoList: nextProps.repoList}); - } - - onCreateRepo = (repo) => { - let groupId = this.props.groupID; - seafileAPI.createGroupRepo(groupId, repo).then(res => { - let repo = new RepoInfo(res.data); - let repoList = this.addRepoItem(repo); - this.setState({repoList: repoList}); - }).catch(() => { - //todo - }); - } - - addRepoItem = (repo) => { - let newRepoList = this.state.repoList.map(item => {return item;}); - newRepoList.push(repo); - return newRepoList; - } - - render() { - let { errMessage, emptyTip } = this.props; - return ( - -
- - -
-
-
-
- -
-
- {this.props.isLoading && } - {(!this.props.isLoading && errMessage) && errMessage} - {(!this.props.isLoading && this.state.repoList.length === 0) && emptyTip} - {(!this.props.isLoading && this.state.repoList.length > 0) && - - } -
-
-
-
- ); - } -} - -ShareRepoView.propTypes = propTypes; - -export default ShareRepoView; diff --git a/frontend/src/pages/groups/group-view.js b/frontend/src/pages/groups/group-view.js index ee5dd52503..496a2013c4 100644 --- a/frontend/src/pages/groups/group-view.js +++ b/frontend/src/pages/groups/group-view.js @@ -1,10 +1,14 @@ -import React from 'react'; +import React,{ Fragment } from 'react'; import PropTypes from 'prop-types'; import { gettext, username, loginUrl } from '../../utils/constants'; import { seafileAPI } from '../../utils/seafile-api'; +import Loading from '../../components/loading'; import Group from '../../models/group'; import RepoInfo from '../../models/repoInfo'; -import SharedRepoView from '../../components/repo-view/share-repo-view'; +import CommonToolbar from '../../components/toolbar/common-toolbar'; +import RepoViewToolbar from '../../components/toolbar/repo-view-toobar'; +import CurRepoPath from '../../components/cur-repo-path/'; +import ShareRepoListView from '../../components/share-repo-list-view/share-repo-list-view'; const propTypes = { onShowSidePanel: PropTypes.func.isRequired, @@ -54,19 +58,19 @@ class GroupView extends React.Component { if (error.response.status == 403) { this.setState({ isLoading: false, - errorMsg: gettext("Permission denied") + errMessage: gettext("Permission denied") }); location.href = `${loginUrl}?next=${encodeURIComponent(location.href)}`; } else { this.setState({ isLoading: false, - errorMsg: gettext("Error") + errMessage: gettext("Error") }); } } else { this.setState({ isLoading: false, - errorMsg: gettext("Please check the network.") + errMessage: gettext("Please check the network.") }); } }); @@ -88,19 +92,19 @@ class GroupView extends React.Component { if (error.response.status == 403) { this.setState({ isLoading: false, - errorMsg: gettext("Permission denied") + errMessage: gettext("Permission denied") }); location.href = `${loginUrl}?next=${encodeURIComponent(location.href)}`; } else { this.setState({ isLoading: false, - errorMsg: gettext("Error") + errMessage: gettext("Error") }); } } else { this.setState({ isLoading: false, - errorMsg: gettext("Please check the network.") + errMessage: gettext("Please check the network.") }); } }); @@ -137,9 +141,55 @@ class GroupView extends React.Component { return emptyTip; } + onCreateRepo = (repo) => { + let groupId = this.props.groupID; + seafileAPI.createGroupRepo(groupId, repo).then(res => { + let repo = new RepoInfo(res.data); + let repoList = this.addRepoItem(repo); + this.setState({repoList: repoList}); + }).catch(() => { + //todo + }); + } + + addRepoItem = (repo) => { + let newRepoList = this.state.repoList.map(item => {return item;}); + newRepoList.push(repo); + return newRepoList; + } + render() { + let { errMessage, emptyTip } = this.state; return ( - + +
+ + +
+
+
+
+ +
+
+ {this.state.isLoading && } + {(!this.state.isLoading && errMessage) && errMessage} + {(!this.state.isLoading && this.state.repoList.length === 0) && emptyTip} + {(!this.state.isLoading && this.state.repoList.length > 0) && + + } +
+
+
+
); } }