Skip to content

Commit

Permalink
Put bottom navigation items into own file (#1361)
Browse files Browse the repository at this point in the history
* put bottom navigation items into own file

* Automated code formatting

* update

* a

* fix circular dependencies

* Automated code formatting

* update

* update

* Automated code formatting

* address code review

* fixup

* update

* fix format after merge

---------

Co-authored-by: Loculus bot <bot@loculus.org>
  • Loading branch information
theosanderson and Loculus bot committed Mar 15, 2024
1 parent 42ff20d commit 0314777
Show file tree
Hide file tree
Showing 50 changed files with 120 additions and 117 deletions.
2 changes: 1 addition & 1 deletion website/src/components/DatasetCitations/DatasetList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import TableSortLabel from '@mui/material/TableSortLabel';
import { visuallyHidden } from '@mui/utils';
import { type FC, type MouseEvent, type ChangeEvent, useState, useMemo } from 'react';

import { routes } from '../../routes';
import { routes } from '../../routes/routes';
import type { Dataset } from '../../types/datasetCitation';

type Order = 'asc' | 'desc';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Edit/EditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type Dispatch, type FC, Fragment, type SetStateAction, useMemo, useRef,
import { EditableDataRow, ProcessedDataRow } from './DataRow.tsx';
import type { Row } from './InputField.tsx';
import { getClientLogger } from '../../clientLogger.ts';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import { backendClientHooks } from '../../services/serviceHooks.ts';
import { ACCESSION_FIELD } from '../../settings.ts';
import type { MetadataRecord, ProcessingAnnotationSourceType, SequenceEntryToEdit } from '../../types/backend.ts';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type FC } from 'react';

import { routes } from '../../routes';
import { routes } from '../../routes/routes';

type GroupSelectorProps = {
groupNames: string[];
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Navigation/Navigation.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { SandwichMenu } from './SandwichMenu.tsx';
import { cleanOrganism } from './cleanOrganism';
import { navigationItems } from '../../routes';
import { navigationItems } from '../../routes/navigationItems';
import { getAuthUrl } from '../../utils/getAuthUrl';
const { organism } = cleanOrganism(Astro.params.organism);
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Navigation/OrganismSelector.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { cleanOrganism } from './cleanOrganism';
import { type Organism } from '../../config';
import { routes } from '../../routes';
import { routes } from '../../routes/routes';
import IwwaArrowDown from '~icons/iwwa/arrow-down';
const { knownOrganisms, organism: originalOrganism } = cleanOrganism(Astro.params.organism);
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Navigation/SandwichMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { FC } from 'react';

import type { Organism } from '../../config.ts';
import { useOffCanvas } from '../../hooks/useOffCanvas';
import { navigationItems } from '../../routes.ts';
import { navigationItems } from '../../routes/navigationItems';
import { OffCanvasOverlay } from '../OffCanvasOverlay';
import { SandwichIcon } from '../SandwichIcon';

Expand Down
2 changes: 1 addition & 1 deletion website/src/components/ReviewPage/ReviewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type ChangeEvent, type FC, useState } from 'react';

import { ReviewCard } from './ReviewCard.tsx';
import { useSubmissionOperations } from '../../hooks/useSubmissionOperations.ts';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import {
approveAllDataScope,
awaitingApprovalStatus,
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/SearchPage/SearchForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { beforeEach, describe, expect, test, vi } from 'vitest';

import { SearchForm } from './SearchForm';
import { testConfig, testOrganism } from '../../../vitest.setup.ts';
import { routes, SEARCH } from '../../routes.ts';
import { routes, SEARCH } from '../../routes/routes.ts';
import type { MetadataFilter } from '../../types/config.ts';
import type { ReferenceGenomesSequenceNames } from '../../types/referencesGenomes.ts';
import type { ClientConfig } from '../../types/runtimeConfig.ts';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/SearchPage/SearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { PangoLineageField } from './fields/PangoLineageField';
import { getClientLogger } from '../../clientLogger.ts';
import { getLapisUrl } from '../../config.ts';
import { useOffCanvas } from '../../hooks/useOffCanvas';
import { routes, navigateToSearchLikePage, type ClassOfSearchPageType } from '../../routes.ts';
import { routes, navigateToSearchLikePage, type ClassOfSearchPageType } from '../../routes/routes.ts';
import type { AccessionFilter, MetadataFilter, MutationFilter } from '../../types/config.ts';
import type { ReferenceGenomesSequenceNames } from '../../types/referencesGenomes.ts';
import type { ClientConfig } from '../../types/runtimeConfig.ts';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/SearchPage/SearchPagination.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Pagination as MUIPagination } from '@mui/material';
import type { FC } from 'react';

import { navigateToSearchLikePage, type ClassOfSearchPageType } from '../../routes';
import { navigateToSearchLikePage, type ClassOfSearchPageType } from '../../routes/routes';
import type { AccessionFilter, MetadataFilter, MutationFilter } from '../../types/config.ts';
import type { OrderBy } from '../../types/lapis.ts';

Expand Down
2 changes: 1 addition & 1 deletion website/src/components/SearchPage/Table.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { capitalCase } from 'change-case';
import type { FC, ReactElement } from 'react';

