Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Commit

Permalink
Feature/track version (#21)
Browse files Browse the repository at this point in the history
Make dashboard version visible in the dashboard.
  • Loading branch information
fieldju authored Jun 6, 2017
1 parent 46a0405 commit 5f80515
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ build/browser-bundle.js
build/browser-bundle.js.map
build/*.svg
build/*.png
build/metadata.json
reports/
logs/
vault/
Expand Down
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 37 additions & 0 deletions app/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<div className="login-error-msg-container">
<div className="login-error-msg-header">Failed to load dashboard metadata</div>
<div className="login-error-msg-content-wrapper">
<div className="login-error-msg-label">Status Code:</div>
<div className="login-error-msg-cms-msg">{response.status}</div>
</div>
</div>
))
})
}
}

export function storeDashboardMetadata(data) {
return {
type: constants.STORE_DOMAIN_DATA,
payload: {
version: data.version
}
}
}
31 changes: 31 additions & 0 deletions app/components/LandingView/LandingView.js
Original file line number Diff line number Diff line change
@@ -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 (
<div id='landing-view' className='ncss-brand'>
<h2>Welcome to the Cerberus Management Dashboard</h2>
<h3>Environment: {EnvironmentService.getEnvironment()}</h3>
<h3>API Domain: {EnvironmentService.getDomain()}</h3>

<div id='loader' className={hasDashboardMetadataLoaded ? 'hide-me' : 'show-me'}>
<div id='fountainG'>
<div id='fountainG_1' className='fountainG'></div>
<div id='fountainG_2' className='fountainG'></div>
<div id='fountainG_3' className='fountainG'></div>
<div id='fountainG_4' className='fountainG'></div>
<div id='fountainG_5' className='fountainG'></div>
<div id='fountainG_6' className='fountainG'></div>
<div id='fountainG_7' className='fountainG'></div>
<div id='fountainG_8' className='fountainG'></div>
</div>
</div>
<h3 className={hasDashboardMetadataLoaded ? '' : 'hide-me'}>Version: {dashboardVersion}</h3>
<h4>For help please visit the <a target="_blank" href="/dashboard/help/index.html">help page</a></h4>
</div>
)
Expand Down
7 changes: 7 additions & 0 deletions app/components/LandingView/LandingView.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,11 @@
a {
text-decoration: underline;
}

display: flex;
flex-flow: column;

#loader {
padding-bottom: 5px;
}
}
4 changes: 2 additions & 2 deletions app/constants/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 14 additions & 0 deletions app/reducers/appReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ const initialState = {
hasLoaded: false,
categories: [],
roles: []
},
metadata: {
hasLoaded: false,
version: 'unknown'
}
}

Expand Down Expand Up @@ -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
}
})
}
})
2 changes: 2 additions & 0 deletions buildAndArtifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ../
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "cerberus-management-dashboard",
"version": "1.2.1",
"description": "A management dashboard for Cerberus.",
"main": "index.js",
"repository": {
Expand Down

0 comments on commit 5f80515

Please sign in to comment.