diff --git a/.gitignore b/.gitignore index 807fd11..dc0adb7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ build/browser-bundle.js build/browser-bundle.js.map build/*.svg build/*.png +build/metadata.json reports/ logs/ vault/ diff --git a/.travis.yml b/.travis.yml index 4bd498d..f6c9d50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,11 +2,7 @@ language: node_js node_js: "v5.1.0" install: - "sed -i.bak -e '/\"api-mock\": \".*\",/d' package.json" - - npm install - - npm run build - - cd build/ - - tar -zcf ../cerberus-dashboard.tar.gz ./* - - cd ../ + - npm run artifact deploy: skip_cleanup: true provider: releases diff --git a/app/actions/appActions.js b/app/actions/appActions.js index 0dc0e0a..f2a8851 100644 --- a/app/actions/appActions.js +++ b/app/actions/appActions.js @@ -133,4 +133,41 @@ export function resetToInitialState() { return { type: constants.RESET_SIDEBAR_DATA } +} + +/** + * Action for loading version data into state + */ +export function loadDashboardMetadata() { + return function(dispatch) { + return axios({ + url: '/dashboard/metadata.json', + timeout: 10000 + }) + .then(function (response) { + dispatch(storeDashboardMetadata(response.data)) + }) + .catch(function (response) { + log.error(JSON.stringify(response, null, 2)) + dispatch(modalActions.popModal()) + dispatch(messengerActions.addNewMessage( +
+
Failed to load dashboard metadata
+
+
Status Code:
+
{response.status}
+
+
+ )) + }) + } +} + +export function storeDashboardMetadata(data) { + return { + type: constants.STORE_DOMAIN_DATA, + payload: { + version: data.version + } + } } \ No newline at end of file diff --git a/app/components/LandingView/LandingView.js b/app/components/LandingView/LandingView.js index 996259b..55007e8 100644 --- a/app/components/LandingView/LandingView.js +++ b/app/components/LandingView/LandingView.js @@ -1,15 +1,46 @@ import React from 'react' import { Component } from 'react' +import { connect } from 'react-redux' +import * as appActions from '../../actions/appActions' import EnvironmentService from '../../service/EnvironmentService' import './LandingView.scss' +@connect((state) => { + return { + hasDashboardMetadataLoaded: state.app.metadata.hasLoaded, + dashboardVersion: state.app.metadata.version + } +}) export default class LandingView extends Component { + + componentDidMount() { + if (! this.props.hasDashboardMetadataLoaded) { + this.props.dispatch(appActions.loadDashboardMetadata()) + } + } + render() { + const {dashboardVersion, hasDashboardMetadataLoaded} = this.props + return (

Welcome to the Cerberus Management Dashboard

Environment: {EnvironmentService.getEnvironment()}

API Domain: {EnvironmentService.getDomain()}

+ +
+
+
+
+
+
+
+
+
+
+
+
+

Version: {dashboardVersion}

For help please visit the help page

) diff --git a/app/components/LandingView/LandingView.scss b/app/components/LandingView/LandingView.scss index 245df7e..57a6823 100644 --- a/app/components/LandingView/LandingView.scss +++ b/app/components/LandingView/LandingView.scss @@ -6,4 +6,11 @@ a { text-decoration: underline; } + + display: flex; + flex-flow: column; + + #loader { + padding-bottom: 5px; + } } \ No newline at end of file diff --git a/app/constants/actions.js b/app/constants/actions.js index e240b0f..21ee98c 100644 --- a/app/constants/actions.js +++ b/app/constants/actions.js @@ -22,8 +22,8 @@ export const FETCHING_SIDE_BAR_DATA = 'FETCHING_SIDE_BAR_DATA' export const FETCHED_SIDE_BAR_DATA = 'FETCHED_SIDE_BAR_DATA' export const MANAGE_BUCKET = 'MANAGE_BUCKET' export const STORE_DOMAIN_DATA = 'STORE_DOMAIN_DATA' -export const RESET_SIDEBAR_DATA = 'RESET_SIDEBAR_DATA'; - +export const RESET_SIDEBAR_DATA = 'RESET_SIDEBAR_DATA' +export const STORE_DASHBOARD_METADATA = 'STORE_DASHBOARD_METADATA' // Events for the create-new-bucket export const CREATE_NEW_SDB_INIT = 'CREATE_NEW_SDB_INIT' diff --git a/app/reducers/appReducer.js b/app/reducers/appReducer.js index 5095294..dfbffbd 100644 --- a/app/reducers/appReducer.js +++ b/app/reducers/appReducer.js @@ -11,6 +11,10 @@ const initialState = { hasLoaded: false, categories: [], roles: [] + }, + metadata: { + hasLoaded: false, + version: 'unknown' } } @@ -44,5 +48,15 @@ export default createReducer(initialState, { [constants.RESET_SIDEBAR_DATA]: (state) => { return initialState + }, + + // stores the metadata about the dashboard into the state + [constants.STORE_DOMAIN_DATA]: (state, payload) => { + return Object.assign({}, state, { + metadata: { + hasLoaded: true, + version: payload.version + } + }) } }) diff --git a/buildAndArtifact.sh b/buildAndArtifact.sh index 1725150..ed5723f 100755 --- a/buildAndArtifact.sh +++ b/buildAndArtifact.sh @@ -3,4 +3,6 @@ npm install npm run build cd build/ +echo "{\"version\":\"$(git describe --tags)\"}" > metadata.json tar -zcvf ../cerberus-dashboard.tar.gz ./* +cd ../ \ No newline at end of file diff --git a/package.json b/package.json index 2e189a8..16b184b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,5 @@ { "name": "cerberus-management-dashboard", - "version": "1.2.1", "description": "A management dashboard for Cerberus.", "main": "index.js", "repository": {