Rift.IO OSM R1 Initial Submission
[osm/UI.git] / skyquake / plugins / composer / src / src / components / RiftHeader.js
1
2 /*
3 *
4 * Copyright 2016 RIFT.IO Inc
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19 /**
20 * Created by kkashalk on 11/10/15.
21 */
22
23 // NOTE: THIS FILE HAS BEEN DEPRECATED AND WILL BE REMOVED
24
25 'use strict';
26
27 import utils from '../libraries/utils'
28 import React from 'react'
29 import ClassNames from 'classnames'
30 import PureRenderMixin from 'react-addons-pure-render-mixin'
31 import RiftHeaderActions from '../actions/RiftHeaderActions'
32 import RiftHeaderStore from '../stores/RiftHeaderStore'
33
34 import '../styles/RiftHeader.scss'
35
36 const uiTransientState = {
37 timeoutId: 0
38 };
39
40 const RiftHeader = React.createClass({
41 mixins: [PureRenderMixin],
42 getInitialState() {
43 return RiftHeaderStore.getState();
44 },
45 getDefaultProps() {
46 },
47 componentWillMount() {
48 },
49 componentDidMount() {
50 RiftHeaderStore.listen(this.onChange);
51 const loadCatalogs = function () {
52 RiftHeaderStore.loadCatalogs();
53 uiTransientState.timeoutId = setTimeout(loadCatalogs, 2000);
54 };
55 RiftHeaderStore.requestLaunchpadConfig();
56 loadCatalogs();
57 },
58 componentDidUpdate() {
59 },
60 componentWillUnmount() {
61 if (uiTransientState.timeoutId) {
62 clearTimeout(uiTransientState.timeoutId);
63 }
64 RiftHeaderStore.unlisten(this.onChange);
65 },
66
67 onChange(state) {
68 this.setState(state);
69 },
70 onClickOpenDashboard() {
71 if (uiTransientState.timeoutId) {
72 clearTimeout(uiTransientState.timeoutId);
73 }
74 RiftHeaderStore.unlisten(this.onChange);
75 window.location.href = '//' + window.location.hostname + ':8000/index.html?api_server=' + utils.getSearchParams(window.location).api_server + '#/launchpad/' + utils.getSearchParams(window.location).mgmt_domain_name;
76 },
77 onClickOpenAccounts() {
78 if (uiTransientState.timeoutId) {
79 clearTimeout(uiTransientState.timeoutId);
80 }
81 RiftHeaderStore.unlisten(this.onChange);
82 window.location.href = '//' + window.location.hostname + ':8000/index.html?api_server=' + utils.getSearchParams(window.location).api_server + '#/launchpad/' + utils.getSearchParams(window.location).mgmt_domain_name + '/cloud-account/dashboard';
83 },
84 render() {
85 let Header = (
86 <header className="header-app">
87 <h1>{this.state.headerTitle}</h1>
88 <nav className="header-nav"> </nav>
89 </header>
90 );
91 Header = null;
92 return (
93 null
94 );
95 }
96 });
97
98 export default RiftHeader;