Rift.IO OSM R1 Initial Submission
[osm/UI.git] / skyquake / plugins / launchpad / src / launchpadBreadcrumbs.jsx
1 /*
2  * 
3  *   Copyright 2016 RIFT.IO Inc
4  *
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
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
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.
16  *
17  */
18 import React from 'react';
19
20 export default class LaunchpadBreadcrumbs extends React.Component {
21
22   constructor(props) {
23     super(props);
24     this.current = props.current;
25   }
26   componentDidMount() {
27
28   }
29   componentWillReceiveProps(props) {
30
31   }
32   breadcrumbItem(url, name, isCurrent) {
33     if (isCurrent) {
34       return (<span className="current">{name}</span>);
35     } else {
36       return (<a href={url} onClick={this.props.clickHandler}>{name}</a>);
37     }
38   }
39   render() {
40     let mgmtDomainName = window.location.hash.split('/')[2];
41     let nsrId = window.location.hash.split('/')[3];
42     let url_base = '#/launchpad/' + mgmtDomainName + '/' + nsrId;
43     let html = (
44       <div className="header-nav">
45         <a href={'#/launchpad/' + mgmtDomainName} onClick={this.props.clickHandler}>DASHBOARD</a>
46         <span className="spacer"> > </span>
47         {this.breadcrumbItem(url_base+'/detail', 'Viewport', (this.props.current == 'viewport'))}
48         <span className="spacer"> | </span>
49         {this.breadcrumbItem(url_base+'/topology', 'Topology', (this.props.current == 'topology' ))}
50         <span className="spacer"> | </span>
51         {this.breadcrumbItem(url_base+'/topologyL2', 'Topology L2', (this.props.current == 'topologyL2' ))}
52         <span className="spacer"> | </span>
53         {this.breadcrumbItem(url_base+'/topologyL2Vm', 'Topology L2Vm', (this.props.current == 'topologyL2Vm'))}
54       </div>
55     );
56     return html;
57   }
58 }