Skip to content

Commit 7f34008

Browse files
Fran McDadeFran McDade
Fran McDade
authored and
Fran McDade
committed
feat: update anvil catalog header to latest findable-ui version (#4120)
1 parent b34f6e1 commit 7f34008

File tree

23 files changed

+786
-126
lines changed

23 files changed

+786
-126
lines changed

explorer/package-lock.json

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

explorer/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"check-system-status:anvil-cmg": "esrun e2e/anvil/anvil-check-system-status.ts"
3838
},
3939
"dependencies": {
40-
"@databiosphere/findable-ui": "9.1.0",
40+
"@databiosphere/findable-ui": "10.1.1",
4141
"@emotion/react": "11.11.1",
4242
"@emotion/styled": "11.11.0",
4343
"@mdx-js/loader": "^3.0.1",

explorer/pages/_app.tsx

+15-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,16 @@ import { SystemStatusProvider } from "@databiosphere/findable-ui/lib/providers/s
1818
import { createAppTheme } from "@databiosphere/findable-ui/lib/theme/theme";
1919
import { DataExplorerError } from "@databiosphere/findable-ui/lib/types/error";
2020
import { ThemeProvider as EmotionThemeProvider } from "@emotion/react";
21-
import { CssBaseline } from "@mui/material";
22-
import { ThemeProvider } from "@mui/material/styles";
21+
import { createTheme, CssBaseline, Theme, ThemeProvider } from "@mui/material";
22+
import { createBreakpoints } from "@mui/system";
23+
import { deepmerge } from "@mui/utils";
2324
import { config } from "app/config/config";
2425
import { FEATURES } from "app/shared/entities";
2526
import { NextPage } from "next";
2627
import type { AppProps } from "next/app";
2728
import { useEffect } from "react";
2829
import TagManager from "react-gtm-module";
30+
import { BREAKPOINTS } from "../site-config/common/constants";
2931

3032
const FEATURE_FLAGS = Object.values(FEATURES);
3133
const SESSION_TIMEOUT = 15 * 60 * 1000; // 15 minutes
@@ -71,7 +73,17 @@ function MyApp({ Component, pageProps }: AppPropsWithComponent): JSX.Element {
7173
<AuthProvider sessionTimeout={SESSION_TIMEOUT}>
7274
<LayoutStateProvider>
7375
<AppLayout>
74-
<Header {...header} />
76+
<ThemeProvider
77+
theme={(theme: Theme): Theme =>
78+
createTheme(
79+
deepmerge(theme, {
80+
breakpoints: createBreakpoints(BREAKPOINTS),
81+
})
82+
)
83+
}
84+
>
85+
<Header {...header} />
86+
</ThemeProvider>
7587
<ExploreStateProvider entityListType={entityListType}>
7688
<FileManifestStateProvider>
7789
<Main>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
export const EXPLORER_ROUTES = {
2+
DATASETS: "/datasets",
3+
};
4+
5+
export const PORTAL_ROUTES = {
6+
CONSORTIA: "/consortia",
7+
EVENTS: "/events",
8+
FAQ: "/faq",
9+
GUIDES: "/guides",
10+
HELP: "/help",
11+
LEARN: "/learn",
12+
NEWS: "/news",
13+
OVERVIEW: "/overview",
14+
PRIVACY: "/privacy",
15+
SEARCH: "/search",
16+
TEAM: "/team",
17+
};
18+
19+
export const ROUTES = {
20+
CONSORTIA: "/consortia",
21+
STUDIES: "/studies",
22+
WORKSPACES: "/workspaces",
23+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { NavLinkItem } from "@databiosphere/findable-ui/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation";
2+
import { VISIBLE } from "../../../common/constants";
3+
import { Parameter, replaceParameters } from "../../../common/utils";
4+
5+
/**
6+
* Returns configured menu item for the navigation.
7+
* @param menuItem - Navigation menu item.
8+
* @param parameter - Parameter.
9+
* @returns menu item.
10+
*/
11+
export function buildNavigationItem(
12+
menuItem: NavLinkItem,
13+
parameter: Parameter
14+
): NavLinkItem {
15+
return {
16+
...menuItem,
17+
menuItems: buildMenuItems(menuItem.menuItems, parameter),
18+
url: replaceParameters(menuItem.url, parameter),
19+
};
20+
}
21+
22+
/**
23+
* Returns configured menu items for the menu item.
24+
* @param menuItems - Menu items.
25+
* @param parameter - Parameter.
26+
* @param isSubMenu - Sub menu items.
27+
* @returns menu items.
28+
*/
29+
function buildMenuItems(
30+
menuItems: NavLinkItem[] | undefined,
31+
parameter: Parameter,
32+
isSubMenu = false
33+
): NavLinkItem[] | undefined {
34+
return menuItems?.map(({ menuItems, url, visible, ...menuItem }) => ({
35+
...menuItem,
36+
menuItems: buildMenuItems(menuItems, parameter, true),
37+
url: replaceParameters(url, parameter),
38+
visible: isSubMenu ? visible ?? VISIBLE.SM_DOWN : visible,
39+
}));
40+
}

explorer/site-config/anvil-catalog/dev/config.ts

+8-112
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
import { ANCHOR_TARGET } from "@databiosphere/findable-ui/lib/components/Links/common/entities";
21
import * as C from "../../../app/components/index";
3-
import { socialMedia, SOCIALS } from "../../anvil/dev/socialMedia";
2+
import { socialMedia } from "../../anvil/dev/socialMedia";
43
import { SiteConfig } from "../../common/entities";
54
import {
65
ANVIL_CATALOG_CATEGORY_KEY,
76
ANVIL_CATALOG_CATEGORY_LABEL,
87
} from "../category";
8+
import { PORTAL_ROUTES, ROUTES } from "./common/constants";
99
import { exportConfig } from "./export/export";
1010
import { consortiaEntityConfig } from "./index/consortiaEntityConfig";
1111
import { studiesEntityConfig } from "./index/studiesEntityConfig";
1212
import { workspaceEntityConfig } from "./index/workspaceEntityConfig";
13+
import { buildNavigation as buildFooterNavigation } from "./layout/footer/navigation/navigation";
14+
import { buildNavigation } from "./layout/header/navigation/navigation";
1315

1416
// Template constants
1517
const APP_TITLE = "AnVIL Dataset Catalog";
1618
const BROWSER_URL = "https://anvilproject.dev.clevercanary.com";
1719
const EXPLORER_URL = "https://explore.anvilproject.dev.clevercanary.com";
18-
const HOME_PAGE_PATH = "/consortia";
20+
const HOME_PAGE_PATH = ROUTES.CONSORTIA;
1921
const PORTAL_URL = "https://anvilproject.dev.clevercanary.com";
2022
const SLOGAN = "NHGRI Analysis Visualization and Informatics Lab-space";
2123

@@ -87,16 +89,7 @@ export function makeConfig(
8789
layout: {
8890
footer: {
8991
Branding: C.ANVILBranding({ portalURL: undefined }),
90-
navLinks: [
91-
{
92-
label: "Help",
93-
url: `${portalUrl}/help`,
94-
},
95-
{
96-
label: "Privacy",
97-
url: `${portalUrl}/privacy`,
98-
},
99-
],
92+
navLinks: buildFooterNavigation(portalUrl),
10093
socials: socialMedia.socials,
10194
},
10295
header: {
@@ -107,106 +100,9 @@ export function makeConfig(
107100
link: portalUrl,
108101
src: "/images/logoAnvil.png",
109102
}),
110-
navigation: [
111-
undefined,
112-
[
113-
{
114-
label: "Overview",
115-
url: `${portalUrl}/overview`,
116-
},
117-
{
118-
label: "Learn",
119-
url: `${portalUrl}/learn`,
120-
},
121-
{
122-
label: "Datasets",
123-
menuItems: [
124-
{
125-
description:
126-
"An open-access view of studies, workspaces, and consortia.",
127-
label: "Catalog",
128-
url: HOME_PAGE_PATH,
129-
},
130-
{
131-
description:
132-
"Build, download, and export cross-study cohorts of open and managed access data.",
133-
label: C.LabelIconMenuItem({
134-
iconFontSize: "small",
135-
label: "Explorer",
136-
}),
137-
target: ANCHOR_TARGET.BLANK,
138-
url: `${explorerUrl}/datasets`,
139-
},
140-
],
141-
url: "",
142-
},
143-
{
144-
label: "Consortia",
145-
url: `${portalUrl}/consortia`,
146-
},
147-
{
148-
label: "More",
149-
menuItems: [
150-
{
151-
label: "News",
152-
url: `${portalUrl}/news`,
153-
},
154-
{
155-
label: "Events",
156-
url: `${portalUrl}/events`,
157-
},
158-
{
159-
label: "Team",
160-
url: `${portalUrl}/team`,
161-
},
162-
{
163-
label: "FAQ",
164-
url: `${portalUrl}/faq`,
165-
},
166-
{
167-
label: "Help",
168-
url: `${portalUrl}/help`,
169-
},
170-
{
171-
label: "Follow Us",
172-
menuItems: [
173-
{
174-
...SOCIALS.DISCOURSE,
175-
icon: C.DiscourseIcon({ fontSize: "small" }),
176-
target: ANCHOR_TARGET.BLANK,
177-
},
178-
{
179-
...SOCIALS.X,
180-
icon: C.XIcon({ fontSize: "small" }),
181-
target: ANCHOR_TARGET.BLANK,
182-
},
183-
{
184-
...SOCIALS.YOUTUBE,
185-
icon: C.YouTubeIcon({ fontSize: "small" }),
186-
target: ANCHOR_TARGET.BLANK,
187-
},
188-
{
189-
...SOCIALS.GITHUB,
190-
icon: C.GitHubIcon({ fontSize: "small" }),
191-
target: ANCHOR_TARGET.BLANK,
192-
},
193-
{
194-
...SOCIALS.SLACK,
195-
icon: C.SlackIcon({ fontSize: "small" }),
196-
target: ANCHOR_TARGET.BLANK,
197-
},
198-
],
199-
url: "",
200-
visible: { lg: false, sm: false, xs: false },
201-
},
202-
],
203-
url: "",
204-
},
205-
],
206-
undefined,
207-
],
103+
navigation: buildNavigation(portalUrl, explorerUrl),
208104
searchEnabled: true,
209-
searchURL: `${portalUrl}/search`,
105+
searchURL: `${portalUrl}${PORTAL_ROUTES.SEARCH}`,
210106
slogan: SLOGAN,
211107
socialMedia,
212108
},
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { NavLinkItem } from "@databiosphere/findable-ui/lib/components/Layout/components/Header/components/Content/components/Navigation/navigation";
2+
import { PORTAL_ROUTES } from "../../../common/constants";
3+
import { buildNavigationItem } from "../../../common/utils";
4+
import { HELP } from "../../header/navigation/navigationItem/help";
5+
import { PRIVACY } from "../../header/navigation/navigationItem/privacy";
6+
7+
/**
8+
* Returns configured footer navigation.
9+
* @param portalUrl - Portal URL.
10+
* @returns navigation.
11+
*/
12+
export function buildNavigation(portalUrl: string): NavLinkItem[] {
13+
return [
14+
buildNavigationItem(HELP, { help: PORTAL_ROUTES.HELP, portalUrl }),
15+
buildNavigationItem(PRIVACY, {
16+
portalUrl,
17+
privacy: PORTAL_ROUTES.PRIVACY,
18+
}),
19+
];
20+
}

0 commit comments

Comments
 (0)