From 5d2421bc6836a96b88c299aa82535e4d49c62c0d Mon Sep 17 00:00:00 2001 From: LeoSirius Date: Thu, 27 Jun 2019 17:53:36 +0800 Subject: [PATCH 1/3] redirect client's view lib url to library content pages's url --- frontend/src/app.js | 13 +++++++++++++ frontend/src/components/cur-dir-path/dir-path.js | 2 +- seahub/urls.py | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/frontend/src/app.js b/frontend/src/app.js index f34b85d0bf..929a2b6a98 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -75,7 +75,20 @@ class App extends Component { } } + navigateClientUrlToLib = () =>{ + if(window.location.hash){ + let splitUrlArray = window.location.hash.split('/'); + let repoID = splitUrlArray[splitUrlArray.length-2]; + let url = siteRoot + 'library/' + repoID + '/'; + navigate(url, {repalce: true}); + } + } + componentDidMount() { + // url from client e.g. http://127.0.0.1:8000/#common/lib/34e7fb92-e91d-499d-bcde-c30ea8af9828/ + // navigate to library page http://127.0.0.1:8000/library/34e7fb92-e91d-499d-bcde-c30ea8af9828/ + this.navigateClientUrlToLib(); + // e.g. from http://127.0.0.1:8000/drafts/reviews/ // get reviews // TODO: need refactor later diff --git a/frontend/src/components/cur-dir-path/dir-path.js b/frontend/src/components/cur-dir-path/dir-path.js index d201cbcc5c..ba86066c6d 100644 --- a/frontend/src/components/cur-dir-path/dir-path.js +++ b/frontend/src/components/cur-dir-path/dir-path.js @@ -86,7 +86,7 @@ class DirPath extends React.Component { / )} - {currentPath === '/' ? + {(currentPath === '/' || currentPath === '') ? {repoName}: {repoName} } diff --git a/seahub/urls.py b/seahub/urls.py index 5a9e8b957a..3264e1eb71 100644 --- a/seahub/urls.py +++ b/seahub/urls.py @@ -223,6 +223,7 @@ urlpatterns = [ url(r'^my-libs/$', react_fake_view, name="my_libs"), url(r'^groups/$', react_fake_view, name="groups"), url(r'^group/(?P\d+)/$', react_fake_view, name="group"), + url(r'^library/(?P[-0-9a-f]{36})/$', react_fake_view, name="library_view"), url(r'^library/(?P[-0-9a-f]{36})/(?P[^/]+)/(?P.*)$', react_fake_view, name="lib_view"), url(r'^my-libs/deleted/$', react_fake_view, name="my_libs_deleted"), url(r'^org/$', react_fake_view, name="org"), From 7c12cc271b7fd91f998483b823f914ba4b6df84e Mon Sep 17 00:00:00 2001 From: LeoSirius Date: Fri, 28 Jun 2019 11:01:55 +0800 Subject: [PATCH 2/3] add client url check logic --- frontend/src/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app.js b/frontend/src/app.js index 929a2b6a98..eab0ca7682 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -76,7 +76,7 @@ class App extends Component { } navigateClientUrlToLib = () =>{ - if(window.location.hash){ + if(window.location.hash && window.location.hash.indexOf('common/lib') != -1){ let splitUrlArray = window.location.hash.split('/'); let repoID = splitUrlArray[splitUrlArray.length-2]; let url = siteRoot + 'library/' + repoID + '/'; From b3a382240f55854637816c5b9e232decb7b341ae Mon Sep 17 00:00:00 2001 From: LeoSirius Date: Fri, 28 Jun 2019 11:38:20 +0800 Subject: [PATCH 3/3] modify some code detail --- frontend/src/app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app.js b/frontend/src/app.js index eab0ca7682..d13fd8331c 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -78,7 +78,7 @@ class App extends Component { navigateClientUrlToLib = () =>{ if(window.location.hash && window.location.hash.indexOf('common/lib') != -1){ let splitUrlArray = window.location.hash.split('/'); - let repoID = splitUrlArray[splitUrlArray.length-2]; + let repoID = splitUrlArray[splitUrlArray.length - 2]; let url = siteRoot + 'library/' + repoID + '/'; navigate(url, {repalce: true}); }