2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 import {connect} from 'react-redux';
23 import i18n from 'nfvo-utils/i18n/i18n.js';
24 import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
25 import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js';
26 import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js';
27 import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';
28 import LandingPageView from './SoftwareProductLandingPageView.jsx';
30 const mapStateToProps = ({softwareProduct, licenseModel: {licenseAgreement}}) => {
31 let {softwareProductEditor: {data:currentSoftwareProduct = {}}, softwareProductComponents, softwareProductCategories = []} = softwareProduct;
32 let {licensingData = {}} = currentSoftwareProduct;
33 let {licenseAgreementList} = licenseAgreement;
34 let {componentsList} = softwareProductComponents;
35 let licenseAgreementName = licenseAgreementList.find(la => la.id === licensingData.licenseAgreement);
36 if (licenseAgreementName) {
37 licenseAgreementName = licenseAgreementName.name;
40 let categoryName = '', subCategoryName = '', fullCategoryDisplayName = '';
41 const category = softwareProductCategories.find(ca => ca.uniqueId === currentSoftwareProduct.category);
43 categoryName = category.name;
44 const subcategories = category.subcategories || [];
45 const subcat = subcategories.find(sc => sc.uniqueId === currentSoftwareProduct.subCategory);
46 subCategoryName = subcat && subcat.name ? subcat.name : '';
48 fullCategoryDisplayName = `${subCategoryName} (${categoryName})`;
50 const isReadOnlyMode = VersionControllerUtils.isReadOnly(currentSoftwareProduct);
53 currentSoftwareProduct: {
54 ...currentSoftwareProduct,
56 fullCategoryDisplayName
63 const mapActionsToProps = (dispatch, {version}) => {
65 onDetailsSelect: ({id: softwareProductId, vendorId: licenseModelId}) => OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, {
69 onAttachmentsSelect: ({id: softwareProductId}) => OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId}),
70 onUpload: (softwareProductId, formData) =>
71 SoftwareProductActionHelper.uploadFile(dispatch, {
74 failedNotificationTitle: i18n('Upload validation failed')
76 onUploadConfirmation: (softwareProductId, formData) =>
77 SoftwareProductActionHelper.uploadConfirmation(dispatch, {
80 failedNotificationTitle: i18n('Upload validation failed')}),
82 onInvalidFileSizeUpload: () => dispatch({
83 type: NotificationConstants.NOTIFY_ERROR,
85 title: i18n('Upload Failed'),
86 msg: i18n('no zip file was uploaded or zip file doesn\'t exist')
89 onComponentSelect: ({id: softwareProductId, componentId}) => {
90 OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version });
92 /** for the next version */
93 onAddComponent: () => SoftwareProductActionHelper.addComponent(dispatch)
97 export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(LandingPageView);