X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fapp%2FMainScreenHeader.jsx;h=8c5e13d9958e8ee23c294fec1bf293dc73f9e108;hb=96319fec0d2af2be5802a56d6b05a3ada939c8df;hp=ec1efdae0bc10dbe738501dedd53cdebd8fa777a;hpb=47b85e9b95e0a0a3570f0cea4d3ee4645c911a8b;p=aai%2Fsparky-fe.git diff --git a/src/app/MainScreenHeader.jsx b/src/app/MainScreenHeader.jsx index ec1efda..8c5e13d 100644 --- a/src/app/MainScreenHeader.jsx +++ b/src/app/MainScreenHeader.jsx @@ -19,6 +19,7 @@ * ============LICENSE_END========================================================= */ import React, {Component} from 'react'; +import { PropTypes } from 'prop-types'; import {connect} from 'react-redux'; import FontAwesome from 'react-fontawesome'; import {clearFilters} from 'filter-bar-utils'; @@ -29,7 +30,7 @@ import {postAnalyticsData} from 'app/analytics/AnalyticsActions.js'; import GlobalInlineMessageBar from 'app/globalInlineMessageBar/GlobalInlineMessageBar.jsx'; import {getClearGlobalMessageEvent} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js'; import {externalUrlRequest, externalMessageRequest, getSubscriptionPayload} from 'app/contextHandler/ContextHandlerActions.js'; - +import { getConfigurableViewConfigs } from 'app/configurableViews/ConfigurableViewActions.js'; import { filterBarActionTypes } from 'utils/GlobalConstants.js'; @@ -56,7 +57,7 @@ import {changeUrlAddress} from 'utils/Routes.js'; import extensibleViews from 'resources/views/extensibleViews.json'; -const mapStateToProps = ({mainWrapper}) => { +const mapStateToProps = ({mainWrapper, configurableViews}) => { let { showMenu = false, toggleButtonActive = false, @@ -66,13 +67,18 @@ const mapStateToProps = ({mainWrapper}) => { subscriptionEnabled = false } = mainWrapper; + let { + configurableViewsConfig + } = configurableViews; + return { showMenu, toggleButtonActive, externalRequestFound, secondaryTitle, subscriptionPayload, - subscriptionEnabled + subscriptionEnabled, + configurableViewsConfig }; }; @@ -100,17 +106,20 @@ const mapActionsToProps = (dispatch) => { }, onGetSubscriptionPayload: () => { dispatch(getSubscriptionPayload()); + }, + onFetchCustomViews: () => { + dispatch(getConfigurableViewConfigs()); } }; }; class MainScreenHeader extends Component { static propTypes = { - showMenu: React.PropTypes.bool, - toggleButtonActive: React.PropTypes.bool, - externalRequestFound: React.PropTypes.object, - secondaryTitle: React.PropTypes.string, - subscriptionPayload: React.PropTypes.object + showMenu: PropTypes.bool, + toggleButtonActive: PropTypes.bool, + externalRequestFound: PropTypes.object, + secondaryTitle: PropTypes.string, + subscriptionPayload: PropTypes.object }; navigationLinkAndCurrentPathMatch(location, to) { @@ -132,7 +141,7 @@ class MainScreenHeader extends Component { return false; } } - + isValidExternalURL(url) { if(decodeURIComponent(url).indexOf('&') > 0 ) { return true; @@ -168,7 +177,7 @@ class MainScreenHeader extends Component { this.props.onExternalUrlRequest(nextProps.match.params.externalUrl); } /* if the externalURL is not valid, we do not add any message as other proper - views will get that messages since the route will be this parameter.*/ + views will get that messages since the route will be this parameter.*/ if(this.props.externalRequestFound !== nextProps.externalRequestFound && nextProps.externalRequestFound !== undefined && nextProps.externalRequestFound.suggestion !== undefined) { @@ -216,13 +225,17 @@ class MainScreenHeader extends Component { $this.receiveMessage(e, $this); }, false); } + + // fetch custom views + this.props.onFetchCustomViews(); } + componentWillUnmount() { if(this.props.subscriptionEnabled) { var $this = this; window.removeEventListener('message', function (e) { - $this.receiveMessage(e, $this); - } + $this.receiveMessage(e, $this); + } ); } } @@ -233,7 +246,8 @@ class MainScreenHeader extends Component { onShowMenu, onHideMenu, toggleButtonActive, - secondaryTitle + secondaryTitle, + configurableViewsConfig } = this.props; let menuOptions = []; @@ -249,6 +263,18 @@ class MainScreenHeader extends Component { )}/> ); + const ConfigurableMenuItem = ({label, to}) => ( + ( + +
+
+
{label}
+
+ + )}/> + ); + // add Tier Support view menuOptions.push( + to='/vnfSearch' + label={MENU_ITEM_VNF_SEARCH} + iconClass='button-icon vnf-search-button-icon'/> ); // add all custom view menu options for (let view in extensibleViews) { - menuOptions.push( - - ); + let shouldDisplayIcon = false; + if(extensibleViews[view]['onlyRoute'] === undefined){ + shouldDisplayIcon = true; + } else if(extensibleViews[view]['onlyRoute'] === false){ + shouldDisplayIcon = true; + } + if(shouldDisplayIcon === true){ + menuOptions.push( + + ); + } + } + + if (configurableViewsConfig && configurableViewsConfig.layouts) { + for (let configurableView in configurableViewsConfig.layouts) { + menuOptions.push( + + ); + } } let secondaryTitleClass = 'secondary-header'; @@ -282,8 +325,8 @@ class MainScreenHeader extends Component {