From 0d280ec1ed4022e0aeb00c24fc2d0142ff368623 Mon Sep 17 00:00:00 2001 From: "Anna (Anya) Parker" <50943381+anna-parker@users.noreply.github.com> Date: Thu, 12 Dec 2024 16:03:45 +0100 Subject: [PATCH] feat(website): allow each organism to not include all pages --- website/.prettierrc | 32 +++++++++---------- .../GenericAnalyzeSingleVariantPage.astro | 6 ++-- .../GenericCompareSideBySidePage.astro | 6 ++-- .../GenericCompareToBaselinePage.astro | 6 ++-- .../GenericCompareVariantsPage.astro | 6 ++-- .../GenericSequencingEffortsPage.astro | 6 ++-- website/src/views/routing.ts | 3 ++ 7 files changed, 34 insertions(+), 31 deletions(-) diff --git a/website/.prettierrc b/website/.prettierrc index 1b5bd8dd..27d7dec6 100644 --- a/website/.prettierrc +++ b/website/.prettierrc @@ -1,18 +1,18 @@ { - "printWidth": 120, - "tabWidth": 4, - "trailingComma": "all", - "semi": true, - "jsxSingleQuote": true, - "singleQuote": true, - "quoteProps": "consistent", - "plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss"], - "overrides": [ - { - "files": "*.astro", - "options": { - "parser": "astro" - } - } - ] + "printWidth": 120, + "tabWidth": 4, + "trailingComma": "all", + "semi": true, + "jsxSingleQuote": true, + "singleQuote": true, + "quoteProps": "consistent", + "plugins": ["prettier-plugin-astro", "prettier-plugin-tailwindcss"], + "overrides": [ + { + "files": "*.astro", + "options": { + "parser": "astro" + } + } + ] } diff --git a/website/src/components/views/analyzeSingleVariant/GenericAnalyzeSingleVariantPage.astro b/website/src/components/views/analyzeSingleVariant/GenericAnalyzeSingleVariantPage.astro index f7a800bf..bb2fd3ef 100644 --- a/website/src/components/views/analyzeSingleVariant/GenericAnalyzeSingleVariantPage.astro +++ b/website/src/components/views/analyzeSingleVariant/GenericAnalyzeSingleVariantPage.astro @@ -2,12 +2,11 @@ import SelectVariant from './SelectVariant.astro'; import { getDashboardsConfig } from '../../../config'; import SingleVariantOrganismPageLayout from '../../../layouts/OrganismPage/SingleVariantOrganismPageLayout.astro'; -import type { Organism } from '../../../types/Organism'; import { chooseGranularityBasedOnDateRange } from '../../../util/chooseGranularityBasedOnDateRange'; import { hasOnlyUndefinedValues } from '../../../util/hasOnlyUndefinedValues'; import { getLineageFilterConfigs, getLineageFilterFields } from '../../../views/View'; import { getLocationSubdivision } from '../../../views/helpers'; -import { type OrganismViewKey } from '../../../views/routing'; +import { type OrganismViewKey, type OrganismWithViewKey } from '../../../views/routing'; import { ServerSide } from '../../../views/serverSideRouting'; import { singleVariantViewKey } from '../../../views/viewKeys'; import ComponentHeadline from '../../ComponentHeadline.astro'; @@ -19,8 +18,9 @@ import GsPrevalenceOverTime from '../../genspectrum/GsPrevalenceOverTime.astro'; import { AnalyzeSingleVariantSelectorFallback } from '../../pageStateSelectors/FallbackElement'; import { SingleVariantPageStateSelector } from '../../pageStateSelectors/SingleVariantPageStateSelector'; +type OrganismViewCompareVariant = OrganismWithViewKey; interface Props { - organism: Organism; + organism: OrganismViewCompareVariant; } const { organism } = Astro.props; diff --git a/website/src/components/views/compareSideBySide/GenericCompareSideBySidePage.astro b/website/src/components/views/compareSideBySide/GenericCompareSideBySidePage.astro index bdb217aa..2fd525a4 100644 --- a/website/src/components/views/compareSideBySide/GenericCompareSideBySidePage.astro +++ b/website/src/components/views/compareSideBySide/GenericCompareSideBySidePage.astro @@ -1,10 +1,9 @@ --- import { getDashboardsConfig, getLapisUrl } from '../../../config'; import OrganismPageLayout from '../../../layouts/OrganismPage/OrganismPageLayout.astro'; -import { type Organism } from '../../../types/Organism'; import { chooseGranularityBasedOnDateRange } from '../../../util/chooseGranularityBasedOnDateRange'; import { getLineageFilterConfigs, getLineageFilterFields } from '../../../views/View'; -import { type OrganismViewKey } from '../../../views/routing'; +import { type OrganismViewKey, type OrganismWithViewKey } from '../../../views/routing'; import { ServerSide } from '../../../views/serverSideRouting'; import { compareSideBySideViewKey } from '../../../views/viewKeys'; import GsAggregate from '../../genspectrum/GsAggregate.astro'; @@ -13,8 +12,9 @@ import GsPrevalenceOverTime from '../../genspectrum/GsPrevalenceOverTime.astro'; import { CompareSideBySidePageStateSelector } from '../../pageStateSelectors/CompareSideBySidePageStateSelector'; import { CompareSideBySideSelectorFallback } from '../../pageStateSelectors/FallbackElement'; +type OrganismViewCompareVariant = OrganismWithViewKey; interface Props { - organism: Organism; + organism: OrganismViewCompareVariant; } const { organism } = Astro.props; diff --git a/website/src/components/views/compareToBaseline/GenericCompareToBaselinePage.astro b/website/src/components/views/compareToBaseline/GenericCompareToBaselinePage.astro index 6cf9158e..622dc0af 100644 --- a/website/src/components/views/compareToBaseline/GenericCompareToBaselinePage.astro +++ b/website/src/components/views/compareToBaseline/GenericCompareToBaselinePage.astro @@ -1,9 +1,8 @@ --- import { getDashboardsConfig } from '../../../config'; import SingleVariantOrganismPageLayout from '../../../layouts/OrganismPage/SingleVariantOrganismPageLayout.astro'; -import type { Organism } from '../../../types/Organism'; import { chooseGranularityBasedOnDateRange } from '../../../util/chooseGranularityBasedOnDateRange'; -import { type OrganismViewKey } from '../../../views/routing'; +import { type OrganismViewKey, type OrganismWithViewKey } from '../../../views/routing'; import { ServerSide } from '../../../views/serverSideRouting'; import { compareToBaselineViewKey } from '../../../views/viewKeys'; import ComponentsGrid from '../../ComponentsGrid.astro'; @@ -11,8 +10,9 @@ import GsPrevalenceOverTime from '../../genspectrum/GsPrevalenceOverTime.astro'; import { CompareVariantsToBaselineStateSelector } from '../../pageStateSelectors/CompareVariantsToBaselineStateSelector'; import { CompareToBaselineSelectorFallback } from '../../pageStateSelectors/FallbackElement'; +type OrganismViewCompareVariant = OrganismWithViewKey; interface Props { - organism: Organism; + organism: OrganismViewCompareVariant; } const { organism } = Astro.props; diff --git a/website/src/components/views/compareVariants/GenericCompareVariantsPage.astro b/website/src/components/views/compareVariants/GenericCompareVariantsPage.astro index 9e851053..e658339b 100644 --- a/website/src/components/views/compareVariants/GenericCompareVariantsPage.astro +++ b/website/src/components/views/compareVariants/GenericCompareVariantsPage.astro @@ -2,9 +2,8 @@ import SelectVariants from './SelectVariants.astro'; import { getDashboardsConfig } from '../../../config'; import SingleVariantOrganismPageLayout from '../../../layouts/OrganismPage/SingleVariantOrganismPageLayout.astro'; -import type { Organism } from '../../../types/Organism'; import { chooseGranularityBasedOnDateRange } from '../../../util/chooseGranularityBasedOnDateRange'; -import { type OrganismViewKey } from '../../../views/routing'; +import { type OrganismViewKey, type OrganismWithViewKey } from '../../../views/routing'; import { ServerSide } from '../../../views/serverSideRouting'; import { compareVariantsViewKey } from '../../../views/viewKeys'; import ComponentsGrid from '../../ComponentsGrid.astro'; @@ -13,8 +12,9 @@ import GsPrevalenceOverTime from '../../genspectrum/GsPrevalenceOverTime.astro'; import { CompareVariantsPageStateSelector } from '../../pageStateSelectors/CompareVariantsPageStateSelector'; import { CompareVariantsSelectorFallback } from '../../pageStateSelectors/FallbackElement'; +type OrganismViewCompareVariant = OrganismWithViewKey; interface Props { - organism: Organism; + organism: OrganismViewCompareVariant; } const { organism } = Astro.props; diff --git a/website/src/components/views/sequencingEfforts/GenericSequencingEffortsPage.astro b/website/src/components/views/sequencingEfforts/GenericSequencingEffortsPage.astro index 8048e0ed..3e0ec479 100644 --- a/website/src/components/views/sequencingEfforts/GenericSequencingEffortsPage.astro +++ b/website/src/components/views/sequencingEfforts/GenericSequencingEffortsPage.astro @@ -1,11 +1,10 @@ --- import { getDashboardsConfig } from '../../../config'; import SingleVariantOrganismPageLayout from '../../../layouts/OrganismPage/SingleVariantOrganismPageLayout.astro'; -import { type Organism } from '../../../types/Organism'; import { chooseGranularityBasedOnDateRange } from '../../../util/chooseGranularityBasedOnDateRange'; import { ComponentHeight } from '../../../views/OrganismConstants'; import { getLocationSubdivision } from '../../../views/helpers'; -import { type OrganismViewKey } from '../../../views/routing'; +import { type OrganismViewKey, type OrganismWithViewKey } from '../../../views/routing'; import { ServerSide } from '../../../views/serverSideRouting'; import { sequencingEffortsViewKey } from '../../../views/viewKeys'; import ComponentsGrid from '../../ComponentsGrid.astro'; @@ -14,8 +13,9 @@ import GsNumberSequencesOverTime from '../../genspectrum/GsNumberSequencesOverTi import { SequencingEffortsSelectorFallback } from '../../pageStateSelectors/FallbackElement'; import { SequencingEffortsPageStateSelector } from '../../pageStateSelectors/SequencingEffortsPageStateSelector'; +type OrganismViewCompareVariant = OrganismWithViewKey; interface Props { - organism: Organism; + organism: OrganismViewCompareVariant; } const { organism } = Astro.props; diff --git a/website/src/views/routing.ts b/website/src/views/routing.ts index 25909d48..9e0a27ed 100644 --- a/website/src/views/routing.ts +++ b/website/src/views/routing.ts @@ -66,6 +66,9 @@ export type OrganismViewKey = { }[ViewKey]; }[keyof ViewsMap]; +type OrganismExtractor = T extends `${infer O}.${ViewKey}` ? O : never; +export type OrganismWithViewKey = OrganismExtractor; + export class Routing { public readonly views; public readonly externalPages;