[AAI] Remove Robby Maharajh & Harish Kajur as committers
[aai/sparky-fe.git] / src / app / model / modelSearch / components / ModelBreadcrumb.jsx
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2021 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *       http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 import React from 'react';
22 import Col from 'react-bootstrap/lib/Col';
23 import Label from 'react-bootstrap/lib/Label';
24 import { Link } from 'react-router-dom';
25 import {GlobalExtConstants} from 'utils/GlobalExtConstants.js';
26
27 const modelBreadcrumb = (props) => {
28
29  let links = null;
30  let historyStackArr = [];
31  var setURIInSession = function(uri){
32     sessionStorage.setItem(GlobalExtConstants.ENVIRONMENT + 'URI', uri);
33  }
34     if (props.historyStackString) {
35       historyStackArr = props.historyStackString.split('||');
36       for(var i = 0; i < historyStackArr.length; i++){
37          historyStackArr[i] = historyStackArr[i].split(',');
38          console.log('[ModelBreadcrumb.jsx] previous url ' + historyStackArr[i][0] + ' previous api call '+ historyStackArr[i][1]);
39       }
40       links = historyStackArr.map((link, idx) => {
41         let breadCrumbTxt=decodeURI(link[2]).replace(/%2F/g,'/');
42         return (
43                 <div className='customBreadCrumb'>
44                 {idx === historyStackArr.length - 2 ? (
45                     <b id={'breadcrumbStatic' + idx} style={{'float' : 'left'}}>{breadCrumbTxt}</b>
46                     ) : idx !== historyStackArr.length - 1 ? (
47                     <div id={'breadcrumbLink' + idx}>
48                       <div style={{'float' : 'left'}}>                          
49                         <Link
50                           key={idx}
51                           to={{
52                             pathname: link[0],
53                             uri: link[1],
54                             historyStackString: (breadCrumbTxt==='Origin')?'':props.historyStackString
55                           }} onClick={() => setURIInSession(link[1])}>{breadCrumbTxt}
56                         </Link>
57                     </div>
58                       <div style={{'float' : 'left'}}>&nbsp;&nbsp;&#x3E;&#x3E;&nbsp;&nbsp;</div>
59                 </div>
60                  ):(<div></div>)}
61                  </div>
62         );
63       });
64     }
65   return (
66     <Col md={12}  className='addPaddingTop'>
67         {links}
68     </Col>
69   );
70 };
71
72 export default modelBreadcrumb;