2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
17 import {connect} from 'react-redux';
18 import OnboardView from './OnboardView.jsx';
19 import OnboardingActionHelper from '../OnboardingActionHelper.js';
20 import OnboardingCatalogActionHelper from './onboardingCatalog/OnboardingCatalogActionHelper.js';
21 import OnboardActionHelper from './OnboardActionHelper.js';
22 import LicenseModelCreationActionHelper from '../licenseModel/creation/LicenseModelCreationActionHelper.js';
23 import SoftwareProductCreationActionHelper from '../softwareProduct/creation/SoftwareProductCreationActionHelper.js';
24 import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js';
26 export const mapStateToProps = ({
27 onboard: {onboardingCatalog, activeTab, searchValue}, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList
30 const reduceLicenseModelList = (accum, vlm)=> {
31 let currentSoftwareProductList = sortByStringProperty(
32 finalizedSoftwareProductList
33 .filter(vsp => vsp.vendorId === vlm.id),
36 accum.push({...vlm, softwareProductList: currentSoftwareProductList});
40 finalizedLicenseModelList = sortByStringProperty(
42 .filter(vlm => finalizedLicenseModelList.map(finalVlm => finalVlm.id).includes(vlm.id))
43 .reduce(reduceLicenseModelList, []),
47 finalizedSoftwareProductList = sortByStringProperty(
49 .filter(vsp => finalizedSoftwareProductList.map(finalVsp => finalVsp.id).includes(vsp.id)),
54 let {activeTab: catalogActiveTab, vendorCatalog: {vspOverlay, selectedVendor}} = onboardingCatalog;
57 finalizedLicenseModelList,
58 finalizedSoftwareProductList,
69 const mapActionsToProps = (dispatch) => {
71 onSelectLicenseModel({id: licenseModelId, version}) {
72 OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId, version});
74 onSelectSoftwareProduct(softwareProduct) {
75 let {id: softwareProductId, vendorId: licenseModelId, licensingVersion, version} = softwareProduct;
76 OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version, licenseModelId, licensingVersion});
78 onAddSoftwareProductClick: (vendorId) => SoftwareProductCreationActionHelper.open(dispatch, vendorId),
79 onAddLicenseModelClick: () => LicenseModelCreationActionHelper.open(dispatch),
80 onVspOverlayChange: (vendor) => OnboardingCatalogActionHelper.changeVspOverlay(dispatch, vendor),
81 closeVspOverlay: () => OnboardingCatalogActionHelper.closeVspOverlay(dispatch),
82 onCatalogTabClick: (tab) => OnboardingCatalogActionHelper.changeActiveTab(dispatch, tab),
83 onTabClick: (tab) => OnboardActionHelper.changeActiveTab(dispatch, tab),
84 onSearch: (searchValue) => OnboardActionHelper.changeSearchValue(dispatch, searchValue),
85 onVendorSelect: (vendor) => OnboardingCatalogActionHelper.onVendorSelect(dispatch, {vendor}),
86 onMigrate: ({softwareProduct}) => OnboardingCatalogActionHelper.onMigrate(dispatch, softwareProduct)
90 export default connect(mapStateToProps, mapActionsToProps)(OnboardView);