From 1c9ea35b492e56c83b05d475c079e7672a8445e7 Mon Sep 17 00:00:00 2001 From: Fran McDade Date: Fri, 8 Nov 2024 17:17:43 +1000 Subject: [PATCH] feat: add banner to dev to indicate it is a dev site (#3147) --- .../Header/content/developmentModeBanner.mdx | 3 +++ .../Layout/components/Header/content/index.tsx | 1 + components/index.tsx | 1 + mdx-components.tsx | 11 +++++++++++ package-lock.json | 2 +- package.json | 2 +- .../dev/announcements/announcements.ts | 15 +++++++++++++++ site-config/anvil-portal/dev/config.ts | 2 ++ site-config/anvil-portal/prod/config.ts | 4 ++++ 9 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 components/Layout/components/Header/content/developmentModeBanner.mdx create mode 100644 components/Layout/components/Header/content/index.tsx create mode 100644 mdx-components.tsx create mode 100644 site-config/anvil-portal/dev/announcements/announcements.ts diff --git a/components/Layout/components/Header/content/developmentModeBanner.mdx b/components/Layout/components/Header/content/developmentModeBanner.mdx new file mode 100644 index 000000000..f62747d78 --- /dev/null +++ b/components/Layout/components/Header/content/developmentModeBanner.mdx @@ -0,0 +1,3 @@ + + This is a development site. To view the production site, please visit https://anvilproject.org/. + diff --git a/components/Layout/components/Header/content/index.tsx b/components/Layout/components/Header/content/index.tsx new file mode 100644 index 000000000..9d596408b --- /dev/null +++ b/components/Layout/components/Header/content/index.tsx @@ -0,0 +1 @@ +export { default as DevelopmentModeBanner } from "./developmentModeBanner.mdx"; diff --git a/components/index.tsx b/components/index.tsx index 3073b914f..66bff9b57 100644 --- a/components/index.tsx +++ b/components/index.tsx @@ -1,5 +1,6 @@ export { Alert } from "@databiosphere/findable-ui/lib/components/common/Alert/alert"; export { AnchorLink } from "@databiosphere/findable-ui/lib/components/common/AnchorLink/anchorLink"; +export { Banner } from "@databiosphere/findable-ui/lib/components/common/Banner/banner"; export { Breadcrumbs } from "@databiosphere/findable-ui/lib/components/common/Breadcrumbs/breadcrumbs"; export { CallToActionButton } from "@databiosphere/findable-ui/lib/components/common/Button/components/CallToActionButton/callToActionButton"; export { Card } from "@databiosphere/findable-ui/lib/components/common/Card/card"; diff --git a/mdx-components.tsx b/mdx-components.tsx new file mode 100644 index 000000000..02c3f2291 --- /dev/null +++ b/mdx-components.tsx @@ -0,0 +1,11 @@ +import { MDXComponents } from "mdx/types"; +import * as C from "./components"; +import { Link } from "./components/common/Link/link"; + +export function useMDXComponents(components: MDXComponents): MDXComponents { + return { + ...components, + Banner: C.Banner, + a: Link, + }; +} diff --git a/package-lock.json b/package-lock.json index 7b1bfb58c..f6946e23a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,6 @@ "@mui/icons-material": "^6.1.5", "@mui/material": "^6.1.5", "@next/mdx": "^14.1.0", - "@types/mdx": "^2.0.11", "copy-to-clipboard": "3.3.1", "echarts": "^5.3.3", "echarts-for-react": "^3.0.2", @@ -36,6 +35,7 @@ "@mui/types": "^7.2.18", "@next/eslint-plugin-next": "^14.1.0", "@types/jest": "^29.4.0", + "@types/mdx": "^2.0.11", "@types/node": "^20.10.0", "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", diff --git a/package.json b/package.json index 8b5bd7a97..3d626905d 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ "@mui/icons-material": "^6.1.5", "@mui/material": "^6.1.5", "@next/mdx": "^14.1.0", - "@types/mdx": "^2.0.11", "copy-to-clipboard": "3.3.1", "echarts": "^5.3.3", "echarts-for-react": "^3.0.2", @@ -45,6 +44,7 @@ "@mui/types": "^7.2.18", "@next/eslint-plugin-next": "^14.1.0", "@types/jest": "^29.4.0", + "@types/mdx": "^2.0.11", "@types/node": "^20.10.0", "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", diff --git a/site-config/anvil-portal/dev/announcements/announcements.ts b/site-config/anvil-portal/dev/announcements/announcements.ts new file mode 100644 index 000000000..c4986d583 --- /dev/null +++ b/site-config/anvil-portal/dev/announcements/announcements.ts @@ -0,0 +1,15 @@ +import { ALERT_PROPS } from "@databiosphere/findable-ui/lib/components/common/Banner/constants"; +import { + ComponentConfig, + ComponentsConfig, +} from "@databiosphere/findable-ui/lib/config/entities"; +import * as MDX from "../../../../components/Layout/components/Header/content"; + +export const announcements: ComponentsConfig = [ + { + component: MDX.DevelopmentModeBanner, + props: { + ...ALERT_PROPS, + }, + } as ComponentConfig, +]; diff --git a/site-config/anvil-portal/dev/config.ts b/site-config/anvil-portal/dev/config.ts index e086063b0..4667902b5 100644 --- a/site-config/anvil-portal/dev/config.ts +++ b/site-config/anvil-portal/dev/config.ts @@ -4,6 +4,7 @@ import * as C from "../../../components"; import { ROUTES } from "../../../routes/constants"; import { FLATTEN, VISIBLE } from "../../common/constants"; import { SiteConfig } from "../../common/entities"; +import { announcements } from "./announcements/announcements"; import { buildMenuItems } from "./common/utils"; import { CONSORTIA } from "./navigation/consortia"; import { FAQ } from "./navigation/faq"; @@ -47,6 +48,7 @@ export function makeConfig(browserUrl: string, portalUrl: string): SiteConfig { socials: socialMedia.socials, }, header: { + announcements, authenticationEnabled: false, logo: C.Logo({ alt: APP_TITLE, diff --git a/site-config/anvil-portal/prod/config.ts b/site-config/anvil-portal/prod/config.ts index 8ec207000..8f71b3091 100644 --- a/site-config/anvil-portal/prod/config.ts +++ b/site-config/anvil-portal/prod/config.ts @@ -13,4 +13,8 @@ const config: SiteConfig = { }, }; +if (config.layout.header.announcements) { + config.layout.header.announcements = undefined; +} + export default config;