import { routes, navigateToSearchLikePage, type ClassOfSearchPageType } from '../../routes.ts';
import { routes, navigateToSearchLikePage, type ClassOfSearchPageType } from '../../routes/routes.ts';
import type { AccessionFilter, MetadataFilter, MutationFilter, Schema } from '../../types/config.ts';
import type { OrderBy } from '../../types/lapis.ts';
import MdiTriangle from '~icons/mdi/triangle';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type FC } from 'react';
import { toast } from 'react-toastify';

import { routes } from '../../routes';
import { routes } from '../../routes/routes';
import { backendClientHooks } from '../../services/serviceHooks';
import type { ClientConfig } from '../../types/runtimeConfig';
import { createAuthorizationHeader } from '../../utils/createAuthorizationHeader';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import { getLatestAccessionVersion } from './getTableData';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import { type SequenceEntryHistory, siloVersionStatuses } from '../../types/lapis';
import { getAccessionVersionString } from '../../utils/extractAccessionVersion';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { sentenceCase } from 'change-case';
import { routes } from '../../routes';
import { routes } from '../../routes/routes';
import { type SequenceEntryHistory } from '../../types/lapis';
import { getAccessionVersionString } from '../../utils/extractAccessionVersion';
import { getVersionStatusColor } from '../../utils/getVersionStatusColor';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { RevokeButton } from './RevokeButton';
import { SequencesContainer } from './SequencesContainer';
import { type TableDataEntry } from './getTableData';
import { getReferenceGenomes, getRuntimeConfig } from '../../config';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import { GroupManagementClient } from '../../services/groupManagementClient';
import { type DataUseTermsHistoryEntry } from '../../types/backend';
import { type Group } from '../../types/backend.ts';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Submission/DataUploadForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { type FormEvent, useState, useRef, useEffect, useCallback, type ElementT

import { DateChangeModal } from './DateChangeModal';
import { getClientLogger } from '../../clientLogger.ts';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import { backendApi } from '../../services/backendApi.ts';
import { backendClientHooks } from '../../services/serviceHooks.ts';
import {
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Submission/RevisionForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type FC } from 'react';

import { DataUploadForm } from './DataUploadForm.tsx';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import { type Group } from '../../types/backend.ts';
import type { ClientConfig } from '../../types/runtimeConfig.ts';
import { ManagedErrorFeedback, useErrorFeedbackState } from '../common/ManagedErrorFeedback';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/Submission/SubmissionForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type FC } from 'react';

import { DataUploadForm } from './DataUploadForm.tsx';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import { type Group } from '../../types/backend.ts';
import type { ClientConfig } from '../../types/runtimeConfig.ts';
import { ManagedErrorFeedback, useErrorFeedbackState } from '../common/ManagedErrorFeedback';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/User/GroupCreationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { type ComponentProps, type FC, type FormEvent, type PropsWithChildren, u

import { listOfCountries } from './listOfCountries.ts';
import { useGroupCreation } from '../../hooks/useGroupOperations.ts';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import { type ClientConfig } from '../../types/runtimeConfig.ts';
import { ErrorFeedback } from '../ErrorFeedback.tsx';
import { withQueryProvider } from '../common/withQueryProvider.tsx';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/User/GroupPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type FC, type FormEvent, useRef, useState } from 'react';

import { useGroupPageHooks } from '../../hooks/useGroupOperations.ts';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import type { Address, GroupDetails } from '../../types/backend.ts';
import { type ClientConfig } from '../../types/runtimeConfig.ts';
import { ConfirmationDialog } from '../DeprecatedConfirmationDialog.tsx';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/User/ListOfGroupsOfUser.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type FC, useState } from 'react';

