Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add staging notice banner and test environment banners #2485

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ REACT_APP_BASE_PATH=''
REACT_APP_URL='http://127.0.0.1:3000'
REACT_APP_TITLE='MapRoulette'

# Set to 'production', 'staging', or 'local'
REACT_APP_ENVIRONMENT='production'

# Features flags. Set each to 'enabled' or 'disabled'.
REACT_APP_FEATURE_MOBILE_DEVICES='disabled'
REACT_APP_FEATURE_EDITOR_IMAGERY='disabled' # Send active imagery layer to editors
Expand Down
2 changes: 2 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import MobileNotSupported
import CheckForToken from './components/CheckForToken/CheckForToken'
import './components/Widgets/widget_registry'
import './App.scss'
import TestEnvironmentBanner from './components/TestEnvironmentBanner/TestEnvironmentBanner.jsx'

// Setup child components with necessary HOCs
const TopNav = withRouter(WithCurrentUser(Navbar))
Expand Down Expand Up @@ -102,6 +103,7 @@ export class App extends Component {
return (
<Fragment>
<TopNav />
<TestEnvironmentBanner />
<SystemNotices />
<FundraisingNotices />
<CheckForToken>
Expand Down
2 changes: 2 additions & 0 deletions src/components/AdminPane/AdminPane.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import EmailRequirementNotice from "./Manage/EmailRequirementNotice/EmailRequire
import HeadTitle from "../Head/Head";
import "./Manage/Widgets/widget_registry.js";
import "./AdminPane.scss";
import TestEnvironmentNotice from "./Manage/TestEnvironmentNotice/TestEnvironmentNotice";

/**
* AdminPane is the top-level component for administration functions. It has a
Expand Down Expand Up @@ -55,6 +56,7 @@ export class AdminPane extends Component {

return (
<Fragment>
<TestEnvironmentNotice />
<EmailRequirementNotice />
<div className="admin mr-bg-gradient-r-green-dark-blue mr-text-white">
<div className="admin-pane">
Expand Down
16 changes: 16 additions & 0 deletions src/components/AdminPane/Manage/TestEnvironmentNotice/Messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineMessages } from 'react-intl'

/**
* Internationalized messages for use with testEnvironmentNotice
*/
export default defineMessages({
title: {
id: 'Admin.testEnvironmentNotice.title',
defaultMessage: "Testing Something?",
},

description: {
id: 'Admin.testEnvironmentNotice.description',
defaultMessage: "Consider using the [MapRoulette Staging Website](https://staging.maproulette.org), a clone of MapRoulette often used for development, where you can create test challenges, projects, and similar tasks."
},
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import { FormattedMessage, injectIntl } from 'react-intl'
import messages from "./Messages";
import MarkdownContent from "../../../MarkdownContent/MarkdownContent";

const TestEnvironmentNotice = (props) => {
const environment = window.env.REACT_APP_ENVIRONMENT;

if(environment === 'production'){
return (
<ul className="mr-bg-gradient-b-blue-darker-blue-dark mr-text-white mr-w-full">
<li className="mr-flex mr-justify-between mr-items-center mr-w-full mr-py-2 mr-px-16">
<div className="mr-flex mr-space-x-4 mr-items-center">
<div className="mr-text-yellow mr-text-md mr-whitespace-nowrap">
<FormattedMessage {...messages.title} />
</div>
<MarkdownContent
markdown={props.intl.formatMessage(messages.description)}
className="mr-text-white mr-text-sm"
/>
</div>
</li>
</ul>
);
} else {
return null;
}

Check warning on line 27 in src/components/AdminPane/Manage/TestEnvironmentNotice/TestEnvironmentNotice.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/AdminPane/Manage/TestEnvironmentNotice/TestEnvironmentNotice.jsx#L26-L27

Added lines #L26 - L27 were not covered by tests
};

export default injectIntl(TestEnvironmentNotice);
15 changes: 15 additions & 0 deletions src/components/TestEnvironmentBanner/Messages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineMessages } from 'react-intl'

/**
* Internationalized messages for use with testEnvironmentBanner
*/
export default defineMessages({
stagingTitle: {
id: 'Admin.testEnvironmentBanner.stagingTitle',
defaultMessage: "You are in a MapRoulette Staging environment.",
},
localTitle: {
id: 'Admin.testEnvironmentBanner.localTitle',
defaultMessage: "You are in a MapRoulette Local environment.",
}
})
29 changes: 29 additions & 0 deletions src/components/TestEnvironmentBanner/TestEnvironmentBanner.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from "react";
import { FormattedMessage, injectIntl } from 'react-intl';
import messages from "./Messages";

const TestEnvironmentBanner = (props) => {
// Check the current environment
const environment = window.env.REACT_APP_ENVIRONMENT;

// Only render the banner if not in production
if (environment === 'production') return null;

return (
<ul className="mr-bg-gradient-b-blue-darker-blue-dark mr-text-white mr-w-full">
<li className="mr-flex mr-justify-between mr-items-center mr-w-full mr-py-2 mr-px-16">
<div className="mr-flex mr-space-x-4 mr-items-center">
<div className="mr-text-yellow mr-text-md mr-whitespace-nowrap">
{environment === 'staging' ?
<FormattedMessage {...messages.stagingTitle} />

Check warning on line 18 in src/components/TestEnvironmentBanner/TestEnvironmentBanner.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/TestEnvironmentBanner/TestEnvironmentBanner.jsx#L12-L18

Added lines #L12 - L18 were not covered by tests
: environment === 'local' ?
<FormattedMessage {...messages.localTitle} />
: null}

Check warning on line 21 in src/components/TestEnvironmentBanner/TestEnvironmentBanner.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/TestEnvironmentBanner/TestEnvironmentBanner.jsx#L20-L21

Added lines #L20 - L21 were not covered by tests
</div>
</div>
</li>
</ul>
);
};

export default injectIntl(TestEnvironmentBanner);