mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-02 07:47:32 +00:00
['dir view' page] when visit it directly via URL, emulate visiting it… (#6753)
* ['dir view' page] when visit it directly via URL, emulate visiting it from 'Files' page, i.e, highlight the 'Files' tab in the side panel, display 'Files' in the path * update code: init current tab with 'library' --------- Co-authored-by: renjie-run <rj.aiyayao@gmail.com>
This commit is contained in:
parent
261e7f10c9
commit
708a046d45
@ -94,16 +94,33 @@ class App extends Component {
|
||||
// navigate to library page http://127.0.0.1:8000/library/34e7fb92-e91d-499d-bcde-c30ea8af9828/
|
||||
this.navigateClientUrlToLib();
|
||||
|
||||
let currentTab;
|
||||
this.initCurrentTabByLocation();
|
||||
}
|
||||
|
||||
initCurrentTabByLocation = () => {
|
||||
// when visit the siteRoot page, highlight the 'Files' tab in the side nav.
|
||||
if (location.pathname == siteRoot) {
|
||||
currentTab = 'libraries';
|
||||
} else {
|
||||
let href = window.location.href.split('/');
|
||||
currentTab = href[href.length - 2];
|
||||
this.setState({ currentTab: 'libraries' });
|
||||
return;
|
||||
}
|
||||
this.setState({ currentTab: currentTab });
|
||||
}
|
||||
|
||||
// get path part start with siteRoot. e.g. '/' or '/xxx/'
|
||||
let pathPart = window.location.pathname.split(siteRoot)[1];
|
||||
pathPart = pathPart && pathPart.split('/')[0];
|
||||
|
||||
let currentTab = '';
|
||||
if (pathPart) {
|
||||
currentTab = pathPart;
|
||||
}
|
||||
|
||||
// when visit a 'dir view' page(http://127.0.0.1:8000/library/1137c0c3-5a5d-4da1-8fd0-69e227a9a23e/My%20Library/) directly via URL,
|
||||
// emulate visiting it from 'Files' page(get the `currentTab` & `pathPrefix`)
|
||||
if (currentTab === 'library') {
|
||||
currentTab = 'libraries';
|
||||
}
|
||||
|
||||
this.setState({ currentTab });
|
||||
};
|
||||
|
||||
resetTitle = () => {
|
||||
const favicon = document.getElementById('favicon');
|
||||
|
Loading…
Reference in New Issue
Block a user