From f1eb4c625f09214d49b7c3724ece606efc49d1c3 Mon Sep 17 00:00:00 2001 From: shanshuirenjia <978987373@qq.com> Date: Tue, 11 Dec 2018 17:52:19 +0800 Subject: [PATCH] repair goto repo bug --- frontend/src/app.js | 46 +++++++++++++++---- .../src/components/cur-dir-path/dir-path.js | 13 ++++-- frontend/src/components/cur-dir-path/index.js | 2 + frontend/src/components/dir-view/dir-panel.js | 2 + frontend/src/components/dir-view/dir-view.js | 13 ++---- frontend/src/components/main-side-nav.js | 6 +-- .../shared-repo-list-item.js | 5 +- 7 files changed, 62 insertions(+), 25 deletions(-) diff --git a/frontend/src/app.js b/frontend/src/app.js index 050c4cf36e..12f519726f 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -1,7 +1,7 @@ -import React, { Component } from 'react'; +import React, { Component, Fragment } from 'react'; import ReactDOM from 'react-dom'; import { Router } from '@reach/router'; -import { siteRoot } from './utils/constants'; +import { gettext, siteRoot } from './utils/constants'; import SidePanel from './components/side-panel'; import MainPanel from './components/main-panel'; import DraftsView from './pages/drafts/drafts-view'; @@ -52,8 +52,8 @@ class App extends Component { draftList:[], isLoadingDraft: true, currentTab: '/', + pathPrefix: null, }; - this.currentTab = ''; //just for refresh brower } componentDidMount() { @@ -101,12 +101,42 @@ class App extends Component { //todos } - tabItemClick = (tabName) => { - this.setState({currentTab: tabName}); + tabItemClick = (tabName, groupID) => { + let pathPrefix = this.generatorPrefix(tabName, groupID); + this.setState({ + currentTab: tabName, + pathPrefix: pathPrefix + }); } - updateCurrentTab = (tabName) => { - this.currentTab = tabName; + generatorPrefix = (currentTab, groupID) => { + if (groupID) { //group + return ( + + {gettext('Groups')} + / + {currentTab} + / + + ); + } + if (currentTab === 'my-libs') { + return ( + + {gettext('Libraries')} + / + + ); + } + if (currentTab === 'shared-libs') { + return ( + + {gettext('Shared with me')} + / + + ); + } + return null; } render() { @@ -141,7 +171,7 @@ class App extends Component { - + diff --git a/frontend/src/components/cur-dir-path/dir-path.js b/frontend/src/components/cur-dir-path/dir-path.js index 92ae0c6429..c1771ca591 100644 --- a/frontend/src/components/cur-dir-path/dir-path.js +++ b/frontend/src/components/cur-dir-path/dir-path.js @@ -1,9 +1,10 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { siteRoot, gettext } from '../../utils/constants'; const propTypes = { repoName: PropTypes.string.isRequired, + pathPrefix: PropTypes.object, currentPath: PropTypes.string.isRequired, onPathClick: PropTypes.func.isRequired, }; @@ -43,10 +44,16 @@ class DirPath extends React.Component { render() { let { currentPath, repoName } = this.props; let pathElem = this.turnPathToLink(currentPath); + let pathPrefix = this.props.pathPrefix !== undefined ? this.props.pathPrefix : false; return (
- {gettext('Libraries')} - / + {pathPrefix ? + pathPrefix : + + {gettext('Libraries')} + / + + } {currentPath === '/' ? {repoName}: {repoName} diff --git a/frontend/src/components/cur-dir-path/index.js b/frontend/src/components/cur-dir-path/index.js index 59215351a4..fbacc1e922 100644 --- a/frontend/src/components/cur-dir-path/index.js +++ b/frontend/src/components/cur-dir-path/index.js @@ -5,6 +5,7 @@ import DirTool from './dir-tool'; const propTypes = { repoID: PropTypes.string.isRequired, + pathPrefix: PropTypes.object.isRequired, repoName: PropTypes.string.isRequired, permission: PropTypes.bool.isRequired, currentPath: PropTypes.string.isRequired, @@ -18,6 +19,7 @@ class CurDirPath extends React.Component { diff --git a/frontend/src/components/dir-view/dir-panel.js b/frontend/src/components/dir-view/dir-panel.js index cc7ce5a04a..63034f10ac 100644 --- a/frontend/src/components/dir-view/dir-panel.js +++ b/frontend/src/components/dir-view/dir-panel.js @@ -14,6 +14,7 @@ import FileUploader from '../file-uploader/file-uploader'; const propTypes = { currentRepo: PropTypes.object, + pathPrefix: PropTypes.object.isRequired, path: PropTypes.string.isRequired, repoID: PropTypes.string.isRequired, repoName: PropTypes.string.isRequired, @@ -147,6 +148,7 @@ class DirPanel extends React.Component { { @@ -430,6 +424,7 @@ class DirView extends React.Component { render() { return ( { - this.props.tabItemClick(param); + tabItemClick = (param, id) => { + this.props.tabItemClick(param, id); } getActiveClass = (tab) => { @@ -76,7 +76,7 @@ class MainSideNav extends React.Component { {this.state.groupItems.map(item => { return (
  • - this.tabItemClick(item.id)}> + this.tabItemClick(item.name, item.id)}> {item.name} diff --git a/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js b/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js index 3f47415558..ebf8ad26e9 100644 --- a/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js +++ b/frontend/src/components/shared-repo-list-view/shared-repo-list-item.js @@ -2,6 +2,7 @@ import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import moment from 'moment'; import { Dropdown, DropdownMenu, DropdownToggle, DropdownItem } from 'reactstrap'; +import { Link } from '@reach/router'; import { Utils } from '../../utils/utils'; import { gettext, siteRoot, isPro, username, folderPermEnabled } from '../../utils/constants'; @@ -91,7 +92,7 @@ class SharedRepoListItem extends React.Component { }); //todo change to library; div-view is not compatibility - let libPath = `${siteRoot}#group/${currentGroup.id}/lib/${this.props.repo.repo_id}/`; + let libPath = `${siteRoot}library/${this.props.repo.repo_id}/`; return { iconUrl, iconTitle, libPath }; } @@ -269,7 +270,7 @@ class SharedRepoListItem extends React.Component { return ( {iconTitle} - {repo.repo_name} + {repo.repo_name} {this.state.isOperationShow && this.generatorPCMenu()} {repo.size} {moment(repo.last_modified).fromNow()}