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 OnboardingCatalogActionHelper from './onboardingCatalog/OnboardingCatalogActionHelper.js';
20 import OnboardActionHelper from './OnboardActionHelper.js';
21 import LicenseModelCreationActionHelper from '../licenseModel/creation/LicenseModelCreationActionHelper.js';
22 import SoftwareProductCreationActionHelper from '../softwareProduct/creation/SoftwareProductCreationActionHelper.js';
23 import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js';
24 import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
25 import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js';
28 export const mapStateToProps = ({
36 finalizedLicenseModelList,
38 finalizedSoftwareProductList
41 const fullSoftwareProducts = softwareProductList.filter(vsp =>
42 !finalizedSoftwareProductList
43 .find(fvsp => fvsp.id === vsp.id)
44 ).concat(finalizedSoftwareProductList);
46 const reduceLicenseModelList = (accum, vlm) => {
47 let currentSoftwareProductList = sortByStringProperty(
49 .filter(vsp => vsp.vendorId === vlm.id),
52 accum.push({...vlm, softwareProductList: currentSoftwareProductList});
56 licenseModelList = sortByStringProperty(
58 .reduce(reduceLicenseModelList, []),
62 finalizedLicenseModelList = sortByStringProperty(
63 finalizedLicenseModelList
64 .reduce(reduceLicenseModelList, []),
68 const fullLicenseModelList = licenseModelList.filter(vlm =>
69 !finalizedLicenseModelList
70 .find(fvlm => fvlm.id === vlm.id)
71 ).concat(finalizedLicenseModelList);
73 let {activeTab: catalogActiveTab, vendorCatalog: {vspOverlay, selectedVendor}} = onboardingCatalog;
76 finalizedLicenseModelList,
77 finalizedSoftwareProductList,
86 users: users.usersList
91 const mapActionsToProps = (dispatch) => {
94 onSelectLicenseModel({id: licenseModelId, name}, users) {
95 ScreensHelper.loadScreen(dispatch, {
96 screen: enums.SCREEN.VERSIONS_PAGE, screenType: screenTypes.LICENSE_MODEL,
97 props: {licenseModelId, licenseModel: {name}, usersList: users}
100 onSelectSoftwareProduct(softwareProduct, users) {
101 let {id: softwareProductId, vendorId: licenseModelId, licensingVersion, name} = softwareProduct;
102 ScreensHelper.loadScreen(dispatch, {
103 screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT,
104 props: {softwareProductId, softwareProduct: {name, vendorId: licenseModelId, licensingVersion}, usersList: users}
107 onAddSoftwareProductClick: (vendorId) => SoftwareProductCreationActionHelper.open(dispatch, vendorId),
108 onAddLicenseModelClick: () => LicenseModelCreationActionHelper.open(dispatch),
109 onVspOverlayChange: (vendor) => OnboardingCatalogActionHelper.changeVspOverlay(dispatch, vendor),
110 closeVspOverlay: () => OnboardingCatalogActionHelper.closeVspOverlay(dispatch),
111 onCatalogTabClick: (tab) => OnboardingCatalogActionHelper.changeActiveTab(dispatch, tab),
112 onTabClick: (tab) => OnboardActionHelper.changeActiveTab(dispatch, tab),
113 onSearch: (searchValue) => OnboardActionHelper.changeSearchValue(dispatch, searchValue),
114 onVendorSelect: (vendor) => OnboardingCatalogActionHelper.onVendorSelect(dispatch, {vendor}),
115 onMigrate: ({softwareProduct}) => OnboardingCatalogActionHelper.onMigrate(dispatch, softwareProduct)
120 export default connect(mapStateToProps, mapActionsToProps)(OnboardView);