From 8310845c47394486bd156768ef1d70625aff8cc1 Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Sun, 25 Feb 2024 20:47:08 +0000 Subject: [PATCH 1/2] add organism selector --- website/src/pages/organism-selector.astro | 45 +++++++++++++++++++++++ website/src/routes.ts | 11 +++++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 website/src/pages/organism-selector.astro diff --git a/website/src/pages/organism-selector.astro b/website/src/pages/organism-selector.astro new file mode 100644 index 000000000..46159d465 --- /dev/null +++ b/website/src/pages/organism-selector.astro @@ -0,0 +1,45 @@ +--- +import { getConfiguredOrganisms } from '../config'; +import BaseLayout from '../layouts/BaseLayout.astro'; +import { routes } from '../routes'; +const redirectTo = Astro.url.searchParams.get('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!]; +--- + + +
+

+ Please select an organism {purpose}. +

+ +
+ { + getConfiguredOrganisms().map(({ key, displayName, image, description }) => ( + + {image !== undefined && {displayName}} +

{displayName}

+

{description}

+
+ )) + } +
+
+
diff --git a/website/src/routes.ts b/website/src/routes.ts index 3996b037c..09cd91491 100644 --- a/website/src/routes.ts +++ b/website/src/routes.ts @@ -72,6 +72,7 @@ export const routes = { }, notFoundPage: () => `/404`, logout: () => '/logout', + organismSelectorPage: (redirectTo: string) => `/organism-selector?redirectTo=${redirectTo}`, }; export type ClassOfSearchPageType = 'SEARCH' | 'MY_SEQUENCES'; @@ -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(), @@ -190,7 +199,7 @@ function topNavigationItems(organism: string | undefined) { return [ { - text: 'Search', + text: 'Browse', path: routes.searchPage(organism), }, { From 5a1ec9d16422d69d38d6b1eb7a8a050e3bd49c0b Mon Sep 17 00:00:00 2001 From: Theo Sanderson Date: Sun, 25 Feb 2024 20:50:27 +0000 Subject: [PATCH 2/2] update --- .../[redirectTo].astro} | 8 ++++---- website/src/routes.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) rename website/src/pages/{organism-selector.astro => organism-selector/[redirectTo].astro} (86%) diff --git a/website/src/pages/organism-selector.astro b/website/src/pages/organism-selector/[redirectTo].astro similarity index 86% rename from website/src/pages/organism-selector.astro rename to website/src/pages/organism-selector/[redirectTo].astro index 46159d465..c2e3a17b7 100644 --- a/website/src/pages/organism-selector.astro +++ b/website/src/pages/organism-selector/[redirectTo].astro @@ -1,8 +1,8 @@ --- -import { getConfiguredOrganisms } from '../config'; -import BaseLayout from '../layouts/BaseLayout.astro'; -import { routes } from '../routes'; -const redirectTo = Astro.url.searchParams.get('redirectTo'); +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', diff --git a/website/src/routes.ts b/website/src/routes.ts index 09cd91491..fbbc18f93 100644 --- a/website/src/routes.ts +++ b/website/src/routes.ts @@ -72,7 +72,7 @@ export const routes = { }, notFoundPage: () => `/404`, logout: () => '/logout', - organismSelectorPage: (redirectTo: string) => `/organism-selector?redirectTo=${redirectTo}`, + organismSelectorPage: (redirectTo: string) => `/organism-selector/${redirectTo}`, }; export type ClassOfSearchPageType = 'SEARCH' | 'MY_SEQUENCES';