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.
16 import {connect} from 'react-redux';
18 import i18n from 'nfvo-utils/i18n/i18n.js';
19 import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
20 import TabulatedEditor from 'src/nfvo-components/editor/TabulatedEditor.jsx';
21 import ActivityLogActionHelper from 'nfvo-components/activity-log/ActivityLogActionHelper.js';
22 import {enums} from 'sdc-app/onboarding/OnboardingConstants.js';
23 import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js';
25 import {navigationItems} from './LicenseModelConstants.js';
26 import LicenseModelActionHelper from './LicenseModelActionHelper.js';
27 import LicenseAgreementActionHelper from './licenseAgreement/LicenseAgreementActionHelper.js';
28 import FeatureGroupsActionHelper from './featureGroups/FeatureGroupsActionHelper.js';
29 import EntitlementPoolsActionHelper from './entitlementPools/EntitlementPoolsActionHelper.js';
30 import LicenseKeyGroupsActionHelper from './licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
33 const buildNavigationBarProps = (licenseModel, screen) => {
34 const {id, vendorName, version} = licenseModel;
35 const meta = {version};
42 id: navigationItems.LICENSE_MODEL_OVERVIEW,
43 name: i18n('Overview'),
47 id: navigationItems.LICENSE_AGREEMENTS,
48 name: i18n('License Agreements'),
52 id: navigationItems.FEATURE_GROUPS,
53 name: i18n('Feature Groups'),
57 id: navigationItems.ENTITLEMENT_POOLS,
58 name: i18n('Entitlement Pools'),
62 id: navigationItems.LICENSE_KEY_GROUPS,
63 name: i18n('License Key Groups'),
67 id: navigationItems.ACTIVITY_LOG,
68 name: i18n('Activity Log'),
74 const activeItemId = ({
75 [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: navigationItems.LICENSE_MODEL_OVERVIEW,
76 [enums.SCREEN.LICENSE_AGREEMENTS]: navigationItems.LICENSE_AGREEMENTS,
77 [enums.SCREEN.FEATURE_GROUPS]: navigationItems.FEATURE_GROUPS,
78 [enums.SCREEN.ENTITLEMENT_POOLS]: navigationItems.ENTITLEMENT_POOLS,
79 [enums.SCREEN.LICENSE_KEY_GROUPS]: navigationItems.LICENSE_KEY_GROUPS,
80 [enums.SCREEN.ACTIVITY_LOG]: navigationItems.ACTIVITY_LOG
89 const buildVersionControllerProps = (licenseModel) => {
90 let {version, viewableVersions, status: currentStatus, lockingUser} = licenseModel;
91 let {status, isCheckedOut} = VersionControllerUtils.getCheckOutStatusKindByUserID(currentStatus, lockingUser);
102 const mapStateToProps = ({licenseModel: {licenseModelEditor}}, {currentScreen: {screen}}) => {
104 versionControllerProps: buildVersionControllerProps(licenseModelEditor.data),
105 navigationBarProps: buildNavigationBarProps(licenseModelEditor.data, screen)
110 const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {licenseModelId}}}) => {
113 onVersionControllerAction: (action, version) =>
114 LicenseModelActionHelper.performVCAction(dispatch, {licenseModelId, action, version}).then((newVersion) => {
116 case enums.SCREEN.LICENSE_MODEL_OVERVIEW:
118 * TODO change to specific rest
120 LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version: newVersion});
122 case enums.SCREEN.LICENSE_AGREEMENTS:
123 LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version: newVersion});
125 case enums.SCREEN.FEATURE_GROUPS:
126 FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version: newVersion});
128 case enums.SCREEN.ENTITLEMENT_POOLS:
129 EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version: newVersion});
131 case enums.SCREEN.LICENSE_KEY_GROUPS:
132 LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version: newVersion});
134 case enums.SCREEN.ACTIVITY_LOG:
135 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: newVersion.id});
139 onVersionSwitching: version => {
140 LicenseModelActionHelper.switchVersion(dispatch, {licenseModelId, version});
141 if(screen === enums.SCREEN.ACTIVITY_LOG) {
142 ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id});
146 onNavigate: ({id, meta: {version}}) => {
148 case navigationItems.LICENSE_MODEL_OVERVIEW:
149 OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId, version});
151 case navigationItems.LICENSE_AGREEMENTS:
152 OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version});
154 case navigationItems.FEATURE_GROUPS:
155 OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version});
157 case navigationItems.ENTITLEMENT_POOLS:
158 OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version});
160 case navigationItems.LICENSE_KEY_GROUPS:
161 OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version});
163 case navigationItems.ACTIVITY_LOG:
164 OnboardingActionHelper.navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version});
171 export default connect(mapStateToProps, mapActionsToProps)(TabulatedEditor);