-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(website): Refactor top navigation items (#2461)
* initial refactor * add potential extra items * rename var * Update navigationItems.ts * Automated code formatting * update * Automated code formatting --------- Co-authored-by: Loculus bot <bot@loculus.org>
- Loading branch information
1 parent
be208eb
commit 032268d
Showing
2 changed files
with
28 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const extraTopNavigationItems = []; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,47 @@ | ||
import { bottomNavigationItems } from './bottomNavigationItems.ts'; | ||
import { extraTopNavigationItems } from './extraTopNavigationItems.js'; | ||
import { routes } from './routes.ts'; | ||
|
||
export const navigationItems = { | ||
top: topNavigationItems, | ||
bottom: bottomNavigationItems, | ||
}; | ||
|
||
function topNavigationItems(organism: string | undefined, isLoggedIn: boolean, loginUrl: string | undefined) { | ||
if (organism === undefined) { | ||
return [ | ||
{ | ||
text: 'Browse', | ||
path: routes.organismSelectorPage('search'), | ||
}, | ||
{ | ||
text: 'Submit', | ||
path: routes.organismSelectorPage('submission'), | ||
}, | ||
{ | ||
text: 'SeqSets', | ||
path: routes.seqSetsPage(), | ||
}, | ||
...(isLoggedIn | ||
? [{ text: 'My account', path: routes.userOverviewPage() }] | ||
: [{ text: 'Login', path: loginUrl! }]), | ||
]; | ||
} | ||
|
||
function getSequenceRelatedItems(organism: string | undefined) { | ||
return [ | ||
{ | ||
text: 'Browse', | ||
path: routes.searchPage(organism), | ||
path: organism !== undefined ? routes.searchPage(organism) : routes.organismSelectorPage('search'), | ||
}, | ||
{ | ||
text: 'Submit', | ||
path: routes.submissionPageWithoutGroup(organism), | ||
path: | ||
organism !== undefined | ||
? routes.submissionPageWithoutGroup(organism) | ||
: routes.organismSelectorPage('submission'), | ||
}, | ||
{ | ||
text: 'SeqSets', | ||
path: routes.seqSetsPage(), | ||
}, | ||
...(isLoggedIn | ||
? [{ text: 'My account', path: routes.userOverviewPage(organism) }] | ||
: [{ text: 'Login', path: loginUrl! }]), | ||
]; | ||
} | ||
|
||
function getAccountItem(isLoggedIn: boolean, loginUrl: string | undefined, organism: string | undefined) { | ||
return isLoggedIn | ||
? { | ||
text: 'My account', | ||
path: organism !== undefined ? routes.userOverviewPage(organism) : routes.userOverviewPage(), | ||
} | ||
: { | ||
text: 'Login', | ||
path: loginUrl!, | ||
}; | ||
} | ||
|
||
function topNavigationItems(organism: string | undefined, isLoggedIn: boolean, loginUrl: string | undefined) { | ||
const sequenceRelatedItems = getSequenceRelatedItems(organism); | ||
const accountItem = getAccountItem(isLoggedIn, loginUrl, organism); | ||
|
||
return [...sequenceRelatedItems, ...extraTopNavigationItems, accountItem]; | ||
} |