diff options
author | talig <talig@amdocs.com> | 2017-12-20 14:30:43 +0200 |
---|---|---|
committer | Vitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com> | 2017-12-21 11:12:33 +0000 |
commit | 8e9c0653dd6c6862123c9609ae34e1206d86456e (patch) | |
tree | 5eeef00ec0677133baa439ca8d7ffd7aca4804b6 /openecomp-ui/src/sdc-app/onboarding/licenseModel | |
parent | 785ebcc95de3e064e843bec04ba7a209d854fc7c (diff) |
Add collaboration feature
Issue-ID: SDC-767
Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795
Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/licenseModel')
39 files changed, 587 insertions, 507 deletions
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js index 895a329047..73027c7e36 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js @@ -16,18 +16,17 @@ import {connect} from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import TabulatedEditor from 'src/nfvo-components/editor/TabulatedEditor.jsx'; -import ActivityLogActionHelper from 'sdc-app/common/activity-log/ActivityLogActionHelper.js'; -import {enums} from 'sdc-app/onboarding/OnboardingConstants.js'; -import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; +import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; +import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; + +import PermissionsActionHelper from './../permissions/PermissionsActionHelper.js'; +import RevisionsActionHelper from './../revisions/RevisionsActionHelper.js'; -import {navigationItems} from './LicenseModelConstants.js'; import LicenseModelActionHelper from './LicenseModelActionHelper.js'; -import LicenseAgreementActionHelper from './licenseAgreement/LicenseAgreementActionHelper.js'; -import FeatureGroupsActionHelper from './featureGroups/FeatureGroupsActionHelper.js'; -import EntitlementPoolsActionHelper from './entitlementPools/EntitlementPoolsActionHelper.js'; -import LicenseKeyGroupsActionHelper from './licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; +import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; +import {CommitModalType} from 'nfvo-components/panel/versionController/components/CommitCommentModal.jsx'; const buildNavigationBarProps = (licenseModel, screen) => { @@ -39,131 +38,135 @@ const buildNavigationBarProps = (licenseModel, screen) => { name: vendorName, items: [ { - id: navigationItems.LICENSE_MODEL_OVERVIEW, + id: enums.SCREEN.LICENSE_MODEL_OVERVIEW, name: i18n('Overview'), meta }, { - id: navigationItems.LICENSE_AGREEMENTS, + id: enums.SCREEN.LICENSE_AGREEMENTS, name: i18n('License Agreements'), meta }, { - id: navigationItems.FEATURE_GROUPS, + id: enums.SCREEN.FEATURE_GROUPS, name: i18n('Feature Groups'), meta }, { - id: navigationItems.ENTITLEMENT_POOLS, + id: enums.SCREEN.ENTITLEMENT_POOLS, name: i18n('Entitlement Pools'), meta }, { - id: navigationItems.LICENSE_KEY_GROUPS, + id: enums.SCREEN.LICENSE_KEY_GROUPS, name: i18n('License Key Groups'), meta }, { - id: navigationItems.ACTIVITY_LOG, + id: enums.SCREEN.ACTIVITY_LOG, name: i18n('Activity Log'), meta } ] }]; - const activeItemId = ({ - [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: navigationItems.LICENSE_MODEL_OVERVIEW, - [enums.SCREEN.LICENSE_AGREEMENTS]: navigationItems.LICENSE_AGREEMENTS, - [enums.SCREEN.FEATURE_GROUPS]: navigationItems.FEATURE_GROUPS, - [enums.SCREEN.ENTITLEMENT_POOLS]: navigationItems.ENTITLEMENT_POOLS, - [enums.SCREEN.LICENSE_KEY_GROUPS]: navigationItems.LICENSE_KEY_GROUPS, - [enums.SCREEN.ACTIVITY_LOG]: navigationItems.ACTIVITY_LOG - })[screen]; - return { - activeItemId, groups + activeItemId: screen, groups }; }; -const buildVersionControllerProps = (licenseModel) => { - let {version, viewableVersions, status: currentStatus, lockingUser} = licenseModel; - let {status, isCheckedOut} = VersionControllerUtils.getCheckOutStatusKindByUserID(currentStatus, lockingUser); - +const buildVersionControllerProps = ({ + licenseModelEditor = {data: {}}, + versions, + currentVersion, + userInfo, + usersList, + permissions, + itemPermission, + isReadOnlyMode +}) => { + const {isValidityData = true} = licenseModelEditor; return { - version, - viewableVersions, - status, - isCheckedOut + version: currentVersion, + viewableVersions: versions, + isFormDataValid: isValidityData, + permissions, + userInfo, + usersList, + itemName: licenseModelEditor.data.vendorName, + itemPermission, + isReadOnlyMode }; }; -const mapStateToProps = ({licenseModel: {licenseModelEditor}}, {currentScreen: {screen}}) => { +const mapStateToProps = ({ + users: {userInfo, usersList}, + licenseModel: {licenseModelEditor}, + versionsPage: {permissions, versionsList: {versions, itemName}} +}, { + currentScreen: {screen, itemPermission, props: {isReadOnlyMode, version: currentVersion}} +}) => { return { - versionControllerProps: buildVersionControllerProps(licenseModelEditor.data), + versionControllerProps: buildVersionControllerProps({ + licenseModelEditor, + versions, + currentVersion, + userInfo, + permissions, + usersList, + itemPermission, + isReadOnlyMode + }), navigationBarProps: buildNavigationBarProps(licenseModelEditor.data, screen) }; }; -const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {licenseModelId}}}) => { +const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {licenseModelId, version}}}) => { return { - onVersionControllerAction: (action, version) => - LicenseModelActionHelper.performVCAction(dispatch, {licenseModelId, action, version}).then((newVersion) => { - switch(screen) { - case enums.SCREEN.LICENSE_MODEL_OVERVIEW: - /** - * TODO change to specific rest - */ - LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version: newVersion}); - break; - case enums.SCREEN.LICENSE_AGREEMENTS: - LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version: newVersion}); - break; - case enums.SCREEN.FEATURE_GROUPS: - FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version: newVersion}); - break; - case enums.SCREEN.ENTITLEMENT_POOLS: - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version: newVersion}); - break; - case enums.SCREEN.LICENSE_KEY_GROUPS: - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version: newVersion}); - break; - case enums.SCREEN.ACTIVITY_LOG: - ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: newVersion.id}); - break; - } + onVersionControllerAction: (action, version, comment) => + LicenseModelActionHelper.performVCAction(dispatch, {licenseModelId, action, version, comment}).then(updatedVersion => { + ScreensHelper.loadScreen(dispatch, {screen, screenType: screenTypes.LICENSE_MODEL, props: {licenseModelId, version: updatedVersion}}); }), - onVersionSwitching: version => { - LicenseModelActionHelper.switchVersion(dispatch, {licenseModelId, version}); - if(screen === enums.SCREEN.ACTIVITY_LOG) { - ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id}); + + onOpenCommentCommitModal: ({onCommit, title}) => dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.COMMIT_COMMENT, + modalComponentProps: { + onCommit, + type: CommitModalType.COMMIT + }, + title } + }), + + onVersionSwitching: version => { + ScreensHelper.loadScreen(dispatch, {screen, screenType: screenTypes.LICENSE_MODEL, props: {licenseModelId, version}}); }, - onNavigate: ({id, meta: {version}}) => { - switch(id) { - case navigationItems.LICENSE_MODEL_OVERVIEW: - OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId, version}); - break; - case navigationItems.LICENSE_AGREEMENTS: - OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version}); - break; - case navigationItems.FEATURE_GROUPS: - OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version}); - break; - case navigationItems.ENTITLEMENT_POOLS: - OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version}); - break; - case navigationItems.LICENSE_KEY_GROUPS: - OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}); - break; - case navigationItems.ACTIVITY_LOG: - OnboardingActionHelper.navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version}); - break; - } + onManagePermissions() { + PermissionsActionHelper.openPermissonsManager(dispatch, {itemId: licenseModelId, askForRights: false}); + }, + + onMoreVersionsClick: ({itemName, users}) => { + ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.VERSIONS_PAGE, screenType: screenTypes.LICENSE_MODEL, + props: {licenseModelId, licenseModel: {name: itemName}, usersList: users}}); + }, + + onOpenPermissions: ({users}) => { + return PermissionsActionHelper.fetchItemUsers(dispatch, {itemId: licenseModelId, allUsers: users}); + }, + + onOpenRevisionsModal: () => { + return RevisionsActionHelper.openRevisionsView(dispatch, {itemId: licenseModelId, version: version, itemType: screenTypes.LICENSE_MODEL}); + }, + + onNavigate: ({id}) => { + ScreensHelper.loadScreen(dispatch, {screen: id, screenType: screenTypes.LICENSE_MODEL, props: {licenseModelId, version}}); } }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js index 788528fd75..ff264b3003 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js @@ -23,7 +23,14 @@ import LicenseAgreementActionHelper from './licenseAgreement/LicenseAgreementAct import FeatureGroupsActionHelper from './featureGroups/FeatureGroupsActionHelper.js'; import EntitlementPoolsActionHelper from './entitlementPools/EntitlementPoolsActionHelper.js'; import LicenseKeyGroupsActionHelper from './licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; -import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; +import ItemsHelper from '../../common/helpers/ItemsHelper.js'; +import MergeEditorActionHelper from 'sdc-app/common/merge/MergeEditorActionHelper.js'; +import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; +import {CommitModalType} from 'nfvo-components/panel/versionController/components/CommitCommentModal.jsx'; +import versionPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js'; +import {itemTypes} from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js'; +import {catalogItemStatuses} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; +import {actionsEnum as VersionControllerActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; function baseUrl() { const restPrefix = Configuration.get('restPrefix'); @@ -31,11 +38,11 @@ function baseUrl() { } function fetchLicenseModels() { - return RestAPIUtil.fetch(baseUrl()); + return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=Draft`); } function fetchFinalizedLicenseModels() { - return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=Final`); + return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=Certified`); } function fetchLicenseModelById(licenseModelId, version) { @@ -43,11 +50,6 @@ function fetchLicenseModelById(licenseModelId, version) { return RestAPIUtil.fetch(`${baseUrl()}${licenseModelId}/versions/${versionId}`); } -function putLicenseModelAction(id, action, version) { - const {id: versionId} = version; - return RestAPIUtil.put(`${baseUrl()}${id}/versions/${versionId}/actions`, {action: action}); -} - function putLicenseModel(licenseModel) { let {id, vendorName, description, iconRef, version: {id: versionId}} = licenseModel; return RestAPIUtil.put(`${baseUrl()}${id}/versions/${versionId}`, { @@ -57,14 +59,9 @@ function putLicenseModel(licenseModel) { }); } -function adjustMinorVersion(version, value) { - let ar = version.split('.'); - return ar[0] + '.' + (parseInt(ar[1]) + value); -} - -function adjustMajorVersion(version, value) { - let ar = version.split('.'); - return (parseInt(ar[0]) + value) + '.0'; +function putLicenseModelAction({itemId, action, version}) { + const {id: versionId} = version; + return RestAPIUtil.put(`${baseUrl()}${itemId}/versions/${versionId}/actions`, {action: action}); } const LicenseModelActionHelper = { @@ -87,8 +84,8 @@ const LicenseModelActionHelper = { }, fetchLicenseModelById(dispatch, {licenseModelId, version}) { - - return fetchLicenseModelById(licenseModelId, version).then(response => { + + return fetchLicenseModelById(licenseModelId, version).then(response => { dispatch({ type: actionTypes.LICENSE_MODEL_LOADED, response: {...response, version} @@ -96,13 +93,6 @@ const LicenseModelActionHelper = { }); }, - addLicenseModel(dispatch, {licenseModel}){ - dispatch({ - type: actionTypes.ADD_LICENSE_MODEL, - licenseModel - }); - }, - fetchLicenseModelItems(dispatch, {licenseModelId, version}) { return Promise.all([ LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version}), @@ -112,58 +102,94 @@ const LicenseModelActionHelper = { ]); }, - performVCAction(dispatch, {licenseModelId, action, version}) { - return putLicenseModelAction(licenseModelId, action, version).then(() => { - if(action === vcActionsEnum.SUBMIT){ + manageSubmitAction(dispatch, {licenseModelId, version, isDirty}) { + if(isDirty) { + const onCommit = comment => { + return this.performVCAction(dispatch, {licenseModelId, action: vcActionsEnum.COMMIT, version, comment}).then(() => { + return this.performSubmitAction(dispatch, {licenseModelId, version}); + }); + }; + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.COMMIT_COMMENT, + modalComponentProps: { + onCommit, + type: CommitModalType.COMMIT_SUBMIT + }, + title: i18n('Commit & Submit') + } + }); + return Promise.reject(); + } + return this.performSubmitAction(dispatch, {licenseModelId, version}); + }, + + performSubmitAction(dispatch, {licenseModelId, version}) { + return putLicenseModelAction({itemId: licenseModelId, action: vcActionsEnum.SUBMIT, version}).then(() => { + return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}).then(updatedVersion => { dispatch({ type: modalActionTypes.GLOBAL_MODAL_SUCCESS, data: { - title: i18n('Submit Succeeded'), + title: i18n('Submit Succeeded'), msg: i18n('This license model successfully submitted'), - cancelButtonText: i18n('OK'), + cancelButtonText: i18n('OK'), timeout: 2000 } }); - } - - let newVersionId = version.id; - /* - TODO Temorary switch to change version label - */ - switch(action) { - case vcActionsEnum.CHECK_OUT: - newVersionId = adjustMinorVersion(version.label, 1); - break; - case vcActionsEnum.UNDO_CHECK_OUT: - newVersionId = adjustMinorVersion(version.label, -1); - break; - case vcActionsEnum.SUBMIT: - newVersionId = adjustMajorVersion(version.label, 1); - } - - OnboardingActionHelper.updateCurrentScreenVersion(dispatch, {label: newVersionId, id: newVersionId}); - - LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version:{id: newVersionId, label: newVersionId}}); - return Promise.resolve({id: newVersionId, label: newVersionId}); + versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: licenseModelId}); + return Promise.resolve(updatedVersion); + }); }); }, - switchVersion(dispatch, {licenseModelId, version}) { - LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version: {id: version.id, label: version.label}}).then(() => { - LicenseModelActionHelper.fetchLicenseModelItems(dispatch, {licenseModelId, version}); + performVCAction(dispatch, {licenseModelId, action, version, comment}) { + return MergeEditorActionHelper.analyzeSyncResult(dispatch, {itemId: licenseModelId, version}).then(({inMerge, isDirty, updatedVersion}) => { + if (updatedVersion.status === catalogItemStatuses.CERTIFIED && + (action === VersionControllerActionsEnum.COMMIT || action === VersionControllerActionsEnum.SYNC)) { + versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: licenseModelId}); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: i18n('Commit error'), + msg: i18n('Item version already Certified'), + cancelButtonText: i18n('Cancel') + } + }); + return Promise.resolve(updatedVersion); + } + if (!inMerge) { + if(action === vcActionsEnum.SUBMIT) { + return this.manageSubmitAction(dispatch, {licenseModelId, version, isDirty}); + } + else { + return ItemsHelper.performVCAction({itemId: licenseModelId, action, version, comment}).then(() => { + versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: licenseModelId}); + if (action === vcActionsEnum.SYNC) { + return MergeEditorActionHelper.analyzeSyncResult(dispatch, {itemId: licenseModelId, version}).then(({updatedVersion}) => { + return Promise.resolve(updatedVersion); + }); + } else { + return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); + } + }); + } + } }); }, saveLicenseModel(dispatch, {licenseModel}) { return putLicenseModel(licenseModel).then(() => { dispatch({ - type: actionTypes.ADD_LICENSE_MODEL, - licenseModel - }); - dispatch({ type: actionTypes.LICENSE_MODEL_LOADED, response: licenseModel }); + const {id, version: {id: versionId}} = licenseModel; + return ItemsHelper.checkItemStatus(dispatch, {itemId: id, versionId}).then(updatedVersion => { + if (updatedVersion.status !== licenseModel.version.status) { + versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: licenseModel.id}); + } + }); }); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js index 960090c2d8..283cb23168 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js @@ -20,18 +20,9 @@ export const actionTypes = keyMirror({ LICENSE_MODEL_LOADED: null, LICENSE_MODELS_LIST_LOADED: null, FINALIZED_LICENSE_MODELS_LIST_LOADED: null, - ADD_LICENSE_MODEL: null, EDIT_LICENSE_MODEL: null }); -export const navigationItems = keyMirror({ - LICENSE_MODEL_OVERVIEW: 'overview', - LICENSE_AGREEMENTS: 'license-agreements', - FEATURE_GROUPS: 'feature-groups', - ENTITLEMENT_POOLS: 'entitlement-pools', - LICENSE_KEY_GROUPS: 'license-key-groups', - ACTIVITY_LOG: 'activity-log' -}); export const thresholdUnitType = { ABSOLUTE: 'Absolute', diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js index fd73b462a3..36a190a39c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js @@ -19,8 +19,6 @@ export default (state = [], action) => { switch (action.type) { case actionTypes.LICENSE_MODELS_LIST_LOADED: return [...action.response.results]; - case actionTypes.ADD_LICENSE_MODEL: - return [...state, action.licenseModel]; default: return state; } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js index 39b3c15c6a..71f41710db 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js @@ -14,34 +14,42 @@ * permissions and limitations under the License. */ import {connect} from 'react-redux'; -import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; import LicenseModelCreationActionHelper from './LicenseModelCreationActionHelper.js'; import LicenseModelCreationView from './LicenseModelCreationView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; +import VersionsPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js'; +import {itemTypes as versionItemTypes} from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js'; +import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; +import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import PermissionsActionHelper from 'sdc-app/onboarding/permissions/PermissionsActionHelper.js'; -export const mapStateToProps = ({licenseModelList, licenseModel: {licenseModelCreation}}) => { +export const mapStateToProps = ({users: {usersList}, licenseModelList, licenseModel: {licenseModelCreation}}) => { let {genericFieldInfo} = licenseModelCreation; let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); let VLMNames = {}; for (let i = 0; i < licenseModelList.length; i++) { - VLMNames[licenseModelList[i].vendorName.toLowerCase()] = licenseModelList[i].id; + VLMNames[licenseModelList[i].name.toLowerCase()] = licenseModelList[i].id; } - return {...licenseModelCreation, isFormValid: isFormValid, VLMNames}; + return {...licenseModelCreation, isFormValid: isFormValid, VLMNames, usersList}; }; export const mapActionsToProps = (dispatch) => { return { onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), onCancel: () => LicenseModelCreationActionHelper.close(dispatch), - onSubmit: (licenseModel) => { + onSubmit: (licenseModel, usersList) => { LicenseModelCreationActionHelper.close(dispatch); LicenseModelCreationActionHelper.createLicenseModel(dispatch, {licenseModel}).then(response => { - LicenseModelActionHelper.fetchLicenseModels(dispatch).then(() => { - OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId: response.value}); - }); + let {itemId, version} = response; + LicenseModelActionHelper.fetchLicenseModels(dispatch).then(() => + PermissionsActionHelper.fetchItemUsers(dispatch, {itemId, allUsers: usersList}).then(() => + VersionsPageActionHelper.fetchVersions(dispatch, {itemType: versionItemTypes.LICENSE_MODEL, itemId}).then(() => + ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.LICENSE_MODEL_OVERVIEW, screenType: screenTypes.LICENSE_MODEL, + props: {licenseModelId: itemId, version}}) + ))); }); }, onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js index 51f5b7f276..87df1386b6 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js @@ -61,7 +61,13 @@ export default { }, createLicenseModel(dispatch, {licenseModel}){ - return createLicenseModel(licenseModel); + return createLicenseModel(licenseModel).then(result => { + dispatch({ + type: actionTypes.LICENSE_MODEL_CREATED, + result + }); + return result; + }); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationConstants.js index 28f1175676..e9b1c46bef 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationConstants.js @@ -17,7 +17,8 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ OPEN: null, - CLOSE: null + CLOSE: null, + LICENSE_MODEL_CREATED: null }); export const LICENSE_MODEL_CREATION_FORM_NAME = 'LMCREATIONFORM'; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx index 80040460c0..948bdc158d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx @@ -14,27 +14,29 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Validator from 'nfvo-utils/Validator.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import Form from 'nfvo-components/input/validation/Form.jsx'; import {LICENSE_MODEL_CREATION_FORM_NAME} from './LicenseModelCreationConstants.js'; -const LicenseModelPropType = React.PropTypes.shape({ - id: React.PropTypes.string, - vendorName: React.PropTypes.string, - description: React.PropTypes.string +const LicenseModelPropType = PropTypes.shape({ + id: PropTypes.string, + vendorName: PropTypes.string, + description: PropTypes.string }); class LicenseModelCreationView extends React.Component { static propTypes = { data: LicenseModelPropType, - VLMNames: React.PropTypes.object, - onDataChanged: React.PropTypes.func.isRequired, - onSubmit: React.PropTypes.func.isRequired, - onValidateForm: React.PropTypes.func.isRequired, - onCancel: React.PropTypes.func.isRequired + VLMNames: PropTypes.object, + usersList: PropTypes.array, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onValidateForm: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired }; render() { @@ -46,6 +48,7 @@ class LicenseModelCreationView extends React.Component { ref='validationForm' hasButtons={true} onSubmit={ () => this.submit() } + submitButtonText={i18n('Create')} onReset={ () => this.props.onCancel() } labledButtons={true} isValid={this.props.isFormValid} @@ -79,8 +82,8 @@ class LicenseModelCreationView extends React.Component { submit() { - const {data:licenseModel} = this.props; - this.props.onSubmit(licenseModel); + const {data:licenseModel, usersList} = this.props; + this.props.onSubmit(licenseModel, usersList); } validateName(value) { diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js index ce4327d810..09a6e8228c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js @@ -16,9 +16,9 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as entitlementPoolsActionTypes } from './EntitlementPoolsConstants.js'; -import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; import {actionTypes as limitEditorActions} from 'sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js'; import {default as getValue, getStrValue} from 'nfvo-utils/getValue.js'; +import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); @@ -124,6 +124,7 @@ export default { type: entitlementPoolsActionTypes.DELETE_ENTITLEMENT_POOL, entitlementPoolId }); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); }, @@ -147,6 +148,7 @@ export default { type: entitlementPoolsActionTypes.EDIT_ENTITLEMENT_POOL, entitlementPool }); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } else { @@ -159,6 +161,7 @@ export default { id: response.value } }); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } }, @@ -176,11 +179,6 @@ export default { }); }, - switchVersion(dispatch, {licenseModelId, version}) { - LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { - this.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); - }); - }, fetchLimits(dispatch, {licenseModelId, version, entitlementPool}) { @@ -200,12 +198,14 @@ export default { type: limitEditorActions.CLOSE }); this.fetchLimits(dispatch, {licenseModelId, version, entitlementPool}); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); }, deleteLimit(dispatch, {licenseModelId, version, entitlementPool, limit}) { return deleteLimit(licenseModelId,entitlementPool.id, version, limit.id).then(() => { this.fetchLimits(dispatch, {licenseModelId, version, entitlementPool}); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx index 8473c1a2be..154174cf6c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Validator from 'nfvo-utils/Validator.js'; @@ -34,19 +35,19 @@ import Tab from 'sdc-ui/lib/react/Tab.js'; import EntitlementPoolsLimits from './EntitlementPoolsLimits.js'; import {limitType, NEW_LIMIT_TEMP_ID} from '../limits/LimitEditorConstants.js'; -const EntitlementPoolPropType = React.PropTypes.shape({ - id: React.PropTypes.string, - name: React.PropTypes.string, - description: React.PropTypes.string, - operationalScope: React.PropTypes.shape({ - choices: React.PropTypes.array, - other: React.PropTypes.string +const EntitlementPoolPropType = PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + operationalScope: PropTypes.shape({ + choices: PropTypes.array, + other: PropTypes.string }), - thresholdUnits: React.PropTypes.string, - thresholdValue: React.PropTypes.number, - increments: React.PropTypes.string, - startDate: React.PropTypes.string, - expiryDate: React.PropTypes.string + thresholdUnits: PropTypes.string, + thresholdValue: PropTypes.string, + increments: PropTypes.string, + startDate: PropTypes.string, + expiryDate: PropTypes.string }); const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, validateName, @@ -55,7 +56,7 @@ const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, val let {name, description, operationalScope, thresholdUnits, thresholdValue, increments, startDate, expiryDate} = data; return ( - <GridSection> + <GridSection hasLastColSet> <GridItem colSpan={2}> <Input onChange={name => onDataChanged({name}, SP_ENTITLEMENT_POOL_FORM, {name: validateName})} @@ -67,7 +68,7 @@ const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, val data-test-id='create-ep-name' type='text'/> </GridItem> - <GridItem colSpan={2}> + <GridItem colSpan={2} lastColInRow> <InputOptions onInputChange={()=>{}} isMultiSelect={true} @@ -94,7 +95,7 @@ const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, val data-test-id='create-ep-description' type='textarea'/> </GridItem> - <GridItem colSpan={2}> + <GridItem colSpan={2} lastColInRow> <div className='threshold-section'> <Input onChange={e => { @@ -152,7 +153,7 @@ const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, val )} isValid={genericFieldInfo.startDate.isValid} errorText={genericFieldInfo.startDate.errorText} - selectsStart/> + selectsStart/> <Input type='date' label={i18n('Expiry Date')} @@ -167,8 +168,8 @@ const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, val isValid={genericFieldInfo.expiryDate.isValid} errorText={genericFieldInfo.expiryDate.errorText} selectsEnd/> - </div> - </GridItem> + </div> + </GridItem> </GridSection> ); }; @@ -178,18 +179,18 @@ class EntitlementPoolsEditorView extends React.Component { static propTypes = { data: EntitlementPoolPropType, previousData: EntitlementPoolPropType, - EPNames: React.PropTypes.object, - isReadOnlyMode: React.PropTypes.bool, - onDataChanged: React.PropTypes.func.isRequired, - onSubmit: React.PropTypes.func.isRequired, - onCancel: React.PropTypes.func.isRequired + EPNames: PropTypes.object, + isReadOnlyMode: PropTypes.bool, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired }; static defaultProps = { data: {} }; - componentDidUpdate(prevProps) { + componentDidUpdate(prevProps) { if (this.props.formReady && this.props.formReady !== prevProps.formReady) { // if form validation succeeded -> continue with submit this.submit(); } @@ -207,9 +208,9 @@ class EntitlementPoolsEditorView extends React.Component { return ( <div> - <Tabs - type='menu' - activeTab={selectedTab} + <Tabs + type='menu' + activeTab={selectedTab} onTabClick={(tabIndex)=>{ if (tabIndex === tabIds.ADD_LIMIT_BUTTON) { this.onAddLimit(); @@ -218,14 +219,13 @@ class EntitlementPoolsEditorView extends React.Component { this.setState({selectedLimit: ''}); onCloseLimitEditor(); } - - }} + }} invalidTabs={[]}> <Tab tabId={tabIds.GENERAL} data-test-id='general-tab' title={i18n('General')}> { genericFieldInfo && <Form ref='validationForm' - hasButtons={false} + hasButtons={false} labledButtons={false} isReadOnlyMode={isReadOnlyMode} isValid={this.props.isFormValid} @@ -243,20 +243,20 @@ class EntitlementPoolsEditorView extends React.Component { } </Tab> <Tab disabled={isTabsDisabled} tabId={tabIds.SP_LIMITS} data-test-id='sp-limits-tab' title={i18n('SP Limits')}> - {selectedTab === tabIds.SP_LIMITS && - <EntitlementPoolsLimits + {selectedTab === tabIds.SP_LIMITS && + <EntitlementPoolsLimits isReadOnlyMode={isReadOnlyMode} - limitType={limitType.SERVICE_PROVIDER} + limitType={limitType.SERVICE_PROVIDER} limitsList={limitsList.filter(item => item.type === limitType.SERVICE_PROVIDER)} selectedLimit={this.state.selectedLimit} onCloseLimitEditor={() => this.onCloseLimitEditor()} onSelectLimit={limit => this.onSelectLimit(limit)}/>} </Tab> <Tab disabled={isTabsDisabled} tabId={tabIds.VENDOR_LIMITS} data-test-id='vendor-limits-tab' title={i18n('Vendor Limits')}> - {selectedTab === tabIds.VENDOR_LIMITS && - <EntitlementPoolsLimits + {selectedTab === tabIds.VENDOR_LIMITS && + <EntitlementPoolsLimits isReadOnlyMode={isReadOnlyMode} - limitType={limitType.VENDOR} + limitType={limitType.VENDOR} limitsList={limitsList.filter(item => item.type === limitType.VENDOR)} selectedLimit={this.state.selectedLimit} onCloseLimitEditor={() => this.onCloseLimitEditor()} @@ -273,7 +273,7 @@ class EntitlementPoolsEditorView extends React.Component { {i18n('Add Limit')} </Button> : - <div></div> // Render empty div to not break tabs + <div></div> // Render empty div to not break tabs } </Tabs> <GridSection className='license-model-modal-buttons entitlement-pools-editor-buttons'> @@ -285,21 +285,18 @@ class EntitlementPoolsEditorView extends React.Component { <Button btnType={this.state.selectedLimit ? 'default' : 'outline'} onClick={() => this.props.onCancel()} type='reset'> {i18n('Cancel')} </Button> - </GridSection> + </GridSection> </div> ); } submit() { const {data: entitlementPool, previousData: previousEntitlementPool, formReady} = this.props; - if (!formReady) { this.props.onValidateForm(SP_ENTITLEMENT_POOL_FORM); } else { this.props.onSubmit({entitlementPool, previousEntitlementPool}); } - - } validateName(value) { @@ -329,8 +326,6 @@ class EntitlementPoolsEditorView extends React.Component { this.props.onOpenLimitEditor(); } - - } export default EntitlementPoolsEditorView; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js index 1eb6eebff8..8300594098 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js @@ -20,10 +20,10 @@ import Limits from 'sdc-app/onboarding/licenseModel/limits/Limits.jsx'; import {actionTypes as globalModalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; import EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; -const mapStateToProps = ({licenseModel: {entitlementPool: {entitlementPoolEditor: {data}}, limitEditor}, currentScreen}) => { +const mapStateToProps = ({licenseModel: {entitlementPool: {entitlementPoolEditor: {data}}, limitEditor}, currentScreen}) => { let {props: {licenseModelId, version}} = currentScreen; return { - parent: data, + parent: data, limitEditor, licenseModelId, version @@ -42,10 +42,10 @@ const mapActionsToProps = (dispatch) => { onDelete: ({limit, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit}) => dispatch({ type: globalModalActionTypes.GLOBAL_MODAL_WARNING, data:{ - msg: i18n(`Are you sure you want to delete ${limit.name}?`), + msg: i18n('Are you sure you want to delete {name}?', {name: limit.name}), confirmationButtonText: i18n('Delete'), title: i18n('Delete'), - onConfirmed: ()=> EntitlementPoolsActionHelper.deleteLimit(dispatch, {limit, entitlementPool: parent, licenseModelId, version}).then(() => + onConfirmed: ()=> EntitlementPoolsActionHelper.deleteLimit(dispatch, {limit, entitlementPool: parent, licenseModelId, version}).then(() => selectedLimit === limit.id && onCloseLimitEditor() ) } @@ -53,4 +53,4 @@ const mapActionsToProps = (dispatch) => { }; }; -export default connect(mapStateToProps, mapActionsToProps)(Limits);
\ No newline at end of file +export default connect(mapStateToProps, mapActionsToProps)(Limits); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js index fa21109541..f1dc1f8542 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js @@ -14,26 +14,24 @@ * permissions and limitations under the License. */ import {connect} from 'react-redux'; -import i18n from 'nfvo-utils/i18n/i18n.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; import EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; import EntitlementPoolsListEditorView, {generateConfirmationMsg} from './EntitlementPoolsListEditorView.jsx'; -import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; const mapStateToProps = ({licenseModel: {entitlementPool, licenseModelEditor}}) => { - let {entitlementPoolsList} = entitlementPool; - let {data} = entitlementPool.entitlementPoolEditor; - let {vendorName} = licenseModelEditor.data; - let isReadOnlyMode = VersionControllerUtils.isReadOnly(licenseModelEditor.data); + const {entitlementPoolsList} = entitlementPool; + const {data} = entitlementPool.entitlementPoolEditor; + const {vendorName} = licenseModelEditor.data; return { vendorName, entitlementPoolsList, - isReadOnlyMode, isDisplayModal: Boolean(data), isModalInEditMode: Boolean(data && data.id), }; + }; const mapActionsToProps = (dispatch, {licenseModelId, version}) => { @@ -46,7 +44,7 @@ const mapActionsToProps = (dispatch, {licenseModelId, version}) => { msg: generateConfirmationMsg(entitlementPool), confirmationButtonText: i18n('Delete'), title: i18n('Delete'), - onConfirmed: ()=>EntitlementPoolsActionHelper.deleteEntitlementPool(dispatch, { + onConfirmed: () => EntitlementPoolsActionHelper.deleteEntitlementPool(dispatch, { licenseModelId, entitlementPoolId: entitlementPool.id, version diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx index c730d669c7..cc0cda1992 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; @@ -25,15 +26,15 @@ import {extractUnits} from './EntitlementPoolsConstants'; class EntitlementPoolsListEditorView extends React.Component { static propTypes = { - vendorName: React.PropTypes.string, - licenseModelId: React.PropTypes.string.isRequired, - entitlementPoolsList: React.PropTypes.array, - isReadOnlyMode: React.PropTypes.bool.isRequired, - isDisplayModal: React.PropTypes.bool, - isModalInEditMode: React.PropTypes.bool, - onAddEntitlementPoolClick: React.PropTypes.func, - onEditEntitlementPoolClick: React.PropTypes.func, - onDeleteEntitlementPool: React.PropTypes.func, + vendorName: PropTypes.string, + licenseModelId: PropTypes.string.isRequired, + entitlementPoolsList: PropTypes.array, + isReadOnlyMode: PropTypes.bool.isRequired, + isDisplayModal: PropTypes.bool, + isModalInEditMode: PropTypes.bool, + onAddEntitlementPoolClick: PropTypes.func, + onEditEntitlementPoolClick: PropTypes.func, + onDeleteEntitlementPool: PropTypes.func, }; static defaultProps = { @@ -50,7 +51,7 @@ class EntitlementPoolsListEditorView extends React.Component { const {localFilter} = this.state; return ( - <div className='entitlement-pools-list-editor'> + <div className='license-model-list-editor entitlement-pools-list-editor'> <ListEditorView title={i18n('Entitlement Pools')} plusButtonTitle={i18n('Add Entitlement Pool')} @@ -125,7 +126,7 @@ export default EntitlementPoolsListEditorView; export function generateConfirmationMsg(entitlementPoolToDelete) { let poolName = entitlementPoolToDelete ? entitlementPoolToDelete.name : ''; - let msg = i18n(`Are you sure you want to delete "${poolName}"?`); + let msg = i18n('Are you sure you want to delete "{poolName}"?', {poolName: poolName}); let subMsg = entitlementPoolToDelete && entitlementPoolToDelete.referencingFeatureGroups && entitlementPoolToDelete.referencingFeatureGroups.length > 0 ? diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx index 6a5ee4617c..6d0acaa65d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import Tabs from 'nfvo-components/input/validation/Tabs.jsx'; import Tab from 'sdc-ui/lib/react/Tab.js'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; @@ -26,20 +27,20 @@ import Validator from 'nfvo-utils/Validator.js'; import {state as FeatureGroupStateConstants, FG_EDITOR_FORM} from './FeatureGroupsConstants.js'; -const FeatureGroupsPropType = React.PropTypes.shape({ - id: React.PropTypes.string, - name: React.PropTypes.string, - description: React.PropTypes.string, - partNumber: React.PropTypes.string, - manufacturerReferenceNumber: React.PropTypes.string, - entitlementPoolsIds: React.PropTypes.arrayOf(React.PropTypes.string), - licenseKeyGroupsIds: React.PropTypes.arrayOf(React.PropTypes.string) +const FeatureGroupsPropType = PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + partNumber: PropTypes.string, + manufacturerReferenceNumber: PropTypes.string, + entitlementPoolsIds: PropTypes.arrayOf(PropTypes.string), + licenseKeyGroupsIds: PropTypes.arrayOf(PropTypes.string) }); const GeneralTab = ({data = {}, onDataChanged, genericFieldInfo, validateName}) => { let {name, description, partNumber, manufacturerReferenceNumber} = data; return ( - <GridSection> + <GridSection hasLastColSet> <GridItem colSpan={2}> <Input groupClassName='field-section' @@ -53,7 +54,7 @@ const GeneralTab = ({data = {}, onDataChanged, genericFieldInfo, validateName}) isValid={genericFieldInfo.name.isValid} errorText={genericFieldInfo.name.errorText} /> </GridItem> - <GridItem colSpan={2}> + <GridItem colSpan={2} lastColInRow> <Input groupClassName='field-section' className='description-field' @@ -78,7 +79,7 @@ const GeneralTab = ({data = {}, onDataChanged, genericFieldInfo, validateName}) isValid={genericFieldInfo.partNumber.isValid} errorText={genericFieldInfo.partNumber.errorText} /> </GridItem> - <GridItem colSpan={2}> + <GridItem colSpan={2} lastColInRow> <Input groupClassName='field-section' onChange={manufacturerReferenceNumber => onDataChanged({manufacturerReferenceNumber}, FG_EDITOR_FORM)} @@ -142,14 +143,14 @@ class FeatureGroupEditorView extends React.Component { static propTypes = { data: FeatureGroupsPropType, previousData: FeatureGroupsPropType, - isReadOnlyMode: React.PropTypes.bool, - FGNames: React.PropTypes.object, + isReadOnlyMode: PropTypes.bool, + FGNames: PropTypes.object, - onSubmit: React.PropTypes.func, - onCancel: React.PropTypes.func, + onSubmit: PropTypes.func, + onCancel: PropTypes.func, - selectedTab: React.PropTypes.number, - onTabSelect: React.PropTypes.func, + selectedTab: PropTypes.number, + onTabSelect: PropTypes.func, entitlementPoolsList: DualListboxView.propTypes.availableList, licenseKeyGroupsList: DualListboxView.propTypes.availableList diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js index fc892387c6..26925487db 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js @@ -14,17 +14,16 @@ * permissions and limitations under the License. */ import {connect} from 'react-redux'; - import FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; import FeatureGroupListEditorView, {generateConfirmationMsg} from './FeatureGroupListEditorView.jsx'; -import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; export const mapStateToProps = ({licenseModel: {featureGroup, licenseModelEditor}}) => { + const {featureGroupEditor: {data}, featureGroupsList} = featureGroup; - let {vendorName, version} = licenseModelEditor.data; - let isReadOnlyMode = VersionControllerUtils.isReadOnly(licenseModelEditor.data); + const {vendorName, version} = licenseModelEditor.data; + return { vendorName, version, @@ -32,9 +31,9 @@ export const mapStateToProps = ({licenseModel: {featureGroup, licenseModelEditor show: Boolean(data), editMode: Boolean(data && data.id) }, - featureGroupsList, - isReadOnlyMode + featureGroupsList }; + }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx index 497c29d14c..f59e000c21 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; @@ -24,18 +25,18 @@ import FeatureGroupEditor from './FeatureGroupEditor.js'; class FeatureGroupListEditorView extends React.Component { static propTypes = { - vendorName: React.PropTypes.string, - licenseModelId: React.PropTypes.string.isRequired, - featureGroupsModal: React.PropTypes.shape({ - show: React.PropTypes.bool, - editMode: React.PropTypes.bool + vendorName: PropTypes.string, + licenseModelId: PropTypes.string.isRequired, + featureGroupsModal: PropTypes.shape({ + show: PropTypes.bool, + editMode: PropTypes.bool }), - isReadOnlyMode: React.PropTypes.bool.isRequired, - onAddFeatureGroupClick: React.PropTypes.func, - onEditFeatureGroupClick: React.PropTypes.func, - onDeleteFeatureGroupClick: React.PropTypes.func, - onCancelFeatureGroupsEditor: React.PropTypes.func, - featureGroupsList: React.PropTypes.array + isReadOnlyMode: PropTypes.bool.isRequired, + onAddFeatureGroupClick: PropTypes.func, + onEditFeatureGroupClick: PropTypes.func, + onDeleteFeatureGroupClick: PropTypes.func, + onCancelFeatureGroupsEditor: PropTypes.func, + featureGroupsList: PropTypes.array }; static defaultProps = { @@ -54,7 +55,7 @@ class FeatureGroupListEditorView extends React.Component { let {licenseModelId, featureGroupsModal, isReadOnlyMode, onAddFeatureGroupClick, version} = this.props; const {localFilter} = this.state; return ( - <div className='feature-groups-list-editor'> + <div className='license-model-list-editor feature-groups-list-editor'> <ListEditorView title={i18n('Feature Groups')} plusButtonTitle={i18n('Add Feature Group')} @@ -155,7 +156,7 @@ export default FeatureGroupListEditorView; export function generateConfirmationMsg(featureGroupToDelete) { let name = featureGroupToDelete ? featureGroupToDelete.name : ''; - let msg = i18n(`Are you sure you want to delete "${name}"?`); + let msg = i18n('Are you sure you want to delete "{name}"?', {name: name}); let subMsg = featureGroupToDelete.referencingLicenseAgreements && featureGroupToDelete.referencingLicenseAgreements.length > 0 ? i18n('This feature group is associated with one ore more license agreements') : diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js index b8c03750fb..aadf8e0301 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js @@ -16,9 +16,9 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as featureGroupsActionConstants} from './FeatureGroupsConstants.js'; -import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; import EntitlementPoolsActionHelper from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js'; import LicenseKeyGroupsActionHelper from 'sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; +import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); @@ -26,6 +26,10 @@ function baseUrl(licenseModelId, version) { return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/feature-groups`; } +function fetchFeatureGroup(licenseModelId, featureGroupId, version) { + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}/${featureGroupId}`); +} + function fetchFeatureGroupsList(licenseModelId, version) { return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } @@ -65,6 +69,10 @@ function updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup, } export default { + fetchFeatureGroup(dispatch, {licenseModelId, featureGroupId, version}) { + return fetchFeatureGroup(licenseModelId, featureGroupId, version); + }, + fetchFeatureGroupsList(dispatch, {licenseModelId, version}) { return fetchFeatureGroupsList(licenseModelId, version).then(response => dispatch({ type: featureGroupsActionConstants.FEATURE_GROUPS_LIST_LOADED, @@ -73,10 +81,13 @@ export default { }, deleteFeatureGroup(dispatch, {licenseModelId, featureGroupId, version}) { - return deleteFeatureGroup(licenseModelId, featureGroupId, version).then(() => dispatch({ - type: featureGroupsActionConstants.DELETE_FEATURE_GROUPS, - featureGroupId - })); + return deleteFeatureGroup(licenseModelId, featureGroupId, version).then(() => { + dispatch({ + type: featureGroupsActionConstants.DELETE_FEATURE_GROUPS, + featureGroupId + }); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); + }); }, saveFeatureGroup(dispatch, {licenseModelId, previousFeatureGroup, featureGroup, version}) { @@ -88,6 +99,7 @@ export default { }); EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } else { @@ -102,6 +114,7 @@ export default { }); EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } }, @@ -114,11 +127,14 @@ export default { }, openFeatureGroupsEditor(dispatch, {featureGroup, licenseModelId, version}) { - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.OPEN, - featureGroup + return Promise.all([ + EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}), + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}) + ]).then(() => { + dispatch({ + type: featureGroupsActionConstants.featureGroupsEditor.OPEN, + featureGroup + }); }); }, @@ -126,12 +142,5 @@ export default { dispatch({ type: featureGroupsActionConstants.featureGroupsEditor.CLOSE }); - }, - - - switchVersion(dispatch, {licenseModelId, version}) { - LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { - this.fetchFeatureGroupsList(dispatch, {licenseModelId, version}); - }); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js index e9d922c212..b4f03a68cd 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js @@ -17,7 +17,7 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as licenseAgreementActionTypes} from './LicenseAgreementConstants.js'; import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js'; -import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; +import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); @@ -29,6 +29,10 @@ function fetchLicenseAgreementList(licenseModelId, version) { return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } +function fetchLicenseAgreement(licenseModelId, licenseAgreementId, version) { + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}/${licenseAgreementId}`); +} + function postLicenseAgreement(licenseModelId, licenseAgreement, version) { return RestAPIUtil.post(baseUrl(licenseModelId, version), { name: licenseAgreement.name, @@ -65,6 +69,10 @@ export default { })); }, + fetchLicenseAgreement(dispatch, {licenseModelId, licenseAgreementId, version}) { + return fetchLicenseAgreement(licenseModelId, licenseAgreementId, version); + }, + openLicenseAgreementEditor(dispatch, {licenseModelId, licenseAgreement, version}) { FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version}); dispatch({ @@ -84,12 +92,14 @@ export default { if (previousLicenseAgreement) { return putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAgreement, version).then(() => { this.fetchLicenseAgreementList(dispatch, {licenseModelId, version}); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } else { return postLicenseAgreement(licenseModelId, licenseAgreement, version).then(() => { this.fetchLicenseAgreementList(dispatch, {licenseModelId, version}); FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version}); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } }, @@ -100,6 +110,7 @@ export default { type: licenseAgreementActionTypes.DELETE_LICENSE_AGREEMENT, licenseAgreementId }); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); }, @@ -108,11 +119,5 @@ export default { type: licenseAgreementActionTypes.licenseAgreementEditor.SELECT_TAB, tab }); - }, - - switchVersion(dispatch, {licenseModelId, version}) { - LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { - this.fetchLicenseAgreementList(dispatch, {licenseModelId, version}); - }); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx index 0b418686fd..a3e73f4f14 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx @@ -14,7 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; - +import PropTypes from 'prop-types'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; import {TabsForm as Form} from 'nfvo-components/input/validation/Form.jsx'; @@ -34,21 +34,21 @@ const dualBoxFilterTitle = { right: i18n('Selected Feature Groups') }; -const LicenseAgreementPropType = React.PropTypes.shape({ - id: React.PropTypes.string, - name: React.PropTypes.string, - description: React.PropTypes.string, - requirementsAndConstrains: React.PropTypes.string, - licenseTerm: React.PropTypes.object, - featureGroupsIds: React.PropTypes.arrayOf(React.PropTypes.string), - version: React.PropTypes.object +const LicenseAgreementPropType = PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + requirementsAndConstrains: PropTypes.string, + licenseTerm: PropTypes.object, + featureGroupsIds: PropTypes.arrayOf(PropTypes.string), + version: PropTypes.object }); const GeneralTabContent = ({data, genericFieldInfo, onDataChanged, validateName}) => { let {name, description, requirementsAndConstrains, licenseTerm} = data; return ( - <GridSection> + <GridSection hasLastColSet> <GridItem colSpan={2}> <Input isValid={genericFieldInfo.name.isValid} @@ -86,7 +86,7 @@ const GeneralTabContent = ({data, genericFieldInfo, onDataChanged, validateName} isValid={genericFieldInfo.licenseTerm.isValid} errorText={genericFieldInfo.licenseTerm.errorText} /> </GridItem> - <GridItem colSpan={2} stretch> + <GridItem colSpan={2} stretch lastColInRow> <Input isValid={genericFieldInfo.description.isValid} errorText={genericFieldInfo.description.errorText} @@ -107,17 +107,17 @@ class LicenseAgreementEditorView extends React.Component { static propTypes = { data: LicenseAgreementPropType, previousData: LicenseAgreementPropType, - LANames: React.PropTypes.object, - isReadOnlyMode: React.PropTypes.bool, - onDataChanged: React.PropTypes.func.isRequired, - onSubmit: React.PropTypes.func.isRequired, - onCancel: React.PropTypes.func.isRequired, + LANames: PropTypes.object, + isReadOnlyMode: PropTypes.bool, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired, - selectedTab: React.PropTypes.number, - onTabSelect: React.PropTypes.func, + selectedTab: PropTypes.number, + onTabSelect: PropTypes.func, - selectedFeatureGroupsButtonTab: React.PropTypes.number, - onFeatureGroupsButtonTabSelect: React.PropTypes.func, + selectedFeatureGroupsButtonTab: PropTypes.number, + onFeatureGroupsButtonTabSelect: PropTypes.func, featureGroupsList: DualListboxView.propTypes.availableList }; @@ -151,7 +151,7 @@ class LicenseAgreementEditorView extends React.Component { data-test-id='general-tab' title={i18n('General')}> <fieldset disabled={isReadOnlyMode}> - <GeneralTabContent data={data} genericFieldInfo={genericFieldInfo} onDataChanged={onDataChanged} + <GeneralTabContent data={data} genericFieldInfo={genericFieldInfo} onDataChanged={onDataChanged} validateLTChoice={(value)=>this.validateLTChoice(value)} validateName={(value)=>this.validateName(value)}/> </fieldset> </Tab> @@ -181,6 +181,12 @@ class LicenseAgreementEditorView extends React.Component { this.props.onSubmit({licenseAgreement, previousLicenseAgreement}); } + validateLTChoice(value) { + if (!value.choice) { + return {isValid: false, errorText: i18n('Field is required')}; + } + return {isValid: true, errorText: ''}; + } validateName(value) { const {data: {id}, LANames} = this.props; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js index 92c2550c1c..72474ecdd3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js @@ -17,24 +17,22 @@ import {connect} from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import LicenseAgreementActionHelper from './LicenseAgreementActionHelper.js'; import LicenseAgreementListEditorView from './LicenseAgreementListEditorView.jsx'; -import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; const mapStateToProps = ({licenseModel: {licenseAgreement, licenseModelEditor}}) => { + let {licenseAgreementList} = licenseAgreement; let {data} = licenseAgreement.licenseAgreementEditor; let {vendorName, version} = licenseModelEditor.data; - let isReadOnlyMode = VersionControllerUtils.isReadOnly(licenseModelEditor.data); - return { vendorName, version, licenseAgreementList, - isReadOnlyMode, isDisplayModal: Boolean(data), isModalInEditMode: Boolean(data && data.id) }; + }; const mapActionsToProps = (dispatch, {licenseModelId}) => { @@ -44,7 +42,7 @@ const mapActionsToProps = (dispatch, {licenseModelId}) => { onDeleteLicenseAgreement: (licenseAgreement, version) => dispatch({ type: globalMoadlActions.GLOBAL_MODAL_WARNING, data:{ - msg: i18n(`Are you sure you want to delete "${licenseAgreement.name}"?`), + msg: i18n('Are you sure you want to delete "{name}"?', {name: licenseAgreement.name}), confirmationButtonText: i18n('Delete'), title: i18n('Delete'), onConfirmed: ()=>LicenseAgreementActionHelper.deleteLicenseAgreement(dispatch, {licenseModelId, licenseAgreementId: licenseAgreement.id, version}) diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx index 6247723d72..ad3cdb0b58 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; @@ -24,15 +25,15 @@ import {extractValue} from './LicenseAgreementConstants'; class LicenseAgreementListEditorView extends React.Component { static propTypes = { - vendorName: React.PropTypes.string, - licenseModelId: React.PropTypes.string.isRequired, - licenseAgreementList: React.PropTypes.array, - isReadOnlyMode: React.PropTypes.bool.isRequired, - isDisplayModal: React.PropTypes.bool, - isModalInEditMode: React.PropTypes.bool, - onAddLicenseAgreementClick: React.PropTypes.func, - onEditLicenseAgreementClick: React.PropTypes.func, - onDeleteLicenseAgreement: React.PropTypes.func, + vendorName: PropTypes.string, + licenseModelId: PropTypes.string.isRequired, + licenseAgreementList: PropTypes.array, + isReadOnlyMode: PropTypes.bool.isRequired, + isDisplayModal: PropTypes.bool, + isModalInEditMode: PropTypes.bool, + onAddLicenseAgreementClick: PropTypes.func, + onEditLicenseAgreementClick: PropTypes.func, + onDeleteLicenseAgreement: PropTypes.func, }; static defaultProps = { @@ -49,7 +50,7 @@ class LicenseAgreementListEditorView extends React.Component { const {localFilter} = this.state; return ( - <div className='license-agreement-list-editor'> + <div className='license-model-list-editor license-agreement-list-editor'> <ListEditorView title={i18n('License Agreements')} plusButtonTitle={i18n('Add License Agreement')} diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js index f22080a75c..4d86815276 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js @@ -16,9 +16,9 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as licenseKeyGroupsConstants} from './LicenseKeyGroupsConstants.js'; -import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; import {actionTypes as limitEditorActions} from 'sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js'; import {default as getValue, getStrValue} from 'nfvo-utils/getValue.js'; +import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); @@ -128,6 +128,7 @@ export default { type: licenseKeyGroupsConstants.EDIT_LICENSE_KEY_GROUP, licenseKeyGroup }); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } else { @@ -140,6 +141,7 @@ export default { id: response.value } }); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } @@ -152,6 +154,7 @@ export default { type: licenseKeyGroupsConstants.DELETE_LICENSE_KEY_GROUP, licenseKeyGroupId }); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); }, @@ -169,12 +172,6 @@ export default { }); }, - switchVersion(dispatch, {licenseModelId, version}) { - LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { - this.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); - }); - }, - fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}) { return fetchLimitsList(licenseModelId, licenseKeyGroup.id, version).then(response => { @@ -193,12 +190,14 @@ export default { type: limitEditorActions.CLOSE }); this.fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); }, deleteLimit(dispatch, {licenseModelId, version, licenseKeyGroup, limit}) { return deleteLimit(licenseModelId,licenseKeyGroup.id, version, limit.id).then(() => { this.fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}); + ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); }); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx index 70fb43ee88..87c947eb02 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Validator from 'nfvo-utils/Validator.js'; @@ -36,26 +37,26 @@ import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js'; import LicenseKeyGroupsLimits from './LicenseKeyGroupsLimits.js'; import {limitType, NEW_LIMIT_TEMP_ID} from '../limits/LimitEditorConstants.js'; - const LicenseKeyGroupPropType = React.PropTypes.shape({ - id: React.PropTypes.string, - name: React.PropTypes.string, - description: React.PropTypes.string, - increments: React.PropTypes.string, - operationalScope: React.PropTypes.shape({ - choices: React.PropTypes.array, - other: React.PropTypes.string + const LicenseKeyGroupPropType = PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + increments: PropTypes.string, + operationalScope: PropTypes.shape({ + choices: PropTypes.array, + other: PropTypes.string }), - type: React.PropTypes.string, - thresholdUnits: React.PropTypes.string, - thresholdValue: React.PropTypes.number, - startDate: React.PropTypes.string, - expiryDate: React.PropTypes.string + type: PropTypes.string, + thresholdUnits: PropTypes.string, + thresholdValue: PropTypes.number, + startDate: PropTypes.string, + expiryDate: PropTypes.string }); const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, validateName, validateStartDate, thresholdValueValidation}) => { let {name, description, increments, operationalScope, type, thresholdUnits, thresholdValue, startDate, expiryDate} = data; return ( - <GridSection> + <GridSection hasLostColSet> <GridItem colSpan={2}> <Input onChange={name => onDataChanged({name}, LKG_FORM_NAME, {name: validateName})} @@ -67,7 +68,7 @@ const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, vali isRequired={true} type='text'/> </GridItem> - <GridItem colSpan={2}> + <GridItem colSpan={2} lastColInRow> <InputOptions onInputChange={()=>{}} isMultiSelect={true} @@ -95,7 +96,7 @@ const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, vali type='textarea' overlayPos='bottom' /> </GridItem> - <GridItem colSpan={2}> + <GridItem colSpan={2} lastColInRow> <Input isRequired={true} onChange={e => { const selectedIndex = e.target.selectedIndex; @@ -108,6 +109,7 @@ const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, vali errorText={genericFieldInfo.type.errorText} groupClassName='bootstrap-input-options' className='input-options-select' + overlayPos='bottom' type='select' > { licenseKeyGroupOptionsInputValues.TYPE.map(type => @@ -167,7 +169,7 @@ const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, vali errorText={genericFieldInfo.startDate.errorText} selectsStart/> </GridItem> - <GridItem> + <GridItem lastColInRow> <Input type='date' label={i18n('Expiry Date')} @@ -199,18 +201,18 @@ class LicenseKeyGroupsEditorView extends React.Component { static propTypes = { data: LicenseKeyGroupPropType, previousData: LicenseKeyGroupPropType, - LKGNames: React.PropTypes.object, - isReadOnlyMode: React.PropTypes.bool, - onDataChanged: React.PropTypes.func.isRequired, - onSubmit: React.PropTypes.func.isRequired, - onCancel: React.PropTypes.func.isRequired + LKGNames: PropTypes.object, + isReadOnlyMode: PropTypes.bool, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired }; static defaultProps = { data: {} }; - componentDidUpdate(prevProps) { + componentDidUpdate(prevProps) { if (this.props.formReady && this.props.formReady !== prevProps.formReady) { // if form validation succeeded -> continue with submit this.submit(); } @@ -229,8 +231,8 @@ class LicenseKeyGroupsEditorView extends React.Component { return ( <div className='license-keygroup-editor'> <Tabs - type='menu' - activeTab={selectedTab} + type='menu' + activeTab={selectedTab} onTabClick={(tabIndex)=>{ if (tabIndex === tabIds.ADD_LIMIT_BUTTON) { this.onAddLimit(); @@ -239,7 +241,7 @@ class LicenseKeyGroupsEditorView extends React.Component { onCloseLimitEditor(); this.setState({selectedLimit: ''}); } - }} + }} invalidTabs={[]}> <Tab tabId={tabIds.GENERAL} data-test-id='general-tab' title={i18n('General')}> { genericFieldInfo && @@ -292,10 +294,10 @@ class LicenseKeyGroupsEditorView extends React.Component { {i18n('Add Limit')} </Button> : - <div></div> // Render empty div to not break tabs + <div></div> // Render empty div to not break tabs } </Tabs> - + <GridSection className='license-model-modal-buttons license-key-group-editor-buttons'> {!this.state.selectedLimit && <Button btnType='default' disabled={!this.props.isFormValid || isReadOnlyMode} onClick={() => this.submit()} type='reset'> diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js index 0e20a6a486..bd8f21a7c5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js @@ -21,10 +21,10 @@ import Limits from 'sdc-app/onboarding/licenseModel/limits/Limits.jsx'; import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; -const mapStateToProps = ({licenseModel: {licenseKeyGroup: {licenseKeyGroupsEditor: {data}}, limitEditor}, currentScreen}) => { +const mapStateToProps = ({licenseModel: {licenseKeyGroup: {licenseKeyGroupsEditor: {data}}, limitEditor}, currentScreen}) => { let {props: {licenseModelId, version}} = currentScreen; return { - parent: data, + parent: data, limitEditor, licenseModelId, version @@ -39,14 +39,14 @@ const mapActionsToProps = (dispatch) => { limit, licenseKeyGroup, licenseModelId, - version}), + version}), onDelete: ({limit, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit}) => dispatch({ type: globalModalActionTypes.GLOBAL_MODAL_WARNING, data:{ - msg: i18n(`Are you sure you want to delete ${limit.name}?`), + msg: i18n('Are you sure you want to delete {name}?', {name: limit.name}), confirmationButtonText: i18n('Delete'), title: i18n('Delete'), - onConfirmed: ()=> LicenseKeyGroupsActionHelper.deleteLimit(dispatch, {limit, licenseKeyGroup: parent, licenseModelId, version}).then(() => + onConfirmed: ()=> LicenseKeyGroupsActionHelper.deleteLimit(dispatch, {limit, licenseKeyGroup: parent, licenseModelId, version}).then(() => selectedLimit === limit.id && onCloseLimitEditor() ) } @@ -54,4 +54,4 @@ const mapActionsToProps = (dispatch) => { }; }; -export default connect(mapStateToProps, mapActionsToProps)(Limits);
\ No newline at end of file +export default connect(mapStateToProps, mapActionsToProps)(Limits); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js index c1d937394a..00c2092b83 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js @@ -15,21 +15,20 @@ */ import {connect} from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; + +import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; + import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; import LicenseKeyGroupsListEditorView, {generateConfirmationMsg} from './LicenseKeyGroupsListEditorView.jsx'; -import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; -import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; const mapStateToProps = ({licenseModel: {licenseKeyGroup, licenseModelEditor}}) => { let {licenseKeyGroupsList} = licenseKeyGroup; let {data} = licenseKeyGroup.licenseKeyGroupsEditor; let {vendorName} = licenseModelEditor.data; - let isReadOnlyMode = VersionControllerUtils.isReadOnly(licenseModelEditor.data); return { vendorName, licenseKeyGroupsList, - isReadOnlyMode, isDisplayModal: Boolean(data), isModalInEditMode: Boolean(data && data.id) }; @@ -45,11 +44,10 @@ const mapActionsToProps = (dispatch, {licenseModelId, version}) => { msg: generateConfirmationMsg(licenseKeyGroup), confirmationButtonText: i18n('Delete'), title: i18n('Delete'), - onConfirmed: ()=>LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId:licenseKeyGroup.id, version}) + onConfirmed: () => LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId:licenseKeyGroup.id, version}) } }) }; }; export default connect(mapStateToProps, mapActionsToProps)(LicenseKeyGroupsListEditorView); - diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx index 1a7f2b0b5b..5a98b7f575 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx @@ -14,7 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; - +import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; @@ -26,15 +26,15 @@ import {optionsInputValues} from './LicenseKeyGroupsConstants'; class LicenseKeyGroupsListEditorView extends React.Component { static propTypes = { - vendorName: React.PropTypes.string, - licenseModelId: React.PropTypes.string.isRequired, - licenseKeyGroupsList: React.PropTypes.array, - isReadOnlyMode: React.PropTypes.bool.isRequired, - isDisplayModal: React.PropTypes.bool, - isModalInEditMode: React.PropTypes.bool, - onAddLicenseKeyGroupClick: React.PropTypes.func, - onEditLicenseKeyGroupClick: React.PropTypes.func, - onDeleteLicenseKeyGroupClick: React.PropTypes.func + vendorName: PropTypes.string, + licenseModelId: PropTypes.string.isRequired, + licenseKeyGroupsList: PropTypes.array, + isReadOnlyMode: PropTypes.bool.isRequired, + isDisplayModal: PropTypes.bool, + isModalInEditMode: PropTypes.bool, + onAddLicenseKeyGroupClick: PropTypes.func, + onEditLicenseKeyGroupClick: PropTypes.func, + onDeleteLicenseKeyGroupClick: PropTypes.func }; static defaultProps = { @@ -51,7 +51,7 @@ class LicenseKeyGroupsListEditorView extends React.Component { const {localFilter} = this.state; return ( - <div className='license-key-groups-list-editor'> + <div className='license-model-list-editor license-key-groups-list-editor'> <ListEditorView title={i18n('License Key Groups')} plusButtonTitle={i18n('Add License Key Group')} @@ -122,26 +122,24 @@ class LicenseKeyGroupsListEditorView extends React.Component { } getOperationalScopes(operationalScope) { - - if(operationalScope.choices && operationalScope.choices.toString() === i18n(optionInputOther.OTHER)) { + + if (operationalScope.choices && operationalScope.choices.toString() === i18n(optionInputOther.OTHER)) { return operationalScope.other; - } - else if (operationalScope.choices) { + } else if (operationalScope.choices) { let allOpScopes = ''; for (let opScope of operationalScope.choices) { allOpScopes += allOpScopes === '' ? InputOptions.getTitleByName(optionsInputValues, opScope) : `, ${InputOptions.getTitleByName(optionsInputValues, opScope)}`; } return allOpScopes; - } - else { + } else { return ''; - } + } } extractValue(item) { if (item === undefined) { return ''; - } //TODO fix it later + } //TODO fix it sooner rather than later return item ? item.choice === optionInputOther.OTHER ? item.other : InputOptions.getTitleByName(optionsInputValues, item.choice) : ''; } @@ -151,7 +149,7 @@ export default LicenseKeyGroupsListEditorView; export function generateConfirmationMsg(licenseKeyGroupToDelete) { let name = licenseKeyGroupToDelete ? licenseKeyGroupToDelete.name : ''; - let msg = i18n(`Are you sure you want to delete "${name}"?`); + let msg = i18n('Are you sure you want to delete "{name}"?', {name: name}); let subMsg = licenseKeyGroupToDelete.referencingFeatureGroups && licenseKeyGroupToDelete.referencingFeatureGroups.length > 0 ? i18n('This license key group is associated with one or more feature groups') : diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx index 110e5137e1..54f057eaa4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Form from 'nfvo-components/input/validation/Form.jsx'; import Input from 'nfvo-components/input/validation/Input.jsx'; @@ -10,35 +11,35 @@ import Validator from 'nfvo-utils/Validator.js'; import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; -const LimitPropType = React.PropTypes.shape({ - id: React.PropTypes.string, - name: React.PropTypes.string, - description: React.PropTypes.string, - metric: React.PropTypes.shape({ - choice: React.PropTypes.string, - other: React.PropTypes.string +const LimitPropType = PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + metric: PropTypes.shape({ + choice: PropTypes.string, + other: PropTypes.string }), - value: React.PropTypes.string, - aggregationFunction: React.PropTypes.string, - time: React.PropTypes.string, - unit: React.PropTypes.shape({ - choice: React.PropTypes.string, - other: React.PropTypes.string + value: PropTypes.string, + aggregationFunction: PropTypes.string, + time: PropTypes.string, + unit: PropTypes.shape({ + choice: PropTypes.string, + other: PropTypes.string }) }); class LimitEditor extends React.Component { static propTypes = { data: LimitPropType, - limitsNames: React.PropTypes.object, - isReadOnlyMode: React.PropTypes.bool, - isFormValid: React.PropTypes.bool, - formReady: React.PropTypes.bool, - genericFieldInfo: React.PropTypes.object.isRequired, - onDataChanged: React.PropTypes.func.isRequired, - onSubmit: React.PropTypes.func.isRequired, - onValidateForm: React.PropTypes.func.isRequired, - onCancel: React.PropTypes.func.isRequired + limitsNames: PropTypes.object, + isReadOnlyMode: PropTypes.bool, + isFormValid: PropTypes.bool, + formReady: PropTypes.bool, + genericFieldInfo: PropTypes.object.isRequired, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onValidateForm: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired }; componentDidUpdate(prevProps) { @@ -67,7 +68,7 @@ class LimitEditor extends React.Component { labledButtons={false} isReadOnlyMode={isReadOnlyMode} className='limit-editor-form'> - <GridSection className='limit-editor-form-grid-section'> + <GridSection className='limit-editor-form-grid-section' hasLastColSet> <GridItem colSpan={2}> <Input onChange={name => onDataChanged({name}, LIMITS_FORM_NAME, {name: () => this.validateName(name)})} @@ -79,7 +80,7 @@ class LimitEditor extends React.Component { isRequired={true} type='text'/> </GridItem> - <GridItem colSpan={2}> + <GridItem colSpan={2} lastColInRow> <Input onChange={description => onDataChanged({description}, LIMITS_FORM_NAME)} label={i18n('Description')} @@ -120,7 +121,7 @@ class LimitEditor extends React.Component { isRequired={true} type='text'/> </GridItem> - <GridItem> + <GridItem lastColInRow> <InputOptions onInputChange={()=>{}} isMultiSelect={false} diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js index 9d714ec62d..54941aaaf0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js @@ -15,12 +15,20 @@ */ import {connect} from 'react-redux'; import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; -import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import LicenseModelOverviewView from './LicenseModelOverviewView.jsx'; import {overviewEditorHeaders, selectedButton} from './LicenseModelOverviewConstants.js'; import licenseModelOverviewActionHelper from './licenseModelOverviewActionHelper.js'; -export const mapStateToProps = ({licenseModel: {licenseModelEditor, entitlementPool, licenseAgreement, featureGroup, licenseKeyGroup, licenseModelOverview}}) => { +export const mapStateToProps = ({ + licenseModel: { + licenseModelEditor, + entitlementPool, + licenseAgreement, + featureGroup, + licenseKeyGroup, + licenseModelOverview + } +}) => { let modalHeader, licensingDataList; let isDisplayModal = false; @@ -128,6 +136,7 @@ export const mapStateToProps = ({licenseModel: {licenseModelEditor, entitlementP modalHeader = overviewEditorHeaders.LICENSE_KEY_GROUP; isDisplayModal = true; } + let orphanDataList = [ ...featureGroup.featureGroupsList.reduce(checkFG, []), ...entitlementPool.entitlementPoolsList.reduce(checkEP, []), @@ -140,8 +149,8 @@ export const mapStateToProps = ({licenseModel: {licenseModelEditor, entitlementP if (selectedTab === null) { selectedTab = (licensingDataList.length) ? selectedButton.VLM_LIST_VIEW : selectedButton.NOT_IN_USE; } + return { - isReadOnlyMode: VersionControllerUtils.isReadOnly(licenseModelEditor.data), isDisplayModal, modalHeader, licenseModelId: licenseModelEditor.data.id, diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx index 77289a3e08..39109af9a3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; import classNames from 'classnames'; @@ -47,25 +48,25 @@ const setModalClassName = (modalHeader) => { class LicenseModelOverviewView extends React.Component { static propTypes = { - isDisplayModal: React.PropTypes.bool, - isReadOnlyMode: React.PropTypes.bool, - licenseModelId: React.PropTypes.string, - licensingDataList: React.PropTypes.array, - orphanDataList: React.PropTypes.array, - modalHeader: React.PropTypes.string, - selectedTab: React.PropTypes.string, - onTabSelect: React.PropTypes.func, - onCallVCAction: React.PropTypes.func, - onClose: React.PropTypes.func + isDisplayModal: PropTypes.bool, + isReadOnlyMode: PropTypes.bool, + licenseModelId: PropTypes.string, + licensingDataList: PropTypes.array, + orphanDataList: PropTypes.array, + modalHeader: PropTypes.string, + selectedTab: PropTypes.string, + onTabSelect: PropTypes.func, + onCallVCAction: PropTypes.func, + onClose: PropTypes.func }; render() { - let {isDisplayModal, modalHeader, licensingDataList, selectedTab, onTabSelect, orphanDataList} = this.props; + let {isDisplayModal, modalHeader, licensingDataList, selectedTab, onTabSelect, orphanDataList, isReadOnlyMode} = this.props; let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE; let dataList = selectedInUse ? licensingDataList : orphanDataList; return( <div className='license-model-overview'> - <SummaryView/> + <SummaryView isReadOnlyMode={isReadOnlyMode}/> <div className={classNames('overview-list-section ', !selectedInUse ? 'overview-list-orphans' : '' )}> <div className='vlm-list-tab-panel'> <ListButtons onTabSelect={onTabSelect} @@ -91,16 +92,16 @@ class LicenseModelOverviewView extends React.Component { } renderModalBody(modalHeader) { - let {licenseModelId, version} = this.props; + let {licenseModelId, version, isReadOnlyMode} = this.props; switch (modalHeader) { case overviewEditorHeaders.ENTITLEMENT_POOL: - return <EntitlementPoolsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; + return <EntitlementPoolsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>; case overviewEditorHeaders.LICENSE_AGREEMENT: - return <LicenseAgreementEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; + return <LicenseAgreementEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>; case overviewEditorHeaders.FEATURE_GROUP: - return <FeatureGroupEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; + return <FeatureGroupEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>; case overviewEditorHeaders.LICENSE_KEY_GROUP: - return <LicenseKeyGroupsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={false}/>; + return <LicenseKeyGroupsEditor version={version} licenseModelId={licenseModelId} isReadOnlyMode={isReadOnlyMode}/>; } } } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx index 6fcdb477e6..4053f14ced 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx @@ -13,21 +13,24 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React from 'react'; +import React, {Component} from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import {default as VendorDataView} from './summary/VendorDataView.js'; import {default as SummaryCountList} from './summary/SummaryCountList.js'; -function SummaryView() { - return( - <div className='overview-top-section'> - <div className='overview-title'>{i18n('overview')}</div> - <div className='license-model-overview-top'> - <VendorDataView/> - <SummaryCountList/> +class SummaryView extends Component { + render() { + const {isReadOnlyMode} = this.props; + return( + <div className='overview-top-section'> + <div className='page-title'>{i18n('overview')}</div> + <div className='license-model-overview-top'> + <VendorDataView isReadOnlyMode={isReadOnlyMode}/> + <SummaryCountList isReadOnlyMode={isReadOnlyMode}/> + </div> </div> - </div> - ); + ); + } } export default SummaryView; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx index ec05e37681..012bd6e158 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React, {Component} from 'react'; +import PropTypes from 'prop-types'; import {Collapse} from 'react-bootstrap'; import LicenseAgreement from './listItems/LicenseAgreement.jsx'; import EntitlementPool from './listItems/EntitlementPool.jsx'; @@ -24,8 +25,8 @@ import {overviewEditorHeaders} from './LicenseModelOverviewConstants.js'; class VLMListView extends Component { static propTypes = { - licensingDataList: React.PropTypes.array, - showInUse: React.PropTypes.bool + licensingDataList: PropTypes.array, + showInUse: PropTypes.bool }; state = { diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/AdditionalDataCol.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/AdditionalDataCol.jsx index 5b5daafb4f..ffc0991354 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/AdditionalDataCol.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/AdditionalDataCol.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; function AdditionalDataCol({children}) { return ( @@ -27,9 +28,9 @@ function AdditionalDataCol({children}) { } AdditionalDataCol.propTypes = { - children: React.PropTypes.oneOfType([ - React.PropTypes.arrayOf(React.PropTypes.node), - React.PropTypes.node + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node ]) }; @@ -43,9 +44,9 @@ function AdditionalDataElement({className, name, value}) { } AdditionalDataElement.propTypes = { - name: React.PropTypes.string, - value: React.PropTypes.string, - className: React.PropTypes.string + name: PropTypes.string, + value: PropTypes.string, + className: PropTypes.string }; export {AdditionalDataCol, AdditionalDataElement}; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ArrowCol.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ArrowCol.jsx index a5eb9d27dd..29aec64bdd 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ArrowCol.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ArrowCol.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import classNames from 'classnames'; function ArrowCol ({isCollapsed, length}) { @@ -28,8 +29,8 @@ function ArrowCol ({isCollapsed, length}) { } ArrowCol.propTypes = { - isCollapsed: React.PropTypes.bool, - length: React.PropTypes.number + isCollapsed: PropTypes.bool, + length: PropTypes.number }; export default ArrowCol; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ItemInfo.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ItemInfo.jsx index 655a0dd4a8..95ae123974 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ItemInfo.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ItemInfo.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; function ItemInfo({name, description, children}) { return ( @@ -28,11 +29,11 @@ function ItemInfo({name, description, children}) { } ItemInfo.propTypes = { - name: React.PropTypes.string, - description: React.PropTypes.string, - children: React.PropTypes.oneOfType([ - React.PropTypes.arrayOf(React.PropTypes.node), - React.PropTypes.node + name: PropTypes.string, + description: PropTypes.string, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node ]) }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/LicenseModelDescriptionEdit.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/LicenseModelDescriptionEdit.jsx index f4d6d4d42c..af759f1206 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/LicenseModelDescriptionEdit.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/LicenseModelDescriptionEdit.jsx @@ -14,22 +14,23 @@ * permissions and limitations under the License. */ import React from 'react'; -import Input from 'nfvo-components/input/validation/Input.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; +import Input from 'nfvo-components/input/validation/Input.jsx'; class LicenseModelDescriptionEdit extends React.Component { render() { //TODO check if buttons let {onDataChanged, description, genericFieldInfo} = this.props; - let saveButtonClassName = (genericFieldInfo.description.isValid) ? 'description-save' : 'description-save disabled'; + let {isValid, errorText} = genericFieldInfo.description; + let saveButtonClassName = isValid ? 'description-save' : 'description-save disabled'; return( <div className='vendor-description-edit'> <Input onChange={description => onDataChanged({description})} value={description} - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} + isValid={isValid} + errorText={errorText} className='description-edit-textarea' type='textarea'/> <div className='buttons-row'> @@ -50,7 +51,7 @@ class LicenseModelDescriptionEdit extends React.Component { let {onSubmit, data, description} = this.props; onSubmit({ ...data, - description: description + description: description.trim() }); } } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx index f02c82d205..3fcac3c1d8 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx @@ -14,6 +14,7 @@ * permissions and limitations under the License. */ import React from 'react'; +import PropTypes from 'prop-types'; import {selectedButton} from '../LicenseModelOverviewConstants.js'; import Tabs from 'sdc-ui/lib/react/Tabs.js'; import Tab from 'sdc-ui/lib/react/Tab.js'; @@ -43,8 +44,8 @@ function ListButtons ({onTabSelect, selectedTab, hasOrphans, hasLicensing}) { } ListButtons.propTypes = { - onTabSelect: React.PropTypes.func, - selectedInUse: React.PropTypes.bool + onTabSelect: PropTypes.func, + selectedInUse: PropTypes.bool }; export default ListButtons; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountItem.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountItem.jsx index 6ec84e16ca..50c547e042 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountItem.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountItem.jsx @@ -24,7 +24,8 @@ function SummaryCountItem ({name, counter, onAdd, onNavigate, isReadOnlyMode}) <span className='item-name' onClick={onNavigate}>{name}</span> <span className='item-count' onClick={onNavigate} data-test-id={'vlm-summary-vendor-counter-' + name.toLowerCase().replace(/\s/g,'-')}>({counter})</span> </div> - <SVGIcon name='plusCircle' disabled={isReadOnlyMode} color='secondary' onClick={onAdd} data-test-id={'vlm-summary-vendor-add-btn-' + name.toLowerCase().replace(/\s/g,'-')}/> + <SVGIcon name='plusCircle' disabled={isReadOnlyMode} className={isReadOnlyMode ? 'disabled' : ''} + color='secondary' onClick={onAdd} data-test-id={'vlm-summary-vendor-add-btn-' + name.toLowerCase().replace(/\s/g,'-')}/> </div> ); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountList.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountList.js index c69a092d23..15b6649543 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountList.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountList.js @@ -16,9 +16,9 @@ import React from 'react'; import {connect} from 'react-redux'; -import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; +import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; -import OnboardingActionHelper from '../../../OnboardingActionHelper.js'; import EntitlementPoolsActionHelper from '../../entitlementPools/EntitlementPoolsActionHelper.js'; import LicenseAgreementActionHelper from '../../licenseAgreement/LicenseAgreementActionHelper.js'; import LicenseKeyGroupsActionHelper from '../../licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; @@ -27,27 +27,32 @@ import FeatureGroupsActionHelper from '../../featureGroups/FeatureGroupsActionHe import {overviewItems} from '../LicenseModelOverviewConstants.js'; import SummaryCountItem from './SummaryCountItem.jsx'; -export const mapStateToProps = ({licenseModel: {licenseModelEditor, licenseAgreement: {licenseAgreementList}, - featureGroup: {featureGroupsList}, entitlementPool: {entitlementPoolsList}, licenseKeyGroup: {licenseKeyGroupsList}}}) => { +export const mapStateToProps = ({ + licenseModel: { + licenseModelEditor, + licenseAgreement: {licenseAgreementList}, + featureGroup: {featureGroupsList}, + entitlementPool: {entitlementPoolsList}, + licenseKeyGroup: {licenseKeyGroupsList} + } +}) => { let {vendorName, description, id, version} = licenseModelEditor.data; - - let isReadOnlyMode = VersionControllerUtils.isReadOnly(licenseModelEditor.data); - let counts = [ {name: overviewItems.LICENSE_AGREEMENTS, count: licenseAgreementList.length}, {name: overviewItems.FEATURE_GROUPS, count: featureGroupsList.length}, {name: overviewItems.ENTITLEMENT_POOLS, count: entitlementPoolsList.length}, {name: overviewItems.LICENSE_KEY_GROUPS, count: licenseKeyGroupsList.length}, ]; + return { vendorName, licenseModelId: id, description, counts, - isReadOnlyMode, version }; + }; const mapActionsToProps = (dispatch) => { @@ -71,22 +76,27 @@ const mapActionsToProps = (dispatch) => { } }, onNavigateClick: ({name, licenseModelId, version}) => { + let screenToNavigate; switch (name) { case overviewItems.ENTITLEMENT_POOLS: - OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version}); + screenToNavigate = enums.SCREEN.ENTITLEMENT_POOLS; break; case overviewItems.FEATURE_GROUPS: - OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version}); + screenToNavigate = enums.SCREEN.FEATURE_GROUPS; break; case overviewItems.LICENSE_AGREEMENTS: - OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version}); + screenToNavigate = enums.SCREEN.LICENSE_AGREEMENTS; break; case overviewItems.LICENSE_KEY_GROUPS: - OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}); + screenToNavigate = enums.SCREEN.LICENSE_KEY_GROUPS; break; default: break; } + ScreensHelper.loadScreen(dispatch, { + screen: screenToNavigate, screenType: screenTypes.LICENSE_MODEL, + props: {licenseModelId, version} + }); } }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js index 532ca32f8e..616355de41 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js @@ -23,17 +23,19 @@ import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import licenseModelOverviewActionHelper from '../licenseModelOverviewActionHelper.js'; import LicenseModelActionHelper from '../../LicenseModelActionHelper.js'; import LicenseModelDescriptionEdit from './LicenseModelDescriptionEdit.jsx'; -import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import {VLM_DESCRIPTION_FORM} from '../LicenseModelOverviewConstants.js'; -export const mapStateToProps = ({licenseModel: {licenseModelEditor: {data}, licenseModelOverview: {descriptionEditor: {data: descriptionData = {}, genericFieldInfo} }}}) => { +export const mapStateToProps = ({ + licenseModel: { + licenseModelEditor: {data}, + licenseModelOverview: {descriptionEditor: {data: descriptionData = {}, genericFieldInfo}} + } +}) => { let {description} = descriptionData; - let isReadOnlyMode = VersionControllerUtils.isReadOnly(data); return { data, description, - genericFieldInfo, - isReadOnlyMode + genericFieldInfo }; }; |