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}
62 // <header className="header-app-component">
64 // <ScreenLoader show={this.props.isLoading}/>
65 // <div className="header-app-main">
66 // <h1>{this.props.title}</h1>
67 // <CommonLinks></CommonLinks>
69 // <div className="header-app-nav">
78 <header className="header-app-component">
80 <ScreenLoader show={this.props.isLoading}/>
81 <div className="header-app-nav">
92 export class CommonLinks extends React.Component {
107 links.push(<li key={'about'} onClick={this.openAbout}><a>About</a></li>);
108 links.push(<li key={'debug'} onClick={this.openDebug}><a>Debug</a></li>);
120 AppHeader.defaultProps = {
124 function generateRefPage() {
125 let applicationContext = window.sessionStorage.getItem('applicationContext') || 'launchpad';
126 let hash = window.location.hash.split('/');
127 let pageTitle = 'Dashboard';
128 if (applicationContext === 'launchpad') {
129 hash = '#/launchpad/' + hash[2];
137 window.sessionStorage.setItem('refPage', JSON.stringify(refPage));
140 function navigateTo(loc) {
141 window.location.hash = '#/' + loc;
143 function setContext() {
144 let applicationContext;
145 let hashOne = window.location.hash.split('/')[1];
146 if(hashOne == "launchpad") {
147 applicationContext = "launchpad";
149 applicationContext = "missioncontrol";
151 if(hashOne != 'about' && hashOne != 'debug'){
152 window.sessionStorage.setItem('applicationContext', applicationContext);}