From a4340adff681afc99ed3190b21643ad89b8235d8 Mon Sep 17 00:00:00 2001 From: Lukas Brabec Date: Feb 09 2021 17:54:24 +0000 Subject: Show info box when using staging instance --- diff --git a/public/env.js b/public/env.js index f805453..d54c7d9 100644 --- a/public/env.js +++ b/public/env.js @@ -9,3 +9,4 @@ window.env['PACKAGER_DASHBOARD_API'] = window.env.API + 'packager_dashboard/' window.env['RELEASES_API'] = window.env.API + 'releases' window.env['LANDINGPAGE_API'] = window.env.API + 'landing_page' window.env['CACHING_INFO_API'] = window.env.API + 'packager_dashboard_caching' +window.env['DEPLOYMENT_ENV'] = window.env.API + 'deployment_env' diff --git a/src/App.css b/src/App.css index 8935c64..1cd89cf 100644 --- a/src/App.css +++ b/src/App.css @@ -274,3 +274,7 @@ svg:not(:root) { text-align: center; vertical-align: top; } + +.w-400px { + width: 400px; +} diff --git a/src/actions/reduxActions.js b/src/actions/reduxActions.js index 488a75c..3a61bbd 100644 --- a/src/actions/reduxActions.js +++ b/src/actions/reduxActions.js @@ -189,3 +189,24 @@ export const setServerError = payload => ({ type: ActionTypes.SET_SERVER_ERROR, payload: payload }) + +export const loadEnvironment = payload => dispatch => { + dispatch({ + type: ActionTypes.LOAD_ENVIRONMENT, + payload: payload + }) + + fetch(window.env.DEPLOYMENT_ENV) + .then(blob => blob.json()) + .then(data => { + const deployment_env = data.deployment_env + + dispatch({ + type: ActionTypes.LOAD_ENVIRONMENT_RESP, + payload: deployment_env + }) + }) + .catch((error) => { + console.error('Error:', error); + }); +} diff --git a/src/components/Dashboard.js b/src/components/Dashboard.js index 1b36ee7..7ba0e93 100644 --- a/src/components/Dashboard.js +++ b/src/components/Dashboard.js @@ -2,6 +2,7 @@ import React, { Component } from "react" import DashboardLayout from "./DashboardLayout" import DashboardNonPackager from "./DashboardNonPackager" import Widget from "./Widget" +import StgAlert from "./StgAlert" import Stats from "./Stats" import Timeline from "./Timeline" import ItemsInfo from "./ItemsInfo" @@ -10,7 +11,7 @@ import DashboardLoading from "./DashboardLoading" import ModalNetwork from "./ModalNetwork" import * as R from "ramda" import { connect } from "react-redux" -import { setUser, loadUser, loadOptions, loadReleases, loadSchedule, loadCachingInfo } from "../actions/reduxActions" +import { setUser, loadUser, loadOptions, loadReleases, loadSchedule, loadCachingInfo, loadEnvironment } from "../actions/reduxActions" import * as U from "../utils" import { showAllOptions } from "../reducers" @@ -28,6 +29,7 @@ class Dashboard extends Component { } componentDidMount() { + this.props.dispatch(loadEnvironment()) this.props.dispatch(loadReleases()) this.props.dispatch(loadSchedule()) this.props.dispatch(loadCachingInfo()) @@ -158,6 +160,7 @@ class Dashboard extends Component { return ( + { - const { user_data, fasuser, options, releases, caching_info, server_error } = state + const { user_data, fasuser, options, releases, caching_info, server_error, environment } = state return { user_data, @@ -196,6 +199,7 @@ const mapStateToProps = (state) => { releases, caching_info, server_error, + environment, } } diff --git a/src/components/EntryForm.js b/src/components/EntryForm.js index d3f7a4a..4258048 100644 --- a/src/components/EntryForm.js +++ b/src/components/EntryForm.js @@ -2,8 +2,10 @@ import React, { Component, createRef } from "react" import { Redirect } from "react-router" import Cookies from "universal-cookie" import logo from "../logo.svg" +import Logo from "./Logo" +import StgAlert from "./StgAlert" import Footer from "./Footer" -import { setUser } from "../actions/reduxActions" +import { setUser, loadEnvironment } from "../actions/reduxActions" import { connect } from "react-redux" const cookies = new Cookies() @@ -21,6 +23,8 @@ class EntryForm extends Component { } componentDidMount() { + this.props.dispatch(loadEnvironment()) + if (cookies.get("fasusername") !== undefined) { console.log("found fasuser in cookies...") this.props.dispatch(setUser(cookies.get("fasusername"))) @@ -35,7 +39,7 @@ class EntryForm extends Component { return (
- Fedora Packager Dashboard +
@@ -58,6 +62,7 @@ class EntryForm extends Component { Need help?
+
diff --git a/src/components/Logo.js b/src/components/Logo.js new file mode 100644 index 0000000..552d285 --- /dev/null +++ b/src/components/Logo.js @@ -0,0 +1,28 @@ +import React, { PureComponent } from "react" +import { connect } from "react-redux" +import * as R from "ramda" + +import logo from "../logo.svg" +import logo_stg from "../logo_stg.svg" + + +class Logo extends PureComponent { + render() { + const cls = R.defaultTo("", this.props.className) + + if(this.props.environment === "prod") { + return Fedora Packager Dashboard + } else { + return Fedora Packager Dashboard + } + } +} + +const mapStateToProps = (state) => { + const { environment } = state + return { + environment, + } +} + +export default connect(mapStateToProps)(Logo) diff --git a/src/components/Masthead.js b/src/components/Masthead.js index deed45d..fa0e0e7 100644 --- a/src/components/Masthead.js +++ b/src/components/Masthead.js @@ -1,5 +1,4 @@ import React, { PureComponent } from "react" -import logo from "../logo.svg" import { Link } from "react-router-dom" import Cookies from "universal-cookie" import { connect } from "react-redux" @@ -7,6 +6,7 @@ import { unsetUser } from "../actions/reduxActions" import { Parser } from "../utils/searchparser" import ModalOptions from "./ModalOptions" +import Logo from "./Logo" import $ from "jquery" @@ -49,7 +49,9 @@ class Masthead extends PureComponent { return (
- Fedora Packager Dashboard + + +
+ ) + } else { + return null + } + } +} + +const mapStateToProps = (state) => { + const { environment } = state + return { + environment, + } +} + +export default connect(mapStateToProps)(StgAlert) diff --git a/src/constants/index.js b/src/constants/index.js index 80fd7b6..b9fc725 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -17,4 +17,6 @@ export default { THROW_ERROR: 'THROW_ERROR', SET_DEP_GRAPH: 'SET_DEP_GRAPH', SET_SERVER_ERROR: 'SET_SERVER_ERROR', + LOAD_ENVIRONMENT: 'LOAD_ENVIRONMENT', + LOAD_ENVIRONMENT_RESP: 'LOAD_ENVIRONMENT_RESP', } diff --git a/src/logo_stg.svg b/src/logo_stg.svg new file mode 100644 index 0000000..03ef4b2 --- /dev/null +++ b/src/logo_stg.svg @@ -0,0 +1,294 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/reducers/index.js b/src/reducers/index.js index a9b6e0d..e41a131 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -50,6 +50,7 @@ const defaultState = { error: undefined, server_error: false, depGraph: {nodes: [], edges: []}, + environment: "prod", } @@ -187,6 +188,12 @@ export default (state = defaultState, action) => { server_error: action.payload } + case ActionTypes.LOAD_ENVIRONMENT_RESP: + return { + ...state, + environment: action.payload + } + default: return state }