3 * Copyright 2016 RIFT.IO Inc
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 import React from 'react';
20 import './header.scss';
21 import Crouton from 'react-crouton';
22 import HeaderStore from './headerStore.js';
23 import ScreenLoader from '../screen-loader/screenLoader.jsx';
24 export default class AppHeader extends React.Component {
28 this.state.validateErrorEvent = 0;
29 this.state.validateErrorMsg = '';
32 HeaderStore.listen(this.storeListener);
34 componentWillUnmount(){
35 HeaderStore.unlisten(this.storeListener);
38 LaunchpadFleetActions.validateReset()
40 storeListener = (state) => {
45 let navItems = this.props.nav.map(function(nav, i) {
46 if (nav.href || nav.onClick) {
47 return <li key={i}><a {...nav}>{nav.name}</a></li>
49 return <li key={i}><span className="current"> {nav.name} </span></li>
52 let errorMessage = <Crouton
54 message={this.state.validateErrorMsg}
56 hidden={!(this.state.validateErrorEvent && this.state.validateErrorMsg)}
57 onDismiss={HeaderStore.validateReset}
61 // <header className="header-app-component">
63 // <ScreenLoader show={this.props.isLoading}/>
64 // <div className="header-app-main">
65 // <h1>{this.props.title}</h1>
66 // <CommonLinks></CommonLinks>
68 // <div className="header-app-nav">
77 <header className="header-app-component">
79 <ScreenLoader show={this.props.isLoading}/>
80 <div className="header-app-nav">
91 export class CommonLinks extends React.Component {
106 links.push(<li key={'about'} onClick={this.openAbout}><a>About</a></li>);
107 links.push(<li key={'debug'} onClick={this.openDebug}><a>Debug</a></li>);
119 AppHeader.defaultProps = {
123 function generateRefPage() {
124 let applicationContext = window.sessionStorage.getItem('applicationContext') || 'launchpad';
125 let hash = window.location.hash.split('/');
126 let pageTitle = 'Dashboard';
127 if (applicationContext === 'launchpad') {
128 hash = '#/launchpad/' + hash[2];
136 window.sessionStorage.setItem('refPage', JSON.stringify(refPage));
139 function navigateTo(loc) {
140 window.location.hash = '#/' + loc;
142 function setContext() {
143 let applicationContext;
144 let hashOne = window.location.hash.split('/')[1];
145 if(hashOne == "launchpad") {
146 applicationContext = "launchpad";
148 applicationContext = "missioncontrol";
150 if(hashOne != 'about' && hashOne != 'debug'){
151 window.sessionStorage.setItem('applicationContext', applicationContext);}