Skip to content

Commit

Permalink
Merge pull request #168 from microbiomedata/issue-166-dev-warning-banner
Browse files Browse the repository at this point in the history
Add dev site warning banner; display it on GH Pages site
  • Loading branch information
eecavanna authored Sep 5, 2024
2 parents 8ef6f85 + 3119fbe commit bb61975
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:

- name: Build project
run: npm run build -- --mode staging
env:
VITE_SHOW_DEV_SITE_WARNING: "true"

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
Expand Down
22 changes: 22 additions & 0 deletions src/components/DevelopmentSiteWarning/DevelopmentSiteWarning.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import config from "../../config";
import Banner from "../Banner/Banner";
import { IonLabel } from "@ionic/react";

const { SHOW_DEV_SITE_WARNING } = config;

const DevelopmentSiteWarning: React.FC = () => {
if (!SHOW_DEV_SITE_WARNING) {
return null;
}

return (
<Banner color="warning">
<IonLabel className="ion-no-margin ion-text-center">
<b>Development Site</b> Do not enter any real data here.
</IonLabel>
</Banner>
);
};

export default DevelopmentSiteWarning;
4 changes: 3 additions & 1 deletion src/components/ThemedToolbar/ThemedToolbar.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from "react";
import { IonIcon, IonProgressBar, IonToolbar } from "@ionic/react";
import { cloudOfflineOutline } from "ionicons/icons";
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
import { useNetworkStatus } from "../../NetworkStatus";
import DevelopmentSiteWarning from "../DevelopmentSiteWarning/DevelopmentSiteWarning";

import classes from "./ThemedToolbar.module.css";
import { useIsFetching, useIsMutating } from "@tanstack/react-query";

interface ThemedToolbarProps extends React.ComponentProps<typeof IonToolbar> {}

Expand All @@ -24,6 +25,7 @@ const ThemedToolbar: React.FC<ThemedToolbarProps> = (props) => {
</div>
</IonToolbar>
)}
<DevelopmentSiteWarning />
<IonToolbar {...rest} className={classes.themedBackground}>
{children}
</IonToolbar>
Expand Down
6 changes: 6 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface Config {
APP_VERSION: typeof env.FIELD_NOTES_VERSION_NUMBER;
APP_BUILD: typeof env.FIELD_NOTES_BUILD_NUMBER;
NMDC_SERVER_API_URL: string;
SHOW_DEV_SITE_WARNING: boolean;
SUPPORT_EMAIL: string;
}

Expand Down Expand Up @@ -46,6 +47,11 @@ const config: Config = {
NMDC_SERVER_API_URL:
env.VITE_NMDC_SERVER_API_URL || "https://data-dev.microbiomedata.org",

/**
* Whether to show a warning that the user is on a development site.
*/
SHOW_DEV_SITE_WARNING: env.VITE_SHOW_DEV_SITE_WARNING === "true",

/**
* Support email address.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/pages/WelcomePage/WelcomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import {
IonCardTitle,
IonAlert,
useIonRouter,
IonHeader,
} from "@ionic/react";
import { logIn } from "ionicons/icons";
import Logo from "../../components/Logo/Logo";
import paths from "../../paths";
import classes from "./WelcomePage.module.css";
import { initiateLogin } from "../../auth";
import DevelopmentSiteWarning from "../../components/DevelopmentSiteWarning/DevelopmentSiteWarning";

const WelcomePage: React.FC = () => {
const router = useIonRouter();
Expand All @@ -29,6 +31,9 @@ const WelcomePage: React.FC = () => {

return (
<IonPage>
<IonHeader>
<DevelopmentSiteWarning />
</IonHeader>
<IonContent
fullscreen
className={`ion-padding ${classes.themedBackground}`}
Expand Down

0 comments on commit bb61975

Please sign in to comment.