Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add organism selector for browse and submit pages #1113

Merged
merged 2 commits into from
Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions website/src/pages/organism-selector/[redirectTo].astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
import { getConfiguredOrganisms } from '../../config';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { routes } from '../../routes';
const redirectTo = Astro.params.redirectTo;

const purposes: { [key: string]: string } = {
submit: 'for which you want to submit data',
search: 'for which you want to browse data',
};

interface Routes {
[key: string]: (organism: string) => string;
}

const myRoutes: Routes = {
submit: routes.submitPage,
search: routes.searchPage,
};

const purpose = purposes[redirectTo!];
---

<BaseLayout title='Home'>
<div class='max-w-6xl mx-auto'>
<p class='text-gray-700 my-4'>
Please select an organism {purpose}.
</p>

<div class='flex flex-wrap'>
{
getConfiguredOrganisms().map(({ key, displayName, image, description }) => (
<a
href={myRoutes[redirectTo!](key)}
class='block rounded border border-gray-300 p-4 m-2 w-64 text-center hover:bg-gray-100'
>
{image !== undefined && <img src={image} class='h-32 mx-auto mb-4' alt={displayName} />}
<h3 class='font-semibold text-gray-700'>{displayName}</h3>
<p class='text-gray-700 text-sm'>{description}</p>
</a>
))
}
</div>
</div>
</BaseLayout>
11 changes: 10 additions & 1 deletion website/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export const routes = {
},
notFoundPage: () => `/404`,
logout: () => '/logout',
organismSelectorPage: (redirectTo: string) => `/organism-selector/${redirectTo}`,
};

export type ClassOfSearchPageType = 'SEARCH' | 'MY_SEQUENCES';
Expand Down Expand Up @@ -177,6 +178,14 @@ export const navigationItems = {
function topNavigationItems(organism: string | undefined) {
if (organism === undefined) {
return [
{
text: 'Browse',
path: routes.organismSelectorPage('search'),
},
{
text: 'Submit',
path: routes.organismSelectorPage('submit'),
},
{
text: 'User',
path: routes.userOverviewPage(),
Expand All @@ -190,7 +199,7 @@ function topNavigationItems(organism: string | undefined) {

return [
{
text: 'Search',
text: 'Browse',
path: routes.searchPage(organism),
},
{
Expand Down
Loading