import { useRemoveFromGroup } from '../../hooks/useGroupOperations.ts';
import { routes } from '../../routes.ts';
import { routes } from '../../routes/routes.ts';
import type { Group } from '../../types/backend.ts';
import type { ClientConfig } from '../../types/runtimeConfig.ts';
import { displayConfirmationDialog } from '../ConfirmationDialog.tsx';
Expand Down
2 changes: 1 addition & 1 deletion website/src/components/User/UserPage.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { ListOfGroupsOfUser } from './ListOfGroupsOfUser.tsx';
import { getRuntimeConfig } from '../../config';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { routes } from '../../routes';
import { routes } from '../../routes/routes';
import { GroupManagementClient } from '../../services/groupManagementClient';
import { KeycloakClientManager } from '../../utils/KeycloakClientManager';
import { getAccessToken } from '../../utils/getAccessToken';
Expand Down
2 changes: 1 addition & 1 deletion website/src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Navigation from '../components/Navigation/Navigation.astro';
import OrganismSelector from '../components/Navigation/OrganismSelector.astro';
import { getWebsiteConfig } from '../config';
import 'react-toastify/dist/ReactToastify.css';
import { navigationItems } from '../routes';
import { navigationItems } from '../routes/navigationItems';
const websiteConfig = getWebsiteConfig();
const { name: websiteName, logo } = websiteConfig;
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/[organism]/my_sequences.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
import BaseLayout from '../../layouts/BaseLayout.astro';
import { routes } from '../../routes';
import { routes } from '../../routes/routes';
import { GroupManagementClient } from '../../services/groupManagementClient';
import { getAccessToken } from '../../utils/getAccessToken';
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/[organism]/my_sequences/[group].astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SearchPagination } from '../../../components/SearchPage/SearchPaginatio
import { Table } from '../../../components/SearchPage/Table';
import ErrorBox from '../../../components/common/ErrorBox.astro';
import BaseLayout from '../../../layouts/BaseLayout.astro';
import { MY_SEQUENCES } from '../../../routes';
import { MY_SEQUENCES } from '../../../routes/routes';
import { GroupManagementClient } from '../../../services/groupManagementClient';
import { pageSize } from '../../../settings';
import { getAccessToken } from '../../../utils/getAccessToken';
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/[organism]/search/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { SearchPagination } from '../../../components/SearchPage/SearchPaginatio
import { Table } from '../../../components/SearchPage/Table';
import ErrorBox from '../../../components/common/ErrorBox.astro';
import BaseLayout from '../../../layouts/BaseLayout.astro';
import { SEARCH } from '../../../routes';
import { SEARCH } from '../../../routes/routes';
import { pageSize } from '../../../settings';
import { processParametersAndFetchSearch } from '../../../utils/processParametersAndFetchSearch';
const {
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/[organism]/submission/index.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { cleanOrganism } from '../../../components/Navigation/cleanOrganism';
import BaseLayout from '../../../layouts/BaseLayout.astro';
import { routes } from '../../../routes';
import { routes } from '../../../routes/routes';
const { organism } = cleanOrganism(Astro.params.organism);
---
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { getConfiguredOrganisms, getWebsiteConfig } from '../config';
import BaseLayout from '../layouts/BaseLayout.astro';
import { routes } from '../routes';
import { routes } from '../routes/routes';
const websiteConfig = getWebsiteConfig();
const { name: websiteName } = websiteConfig;
---
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/organism-selector/[redirectTo].astro
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
import { getConfiguredOrganisms } from '../../config';
import BaseLayout from '../../layouts/BaseLayout.astro';
import { routes } from '../../routes';
import { routes } from '../../routes/routes';
const redirectTo = Astro.params.redirectTo;
const purposes: { [key: string]: string } = {
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/seq/[accessionVersion].fa/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { err, type Result } from 'neverthrow';

import { getConfiguredOrganisms } from '../../../config';
import { getReferenceGenomes } from '../../../config.ts';
import { routes } from '../../../routes.ts';
import { routes } from '../../../routes/routes.ts';
import { LapisClient } from '../../../services/lapisClient.ts';
import { type ProblemDetail } from '../../../types/backend.ts';
import { parseAccessionVersionFromString } from '../../../utils/extractAccessionVersion.ts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Result } from 'neverthrow';

import { getTableData, type TableDataEntry } from '../../../components/SequenceDetailsPage/getTableData.ts';
import { getSchema } from '../../../config.ts';
import { routes } from '../../../routes.ts';
import { routes } from '../../../routes/routes.ts';
import { BackendClient } from '../../../services/backendClient.ts';
import { LapisClient } from '../../../services/lapisClient.ts';
import type { DataUseTermsHistoryEntry, ProblemDetail } from '../../../types/backend.ts';
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/seq/[accessionVersion]/versions.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { sentenceCase } from 'change-case';
import ErrorBox from '../../../components/common/ErrorBox.astro';
import { getConfiguredOrganisms } from '../../../config';
import BaseLayout from '../../../layouts/BaseLayout.astro';
import { routes } from '../../../routes';
import { routes } from '../../../routes/routes';
import { LapisClient } from '../../../services/lapisClient';
import {
extractAccessionVersion,
Expand Down
23 changes: 23 additions & 0 deletions website/src/routes/bottomNavigationItems.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { routes } from './routes.ts';
export const bottomNavigationItems = [
{
text: 'About',
path: routes.aboutPage(),
},
{
text: 'Docs',
path: 'https://loculus-project.github.io/loculus/',
},
{
text: 'API docs',
path: routes.apiDocumentationPage(),
},
{
text: 'Governance',
path: routes.governancePage(),
},
{
text: 'Status',
path: routes.statusPage(),
},
];
46 changes: 46 additions & 0 deletions website/src/routes/navigationItems.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { bottomNavigationItems } from './bottomNavigationItems.ts';
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('submit'),
},
...(isLoggedIn
? [{ text: 'My account', path: routes.userOverviewPage() }]
: [{ text: 'Login', path: loginUrl! }]),
{
text: 'Datasets',
path: routes.datasetsPage(),
},
];
}

return [
{
text: 'Browse',
path: routes.searchPage(organism),
},
{
text: 'Submit',
path: routes.submissionPage(organism),
},
...(isLoggedIn
? [{ text: 'My account', path: routes.userOverviewPage(organism) }]
: [{ text: 'Login', path: loginUrl! }]),
{
text: 'Datasets',
path: routes.datasetsPage(),
},
];
}
Loading

0 comments on commit 0314777

Please sign in to comment.