X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fsparky-fe.git;a=blobdiff_plain;f=src%2Fapp%2FMainScreenWrapper.jsx;h=3348494219c4b871eb2ec12276f808598c946032;hp=e6d088f4a03f19107802463d3d01259c2fc44a73;hb=410e8a48a471c6bb814f253abe006f20db0c2750;hpb=1580adb8ab521e55a129afc32693071620d85c02 diff --git a/src/app/MainScreenWrapper.jsx b/src/app/MainScreenWrapper.jsx index e6d088f..3348494 100644 --- a/src/app/MainScreenWrapper.jsx +++ b/src/app/MainScreenWrapper.jsx @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 Amdocs + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,8 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ import React, {Component} from 'react'; import {connect} from 'react-redux'; @@ -27,8 +25,12 @@ import TierSupport from './tierSupport/TierSupport.jsx'; import VnfSearch from './vnfSearch/VnfSearch.jsx'; import MainScreenHeader from './MainScreenHeader.jsx'; import {decryptParamsForView, changeUrlAddress} from 'utils/Routes.js'; - - +import { + getConfigurableViewConfigs, + setCustomRoutes +} from 'app/configurableViews/ConfigurableViewActions.js'; +import {isEmpty} from 'lodash'; +import {genericRequest} from 'app/networking/NetworkCalls.js'; import { Route, HashRouter as Router, @@ -39,22 +41,41 @@ import { import { windowResize, extensibleViewNetworkCallback, + overlayNetworkCallback, extensibleViewMessageCallback } from './MainScreenWrapperActionHelper.js'; import extensibleViews from 'resources/views/extensibleViews.json'; +import customComponentConfig from 'resources/views/customComponents.json'; +import { newCustomComponentsEvent } from 'app/configurableViews/ConfigurableViewActions.js'; +import { + getConfigurableRoutes +} from 'app/configurableViews/ConfigurableViewManager.js'; + +import { + getConfiguredComponentList +} from 'app/configurableViews/index.js'; -const mapStateToProps = ({mainWrapper}) => { +const mapStateToProps = ({mainWrapper, configurableViews}) => { let { showMenu = false, toggleButtonActive = false, extensibleViewNetworkCallbackData = {} } = mainWrapper; + let { + configurableViewsConfig = {}, + customComponents = {}, + customRoutes = [] + } = configurableViews; + return { showMenu, toggleButtonActive, - extensibleViewNetworkCallbackData + extensibleViewNetworkCallbackData, + configurableViewsConfig, + customComponents, + customRoutes }; }; @@ -66,6 +87,18 @@ const mapActionsToProps = (dispatch) => { }, onExtensibleViewMessageCallback: (message, messageSevirity) => { dispatch(extensibleViewMessageCallback(message, messageSevirity)); + }, + onOverlayNetworkCallback: (apiUrl, body, viewName, curViewData, responseEventKey) => { + dispatch(overlayNetworkCallback(apiUrl, body, viewName, curViewData, responseEventKey)); + }, + onConfigurableViewsInitialLoad: (components) => { + dispatch(newCustomComponentsEvent(components)); + }, + onFetchCustomViews: () => { + dispatch(getConfigurableViewConfigs()); + }, + onSetCustomRoutes: (routes) => { + dispatch(setCustomRoutes(routes)); } }; }; @@ -80,20 +113,53 @@ class MainScreenWrapper extends Component { } + componentDidMount() { + // fetch custom views + this.props.onFetchCustomViews(); + + // fetch custom components + let components = getConfiguredComponentList(customComponentConfig); + this.props.onConfigurableViewsInitialLoad(components); + } + + componentDidUpdate(prevProps) { + if ((Object.keys(this.props.customComponents).length > 0 && + Object.keys(this.props.configurableViewsConfig).length > 0) && + ((JSON.stringify(prevProps.configurableViewsConfig) !== JSON.stringify(this.props.configurableViewsConfig)) || + (JSON.stringify(prevProps.customComponents) !== JSON.stringify(this.props.customComponents)))) { + // we have both config and components populated and one was just set + let customRoutes = getConfigurableRoutes(this.props.configurableViewsConfig, this.props.customComponents); + this.props.onSetCustomRoutes(customRoutes); + } + } render() { const { onExtensibleViewNetworkCallback, extensibleViewNetworkCallbackData, - onExtensibleViewMessageCallback + onExtensibleViewMessageCallback, + onOverlayNetworkCallback, + configurableViewsConfig, + customComponents, + customRoutes } = this.props; let customViewList = []; - extensibleViews.forEach(function(view,key){ + extensibleViews.forEach(function(view,key) { + + let path = '', extKey = ''; + if(isEmpty(extensibleViews[key]['viewParams'])){ + path = '/' + view.viewName + '/:extensibleViewParams?'; + extKey = view.viewName + 'Route'; + } else { + path = '/' + view.viewName + view.viewParams; + extKey = view.viewName + view.viewParams + 'Route'; + } + var renderComponent = (props) => { let viewParams = {}; - if(props.match.params.extensibleViewParams !== undefined) { + if(isEmpty(extensibleViews[key]['viewParams']) && props.match.params.extensibleViewParams !== undefined) { viewParams = decryptParamsForView(props.match.params.extensibleViewParams); } @@ -102,28 +168,41 @@ class MainScreenWrapper extends Component { return ( { + networkingCallback={(apiUrl, body, paramName, curViewData) => { onExtensibleViewNetworkCallback(apiUrl, body, paramName, curViewData); }} - messagingCallback ={(message, messageSevirity) => { - onExtensibleViewMessageCallback(message, messageSevirity); + overlayCallback={(apiUrl, body, paramName, curOverlayData,responseEventKey) => { + onOverlayNetworkCallback(apiUrl, body, paramName, curOverlayData, responseEventKey); + }} + messagingCallback ={(message, messageSeverity) => { + onExtensibleViewMessageCallback(message, messageSeverity); }} changeRouteCallback = {(routeParam, historyObj) => { changeUrlAddress(routeParam, historyObj); }} + networkingCallbackPromise = {(url, relativeURL, httpMethodType) => { + return genericRequest(url, relativeURL, httpMethodType); + }} viewName={view.displayName} viewData={extensibleViewNetworkCallbackData} viewParams={viewParams}/> ); } }; + if(isEmpty(extensibleViews[key]['isExact']) && !extensibleViews[key]['isExact']){ + customViewList.push( + + ); + } else { + customViewList.push( + + ); + } - customViewList.push( - - ); }); + let configurableViewList = getConfigurableRoutes(configurableViewsConfig, customComponents); + return (
@@ -134,6 +213,8 @@ class MainScreenWrapper extends Component { {customViewList} + {customRoutes} + {configurableViewList}
);