From 7fdf733a64670fceefc3ded35cfa581e1c458179 Mon Sep 17 00:00:00 2001 From: Einav Weiss Keidar Date: Tue, 20 Mar 2018 14:45:40 +0200 Subject: Adding Prettier and fixing up eslint version Issue-ID: SDC-1094 Change-Id: Ie83ad95a03899345dd90235daf0323cbe3bc6afd Signed-off-by: Einav Weiss Keidar --- openecomp-ui/.eslintrc | 71 +- openecomp-ui/.prettierrc | 5 + openecomp-ui/package.json | 304 ++--- .../src/nfvo-components/SubmitErrorResponse.jsx | 228 ++-- .../src/nfvo-components/accordion/Accordion.jsx | 63 +- .../src/nfvo-components/datepicker/Datepicker.jsx | 151 ++- .../src/nfvo-components/editor/TabulatedEditor.jsx | 165 +-- .../fileupload/DraggableUploadFileBox.jsx | 35 +- openecomp-ui/src/nfvo-components/grid/GridItem.jsx | 21 +- .../src/nfvo-components/grid/GridSection.jsx | 35 +- .../src/nfvo-components/input/ExpandableInput.jsx | 177 +-- .../src/nfvo-components/input/SelectInput.jsx | 68 +- .../src/nfvo-components/input/ToggleInput.jsx | 93 +- .../input/dualListbox/DualListboxView.jsx | 348 ++++-- .../src/nfvo-components/input/validation/Form.jsx | 272 +++-- .../src/nfvo-components/input/validation/Input.jsx | 404 ++++--- .../input/validation/InputOptions.jsx | 545 +++++---- .../input/validation/InputWrapper.jsx | 255 ++-- .../src/nfvo-components/input/validation/Tabs.jsx | 116 +- .../input/validation/ValidationButtons.jsx | 81 +- .../listEditor/ListEditorItemView.jsx | 108 +- .../listEditor/ListEditorItemViewField.jsx | 6 +- .../nfvo-components/listEditor/ListEditorView.jsx | 148 ++- .../listEditor/listEditor.stories.js | 77 +- openecomp-ui/src/nfvo-components/loader/Loader.jsx | 61 +- .../src/nfvo-components/loader/LoaderConstants.js | 8 +- .../src/nfvo-components/loader/LoaderReducer.js | 85 +- .../src/nfvo-components/modal/GlobalModal.js | 280 +++-- .../nfvo-components/modal/GlobalModalConstants.js | 26 +- .../nfvo-components/modal/GlobalModalReducer.js | 58 +- openecomp-ui/src/nfvo-components/modal/Modal.jsx | 102 +- .../src/nfvo-components/overlay/Overlay.jsx | 32 +- .../nfvo-components/panel/NavigationSideBar.jsx | 219 ++-- .../panel/versionController/VersionController.jsx | 323 +++-- .../VersionControllerConstants.js | 10 +- .../versionController/components/ActionButtons.jsx | 227 ++-- .../components/CommitCommentModal.jsx | 87 +- .../versionController/components/Permissions.jsx | 106 +- .../nfvo-components/progressBar/ProgressBar.jsx | 33 +- .../nfvo-components/table/SelectActionTable.jsx | 75 +- .../table/SelectActionTableCell.jsx | 36 +- .../nfvo-components/table/SelectActionTableRow.jsx | 77 +- openecomp-ui/src/nfvo-components/tree/Tree.jsx | 406 ++++--- .../src/nfvo-components/tree/Tree.stories.js | 242 ++-- openecomp-ui/src/nfvo-utils/DirectedGraph.js | 44 +- .../src/nfvo-utils/ErrorResponseHandler.js | 103 +- openecomp-ui/src/nfvo-utils/KeyMirror.js | 43 +- openecomp-ui/src/nfvo-utils/RestAPIUtil.js | 231 ++-- openecomp-ui/src/nfvo-utils/ShowFileSaveDialog.js | 69 +- openecomp-ui/src/nfvo-utils/UUID.js | 60 +- openecomp-ui/src/nfvo-utils/Validator.js | 288 +++-- openecomp-ui/src/nfvo-utils/WebSocketUtil.js | 65 +- openecomp-ui/src/nfvo-utils/getValue.js | 54 +- openecomp-ui/src/nfvo-utils/i18n/i18n.js | 132 ++- openecomp-ui/src/nfvo-utils/i18n/i18n.stories.js | 64 +- openecomp-ui/src/nfvo-utils/json/JSONPointer.js | 79 +- openecomp-ui/src/nfvo-utils/json/JSONSchema.js | 489 ++++---- .../src/nfvo-utils/sortByStringProperty.js | 4 +- openecomp-ui/src/sdc-app/AppStore.js | 23 +- openecomp-ui/src/sdc-app/Application.jsx | 53 +- openecomp-ui/src/sdc-app/ModulesOptions.jsx | 292 +++-- openecomp-ui/src/sdc-app/Reducers.js | 16 +- .../src/sdc-app/common/activity-log/ActivityLog.js | 30 +- .../common/activity-log/ActivityLogActionHelper.js | 13 +- .../common/activity-log/ActivityLogConstants.js | 5 +- .../common/activity-log/ActivityLogReducer.js | 10 +- .../common/activity-log/ActivityLogView.jsx | 255 ++-- .../src/sdc-app/common/activity-log/LogixUtil.jsx | 52 +- .../src/sdc-app/common/helpers/ItemsHelper.js | 148 ++- .../src/sdc-app/common/helpers/ScreensHelper.js | 553 +++++---- .../src/sdc-app/common/helpers/ValidationHelper.js | 135 ++- .../src/sdc-app/common/merge/MergeEditor.js | 45 +- .../common/merge/MergeEditorActionHelper.js | 881 ++++++++------ .../sdc-app/common/merge/MergeEditorConstants.js | 375 +++--- .../src/sdc-app/common/merge/MergeEditorReducer.js | 96 +- .../src/sdc-app/common/merge/MergeEditorView.jsx | 568 +++++---- .../src/sdc-app/common/modal/ModalContentMapper.js | 66 +- .../sdc-app/common/reducers/JSONSchemaReducer.js | 288 +++-- .../common/reducers/JSONSchemaReducerConstants.js | 8 +- .../sdc-app/common/reducers/PlainDataReducer.js | 206 ++-- .../common/reducers/PlainDataReducerConstants.js | 6 +- openecomp-ui/src/sdc-app/config/Configuration.js | 66 +- .../src/sdc-app/features/FeaturesActionHelper.js | 32 +- .../src/sdc-app/features/FeaturesConstants.js | 8 +- .../src/sdc-app/features/FeaturesReducer.js | 18 +- openecomp-ui/src/sdc-app/features/featureToggle.js | 47 +- openecomp-ui/src/sdc-app/features/restToggle.js | 12 +- openecomp-ui/src/sdc-app/flows/FlowsActions.js | 321 ++--- openecomp-ui/src/sdc-app/flows/FlowsConstants.js | 32 +- openecomp-ui/src/sdc-app/flows/FlowsEditorModal.js | 77 +- .../src/sdc-app/flows/FlowsEditorModalView.jsx | 101 +- openecomp-ui/src/sdc-app/flows/FlowsListEditor.js | 66 +- .../src/sdc-app/flows/FlowsListEditorView.jsx | 261 ++-- openecomp-ui/src/sdc-app/flows/FlowsListReducer.js | 162 +-- openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx | 97 +- openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js | 4 +- openecomp-ui/src/sdc-app/flows/ImportantLogic.jsx | 58 +- openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx | 54 +- .../sdc-app/flows/SequenceDiagramModelHelper.js | 77 +- openecomp-ui/src/sdc-app/heatValidation.app.jsx | 8 +- .../src/sdc-app/heatvalidation/Attachments.js | 59 +- .../src/sdc-app/heatvalidation/HeatSetup.js | 28 +- .../src/sdc-app/heatvalidation/UploadScreen.jsx | 19 +- .../heatvalidation/UploadScreenActionHelper.js | 290 +++-- .../src/sdc-app/onboarding/GridStyling.stories.js | 342 +++--- openecomp-ui/src/sdc-app/onboarding/Onboarding.js | 4 +- .../sdc-app/onboarding/OnboardingActionHelper.js | 842 ++++++++----- .../src/sdc-app/onboarding/OnboardingConstants.js | 153 +-- .../src/sdc-app/onboarding/OnboardingPunchOut.jsx | 1250 +++++++++++++------- .../src/sdc-app/onboarding/OnboardingReducers.js | 273 +++-- .../sdc-app/onboarding/OnboardingReducersMap.js | 30 +- .../src/sdc-app/onboarding/OnboardingView.jsx | 361 ++++-- .../ArchivedLicenseModelListReducer.js | 14 +- .../FinalizedLicenseModelListReducer.js | 14 +- .../onboarding/licenseModel/LicenseModel.js | 329 +++--- .../licenseModel/LicenseModelActionHelper.js | 392 +++--- .../licenseModel/LicenseModelConstants.js | 27 +- .../licenseModel/LicenseModelEditorReducer.js | 20 +- .../licenseModel/LicenseModelListReducer.js | 14 +- .../onboarding/licenseModel/LicenseModelReducer.js | 117 +- .../licenseModel/LicenseModelValidations.js | 42 +- .../licenseModel/creation/LicenseModelCreation.js | 98 +- .../creation/LicenseModelCreationActionHelper.js | 81 +- .../creation/LicenseModelCreationConstants.js | 6 +- .../creation/LicenseModelCreationReducer.js | 61 +- .../creation/LicenseModelCreationView.jsx | 164 +-- .../EntitlementPoolsActionHelper.js | 410 ++++--- .../entitlementPools/EntitlementPoolsConstants.js | 162 +-- .../entitlementPools/EntitlementPoolsEditor.js | 100 +- .../EntitlementPoolsEditorReducer.js | 172 +-- .../EntitlementPoolsEditorView.jsx | 730 +++++++----- .../entitlementPools/EntitlementPoolsLimits.js | 92 +- .../entitlementPools/EntitlementPoolsListEditor.js | 83 +- .../EntitlementPoolsListEditorView.jsx | 244 ++-- .../EntitlementPoolsListReducer.js | 38 +- .../featureGroups/FeatureGroupEditor.js | 124 +- .../featureGroups/FeatureGroupEditorView.jsx | 483 +++++--- .../featureGroups/FeatureGroupListEditor.js | 90 +- .../featureGroups/FeatureGroupListEditorView.jsx | 313 ++--- .../featureGroups/FeatureGroupsActionHelper.js | 270 +++-- .../featureGroups/FeatureGroupsConstants.js | 32 +- .../featureGroups/FeatureGroupsEditorReducer.js | 133 ++- .../featureGroups/FeatureGroupsListReducer.js | 36 +- .../LicenseAgreementActionHelper.js | 228 ++-- .../licenseAgreement/LicenseAgreementConstants.js | 61 +- .../licenseAgreement/LicenseAgreementEditor.js | 127 +- .../LicenseAgreementEditorReducer.js | 117 +- .../LicenseAgreementEditorView.jsx | 404 ++++--- .../licenseAgreement/LicenseAgreementListEditor.js | 82 +- .../LicenseAgreementListEditorView.jsx | 230 ++-- .../LicenseAgreementListReducer.js | 21 +- .../LicenseKeyGroupsActionHelper.js | 387 +++--- .../licenseKeyGroups/LicenseKeyGroupsConstants.js | 117 +- .../licenseKeyGroups/LicenseKeyGroupsEditor.js | 100 +- .../LicenseKeyGroupsEditorReducer.js | 165 +-- .../LicenseKeyGroupsEditorView.jsx | 772 +++++++----- .../licenseKeyGroups/LicenseKeyGroupsLimits.js | 92 +- .../licenseKeyGroups/LicenseKeyGroupsListEditor.js | 77 +- .../LicenseKeyGroupsListEditorView.jsx | 326 ++--- .../LicenseKeyGroupsListReducer.js | 39 +- .../onboarding/licenseModel/limits/LimitEditor.js | 39 +- .../onboarding/licenseModel/limits/LimitEditor.jsx | 517 +++++--- .../licenseModel/limits/LimitEditorActionHelper.js | 68 +- .../licenseModel/limits/LimitEditorConstants.js | 89 +- .../licenseModel/limits/LimitEditorReducer.js | 119 +- .../onboarding/licenseModel/limits/Limits.jsx | 222 ++-- .../onboarding/licenseModel/limits/LimitsServer.js | 46 +- .../licenseModel/overview/LicenseModelOverview.js | 349 +++--- .../overview/LicenseModelOverviewConstants.js | 24 +- .../overview/LicenseModelOverviewView.jsx | 194 +-- .../licenseModel/overview/SummaryView.jsx | 30 +- .../licenseModel/overview/VLMListView.jsx | 202 ++-- .../overview/licenseModelOverviewActionHelper.js | 38 +- .../overview/listItems/EntitlementPool.jsx | 55 +- .../overview/listItems/FeatureGroup.jsx | 108 +- .../overview/listItems/LicenseAgreement.jsx | 89 +- .../overview/listItems/LicenseKeyGroup.jsx | 65 +- .../listItemsComponents/AdditionalDataCol.jsx | 46 +- .../listItems/listItemsComponents/ArrowCol.jsx | 26 +- .../listItems/listItemsComponents/IconCol.jsx | 14 +- .../listItems/listItemsComponents/ItemInfo.jsx | 34 +- .../summary/LicenseModelDescriptionEdit.jsx | 80 +- .../licenseModel/overview/summary/ListButtons.jsx | 50 +- .../overview/summary/SummaryCountItem.jsx | 50 +- .../overview/summary/SummaryCountList.js | 227 ++-- .../overview/summary/VendorDataView.js | 196 +-- .../onboarding/onboard/CatalogItemDetails.jsx | 137 ++- .../onboard/CatalogItemDetails.stories.js | 55 +- .../src/sdc-app/onboarding/onboard/CatalogList.jsx | 78 +- .../sdc-app/onboarding/onboard/CatalogModal.jsx | 75 +- .../onboarding/onboard/DetailsCatalogView.jsx | 88 +- .../src/sdc-app/onboarding/onboard/Onboard.js | 184 +-- .../onboarding/onboard/OnboardActionHelper.js | 219 ++-- .../sdc-app/onboarding/onboard/OnboardConstants.js | 12 +- .../sdc-app/onboarding/onboard/OnboardReducer.js | 26 +- .../src/sdc-app/onboarding/onboard/OnboardView.jsx | 150 +-- .../sdc-app/onboarding/onboard/filter/Filter.jsx | 205 +++- .../onboarding/onboard/filter/FilterConstants.js | 8 +- .../onboarding/onboard/filter/FilterReducer.js | 22 +- .../OnboardingCatalogActionHelper.js | 131 +- .../OnboardingCatalogConstants.js | 38 +- .../onboardingCatalog/OnboardingCatalogReducer.js | 19 +- .../onboardingCatalog/OnboardingCatalogUtils.js | 6 +- .../onboardingCatalog/OnboardingCatalogView.jsx | 274 +++-- .../onboard/onboardingCatalog/Tooltip.jsx | 24 +- .../onboard/onboardingCatalog/VSPOverlay.jsx | 68 +- .../onboardingCatalog/VendorCatalogReducer.js | 40 +- .../onboardingCatalog/VendorCatalogView.jsx | 134 ++- .../onboard/onboardingCatalog/VendorItem.jsx | 158 +-- .../onboarding/onboard/workspace/WorkspaceView.jsx | 58 +- .../permissions/PermissionsActionHelper.js | 170 +-- .../onboarding/permissions/PermissionsConstants.js | 9 +- .../onboarding/permissions/PermissionsManager.js | 61 +- .../onboarding/permissions/PermissionsManager.jsx | 221 ++-- .../onboarding/permissions/PermissionsReducer.js | 22 +- .../src/sdc-app/onboarding/revisions/Revisions.js | 35 +- .../onboarding/revisions/RevisionsActionHelper.js | 128 +- .../onboarding/revisions/RevisionsConstants.js | 2 +- .../onboarding/revisions/RevisionsReducer.js | 16 +- .../sdc-app/onboarding/revisions/RevisionsView.jsx | 160 ++- .../ArchivedSoftwareProductReducer.js | 14 +- .../FinalizedSoftwareProductReducer.js | 14 +- .../onboarding/softwareProduct/SoftwareProduct.js | 947 ++++++++++----- .../softwareProduct/SoftwareProductActionHelper.js | 1174 ++++++++++-------- .../SoftwareProductCategoriesHelper.js | 30 +- .../softwareProduct/SoftwareProductConstants.js | 49 +- .../softwareProduct/SoftwareProductListReducer.js | 26 +- .../softwareProduct/SoftwareProductReducer.js | 176 ++- .../attachments/SoftwareProductAttachments.js | 206 ++-- .../SoftwareProductAttachmentsActionHelper.js | 14 +- .../SoftwareProductAttachmentsConstants.js | 6 +- .../SoftwareProductAttachmentsReducer.js | 14 +- .../attachments/SoftwareProductAttachmentsUtils.js | 14 +- .../attachments/SoftwareProductAttachmentsView.jsx | 312 +++-- .../softwareProduct/attachments/setup/HeatSetup.js | 81 +- .../attachments/setup/HeatSetupActionHelper.js | 92 +- .../attachments/setup/HeatSetupConstants.js | 32 +- .../attachments/setup/HeatSetupReducer.js | 239 ++-- .../attachments/setup/HeatSetupView.jsx | 713 ++++++----- .../attachments/validation/HeatValidation.js | 74 +- .../validation/HeatValidationActionHelper.js | 37 +- .../validation/HeatValidationConstants.js | 55 +- .../validation/HeatValidationReducer.js | 371 +++--- .../attachments/validation/HeatValidationView.jsx | 542 +++++---- .../SoftwareProductComponentEditorReducer.js | 150 +-- .../components/SoftwareProductComponents.js | 93 +- .../SoftwareProductComponentsActionHelper.js | 360 ++++-- .../SoftwareProductComponentsConstants.js | 50 +- .../SoftwareProductComponentsListReducer.js | 32 +- .../SoftwareProductComponentsListView.jsx | 168 +-- .../compute/ComputeFlavorActionHelper.js | 362 ++++-- .../compute/SoftwareProductComponentCompute.js | 74 +- .../SoftwareProductComponentComputeView.jsx | 144 ++- .../compute/computeComponents/ComputeFlavors.js | 218 ++-- .../compute/computeComponents/GuestOs.jsx | 136 ++- .../compute/computeComponents/NumberOfVms.jsx | 97 +- .../computeFlavor/ComputeFlavorConstants.js | 20 +- .../computeFlavor/ComputeFlavorEditor.js | 99 +- .../computeFlavor/ComputeFlavorEditorView.jsx | 169 +-- .../computeFlavor/ComputeFlavorListReducer.js | 36 +- .../computeFlavor/ComputeFlavorReducer.js | 53 +- .../computeComponents/computeFlavor/VmSizing.jsx | 223 ++-- .../creation/SoftwareProductComponentCreation.js | 64 +- .../SoftwareProductComponentCreationView.jsx | 121 +- .../general/SoftwareProductComponentsGeneral.js | 92 +- .../SoftwareProductComponentsGeneralView.jsx | 572 +++++---- .../components/images/ImageValidations.js | 6 +- .../SoftwareProductComponentsImageActionHelper.js | 375 +++--- .../SoftwareProductComponentsImageConstants.js | 10 +- .../images/SoftwareProductComponentsImageEditor.js | 119 +- .../SoftwareProductComponentsImageEditorReducer.js | 47 +- .../SoftwareProductComponentsImageEditorView.jsx | 116 +- .../images/SoftwareProductComponentsImageList.js | 161 ++- .../SoftwareProductComponentsImageListReducer.js | 15 +- .../SoftwareProductComponentsImageListView.jsx | 237 ++-- .../images/imagesEditorComponents/FileDetails.jsx | 78 +- .../images/imagesEditorComponents/Format.jsx | 54 +- .../images/imagesEditorComponents/ImageDetails.jsx | 33 +- .../images/imagesEditorComponents/Version.jsx | 42 +- .../SoftwareProductComponentLoadBalancing.js | 55 +- ...oftwareProductComponentLoadBalancingRefView.jsx | 359 ++++-- .../SoftwareProductComponentsMonitoring.js | 79 +- ...twareProductComponentsMonitoringActionHelper.js | 115 +- ...SoftwareProductComponentsMonitoringConstants.js | 27 +- .../SoftwareProductComponentsMonitoringReducer.js | 37 +- .../SoftwareProductComponentsMonitoringView.jsx | 232 ++-- .../components/network/NICCreation/NICCreation.js | 66 +- .../network/NICCreation/NICCreationActionHelper.js | 54 +- .../network/NICCreation/NICCreationReducer.js | 65 +- .../network/NICCreation/NICCreationView.jsx | 217 ++-- .../network/SoftwareProductComponentsNICEditor.js | 125 +- .../SoftwareProductComponentsNICEditorReducer.js | 62 +- .../SoftwareProductComponentsNICEditorView.jsx | 147 ++- .../SoftwareProductComponentsNICListReducer.js | 26 +- ...SoftwareProductComponentsNetworkActionHelper.js | 300 +++-- .../SoftwareProductComponentsNetworkConstants.js | 26 +- .../SoftwareProductComponentsNetworkList.js | 179 ++- .../SoftwareProductComponentsNetworkListView.jsx | 313 +++-- .../network/nicEditorComponents/Acceptable.jsx | 142 ++- .../network/nicEditorComponents/FlowLength.jsx | 22 +- .../network/nicEditorComponents/InFlowTraffic.jsx | 22 +- .../network/nicEditorComponents/IpConfig.jsx | 52 +- .../network/nicEditorComponents/NameAndPurpose.jsx | 70 +- .../network/nicEditorComponents/Network.jsx | 110 +- .../network/nicEditorComponents/OutFlowTraffic.jsx | 22 +- .../network/nicEditorComponents/PacketsBytes.jsx | 93 +- .../network/nicEditorComponents/Protocols.jsx | 120 +- .../network/nicEditorComponents/Sizing.jsx | 41 +- ...oftwareProductComponentProcessesActionHelper.js | 263 ++-- .../SoftwareProductComponentProcessesConstants.js | 27 +- .../SoftwareProductComponentProcessesEditor.js | 86 +- ...ftwareProductComponentProcessesEditorReducer.js | 78 +- ...SoftwareProductComponentProcessesEditorView.jsx | 17 +- .../SoftwareProductComponentProcessesList.js | 83 +- ...SoftwareProductComponentProcessesListReducer.js | 34 +- .../SoftwareProductComponentsProcessesListView.jsx | 110 +- .../storage/SoftwareProductComponentStorage.js | 59 +- .../SoftwareProductComponentStorageView.jsx | 450 ++++--- .../creation/SoftwareProductCreation.js | 126 +- .../SoftwareProductCreationActionHelper.js | 98 +- .../creation/SoftwareProductCreationConstants.js | 6 +- .../creation/SoftwareProductCreationReducer.js | 114 +- .../creation/SoftwareProductCreationView.jsx | 468 +++++--- .../dependencies/SoftwareProductDependencies.js | 51 +- .../SoftwareProductDependenciesActionHelper.js | 130 +- .../SoftwareProductDependenciesConstants.js | 12 +- .../SoftwareProductDependenciesReducer.js | 68 +- .../SoftwareProductDependenciesUtils.js | 108 +- .../SoftwareProductDependenciesView.jsx | 292 +++-- .../deployment/SoftwareProductDeployment.js | 85 +- .../SoftwareProductDeploymentActionHelper.js | 232 ++-- .../SoftwareProductDeploymentConstants.js | 12 +- .../SoftwareProductDeploymentListReducer.js | 14 +- .../deployment/SoftwareProductDeploymentView.jsx | 136 ++- .../editor/SoftwareProductDeploymentEditor.js | 144 ++- .../SoftwareProductDeploymentEditorReducer.js | 57 +- .../editor/SoftwareProductDeploymentEditorView.jsx | 351 ++++-- .../details/SoftwareProductDetails.js | 190 ++- .../details/SoftwareProductDetailsReducer.js | 93 +- .../SoftwareProductDetailsVendorSelector.jsx | 122 +- .../details/SoftwareProductDetailsView.jsx | 993 ++++++++++------ .../landingPage/SoftwareProductLandingPage.js | 204 ++-- .../landingPage/SoftwareProductLandingPageView.jsx | 396 ++++--- .../networks/SoftwareProductNetworks.js | 13 +- .../SoftwareProductNetworksActionHelper.js | 29 +- .../networks/SoftwareProductNetworksConstants.js | 2 +- .../networks/SoftwareProductNetworksListReducer.js | 14 +- .../networks/SoftwareProductNetworksView.jsx | 125 +- .../processes/SoftwareProductProcessListView.jsx | 140 +-- .../processes/SoftwareProductProcesses.js | 71 +- .../SoftwareProductProcessesActionHelper.js | 218 ++-- .../processes/SoftwareProductProcessesConstants.js | 22 +- .../processes/SoftwareProductProcessesEditor.js | 73 +- .../SoftwareProductProcessesEditorForm.jsx | 341 +++--- .../SoftwareProductProcessesEditorReducer.js | 78 +- .../SoftwareProductProcessesEditorView.jsx | 16 +- .../SoftwareProductProcessesListReducer.js | 34 +- .../processes/SoftwareProductProcessesView.jsx | 88 +- .../userNotifications/NotificationsReducer.js | 113 +- .../userNotifications/NotificationsView.jsx | 202 ++-- .../userNotifications/UserNotifications.jsx | 283 +++-- .../UserNotificationsActionHelper.js | 230 ++-- .../UserNotificationsConstants.js | 31 +- .../sdc-app/onboarding/users/UsersActionHelper.js | 53 +- .../src/sdc-app/onboarding/users/UsersConstants.js | 4 +- .../src/sdc-app/onboarding/users/UsersReducers.js | 41 +- .../onboarding/versionsPage/VersionsPage.js | 134 ++- .../onboarding/versionsPage/VersionsPage.jsx | 201 ++-- .../versionsPage/VersionsPageActionHelper.js | 156 +-- .../versionsPage/VersionsPageConstants.js | 10 +- .../onboarding/versionsPage/VersionsPageReducer.js | 44 +- .../versionsPage/components/PermissionsView.jsx | 141 ++- .../versionsPage/components/VersionList.jsx | 251 ++-- .../versionsPage/creation/VersionsPageCreation.js | 58 +- .../creation/VersionsPageCreationActionHelper.js | 109 +- .../creation/VersionsPageCreationConstants.js | 10 +- .../creation/VersionsPageCreationReducer.js | 59 +- .../creation/VersionsPageCreationView.jsx | 215 ++-- openecomp-ui/src/sdc-app/sdc.app.jsx | 19 +- openecomp-ui/webpack.common.js | 102 +- openecomp-ui/webpack.production.js | 89 +- openecomp-ui/yarn.lock | 690 +++++++---- 382 files changed, 32740 insertions(+), 22030 deletions(-) create mode 100644 openecomp-ui/.prettierrc (limited to 'openecomp-ui') diff --git a/openecomp-ui/.eslintrc b/openecomp-ui/.eslintrc index 2ebd851b87..5bc1423a4a 100644 --- a/openecomp-ui/.eslintrc +++ b/openecomp-ui/.eslintrc @@ -1,5 +1,15 @@ { "parser": "babel-eslint", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module", + "ecmaFeatures": { + "jsx": true, + "classes": true, + "modules": true, + "experimentalDecorators": true + } + }, "env": { "es6": true, "jquery": true, @@ -8,14 +18,12 @@ }, "plugins": [ "react", - "import" + "import", + "prettier" + ], + "extends": [ + "prettier" ], - "ecmaFeatures": { - "jsx": true, - "classes": true, - "modules": true, - "experimentalDecorators": true - }, "globals": { "Event": true, "window": true, @@ -40,23 +48,17 @@ "describe": true }, "rules": { + "prettier/prettier": ["error", { + "singleQuote": true, + "jsxBracketSameLine": true, + "tabWidth": 4 + }], "linebreak-style": 0, "no-unused-vars": 2, "no-bitwise": 0, "no-eq-null": 2, "eqeqeq": 2, - "wrap-iife": [ - 2, - "any" - ], "no-unused-expressions": 2, - "indent": [ - 1, - "tab", - { - "SwitchCase": 1 - } - ], "no-use-before-define": 2, "new-cap": [ 2, @@ -75,25 +77,13 @@ "single", "avoid-escape" ], - "jsx-quotes": [ - 2, - "prefer-single" - ], "no-plusplus": 0, "no-cond-assign": [ 2, "except-parens" ], - "comma-style": [ - 2, - "last" - ], "no-invalid-this": 0, "dot-notation": 0, - "max-len": [ - 1, - 200 - ], "camelcase": [ 2, { @@ -101,16 +91,10 @@ } ], "curly": 2, - "brace-style": 0, "semi": [ 2, "always" ], - "space-in-brackets": [ - 0, - "never" - ], - "space-infix-ops": 2, "import/default": 0, "import/no-unresolved": 0, "import/no-named-as-default": 2, @@ -120,19 +104,6 @@ "react/display-name": 0, "react/forbid-prop-types": 0, "react/jsx-boolean-value": 0, - "react/jsx-closing-bracket-location": [ - 1, - { - "nonEmpty": "after-props", - "selfClosing": "after-props" - } - ], - "react/jsx-curly-spacing": 0, - "react/jsx-indent-props": [ - 1, - "tab" - ], - "react/jsx-max-props-per-line": 0, "react/jsx-no-duplicate-props": 1, "react/jsx-no-literals": 0, "react/jsx-no-undef": 1, @@ -149,9 +120,7 @@ "react/no-unknown-property": 1, "react/prop-types": 0, "react/react-in-jsx-scope": 1, - "react/require-extension": 1, "react/self-closing-comp": 1, "react/sort-comp": 0, - "react/wrap-multilines": 1 } } diff --git a/openecomp-ui/.prettierrc b/openecomp-ui/.prettierrc new file mode 100644 index 0000000000..0a7b3ae85f --- /dev/null +++ b/openecomp-ui/.prettierrc @@ -0,0 +1,5 @@ +{ + "singleQuote": true, + "jsxBracketSameLine": true, + "tabWidth": 4 +} diff --git a/openecomp-ui/package.json b/openecomp-ui/package.json index ecc28f7552..70c86cc50a 100644 --- a/openecomp-ui/package.json +++ b/openecomp-ui/package.json @@ -1,154 +1,158 @@ { - "name": "dox-ui", - "version": "1.0.0", - "description": "", - "author": "ONAP", - "license": "SEE LICENSE IN LICENSE", - "scripts": { - "start": "gulp dev && webpack-dev-server --progress", - "build": "gulp build", - "css-usage": "gulp css-usage", - "static-keys-bundle": "gulp static-keys-bundle", - "check-keys-against-bundles": "gulp static-keys-bundle-with-report", - "test": "jest", - "test-failedTestReport": "jest --json | node test-utils/failedTestReport.js", - "test-dev": "jest --watch", - "test-coverage": "jest --coverage && start ./coverage/lcov-report/index.html", - "test-build": "jest --coverage", - "storybook": "start-storybook -p 9090 -c .storybook -s .storybook/fonts", - "storyshots": "jest storyshots.test.js", - "build-storybook": "build-storybook -c .storybook -o .storybook-dist && gulp copy-storybook-fonts" - }, - "dependencies": { - "attr-accept": "^1.1.0", - "axios": "^0.16.2", - "classnames": "^2.2.5", - "core-js": "^2.4.0", - "d3": "^4.10.0", - "dox-sequence-diagram-ui": "file:../dox-sequence-diagram-ui", - "intl": "^1.0.1", - "intl-format-cache": "^2.0.5", - "intl-messageformat": "^1.2.0", - "intl-relativeformat": "^1.2.0", - "lodash": "^4.13.1", - "md5": "^2.1.0", - "prop-types": "^15.6.0", - "randomstring": "^1.1.5", - "react": "^15.6.2", - "react-dnd": "^2.5.4", - "react-dnd-html5-backend": "^2.5.4", - "react-dom": "^15.6.2", - "react-redux": "^5.0.6", - "react-select": "1.2.1", - "redux": "^3.7.2", - "react-bootstrap": "^0.32.1", - "react-click-outside": "^2.3.1", - "react-datepicker": "^0.48.0", - "react-dropzone": "4.2.3", - "react-input-autosize": "^2.2.0", - "react-show-more": "^1.1.1", - "react-sortable": "^1.2.0", - "sdc-ui": "1.6.24", - "uuid-js": "^0.7.5", - "validator": "^4.3.0" - }, - "devDependencies": { - "@kadira/storybook": "^2.35.3", - "@kadira/storybook-addon-knobs": "^1.7.1", - "@kadira/storybook-addon-options": "^1.0.2", - "babel-core": "^6.24.0", - "babel-eslint": "^7.2.1", - "babel-jest": "^22.1.0", - "babel-loader": "^7.0.0-beta.1", - "babel-plugin-transform-class-properties": "^6.10.2", - "babel-plugin-transform-decorators-legacy": "^1.3.4", - "babel-plugin-transform-object-rest-spread": "^6.8.0", - "babel-plugin-transform-runtime": "^6.22.0", - "babel-preset-env": "^1.6.1", - "babel-preset-react": "^6.23.0", - "css-loader": "^0.23.1", - "deep-freeze": "0.0.1", - "del": "^3.0.0", - "enzyme": "^2.7.1", - "eslint": "^2.13.1", - "eslint-loader": "^1.3.0", - "eslint-plugin-import": "^0.8.1", - "eslint-plugin-react": "^3.14.0", - "express": "^4.13.3", - "file-loader": "^0.8.5", - "gulp": "^3.9.1", - "gulp-clean": "^0.3.1", - "gulp-css-usage": "^2.0.0", - "gulp-rename": "^1.2.2", - "gulp-replace": "^0.5.4", - "gulp-sass": "^3.1.0", - "gulp-tap": "^1.0.1", - "gulp-zip": "^4.1.0", - "html-loader": "^0.4.3", - "http-proxy-middleware": "^0.17.4", - "ignore-loader": "^0.1.1", - "jasmine-core": "^2.5.2", - "jest": "^21.2.1", - "jshint": "^2.9.4", - "json-loader": "^0.5.4", - "jsx-loader": "^0.13.2", - "mkdirp": "^0.5.1", - "moment": "^2.18.1", - "node-sass": "^4.7.2", - "node-watch": "^0.3.5", - "prompt": "^0.2.14", - "react-addons-test-utils": "~15.3.2", - "react-hot-loader": "^3.1.3", - "rosie": "^1.6.0", - "run-sequence": "^2.2.1", - "sass-loader": "^6.0.6", - "source-map-loader": "^0.1.5", - "storyshots": "^3.2.2", - "style-loader": "^0.13.0", - "svg-sprite-loader": "^0.1.1", - "url-loader": "^0.5.7", - "webpack": "^2.2.1", - "webpack-dev-server": "^2.4.2" - }, - "engines": { - "node": ">=8.0.0", - "npm": ">=5.0.0", - "yarn": "^1.3.2" - }, - "jest": { - "moduleNameMapper": { - "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/test-utils/fileMock.js", - "\\.(css|scss)$": "/test-utils/styleMock.js", - "^nfvo-utils/RestAPIUtil.js$": "/test-utils/MockRest.js", - "^sdc-ui/lib/react/SVGIcon.js$": "/test-utils/MockSVGIcon.js", - "^react-show-more$": "/test-utils/ShowMore.js", - "^nfvo-utils(.*)$": "/src/nfvo-utils$1", - "^nfvo-components(.*)$": "/src/nfvo-components$1", - "^sdc-app(.*)$": "/src/sdc-app$1", - "^test-utils(.*)$": "/test-utils$1", - "^i18nJson$": "/src/nfvo-utils/i18n/en.json", - "^src(.*)$": "/src$1" + "name": "dox-ui", + "version": "1.0.0", + "description": "", + "author": "ONAP", + "license": "SEE LICENSE IN LICENSE", + "scripts": { + "start": "gulp dev && webpack-dev-server --progress", + "build": "gulp build", + "css-usage": "gulp css-usage", + "static-keys-bundle": "gulp static-keys-bundle", + "check-keys-against-bundles": "gulp static-keys-bundle-with-report", + "test": "jest", + "test-failedTestReport": "jest --json | node test-utils/failedTestReport.js", + "test-dev": "jest --watch", + "test-coverage": "jest --coverage && start ./coverage/lcov-report/index.html", + "test-build": "jest --coverage", + "storybook": "start-storybook -p 9090 -c .storybook -s .storybook/fonts", + "storyshots": "jest storyshots.test.js", + "build-storybook": "build-storybook -c .storybook -o .storybook-dist && gulp copy-storybook-fonts", + "lint-fix": "eslint --fix --ext .js --ext .jsx src" }, - "globals": { - "DEBUG": false + "dependencies": { + "attr-accept": "^1.1.0", + "axios": "^0.16.2", + "classnames": "^2.2.5", + "core-js": "^2.4.0", + "d3": "^4.10.0", + "dox-sequence-diagram-ui": "file:../dox-sequence-diagram-ui", + "intl": "^1.0.1", + "intl-format-cache": "^2.0.5", + "intl-messageformat": "^1.2.0", + "intl-relativeformat": "^1.2.0", + "lodash": "^4.13.1", + "md5": "^2.1.0", + "prop-types": "^15.6.0", + "randomstring": "^1.1.5", + "react": "^15.6.2", + "react-bootstrap": "^0.32.1", + "react-click-outside": "^2.3.1", + "react-datepicker": "^0.48.0", + "react-dnd": "^2.5.4", + "react-dnd-html5-backend": "^2.5.4", + "react-dom": "^15.6.2", + "react-dropzone": "4.2.3", + "react-input-autosize": "^2.2.0", + "react-redux": "^5.0.6", + "react-select": "1.2.1", + "react-show-more": "^1.1.1", + "react-sortable": "^1.2.0", + "redux": "^3.7.2", + "sdc-ui": "1.6.24", + "uuid-js": "^0.7.5", + "validator": "^4.3.0" }, - "setupFiles": [ - "/test-utils/test-env-setup.js" - ], - "setupTestFrameworkScriptFile": "/test-utils/test-setup.js", - "testPathIgnorePatterns": [ - "/node_modules/", - "/test/nfvo-components/storyshots.test.js" - ], - "collectCoverageFrom": [ - "src/**/*.{js,jsx}" - ], - "coveragePathIgnorePatterns": [ - "/node_modules/", - "(.)*.stories.js" - ], - "coverageReporters": [ - "lcov" - ] - } + "devDependencies": { + "@kadira/storybook": "^2.35.3", + "@kadira/storybook-addon-knobs": "^1.7.1", + "@kadira/storybook-addon-options": "^1.0.2", + "babel-core": "^6.24.0", + "babel-eslint": "^8.2.1", + "babel-jest": "^22.1.0", + "babel-loader": "^7.0.0-beta.1", + "babel-plugin-transform-class-properties": "^6.10.2", + "babel-plugin-transform-decorators-legacy": "^1.3.4", + "babel-plugin-transform-object-rest-spread": "^6.8.0", + "babel-plugin-transform-runtime": "^6.22.0", + "babel-preset-env": "^1.6.1", + "babel-preset-react": "^6.23.0", + "css-loader": "^0.23.1", + "deep-freeze": "0.0.1", + "del": "^3.0.0", + "enzyme": "^2.7.1", + "eslint": "^4.18.1", + "eslint-config-prettier": "^2.9.0", + "eslint-loader": "^2.0.0", + "eslint-plugin-import": "^2.9.0", + "eslint-plugin-prettier": "^2.6.0", + "eslint-plugin-react": "^7.7.0", + "express": "^4.13.3", + "file-loader": "^0.8.5", + "gulp": "^3.9.1", + "gulp-clean": "^0.3.1", + "gulp-css-usage": "^2.0.0", + "gulp-rename": "^1.2.2", + "gulp-replace": "^0.5.4", + "gulp-sass": "^3.1.0", + "gulp-tap": "^1.0.1", + "gulp-zip": "^4.1.0", + "html-loader": "^0.4.3", + "http-proxy-middleware": "^0.17.4", + "ignore-loader": "^0.1.1", + "jasmine-core": "^2.5.2", + "jest": "^21.2.1", + "jshint": "^2.9.4", + "json-loader": "^0.5.4", + "jsx-loader": "^0.13.2", + "mkdirp": "^0.5.1", + "moment": "^2.18.1", + "node-sass": "^4.7.2", + "node-watch": "^0.3.5", + "prettier": "^1.10.2", + "prompt": "^0.2.14", + "react-addons-test-utils": "~15.3.2", + "react-hot-loader": "^3.1.3", + "rosie": "^1.6.0", + "run-sequence": "^2.2.1", + "sass-loader": "^6.0.6", + "source-map-loader": "^0.1.5", + "storyshots": "^3.2.2", + "style-loader": "^0.13.0", + "svg-sprite-loader": "^0.1.1", + "url-loader": "^0.5.7", + "webpack": "^2.2.1", + "webpack-dev-server": "^2.4.2" + }, + "engines": { + "node": ">=8.0.0", + "npm": ">=5.0.0", + "yarn": "^1.3.2" + }, + "jest": { + "moduleNameMapper": { + "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/test-utils/fileMock.js", + "\\.(css|scss)$": "/test-utils/styleMock.js", + "^nfvo-utils/RestAPIUtil.js$": "/test-utils/MockRest.js", + "^sdc-ui/lib/react/SVGIcon.js$": "/test-utils/MockSVGIcon.js", + "^react-show-more$": "/test-utils/ShowMore.js", + "^nfvo-utils(.*)$": "/src/nfvo-utils$1", + "^nfvo-components(.*)$": "/src/nfvo-components$1", + "^sdc-app(.*)$": "/src/sdc-app$1", + "^test-utils(.*)$": "/test-utils$1", + "^i18nJson$": "/src/nfvo-utils/i18n/en.json", + "^src(.*)$": "/src$1" + }, + "globals": { + "DEBUG": false + }, + "setupFiles": [ + "/test-utils/test-env-setup.js" + ], + "setupTestFrameworkScriptFile": "/test-utils/test-setup.js", + "testPathIgnorePatterns": [ + "/node_modules/", + "/test/nfvo-components/storyshots.test.js" + ], + "collectCoverageFrom": [ + "src/**/*.{js,jsx}" + ], + "coveragePathIgnorePatterns": [ + "/node_modules/", + "(.)*.stories.js" + ], + "coverageReporters": [ + "lcov" + ] + } } diff --git a/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx b/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx index c15cd1d0e8..56382d6325 100644 --- a/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx +++ b/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx @@ -13,11 +13,11 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import ListGroupItem from 'react-bootstrap/lib/ListGroupItem.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; -import {Collapse} from 'react-bootstrap'; +import { Collapse } from 'react-bootstrap'; /** * parsing and showing the following Java Response object * @@ -42,121 +42,151 @@ import {Collapse} from 'react-bootstrap'; } */ class SubmitErrorResponse extends Component { + render() { + let { + validationResponse: { + vspErrors, + licensingDataErrors, + questionnaireValidationResult, + uploadDataErrors + } + } = this.props; + return ( +
+ {vspErrors && this.renderVspErrors(vspErrors)} + {licensingDataErrors && + this.renderVspErrors(licensingDataErrors)} + {questionnaireValidationResult && + this.renderComponentsErrors(questionnaireValidationResult)} + {uploadDataErrors && + this.renderUploadDataErrors(uploadDataErrors)} +
+ ); + } + renderVspErrors(errors) { + return ( + +
+ {errors.length && + errors.map((error, i) => { + return ( + + ); + })} +
+
+ ); + } - render() { - let {validationResponse : {vspErrors, licensingDataErrors, questionnaireValidationResult, uploadDataErrors}} = this.props; - return ( -
- {vspErrors && this.renderVspErrors(vspErrors)} - {licensingDataErrors && this.renderVspErrors(licensingDataErrors)} - {questionnaireValidationResult && this.renderComponentsErrors(questionnaireValidationResult)} - {uploadDataErrors && this.renderUploadDataErrors(uploadDataErrors)} -
- ); - } - - renderVspErrors(errors) { - return ( - -
- {errors.length && errors.map((error, i) => {return ();})} -
-
- ); - } - - - renderComponentsErrors(errors) { - return ( - -
- {errors.validationData.length && errors.validationData.map((item, i) =>{ return ();})} -
-
- ); - } + renderComponentsErrors(errors) { + return ( + +
+ {errors.validationData.length && + errors.validationData.map((item, i) => { + return ; + })} +
+
+ ); + } - renderUploadDataErrors(uploadDataErrors) { - return ( - -
- -
-
- ); - } + renderUploadDataErrors(uploadDataErrors) { + return ( + +
+ +
+
+ ); + } } - -const ComponentError = ({item}) => { - return ( -
-
{item.entityName}
- {item.errors.map((error, i) => {return();})} -
- ); +const ComponentError = ({ item }) => { + return ( +
+
{item.entityName}
+ {item.errors.map((error, i) => { + return ; + })} +
+ ); }; function* entries(obj) { - for (let key of Object.keys(obj)) { - yield {header: key, list: obj[key]}; - } + for (let key of Object.keys(obj)) { + yield { header: key, list: obj[key] }; + } } -const UploadErrorList = ({items}) => { - let generator = entries(items); - - let errors = []; - for (let item of generator) {errors.push( -
-
{item.header}
- {item.list.map((error, i) => )} -
- );} +const UploadErrorList = ({ items }) => { + let generator = entries(items); + + let errors = []; + for (let item of generator) { + errors.push( +
+
{item.header}
+ {item.list.map((error, i) => ( + + ))} +
+ ); + } - return ( -
- {errors} -
- ); + return
{errors}
; }; class ErrorBlock extends React.Component { - state = { - collapsed: false - }; - - render() { - let {errorType, children} = this.props; - return ( -
- {this.setState({collapsed: !this.state.collapsed});}} errorType={errorType}/> - - {children} - -
- ); - } + state = { + collapsed: false + }; + + render() { + let { errorType, children } = this.props; + return ( +
+ { + this.setState({ collapsed: !this.state.collapsed }); + }} + errorType={errorType} + /> + {children} +
+ ); + } } -const ErrorHeader = ({errorType, collapsed, onClick}) => { - return( -
- -
- ); +const ErrorHeader = ({ errorType, collapsed, onClick }) => { + return ( +
+ +
+ ); }; -const ErrorMessage = ({error, warning}) => { - return ( - - - {error} - - ); +const ErrorMessage = ({ error, warning }) => { + return ( + + + {error} + + ); }; export default SubmitErrorResponse; diff --git a/openecomp-ui/src/nfvo-components/accordion/Accordion.jsx b/openecomp-ui/src/nfvo-components/accordion/Accordion.jsx index ac19072307..72f8de0d23 100644 --- a/openecomp-ui/src/nfvo-components/accordion/Accordion.jsx +++ b/openecomp-ui/src/nfvo-components/accordion/Accordion.jsx @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -18,35 +18,38 @@ import React from 'react'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import PropTypes from 'prop-types'; - class Accordion extends React.Component { + static propTypes = { + title: PropTypes.string, + children: PropTypes.node + }; - static propTypes = { - title: PropTypes.string, - children: PropTypes.node - } - - constructor(props) { - super(props); - this.state = { - open: false - }; - } - render() { - const {children, title} = this.props; - const {open} = this.state; - return ( -
-
this.setState({open: !open})} className='accordion-header'> - -
{title}
-
-
- {children} -
-
- ); - } + constructor(props) { + super(props); + this.state = { + open: false + }; + } + render() { + const { children, title } = this.props; + const { open } = this.state; + return ( +
+
this.setState({ open: !open })} + className="accordion-header"> + +
{title}
+
+
+ {children} +
+
+ ); + } } -export default Accordion; \ No newline at end of file +export default Accordion; diff --git a/openecomp-ui/src/nfvo-components/datepicker/Datepicker.jsx b/openecomp-ui/src/nfvo-components/datepicker/Datepicker.jsx index 25e7e7e02d..b4bc8be9ec 100644 --- a/openecomp-ui/src/nfvo-components/datepicker/Datepicker.jsx +++ b/openecomp-ui/src/nfvo-components/datepicker/Datepicker.jsx @@ -5,72 +5,105 @@ import moment from 'moment'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; class CustomInput extends React.Component { + static propTypes = { + placeHolderText: PropTypes.string, + onChange: PropTypes.func, + onClick: PropTypes.func, + value: PropTypes.string + }; - static propTypes = { - placeHolderText: PropTypes.string, - onChange: PropTypes.func, - onClick: PropTypes.func, - value: PropTypes.string - }; - - render() { - const {placeholderText, onClick, onClear, inputRef, value: date} = this.props; - const text = date ? date : placeholderText; - const textStyle = date ? '' : 'placeholder'; - return ( -
-
{text}
- {date && {e.stopPropagation(); onClear();}} name='close' className='clear-input'/>} - -
- ); - } -}; + render() { + const { + placeholderText, + onClick, + onClear, + inputRef, + value: date + } = this.props; + const text = date ? date : placeholderText; + const textStyle = date ? '' : 'placeholder'; + return ( +
+
{text}
+ {date && ( + { + e.stopPropagation(); + onClear(); + }} + name="close" + className="clear-input" + /> + )} + +
+ ); + } +} const parseDate = (date, format) => { - return typeof date === 'number' ? moment.unix(date) : moment(date, format); + return typeof date === 'number' ? moment.unix(date) : moment(date, format); }; class Datepicker extends React.Component { - static propTypes = { - date: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - format: PropTypes.string, - onChange: PropTypes.func, - selectsStart: PropTypes.bool, - selectsEnd: PropTypes.bool, - startDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - endDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), - disabled: PropTypes.bool, - label: PropTypes.string, - isRequired: PropTypes.bool - } - render() { - let {date, format, onChange, selectsStart = false, startDate = null, endDate = null, selectsEnd = false, - disabled = false, inputRef} = this.props; - const placeholderText = 'Enter a date'; - const props = { - format, - onChange, - disabled, - selected: date ? parseDate(date, format) : date, - selectsStart, - selectsEnd, - placeholderText, - startDate: startDate ? parseDate(startDate, format) : startDate, - endDate: endDate ? parseDate(endDate, format) : endDate - }; + static propTypes = { + date: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + format: PropTypes.string, + onChange: PropTypes.func, + selectsStart: PropTypes.bool, + selectsEnd: PropTypes.bool, + startDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + endDate: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), + disabled: PropTypes.bool, + label: PropTypes.string, + isRequired: PropTypes.bool + }; + render() { + let { + date, + format, + onChange, + selectsStart = false, + startDate = null, + endDate = null, + selectsEnd = false, + disabled = false, + inputRef + } = this.props; + const placeholderText = 'Enter a date'; + const props = { + format, + onChange, + disabled, + selected: date ? parseDate(date, format) : date, + selectsStart, + selectsEnd, + placeholderText, + startDate: startDate ? parseDate(startDate, format) : startDate, + endDate: endDate ? parseDate(endDate, format) : endDate + }; - return ( -
- onChange(undefined)} placeholderText={placeholderText}/>} - minDate={selectsEnd && props.startDate} - maxDate={selectsStart && props.endDate} - {...props}/> -
- ); - } + return ( +
+ onChange(undefined)} + placeholderText={placeholderText} + /> + } + minDate={selectsEnd && props.startDate} + maxDate={selectsStart && props.endDate} + {...props} + /> +
+ ); + } } export default Datepicker; diff --git a/openecomp-ui/src/nfvo-components/editor/TabulatedEditor.jsx b/openecomp-ui/src/nfvo-components/editor/TabulatedEditor.jsx index 3c9ceed0d8..9fcd7042bc 100644 --- a/openecomp-ui/src/nfvo-components/editor/TabulatedEditor.jsx +++ b/openecomp-ui/src/nfvo-components/editor/TabulatedEditor.jsx @@ -20,79 +20,106 @@ import VersionController from 'nfvo-components/panel/versionController/VersionCo import NavigationSideBar from 'nfvo-components/panel/NavigationSideBar.jsx'; export default class TabulatedEditor extends React.Component { + render() { + const { + navigationBarProps, + onToggle, + onVersionSwitching, + onMoreVersionsClick, + onCreate, + onSave, + onClose, + onVersionControllerAction, + onNavigate, + children, + meta, + onManagePermissions, + onOpenCommentCommitModal, + onOpenPermissions, + onOpenRevisionsModal + } = this.props; + let { versionControllerProps } = this.props; + const { className = '' } = React.Children.only(children).props; + const child = this.prepareChild(); - render() { - const {navigationBarProps, onToggle, onVersionSwitching, onMoreVersionsClick, onCreate, onSave, onClose, - onVersionControllerAction, onNavigate, children, meta, onManagePermissions, onOpenCommentCommitModal, onOpenPermissions, onOpenRevisionsModal} = this.props; - let {versionControllerProps} = this.props; - const {className = ''} = React.Children.only(children).props; - const child = this.prepareChild(); + if (onClose) { + versionControllerProps = { + ...versionControllerProps, + onClose: () => onClose(versionControllerProps) + }; + } + return ( +
+
+ +
+
+ + onVersionSwitching(version, meta) + } + onMoreVersionsClick={onMoreVersionsClick} + onManagePermissions={onManagePermissions} + onOpenCommentCommitModal={onOpenCommentCommitModal} + onOpenPermissions={onOpenPermissions} + onOpenRevisionsModal={onOpenRevisionsModal} + callVCAction={(action, version, comment) => + onVersionControllerAction( + action, + version, + comment, + meta + ) + } + onCreate={onCreate && this.handleCreate} + onSave={onSave && this.handleSave} + /> +
+ {child} +
+
+
+ ); + } - if(onClose) { - versionControllerProps = { - ...versionControllerProps, - onClose: () => onClose(versionControllerProps) - }; - } - return ( -
-
- -
-
- onVersionSwitching(version, meta)} - onMoreVersionsClick={onMoreVersionsClick} - onManagePermissions={onManagePermissions} - onOpenCommentCommitModal={onOpenCommentCommitModal} - onOpenPermissions={onOpenPermissions} - onOpenRevisionsModal={onOpenRevisionsModal} - callVCAction={(action, version, comment) => onVersionControllerAction(action, version, comment, meta)} - onCreate={onCreate && this.handleCreate} - onSave={onSave && this.handleSave}/> -
- { - child - } -
-
-
- ); - } + prepareChild() { + const { onSave, onCreate, children } = this.props; - prepareChild() { - const {onSave, onCreate, children} = this.props; + const additionalChildProps = { ref: 'editor' }; + if (onSave) { + additionalChildProps.onSave = onSave; + } + if (onCreate) { + additionalChildProps.onCreate = onCreate; + } - const additionalChildProps = {ref: 'editor'}; - if (onSave) { - additionalChildProps.onSave = onSave; - } - if (onCreate) { - additionalChildProps.onCreate = onCreate; - } + const child = React.cloneElement( + React.Children.only(children), + additionalChildProps + ); + return child; + } - const child = React.cloneElement(React.Children.only(children), additionalChildProps); - return child; - } + handleSave = () => { + const childInstance = this.refs.editor.getWrappedInstance(); + if (childInstance.save) { + return childInstance.save(); + } else { + return this.props.onSave(); + } + }; - - - handleSave = () => { - const childInstance = this.refs.editor.getWrappedInstance(); - if (childInstance.save) { - return childInstance.save(); - } else { - return this.props.onSave(); - } - }; - - handleCreate = () => { - const childInstance = this.refs.editor.getWrappedInstance(); - if (childInstance.create) { - childInstance.create(); - } else { - this.props.onCreate(); - } - } + handleCreate = () => { + const childInstance = this.refs.editor.getWrappedInstance(); + if (childInstance.create) { + childInstance.create(); + } else { + this.props.onCreate(); + } + }; } diff --git a/openecomp-ui/src/nfvo-components/fileupload/DraggableUploadFileBox.jsx b/openecomp-ui/src/nfvo-components/fileupload/DraggableUploadFileBox.jsx index 5b4e0a8bee..0d47d859d9 100644 --- a/openecomp-ui/src/nfvo-components/fileupload/DraggableUploadFileBox.jsx +++ b/openecomp-ui/src/nfvo-components/fileupload/DraggableUploadFileBox.jsx @@ -26,20 +26,33 @@ * or * https://github.com/JedWatson/react-select */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Button from 'sdc-ui/lib/react/Button.js'; class DraggableUploadFileBox extends Component { - render() { - let {className, onClick, dataTestId, isReadOnlyMode} = this.props; - return ( -
-
{i18n('Drag & drop for upload')}
-
{i18n('or')}
- -
- ); - } + render() { + let { className, onClick, dataTestId, isReadOnlyMode } = this.props; + return ( +
+
+ {i18n('Drag & drop for upload')} +
+
{i18n('or')}
+ +
+ ); + } } export default DraggableUploadFileBox; diff --git a/openecomp-ui/src/nfvo-components/grid/GridItem.jsx b/openecomp-ui/src/nfvo-components/grid/GridItem.jsx index c62e042bf4..9723cde2c0 100644 --- a/openecomp-ui/src/nfvo-components/grid/GridItem.jsx +++ b/openecomp-ui/src/nfvo-components/grid/GridItem.jsx @@ -15,12 +15,21 @@ */ import React from 'react'; -const GridItem = ({colSpan = 1, children, lastColInRow = false, stretch = false, className = ''}) => ( -
-
- {children} -
-
+const GridItem = ({ + colSpan = 1, + children, + lastColInRow = false, + stretch = false, + className = '' +}) => ( +
+
+ {children} +
+
); export default GridItem; diff --git a/openecomp-ui/src/nfvo-components/grid/GridSection.jsx b/openecomp-ui/src/nfvo-components/grid/GridSection.jsx index 8f4a024fdb..f2e3588d9e 100644 --- a/openecomp-ui/src/nfvo-components/grid/GridSection.jsx +++ b/openecomp-ui/src/nfvo-components/grid/GridSection.jsx @@ -17,21 +17,32 @@ import React from 'react'; import PropTypes from 'prop-types'; import classnames from 'classnames'; -const GridSection = ({title, children, className = '', titleClassName, hasLastColSet = false}) => { - return ( -
- {title &&
{title}
} -
- {children} -
-
- ); +const GridSection = ({ + title, + children, + className = '', + titleClassName, + hasLastColSet = false +}) => { + return ( +
+ {title && ( +
+ {title} +
+ )} +
{children}
+
+ ); }; GridSection.propTypes = { - title: PropTypes.string, - titleClassName: PropTypes.string, - hasLastColSet: PropTypes.bool + title: PropTypes.string, + titleClassName: PropTypes.string, + hasLastColSet: PropTypes.bool }; export default GridSection; diff --git a/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx b/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx index 82fbe1deed..3973ae8c5d 100644 --- a/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx +++ b/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx @@ -19,99 +19,118 @@ import ReactDOM from 'react-dom'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import Input from 'nfvo-components/input/validation/InputWrapper.jsx'; -const ExpandableInputClosed = ({iconType, onClick}) => ( - +const ExpandableInputClosed = ({ iconType, onClick }) => ( + ); class ExpandableInputOpened extends React.Component { - componentDidMount(){ - this.rawDomNode = ReactDOM.findDOMNode(this.searchInputNode.inputWrapper); - this.rawDomNode.focus(); - } + componentDidMount() { + this.rawDomNode = ReactDOM.findDOMNode( + this.searchInputNode.inputWrapper + ); + this.rawDomNode.focus(); + } - componentWillReceiveProps(newProps){ - if (!newProps.value){ - if (!(document.activeElement === this.rawDomNode)){ - this.props.handleBlur(); - } - } - } + componentWillReceiveProps(newProps) { + if (!newProps.value) { + if (!(document.activeElement === this.rawDomNode)) { + this.props.handleBlur(); + } + } + } - handleClose(){ - this.props.onChange(''); - this.rawDomNode.focus(); - } + handleClose() { + this.props.onChange(''); + this.rawDomNode.focus(); + } - handleKeyDown(e){ - if (e.key === 'Escape'){ - e.preventDefault(); - if (this.props.value) { - this.handleClose(); - } else { - this.rawDomNode.blur(); - } - }; - } + handleKeyDown(e) { + if (e.key === 'Escape') { + e.preventDefault(); + if (this.props.value) { + this.handleClose(); + } else { + this.rawDomNode.blur(); + } + } + } - render() { - let {iconType, value, onChange, handleBlur} = this.props; - return ( -
- this.searchInputNode = input} - className='expandable-active' - groupClassName='expandable-input-control' - onChange={e => onChange(e)} - onKeyDown={e => this.handleKeyDown(e)} - onBlur={handleBlur}/> - {value && this.handleClose()} name='close' />} - {!value && } -
- ); - } + render() { + let { iconType, value, onChange, handleBlur } = this.props; + return ( +
+ (this.searchInputNode = input)} + className="expandable-active" + groupClassName="expandable-input-control" + onChange={e => onChange(e)} + onKeyDown={e => this.handleKeyDown(e)} + onBlur={handleBlur} + /> + {value && ( + this.handleClose()} + name="close" + /> + )} + {!value && } +
+ ); + } } class ExpandableInput extends React.Component { + static propTypes = { + iconType: PropTypes.string, + onChange: PropTypes.func, + value: PropTypes.string + }; - static propTypes = { - iconType: PropTypes.string, - onChange: PropTypes.func, - value: PropTypes.string - }; + state = { showInput: false }; - state = {showInput: false}; + closeInput() { + if (!this.props.value) { + this.setState({ showInput: false }); + } + } - closeInput(){ - if (!this.props.value) { - this.setState({showInput: false}); - } - } + getValue() { + return this.props.value; + } - getValue(){ - return this.props.value; - } - - render(){ - let {iconType, value, onChange = false} = this.props; - return ( -
- {this.state.showInput && - this.handleKeyDown(e)} - handleBlur={() => this.closeInput()}/> - } - {!this.state.showInput && this.setState({showInput: true})} />} -
- ); - } + render() { + let { iconType, value, onChange = false } = this.props; + return ( +
+ {this.state.showInput && ( + this.handleKeyDown(e)} + handleBlur={() => this.closeInput()} + /> + )} + {!this.state.showInput && ( + this.setState({ showInput: true })} + /> + )} +
+ ); + } } - export default ExpandableInput; diff --git a/openecomp-ui/src/nfvo-components/input/SelectInput.jsx b/openecomp-ui/src/nfvo-components/input/SelectInput.jsx index 03c727379e..b0e0d87d7c 100644 --- a/openecomp-ui/src/nfvo-components/input/SelectInput.jsx +++ b/openecomp-ui/src/nfvo-components/input/SelectInput.jsx @@ -26,43 +26,51 @@ * or * https://github.com/JedWatson/react-select */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import Select from 'react-select'; class SelectInput extends Component { + inputValue = []; - inputValue = []; + render() { + let { label, value, ...other } = this.props; + const dataTestId = this.props['data-test-id'] + ? { 'data-test-id': this.props['data-test-id'] } + : {}; + return ( +
+
+ {label && } + this.onSelectChanged(value)} {...other} value={value} /> -
-
- ); - } + getValue() { + return this.inputValue && this.inputValue.length ? this.inputValue : ''; + } - getValue() { - return this.inputValue && this.inputValue.length ? this.inputValue : ''; - } + onSelectChanged(value) { + this.props.onMultiSelectChanged(value); + } - onSelectChanged(value) { - this.props.onMultiSelectChanged(value); - } - - componentDidMount() { - let {value} = this.props; - this.inputValue = value ? value : []; - } - componentDidUpdate() { - if (this.inputValue !== this.props.value) { - this.inputValue = this.props.value; - } - } + componentDidMount() { + let { value } = this.props; + this.inputValue = value ? value : []; + } + componentDidUpdate() { + if (this.inputValue !== this.props.value) { + this.inputValue = this.props.value; + } + } } export default SelectInput; diff --git a/openecomp-ui/src/nfvo-components/input/ToggleInput.jsx b/openecomp-ui/src/nfvo-components/input/ToggleInput.jsx index 31a8a66d86..947570fa29 100644 --- a/openecomp-ui/src/nfvo-components/input/ToggleInput.jsx +++ b/openecomp-ui/src/nfvo-components/input/ToggleInput.jsx @@ -16,55 +16,60 @@ import React from 'react'; import PropTypes from 'prop-types'; -export default -class ToggleInput extends React.Component { +export default class ToggleInput extends React.Component { + static propTypes = { + label: PropTypes.node, + value: PropTypes.bool, + onChange: PropTypes.func, + disabled: PropTypes.bool + }; - static propTypes = { - label: PropTypes.node, - value: PropTypes.bool, - onChange: PropTypes.func, - disabled: PropTypes.bool - } + static defaultProps = { + value: false, + label: '' + }; - static defaultProps = { - value: false, - label: '' - } + state = { + value: this.props.value + }; - state = { - value: this.props.value - } + status() { + return this.state.value ? 'on' : 'off'; + } - status() { - return this.state.value ? 'on' : 'off'; - } + render() { + let { label, disabled } = this.props; + let checked = this.status() === 'on'; + //TODO check onclick + return ( +
+
{label}
+
+ +
+
+ ); + } - render() { - let {label, disabled} = this.props; - let checked = this.status() === 'on'; - //TODO check onclick - return ( -
-
{label}
-
- - -
-
- ); - } + click = () => { + let value = !this.state.value; + this.setState({ value }); - click = () => { - let value = !this.state.value; - this.setState({value}); + let onChange = this.props.onChange; + if (onChange) { + onChange(value); + } + }; - let onChange = this.props.onChange; - if (onChange) { - onChange(value); - } - } - - getValue() { - return this.state.value; - } + getValue() { + return this.state.value; + } } diff --git a/openecomp-ui/src/nfvo-components/input/dualListbox/DualListboxView.jsx b/openecomp-ui/src/nfvo-components/input/dualListbox/DualListboxView.jsx index a689c50778..7ab4c8242c 100644 --- a/openecomp-ui/src/nfvo-components/input/dualListbox/DualListboxView.jsx +++ b/openecomp-ui/src/nfvo-components/input/dualListbox/DualListboxView.jsx @@ -19,136 +19,224 @@ import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import Input from 'nfvo-components/input/validation/InputWrapper.jsx'; class DualListboxView extends React.Component { - - static propTypes = { - - availableList: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.string.isRequired, - name: PropTypes.string.isRequired - })), - filterTitle: PropTypes.shape({ - left: PropTypes.string, - right: PropTypes.string - }), - selectedValuesList: PropTypes.arrayOf(PropTypes.string), - - onChange: PropTypes.func.isRequired - }; - - static defaultProps = { - selectedValuesList: [], - availableList: [], - filterTitle: { - left: '', - right: '' - } - }; - - state = { - availableListFilter: '', - selectedValuesListFilter: '', - selectedValues: [] - }; - - render() { - let {availableList, selectedValuesList, filterTitle, isReadOnlyMode} = this.props; - let {availableListFilter, selectedValuesListFilter} = this.state; - - let unselectedList = availableList.filter(availableItem => !selectedValuesList.find(value => value === availableItem.id)); - let selectedList = availableList.filter(availableItem => selectedValuesList.find(value => value === availableItem.id)); - selectedList = selectedList.sort((a, b) => selectedValuesList.indexOf(a.id) - selectedValuesList.indexOf(b.id)); - return ( -
- {this.renderListbox(filterTitle.left, unselectedList, { - value: availableListFilter, - ref: 'availableListFilter', - disabled: isReadOnlyMode, - onChange: (value) => this.setState({availableListFilter: value}) - }, {ref: 'availableValues', disabled: isReadOnlyMode, testId: 'available',})} - {this.renderOperationsBar(isReadOnlyMode)} - {this.renderListbox(filterTitle.right, selectedList, { - value: selectedValuesListFilter, - ref: 'selectedValuesListFilter', - disabled: isReadOnlyMode, - onChange: (value) => this.setState({selectedValuesListFilter: value}) - }, {ref: 'selectedValues', disabled: isReadOnlyMode, testId: 'selected'})} -
- ); - } - - renderListbox(filterTitle, list, filterProps, props) { - let regExFilter = new RegExp(escape(filterProps.value), 'i'); - let matchedItems = list.filter(item => item.name.match(regExFilter)); - let unMatchedItems = list.filter(item => !item.name.match(regExFilter)); - return ( -
-

{filterTitle}

-
- - -
- this.onSelectItems(event.target.selectedOptions)} - groupClassName='dual-list-box-multi-select' - type='select' - name='dual-list-box-multi-select' - data-test-id={`${props.testId}-select-input`} - disabled={props.disabled} - ref={props.ref}> - {matchedItems.map(item => this.renderOption(item.id, item.name))} - {matchedItems.length && unMatchedItems.length && } - {unMatchedItems.map(item => this.renderOption(item.id, item.name))} - -
- ); - } - - onSelectItems(selectedOptions) { - let selectedValues = Object.keys(selectedOptions).map((k) => selectedOptions[k].value); - this.setState({selectedValues}); - } - - renderOption(value, name) { - return (); - } - - renderOperationsBar(isReadOnlyMode) { - return ( -
- {this.renderOperationBarButton(() => this.addToSelectedList(), 'angleRight')} - {this.renderOperationBarButton(() => this.removeFromSelectedList(), 'angleLeft')} - {this.renderOperationBarButton(() => this.addAllToSelectedList(), 'angleDoubleRight')} - {this.renderOperationBarButton(() => this.removeAllFromSelectedList(), 'angleDoubleLeft')} -
- ); - } - - renderOperationBarButton(onClick, iconName){ - return (
); - } - - addToSelectedList() { - this.props.onChange(this.props.selectedValuesList.concat(this.state.selectedValues)); - this.setState({selectedValues: []}); - } - - removeFromSelectedList() { - const selectedValues = this.state.selectedValues; - this.props.onChange(this.props.selectedValuesList.filter(value => !selectedValues.find(selectedValue => selectedValue === value))); - this.setState({selectedValues: []}); - } - - addAllToSelectedList() { - this.props.onChange(this.props.availableList.map(item => item.id)); - } - - removeAllFromSelectedList() { - this.props.onChange([]); - } + static propTypes = { + availableList: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired + }) + ), + filterTitle: PropTypes.shape({ + left: PropTypes.string, + right: PropTypes.string + }), + selectedValuesList: PropTypes.arrayOf(PropTypes.string), + + onChange: PropTypes.func.isRequired + }; + + static defaultProps = { + selectedValuesList: [], + availableList: [], + filterTitle: { + left: '', + right: '' + } + }; + + state = { + availableListFilter: '', + selectedValuesListFilter: '', + selectedValues: [] + }; + + render() { + let { + availableList, + selectedValuesList, + filterTitle, + isReadOnlyMode + } = this.props; + let { availableListFilter, selectedValuesListFilter } = this.state; + + let unselectedList = availableList.filter( + availableItem => + !selectedValuesList.find(value => value === availableItem.id) + ); + let selectedList = availableList.filter(availableItem => + selectedValuesList.find(value => value === availableItem.id) + ); + selectedList = selectedList.sort( + (a, b) => + selectedValuesList.indexOf(a.id) - + selectedValuesList.indexOf(b.id) + ); + return ( +
+ {this.renderListbox( + filterTitle.left, + unselectedList, + { + value: availableListFilter, + ref: 'availableListFilter', + disabled: isReadOnlyMode, + onChange: value => + this.setState({ availableListFilter: value }) + }, + { + ref: 'availableValues', + disabled: isReadOnlyMode, + testId: 'available' + } + )} + {this.renderOperationsBar(isReadOnlyMode)} + {this.renderListbox( + filterTitle.right, + selectedList, + { + value: selectedValuesListFilter, + ref: 'selectedValuesListFilter', + disabled: isReadOnlyMode, + onChange: value => + this.setState({ selectedValuesListFilter: value }) + }, + { + ref: 'selectedValues', + disabled: isReadOnlyMode, + testId: 'selected' + } + )} +
+ ); + } + + renderListbox(filterTitle, list, filterProps, props) { + let regExFilter = new RegExp(escape(filterProps.value), 'i'); + let matchedItems = list.filter(item => item.name.match(regExFilter)); + let unMatchedItems = list.filter(item => !item.name.match(regExFilter)); + return ( +
+

{filterTitle}

+
+ + +
+ + this.onSelectItems(event.target.selectedOptions) + } + groupClassName="dual-list-box-multi-select" + type="select" + name="dual-list-box-multi-select" + data-test-id={`${props.testId}-select-input`} + disabled={props.disabled} + ref={props.ref}> + {matchedItems.map(item => + this.renderOption(item.id, item.name) + )} + {matchedItems.length && + unMatchedItems.length && ( + + )} + {unMatchedItems.map(item => + this.renderOption(item.id, item.name) + )} + +
+ ); + } + + onSelectItems(selectedOptions) { + let selectedValues = Object.keys(selectedOptions).map( + k => selectedOptions[k].value + ); + this.setState({ selectedValues }); + } + + renderOption(value, name) { + return ( + + ); + } + + renderOperationsBar(isReadOnlyMode) { + return ( +
+ {this.renderOperationBarButton( + () => this.addToSelectedList(), + 'angleRight' + )} + {this.renderOperationBarButton( + () => this.removeFromSelectedList(), + 'angleLeft' + )} + {this.renderOperationBarButton( + () => this.addAllToSelectedList(), + 'angleDoubleRight' + )} + {this.renderOperationBarButton( + () => this.removeAllFromSelectedList(), + 'angleDoubleLeft' + )} +
+ ); + } + + renderOperationBarButton(onClick, iconName) { + return ( +
+ +
+ ); + } + + addToSelectedList() { + this.props.onChange( + this.props.selectedValuesList.concat(this.state.selectedValues) + ); + this.setState({ selectedValues: [] }); + } + + removeFromSelectedList() { + const selectedValues = this.state.selectedValues; + this.props.onChange( + this.props.selectedValuesList.filter( + value => + !selectedValues.find( + selectedValue => selectedValue === value + ) + ) + ); + this.setState({ selectedValues: [] }); + } + + addAllToSelectedList() { + this.props.onChange(this.props.availableList.map(item => item.id)); + } + + removeAllFromSelectedList() { + this.props.onChange([]); + } } export default DualListboxView; diff --git a/openecomp-ui/src/nfvo-components/input/validation/Form.jsx b/openecomp-ui/src/nfvo-components/input/validation/Form.jsx index 6df0bf9009..62fc29a55c 100644 --- a/openecomp-ui/src/nfvo-components/input/validation/Form.jsx +++ b/openecomp-ui/src/nfvo-components/input/validation/Form.jsx @@ -19,130 +19,160 @@ import PropTypes from 'prop-types'; import ValidationButtons from './ValidationButtons.jsx'; class Form extends React.Component { - - static defaultProps = { - hasButtons : true, - onSubmit : null, - onReset : null, - labledButtons: true, - onValidChange : null, - isValid: true, - submitButtonText: null, - cancelButtonText: null - }; - - static propTypes = { - isValid : PropTypes.bool, - formReady : PropTypes.bool, - isReadOnlyMode : PropTypes.bool, - hasButtons : PropTypes.bool, - onSubmit : PropTypes.func, - onReset : PropTypes.func, - labledButtons: PropTypes.bool, - submitButtonText: PropTypes.string, - cancelButtonText: PropTypes.string, - onValidChange : PropTypes.func, - onValidityChanged: PropTypes.func, - onValidateForm: PropTypes.func - }; - - constructor(props) { - super(props); - } - - - render() { - // eslint-disable-next-line no-unused-vars - let {isValid, onValidChange, onValidityChanged, onDataChanged, formReady, onValidateForm, isReadOnlyMode, hasButtons, onSubmit, labledButtons, submitButtonText, - cancelButtonText, children, ...formProps} = this.props; - return ( -
this.form = form} onSubmit={event => this.handleFormValidation(event)}> -
-
- {children} -
-
- {hasButtons && - this.buttons = buttons} - isReadOnlyMode={isReadOnlyMode}/>} - - ); - } - - handleFormValidation(event) { - event.preventDefault(); - if (this.props.onValidateForm && !this.props.formReady){ - return this.props.onValidateForm(); - } else { - return this.handleFormSubmit(event); - } - } - handleFormSubmit(event) { - if (event) { - event.preventDefault(); - } - if(this.props.onSubmit) { - return this.props.onSubmit(event); - } - } - - componentDidMount() { - if (this.props.hasButtons) { - this.buttons.setState({isValid: this.props.isValid}); - } - } - - - - componentDidUpdate(prevProps) { - // only handling this programatically if the validation of the form is done outside of the view - // (example with a form that is dependent on the state of other forms) - if (prevProps.isValid !== this.props.isValid) { - if (this.props.hasButtons) { - this.buttons.setState({isValid: this.props.isValid}); - } - // callback in case form is part of bigger picture in view - if (this.props.onValidChange) { - this.props.onValidChange(this.props.isValid); - } - - // TODO - maybe this has to be part of componentWillUpdate - if(this.props.onValidityChanged) { - this.props.onValidityChanged(this.props.isValid); - } - } - if (this.props.formReady) { // if form validation succeeded -> continue with submit - this.handleFormSubmit(); - } - } - + static defaultProps = { + hasButtons: true, + onSubmit: null, + onReset: null, + labledButtons: true, + onValidChange: null, + isValid: true, + submitButtonText: null, + cancelButtonText: null + }; + + static propTypes = { + isValid: PropTypes.bool, + formReady: PropTypes.bool, + isReadOnlyMode: PropTypes.bool, + hasButtons: PropTypes.bool, + onSubmit: PropTypes.func, + onReset: PropTypes.func, + labledButtons: PropTypes.bool, + submitButtonText: PropTypes.string, + cancelButtonText: PropTypes.string, + onValidChange: PropTypes.func, + onValidityChanged: PropTypes.func, + onValidateForm: PropTypes.func + }; + + constructor(props) { + super(props); + } + render() { + /* eslint-disable no-unused-vars */ + let { + isValid, + onValidChange, + onValidityChanged, + onDataChanged, + formReady, + onValidateForm, + isReadOnlyMode, + hasButtons, + onSubmit, + labledButtons, + submitButtonText, + cancelButtonText, + children, + ...formProps + } = this.props; + /* eslint-enable no-unused-vars */ + return ( +
(this.form = form)} + onSubmit={event => this.handleFormValidation(event)}> +
+
{children}
+
+ {hasButtons && ( + (this.buttons = buttons)} + isReadOnlyMode={isReadOnlyMode} + /> + )} + + ); + } + + handleFormValidation(event) { + event.preventDefault(); + if (this.props.onValidateForm && !this.props.formReady) { + return this.props.onValidateForm(); + } else { + return this.handleFormSubmit(event); + } + } + handleFormSubmit(event) { + if (event) { + event.preventDefault(); + } + if (this.props.onSubmit) { + return this.props.onSubmit(event); + } + } + + componentDidMount() { + if (this.props.hasButtons) { + this.buttons.setState({ isValid: this.props.isValid }); + } + } + + componentDidUpdate(prevProps) { + // only handling this programatically if the validation of the form is done outside of the view + // (example with a form that is dependent on the state of other forms) + if (prevProps.isValid !== this.props.isValid) { + if (this.props.hasButtons) { + this.buttons.setState({ isValid: this.props.isValid }); + } + // callback in case form is part of bigger picture in view + if (this.props.onValidChange) { + this.props.onValidChange(this.props.isValid); + } + + // TODO - maybe this has to be part of componentWillUpdate + if (this.props.onValidityChanged) { + this.props.onValidityChanged(this.props.isValid); + } + } + if (this.props.formReady) { + // if form validation succeeded -> continue with submit + this.handleFormSubmit(); + } + } } export class TabsForm extends Form { - render() { - // eslint-disable-next-line no-unused-vars - let {submitButtonText, cancelButtonText, isValid, formReady, onValidateForm, isReadOnlyMode, hasButtons, onSubmit, labledButtons, onValidChange, onValidityChanged, onDataChanged, children, - ...formProps} = this.props; - return ( -
this.form = form} onSubmit={event => this.handleFormValidation(event)}> -
- {children} -
- {hasButtons && - this.buttons = buttons} - isReadOnlyMode={isReadOnlyMode}/> - } - - ); - } + render() { + /* eslint-disable no-unused-vars */ + let { + submitButtonText, + cancelButtonText, + isValid, + formReady, + onValidateForm, + isReadOnlyMode, + hasButtons, + onSubmit, + labledButtons, + onValidChange, + onValidityChanged, + onDataChanged, + children, + ...formProps + } = this.props; + /* eslint-enable no-unused-vars */ + return ( +
(this.form = form)} + onSubmit={event => this.handleFormValidation(event)}> +
{children}
+ {hasButtons && ( + (this.buttons = buttons)} + isReadOnlyMode={isReadOnlyMode} + /> + )} + + ); + } } export default Form; diff --git a/openecomp-ui/src/nfvo-components/input/validation/Input.jsx b/openecomp-ui/src/nfvo-components/input/validation/Input.jsx index 33cea933b5..a5d6f4fd7a 100644 --- a/openecomp-ui/src/nfvo-components/input/validation/Input.jsx +++ b/openecomp-ui/src/nfvo-components/input/validation/Input.jsx @@ -25,191 +25,249 @@ import Tooltip from 'react-bootstrap/lib/Tooltip.js'; import Datepicker from 'nfvo-components/datepicker/Datepicker.jsx'; class Input extends React.Component { + state = { + value: this.props.value, + checked: this.props.checked, + selectedValues: [] + }; - state = { - value: this.props.value, - checked: this.props.checked, - selectedValues: [] - }; + render() { + /* eslint-disable no-unused-vars */ + const { + label, + isReadOnlyMode, + value, + onBlur, + onKeyDown, + type, + disabled, + checked, + name + } = this.props; + const { + groupClassName, + isValid = true, + errorText, + isRequired, + overlayPos, + ...inputProps + } = this.props; + const { + dateFormat, + startDate, + endDate, + selectsStart, + selectsEnd + } = this.props; // Date Props + /* eslint-enable no-unused-vars */ + let wrapperClassName = + type !== 'radio' + ? 'validation-input-wrapper' + : 'validation-radio-wrapper'; + if (disabled) { + wrapperClassName += ' disabled'; + } + return ( +
+ + {label && + (type !== 'checkbox' && type !== 'radio') && ( + + )} + {type === 'text' && ( + this.onChange(e)} + disabled={isReadOnlyMode || Boolean(disabled)} + onBlur={onBlur} + onKeyDown={onKeyDown} + value={value || ''} + inputRef={input => (this.input = input)} + type={type} + data-test-id={this.props['data-test-id']} + /> + )} + {type === 'number' && ( + this.onChange(e)} + disabled={isReadOnlyMode || Boolean(disabled)} + onBlur={onBlur} + onKeyDown={onKeyDown} + value={value !== undefined ? value : ''} + inputRef={input => (this.input = input)} + type={type} + data-test-id={this.props['data-test-id']} + /> + )} - render() { - const {label, isReadOnlyMode, value, onBlur, onKeyDown, type, disabled, checked, name} = this.props; - // eslint-disable-next-line no-unused-vars - const {groupClassName, isValid = true, errorText, isRequired, overlayPos, ...inputProps} = this.props; - const {dateFormat, startDate, endDate, selectsStart, selectsEnd} = this.props; // Date Props - let wrapperClassName = (type !== 'radio') ? 'validation-input-wrapper' : 'validation-radio-wrapper'; - if (disabled) { - wrapperClassName += ' disabled'; - } - return( -
- - {(label && (type !== 'checkbox' && type !== 'radio')) && } - {type === 'text' && - this.onChange(e)} - disabled={isReadOnlyMode || Boolean(disabled)} - onBlur={onBlur} - onKeyDown={onKeyDown} - value={value || ''} - inputRef={(input) => this.input = input} - type={type} - data-test-id={this.props['data-test-id']}/>} - {type === 'number' && - this.onChange(e)} - disabled={isReadOnlyMode || Boolean(disabled)} - onBlur={onBlur} - onKeyDown={onKeyDown} - value={(value !== undefined) ? value : ''} - inputRef={(input) => this.input = input} - type={type} - data-test-id={this.props['data-test-id']}/>} + {type === 'textarea' && ( + this.onChange(e)} + inputRef={input => (this.input = input)} + data-test-id={this.props['data-test-id']} + /> + )} - {type === 'textarea' && - this.onChange(e)} - inputRef={(input) => this.input = input} - data-test-id={this.props['data-test-id']}/>} + {type === 'checkbox' && ( + this.onChangeCheckBox(e)} + disabled={isReadOnlyMode || Boolean(disabled)} + checked={checked} + data-test-id={this.props['data-test-id']}> + {label} + + )} - {type === 'checkbox' && - this.onChangeCheckBox(e)} - disabled={isReadOnlyMode || Boolean(disabled)} - checked={checked} - data-test-id={this.props['data-test-id']}>{label}} + {type === 'radio' && ( + + this.onChangeRadio(isChecked) + } + inputRef={input => (this.input = input)} + label={label} + data-test-id={this.props['data-test-id']} + /> + )} + {type === 'select' && ( + this.optionSelect(e)} + className="custom-select" + componentClass={type} + inputRef={input => (this.input = input)} + name={name} + {...inputProps} + data-test-id={this.props['data-test-id']} + /> + )} + {type === 'date' && ( + (this.input = input)} + onChange={this.props.onChange} + disabled={isReadOnlyMode || Boolean(disabled)} + data-test-id={this.props['data-test-id']} + selectsStart={selectsStart} + selectsEnd={selectsEnd} + /> + )} + + {this.renderErrorOverlay()} +
+ ); + } - {type === 'radio' && - this.onChangeRadio(isChecked)} - inputRef={(input) => this.input = input} - label={label} - data-test-id={this.props['data-test-id']} />} - {type === 'select' && - this.optionSelect(e) } - className='custom-select' - componentClass={type} - inputRef={(input) => this.input = input} - name={name} {...inputProps} - data-test-id={this.props['data-test-id']}/>} - {type === 'date' && - this.input = input} - onChange={this.props.onChange} - disabled={isReadOnlyMode || Boolean(disabled)} - data-test-id={this.props['data-test-id']} - selectsStart={selectsStart} - selectsEnd={selectsEnd} />} -
- { this.renderErrorOverlay() } -
- ); - } + getValue() { + return this.props.type !== 'select' + ? this.state.value + : this.state.selectedValues; + } - getValue() { - return this.props.type !== 'select' ? this.state.value : this.state.selectedValues; - } + getChecked() { + return this.state.checked; + } - getChecked() { - return this.state.checked; - } + optionSelect(e) { + let selectedValues = []; + if (e.target.value) { + selectedValues.push(e.target.value); + } + this.setState({ + selectedValues + }); + } - optionSelect(e) { - let selectedValues = []; - if (e.target.value) { - selectedValues.push(e.target.value); - } - this.setState({ - selectedValues - }); - } + onChange(e) { + const { onChange, type } = this.props; + let value = e.target.value; + if (type === 'number') { + if (value === '') { + value = undefined; + } else { + value = Number(value); + } + } + this.setState({ + value + }); + onChange(value); + } - onChange(e) { - const {onChange, type} = this.props; - let value = e.target.value; - if (type === 'number') { - if (value === '') { - value = undefined; - } else { - value = Number(value); - } - } - this.setState({ - value - }); - onChange(value); - } + onChangeCheckBox(e) { + let { onChange } = this.props; + let checked = e.target.checked; + this.setState({ + checked + }); + onChange(checked); + } - onChangeCheckBox(e) { - let {onChange} = this.props; - let checked = e.target.checked; - this.setState({ - checked - }); - onChange(checked); - } + onChangeRadio(isChecked) { + let { onChange } = this.props; + this.setState({ + checked: isChecked + }); + onChange(this.state.value); + } - onChangeRadio(isChecked) { - let {onChange} = this.props; - this.setState({ - checked: isChecked - }); - onChange(this.state.value); - } + focus() { + ReactDOM.findDOMNode(this.input).focus(); + } - focus() { - ReactDOM.findDOMNode(this.input).focus(); - } + renderErrorOverlay() { + let position = 'right'; + const { errorText = '', isValid = true, type, overlayPos } = this.props; - renderErrorOverlay() { - let position = 'right'; - const {errorText = '', isValid = true, type, overlayPos} = this.props; - - if (overlayPos) { - position = overlayPos; - } - else if (type === 'text' - || type === 'email' - || type === 'number' - || type === 'radio' - || type === 'password' - || type === 'date') { - position = 'bottom'; - } - - return ( - { - let target = ReactDOM.findDOMNode(this.input); - return target.offsetParent ? target : undefined; - }} - container={this}> - - {errorText} - - - ); - } + if (overlayPos) { + position = overlayPos; + } else if ( + type === 'text' || + type === 'email' || + type === 'number' || + type === 'radio' || + type === 'password' || + type === 'date' + ) { + position = 'bottom'; + } + return ( + { + let target = ReactDOM.findDOMNode(this.input); + return target.offsetParent ? target : undefined; + }} + container={this}> + + {errorText} + + + ); + } } -export default Input; +export default Input; diff --git a/openecomp-ui/src/nfvo-components/input/validation/InputOptions.jsx b/openecomp-ui/src/nfvo-components/input/validation/InputOptions.jsx index 11b07ba9da..019b6a5c70 100644 --- a/openecomp-ui/src/nfvo-components/input/validation/InputOptions.jsx +++ b/openecomp-ui/src/nfvo-components/input/validation/InputOptions.jsx @@ -22,260 +22,341 @@ import Select from 'nfvo-components/input/SelectInput.jsx'; import Overlay from 'react-bootstrap/lib/Overlay.js'; import Tooltip from 'react-bootstrap/lib/Tooltip.js'; -export const other = {OTHER: 'Other'}; +export const other = { OTHER: 'Other' }; class InputOptions extends React.Component { + static propTypes = { + values: PropTypes.arrayOf( + PropTypes.shape({ + enum: PropTypes.string, + title: PropTypes.string + }) + ), + isEnabledOther: PropTypes.bool, + label: PropTypes.string, + selectedValue: PropTypes.string, + multiSelectedEnum: PropTypes.oneOfType([ + PropTypes.string, + PropTypes.array + ]), + selectedEnum: PropTypes.string, + otherValue: PropTypes.string, + overlayPos: PropTypes.string, + onEnumChange: PropTypes.func, + onOtherChange: PropTypes.func, + onBlur: PropTypes.func, + isRequired: PropTypes.bool, + isMultiSelect: PropTypes.bool, + isValid: PropTypes.bool, + disabled: PropTypes.bool + }; - static propTypes = { - values: PropTypes.arrayOf(PropTypes.shape({ - enum: PropTypes.string, - title: PropTypes.string - })), - isEnabledOther: PropTypes.bool, - label: PropTypes.string, - selectedValue: PropTypes.string, - multiSelectedEnum: PropTypes.oneOfType([ - PropTypes.string, - PropTypes.array - ]), - selectedEnum: PropTypes.string, - otherValue: PropTypes.string, - overlayPos: PropTypes.string, - onEnumChange: PropTypes.func, - onOtherChange: PropTypes.func, - onBlur: PropTypes.func, - isRequired: PropTypes.bool, - isMultiSelect: PropTypes.bool, - isValid: PropTypes.bool, - disabled: PropTypes.bool - }; + state = { + otherInputDisabled: !this.props.otherValue + }; - state = { - otherInputDisabled: !this.props.otherValue - }; + oldProps = { + selectedEnum: '', + otherValue: '', + multiSelectedEnum: [] + }; - oldProps = { - selectedEnum: '', - otherValue: '', - multiSelectedEnum: [] - }; + render() { + let { + label, + isRequired, + values, + otherValue, + onOtherChange, + isMultiSelect, + onBlur, + multiSelectedEnum, + selectedEnum, + isValid, + children, + isReadOnlyMode + } = this.props; + const dataTestId = this.props['data-test-id'] + ? { 'data-test-id': this.props['data-test-id'] } + : {}; + let currentMultiSelectedEnum = []; + let currentSelectedEnum = ''; + let otherInputDisabled = + (isMultiSelect && + (multiSelectedEnum === undefined || + multiSelectedEnum.length === 0 || + multiSelectedEnum[0] !== other.OTHER)) || + (!isMultiSelect && + (selectedEnum === undefined || selectedEnum !== other.OTHER)); + if (isMultiSelect) { + currentMultiSelectedEnum = multiSelectedEnum; + if (!otherInputDisabled) { + currentSelectedEnum = multiSelectedEnum + ? multiSelectedEnum.toString() + : undefined; + } + } else if (selectedEnum) { + currentSelectedEnum = selectedEnum; + } + if (!onBlur) { + onBlur = () => {}; + } - render() { - let {label, isRequired, values, otherValue, onOtherChange, isMultiSelect, onBlur, multiSelectedEnum, selectedEnum, isValid, children, isReadOnlyMode} = this.props; - const dataTestId = this.props['data-test-id'] ? {'data-test-id': this.props['data-test-id']} : {}; - let currentMultiSelectedEnum = []; - let currentSelectedEnum = ''; - let otherInputDisabled = (isMultiSelect && (multiSelectedEnum === undefined || multiSelectedEnum.length === 0 || multiSelectedEnum[0] !== other.OTHER)) - || (!isMultiSelect && (selectedEnum === undefined || selectedEnum !== other.OTHER)); - if (isMultiSelect) { - currentMultiSelectedEnum = multiSelectedEnum; - if(!otherInputDisabled) { - currentSelectedEnum = multiSelectedEnum ? multiSelectedEnum.toString() : undefined; - } - } - else if(selectedEnum){ - currentSelectedEnum = selectedEnum; - } - if (!onBlur) { - onBlur = () => {}; - } + return ( +
+
+ {label && } + {isMultiSelect && otherInputDisabled ? ( + (this.input = input)} + label={label} + className="form-control input-options-select" + value={currentSelectedEnum} + style={{ + width: otherInputDisabled ? '100%' : '100px' + }} + onBlur={() => onBlur()} + disabled={ + isReadOnlyMode || + Boolean(this.props.disabled) + } + onChange={value => this.enumChanged(value)} + type="select"> + {children || + (values && + values.length && + values.map((val, index) => + this.renderOptions(val, index) + ))} + {onOtherChange && ( + + )} + - return( -
-
- {label && } - {isMultiSelect && otherInputDisabled ? - this.input = input} - label={label} - className='form-control input-options-select' - value={currentSelectedEnum} - style={{'width' : otherInputDisabled ? '100%' : '100px'}} - onBlur={() => onBlur()} - disabled={isReadOnlyMode || Boolean(this.props.disabled)} - onChange={ value => this.enumChanged(value)} - type='select'> - {children || (values && values.length && values.map((val, index) => this.renderOptions(val, index)))} - {onOtherChange && } - + {!otherInputDisabled && ( +
+ )} + + (this.otherValue = otherValue) + } + style={{ + display: otherInputDisabled + ? 'none' + : 'block' + }} + disabled={ + isReadOnlyMode || + Boolean(this.props.disabled) + } + value={otherValue || ''} + onBlur={() => onBlur()} + onChange={() => this.changedOtherInput()} + /> +
+ )} +
+ {this.renderErrorOverlay()} +
+ ); + } - {!otherInputDisabled &&
} - this.otherValue = otherValue} - style={{'display' : otherInputDisabled ? 'none' : 'block'}} - disabled={isReadOnlyMode || Boolean(this.props.disabled)} - value={otherValue || ''} - onBlur={() => onBlur()} - onChange={() => this.changedOtherInput()}/> -
- } -
- { this.renderErrorOverlay() } -
- ); - } + renderOptions(val, index) { + return ( + + ); + } - renderOptions(val, index){ - return ( - - ); - } + renderMultiSelectOptions(values) { + let { onOtherChange } = this.props; + let optionsList = []; + if (onOtherChange) { + optionsList = values + .map(option => { + return { + label: option.title, + value: option.enum + }; + }) + .concat([ + { + label: i18n(other.OTHER), + value: i18n(other.OTHER) + } + ]); + } else { + optionsList = values.map(option => { + return { + label: option.title, + value: option.enum + }; + }); + } + if (optionsList.length > 0 && optionsList[0].value === '') { + optionsList.shift(); + } + return optionsList; + } + renderErrorOverlay() { + let position = 'right'; + const { errorText = '', isValid = true, type, overlayPos } = this.props; - renderMultiSelectOptions(values) { - let {onOtherChange} = this.props; - let optionsList = []; - if (onOtherChange) { - optionsList = values.map(option => { - return { - label: option.title, - value: option.enum, - }; - }).concat([{ - label: i18n(other.OTHER), - value: i18n(other.OTHER), - }]); - } - else { - optionsList = values.map(option => { - return { - label: option.title, - value: option.enum, - }; - }); - } - if (optionsList.length > 0 && optionsList[0].value === '') { - optionsList.shift(); - } - return optionsList; - } + if (overlayPos) { + position = overlayPos; + } else if ( + type === 'text' || + type === 'email' || + type === 'number' || + type === 'password' + ) { + position = 'bottom'; + } - renderErrorOverlay() { - let position = 'right'; - const {errorText = '', isValid = true, type, overlayPos} = this.props; + return ( + { + let { otherInputDisabled } = this.state; + let target = otherInputDisabled + ? ReactDOM.findDOMNode(this.input) + : ReactDOM.findDOMNode(this.otherValue); + return target.offsetParent ? target : undefined; + }} + container={this}> + + {errorText} + + + ); + } - if (overlayPos) { - position = overlayPos; - } - else if (type === 'text' - || type === 'email' - || type === 'number' - || type === 'password') { - position = 'bottom'; - } + getValue() { + let res = ''; + let { isMultiSelect } = this.props; + let { otherInputDisabled } = this.state; - return ( - { - let {otherInputDisabled} = this.state; - let target = otherInputDisabled ? ReactDOM.findDOMNode(this.input) : ReactDOM.findDOMNode(this.otherValue); - return target.offsetParent ? target : undefined; - }} - container={this}> - - {errorText} - - - ); - } + if (otherInputDisabled) { + res = isMultiSelect ? this.input.getValue() : this.input.value; + } else { + res = this.otherValue.value; + } + return res; + } - getValue() { - let res = ''; - let {isMultiSelect} = this.props; - let {otherInputDisabled} = this.state; + enumChanged() { + let enumValue = this.input.value; + let { + onEnumChange, + onOtherChange, + isMultiSelect, + onChange + } = this.props; + this.setState({ + otherInputDisabled: + !Boolean(onOtherChange) || enumValue !== other.OTHER + }); - if (otherInputDisabled) { - res = isMultiSelect ? this.input.getValue() : this.input.value; - } else { - res = this.otherValue.value; - } - return res; - } + let value = isMultiSelect ? [enumValue] : enumValue; + if (onEnumChange) { + onEnumChange(value); + } + if (onChange) { + onChange(value); + } + } - enumChanged() { - let enumValue = this.input.value; - let {onEnumChange, onOtherChange, isMultiSelect, onChange} = this.props; - this.setState({ - otherInputDisabled: !Boolean(onOtherChange) || enumValue !== other.OTHER - }); + multiSelectEnumChanged(enumValue) { + let { onEnumChange, onOtherChange } = this.props; + let selectedValues = enumValue.map(enumVal => { + return enumVal.value; + }); - let value = isMultiSelect ? [enumValue] : enumValue; - if (onEnumChange) { - onEnumChange(value); - } - if (onChange) { - onChange(value); - } - } + if (this.state.otherInputDisabled === false) { + selectedValues.shift(); + } else if (selectedValues.includes(i18n(other.OTHER))) { + selectedValues = [i18n(other.OTHER)]; + } - multiSelectEnumChanged(enumValue) { - let {onEnumChange, onOtherChange} = this.props; - let selectedValues = enumValue.map(enumVal => { - return enumVal.value; - }); + this.setState({ + otherInputDisabled: + !Boolean(onOtherChange) || + !selectedValues.includes(i18n(other.OTHER)) + }); + onEnumChange(selectedValues); + } - if (this.state.otherInputDisabled === false) { - selectedValues.shift(); - } - else if (selectedValues.includes(i18n(other.OTHER))) { - selectedValues = [i18n(other.OTHER)]; - } + changedOtherInput() { + let { onOtherChange } = this.props; + onOtherChange(this.otherValue.value); + } - this.setState({ - otherInputDisabled: !Boolean(onOtherChange) || !selectedValues.includes(i18n(other.OTHER)) - }); - onEnumChange(selectedValues); - } - - changedOtherInput() { - let {onOtherChange} = this.props; - onOtherChange(this.otherValue.value); - } - - componentDidUpdate() { - let {otherValue, selectedEnum, onInputChange, multiSelectedEnum} = this.props; - if (this.oldProps.otherValue !== otherValue - || this.oldProps.selectedEnum !== selectedEnum - || this.oldProps.multiSelectedEnum !== multiSelectedEnum) { - this.oldProps = { - otherValue, - selectedEnum, - multiSelectedEnum - }; - onInputChange(); - } - } - - static getTitleByName(values, name) { - for (let key of Object.keys(values)) { - let option = values[key].find(option => option.enum === name); - if (option) { - return option.title; - } - } - return name; - } + componentDidUpdate() { + let { + otherValue, + selectedEnum, + onInputChange, + multiSelectedEnum + } = this.props; + if ( + this.oldProps.otherValue !== otherValue || + this.oldProps.selectedEnum !== selectedEnum || + this.oldProps.multiSelectedEnum !== multiSelectedEnum + ) { + this.oldProps = { + otherValue, + selectedEnum, + multiSelectedEnum + }; + onInputChange(); + } + } + static getTitleByName(values, name) { + for (let key of Object.keys(values)) { + let option = values[key].find(option => option.enum === name); + if (option) { + return option.title; + } + } + return name; + } } export default InputOptions; diff --git a/openecomp-ui/src/nfvo-components/input/validation/InputWrapper.jsx b/openecomp-ui/src/nfvo-components/input/validation/InputWrapper.jsx index e440fcda69..3e0bb32ca9 100644 --- a/openecomp-ui/src/nfvo-components/input/validation/InputWrapper.jsx +++ b/openecomp-ui/src/nfvo-components/input/validation/InputWrapper.jsx @@ -22,114 +22,149 @@ import FormGroup from 'react-bootstrap/lib/FormGroup.js'; import FormControl from 'react-bootstrap/lib/FormControl.js'; class InputWrapper extends React.Component { - - state = { - value: this.props.value, - checked: this.props.checked, - selectedValues: [] - } - - render() { - const {label, hasError, validations = {}, isReadOnlyMode, value, onBlur, onKeyDown, type, disabled, checked, name} = this.props; - const {groupClassName, ...inputProps} = this.props; - return( - - {(label && (type !== 'checkbox' && type !== 'radio')) && } - {(type === 'text' || type === 'number') && - this.onChange(e)} - disabled={isReadOnlyMode || Boolean(disabled)} - onBlur={onBlur} - onKeyDown={onKeyDown} - value={value || ''} - ref={(input) => this.inputWrapper = input} - type={type} - data-test-id={this.props['data-test-id']}/>} - - {type === 'textarea' && - this.onChange(e)} - data-test-id={this.props['data-test-id']}/>} - - {type === 'checkbox' && - this.onChangeCheckBox(e)} - disabled={isReadOnlyMode || Boolean(disabled)} - checked={value} - data-test-id={this.props['data-test-id']}>{label}} - - {type === 'radio' && - this.inputWrapper = input} - onChange={(isChecked)=>this.onChangeRadio(isChecked)} label={label} - data-test-id={this.props['data-test-id']} />} - {type === 'select' && - this.optionSelect(e) } - componentClass={type} - name={name} {...inputProps} - data-test-id={this.props['data-test-id']}/>} - - - - ); - } - - getValue() { - return this.props.type !== 'select' ? this.state.value : this.state.selectedValues; - } - - getChecked() { - return this.state.checked; - } - - optionSelect(e) { - let selectedValues = []; - if (e.target.value) { - selectedValues.push(e.target.value); - } - this.setState({ - selectedValues - }); - } - - onChange(e) { - let {onChange} = this.props; - this.setState({ - value: e.target.value - }); - onChange(e.target.value); - } - - onChangeCheckBox(e) { - let {onChange} = this.props; - this.setState({ - checked: e.target.checked - }); - onChange(e.target.checked); - } - - onChangeRadio(isChecked) { - let {onChange} = this.props; - this.setState({ - checked: isChecked - }); - onChange(this.state.value); - } - - focus() { - ReactDOM.findDOMNode(this.inputWrapper).focus(); - } - + state = { + value: this.props.value, + checked: this.props.checked, + selectedValues: [] + }; + + render() { + const { + label, + hasError, + validations = {}, + isReadOnlyMode, + value, + onBlur, + onKeyDown, + type, + disabled, + checked, + name + } = this.props; + const { groupClassName, ...inputProps } = this.props; + return ( + + {label && + (type !== 'checkbox' && type !== 'radio') && ( + + )} + {(type === 'text' || type === 'number') && ( + this.onChange(e)} + disabled={isReadOnlyMode || Boolean(disabled)} + onBlur={onBlur} + onKeyDown={onKeyDown} + value={value || ''} + ref={input => (this.inputWrapper = input)} + type={type} + data-test-id={this.props['data-test-id']} + /> + )} + + {type === 'textarea' && ( + this.onChange(e)} + data-test-id={this.props['data-test-id']} + /> + )} + + {type === 'checkbox' && ( + this.onChangeCheckBox(e)} + disabled={isReadOnlyMode || Boolean(disabled)} + checked={value} + data-test-id={this.props['data-test-id']}> + {label} + + )} + + {type === 'radio' && ( + (this.inputWrapper = input)} + onChange={isChecked => this.onChangeRadio(isChecked)} + label={label} + data-test-id={this.props['data-test-id']} + /> + )} + {type === 'select' && ( + this.optionSelect(e)} + componentClass={type} + name={name} + {...inputProps} + data-test-id={this.props['data-test-id']} + /> + )} + + ); + } + + getValue() { + return this.props.type !== 'select' + ? this.state.value + : this.state.selectedValues; + } + + getChecked() { + return this.state.checked; + } + + optionSelect(e) { + let selectedValues = []; + if (e.target.value) { + selectedValues.push(e.target.value); + } + this.setState({ + selectedValues + }); + } + + onChange(e) { + let { onChange } = this.props; + this.setState({ + value: e.target.value + }); + onChange(e.target.value); + } + + onChangeCheckBox(e) { + let { onChange } = this.props; + this.setState({ + checked: e.target.checked + }); + onChange(e.target.checked); + } + + onChangeRadio(isChecked) { + let { onChange } = this.props; + this.setState({ + checked: isChecked + }); + onChange(this.state.value); + } + + focus() { + ReactDOM.findDOMNode(this.inputWrapper).focus(); + } } -export default InputWrapper; +export default InputWrapper; diff --git a/openecomp-ui/src/nfvo-components/input/validation/Tabs.jsx b/openecomp-ui/src/nfvo-components/input/validation/Tabs.jsx index 0982c133e6..429985a902 100644 --- a/openecomp-ui/src/nfvo-components/input/validation/Tabs.jsx +++ b/openecomp-ui/src/nfvo-components/input/validation/Tabs.jsx @@ -16,64 +16,76 @@ import React from 'react'; import PropTypes from 'prop-types'; import ReactDOM from 'react-dom'; -import {default as SDCTabs} from 'sdc-ui/lib/react/Tabs.js'; +import { default as SDCTabs } from 'sdc-ui/lib/react/Tabs.js'; import Overlay from 'react-bootstrap/lib/Overlay.js'; import Tooltip from 'react-bootstrap/lib/Tooltip.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -export default -class Tabs extends React.Component { +export default class Tabs extends React.Component { + static propTypes = { + children: PropTypes.node + }; - static propTypes = { - children: PropTypes.node - }; + cloneTab(element) { + const { invalidTabs } = this.props; + return React.cloneElement(element, { + key: element.props.tabId, + className: + invalidTabs.indexOf(element.props.tabId) > -1 + ? 'invalid-tab' + : 'valid-tab' + }); + } - cloneTab(element) { - const {invalidTabs} = this.props; - return React.cloneElement( - element, - { - key: element.props.tabId, - className: invalidTabs.indexOf(element.props.tabId) > -1 ? 'invalid-tab' : 'valid-tab' - } - ); - } + showTabsError() { + const { invalidTabs } = this.props; + const showError = + (invalidTabs.length === 1 && + invalidTabs[0] !== this.props.activeTab) || + invalidTabs.length > 1; + return showError; + } - showTabsError() { - const {invalidTabs} = this.props; - const showError = ((invalidTabs.length === 1 && invalidTabs[0] !== this.props.activeTab) || (invalidTabs.length > 1)); - return showError; - } - - render() { - // eslint-disable-next-line no-unused-vars - let {invalidTabs, ...tabProps} = this.props; - return ( -
- - {this.props.children.map(element => this.cloneTab(element))} - - { - let target = ReactDOM.findDOMNode(this.refs.tabsList).querySelector('ul > li.invalid-tab:not(.sdc-tab-active):nth-of-type(n)'); - return target && target.offsetParent ? target : undefined; - } - } - container={() => { - let target = ReactDOM.findDOMNode(this.refs.tabsList).querySelector('ul > li.invalid-tab:not(.sdc-tab-active):nth-of-type(n)'); - return target && target.offsetParent ? target.offsetParent : this; - }}> - - {i18n('One or more tabs are invalid')} - - -
- ); - } + render() { + // eslint-disable-next-line no-unused-vars + let { invalidTabs, ...tabProps } = this.props; + return ( +
+ + {this.props.children.map(element => this.cloneTab(element))} + + { + let target = ReactDOM.findDOMNode( + this.refs.tabsList + ).querySelector( + 'ul > li.invalid-tab:not(.sdc-tab-active):nth-of-type(n)' + ); + return target && target.offsetParent + ? target + : undefined; + }} + container={() => { + let target = ReactDOM.findDOMNode( + this.refs.tabsList + ).querySelector( + 'ul > li.invalid-tab:not(.sdc-tab-active):nth-of-type(n)' + ); + return target && target.offsetParent + ? target.offsetParent + : this; + }}> + + {i18n('One or more tabs are invalid')} + + +
+ ); + } } diff --git a/openecomp-ui/src/nfvo-components/input/validation/ValidationButtons.jsx b/openecomp-ui/src/nfvo-components/input/validation/ValidationButtons.jsx index 151d3fe859..e460f68a98 100644 --- a/openecomp-ui/src/nfvo-components/input/validation/ValidationButtons.jsx +++ b/openecomp-ui/src/nfvo-components/input/validation/ValidationButtons.jsx @@ -27,32 +27,63 @@ import Button from 'sdc-ui/lib/react/Button.js'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; class ValidationButtons extends React.Component { + static propTypes = { + labledButtons: PropTypes.bool.isRequired, + isReadOnlyMode: PropTypes.bool, + submitButtonText: PropTypes.string, + cancelButtonText: PropTypes.string + }; - static propTypes = { - labledButtons: PropTypes.bool.isRequired, - isReadOnlyMode: PropTypes.bool, - submitButtonText: PropTypes.string, - cancelButtonText: PropTypes.string - }; + state = { + isValid: this.props.formValid + }; - state = { - isValid: this.props.formValid - }; - - render() { - let submitBtn = this.props.labledButtons ? this.props.submitButtonText ? this.props.submitButtonText : i18n('Save') : ; - let closeBtn = this.props.labledButtons ? this.props.cancelButtonText ? this.props.cancelButtonText : i18n('Cancel') : ; - return ( -
- {!this.props.isReadOnlyMode ? -
- - -
- : - } -
- ); - } + render() { + let submitBtn = this.props.labledButtons ? ( + this.props.submitButtonText ? ( + this.props.submitButtonText + ) : ( + i18n('Save') + ) + ) : ( + + ); + let closeBtn = this.props.labledButtons ? ( + this.props.cancelButtonText ? ( + this.props.cancelButtonText + ) : ( + i18n('Cancel') + ) + ) : ( + + ); + return ( +
+ {!this.props.isReadOnlyMode ? ( +
+ + +
+ ) : ( + + )} +
+ ); + } } export default ValidationButtons; diff --git a/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemView.jsx b/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemView.jsx index 60c559a3d1..359af9d3b8 100644 --- a/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemView.jsx +++ b/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemView.jsx @@ -19,50 +19,78 @@ import classnames from 'classnames'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import store from 'sdc-app/AppStore.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; class ListEditorItem extends React.Component { - static propTypes = { - onSelect: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), - onDelete: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), - onEdit: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), - children: PropTypes.node, - isReadOnlyMode: PropTypes.bool - }; + static propTypes = { + onSelect: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), + onDelete: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), + onEdit: PropTypes.oneOfType([PropTypes.func, PropTypes.bool]), + children: PropTypes.node, + isReadOnlyMode: PropTypes.bool + }; - render() { - let {onDelete, onSelect, onEdit, children, isReadOnlyMode} = this.props; - let isAbilityToDelete = isReadOnlyMode === undefined ? true : !isReadOnlyMode; - return ( -
-
- {children} -
- {(onEdit || onDelete) &&
- {onEdit && this.onClickedItem(onEdit)}/>} - {onDelete && isAbilityToDelete && this.onClickedItem(onDelete)}/>} -
} -
- ); - } + render() { + let { + onDelete, + onSelect, + onEdit, + children, + isReadOnlyMode + } = this.props; + let isAbilityToDelete = + isReadOnlyMode === undefined ? true : !isReadOnlyMode; + return ( +
+
+ {children} +
+ {(onEdit || onDelete) && ( +
+ {onEdit && ( + this.onClickedItem(onEdit)} + /> + )} + {onDelete && + isAbilityToDelete && ( + this.onClickedItem(onDelete)} + /> + )} +
+ )} +
+ ); + } - onClickedItem(callBackFunc) { - if(typeof callBackFunc === 'function') { - let {isCheckedOut} = this.props; - if (isCheckedOut === false) { - store.dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data: { - title: i18n('Error'), - msg: i18n('This item is checkedin/submitted, Click Check Out to continue') - } - }); - } - else { - callBackFunc(); - } - } - } + onClickedItem(callBackFunc) { + if (typeof callBackFunc === 'function') { + let { isCheckedOut } = this.props; + if (isCheckedOut === false) { + store.dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: i18n('Error'), + msg: i18n( + 'This item is checkedin/submitted, Click Check Out to continue' + ) + } + }); + } else { + callBackFunc(); + } + } + } } export default ListEditorItem; diff --git a/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemViewField.jsx b/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemViewField.jsx index 839f9a504a..509ea176a5 100644 --- a/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemViewField.jsx +++ b/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemViewField.jsx @@ -15,10 +15,8 @@ */ import React from 'react'; -export const ListEditorItemViewField = ({children}) => ( -
- {children} -
+export const ListEditorItemViewField = ({ children }) => ( +
{children}
); export default ListEditorItemViewField; diff --git a/openecomp-ui/src/nfvo-components/listEditor/ListEditorView.jsx b/openecomp-ui/src/nfvo-components/listEditor/ListEditorView.jsx index 16823b7dc5..f71372ce1a 100644 --- a/openecomp-ui/src/nfvo-components/listEditor/ListEditorView.jsx +++ b/openecomp-ui/src/nfvo-components/listEditor/ListEditorView.jsx @@ -19,69 +19,107 @@ import Button from 'sdc-ui/lib/react/Button.js'; import classnames from 'classnames'; import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx'; -const ListEditorHeader = ({onAdd, isReadOnlyMode, title, plusButtonTitle}) => { - return ( -
- {title &&
{title}
} -
- { onAdd && - - } -
-
- ); +const ListEditorHeader = ({ + onAdd, + isReadOnlyMode, + title, + plusButtonTitle +}) => { + return ( +
+ {title &&
{title}
} +
+ {onAdd && ( + + )} +
+
+ ); }; -const ListEditorScroller = ({children, twoColumns}) => { - return ( -
-
- {children} -
-
- ); +const ListEditorScroller = ({ children, twoColumns }) => { + return ( +
+
+ {children} +
+
+ ); }; -const FilterWrapper = ({onFilter, filterValue}) => { - return ( -
- -
- ); +const FilterWrapper = ({ onFilter, filterValue }) => { + return ( +
+ +
+ ); }; class ListEditorView extends React.Component { + static defaultProps = { + className: '', + twoColumns: false + }; - static defaultProps = { - className: '', - twoColumns: false - }; - - static propTypes = { - title: PropTypes.string, - plusButtonTitle: PropTypes.string, - children: PropTypes.node, - filterValue: PropTypes.string, - onFilter: PropTypes.func, - className: PropTypes.string, - isReadOnlyMode: PropTypes.bool, - placeholder: PropTypes.string, - twoColumns: PropTypes.bool - }; - - render() { - let {title, plusButtonTitle, onAdd, children, onFilter, className, isReadOnlyMode, twoColumns, filterValue} = this.props; - return ( -
- - {onFilter && (children.length || filterValue) && } - -
- ); - } + static propTypes = { + title: PropTypes.string, + plusButtonTitle: PropTypes.string, + children: PropTypes.node, + filterValue: PropTypes.string, + onFilter: PropTypes.func, + className: PropTypes.string, + isReadOnlyMode: PropTypes.bool, + placeholder: PropTypes.string, + twoColumns: PropTypes.bool + }; + render() { + let { + title, + plusButtonTitle, + onAdd, + children, + onFilter, + className, + isReadOnlyMode, + twoColumns, + filterValue + } = this.props; + return ( +
+ + {onFilter && + (children.length || filterValue) && ( + + )} + +
+ ); + } } export default ListEditorView; diff --git a/openecomp-ui/src/nfvo-components/listEditor/listEditor.stories.js b/openecomp-ui/src/nfvo-components/listEditor/listEditor.stories.js index 81125c84ba..67258c956d 100644 --- a/openecomp-ui/src/nfvo-components/listEditor/listEditor.stories.js +++ b/openecomp-ui/src/nfvo-components/listEditor/listEditor.stories.js @@ -1,27 +1,25 @@ import React from 'react'; -import {storiesOf, action} from '@kadira/storybook'; +import { storiesOf, action } from '@kadira/storybook'; import ListEditorView from './ListEditorView.jsx'; import ListEditorItemView from './ListEditorItemView.jsx'; import ListEditorItemField from './ListEditorItemViewField.jsx'; -import {text, number} from '@kadira/storybook-addon-knobs'; -import {withKnobs} from '@kadira/storybook-addon-knobs'; +import { text, number } from '@kadira/storybook-addon-knobs'; +import { withKnobs } from '@kadira/storybook-addon-knobs'; -function makeChildren({onEdit = false, onDelete = false} = {}) { - return ( - [...Array(number('Items', 2)).keys()].map(index => ( - - -
{text('field 1', 'Lorum Ipsum')}
-
- -
{text('field 2', 'Lorum Ipsum')}
-
-
) - ) - ); +function makeChildren({ onEdit = false, onDelete = false } = {}) { + return [...Array(number('Items', 2)).keys()].map(index => ( + + +
{text('field 1', 'Lorum Ipsum')}
+
+ +
{text('field 2', 'Lorum Ipsum')}
+
+
+ )); } const stories = storiesOf('ListEditor', module); @@ -29,32 +27,49 @@ stories.addDecorator(withKnobs); stories .add('regular', () => ( - - {makeChildren()} - + {makeChildren()} )) .add('two columns', () => ( - + {makeChildren()} )) .add('with add', () => ( - - {makeChildren()} + + {makeChildren()} )) .add('with delete', () => ( - - {makeChildren({onDelete: action('onDelete')})} + + {makeChildren({ onDelete: action('onDelete') })} )) .add('with edit', () => ( - - {makeChildren({onEdit: action('onEdit')})} + + {makeChildren({ onEdit: action('onEdit') })} )) .add('with edit and delete', () => ( - - {makeChildren({onDelete: action('onDelete'), onEdit: action('onEdit')})} + + {makeChildren({ + onDelete: action('onDelete'), + onEdit: action('onEdit') + })} )); diff --git a/openecomp-ui/src/nfvo-components/loader/Loader.jsx b/openecomp-ui/src/nfvo-components/loader/Loader.jsx index 9ebe52dcfc..076351bf7a 100644 --- a/openecomp-ui/src/nfvo-components/loader/Loader.jsx +++ b/openecomp-ui/src/nfvo-components/loader/Loader.jsx @@ -16,40 +16,39 @@ import React from 'react'; import PropTypes from 'prop-types'; -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; -const mapStateToProps = ({loader}) => { - return { - isLoading: loader.isLoading - }; +const mapStateToProps = ({ loader }) => { + return { + isLoading: loader.isLoading + }; }; class Loader extends React.Component { - - static propTypes = { - isLoading: PropTypes.bool.isRequired - }; - - static defaultProps = { - isLoading: false - }; - - shouldComponentUpdate(nextProps) { - return (nextProps.isLoading !== this.props.isLoading); - } - - render() { - let {isLoading} = this.props; - return ( -
- { - isLoading &&
-
-
- } -
- ); - } + static propTypes = { + isLoading: PropTypes.bool.isRequired + }; + + static defaultProps = { + isLoading: false + }; + + shouldComponentUpdate(nextProps) { + return nextProps.isLoading !== this.props.isLoading; + } + + render() { + let { isLoading } = this.props; + return ( +
+ {isLoading && ( +
+
+
+ )} +
+ ); + } } -export default connect(mapStateToProps) (Loader); +export default connect(mapStateToProps)(Loader); diff --git a/openecomp-ui/src/nfvo-components/loader/LoaderConstants.js b/openecomp-ui/src/nfvo-components/loader/LoaderConstants.js index 2b531b08fa..e367a74352 100644 --- a/openecomp-ui/src/nfvo-components/loader/LoaderConstants.js +++ b/openecomp-ui/src/nfvo-components/loader/LoaderConstants.js @@ -16,9 +16,9 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - SHOW: null, - HIDE: null, + SHOW: null, + HIDE: null, - SEND_REQUEST: null, - RECEIVE_RESPONSE: null + SEND_REQUEST: null, + RECEIVE_RESPONSE: null }); diff --git a/openecomp-ui/src/nfvo-components/loader/LoaderReducer.js b/openecomp-ui/src/nfvo-components/loader/LoaderReducer.js index 3afdad0573..1d0f6790e1 100644 --- a/openecomp-ui/src/nfvo-components/loader/LoaderReducer.js +++ b/openecomp-ui/src/nfvo-components/loader/LoaderReducer.js @@ -13,43 +13,54 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {actionTypes} from './LoaderConstants.js'; +import { actionTypes } from './LoaderConstants.js'; -export default (state = {fetchingRequests : 0, currentlyFetching : [], isLoading : false}, action) => { - let fetchingRequests = state.fetchingRequests; - let newArray; - switch (action.type) { - case actionTypes.SEND_REQUEST: - fetchingRequests++; - newArray = state.currentlyFetching.slice(); - newArray.splice(0, 0, action.url); - if (DEBUG) { - console.log('Loader SEND REQUEST url: ' + action.url); - console.log('Loader SEND REQUEST number of fetching requests: ' + fetchingRequests); - } - return { - fetchingRequests: fetchingRequests, - currentlyFetching : newArray, - isLoading: true - }; - case actionTypes.RECEIVE_RESPONSE: - fetchingRequests--; +export default ( + state = { fetchingRequests: 0, currentlyFetching: [], isLoading: false }, + action +) => { + let fetchingRequests = state.fetchingRequests; + let newArray; + switch (action.type) { + case actionTypes.SEND_REQUEST: + fetchingRequests++; + newArray = state.currentlyFetching.slice(); + newArray.splice(0, 0, action.url); + if (DEBUG) { + console.log('Loader SEND REQUEST url: ' + action.url); + console.log( + 'Loader SEND REQUEST number of fetching requests: ' + + fetchingRequests + ); + } + return { + fetchingRequests: fetchingRequests, + currentlyFetching: newArray, + isLoading: true + }; + case actionTypes.RECEIVE_RESPONSE: + fetchingRequests--; - newArray = state.currentlyFetching.filter((item) => {return item !== action.url;}); - if (DEBUG) { - console.log('Loader RECEIVE_RESPONSE url: ' + action.url); - console.log('Loader RECEIVE_RESPONSE: number of fetching requests: ' + fetchingRequests); - } - return { - currentlyFetching : newArray, - fetchingRequests: fetchingRequests, - isLoading: (fetchingRequests !== 0) - }; - case actionTypes.SHOW: - return {isLoading: true}; - case actionTypes.HIDE: - return {isLoading: false}; - default: - return state; - } + newArray = state.currentlyFetching.filter(item => { + return item !== action.url; + }); + if (DEBUG) { + console.log('Loader RECEIVE_RESPONSE url: ' + action.url); + console.log( + 'Loader RECEIVE_RESPONSE: number of fetching requests: ' + + fetchingRequests + ); + } + return { + currentlyFetching: newArray, + fetchingRequests: fetchingRequests, + isLoading: fetchingRequests !== 0 + }; + case actionTypes.SHOW: + return { isLoading: true }; + case actionTypes.HIDE: + return { isLoading: false }; + default: + return state; + } }; diff --git a/openecomp-ui/src/nfvo-components/modal/GlobalModal.js b/openecomp-ui/src/nfvo-components/modal/GlobalModal.js index 75b7983ac3..3f19bd76a3 100644 --- a/openecomp-ui/src/nfvo-components/modal/GlobalModal.js +++ b/openecomp-ui/src/nfvo-components/modal/GlobalModal.js @@ -16,145 +16,195 @@ import React from 'react'; import PropTypes from 'prop-types'; -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import Modal from 'nfvo-components/modal/Modal.jsx'; import Button from 'sdc-ui/lib/react/Button.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {modalContentComponents} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes, typeEnum} from './GlobalModalConstants.js'; - +import { modalContentComponents } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes, typeEnum } from './GlobalModalConstants.js'; const typeClass = { - 'default': 'primary', - error: 'negative', - warning: 'warning', - success: 'positive' + default: 'primary', + error: 'negative', + warning: 'warning', + success: 'positive' }; const type2HeaderColor = { - 'default': 'primary', - error: 'danger', - warning: 'warning', - success: 'success' + default: 'primary', + error: 'danger', + warning: 'warning', + success: 'success' }; - -const ModalFooter = ({type, onConfirmed, onDeclined, onClose, confirmationButtonText, cancelButtonText}) => { - let myPropsForNoConfirmed = {}; - if (onConfirmed) { - myPropsForNoConfirmed.btnType = 'outline'; - } - return ( - -
- {onConfirmed && } - -
-
- ); +const ModalFooter = ({ + type, + onConfirmed, + onDeclined, + onClose, + confirmationButtonText, + cancelButtonText +}) => { + let myPropsForNoConfirmed = {}; + if (onConfirmed) { + myPropsForNoConfirmed.btnType = 'outline'; + } + return ( + +
+ {onConfirmed && ( + + )} + +
+
+ ); }; ModalFooter.defaultProps = { - type: 'default', - confirmationButtonText: i18n('OK'), - cancelButtonText: i18n('Cancel') + type: 'default', + confirmationButtonText: i18n('OK'), + cancelButtonText: i18n('Cancel') }; ModalFooter.PropTypes = { - type: PropTypes.string, - confirmationButtonText: PropTypes.string, - cancelButtonText: PropTypes.string + type: PropTypes.string, + confirmationButtonText: PropTypes.string, + cancelButtonText: PropTypes.string }; -export const mapStateToProps = ({modal}) => { - const show = !!modal; - return { - show, - ...modal - }; +export const mapStateToProps = ({ modal }) => { + const show = !!modal; + return { + show, + ...modal + }; }; -export const mapActionToProps = (dispatch) => { - return { - onClose: () => dispatch({type: actionTypes.GLOBAL_MODAL_CLOSE}) - }; +export const mapActionToProps = dispatch => { + return { + onClose: () => dispatch({ type: actionTypes.GLOBAL_MODAL_CLOSE }) + }; }; - -export class GlobalModalView extends React.Component { - - static propTypes = { - show: PropTypes.bool, - type: PropTypes.oneOf(['default', 'error', 'warning', 'success']), - title: PropTypes.string, - modalComponentProps: PropTypes.object, - modalComponentName: PropTypes.string, - onConfirmed: PropTypes.func, - onDeclined: PropTypes.func, - confirmationButtonText: PropTypes.string, - cancelButtonText: PropTypes.string - }; - - static defaultProps = { - show: false, - type: 'default', - title: '' - }; - - render() { - let {title, type, show, modalComponentName, modalComponentProps, - modalClassName, msg, onConfirmed, onDeclined, confirmationButtonText, cancelButtonText, onClose} = this.props; - const ComponentToRender = modalContentComponents[modalComponentName]; - return ( - - - {title} - - - {ComponentToRender ? - : - msg && typeof msg === 'string' ? -
{msg.split('\n').map((txt, i) => {txt}
)}
: - msg - } -
- {(onConfirmed || onDeclined || type !== typeEnum.DEFAULT) && - } -
- ); - } - - componentDidUpdate() { - if (this.props.timeout) { - setTimeout(this.props.onClose, this.props.timeout); - } - } -}; +export class GlobalModalView extends React.Component { + static propTypes = { + show: PropTypes.bool, + type: PropTypes.oneOf(['default', 'error', 'warning', 'success']), + title: PropTypes.string, + modalComponentProps: PropTypes.object, + modalComponentName: PropTypes.string, + onConfirmed: PropTypes.func, + onDeclined: PropTypes.func, + confirmationButtonText: PropTypes.string, + cancelButtonText: PropTypes.string + }; + + static defaultProps = { + show: false, + type: 'default', + title: '' + }; + + render() { + let { + title, + type, + show, + modalComponentName, + modalComponentProps, + modalClassName, + msg, + onConfirmed, + onDeclined, + confirmationButtonText, + cancelButtonText, + onClose + } = this.props; + const ComponentToRender = modalContentComponents[modalComponentName]; + return ( + + + {title} + + + {ComponentToRender ? ( + + ) : msg && typeof msg === 'string' ? ( +
+ {' '} + {msg.split('\n').map((txt, i) => ( + + {' '} + {txt}
{' '} +
+ ))}{' '} +
+ ) : ( + msg + )} +
+ {(onConfirmed || onDeclined || type !== typeEnum.DEFAULT) && ( + + )} +
+ ); + } + + componentDidUpdate() { + if (this.props.timeout) { + setTimeout(this.props.onClose, this.props.timeout); + } + } +} GlobalModalView.propTypes = { - show: PropTypes.bool, - type: PropTypes.oneOf(['default', 'error', 'warning', 'success']), - title: PropTypes.string, - modalComponentProps: PropTypes.object, - modalComponentName: PropTypes.string, - onConfirmed: PropTypes.func, - onDeclined: PropTypes.func, - confirmationButtonText: PropTypes.string, - cancelButtonText: PropTypes.string + show: PropTypes.bool, + type: PropTypes.oneOf(['default', 'error', 'warning', 'success']), + title: PropTypes.string, + modalComponentProps: PropTypes.object, + modalComponentName: PropTypes.string, + onConfirmed: PropTypes.func, + onDeclined: PropTypes.func, + confirmationButtonText: PropTypes.string, + cancelButtonText: PropTypes.string }; -export default connect(mapStateToProps, mapActionToProps, null, {withRef: true})(GlobalModalView); +export default connect(mapStateToProps, mapActionToProps, null, { + withRef: true +})(GlobalModalView); diff --git a/openecomp-ui/src/nfvo-components/modal/GlobalModalConstants.js b/openecomp-ui/src/nfvo-components/modal/GlobalModalConstants.js index 3e5545371a..e9c1853c97 100644 --- a/openecomp-ui/src/nfvo-components/modal/GlobalModalConstants.js +++ b/openecomp-ui/src/nfvo-components/modal/GlobalModalConstants.js @@ -16,23 +16,21 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - GLOBAL_MODAL_SHOW: null, - GLOBAL_MODAL_CLOSE: null, - GLOBAL_MODAL_ERROR: null, - GLOBAL_MODAL_WARNING: null, - GLOBAL_MODAL_SUCCESS: null, - + GLOBAL_MODAL_SHOW: null, + GLOBAL_MODAL_CLOSE: null, + GLOBAL_MODAL_ERROR: null, + GLOBAL_MODAL_WARNING: null, + GLOBAL_MODAL_SUCCESS: null }); - export const typeEnum = { - DEFAULT: 'default', - ERROR: 'error', - WARNING: 'warning', - SUCCESS: 'success' + DEFAULT: 'default', + ERROR: 'error', + WARNING: 'warning', + SUCCESS: 'success' }; -export const modalSizes = { - LARGE: 'large', - SMALL: 'small' +export const modalSizes = { + LARGE: 'large', + SMALL: 'small' }; diff --git a/openecomp-ui/src/nfvo-components/modal/GlobalModalReducer.js b/openecomp-ui/src/nfvo-components/modal/GlobalModalReducer.js index 28674ea569..b2273fa7a7 100644 --- a/openecomp-ui/src/nfvo-components/modal/GlobalModalReducer.js +++ b/openecomp-ui/src/nfvo-components/modal/GlobalModalReducer.js @@ -14,37 +14,37 @@ * permissions and limitations under the License. */ -import {actionTypes, typeEnum} from './GlobalModalConstants.js'; +import { actionTypes, typeEnum } from './GlobalModalConstants.js'; export default (state = null, action) => { - switch (action.type) { - case actionTypes.GLOBAL_MODAL_SHOW: - return { - ...action.data - }; - case actionTypes.GLOBAL_MODAL_ERROR: - return { - type: typeEnum.ERROR, - modalClassName: 'notification-modal', - ...action.data - }; - case actionTypes.GLOBAL_MODAL_WARNING: - return { - type: typeEnum.WARNING, - modalClassName: 'notification-modal', - ...action.data - }; + switch (action.type) { + case actionTypes.GLOBAL_MODAL_SHOW: + return { + ...action.data + }; + case actionTypes.GLOBAL_MODAL_ERROR: + return { + type: typeEnum.ERROR, + modalClassName: 'notification-modal', + ...action.data + }; + case actionTypes.GLOBAL_MODAL_WARNING: + return { + type: typeEnum.WARNING, + modalClassName: 'notification-modal', + ...action.data + }; - case actionTypes.GLOBAL_MODAL_SUCCESS: - return { - type: typeEnum.SUCCESS, - modalClassName: 'notification-modal', - ...action.data - }; + case actionTypes.GLOBAL_MODAL_SUCCESS: + return { + type: typeEnum.SUCCESS, + modalClassName: 'notification-modal', + ...action.data + }; - case actionTypes.GLOBAL_MODAL_CLOSE: - return null; - default: - return state; - } + case actionTypes.GLOBAL_MODAL_CLOSE: + return null; + default: + return state; + } }; diff --git a/openecomp-ui/src/nfvo-components/modal/Modal.jsx b/openecomp-ui/src/nfvo-components/modal/Modal.jsx index b0f704dba9..cfd757501f 100644 --- a/openecomp-ui/src/nfvo-components/modal/Modal.jsx +++ b/openecomp-ui/src/nfvo-components/modal/Modal.jsx @@ -20,65 +20,63 @@ import BootstrapModal from 'react-bootstrap/lib/Modal.js'; let nextModalId = 0; export default class Modal extends React.Component { + static Header = BootstrapModal.Header; - static Header = BootstrapModal.Header; + static Title = BootstrapModal.Title; - static Title = BootstrapModal.Title; + static Footer = BootstrapModal.Footer; - static Footer = BootstrapModal.Footer; + static Body = class ModalBody extends React.Component { + render() { + let { children, ...props } = this.props; + return ( + {children} + ); + } - static Body = class ModalBody extends React.Component { + componentDidMount() { + let element = ReactDOM.findDOMNode(this); + element.addEventListener('click', event => { + if (event.target.tagName === 'A') { + event.preventDefault(); + } + }); + ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType => + element.addEventListener(eventType, event => + event.stopPropagation() + ) + ); + } + }; - render() { - let {children, ...props} = this.props; - return ( - - {children} - - ); - } + componentWillMount() { + this.modalId = `dox-ui-modal-${nextModalId++}`; + } - componentDidMount() { - let element = ReactDOM.findDOMNode(this); - element.addEventListener('click', event => { - if (event.target.tagName === 'A') { - event.preventDefault(); - } - }); - ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType => - element.addEventListener(eventType, event => event.stopPropagation()) - ); - } - }; + componentDidMount() { + this.ensureRootClass(); + } - componentWillMount() { - this.modalId = `dox-ui-modal-${nextModalId++}`; - } + componentDidUpdate() { + this.ensureRootClass(); + } - componentDidMount() { - this.ensureRootClass(); - } + ensureRootClass() { + let element = document.getElementById(this.modalId); + while (element && !element.hasAttribute('data-reactroot')) { + element = element.parentElement; + } + if (element && !element.classList.contains('dox-ui')) { + element.classList.add('dox-ui'); + } + } - componentDidUpdate() { - this.ensureRootClass(); - } - - ensureRootClass() { - let element = document.getElementById(this.modalId); - while(element && !element.hasAttribute('data-reactroot')) { - element = element.parentElement; - } - if (element && !element.classList.contains('dox-ui')) { - element.classList.add('dox-ui'); - } - } - - render() { - let {children, ...props} = this.props; - return ( - - {children} - - ); - } + render() { + let { children, ...props } = this.props; + return ( + + {children} + + ); + } } diff --git a/openecomp-ui/src/nfvo-components/overlay/Overlay.jsx b/openecomp-ui/src/nfvo-components/overlay/Overlay.jsx index 054c1e2852..7ed898e593 100644 --- a/openecomp-ui/src/nfvo-components/overlay/Overlay.jsx +++ b/openecomp-ui/src/nfvo-components/overlay/Overlay.jsx @@ -18,23 +18,21 @@ import React from 'react'; import enhanceWithClickOutside from 'react-click-outside'; class Overlay extends React.Component { + handleClickOutside() { + if (this.props.onClose) { + this.props.onClose(); + } + } - handleClickOutside() { - if (this.props.onClose) { - this.props.onClose(); - } - } - - render() { - return ( -
-
-
- {this.props.children} -
- ); - } - -}; + render() { + return ( +
+
+
+ {this.props.children} +
+ ); + } +} export default enhanceWithClickOutside(Overlay); diff --git a/openecomp-ui/src/nfvo-components/panel/NavigationSideBar.jsx b/openecomp-ui/src/nfvo-components/panel/NavigationSideBar.jsx index 2eda7e69bf..61121df335 100644 --- a/openecomp-ui/src/nfvo-components/panel/NavigationSideBar.jsx +++ b/openecomp-ui/src/nfvo-components/panel/NavigationSideBar.jsx @@ -19,116 +19,159 @@ import classnames from 'classnames'; import Collapse from 'react-bootstrap/lib/Collapse.js'; class NavigationSideBar extends React.Component { - static PropTypes = { - activeItemId: PropTypes.string.isRequired, - onSelect: PropTypes.func, - onToggle: PropTypes.func, - groups: PropTypes.array, - disabled: PropTypes.bool - }; + static PropTypes = { + activeItemId: PropTypes.string.isRequired, + onSelect: PropTypes.func, + onToggle: PropTypes.func, + groups: PropTypes.array, + disabled: PropTypes.bool + }; - constructor(props) { - super(props); - this.state = { - activeItemId: null - }; - this.handleItemClicked = this.handleItemClicked.bind(this); - } + constructor(props) { + super(props); + this.state = { + activeItemId: null + }; + this.handleItemClicked = this.handleItemClicked.bind(this); + } - render() { - let {groups, activeItemId, disabled = false} = this.props; + render() { + let { groups, activeItemId, disabled = false } = this.props; - return ( -
- {groups.map(group => ( - - ))} -
- ); - } + return ( +
+ {groups.map(group => ( + + ))} +
+ ); + } - handleItemClicked(event, item) { - event.stopPropagation(); - if(this.props.onToggle) { - this.props.onToggle(this.props.groups, item.id); - } - if(item.onSelect) { - item.onSelect(); - } - if(this.props.onSelect) { - this.props.onSelect(item); - } - } + handleItemClicked(event, item) { + event.stopPropagation(); + if (this.props.onToggle) { + this.props.onToggle(this.props.groups, item.id); + } + if (item.onSelect) { + item.onSelect(); + } + if (this.props.onSelect) { + this.props.onSelect(item); + } + } } class NavigationMenu extends React.Component { - static PropTypes = { - activeItemId: PropTypes.string.isRequired, - onNavigationItemClick: PropTypes.func, - menu: PropTypes.array - }; + static PropTypes = { + activeItemId: PropTypes.string.isRequired, + onNavigationItemClick: PropTypes.func, + menu: PropTypes.array + }; - render() { - const {menu, activeItemId, onNavigationItemClick} = this.props; - return ( -
- - -
); - } + render() { + const { menu, activeItemId, onNavigationItemClick } = this.props; + return ( +
+ + +
+ ); + } } function NavigationMenuHeader(props) { - return
{props.title}
; + return ( +
+ {props.title} +
+ ); } function getItemDataTestId(itemId) { - return itemId.split('|')[0]; + return itemId.split('|')[0]; } function NavigationMenuItems(props) { - const {items, activeItemId, onNavigationItemClick} = props; - return ( -
- { - items && items.map(item => ()) - } -
- ); + const { items, activeItemId, onNavigationItemClick } = props; + return ( +
+ {items && + items.map(item => ( + + ))} +
+ ); } function NavigationMenuItem(props) { - const {onNavigationItemClick, item, activeItemId} = props; - const isGroup = item.items && item.items.length > 0; - return ( -
- - {isGroup && -
- {item.items.map(subItem => ()) } -
-
- } -
- ); + const { onNavigationItemClick, item, activeItemId } = props; + const isGroup = item.items && item.items.length > 0; + return ( +
+ + {isGroup && ( + +
+ {item.items.map(subItem => ( + + ))} +
+
+ )} +
+ ); } function NavigationLink(props) { - const {item, activeItemId, onClick} = props; - // todo should this be button - return ( -
onClick(event, item)} - data-test-id={'navbar-group-item-' + getItemDataTestId(item.id)}> - {item.name} -
- ); + const { item, activeItemId, onClick } = props; + // todo should this be button + return ( +
onClick(event, item)} + data-test-id={'navbar-group-item-' + getItemDataTestId(item.id)}> + {item.name} +
+ ); } export default NavigationSideBar; diff --git a/openecomp-ui/src/nfvo-components/panel/versionController/VersionController.jsx b/openecomp-ui/src/nfvo-components/panel/versionController/VersionController.jsx index 57fa86f561..c9c5789622 100644 --- a/openecomp-ui/src/nfvo-components/panel/versionController/VersionController.jsx +++ b/openecomp-ui/src/nfvo-components/panel/versionController/VersionController.jsx @@ -17,125 +17,224 @@ import React from 'react'; import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionsEnum} from './VersionControllerConstants.js'; +import { actionsEnum } from './VersionControllerConstants.js'; import ActionButtons from './components/ActionButtons.jsx'; import NotificationsView from 'sdc-app/onboarding/userNotifications/NotificationsView.jsx'; - class VersionController extends React.Component { - - static propTypes = { - version: PropTypes.object, - viewableVersions: PropTypes.array, - onVersionSwitching: PropTypes.func, - callVCAction: PropTypes.func, - onSave: PropTypes.func, - onClose: PropTypes.func, - isFormDataValid: PropTypes.bool, - onOpenCommentCommitModal: PropTypes.func, - isReadOnlyMode: PropTypes.bool - }; - - state = { - showPermissions: false, - showRevisions: false - }; - - render() { - let {version = {}, viewableVersions = [], onVersionSwitching, onMoreVersionsClick, callVCAction, onSave, isReadOnlyMode, itemPermission, - isFormDataValid, onClose, onManagePermissions, permissions = {}, userInfo, usersList, itemName, - onOpenCommentCommitModal, onOpenRevisionsModal, isManual, candidateInProcess, isArchived} = this.props; - return ( -
-
-
- onMoreVersionsClick({itemName, users: usersList})}/> - {isArchived &&
{i18n('Archived')}
} -
-
- this.submit(callVCAction, version) : undefined} - onRevert={callVCAction ? () => this.revert(callVCAction, version) : undefined} - onOpenRevisionsModal={onOpenRevisionsModal} - onSave={onSave ? () => onSave() : undefined} - permissions={permissions} - userInfo={userInfo} - onManagePermissions={onManagePermissions} - showPermissions={this.state.showPermissions} - onClosePermissions={()=>this.setState({showPermissions: false})} - onClickPermissions={() => this.onClickPermissions()} - onSync={callVCAction ? () => this.sync(callVCAction, version) : undefined} - onOpenCommentCommitModal={onOpenCommentCommitModal} - onCommit={callVCAction ? (comment) => this.commit(callVCAction, version, comment) : undefined} - isFormDataValid={isFormDataValid} - itemPermissions={itemPermission} - isArchived={isArchived} - isReadOnlyMode={isReadOnlyMode || candidateInProcess} - isManual={isManual} /> -
- - {onClose &&
onClose()} data-test-id='vc-cancel-btn'> X
} -
-
-
- ); - } - - onClickPermissions() { - let {onOpenPermissions, usersList} = this.props; - let {showPermissions} = this.state; - let promise = showPermissions ? Promise.resolve() : onOpenPermissions({users: usersList}); - promise.then(() => this.setState({showPermissions: !showPermissions})); - } - - - submit(callVCAction, version) { - const action = actionsEnum.SUBMIT; - callVCAction(action, version); - } - - revert(callVCAction, version) { - const action = actionsEnum.REVERT; - callVCAction(action, version); - } - - sync(callVCAction, version) { - const action = actionsEnum.SYNC; - callVCAction(action, version); - } - - commit(callVCAction, version, comment) { - const action = actionsEnum.COMMIT; - callVCAction(action, version, comment); - } - - permissions() { - - } + static propTypes = { + version: PropTypes.object, + viewableVersions: PropTypes.array, + onVersionSwitching: PropTypes.func, + callVCAction: PropTypes.func, + onSave: PropTypes.func, + onClose: PropTypes.func, + isFormDataValid: PropTypes.bool, + onOpenCommentCommitModal: PropTypes.func, + isReadOnlyMode: PropTypes.bool + }; + + state = { + showPermissions: false, + showRevisions: false + }; + + render() { + let { + version = {}, + viewableVersions = [], + onVersionSwitching, + onMoreVersionsClick, + callVCAction, + onSave, + isReadOnlyMode, + itemPermission, + isFormDataValid, + onClose, + onManagePermissions, + permissions = {}, + userInfo, + usersList, + itemName, + onOpenCommentCommitModal, + onOpenRevisionsModal, + isManual, + candidateInProcess, + isArchived + } = this.props; + return ( +
+
+
+ + onMoreVersionsClick({ + itemName, + users: usersList + }) + } + /> + {isArchived && ( +
+ {i18n('Archived')} +
+ )} +
+
+ this.submit(callVCAction, version) + : undefined + } + onRevert={ + callVCAction + ? () => this.revert(callVCAction, version) + : undefined + } + onOpenRevisionsModal={onOpenRevisionsModal} + onSave={onSave ? () => onSave() : undefined} + permissions={permissions} + userInfo={userInfo} + onManagePermissions={onManagePermissions} + showPermissions={this.state.showPermissions} + onClosePermissions={() => + this.setState({ showPermissions: false }) + } + onClickPermissions={() => this.onClickPermissions()} + onSync={ + callVCAction + ? () => this.sync(callVCAction, version) + : undefined + } + onOpenCommentCommitModal={onOpenCommentCommitModal} + onCommit={ + callVCAction + ? comment => + this.commit( + callVCAction, + version, + comment + ) + : undefined + } + isFormDataValid={isFormDataValid} + itemPermissions={itemPermission} + isArchived={isArchived} + isReadOnlyMode={ + isReadOnlyMode || candidateInProcess + } + isManual={isManual} + /> +
+ + {onClose && ( +
onClose()} + data-test-id="vc-cancel-btn"> + {' '} + X +
+ )} +
+
+
+ ); + } + + onClickPermissions() { + let { onOpenPermissions, usersList } = this.props; + let { showPermissions } = this.state; + let promise = showPermissions + ? Promise.resolve() + : onOpenPermissions({ users: usersList }); + promise.then(() => + this.setState({ showPermissions: !showPermissions }) + ); + } + + submit(callVCAction, version) { + const action = actionsEnum.SUBMIT; + callVCAction(action, version); + } + + revert(callVCAction, version) { + const action = actionsEnum.REVERT; + callVCAction(action, version); + } + + sync(callVCAction, version) { + const action = actionsEnum.SYNC; + callVCAction(action, version); + } + + commit(callVCAction, version, comment) { + const action = actionsEnum.COMMIT; + callVCAction(action, version, comment); + } + + permissions() {} } function VersionSelector(props) { - let {version = {}, onMoreVersionsClick, viewableVersions = [], onVersionSwitching} = props; - const includedVersions = viewableVersions.filter(ver => {return ver.id === version.id;}); - return (
- - {i18n('Versions Page')} -
); + let { + version = {}, + onMoreVersionsClick, + viewableVersions = [], + onVersionSwitching + } = props; + const includedVersions = viewableVersions.filter(ver => { + return ver.id === version.id; + }); + return ( +
+ + + {i18n('Versions Page')} + +
+ ); } export default VersionController; diff --git a/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerConstants.js b/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerConstants.js index ddb428a1e9..54f10c1acf 100644 --- a/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerConstants.js +++ b/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerConstants.js @@ -16,9 +16,9 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionsEnum = keyMirror({ - REVERT: 'Revert', - SYNC: 'Sync', - SUBMIT: 'Submit', - COMMIT: 'Commit', - CREATE_PACKAGE: 'Create_Package' + REVERT: 'Revert', + SYNC: 'Sync', + SUBMIT: 'Submit', + COMMIT: 'Commit', + CREATE_PACKAGE: 'Create_Package' }); diff --git a/openecomp-ui/src/nfvo-components/panel/versionController/components/ActionButtons.jsx b/openecomp-ui/src/nfvo-components/panel/versionController/components/ActionButtons.jsx index b5750817ba..4dfa117803 100644 --- a/openecomp-ui/src/nfvo-components/panel/versionController/components/ActionButtons.jsx +++ b/openecomp-ui/src/nfvo-components/panel/versionController/components/ActionButtons.jsx @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import enhanceWithClickOutside from 'react-click-outside'; import i18n from 'nfvo-utils/i18n/i18n.js'; @@ -22,88 +22,171 @@ import Overlay from 'nfvo-components/overlay/Overlay.jsx'; import Permissions from './Permissions.jsx'; class ClickOutsideWrapper extends Component { - handleClickOutside() { - this.props.onClose(); - } - render() { - return
{this.props.children}
; - } + handleClickOutside() { + this.props.onClose(); + } + render() { + return
{this.props.children}
; + } } -const EnhancedClickOutsideWrapper = enhanceWithClickOutside(ClickOutsideWrapper); +const EnhancedClickOutsideWrapper = enhanceWithClickOutside( + ClickOutsideWrapper +); -const VCButton = ({name, tooltipText, disabled, onClick, dataTestId}) => { - let onClickAction = disabled ? ()=>{} : onClick; - return ( -
-
- -
-
- ); +const VCButton = ({ name, tooltipText, disabled, onClick, dataTestId }) => { + let onClickAction = disabled ? () => {} : onClick; + return ( +
+
+ +
+
+ ); }; -const Separator = () => (
); +const Separator = () =>
; -const SubmitButton = ({onClick, disabled}) => ( -
onClick()} data-test-id='vc-submit-btn' className={`vc-submit-button ${disabled ? 'disabled' : ''}`}> - - {i18n('Submit')} -
+const SubmitButton = ({ onClick, disabled }) => ( +
onClick()} + data-test-id="vc-submit-btn" + className={`vc-submit-button ${disabled ? 'disabled' : ''}`}> + + {i18n('Submit')} +
); - -const ActionButtons = ({isReadOnlyMode, onSubmit, onRevert, onSave, isFormDataValid, onClickPermissions, onSync, onCommit, isArchived, - onOpenCommentCommitModal, showPermissions, onClosePermissions, permissions, onManagePermissions, userInfo, onOpenRevisionsModal, isManual, - itemPermissions: {isCertified, isCollaborator, isDirty, isOutOfSync, isUpToDate}}) => ( -
- - - {showPermissions && - - - - } - - {isCollaborator && !isArchived &&
- - {onSave &&
- onSave()} - name='version-controller-save' tooltipText={i18n('Save')} disabled={isReadOnlyMode || !isFormDataValid} /> - -
- } - - onOpenCommentCommitModal({onCommit, title: i18n('Commit')})} - name='version-controller-commit' tooltipText={i18n('Share')} disabled={isReadOnlyMode || !isDirty || isOutOfSync} /> - {onRevert && - - } - {onSubmit && -
- - -
- } -
} -
+const ActionButtons = ({ + isReadOnlyMode, + onSubmit, + onRevert, + onSave, + isFormDataValid, + onClickPermissions, + onSync, + onCommit, + isArchived, + onOpenCommentCommitModal, + showPermissions, + onClosePermissions, + permissions, + onManagePermissions, + userInfo, + onOpenRevisionsModal, + isManual, + itemPermissions: { + isCertified, + isCollaborator, + isDirty, + isOutOfSync, + isUpToDate + } +}) => ( +
+ + + {showPermissions && ( + + + + )} + + {isCollaborator && + !isArchived && ( +
+ + {onSave && ( +
+ onSave()} + name="version-controller-save" + tooltipText={i18n('Save')} + disabled={isReadOnlyMode || !isFormDataValid} + /> + +
+ )} + + + onOpenCommentCommitModal({ + onCommit, + title: i18n('Commit') + }) + } + name="version-controller-commit" + tooltipText={i18n('Share')} + disabled={isReadOnlyMode || !isDirty || isOutOfSync} + /> + {onRevert && ( + + )} + {onSubmit && ( +
+ + +
+ )} +
+ )} +
); ActionButtons.propTypes = { - version: PropTypes.object, - onSubmit: PropTypes.func, - onRevert: PropTypes.func, - onSave: PropTypes.func, - isLatestVersion: PropTypes.bool, - isCheckedIn: PropTypes.bool, - isCheckedOut: PropTypes.bool, - isFormDataValid: PropTypes.bool, - isReadOnlyMode: PropTypes.bool + version: PropTypes.object, + onSubmit: PropTypes.func, + onRevert: PropTypes.func, + onSave: PropTypes.func, + isLatestVersion: PropTypes.bool, + isCheckedIn: PropTypes.bool, + isCheckedOut: PropTypes.bool, + isFormDataValid: PropTypes.bool, + isReadOnlyMode: PropTypes.bool }; export default ActionButtons; diff --git a/openecomp-ui/src/nfvo-components/panel/versionController/components/CommitCommentModal.jsx b/openecomp-ui/src/nfvo-components/panel/versionController/components/CommitCommentModal.jsx index 600eaeefaa..ae0913f3a9 100644 --- a/openecomp-ui/src/nfvo-components/panel/versionController/components/CommitCommentModal.jsx +++ b/openecomp-ui/src/nfvo-components/panel/versionController/components/CommitCommentModal.jsx @@ -15,59 +15,66 @@ */ import React from 'react'; -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; 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'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import keyMirror from 'nfvo-utils/KeyMirror.js'; export const CommitModalType = keyMirror({ - COMMIT: null, - COMMIT_SUBMIT: null - + COMMIT: null, + COMMIT_SUBMIT: null }); -export const mapActionToProps = (dispatch) => { - return { - onClose: () => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }) - }; +export const mapActionToProps = dispatch => { + return { + onClose: () => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }) + }; }; class CommitCommentModal extends React.Component { + state = { + comment: '' + }; - state = { - comment: '' - }; - - render() { - const {onCommit, onClose, type} = this.props; - const [commitButtonText, descriptionText] = type === CommitModalType.COMMIT ? - [i18n('Commit'), i18n('You are about to commit your version')] : - [i18n('Commit & Submit'), i18n('You must commit your changes before the submit')]; + render() { + const { onCommit, onClose, type } = this.props; + const [commitButtonText, descriptionText] = + type === CommitModalType.COMMIT + ? [i18n('Commit'), i18n('You are about to commit your version')] + : [ + i18n('Commit & Submit'), + i18n('You must commit your changes before the submit') + ]; - return ( -
{onCommit(this.state.comment); onClose();} } - onReset={onClose} - submitButtonText={commitButtonText} - labledButtons={true} - isValid={true} - className='comment-commit-form'> -
{descriptionText}
- this.setState({comment: comment})} - label={i18n('Enter Commit Comment:')} - value={this.state.comment} - type='textarea'/> -
- ); - } + return ( +
{ + onCommit(this.state.comment); + onClose(); + }} + onReset={onClose} + submitButtonText={commitButtonText} + labledButtons={true} + isValid={true} + className="comment-commit-form"> +
{descriptionText}
+ this.setState({ comment: comment })} + label={i18n('Enter Commit Comment:')} + value={this.state.comment} + type="textarea" + /> +
+ ); + } } export default connect(null, mapActionToProps)(CommitCommentModal); diff --git a/openecomp-ui/src/nfvo-components/panel/versionController/components/Permissions.jsx b/openecomp-ui/src/nfvo-components/panel/versionController/components/Permissions.jsx index 952bd4fb58..6e0ae8187b 100644 --- a/openecomp-ui/src/nfvo-components/panel/versionController/components/Permissions.jsx +++ b/openecomp-ui/src/nfvo-components/panel/versionController/components/Permissions.jsx @@ -18,48 +18,76 @@ import React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; -const Contributor = ({name, role, id, userInfo}) => { +const Contributor = ({ name, role, id, userInfo }) => { + const selected = id === userInfo.userId ? 'selected' : ''; - const selected = id === userInfo.userId ? 'selected' : ''; - - return( -
-
-
-
- -
-
-
-
{name}
-

{role}

-
-
-
- ); + return ( +
+
+
+
+ +
+
+
+
{name}
+
+

{role}

+
+
+
+
+ ); }; -const Permissions = ({permissions: {owner, contributors}, onManagePermissions, userInfo, onClosePermissions}) => { - - return ( -
-
-

{i18n('PERMISSIONS')}

-
-
- - {contributors.map(item => item.userId !== owner.userId && )} -
-
- { - owner.userId === userInfo.userId && -
{ onClosePermissions(); onManagePermissions(); }} className='manage-permissions-btn'> - {i18n('Manage Permissions')} -
- } -
-
- ); +const Permissions = ({ + permissions: { owner, contributors }, + onManagePermissions, + userInfo, + onClosePermissions +}) => { + return ( +
+
+

+ {i18n('PERMISSIONS')} +

+
+
+ + {contributors.map( + item => + item.userId !== owner.userId && ( + + ) + )} +
+
+ {owner.userId === userInfo.userId && ( +
{ + onClosePermissions(); + onManagePermissions(); + }} + className="manage-permissions-btn"> + {i18n('Manage Permissions')} +
+ )} +
+
+ ); }; export default Permissions; diff --git a/openecomp-ui/src/nfvo-components/progressBar/ProgressBar.jsx b/openecomp-ui/src/nfvo-components/progressBar/ProgressBar.jsx index ca5cb3d765..cb10bb565e 100644 --- a/openecomp-ui/src/nfvo-components/progressBar/ProgressBar.jsx +++ b/openecomp-ui/src/nfvo-components/progressBar/ProgressBar.jsx @@ -17,22 +17,25 @@ import React from 'react'; import PropTypes from 'prop-types'; class ProgressBar extends React.Component { - static propTypes = { - label: PropTypes.string, - now: PropTypes.string.isRequired - } - render() { - let {label, now} = this.props; + static propTypes = { + label: PropTypes.string, + now: PropTypes.string.isRequired + }; + render() { + let { label, now } = this.props; - return( -
-
-
-
-
{label}
-
- ); - } + return ( +
+
+
+
+
{label}
+
+ ); + } } export default ProgressBar; diff --git a/openecomp-ui/src/nfvo-components/table/SelectActionTable.jsx b/openecomp-ui/src/nfvo-components/table/SelectActionTable.jsx index 3f8dbba53a..ee8a9dca45 100644 --- a/openecomp-ui/src/nfvo-components/table/SelectActionTable.jsx +++ b/openecomp-ui/src/nfvo-components/table/SelectActionTable.jsx @@ -5,26 +5,57 @@ import Button from 'sdc-ui/lib/react/Button.js'; import uuid from 'uuid-js'; export default class SelectActionTable extends React.Component { - - render() { - let {columns, onAdd, isReadOnlyMode, children, onAddItem, numOfIcons} = this.props; - return ( -
-
- {onAdd && onAddItem && - } - -
-
-
- {columns.map(column =>
{i18n(column)}
)} - {Array(numOfIcons).fill().map((e, i) => )} -
-
- {children} -
-
-
- ); - } + render() { + let { + columns, + onAdd, + isReadOnlyMode, + children, + onAddItem, + numOfIcons + } = this.props; + return ( +
+
+ {onAdd && + onAddItem && ( + + )} + +
+
+
+ {columns.map(column => ( +
+ {i18n(column)} +
+ ))} + {Array(numOfIcons) + .fill() + .map((e, i) => ( + + ))} +
+
{children}
+
+
+ ); + } } diff --git a/openecomp-ui/src/nfvo-components/table/SelectActionTableCell.jsx b/openecomp-ui/src/nfvo-components/table/SelectActionTableCell.jsx index 2664c8e944..20e4f2413c 100644 --- a/openecomp-ui/src/nfvo-components/table/SelectActionTableCell.jsx +++ b/openecomp-ui/src/nfvo-components/table/SelectActionTableCell.jsx @@ -1,20 +1,28 @@ import React from 'react'; import SelectInput from 'nfvo-components/input/SelectInput.jsx'; -const SelectActionTableCell = ({options, selected, disabled, onChange, clearable = true, placeholder}) => { - return ( -
- onChange(option ? option.value : null)} - clearable={clearable} - options={options} /> -
- ); +const SelectActionTableCell = ({ + options, + selected, + disabled, + onChange, + clearable = true, + placeholder +}) => { + return ( +
+ onChange(option ? option.value : null)} + clearable={clearable} + options={options} + /> +
+ ); }; export default SelectActionTableCell; diff --git a/openecomp-ui/src/nfvo-components/table/SelectActionTableRow.jsx b/openecomp-ui/src/nfvo-components/table/SelectActionTableRow.jsx index 260d39d31c..1c2c1529f2 100644 --- a/openecomp-ui/src/nfvo-components/table/SelectActionTableRow.jsx +++ b/openecomp-ui/src/nfvo-components/table/SelectActionTableRow.jsx @@ -3,38 +3,65 @@ import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; import Tooltip from 'react-bootstrap/lib/Tooltip.js'; -function tooltip (msg) { - return ( - {msg} - ); -}; +function tooltip(msg) { + return ( + + {msg} + + ); +} -const IconWithOverlay = ({overlayMsg}) => ( - - - +const IconWithOverlay = ({ overlayMsg }) => ( + + + ); -function renderErrorOrCheck({hasError, overlayMsg}) { - if (hasError === undefined) { - return ; - } +function renderErrorOrCheck({ hasError, overlayMsg }) { + if (hasError === undefined) { + return ; + } - if (hasError) { - return overlayMsg ? : ; - } + if (hasError) { + return overlayMsg ? ( + + ) : ( + + ); + } - return ; + return ; } -const SelectActionTableRow = ({children, actionIcon, onAction, showAction, hasError, hasErrorIndication, overlayMsg}) => ( -
-
- {children} -
- {onAction && } - {hasErrorIndication && renderErrorOrCheck({hasError, overlayMsg})} -
+const SelectActionTableRow = ({ + children, + actionIcon, + onAction, + showAction, + hasError, + hasErrorIndication, + overlayMsg +}) => ( +
+
+ {children} +
+ {onAction && ( + + )} + {hasErrorIndication && renderErrorOrCheck({ hasError, overlayMsg })} +
); export default SelectActionTableRow; diff --git a/openecomp-ui/src/nfvo-components/tree/Tree.jsx b/openecomp-ui/src/nfvo-components/tree/Tree.jsx index 682f3b6d50..39434fcdf1 100644 --- a/openecomp-ui/src/nfvo-components/tree/Tree.jsx +++ b/openecomp-ui/src/nfvo-components/tree/Tree.jsx @@ -1,16 +1,28 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import {select} from 'd3-selection'; -import {tree, stratify} from 'd3-hierarchy'; - +import { select } from 'd3-selection'; +import { tree, stratify } from 'd3-hierarchy'; function diagonal(d) { - - const offset = 50; - return 'M' + d.y + ',' + d.x - + 'C' + (d.parent.y + offset) + ',' + d.x - + ' ' + (d.parent.y + offset) + ',' + d.parent.x - + ' ' + d.parent.y + ',' + d.parent.x; + const offset = 50; + return ( + 'M' + + d.y + + ',' + + d.x + + 'C' + + (d.parent.y + offset) + + ',' + + d.x + + ' ' + + (d.parent.y + offset) + + ',' + + d.parent.x + + ' ' + + d.parent.y + + ',' + + d.parent.x + ); } const nodeRadius = 8; @@ -18,164 +30,226 @@ const verticalSpaceBetweenNodes = 70; const NARROW_HORIZONTAL_SPACES = 47; const WIDE_HORIZONTAL_SPACES = 65; -const stratifyFn = stratify().id(d => d.id).parentId(d => d.parent); +const stratifyFn = stratify() + .id(d => d.id) + .parentId(d => d.parent); class Tree extends Component { - - // state = { - // startingCoordinates: null, - // isDown: false - // } - - static propTypes = { - name: PropTypes.string, - width: PropTypes.number, - allowScaleWidth: PropTypes.bool, - nodes: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - parent: PropTypes.string - })), - selectedNodeId: PropTypes.string, - onNodeClick: PropTypes.func, - onRenderedBeyondWidth: PropTypes.func - }; - - static defaultProps = { - width: 500, - allowScaleWidth : true, - name: 'default-name' - }; - - render() { - let {width, name, scrollable = false} = this.props; - return ( -
- -
- ); - } - - componentDidMount() { - this.renderTree(); - } - - // handleMouseMove(e) { - // if (!this.state.isDown) { - // return; - // } - // const container = select(`.tree-view.${this.props.name}-container`); - // let coordinates = this.getCoordinates(e); - // container.property('scrollLeft' , container.property('scrollLeft') + coordinates.x - this.state.startingCoordinates.x); - // container.property('scrollTop' , container.property('scrollTop') + coordinates.y - this.state.startingCoordinates.y); - // } - - // handleMouseDown(e) { - // let startingCoordinates = this.getCoordinates(e); - // this.setState({ - // startingCoordinates, - // isDown: true - // }); - // } - - // handleMouseUp() { - // this.setState({ - // startingCorrdinates: null, - // isDown: false - // }); - // } - - // getCoordinates(e) { - // var bounds = e.target.getBoundingClientRect(); - // var x = e.clientX - bounds.left; - // var y = e.clientY - bounds.top; - // return {x, y}; - // } - - componentDidUpdate(prevProps) { - if (this.props.nodes.length !== prevProps.nodes.length || - this.props.selectedNodeId !== prevProps.selectedNodeId) { - console.log('update'); - this.renderTree(); - } - } - - renderTree() { - let {width, nodes, name, allowScaleWidth, selectedNodeId, onRenderedBeyondWidth, toWiden} = this.props; - if (nodes.length > 0) { - - let horizontalSpaceBetweenLeaves = toWiden ? WIDE_HORIZONTAL_SPACES : NARROW_HORIZONTAL_SPACES; - const treeFn = tree().nodeSize([horizontalSpaceBetweenLeaves, verticalSpaceBetweenNodes]);//.size([width - 50, height - 50]) - let root = stratifyFn(nodes).sort((a, b) => a.data.name.localeCompare(b.data.name)); - let svgHeight = verticalSpaceBetweenNodes * root.height + nodeRadius * 6; - - treeFn(root); - - let nodesXValue = root.descendants().map(node => node.x); - let maxX = Math.max(...nodesXValue); - let minX = Math.min(...nodesXValue); - - let svgTempWidth = (maxX - minX) / 30 * (horizontalSpaceBetweenLeaves); - let svgWidth = svgTempWidth < width ? (width - 5) : svgTempWidth; - const svgEL = select(`svg.${name}`); - const container = select(`.tree-view.${name}-container`); - svgEL.html(''); - svgEL.attr('height', svgHeight); - let canvasWidth = width; - if (svgTempWidth > width) { - if (allowScaleWidth) { - canvasWidth = svgTempWidth; - } - // we seems to have a margin of 25px that we can still see with text - if (((svgTempWidth - 25) > width) && onRenderedBeyondWidth !== undefined) { - onRenderedBeyondWidth(); - } - }; - svgEL.attr('width', canvasWidth); - let rootGroup = svgEL.append('g').attr('transform', `translate(${svgWidth / 2 + nodeRadius},${nodeRadius * 4}) rotate(90)`); - - // handle link - rootGroup.selectAll('.link') - .data(root.descendants().slice(1)) - .enter().append('path') - .attr('class', 'link') - .attr('d', diagonal); - - let node = rootGroup.selectAll('.node') - .data(root.descendants()) - .enter().append('g') - .attr('class', node => `node ${node.children ? ' has-children' : ' leaf'} ${node.id === selectedNodeId ? 'selectedNode' : ''} ${this.props.onNodeClick ? 'clickable' : ''}`) - .attr('transform', node => 'translate(' + node.y + ',' + node.x + ')') - .on('click', node => this.onNodeClick(node)); - - node.append('circle').attr('r', nodeRadius).attr('class', 'outer-circle'); - node.append('circle').attr('r', nodeRadius - 3).attr('class', 'inner-circle'); - - node.append('text') - .attr('y', nodeRadius / 4 + 1) - .attr('x', - nodeRadius * 1.8) - .text(node => node.data.name) - .attr('transform', 'rotate(-90)'); - - let selectedNode = selectedNodeId ? root.descendants().find(node => node.id === selectedNodeId) : null; - if (selectedNode) { - - container.property('scrollLeft', (svgWidth / 4) + (svgWidth / 4 - 100) - (selectedNode.x / 30 * horizontalSpaceBetweenLeaves)); - container.property('scrollTop', (selectedNode.y / 100 * verticalSpaceBetweenNodes)); - - } else { - container.property('scrollLeft', (svgWidth / 4) + (svgWidth / 4 - 100)); - } - } - } - - onNodeClick(node) { - if (this.props.onNodeClick) { - this.props.onNodeClick(node.data); - } - } - + // state = { + // startingCoordinates: null, + // isDown: false + // } + + static propTypes = { + name: PropTypes.string, + width: PropTypes.number, + allowScaleWidth: PropTypes.bool, + nodes: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + parent: PropTypes.string + }) + ), + selectedNodeId: PropTypes.string, + onNodeClick: PropTypes.func, + onRenderedBeyondWidth: PropTypes.func + }; + + static defaultProps = { + width: 500, + allowScaleWidth: true, + name: 'default-name' + }; + + render() { + let { width, name, scrollable = false } = this.props; + return ( +
+ +
+ ); + } + + componentDidMount() { + this.renderTree(); + } + + // handleMouseMove(e) { + // if (!this.state.isDown) { + // return; + // } + // const container = select(`.tree-view.${this.props.name}-container`); + // let coordinates = this.getCoordinates(e); + // container.property('scrollLeft' , container.property('scrollLeft') + coordinates.x - this.state.startingCoordinates.x); + // container.property('scrollTop' , container.property('scrollTop') + coordinates.y - this.state.startingCoordinates.y); + // } + + // handleMouseDown(e) { + // let startingCoordinates = this.getCoordinates(e); + // this.setState({ + // startingCoordinates, + // isDown: true + // }); + // } + + // handleMouseUp() { + // this.setState({ + // startingCorrdinates: null, + // isDown: false + // }); + // } + + // getCoordinates(e) { + // var bounds = e.target.getBoundingClientRect(); + // var x = e.clientX - bounds.left; + // var y = e.clientY - bounds.top; + // return {x, y}; + // } + + componentDidUpdate(prevProps) { + if ( + this.props.nodes.length !== prevProps.nodes.length || + this.props.selectedNodeId !== prevProps.selectedNodeId + ) { + console.log('update'); + this.renderTree(); + } + } + + renderTree() { + let { + width, + nodes, + name, + allowScaleWidth, + selectedNodeId, + onRenderedBeyondWidth, + toWiden + } = this.props; + if (nodes.length > 0) { + let horizontalSpaceBetweenLeaves = toWiden + ? WIDE_HORIZONTAL_SPACES + : NARROW_HORIZONTAL_SPACES; + const treeFn = tree().nodeSize([ + horizontalSpaceBetweenLeaves, + verticalSpaceBetweenNodes + ]); //.size([width - 50, height - 50]) + let root = stratifyFn(nodes).sort((a, b) => + a.data.name.localeCompare(b.data.name) + ); + let svgHeight = + verticalSpaceBetweenNodes * root.height + nodeRadius * 6; + + treeFn(root); + + let nodesXValue = root.descendants().map(node => node.x); + let maxX = Math.max(...nodesXValue); + let minX = Math.min(...nodesXValue); + + let svgTempWidth = + (maxX - minX) / 30 * horizontalSpaceBetweenLeaves; + let svgWidth = svgTempWidth < width ? width - 5 : svgTempWidth; + const svgEL = select(`svg.${name}`); + const container = select(`.tree-view.${name}-container`); + svgEL.html(''); + svgEL.attr('height', svgHeight); + let canvasWidth = width; + if (svgTempWidth > width) { + if (allowScaleWidth) { + canvasWidth = svgTempWidth; + } + // we seems to have a margin of 25px that we can still see with text + if ( + svgTempWidth - 25 > width && + onRenderedBeyondWidth !== undefined + ) { + onRenderedBeyondWidth(); + } + } + svgEL.attr('width', canvasWidth); + let rootGroup = svgEL + .append('g') + .attr( + 'transform', + `translate(${svgWidth / 2 + nodeRadius},${nodeRadius * + 4}) rotate(90)` + ); + + // handle link + rootGroup + .selectAll('.link') + .data(root.descendants().slice(1)) + .enter() + .append('path') + .attr('class', 'link') + .attr('d', diagonal); + + let node = rootGroup + .selectAll('.node') + .data(root.descendants()) + .enter() + .append('g') + .attr( + 'class', + node => + `node ${node.children ? ' has-children' : ' leaf'} ${ + node.id === selectedNodeId ? 'selectedNode' : '' + } ${this.props.onNodeClick ? 'clickable' : ''}` + ) + .attr( + 'transform', + node => 'translate(' + node.y + ',' + node.x + ')' + ) + .on('click', node => this.onNodeClick(node)); + + node + .append('circle') + .attr('r', nodeRadius) + .attr('class', 'outer-circle'); + node + .append('circle') + .attr('r', nodeRadius - 3) + .attr('class', 'inner-circle'); + + node + .append('text') + .attr('y', nodeRadius / 4 + 1) + .attr('x', -nodeRadius * 1.8) + .text(node => node.data.name) + .attr('transform', 'rotate(-90)'); + + let selectedNode = selectedNodeId + ? root.descendants().find(node => node.id === selectedNodeId) + : null; + if (selectedNode) { + container.property( + 'scrollLeft', + svgWidth / 4 + + (svgWidth / 4 - 100) - + selectedNode.x / 30 * horizontalSpaceBetweenLeaves + ); + container.property( + 'scrollTop', + selectedNode.y / 100 * verticalSpaceBetweenNodes + ); + } else { + container.property( + 'scrollLeft', + svgWidth / 4 + (svgWidth / 4 - 100) + ); + } + } + } + + onNodeClick(node) { + if (this.props.onNodeClick) { + this.props.onNodeClick(node.data); + } + } } export default Tree; diff --git a/openecomp-ui/src/nfvo-components/tree/Tree.stories.js b/openecomp-ui/src/nfvo-components/tree/Tree.stories.js index b29920b3ec..aca1a13402 100644 --- a/openecomp-ui/src/nfvo-components/tree/Tree.stories.js +++ b/openecomp-ui/src/nfvo-components/tree/Tree.stories.js @@ -1,119 +1,141 @@ import React from 'react'; -import {storiesOf} from '@kadira/storybook'; -import {withKnobs} from '@kadira/storybook-addon-knobs'; +import { storiesOf } from '@kadira/storybook'; +import { withKnobs } from '@kadira/storybook-addon-knobs'; import Tree from './Tree.jsx'; -import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; const stories = storiesOf('Version Tree', module); stories.addDecorator(withKnobs); const response = { - listCount: 6, - results: [ - { - 'id': '123', - 'name': '1.0', - 'description': 'string', - 'baseId': '', - 'status': 'Draft', - 'creationTime': '2017-06-08T08:55:37.831Z', - 'modificationTime': '2017-06-08T08:55:37.831Z' - }, - { - 'id': '1234', - 'name': '1.1', - 'description': 'string', - 'baseId': '123', - 'status': 'Draft', - 'creationTime': '2017-06-08T08:55:37.831Z', - 'modificationTime': '2017-06-08T08:55:37.831Z' - }, - { - 'id': '12345', - 'name': '2.0', - 'description': 'string', - 'baseId': '123', - 'status': 'Draft', - 'creationTime': '2017-06-08T08:55:37.831Z', - 'modificationTime': '2017-06-08T08:55:37.831Z' - }, - { - 'id': '123456', - 'name': '3.0', - 'description': 'string', - 'baseId': '12345', - 'status': 'Draft', - 'creationTime': '2017-06-08T08:55:37.831Z', - 'modificationTime': '2017-06-08T08:55:37.831Z' - }, - { - 'id': '1234567', - 'name': '1.2', - 'description': 'string', - 'baseId': '1234', - 'status': 'Draft', - 'creationTime': '2017-06-08T08:55:37.831Z', - 'modificationTime': '2017-06-08T08:55:37.831Z' - }, - { - 'id': '12345678', - 'name': '2.1', - 'description': 'string', - 'baseId': '12345', - 'status': 'Draft', - 'creationTime': '2017-06-08T08:55:37.831Z', - 'modificationTime': '2017-06-08T08:55:37.831Z' - }, - { - 'id': '123456789', - 'name': '4.0', - 'description': 'string', - 'baseId': '123456', - 'status': 'Draft', - 'creationTime': '2017-06-08T08:55:37.831Z', - 'modificationTime': '2017-06-08T08:55:37.831Z' - }, - { - 'id': '12345678910', - 'name': '3.1', - 'description': 'string', - 'baseId': '123456', - 'status': 'Draft', - 'creationTime': '2017-06-08T08:55:37.831Z', - 'modificationTime': '2017-06-08T08:55:37.831Z' - } - ] + listCount: 6, + results: [ + { + id: '123', + name: '1.0', + description: 'string', + baseId: '', + status: 'Draft', + creationTime: '2017-06-08T08:55:37.831Z', + modificationTime: '2017-06-08T08:55:37.831Z' + }, + { + id: '1234', + name: '1.1', + description: 'string', + baseId: '123', + status: 'Draft', + creationTime: '2017-06-08T08:55:37.831Z', + modificationTime: '2017-06-08T08:55:37.831Z' + }, + { + id: '12345', + name: '2.0', + description: 'string', + baseId: '123', + status: 'Draft', + creationTime: '2017-06-08T08:55:37.831Z', + modificationTime: '2017-06-08T08:55:37.831Z' + }, + { + id: '123456', + name: '3.0', + description: 'string', + baseId: '12345', + status: 'Draft', + creationTime: '2017-06-08T08:55:37.831Z', + modificationTime: '2017-06-08T08:55:37.831Z' + }, + { + id: '1234567', + name: '1.2', + description: 'string', + baseId: '1234', + status: 'Draft', + creationTime: '2017-06-08T08:55:37.831Z', + modificationTime: '2017-06-08T08:55:37.831Z' + }, + { + id: '12345678', + name: '2.1', + description: 'string', + baseId: '12345', + status: 'Draft', + creationTime: '2017-06-08T08:55:37.831Z', + modificationTime: '2017-06-08T08:55:37.831Z' + }, + { + id: '123456789', + name: '4.0', + description: 'string', + baseId: '123456', + status: 'Draft', + creationTime: '2017-06-08T08:55:37.831Z', + modificationTime: '2017-06-08T08:55:37.831Z' + }, + { + id: '12345678910', + name: '3.1', + description: 'string', + baseId: '123456', + status: 'Draft', + creationTime: '2017-06-08T08:55:37.831Z', + modificationTime: '2017-06-08T08:55:37.831Z' + } + ] }; -const divStyle = { width: '200px', borderStyle: 'solid', borderColor: 'black', border: '1px solid black'}; -const tree = response.results.map(item => ({id: item.id, name: item.name, parent: item.baseId})); -const nodeClickHandler = function (node) { - window.alert(node.name); +const divStyle = { + width: '200px', + borderStyle: 'solid', + borderColor: 'black', + border: '1px solid black' }; -stories.add('Classic Version Tree', () => ( -
- -
-)).add('Single Version Tree', () => ( -
- -
-)).add('Single Path Version Tree', () => ( -
- -
-)).add('Empty Tree', () => ( -
- -
-)).add('Add Tree in Version Page Frame', () => ( -
- Tree wider than frame


- {console.log('rendered beyond width')}} - allowScaleWidth={false} - onNodeClick={nodeClickHandler}/> -
-)); +const tree = response.results.map(item => ({ + id: item.id, + name: item.name, + parent: item.baseId +})); +const nodeClickHandler = function(node) { + window.alert(node.name); +}; +stories + .add('Classic Version Tree', () => ( +
+ +
+ )) + .add('Single Version Tree', () => ( +
+ +
+ )) + .add('Single Path Version Tree', () => ( +
+ +
+ )) + .add('Empty Tree', () => ( +
+ +
+ )) + .add('Add Tree in Version Page Frame', () => ( +
+ Tree wider than frame
+
+
+ { + console.log('rendered beyond width'); + }} + allowScaleWidth={false} + onNodeClick={nodeClickHandler} + /> +
+ )); diff --git a/openecomp-ui/src/nfvo-utils/DirectedGraph.js b/openecomp-ui/src/nfvo-utils/DirectedGraph.js index 197625a013..bdaf08b995 100644 --- a/openecomp-ui/src/nfvo-utils/DirectedGraph.js +++ b/openecomp-ui/src/nfvo-utils/DirectedGraph.js @@ -15,31 +15,31 @@ */ export default class Graph { - constructor() { - this.nodes = {}; - } + constructor() { + this.nodes = {}; + } - addNode(node) { - this.nodes[node] = []; - } + addNode(node) { + this.nodes[node] = []; + } - hasNode(node) { - return this.nodes.hasOwnProperty(node); - } + hasNode(node) { + return this.nodes.hasOwnProperty(node); + } - addEdge(firstNode, secondNode, payload) { - if (!this.hasNode(firstNode)) { - this.addNode(firstNode); - } + addEdge(firstNode, secondNode, payload) { + if (!this.hasNode(firstNode)) { + this.addNode(firstNode); + } - if (!this.hasNode(secondNode)) { - this.addNode(secondNode); - } + if (!this.hasNode(secondNode)) { + this.addNode(secondNode); + } - this.nodes[firstNode].push({...payload, target: secondNode}); - } + this.nodes[firstNode].push({ ...payload, target: secondNode }); + } - getEdges(node) { - return this.nodes[node]; - } -} \ No newline at end of file + getEdges(node) { + return this.nodes[node]; + } +} diff --git a/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js b/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js index 13dfb1f0ab..5c55855027 100644 --- a/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js +++ b/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js @@ -15,62 +15,71 @@ */ import store from 'sdc-app/AppStore.js'; import React from 'react'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SubmitErrorResponse from 'nfvo-components/SubmitErrorResponse.jsx'; function showVariablesInMessage(variables, msg) { - let regex; - variables.forEach((value, index) => { - value = value.replace(';', ','); - regex = new RegExp('\'\%' + (index + 1) + '\''); - msg = msg.replace(regex, value); - }); - return msg; + let regex; + variables.forEach((value, index) => { + value = value.replace(';', ','); + regex = new RegExp("'%" + (index + 1) + "'"); + msg = msg.replace(regex, value); + }); + return msg; } function parseCatalogExceptionObject(responseJSON) { - let title, msg; - if (responseJSON.requestError && responseJSON.requestError.policyException) { - title = 'Error: ' + responseJSON.requestError.policyException.messageId; - msg = responseJSON.requestError.policyException.text; - } - else if (responseJSON.requestError && responseJSON.requestError.serviceException) { - title = 'Error: ' + responseJSON.requestError.serviceException.messageId; - msg = responseJSON.requestError.serviceException.text; - let {variables} = responseJSON.requestError.serviceException; - if (variables) { - msg = showVariablesInMessage(variables, msg); - } - } - else if (responseJSON.uploadDataErrors) { - title = i18n('Error: Upload Data Error'); - msg = (); - } - else { - title = responseJSON.status; - msg = responseJSON.message; - } - return {title, msg}; + let title, msg; + if ( + responseJSON.requestError && + responseJSON.requestError.policyException + ) { + title = 'Error: ' + responseJSON.requestError.policyException.messageId; + msg = responseJSON.requestError.policyException.text; + } else if ( + responseJSON.requestError && + responseJSON.requestError.serviceException + ) { + title = + 'Error: ' + responseJSON.requestError.serviceException.messageId; + msg = responseJSON.requestError.serviceException.text; + let { variables } = responseJSON.requestError.serviceException; + if (variables) { + msg = showVariablesInMessage(variables, msg); + } + } else if (responseJSON.uploadDataErrors) { + title = i18n('Error: Upload Data Error'); + msg = ( + + ); + } else { + title = responseJSON.status; + msg = responseJSON.message; + } + return { title, msg }; } -var errorResponseHandler = (error) => { - let errorData; - if (error.data) { - errorData = parseCatalogExceptionObject(error.data); - } - else { - errorData = { - title: error.statusText, - msg: error.responseText ? error.responseText : i18n('GENERIC_ERROR'), - }; - } - store.dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - ...errorData - } - }); +var errorResponseHandler = error => { + let errorData; + if (error.data) { + errorData = parseCatalogExceptionObject(error.data); + } else { + errorData = { + title: error.statusText, + msg: error.responseText ? error.responseText : i18n('GENERIC_ERROR') + }; + } + store.dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + ...errorData + } + }); }; export default errorResponseHandler; diff --git a/openecomp-ui/src/nfvo-utils/KeyMirror.js b/openecomp-ui/src/nfvo-utils/KeyMirror.js index 220fe07430..dc351af57c 100644 --- a/openecomp-ui/src/nfvo-utils/KeyMirror.js +++ b/openecomp-ui/src/nfvo-utils/KeyMirror.js @@ -13,27 +13,26 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -var keyMirror = function (obj) { - var ret = {}; - var key; - var val; - if (!(obj instanceof Object && !Array.isArray(obj))) { - throw new Error('keyMirror(...): Argument must be an object.'); - } - for (key in obj) { - if (obj.hasOwnProperty(key)) { - val = obj[key]; - if (val instanceof Object) { - ret[key] = keyMirror(obj[key]); - } else if(val !== null && val !== undefined){ - ret[key] = val; - } - else { - ret[key] = Symbol(key); - } - } - } - return Object.freeze(ret); +var keyMirror = function(obj) { + var ret = {}; + var key; + var val; + if (!(obj instanceof Object && !Array.isArray(obj))) { + throw new Error('keyMirror(...): Argument must be an object.'); + } + for (key in obj) { + if (obj.hasOwnProperty(key)) { + val = obj[key]; + if (val instanceof Object) { + ret[key] = keyMirror(obj[key]); + } else if (val !== null && val !== undefined) { + ret[key] = val; + } else { + ret[key] = Symbol(key); + } + } + } + return Object.freeze(ret); }; -export default keyMirror; \ No newline at end of file +export default keyMirror; diff --git a/openecomp-ui/src/nfvo-utils/RestAPIUtil.js b/openecomp-ui/src/nfvo-utils/RestAPIUtil.js index 5b07986390..1a5817de66 100644 --- a/openecomp-ui/src/nfvo-utils/RestAPIUtil.js +++ b/openecomp-ui/src/nfvo-utils/RestAPIUtil.js @@ -18,7 +18,7 @@ import md5 from 'md5'; import axios from 'axios'; import store from 'sdc-app/AppStore.js'; -import {actionTypes as LoaderConstants} from 'nfvo-components/loader/LoaderConstants.js'; +import { actionTypes as LoaderConstants } from 'nfvo-components/loader/LoaderConstants.js'; import Configuration from 'sdc-app/config/Configuration.js'; import errorResponseHandler from './ErrorResponseHandler.js'; @@ -39,124 +39,133 @@ const STORAGE_AUTH_KEY = 'sdc-auth-token'; const REQUEST_ID_HEADER = 'X-ECOMP-RequestID'; const CONTENT_MD5_HEADER = 'Content-MD5'; - function applySecurity(options, data) { - let headers = options.headers || (options.headers = {}); - - let authToken = localStorage.getItem(STORAGE_AUTH_KEY); - if (authToken) { - headers[AUTHORIZATION_HEADER] = authToken; - } - - let catalogApiHeaders = Configuration.get('CatalogApiHeaders'), - catalogUidHeader = catalogApiHeaders && catalogApiHeaders.userId; - if (catalogUidHeader) { - headers[catalogUidHeader.name] = catalogUidHeader.value; - } - - headers[REQUEST_ID_HEADER] = uuid.create().toString(); - if (options.md5) { - let headers = options.headers; - headers[CONTENT_MD5_HEADER] = window.btoa(md5(JSON.stringify(data)).toLowerCase()); - } + let headers = options.headers || (options.headers = {}); + + let authToken = localStorage.getItem(STORAGE_AUTH_KEY); + if (authToken) { + headers[AUTHORIZATION_HEADER] = authToken; + } + + let catalogApiHeaders = Configuration.get('CatalogApiHeaders'), + catalogUidHeader = catalogApiHeaders && catalogApiHeaders.userId; + if (catalogUidHeader) { + headers[catalogUidHeader.name] = catalogUidHeader.value; + } + + headers[REQUEST_ID_HEADER] = uuid.create().toString(); + if (options.md5) { + let headers = options.headers; + headers[CONTENT_MD5_HEADER] = window.btoa( + md5(JSON.stringify(data)).toLowerCase() + ); + } } - function handleSuccess(responseHeaders, requestHeaders) { - let authToken = responseHeaders[AUTHORIZATION_HEADER]; - let prevToken = requestHeaders && requestHeaders[AUTHORIZATION_HEADER]; - if (authToken && authToken !== prevToken) { - if (authToken === 'null') { - localStorage.removeItem(STORAGE_AUTH_KEY); - } else { - localStorage.setItem(STORAGE_AUTH_KEY, authToken); - } - } + let authToken = responseHeaders[AUTHORIZATION_HEADER]; + let prevToken = requestHeaders && requestHeaders[AUTHORIZATION_HEADER]; + if (authToken && authToken !== prevToken) { + if (authToken === 'null') { + localStorage.removeItem(STORAGE_AUTH_KEY); + } else { + localStorage.setItem(STORAGE_AUTH_KEY, authToken); + } + } } -class RestAPIUtil { - handleRequest(url, type, options = {}, data){ - if (DEBUG) { - console.log('axios --> Making REST call (' + type + '): ' + url); - } - - applySecurity(options, data); - - // TODO see ig necessary or in transformrequest funtion - if (type === POST || type === PUT) { - if (data instanceof FormData) { - options.headers.contentType = MULTIPART_FORM_DATA; - } - else { - options.headers.contentType = APPLICATION_JSON; -// config.data = JSON.stringify(data); - } - - } else { - data = null; - } - - let config = { - method: type, - url: url, - headers : options.headers, - data : data - }; - - store.dispatch({type: LoaderConstants.SEND_REQUEST, url: url}); - if (options.dataType === BINARY) { - config.responseType = 'arraybuffer'; - return axios(config). - then(result => { - store.dispatch({type: LoaderConstants.RECEIVE_RESPONSE, url : result.config.url}); - return ({ - blob : new Blob([result.data] ), - headers : result.headers - }); - }).catch(error => { - store.dispatch({type: LoaderConstants.RECEIVE_RESPONSE, url : error.config.url}); - errorResponseHandler(error.response); }); - } else { - return axios(config). - then(result => { - store.dispatch({type: LoaderConstants.RECEIVE_RESPONSE, url : result.config.url}); - handleSuccess(result.headers, result.config.headers); - return result.data; - }).catch(error => { - store.dispatch({type: LoaderConstants.RECEIVE_RESPONSE, url : error.config.url}); - errorResponseHandler(error.response); - return Promise.reject({responseJSON: error.response.data}); - }); - } - - } - - fetch(url, options) { - return this.handleRequest(url, GET, options); - } - - get(url, options) { - return this.fetch(url, options); - } - - post(url, data, options) { - return this.handleRequest(url, POST, options, data); - } - - put(url, data, options) { - return this.handleRequest(url, PUT, options, data); - } - - destroy(url, options) { - return this.handleRequest(url, DELETE, options); - } - - - +class RestAPIUtil { + handleRequest(url, type, options = {}, data) { + if (DEBUG) { + console.log('axios --> Making REST call (' + type + '): ' + url); + } + + applySecurity(options, data); + + // TODO see ig necessary or in transformrequest funtion + if (type === POST || type === PUT) { + if (data instanceof FormData) { + options.headers.contentType = MULTIPART_FORM_DATA; + } else { + options.headers.contentType = APPLICATION_JSON; + // config.data = JSON.stringify(data); + } + } else { + data = null; + } + + let config = { + method: type, + url: url, + headers: options.headers, + data: data + }; + + store.dispatch({ type: LoaderConstants.SEND_REQUEST, url: url }); + if (options.dataType === BINARY) { + config.responseType = 'arraybuffer'; + return axios(config) + .then(result => { + store.dispatch({ + type: LoaderConstants.RECEIVE_RESPONSE, + url: result.config.url + }); + return { + blob: new Blob([result.data]), + headers: result.headers + }; + }) + .catch(error => { + store.dispatch({ + type: LoaderConstants.RECEIVE_RESPONSE, + url: error.config.url + }); + errorResponseHandler(error.response); + }); + } else { + return axios(config) + .then(result => { + store.dispatch({ + type: LoaderConstants.RECEIVE_RESPONSE, + url: result.config.url + }); + handleSuccess(result.headers, result.config.headers); + return result.data; + }) + .catch(error => { + store.dispatch({ + type: LoaderConstants.RECEIVE_RESPONSE, + url: error.config.url + }); + errorResponseHandler(error.response); + return Promise.reject({ + responseJSON: error.response.data + }); + }); + } + } + + fetch(url, options) { + return this.handleRequest(url, GET, options); + } + + get(url, options) { + return this.fetch(url, options); + } + + post(url, data, options) { + return this.handleRequest(url, POST, options, data); + } + + put(url, data, options) { + return this.handleRequest(url, PUT, options, data); + } + + destroy(url, options) { + return this.handleRequest(url, DELETE, options); + } } const instance = new RestAPIUtil(); - - export default instance; diff --git a/openecomp-ui/src/nfvo-utils/ShowFileSaveDialog.js b/openecomp-ui/src/nfvo-utils/ShowFileSaveDialog.js index bddd49c700..990701c6f0 100644 --- a/openecomp-ui/src/nfvo-utils/ShowFileSaveDialog.js +++ b/openecomp-ui/src/nfvo-utils/ShowFileSaveDialog.js @@ -15,35 +15,48 @@ */ function getTimestampString() { - let date = new Date(); - let z = n => n < 10 ? '0' + n : n; - return `${date.getFullYear()}-${z(date.getMonth())}-${z(date.getDate())}_${z(date.getHours())}-${z(date.getMinutes())}`; + let date = new Date(); + let z = n => (n < 10 ? '0' + n : n); + return `${date.getFullYear()}-${z(date.getMonth())}-${z( + date.getDate() + )}_${z(date.getHours())}-${z(date.getMinutes())}`; } +export default function showFileSaveDialog({ + blob, + headers, + defaultFilename, + addTimestamp +}) { + let filename; + let contentDisposition = headers['content-disposition'] + ? headers['content-disposition'] + : ''; + let match = contentDisposition + ? contentDisposition.match(/filename=(.*?)(;|$)/) + : false; + if (match) { + filename = match[1]; + } else { + filename = defaultFilename; + } -export default function showFileSaveDialog({blob, headers, defaultFilename, addTimestamp}) { - let filename; - let contentDisposition = headers['content-disposition'] ? headers['content-disposition'] : ''; - let match = contentDisposition ? contentDisposition.match(/filename=(.*?)(;|$)/) : false; - if (match) { - filename = match[1]; - } else { - filename = defaultFilename; - } + if (addTimestamp) { + filename = filename.replace( + /(^.*?)\.([^.]+$)/, + `$1_${getTimestampString()}.$2` + ); + } - if (addTimestamp) { - filename = filename.replace(/(^.*?)\.([^.]+$)/, `$1_${getTimestampString()}.$2`); - } - - let link = document.createElement('a'); - let url = URL.createObjectURL(blob); - link.href = url; - link.download = filename; - link.style.display = 'none'; - document.body.appendChild(link); - link.click(); - setTimeout(function(){ - document.body.removeChild(link); - URL.revokeObjectURL(url); - }, 0); -}; + let link = document.createElement('a'); + let url = URL.createObjectURL(blob); + link.href = url; + link.download = filename; + link.style.display = 'none'; + document.body.appendChild(link); + link.click(); + setTimeout(function() { + document.body.removeChild(link); + URL.revokeObjectURL(url); + }, 0); +} diff --git a/openecomp-ui/src/nfvo-utils/UUID.js b/openecomp-ui/src/nfvo-utils/UUID.js index e1d4c54b1f..37de994201 100644 --- a/openecomp-ui/src/nfvo-utils/UUID.js +++ b/openecomp-ui/src/nfvo-utils/UUID.js @@ -15,39 +15,39 @@ */ import UUID from 'uuid-js'; -let toCustomUUID = (uuid) => { - return 'U' + uuid.replace(/-/g, ''); +let toCustomUUID = uuid => { + return 'U' + uuid.replace(/-/g, ''); }; let getUUID = function(num, isSync) { - if (isSync) { - let uuid; - if (!num) { - uuid = toCustomUUID(UUID.create().toString()); - } else { - uuid = []; - for (var i = 0; i < num; i++) { - uuid[i] = toCustomUUID(UUID.create().toString()); - } - } - if (num === 1) { - return uuid[0]; - } else { - return uuid; - } - } - return new Promise(resolve => { - let uuid; - if (!num) { - uuid = toCustomUUID(UUID.create().toString()); - } else { - uuid = []; - for (var i = 0; i < num; i++) { - uuid[i] = toCustomUUID(UUID.create().toString()); - } - } - setTimeout(() => resolve(uuid), 100); - }); + if (isSync) { + let uuid; + if (!num) { + uuid = toCustomUUID(UUID.create().toString()); + } else { + uuid = []; + for (var i = 0; i < num; i++) { + uuid[i] = toCustomUUID(UUID.create().toString()); + } + } + if (num === 1) { + return uuid[0]; + } else { + return uuid; + } + } + return new Promise(resolve => { + let uuid; + if (!num) { + uuid = toCustomUUID(UUID.create().toString()); + } else { + uuid = []; + for (var i = 0; i < num; i++) { + uuid[i] = toCustomUUID(UUID.create().toString()); + } + } + setTimeout(() => resolve(uuid), 100); + }); }; export default getUUID; diff --git a/openecomp-ui/src/nfvo-utils/Validator.js b/openecomp-ui/src/nfvo-utils/Validator.js index 0cb1943d66..324198ef2e 100644 --- a/openecomp-ui/src/nfvo-utils/Validator.js +++ b/openecomp-ui/src/nfvo-utils/Validator.js @@ -18,119 +18,189 @@ import * as ValidatorJS from 'validator'; import i18n from 'nfvo-utils/i18n/i18n.js'; class Validator { - static get globalValidationFunctions() { - return { - required: value => { - return typeof value === 'string' ? value.replace(/\s+/g, '') !== '' : value !== ''; - }, - requiredChooseOption: value => value !== '', - maxLength: (value, length) => ValidatorJS.isLength(value, {max: length}), - minLength: (value, length) => ValidatorJS.isLength(value, {min: length}), - pattern: (value, pattern) => ValidatorJS.matches(value, pattern), - numeric: value => { - if (value === '') { - // to allow empty value which is not zero - return true; - } - return ValidatorJS.isNumeric(value); - }, - maximum: (value, maxValue) => {return (value === undefined) ? true : (value <= maxValue);}, - minimum: (value, minValue) => {return (value === undefined) ? true : (value >= minValue);}, - maximumExclusive: (value, maxValue) => {return (value === undefined) ? true : (value < maxValue);}, - minimumExclusive: (value, minValue) => {return (value === undefined) ? true : (value > minValue);}, - alphanumeric: value => ValidatorJS.isAlphanumeric(value), - alphanumericWithSpaces: value => ValidatorJS.isAlphanumeric(value.replace(/ /g, '')), - validateName: value => ValidatorJS.isAlphanumeric(value.replace(/\s|\.|\_|\-/g, ''), 'en-US'), - validateVendorName: value => ValidatorJS.isAlphanumeric(value.replace(/[\x7F-\xFF]|\s/g, ''), 'en-US'), - freeEnglishText: value => ValidatorJS.isAlphanumeric(value.replace(/\s|\.|\_|\-|\,|\(|\)|\?/g, ''), 'en-US'), - email: value => ValidatorJS.isEmail(value), - ip: value => ValidatorJS.isIP(value), - url: value => ValidatorJS.isURL(value), - alphanumericWithUnderscores: value => ValidatorJS.isAlphanumeric(value.replace(/_/g, '')), - requiredChoiceWithOther: (value, otherValue) => { - let chosen = value.choice; - // if we have an empty multiple select we have a problem since it's required - let validationFunc = this.globalValidationFunctions['required']; - if (value.choices) { - if (value.choices.length === 0) { - return false; - } else { - // continuing validation with the first chosen value in case we have the 'Other' field - chosen = value.choices[0]; - } - } - if (chosen !== otherValue) { - return validationFunc(chosen, true); - } else { // when 'Other' was chosen, validate other value - return validationFunc(value.other, true); - } - } - }; - } + static get globalValidationFunctions() { + return { + required: value => { + return typeof value === 'string' + ? value.replace(/\s+/g, '') !== '' + : value !== ''; + }, + requiredChooseOption: value => value !== '', + maxLength: (value, length) => + ValidatorJS.isLength(value, { max: length }), + minLength: (value, length) => + ValidatorJS.isLength(value, { min: length }), + pattern: (value, pattern) => ValidatorJS.matches(value, pattern), + numeric: value => { + if (value === '') { + // to allow empty value which is not zero + return true; + } + return ValidatorJS.isNumeric(value); + }, + maximum: (value, maxValue) => { + return value === undefined ? true : value <= maxValue; + }, + minimum: (value, minValue) => { + return value === undefined ? true : value >= minValue; + }, + maximumExclusive: (value, maxValue) => { + return value === undefined ? true : value < maxValue; + }, + minimumExclusive: (value, minValue) => { + return value === undefined ? true : value > minValue; + }, + alphanumeric: value => ValidatorJS.isAlphanumeric(value), + alphanumericWithSpaces: value => + ValidatorJS.isAlphanumeric(value.replace(/ /g, '')), + validateName: value => + ValidatorJS.isAlphanumeric( + value.replace(/\s|\.|\_|\-/g, ''), + 'en-US' + ), + validateVendorName: value => + ValidatorJS.isAlphanumeric( + value.replace(/[\x7F-\xFF]|\s/g, ''), + 'en-US' + ), + freeEnglishText: value => + ValidatorJS.isAlphanumeric( + value.replace(/\s|\.|\_|\-|\,|\(|\)|\?/g, ''), + 'en-US' + ), + email: value => ValidatorJS.isEmail(value), + ip: value => ValidatorJS.isIP(value), + url: value => ValidatorJS.isURL(value), + alphanumericWithUnderscores: value => + ValidatorJS.isAlphanumeric(value.replace(/_/g, '')), + requiredChoiceWithOther: (value, otherValue) => { + let chosen = value.choice; + // if we have an empty multiple select we have a problem since it's required + let validationFunc = this.globalValidationFunctions['required']; + if (value.choices) { + if (value.choices.length === 0) { + return false; + } else { + // continuing validation with the first chosen value in case we have the 'Other' field + chosen = value.choices[0]; + } + } + if (chosen !== otherValue) { + return validationFunc(chosen, true); + } else { + // when 'Other' was chosen, validate other value + return validationFunc(value.other, true); + } + } + }; + } - static get globalValidationMessagingFunctions() { - return { - required: () => i18n('Field is required'), - requiredChooseOption: () => i18n('Field should have one of these options'), - requiredChoiceWithOther: () => i18n('Field is required'), - maxLength: (value, maxLength) => i18n('Field value has exceeded it\'s limit, {maxLength}. current length: {length}', { - length: value.length, - maxLength - }), - minLength: (value, minLength) => i18n('Field value should contain at least {minLength} characters.', {minLength: minLength}), - pattern: (value, pattern) => i18n('Field value should match the pattern: {pattern}.', {pattern: pattern}), - numeric: () => i18n('Field value should contain numbers only.'), - maximum: (value, maxValue) => i18n('Field value should be less or equal to: {maxValue}.', {maxValue: maxValue}), - minimum: (value, minValue) => i18n('Field value should be at least: {minValue}.', {minValue: minValue.toString()}), - maximumExclusive: (value, maxValue) => i18n('Field value should be less than: {maxValue}.', {maxValue: maxValue}), - minimumExclusive: (value, minValue) => i18n('Field value should be more than: {minValue}.', {minValue: minValue.toString()}), - alphanumeric: () => i18n('Field value should contain letters or digits only.'), - alphanumericWithSpaces: () => i18n('Field value should contain letters, digits or spaces only.'), - validateName: ()=> i18n('Field value should contain English letters, digits , spaces, underscores, dashes and dots only.'), - validateVendorName: ()=> i18n('Field value should contain English letters digits and spaces only.'), - freeEnglishText: ()=> i18n('Field value should contain English letters, digits , spaces, underscores, dashes and dots only.'), - email: () => i18n('Field value should be a valid email address.'), - ip: () => i18n('Field value should be a valid ip address.'), - url: () => i18n('Field value should be a valid url address.'), - general: () => i18n('Field value is invalid.'), - alphanumericWithUnderscores: () => i18n('Field value should contain letters, digits or _ only.') - }; - } + static get globalValidationMessagingFunctions() { + return { + required: () => i18n('Field is required'), + requiredChooseOption: () => + i18n('Field should have one of these options'), + requiredChoiceWithOther: () => i18n('Field is required'), + maxLength: (value, maxLength) => + i18n( + "Field value has exceeded it's limit, {maxLength}. current length: {length}", + { + length: value.length, + maxLength + } + ), + minLength: (value, minLength) => + i18n( + 'Field value should contain at least {minLength} characters.', + { + minLength: minLength + } + ), + pattern: (value, pattern) => + i18n('Field value should match the pattern: {pattern}.', { + pattern: pattern + }), + numeric: () => i18n('Field value should contain numbers only.'), + maximum: (value, maxValue) => + i18n('Field value should be less or equal to: {maxValue}.', { + maxValue: maxValue + }), + minimum: (value, minValue) => + i18n('Field value should be at least: {minValue}.', { + minValue: minValue.toString() + }), + maximumExclusive: (value, maxValue) => + i18n('Field value should be less than: {maxValue}.', { + maxValue: maxValue + }), + minimumExclusive: (value, minValue) => + i18n('Field value should be more than: {minValue}.', { + minValue: minValue.toString() + }), + alphanumeric: () => + i18n('Field value should contain letters or digits only.'), + alphanumericWithSpaces: () => + i18n( + 'Field value should contain letters, digits or spaces only.' + ), + validateName: () => + i18n( + 'Field value should contain English letters, digits , spaces, underscores, dashes and dots only.' + ), + validateVendorName: () => + i18n( + 'Field value should contain English letters digits and spaces only.' + ), + freeEnglishText: () => + i18n( + 'Field value should contain English letters, digits , spaces, underscores, dashes and dots only.' + ), + email: () => i18n('Field value should be a valid email address.'), + ip: () => i18n('Field value should be a valid ip address.'), + url: () => i18n('Field value should be a valid url address.'), + general: () => i18n('Field value is invalid.'), + alphanumericWithUnderscores: () => + i18n('Field value should contain letters, digits or _ only.') + }; + } - static validateItem(value, data, type) { - let validationFunc = this.globalValidationFunctions[type]; - const isValid = validationFunc(value, data); - let errorText = ''; - if (!isValid) { - errorText = this.globalValidationMessagingFunctions[type](value, data); - } - return { - isValid, - errorText - }; - } + static validateItem(value, data, type) { + let validationFunc = this.globalValidationFunctions[type]; + const isValid = validationFunc(value, data); + let errorText = ''; + if (!isValid) { + errorText = this.globalValidationMessagingFunctions[type]( + value, + data + ); + } + return { + isValid, + errorText + }; + } - static validate(fieldName, value, validations, state, customValidations) { - let result = { isValid: true, errorText: '' }; - for (let validation of validations) { - result = this.validateItem(value, validation.data, validation.type); - if (!result.isValid) { - return result; - } - } - if (customValidations) { - let validationFunc = customValidations[fieldName]; - if (validationFunc) { - result = validationFunc(value, state); - } - } - return result; - } + static validate(fieldName, value, validations, state, customValidations) { + let result = { isValid: true, errorText: '' }; + for (let validation of validations) { + result = this.validateItem(value, validation.data, validation.type); + if (!result.isValid) { + return result; + } + } + if (customValidations) { + let validationFunc = customValidations[fieldName]; + if (validationFunc) { + result = validationFunc(value, state); + } + } + return result; + } - static isItemNameAlreadyExistsInList({itemId, itemName, list}) { - itemName = itemName.toLowerCase(); - return list[itemName] && list[itemName] !== itemId; - } + static isItemNameAlreadyExistsInList({ itemId, itemName, list }) { + itemName = itemName.toLowerCase(); + return list[itemName] && list[itemName] !== itemId; + } } export default Validator; diff --git a/openecomp-ui/src/nfvo-utils/WebSocketUtil.js b/openecomp-ui/src/nfvo-utils/WebSocketUtil.js index c9dd10f1af..69f44d4da5 100644 --- a/openecomp-ui/src/nfvo-utils/WebSocketUtil.js +++ b/openecomp-ui/src/nfvo-utils/WebSocketUtil.js @@ -16,41 +16,50 @@ import store from 'sdc-app/AppStore.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from 'sdc-app/onboarding/userNotifications/UserNotificationsConstants.js'; +import { actionTypes } from 'sdc-app/onboarding/userNotifications/UserNotificationsConstants.js'; - -export const websocketUrl = 'ws://' + window.location.hostname + ':' + Configuration.get('websocketPort') - + '/' + Configuration.get('websocketPath'); +export const websocketUrl = + 'ws://' + + window.location.hostname + + ':' + + Configuration.get('websocketPort') + + '/' + + Configuration.get('websocketPath'); /*** * Websocket is treated like a singleton. only need one for the application. */ var websocket; - export default { + open(url, { lastScanned }) { + if ( + websocket === undefined || + websocket.readyState === websocket.CLOSED + ) { + websocket = new WebSocket( + `${url}?LAST_DELIVERED_EVENT_ID=${lastScanned}` + ); + websocket.onmessage = event => + store.dispatch({ + type: actionTypes.NOTIFICATION, + data: JSON.parse(event.data) + }); + websocket.onclose = event => { + if (event.code && event.code === 1001) { + // - Idle Timeout + const { lastScanned } = store.getState().notifications; + console.log('Reconnecting to Websocket'); + this.open(websocketUrl, { lastScanned }); + } + }; + websocket.onerror = event => console.log(event); + } + }, - open(url, {lastScanned}) { - if (websocket === undefined || websocket.readyState === websocket.CLOSED) { - websocket = new WebSocket(`${url}?LAST_DELIVERED_EVENT_ID=${lastScanned}`); - websocket.onmessage = event => store.dispatch({ - type: actionTypes.NOTIFICATION, - data: JSON.parse(event.data) - }); - websocket.onclose = event => { - if(event.code && event.code === 1001) { // - Idle Timeout - const {lastScanned} = store.getState().notifications; - console.log('Reconnecting to Websocket'); - this.open(websocketUrl, {lastScanned}); - } - }; - websocket.onerror = event => console.log(event); - } - }, - - close() { - if (websocket !== undefined) { - websocket.close(); - } - } + close() { + if (websocket !== undefined) { + websocket.close(); + } + } }; diff --git a/openecomp-ui/src/nfvo-utils/getValue.js b/openecomp-ui/src/nfvo-utils/getValue.js index 5ab0c76d73..0cac3cd726 100644 --- a/openecomp-ui/src/nfvo-utils/getValue.js +++ b/openecomp-ui/src/nfvo-utils/getValue.js @@ -13,38 +13,50 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx'; function getValueFromObject(element) { - return element.choices && element.choices.length > 0 && element.choices[0] !== '' && element.choices[0] !== optionInputOther.OTHER || - element.other && element.choices[0] === optionInputOther.OTHER ? - element : undefined; + return (element.choices && + element.choices.length > 0 && + element.choices[0] !== '' && + element.choices[0] !== optionInputOther.OTHER) || + (element.other && element.choices[0] === optionInputOther.OTHER) + ? element + : undefined; } function getValueFromVariable(variable) { - return variable ? variable : undefined; + return variable ? variable : undefined; } function getArrayData(variable) { - return variable.length ? variable : undefined; + return variable.length ? variable : undefined; } - let getValue = element => { - return typeof element === 'object' ? - element instanceof Array ? getArrayData(element) : getValueFromObject(element) : - getValueFromVariable(element); - }; +let getValue = element => { + return typeof element === 'object' + ? element instanceof Array + ? getArrayData(element) + : getValueFromObject(element) + : getValueFromVariable(element); +}; export function getStrValue(choiceObject) { - if (!choiceObject) { - return undefined; - } - if (choiceObject.choice && choiceObject.choice !== '' && choiceObject.choice !== optionInputOther.OTHER) { - return choiceObject.choice; - } - else if (choiceObject.other && choiceObject.choice === optionInputOther.OTHER) { - return choiceObject.other; - } + if (!choiceObject) { + return undefined; + } + if ( + choiceObject.choice && + choiceObject.choice !== '' && + choiceObject.choice !== optionInputOther.OTHER + ) { + return choiceObject.choice; + } else if ( + choiceObject.other && + choiceObject.choice === optionInputOther.OTHER + ) { + return choiceObject.other; + } } - export default getValue; +export default getValue; diff --git a/openecomp-ui/src/nfvo-utils/i18n/i18n.js b/openecomp-ui/src/nfvo-utils/i18n/i18n.js index ef97b8bab4..43a183def4 100644 --- a/openecomp-ui/src/nfvo-utils/i18n/i18n.js +++ b/openecomp-ui/src/nfvo-utils/i18n/i18n.js @@ -22,88 +22,94 @@ import i18nJson from 'i18nJson'; Intl libs are using out dated transpailer from ecmascript6. * TODO: As soon as they fix it, remove this assignments!!! * */ -var Intl = window.Intl || IntlObj.default, - IntlMessageFormat = IntlMessageFormatObj.default, - IntlRelativeFormat = IntlRelativeFormatObj.default, - createFormatCache = createFormatCacheObj.default; +var Intl = window.Intl || IntlObj.default, + IntlMessageFormat = IntlMessageFormatObj.default, + IntlRelativeFormat = IntlRelativeFormatObj.default, + createFormatCache = createFormatCacheObj.default; /*extract locale*/ var _locale = window.localStorage && localStorage.getItem('user_locale'); -if(!_locale) { - if(window.navigator) { - _locale = navigator.language || navigator.userLanguage; +if (!_locale) { + if (window.navigator) { + _locale = navigator.language || navigator.userLanguage; - //For now removing the dashes from the language. - let indexOfDash = _locale.indexOf('-'); - if(-1 !== indexOfDash) { - _locale = _locale.substr(0, indexOfDash); - } - } - if(!_locale) { - _locale = 'en'; - } + //For now removing the dashes from the language. + let indexOfDash = _locale.indexOf('-'); + if (-1 !== indexOfDash) { + _locale = _locale.substr(0, indexOfDash); + } + } + if (!_locale) { + _locale = 'en'; + } } var _localeUpper = _locale.toUpperCase(); var i18n = { + _locale: _locale, + _localeUpper: _localeUpper, + _i18nData: i18nJson || {}, - _locale: _locale, - _localeUpper: _localeUpper, - _i18nData: i18nJson || {}, + number(num) { + return createFormatCache(Intl.NumberFormat)(this._locale).format(num); + }, - number(num) { - return createFormatCache(Intl.NumberFormat)(this._locale).format(num); - }, + date(date, options, relativeDates) { + if (undefined === relativeDates || relativeDates) { + return this.dateRelative(date, options); + } else { + return this.dateNormal(date, options); + } + }, - date(date, options, relativeDates) { - if (undefined === relativeDates || relativeDates) { - return this.dateRelative(date, options); - } else { - return this.dateNormal(date, options); - } - }, - - dateNormal(date, options) { - return createFormatCache(Intl.DateTimeFormat)(this._locale, options).format(date); - }, - - dateRelative(date, options) { - return createFormatCache(IntlRelativeFormat)(this._locale, options).format(date); - }, - message(messageId, options) { - let messageTxt = null; - if (i18nJson && i18nJson[messageId]) { - messageTxt = i18nJson[messageId]; - } else { - messageTxt = String(messageId); - } - return createFormatCache(IntlMessageFormat)(messageTxt, this._locale).format(options); - - }, - getLocale() { - return this._locale; - }, - getLocaleUpper() { - return this._localeUpper; - }, - setLocale(locale) { - localStorage.setItem('user_locale', locale); - window.location.reload(); - } + dateNormal(date, options) { + return createFormatCache(Intl.DateTimeFormat)( + this._locale, + options + ).format(date); + }, + dateRelative(date, options) { + return createFormatCache(IntlRelativeFormat)( + this._locale, + options + ).format(date); + }, + message(messageId, options) { + let messageTxt = null; + if (i18nJson && i18nJson[messageId]) { + messageTxt = i18nJson[messageId]; + } else { + messageTxt = String(messageId); + } + return createFormatCache(IntlMessageFormat)( + messageTxt, + this._locale + ).format(options); + }, + getLocale() { + return this._locale; + }, + getLocaleUpper() { + return this._localeUpper; + }, + setLocale(locale) { + localStorage.setItem('user_locale', locale); + window.location.reload(); + } }; function i18nWrapper() { - return i18nWrapper.message.apply(i18nWrapper, arguments); + return i18nWrapper.message.apply(i18nWrapper, arguments); } /*replace with some kind of extend method*/ var prop, propKey; for (propKey in i18n) { - prop = i18n[propKey]; - if (typeof prop === 'function') { - prop = prop.bind(i18nWrapper); - } - i18nWrapper[propKey] = prop; + prop = i18n[propKey]; + if (typeof prop === 'function') { + prop = prop.bind(i18nWrapper); + } + i18nWrapper[propKey] = prop; } export default i18nWrapper; diff --git a/openecomp-ui/src/nfvo-utils/i18n/i18n.stories.js b/openecomp-ui/src/nfvo-utils/i18n/i18n.stories.js index 816915b1c9..79f95057a0 100644 --- a/openecomp-ui/src/nfvo-utils/i18n/i18n.stories.js +++ b/openecomp-ui/src/nfvo-utils/i18n/i18n.stories.js @@ -1,35 +1,51 @@ import React from 'react'; -import {storiesOf, action} from '@kadira/storybook'; -import {text, number} from '@kadira/storybook-addon-knobs'; -import {withKnobs} from '@kadira/storybook-addon-knobs'; +import { storiesOf } from '@kadira/storybook'; +import { withKnobs } from '@kadira/storybook-addon-knobs'; import i18n from 'nfvo-utils/i18n/i18n.js'; import i18nJson from 'nfvo-utils/i18n/en.json'; const stories = storiesOf('i18n', module); stories.addDecorator(withKnobs); - i18nJson['added'] = 'this is my test'; i18nJson['added with {param}'] = 'this is my test with {param}'; -stories - .add('i18n tests', () => { - let keys = [ - 'I do not exist', - 'Delete', - 'OrchestrationTemplateCandidate/File Structure' - ]; - let translations = []; - let i=0; - translations.push(
KEY: VALUE
) - keys.forEach((key) => { - translations.push((
{key} : {i18n(key)}
)); - }); - var param = 'param'; - translations.push((
added : {i18n('added')}
)); - translations.push((
WRONG - added with ${param} in translation : {i18n(`added with ${param}`)}
)); - translations.push((
RIGHT - added with ${param} and options object {JSON.stringify({param:param})}: {i18n('added with {param}', {param: param})}
)); +stories.add('i18n tests', () => { + let keys = [ + 'I do not exist', + 'Delete', + 'OrchestrationTemplateCandidate/File Structure' + ]; + let translations = []; + let i = 0; + translations.push(
KEY: VALUE
); + keys.forEach(key => { + translations.push( +
+ {key} : {i18n(key)}{' '} +
+ ); + }); + var param = 'param'; + translations.push(
added : {i18n('added')}
); + translations.push( +
+ + WRONG + {' '} + - added with ${param} in translation : {i18n(`added with ${param}`)}{' '} +
+ ); + translations.push( +
+ + RIGHT + {' '} + - added with ${param} and options object{' '} + {JSON.stringify({ param: param })}:{' '} + {i18n('added with {param}', { param: param })}{' '} +
+ ); - return (
{translations}
); - }) -; + return
{translations}
; +}); diff --git a/openecomp-ui/src/nfvo-utils/json/JSONPointer.js b/openecomp-ui/src/nfvo-utils/json/JSONPointer.js index f4c0d4ed59..66c67dd234 100644 --- a/openecomp-ui/src/nfvo-utils/json/JSONPointer.js +++ b/openecomp-ui/src/nfvo-utils/json/JSONPointer.js @@ -14,44 +14,47 @@ * permissions and limitations under the License. */ const JSONPointer = { - - extractParentPointer(pointer) { - return pointer.replace(/\/[^\/]+$/, ''); - }, - - extractLastPart(pointer) { - const [,lastPart] = pointer.match(/\/([^\/]+)$/) || []; - return lastPart; - }, - - extractParts(pointer = '') { - return pointer.split('/').slice(1) - .map(part => part.replace(/~1/g, '/')) - .map(part => part.replace(/~0/g, '~')); - }, - - getValue(object, pointer) { - let parts = JSONPointer.extractParts(pointer); - return parts.reduce((object, part) => object && object[part], object); - }, - - setValue(object, pointer, value) { - let clone = obj => Array.isArray(obj) ? [...obj] : {...obj}; - - let parts = JSONPointer.extractParts(pointer), - newObject = clone(object), - subObject = object, - subNewObject = newObject; - - for(let i = 0, n = parts.length - 1; i < n; ++i) { - let nextSubObject = subObject && subObject[parts[i]]; - subNewObject = subNewObject[parts[i]] = nextSubObject ? clone(nextSubObject) : {}; - subObject = nextSubObject; - } - subNewObject[parts[parts.length - 1]] = value; - - return newObject; - } + extractParentPointer(pointer) { + return pointer.replace(/\/[^\/]+$/, ''); + }, + + extractLastPart(pointer) { + const [, lastPart] = pointer.match(/\/([^\/]+)$/) || []; + return lastPart; + }, + + extractParts(pointer = '') { + return pointer + .split('/') + .slice(1) + .map(part => part.replace(/~1/g, '/')) + .map(part => part.replace(/~0/g, '~')); + }, + + getValue(object, pointer) { + let parts = JSONPointer.extractParts(pointer); + return parts.reduce((object, part) => object && object[part], object); + }, + + setValue(object, pointer, value) { + let clone = obj => (Array.isArray(obj) ? [...obj] : { ...obj }); + + let parts = JSONPointer.extractParts(pointer), + newObject = clone(object), + subObject = object, + subNewObject = newObject; + + for (let i = 0, n = parts.length - 1; i < n; ++i) { + let nextSubObject = subObject && subObject[parts[i]]; + subNewObject = subNewObject[parts[i]] = nextSubObject + ? clone(nextSubObject) + : {}; + subObject = nextSubObject; + } + subNewObject[parts[parts.length - 1]] = value; + + return newObject; + } }; export default JSONPointer; diff --git a/openecomp-ui/src/nfvo-utils/json/JSONSchema.js b/openecomp-ui/src/nfvo-utils/json/JSONSchema.js index 3b3a9bf7b4..53d288f3ae 100644 --- a/openecomp-ui/src/nfvo-utils/json/JSONSchema.js +++ b/openecomp-ui/src/nfvo-utils/json/JSONSchema.js @@ -18,235 +18,264 @@ import cloneDeep from 'lodash/cloneDeep.js'; import JSONPointer from './JSONPointer.js'; export default class JSONSchema { - - setSchema(schema) { - this._schema = schema; - this._fragmentsCache = new Map(); - // this._ajv = new Ajv({ - // useDefaults: true, - // coerceTypes: true - // }); - // this._validate = this._ajv.compile(schema); - } - - processData(data) { - data = cloneDeep(data); - // this._validate(data); - return data; - } - - // array of names of validation functions - setSupportedValidationFunctions(supportedValidationFunctions) { - this._supportedValidationFunctions = supportedValidationFunctions; - } - - /* FYI - I was going to support "required" but then found out that server never sends it in its schema (it was a business decision. so leaving the code commented for now */ - flattenSchema(supportedValidationFunctions) { - if (supportedValidationFunctions) { this.setSupportedValidationFunctions(supportedValidationFunctions); } - let genericFieldInfo = {}; - if (this._schema && this._schema.properties) { - this.travelProperties(this._schema.properties, genericFieldInfo/*, this._schema.required*/); - } - return {genericFieldInfo}; - } - - extractGenericFieldInfo(item) { - let validationsArr = []; - let additionalInfo = { isValid: true, errorText: ''}; - for (let value in item) { - if (this._supportedValidationFunctions.includes(value)) { - let validationItem = this.extractValidations(item, value); - validationsArr[validationsArr.length] = validationItem; - } else { - let enumResult = this.extractEnum(item, value); - if (enumResult !== null) { - additionalInfo.enum = enumResult; - } - else { - additionalInfo[value] = item[value]; - } - /*if (required.includes (property)) { + setSchema(schema) { + this._schema = schema; + this._fragmentsCache = new Map(); + // this._ajv = new Ajv({ + // useDefaults: true, + // coerceTypes: true + // }); + // this._validate = this._ajv.compile(schema); + } + + processData(data) { + data = cloneDeep(data); + // this._validate(data); + return data; + } + + // array of names of validation functions + setSupportedValidationFunctions(supportedValidationFunctions) { + this._supportedValidationFunctions = supportedValidationFunctions; + } + + /* FYI - I was going to support "required" but then found out that server never sends it in its schema (it was a business decision. so leaving the code commented for now */ + flattenSchema(supportedValidationFunctions) { + if (supportedValidationFunctions) { + this.setSupportedValidationFunctions(supportedValidationFunctions); + } + let genericFieldInfo = {}; + if (this._schema && this._schema.properties) { + this.travelProperties( + this._schema.properties, + genericFieldInfo /*, this._schema.required*/ + ); + } + return { genericFieldInfo }; + } + + extractGenericFieldInfo(item) { + let validationsArr = []; + let additionalInfo = { isValid: true, errorText: '' }; + for (let value in item) { + if (this._supportedValidationFunctions.includes(value)) { + let validationItem = this.extractValidations(item, value); + validationsArr[validationsArr.length] = validationItem; + } else { + let enumResult = this.extractEnum(item, value); + if (enumResult !== null) { + additionalInfo.enum = enumResult; + } else { + additionalInfo[value] = item[value]; + } + /*if (required.includes (property)) { additionalInfo[value].isRequired = true ; }*/ - } - } - - additionalInfo.validations = validationsArr; - return additionalInfo; - } - - extractValidations(item, value) { - let validationItem; - let data = item[value]; - if (value === 'maximum') { - if (item.exclusiveMaximum) { - value = 'maximumExclusive'; - } - } - if (value === 'minimum') { - if (item.exclusiveMinimum) { - value = 'minimumExclusive'; - } - } - validationItem = {type: value, data: data}; - return validationItem; - } - - extractEnum(item, value) { - let enumResult = null; - if (value === 'type' && item[value] === 'array') { - let items = item.items; - if (items && items.enum && items.enum.length > 0) { - let values = items.enum - .filter(value => value) - .map(value => ({enum: value, title: value})); - enumResult = values; - } - } - else if (value === 'enum') { - let items = item[value]; - if (items && items.length > 0) { - let values = items - .filter(value => value) - .map(value => ({enum: value, title: value})); - enumResult = values; - } - } - return enumResult; - } - - travelProperties(properties, genericFieldDefs, /*required = [],*/ pointer = ''){ - let newPointer = pointer; - for (let property in properties) { - newPointer = newPointer ? newPointer + '/' + property : property; - if (properties[property].properties) { - this.travelProperties(properties[property].properties, genericFieldDefs /*, properties[property].required*/, newPointer); - } - else if (properties[property].$ref){ - let fragment = this._getSchemaFragmentByRef(properties[property].$ref); - if (fragment.properties) { - this.travelProperties(fragment.properties, genericFieldDefs /*, properties[property].required*/, newPointer); - } else { - genericFieldDefs[newPointer] = this.extractGenericFieldInfo(fragment.properties); - } - } - else { - genericFieldDefs[newPointer] = this.extractGenericFieldInfo(properties[property]); - } - newPointer = pointer; - } - } - - getTitle(pointer) { - return this._getSchemaFragment(pointer).title; - } - - exists(pointer) { - const fragment = this._getSchemaFragment(pointer); - return !!fragment; - } - - getDefault(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.default; - } - - getEnum(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && (fragment.type === 'array' ? fragment.items.enum : fragment.enum); - } - - isRequired(pointer) { - const parentPointer = JSONPointer.extractParentPointer(pointer); - const lastPart = JSONPointer.extractLastPart(pointer); - let parentFragment = this._getSchemaFragment(parentPointer); - return parentFragment && parentFragment.required && parentFragment.required.includes(lastPart); - } - - isNumber(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.type === 'number'; - } - - getMaxValue(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.exclusiveMaximum ? fragment.maximum - 1 : fragment.maximum; - } - - getMinValue(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.exclusiveMinimum ? fragment.minimum : fragment.minimum; - } - - isString(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.type === 'string'; - } - - getPattern(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.pattern; - } - - getMaxLength(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.maxLength; - } - - getMinLength(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.minLength; - } - - isArray(pointer) { - const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.type === 'array'; - } - - _getSchemaFragment(pointer) { - if (this._fragmentsCache.has(pointer)) { - return this._fragmentsCache.get(pointer); - } - - let parts = JSONPointer.extractParts(pointer); - - let fragment = parts.reduce((fragment, part) => { - if (fragment === undefined) { - return undefined; - } - - if (fragment.$ref) { - fragment = this._getSchemaFragmentByRef(fragment.$ref); - } - - switch (fragment.type) { - case 'object': - return fragment.properties && fragment.properties[part]; - - case 'array': - return fragment.enum && fragment.enum[part]; - - default: - // throw new Error(`Incorrect/unsupported JSONPointer "${pointer}" from "${part}"`); - return undefined; - } - }, this._schema); - - while(fragment && fragment.$ref) { - fragment = this._getSchemaFragmentByRef(fragment.$ref); - } - - this._fragmentsCache.set(pointer, fragment); - return fragment; - } - - _getSchemaFragmentByRef($ref) { - let pointer = $ref.substr(1); - return JSONPointer.getValue(this._schema, pointer); - // let fragmentAjv = new Ajv(); - // fragmentAjv.addSchema(this._schema); - // let compiledFragment = fragmentAjv.compile({$ref}); - // let fragment = compiledFragment.refVal[compiledFragment.refs[$ref]]; - // return fragment; - } -}; + } + } + + additionalInfo.validations = validationsArr; + return additionalInfo; + } + + extractValidations(item, value) { + let validationItem; + let data = item[value]; + if (value === 'maximum') { + if (item.exclusiveMaximum) { + value = 'maximumExclusive'; + } + } + if (value === 'minimum') { + if (item.exclusiveMinimum) { + value = 'minimumExclusive'; + } + } + validationItem = { type: value, data: data }; + return validationItem; + } + + extractEnum(item, value) { + let enumResult = null; + if (value === 'type' && item[value] === 'array') { + let items = item.items; + if (items && items.enum && items.enum.length > 0) { + let values = items.enum + .filter(value => value) + .map(value => ({ enum: value, title: value })); + enumResult = values; + } + } else if (value === 'enum') { + let items = item[value]; + if (items && items.length > 0) { + let values = items + .filter(value => value) + .map(value => ({ enum: value, title: value })); + enumResult = values; + } + } + return enumResult; + } + + travelProperties( + properties, + genericFieldDefs, + /*required = [],*/ pointer = '' + ) { + let newPointer = pointer; + for (let property in properties) { + newPointer = newPointer ? newPointer + '/' + property : property; + if (properties[property].properties) { + this.travelProperties( + properties[property].properties, + genericFieldDefs /*, properties[property].required*/, + newPointer + ); + } else if (properties[property].$ref) { + let fragment = this._getSchemaFragmentByRef( + properties[property].$ref + ); + if (fragment.properties) { + this.travelProperties( + fragment.properties, + genericFieldDefs /*, properties[property].required*/, + newPointer + ); + } else { + genericFieldDefs[newPointer] = this.extractGenericFieldInfo( + fragment.properties + ); + } + } else { + genericFieldDefs[newPointer] = this.extractGenericFieldInfo( + properties[property] + ); + } + newPointer = pointer; + } + } + + getTitle(pointer) { + return this._getSchemaFragment(pointer).title; + } + + exists(pointer) { + const fragment = this._getSchemaFragment(pointer); + return !!fragment; + } + + getDefault(pointer) { + const fragment = this._getSchemaFragment(pointer); + return fragment && fragment.default; + } + + getEnum(pointer) { + const fragment = this._getSchemaFragment(pointer); + return ( + fragment && + (fragment.type === 'array' ? fragment.items.enum : fragment.enum) + ); + } + + isRequired(pointer) { + const parentPointer = JSONPointer.extractParentPointer(pointer); + const lastPart = JSONPointer.extractLastPart(pointer); + let parentFragment = this._getSchemaFragment(parentPointer); + return ( + parentFragment && + parentFragment.required && + parentFragment.required.includes(lastPart) + ); + } + + isNumber(pointer) { + const fragment = this._getSchemaFragment(pointer); + return fragment && fragment.type === 'number'; + } + + getMaxValue(pointer) { + const fragment = this._getSchemaFragment(pointer); + return fragment && fragment.exclusiveMaximum + ? fragment.maximum - 1 + : fragment.maximum; + } + + getMinValue(pointer) { + const fragment = this._getSchemaFragment(pointer); + return fragment && fragment.exclusiveMinimum + ? fragment.minimum + : fragment.minimum; + } + + isString(pointer) { + const fragment = this._getSchemaFragment(pointer); + return fragment && fragment.type === 'string'; + } + + getPattern(pointer) { + const fragment = this._getSchemaFragment(pointer); + return fragment && fragment.pattern; + } + + getMaxLength(pointer) { + const fragment = this._getSchemaFragment(pointer); + return fragment && fragment.maxLength; + } + + getMinLength(pointer) { + const fragment = this._getSchemaFragment(pointer); + return fragment && fragment.minLength; + } + + isArray(pointer) { + const fragment = this._getSchemaFragment(pointer); + return fragment && fragment.type === 'array'; + } + + _getSchemaFragment(pointer) { + if (this._fragmentsCache.has(pointer)) { + return this._fragmentsCache.get(pointer); + } + + let parts = JSONPointer.extractParts(pointer); + + let fragment = parts.reduce((fragment, part) => { + if (fragment === undefined) { + return undefined; + } + + if (fragment.$ref) { + fragment = this._getSchemaFragmentByRef(fragment.$ref); + } + + switch (fragment.type) { + case 'object': + return fragment.properties && fragment.properties[part]; + + case 'array': + return fragment.enum && fragment.enum[part]; + + default: + // throw new Error(`Incorrect/unsupported JSONPointer "${pointer}" from "${part}"`); + return undefined; + } + }, this._schema); + + while (fragment && fragment.$ref) { + fragment = this._getSchemaFragmentByRef(fragment.$ref); + } + + this._fragmentsCache.set(pointer, fragment); + return fragment; + } + + _getSchemaFragmentByRef($ref) { + let pointer = $ref.substr(1); + return JSONPointer.getValue(this._schema, pointer); + // let fragmentAjv = new Ajv(); + // fragmentAjv.addSchema(this._schema); + // let compiledFragment = fragmentAjv.compile({$ref}); + // let fragment = compiledFragment.refVal[compiledFragment.refs[$ref]]; + // return fragment; + } +} diff --git a/openecomp-ui/src/nfvo-utils/sortByStringProperty.js b/openecomp-ui/src/nfvo-utils/sortByStringProperty.js index b415dd7e07..89e9f4034c 100644 --- a/openecomp-ui/src/nfvo-utils/sortByStringProperty.js +++ b/openecomp-ui/src/nfvo-utils/sortByStringProperty.js @@ -14,5 +14,7 @@ * permissions and limitations under the License. */ export default function sortByStringProperty(array, property) { - return [...array].sort((a, b) => a[property].toLowerCase().localeCompare(b[property].toLowerCase())); + return [...array].sort((a, b) => + a[property].toLowerCase().localeCompare(b[property].toLowerCase()) + ); } diff --git a/openecomp-ui/src/sdc-app/AppStore.js b/openecomp-ui/src/sdc-app/AppStore.js index bafef7dcd6..bca750a930 100644 --- a/openecomp-ui/src/sdc-app/AppStore.js +++ b/openecomp-ui/src/sdc-app/AppStore.js @@ -14,24 +14,27 @@ * limitations under the License. */ -import {createStore, applyMiddleware, compose} from 'redux'; +import { createStore, applyMiddleware, compose } from 'redux'; import Reducers from './Reducers.js'; const thunk = store => next => action => - typeof action === 'function' ? - action(store.dispatch, store.getState) : - next(action); - + typeof action === 'function' + ? action(store.dispatch, store.getState) + : next(action); const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose; -export const storeCreator = (initialState) => createStore(Reducers, initialState, composeEnhancers(applyMiddleware(thunk))); - +export const storeCreator = initialState => + createStore( + Reducers, + initialState, + composeEnhancers(applyMiddleware(thunk)) + ); const store = storeCreator(); if (module.hot) { - module.hot.accept('./Reducers.js', () => - store.replaceReducer(require('./Reducers.js').default) - ); + module.hot.accept('./Reducers.js', () => + store.replaceReducer(require('./Reducers.js').default) + ); } export default store; diff --git a/openecomp-ui/src/sdc-app/Application.jsx b/openecomp-ui/src/sdc-app/Application.jsx index aa81eb384c..abebb6d89a 100644 --- a/openecomp-ui/src/sdc-app/Application.jsx +++ b/openecomp-ui/src/sdc-app/Application.jsx @@ -15,7 +15,7 @@ */ import React from 'react'; import PropTypes from 'prop-types'; -import {Provider} from 'react-redux'; +import { Provider } from 'react-redux'; import GlobalModal from 'nfvo-components/modal/GlobalModal.js'; import Loader from 'nfvo-components/loader/Loader.jsx'; import WebSocketUtil from 'nfvo-utils/WebSocketUtil.js'; @@ -24,31 +24,32 @@ import store from './AppStore.js'; import FeaturesActionHelper from 'sdc-app/features/FeaturesActionHelper.js'; class Application extends React.Component { - static propTypes = { - openSocket: PropTypes.bool - }; - componentDidMount() { - const {openSocket = true} = this.props; - if(openSocket) { - UserNotificationsActionHelper.notificationsFirstHandling(store.dispatch); - } - FeaturesActionHelper.getFeaturesList(store.dispatch); - } - componentWillUnmount() { - WebSocketUtil.close(); - } - render() { - return ( - -
- - {this.props.children} - -
-
- ); - } + static propTypes = { + openSocket: PropTypes.bool + }; + componentDidMount() { + const { openSocket = true } = this.props; + if (openSocket) { + UserNotificationsActionHelper.notificationsFirstHandling( + store.dispatch + ); + } + FeaturesActionHelper.getFeaturesList(store.dispatch); + } + componentWillUnmount() { + WebSocketUtil.close(); + } + render() { + return ( + +
+ + {this.props.children} + +
+
+ ); + } } export default Application; - diff --git a/openecomp-ui/src/sdc-app/ModulesOptions.jsx b/openecomp-ui/src/sdc-app/ModulesOptions.jsx index 28fab80da9..63296b57c9 100644 --- a/openecomp-ui/src/sdc-app/ModulesOptions.jsx +++ b/openecomp-ui/src/sdc-app/ModulesOptions.jsx @@ -15,7 +15,7 @@ */ import React from 'react'; import PropTypes from 'prop-types'; -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import Input from 'nfvo-components/input/validation/InputWrapper.jsx'; import LicenseModelActionHelper from './onboarding/licenseModel/LicenseModelActionHelper.js'; @@ -27,140 +27,198 @@ import LicenseKeyGroupsListEditor from './onboarding/licenseModel/licenseKeyGrou import LicenseKeyGroupsActionHelper from './onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; import EntitlementPoolsListEditor from './onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js'; import EntitlementPoolsActionHelper from './onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js'; -import SoftwareProductLandingPage from './onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js'; -import SoftwareProductDetails from './onboarding/softwareProduct/details/SoftwareProductDetails.js'; +import SoftwareProductLandingPage from './onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js'; +import SoftwareProductDetails from './onboarding/softwareProduct/details/SoftwareProductDetails.js'; import Onboard from './onboarding/onboard/Onboard.js'; import SoftwareProductActionHelper from './onboarding/softwareProduct/SoftwareProductActionHelper.js'; import FlowsListEditor from './flows/FlowsListEditor.js'; import FlowsActions from './flows/FlowsActions.js'; - -const mapStateToProps = ({licenseModelList}) => { - return {licenseModelList}; +const mapStateToProps = ({ licenseModelList }) => { + return { licenseModelList }; }; - const mapActionsToProps = dispatch => { - return { - onBootstrapped: () => LicenseModelActionHelper.fetchLicenseModels(dispatch), - onLicenseAgreementListEditor: licenseModelId => LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId}), - onFeatureGroupsListEditor: licenseModelId => FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId}), - onLicenseKeyGroupsListEditor: licenseModelId =>LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId}), - onEntitlementPoolsListEditor: licenseModelId => EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId}), - onOnboardingCatalog: () => SoftwareProductActionHelper.fetchSoftwareProductList(dispatch), - onSoftwareProductDetails: () => SoftwareProductActionHelper.fetchSoftwareProductCategories(dispatch), - onFlowsListEditor: () => FlowsActions.fetchFlows(dispatch) - }; + return { + onBootstrapped: () => + LicenseModelActionHelper.fetchLicenseModels(dispatch), + onLicenseAgreementListEditor: licenseModelId => + LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, { + licenseModelId + }), + onFeatureGroupsListEditor: licenseModelId => + FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, { + licenseModelId + }), + onLicenseKeyGroupsListEditor: licenseModelId => + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, { + licenseModelId + }), + onEntitlementPoolsListEditor: licenseModelId => + EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, { + licenseModelId + }), + onOnboardingCatalog: () => + SoftwareProductActionHelper.fetchSoftwareProductList(dispatch), + onSoftwareProductDetails: () => + SoftwareProductActionHelper.fetchSoftwareProductCategories( + dispatch + ), + onFlowsListEditor: () => FlowsActions.fetchFlows(dispatch) + }; }; class ModuleOptions extends React.Component { + static propTypes = { + onBootstrapped: PropTypes.func.isRequired, + onLicenseAgreementListEditor: PropTypes.func.isRequired, + onFeatureGroupsListEditor: PropTypes.func.isRequired, + onLicenseKeyGroupsListEditor: PropTypes.func.isRequired, + onEntitlementPoolsListEditor: PropTypes.func.isRequired, + onOnboardingCatalog: PropTypes.func.isRequired, + onSoftwareProductDetails: PropTypes.func.isRequired + }; - static propTypes = { - onBootstrapped: PropTypes.func.isRequired, - onLicenseAgreementListEditor: PropTypes.func.isRequired, - onFeatureGroupsListEditor: PropTypes.func.isRequired, - onLicenseKeyGroupsListEditor: PropTypes.func.isRequired, - onEntitlementPoolsListEditor: PropTypes.func.isRequired, - onOnboardingCatalog: PropTypes.func.isRequired, - onSoftwareProductDetails: PropTypes.func.isRequired, - }; - - state = { - currentModule: localStorage.getItem('default-module'), - licenseModelId: localStorage.getItem('default-license-model-id') - }; + state = { + currentModule: localStorage.getItem('default-module'), + licenseModelId: localStorage.getItem('default-license-model-id') + }; - componentDidMount() { - this.props.onBootstrapped(); - } + componentDidMount() { + this.props.onBootstrapped(); + } - render() { - let {currentModule, licenseModelId} = this.state; - let {licenseModelList} = this.props; - return ( -
- - - { - licenseModelList.map(({id, vendorName}) => ) - } - - - - - - - - - - - - -
- {this.renderModule(currentModule)} -
-
- ); - } + render() { + let { currentModule, licenseModelId } = this.state; + let { licenseModelList } = this.props; + return ( +
+ + + {licenseModelList.map(({ id, vendorName }) => ( + + ))} + + + + + + + + + + + + +
+ {this.renderModule(currentModule)} +
+
+ ); + } - renderModule(currentModule) { - const {licenseModelId} = this.state; - if (!licenseModelId) { - return; - } + renderModule(currentModule) { + const { licenseModelId } = this.state; + if (!licenseModelId) { + return; + } - switch (currentModule) { - case 'LicenseAgreementListEditor': - this.props.onLicenseAgreementListEditor(licenseModelId); - return ; - case 'FutureGroupListEditor': - this.props.onFeatureGroupsListEditor(licenseModelId); - return ; - case 'EntitlementPoolsListEditor': - this.props.onEntitlementPoolsListEditor(licenseModelId); - return ; - case 'LicenseKeyGroupsListEditor': - this.props.onLicenseKeyGroupsListEditor(licenseModelId); - return ; - case 'SoftwareProductLanding': - return ; - case 'SoftwareProductDetails': - this.props.onSoftwareProductDetails(licenseModelId); - return ; - case 'OnboardingCatalog': - this.props.onOnboardingCatalog(); - return ; - case 'Flows': - this.props.onFlowsListEditor(); - return ; - default: - return; - } - } + switch (currentModule) { + case 'LicenseAgreementListEditor': + this.props.onLicenseAgreementListEditor(licenseModelId); + return ( + + ); + case 'FutureGroupListEditor': + this.props.onFeatureGroupsListEditor(licenseModelId); + return ( + + ); + case 'EntitlementPoolsListEditor': + this.props.onEntitlementPoolsListEditor(licenseModelId); + return ( + + ); + case 'LicenseKeyGroupsListEditor': + this.props.onLicenseKeyGroupsListEditor(licenseModelId); + return ( + + ); + case 'SoftwareProductLanding': + return ( + + ); + case 'SoftwareProductDetails': + this.props.onSoftwareProductDetails(licenseModelId); + return ( + + ); + case 'OnboardingCatalog': + this.props.onOnboardingCatalog(); + return ; + case 'Flows': + this.props.onFlowsListEditor(); + return ; + default: + return; + } + } - handleModuleSelection = () => { - let selectedModule = this.refs.selectedModule.getValue(); - localStorage.setItem('default-module', selectedModule); - this.setState({currentModule: selectedModule}); - } + handleModuleSelection = () => { + let selectedModule = this.refs.selectedModule.getValue(); + localStorage.setItem('default-module', selectedModule); + this.setState({ currentModule: selectedModule }); + }; - handleLicenseModelIdChange = () => { - let licenseModelId = this.refs.licenseModelId.getValue(); - localStorage.setItem('default-license-model-id', licenseModelId); - this.setState({licenseModelId}); - } + handleLicenseModelIdChange = () => { + let licenseModelId = this.refs.licenseModelId.getValue(); + localStorage.setItem('default-license-model-id', licenseModelId); + this.setState({ licenseModelId }); + }; } export default connect(mapStateToProps, mapActionsToProps)(ModuleOptions); diff --git a/openecomp-ui/src/sdc-app/Reducers.js b/openecomp-ui/src/sdc-app/Reducers.js index a0a8ebafa1..9f424235cb 100644 --- a/openecomp-ui/src/sdc-app/Reducers.js +++ b/openecomp-ui/src/sdc-app/Reducers.js @@ -14,7 +14,7 @@ * limitations under the License. */ -import {combineReducers} from 'redux'; +import { combineReducers } from 'redux'; import onBoardingReducersMap from './onboarding/OnboardingReducersMap.js'; import flowsReducersMap from './flows/FlowsReducersMap.js'; import loaderReducer from 'nfvo-components/loader/LoaderReducer.js'; @@ -22,12 +22,12 @@ import globalModalReducer from 'nfvo-components/modal/GlobalModalReducer.js'; import notificationsReducer from 'sdc-app/onboarding/userNotifications/NotificationsReducer.js'; export default combineReducers({ - // on-boarding reducers - ...onBoardingReducersMap, + // on-boarding reducers + ...onBoardingReducersMap, - // flows reducers - ...flowsReducersMap, - modal: globalModalReducer, - loader: loaderReducer, - notifications: notificationsReducer + // flows reducers + ...flowsReducersMap, + modal: globalModalReducer, + loader: loaderReducer, + notifications: notificationsReducer }); diff --git a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLog.js b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLog.js index a1ad437f5b..2978cacda4 100644 --- a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLog.js +++ b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLog.js @@ -13,16 +13,28 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import ActivityLogView from './ActivityLogView.jsx'; -export const mapStateToProps = ({users: {usersList}, licenseModel: {activityLog}}) => { - - let activities = activityLog; - return { - activities: activities.map(activity => ({...activity, user: {id: activity.user, name: usersList.find(userObject => userObject.userId === activity.user).fullName}})), - usersList - }; +export const mapStateToProps = ({ + users: { usersList }, + licenseModel: { activityLog } +}) => { + let activities = activityLog; + return { + activities: activities.map(activity => ({ + ...activity, + user: { + id: activity.user, + name: usersList.find( + userObject => userObject.userId === activity.user + ).fullName + } + })), + usersList + }; }; -export default connect(mapStateToProps, undefined, null, {withRef: true})(ActivityLogView); +export default connect(mapStateToProps, undefined, null, { withRef: true })( + ActivityLogView +); diff --git a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogActionHelper.js b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogActionHelper.js index 729d8fb5f3..6856b08c8b 100644 --- a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogActionHelper.js +++ b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogActionHelper.js @@ -17,8 +17,13 @@ import ActivityLogConstants from './ActivityLogConstants.js'; import ItemHelper from 'sdc-app/common/helpers/ItemsHelper.js'; export default { - - fetchActivityLog(dispatch, {itemId, versionId}){ - return ItemHelper.fetchActivityLog({itemId, versionId}).then(response => dispatch({type: ActivityLogConstants.ACTIVITY_LOG_UPDATED, response})); - } + fetchActivityLog(dispatch, { itemId, versionId }) { + return ItemHelper.fetchActivityLog({ itemId, versionId }).then( + response => + dispatch({ + type: ActivityLogConstants.ACTIVITY_LOG_UPDATED, + response + }) + ); + } }; diff --git a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogConstants.js b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogConstants.js index 69faf7cbb6..2da3c7799e 100644 --- a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogConstants.js +++ b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogConstants.js @@ -16,8 +16,5 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export default keyMirror({ - - ACTIVITY_LOG_UPDATED: null - + ACTIVITY_LOG_UPDATED: null }); - diff --git a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogReducer.js b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogReducer.js index fc3dfa1515..418a9b9e3d 100644 --- a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogReducer.js +++ b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogReducer.js @@ -16,10 +16,10 @@ import ActivityLogConstants from './ActivityLogConstants.js'; export default (state = [], action) => { - switch (action.type) { - case ActivityLogConstants.ACTIVITY_LOG_UPDATED: - return [...action.response.results]; - } + switch (action.type) { + case ActivityLogConstants.ACTIVITY_LOG_UPDATED: + return [...action.response.results]; + } - return state; + return state; }; diff --git a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogView.jsx b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogView.jsx index 5b8c29b719..d65e667163 100644 --- a/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogView.jsx +++ b/openecomp-ui/src/sdc-app/common/activity-log/ActivityLogView.jsx @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; import Tooltip from 'react-bootstrap/lib/Tooltip.js'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; @@ -21,108 +21,177 @@ import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import LogDetails from './LogixUtil.jsx'; -function ActivityLogSortableCellHeader({isHeader, data, isDes, onSort}) { - //TODO check icon sdc-ui - if (isHeader) { - return ( - - {data} - - - ); - } - return ( - - {i18n.dateNormal(data, { - year: 'numeric', month: 'numeric', day: 'numeric' - })} - {i18n.dateNormal(data, { - hour: 'numeric', minute: 'numeric', - hour12: true - })} - - ); +function ActivityLogSortableCellHeader({ isHeader, data, isDes, onSort }) { + //TODO check icon sdc-ui + if (isHeader) { + return ( + + {data} + + + ); + } + return ( + + + {i18n.dateNormal(data, { + year: 'numeric', + month: 'numeric', + day: 'numeric' + })} + + + {i18n.dateNormal(data, { + hour: 'numeric', + minute: 'numeric', + hour12: true + })} + + + ); } -function ActivityLogStatus({status, isHeader}) { - if (isHeader) { - return {status}; - } - let {message, success} = status; - return ( - - {`${success ? i18n('Success') : i18n('Failure')}`} - {success && } - {!success && -
{message}
- }> - {'?'} -
} -
- ); +function ActivityLogStatus({ status, isHeader }) { + if (isHeader) { + return {status}; + } + let { message, success } = status; + return ( + + {`${ + success ? i18n('Success') : i18n('Failure') + }`} + {success && } + {!success && ( + +
{message}
+ + }> + {'?'} +
+ )} +
+ ); } -export function ActivityListItem({activity, isHeader, isDes, onSort}) { - let {type, timestamp, comment, user, status} = activity; - return ( -
  • -
    -
    {i18n(type)}
    -
    {i18n(comment)}
    -
    {isHeader ? i18n(activity.user) : `${i18n(user.name)} (${user.id})`}
    -
    -
  • - ); +export function ActivityListItem({ activity, isHeader, isDes, onSort }) { + let { type, timestamp, comment, user, status } = activity; + return ( +
  • +
    + +
    +
    + {i18n(type)} +
    +
    + {i18n(comment)} +
    +
    + {isHeader + ? i18n(activity.user) + : `${i18n(user.name)} (${user.id})`} +
    +
    + +
    +
  • + ); } class ActivityLogView extends Component { + state = { + localFilter: '', + sortDescending: true + }; - state = { - localFilter: '', - sortDescending: true - }; + render() { + return ( +
    + + this.setState({ localFilter: filter })}> + + this.setState({ + sortDescending: !this.state.sortDescending + }) + } + isHeader + /> + {this.sortActivities( + this.filterActivities(), + this.state.sortDescending + ).map(activity => ( + + ))} + +
    + ); + } - render() { - return ( -
    - - this.setState({localFilter: filter})}> - this.setState({sortDescending: !this.state.sortDescending})} - isHeader/> - {this.sortActivities(this.filterActivities(), this.state.sortDescending).map(activity => )} - -
    - ); - } - - filterActivities() { - let {activities} = this.props; - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return activities.filter(({user = {id: '', name: ''}, comment = '', type = ''}) => - escape(user.id).match(filter) || escape(user.name).match(filter) || escape(comment).match(filter) || escape(type).match(filter)); - } - else { - return activities; - } - } - - sortActivities(activities) { - if (this.state.sortDescending) { - return activities.sort((a, b) => a.timestamp - b.timestamp); - } - else { - return activities.reverse(); - } - } + filterActivities() { + let { activities } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return activities.filter( + ({ user = { id: '', name: '' }, comment = '', type = '' }) => + escape(user.id).match(filter) || + escape(user.name).match(filter) || + escape(comment).match(filter) || + escape(type).match(filter) + ); + } else { + return activities; + } + } + sortActivities(activities) { + if (this.state.sortDescending) { + return activities.sort((a, b) => a.timestamp - b.timestamp); + } else { + return activities.reverse(); + } + } } export default ActivityLogView; diff --git a/openecomp-ui/src/sdc-app/common/activity-log/LogixUtil.jsx b/openecomp-ui/src/sdc-app/common/activity-log/LogixUtil.jsx index bd40e113e9..0dbf518768 100644 --- a/openecomp-ui/src/sdc-app/common/activity-log/LogixUtil.jsx +++ b/openecomp-ui/src/sdc-app/common/activity-log/LogixUtil.jsx @@ -1,28 +1,36 @@ -import React, {Component} from 'react'; -// eslint-disable-next-line max-len -const style = 'LnJhYmJpdHt3aWR0aDo1ZW07aGVpZ2h0OjNlbTtiYWNrZ3JvdW5kOiM5OTk7Ym9yZGVyLXJhZGl1czo3MCUgOTAlIDYwJSA1MCU7cG9zaXRpb246cmVsYXRpdmU7LW1vei10cmFuc2Zvcm06cm90YXRlKDApIHRyYW5zbGF0ZSgtMmVtLDApOy1tcy10cmFuc2Zvcm06cm90YXRlKDApIHRyYW5zbGF0ZSgtMmVtLDApOy13ZWJraXQtdHJhbnNmb3JtOnJvdGF0ZSgwKSB0cmFuc2xhdGUoLTJlbSwwKTt0cmFuc2Zvcm06cm90YXRlKDApIHRyYW5zbGF0ZSgtMmVtLDApO2FuaW1hdGlvbjpob3AgMXMgaW5maW5pdGUgbGluZWFyO3otaW5kZXg6MX0ucmFiYml0OmFmdGVyLC5yYWJiaXQ6YmVmb3Jle2NvbnRlbnQ6IiI7cG9zaXRpb246YWJzb2x1dGU7YmFja2dyb3VuZDojZjFmMWYxfS5uby1mbGV4Ym94IC5yYWJiaXR7bWFyZ2luOjEwZW0gYXV0byAwfS5yYWJiaXQ6YmVmb3Jle3dpZHRoOjFlbTtoZWlnaHQ6MWVtO2JvcmRlci1yYWRpdXM6MTAwJTt0b3A6LjVlbTtsZWZ0Oi0uM2VtO2JveC1zaGFkb3c6NGVtIC40ZW0gMCAtLjM1ZW0gIzNmMzMzNCwuNWVtIDFlbSAwICNmMWYxZjEsNGVtIDFlbSAwIC0uM2VtICNmMWYxZjEsNGVtIDFlbSAwIC0uM2VtICNmMWYxZjEsNGVtIDFlbSAwIC0uNGVtICNmMWYxZjE7YW5pbWF0aW9uOmtpY2sgMXMgaW5maW5pdGUgbGluZWFyfS5yYWJiaXQ6YWZ0ZXJ7d2lkdGg6Ljc1ZW07aGVpZ2h0OjJlbTtib3JkZXItcmFkaXVzOjUwJSAxMDAlIDAgMDstbW96LXRyYW5zZm9ybTpyb3RhdGUoLTMwZGVnKTstbXMtdHJhbnNmb3JtOnJvdGF0ZSgtMzBkZWcpOy13ZWJraXQtdHJhbnNmb3JtOnJvdGF0ZSgtMzBkZWcpO3RyYW5zZm9ybTpyb3RhdGUoLTMwZGVnKTtyaWdodDoxZW07dG9wOi0xZW07Ym9yZGVyLXRvcDoxcHggc29saWQgI2Y3ZjVmNDtib3JkZXItbGVmdDoxcHggc29saWQgI2Y3ZjVmNDtib3gtc2hhZG93Oi0uNWVtIDAgMCAtLjFlbSAjZjFmMWYxfUBrZXlmcmFtZXMgaG9wezIwJXstbW96LXRyYW5zZm9ybTpyb3RhdGUoLTEwZGVnKSB0cmFuc2xhdGUoMWVtLC0yZW0pOy1tcy10cmFuc2Zvcm06cm90YXRlKC0xMGRlZykgdHJhbnNsYXRlKDFlbSwtMmVtKTstd2Via2l0LXRyYW5zZm9ybTpyb3RhdGUoLTEwZGVnKSB0cmFuc2xhdGUoMWVtLC0yZW0pO3RyYW5zZm9ybTpyb3RhdGUoLTEwZGVnKSB0cmFuc2xhdGUoMWVtLC0yZW0pfTQwJXstbW96LXRyYW5zZm9ybTpyb3RhdGUoMTBkZWcpIHRyYW5zbGF0ZSgzZW0sLTRlbSk7LW1zLXRyYW5zZm9ybTpyb3RhdGUoMTBkZWcpIHRyYW5zbGF0ZSgzZW0sLTRlbSk7LXdlYmtpdC10cmFuc2Zvcm06cm90YXRlKDEwZGVnKSB0cmFuc2xhdGUoM2VtLC00ZW0pO3RyYW5zZm9ybTpyb3RhdGUoMTBkZWcpIHRyYW5zbGF0ZSgzZW0sLTRlbSl9NjAlLDc1JXstbW96LXRyYW5zZm9ybTpyb3RhdGUoMCkgdHJhbnNsYXRlKDRlbSwwKTstbXMtdHJhbnNmb3JtOnJvdGF0ZSgwKSB0cmFuc2xhdGUoNGVtLDApOy13ZWJraXQtdHJhbnNmb3JtOnJvdGF0ZSgwKSB0cmFuc2xhdGUoNGVtLDApO3RyYW5zZm9ybTpyb3RhdGUoMCkgdHJhbnNsYXRlKDRlbSwwKX19QGtleWZyYW1lcyBraWNrezIwJSw1MCV7Ym94LXNoYWRvdzo0ZW0gLjRlbSAwIC0uMzVlbSAjM2YzMzM0LC41ZW0gMS41ZW0gMCAjZjFmMWYxLDRlbSAxLjc1ZW0gMCAtLjNlbSAjZjFmMWYxLDRlbSAxLjc1ZW0gMCAtLjNlbSAjZjFmMWYxLDRlbSAxLjllbSAwIC0uNGVtICNmMWYxZjF9NDAle2JveC1zaGFkb3c6NGVtIC40ZW0gMCAtLjM1ZW0gIzNmMzMzNCwuNWVtIDJlbSAwICNmMWYxZjEsNGVtIDEuNzVlbSAwIC0uM2VtICNmMWYxZjEsNC4yZW0gMS43NWVtIDAgLS4yZW0gI2YxZjFmMSw0LjRlbSAxLjllbSAwIC0uMmVtICNmMWYxZjF9fQ=='; +import React, { Component } from 'react'; /* eslint-disable max-len */ +const style = + 'LnJhYmJpdHt3aWR0aDo1ZW07aGVpZ2h0OjNlbTtiYWNrZ3JvdW5kOiM5OTk7Ym9yZGVyLXJhZGl1czo3MCUgOTAlIDYwJSA1MCU7cG9zaXRpb246cmVsYXRpdmU7LW1vei10cmFuc2Zvcm06cm90YXRlKDApIHRyYW5zbGF0ZSgtMmVtLDApOy1tcy10cmFuc2Zvcm06cm90YXRlKDApIHRyYW5zbGF0ZSgtMmVtLDApOy13ZWJraXQtdHJhbnNmb3JtOnJvdGF0ZSgwKSB0cmFuc2xhdGUoLTJlbSwwKTt0cmFuc2Zvcm06cm90YXRlKDApIHRyYW5zbGF0ZSgtMmVtLDApO2FuaW1hdGlvbjpob3AgMXMgaW5maW5pdGUgbGluZWFyO3otaW5kZXg6MX0ucmFiYml0OmFmdGVyLC5yYWJiaXQ6YmVmb3Jle2NvbnRlbnQ6IiI7cG9zaXRpb246YWJzb2x1dGU7YmFja2dyb3VuZDojZjFmMWYxfS5uby1mbGV4Ym94IC5yYWJiaXR7bWFyZ2luOjEwZW0gYXV0byAwfS5yYWJiaXQ6YmVmb3Jle3dpZHRoOjFlbTtoZWlnaHQ6MWVtO2JvcmRlci1yYWRpdXM6MTAwJTt0b3A6LjVlbTtsZWZ0Oi0uM2VtO2JveC1zaGFkb3c6NGVtIC40ZW0gMCAtLjM1ZW0gIzNmMzMzNCwuNWVtIDFlbSAwICNmMWYxZjEsNGVtIDFlbSAwIC0uM2VtICNmMWYxZjEsNGVtIDFlbSAwIC0uM2VtICNmMWYxZjEsNGVtIDFlbSAwIC0uNGVtICNmMWYxZjE7YW5pbWF0aW9uOmtpY2sgMXMgaW5maW5pdGUgbGluZWFyfS5yYWJiaXQ6YWZ0ZXJ7d2lkdGg6Ljc1ZW07aGVpZ2h0OjJlbTtib3JkZXItcmFkaXVzOjUwJSAxMDAlIDAgMDstbW96LXRyYW5zZm9ybTpyb3RhdGUoLTMwZGVnKTstbXMtdHJhbnNmb3JtOnJvdGF0ZSgtMzBkZWcpOy13ZWJraXQtdHJhbnNmb3JtOnJvdGF0ZSgtMzBkZWcpO3RyYW5zZm9ybTpyb3RhdGUoLTMwZGVnKTtyaWdodDoxZW07dG9wOi0xZW07Ym9yZGVyLXRvcDoxcHggc29saWQgI2Y3ZjVmNDtib3JkZXItbGVmdDoxcHggc29saWQgI2Y3ZjVmNDtib3gtc2hhZG93Oi0uNWVtIDAgMCAtLjFlbSAjZjFmMWYxfUBrZXlmcmFtZXMgaG9wezIwJXstbW96LXRyYW5zZm9ybTpyb3RhdGUoLTEwZGVnKSB0cmFuc2xhdGUoMWVtLC0yZW0pOy1tcy10cmFuc2Zvcm06cm90YXRlKC0xMGRlZykgdHJhbnNsYXRlKDFlbSwtMmVtKTstd2Via2l0LXRyYW5zZm9ybTpyb3RhdGUoLTEwZGVnKSB0cmFuc2xhdGUoMWVtLC0yZW0pO3RyYW5zZm9ybTpyb3RhdGUoLTEwZGVnKSB0cmFuc2xhdGUoMWVtLC0yZW0pfTQwJXstbW96LXRyYW5zZm9ybTpyb3RhdGUoMTBkZWcpIHRyYW5zbGF0ZSgzZW0sLTRlbSk7LW1zLXRyYW5zZm9ybTpyb3RhdGUoMTBkZWcpIHRyYW5zbGF0ZSgzZW0sLTRlbSk7LXdlYmtpdC10cmFuc2Zvcm06cm90YXRlKDEwZGVnKSB0cmFuc2xhdGUoM2VtLC00ZW0pO3RyYW5zZm9ybTpyb3RhdGUoMTBkZWcpIHRyYW5zbGF0ZSgzZW0sLTRlbSl9NjAlLDc1JXstbW96LXRyYW5zZm9ybTpyb3RhdGUoMCkgdHJhbnNsYXRlKDRlbSwwKTstbXMtdHJhbnNmb3JtOnJvdGF0ZSgwKSB0cmFuc2xhdGUoNGVtLDApOy13ZWJraXQtdHJhbnNmb3JtOnJvdGF0ZSgwKSB0cmFuc2xhdGUoNGVtLDApO3RyYW5zZm9ybTpyb3RhdGUoMCkgdHJhbnNsYXRlKDRlbSwwKX19QGtleWZyYW1lcyBraWNrezIwJSw1MCV7Ym94LXNoYWRvdzo0ZW0gLjRlbSAwIC0uMzVlbSAjM2YzMzM0LC41ZW0gMS41ZW0gMCAjZjFmMWYxLDRlbSAxLjc1ZW0gMCAtLjNlbSAjZjFmMWYxLDRlbSAxLjc1ZW0gMCAtLjNlbSAjZjFmMWYxLDRlbSAxLjllbSAwIC0uNGVtICNmMWYxZjF9NDAle2JveC1zaGFkb3c6NGVtIC40ZW0gMCAtLjM1ZW0gIzNmMzMzNCwuNWVtIDJlbSAwICNmMWYxZjEsNGVtIDEuNzVlbSAwIC0uM2VtICNmMWYxZjEsNC4yZW0gMS43NWVtIDAgLS4yZW0gI2YxZjFmMSw0LjRlbSAxLjllbSAwIC0uMmVtICNmMWYxZjF9fQ=='; +/* eslint-enable max-len */ class LogixUtil extends Component { + state = { + whatToDisplay: false + }; - state = { - whatToDisplay: false - }; - - componentWillReceiveProps(nextProps) { - this.setState({whatToDisplay: window.btoa(nextProps.display) === 'YnJpdG5leSBiaXRjaCE='}); - } - - render() { - if (this.state.whatToDisplay) { - setTimeout(() => this.setState({whatToDisplay: false}), 5000); - } - return ( -
    - -
    -
    - ); - } + componentWillReceiveProps(nextProps) { + this.setState({ + whatToDisplay: + window.btoa(nextProps.display) === 'YnJpdG5leSBiaXRjaCE=' + }); + } + render() { + if (this.state.whatToDisplay) { + setTimeout(() => this.setState({ whatToDisplay: false }), 5000); + } + return ( +
    + +
    +
    + ); + } } export default LogixUtil; diff --git a/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js b/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js index 05affe981f..99ecae9887 100644 --- a/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js +++ b/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js @@ -15,92 +15,110 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {permissionTypes} from 'sdc-app/onboarding/permissions/PermissionsConstants.js'; -import {actionsEnum as VersionControllerActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; -import {actionTypes as onboardingActionTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { permissionTypes } from 'sdc-app/onboarding/permissions/PermissionsConstants.js'; +import { actionsEnum as VersionControllerActionsEnum } from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import { actionTypes as onboardingActionTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import restToggle from 'sdc-app/features/restToggle.js'; -import {featureToggleNames} from 'sdc-app/features/FeaturesConstants.js'; +import { featureToggleNames } from 'sdc-app/features/FeaturesConstants.js'; export const archiveActions = { - ARCHIVE: 'ARCHIVE', - RESTORE: 'RESTORE' + ARCHIVE: 'ARCHIVE', + RESTORE: 'RESTORE' }; export const itemStatus = { - ARCHIVED: 'ARCHIVED', - DRAFT: 'Draft', - CERTIFIED: 'Certified' + ARCHIVED: 'ARCHIVED', + DRAFT: 'Draft', + CERTIFIED: 'Certified' }; - function baseUrl() { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/items`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/items`; } const ItemsHelper = { - performVCAction({itemId, version, action, comment}) { - const {id: versionId} = version; - const data = { - action, - ...action === VersionControllerActionsEnum.COMMIT && {commitRequest: {message: comment}} - }; - return RestAPIUtil.put(`${baseUrl()}/${itemId}/versions/${versionId}/actions`, data); - }, + performVCAction({ itemId, version, action, comment }) { + const { id: versionId } = version; + const data = { + action, + ...(action === VersionControllerActionsEnum.COMMIT && { + commitRequest: { message: comment } + }) + }; + return RestAPIUtil.put( + `${baseUrl()}/${itemId}/versions/${versionId}/actions`, + data + ); + }, - fetchVersions({itemId}) { - return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/versions`); - }, + fetchVersions({ itemId }) { + return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/versions`); + }, - fetchVersion({itemId, versionId}) { - return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/versions/${versionId}`); - }, + fetchVersion({ itemId, versionId }) { + return RestAPIUtil.fetch( + `${baseUrl()}/${itemId}/versions/${versionId}` + ); + }, - fetchActivityLog({itemId, versionId}) { - return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/versions/${versionId}/activity-logs`); - }, + fetchActivityLog({ itemId, versionId }) { + return RestAPIUtil.fetch( + `${baseUrl()}/${itemId}/versions/${versionId}/activity-logs` + ); + }, - fetchUsers({itemId}) { - return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/permissions`); - }, + fetchUsers({ itemId }) { + return RestAPIUtil.fetch(`${baseUrl()}/${itemId}/permissions`); + }, - updateContributors({itemId, removedUsersIds, addedUsersIds}) { - return RestAPIUtil.put(`${baseUrl()}/${itemId}/permissions/${permissionTypes.CONTRIBUTOR}`, {removedUsersIds, addedUsersIds}); - }, + updateContributors({ itemId, removedUsersIds, addedUsersIds }) { + return RestAPIUtil.put( + `${baseUrl()}/${itemId}/permissions/${permissionTypes.CONTRIBUTOR}`, + { removedUsersIds, addedUsersIds } + ); + }, - changeOwner({itemId, ownerId}) { - return RestAPIUtil.put(`${baseUrl()}/${itemId}/permissions/${permissionTypes.OWNER}`, {removedUsersIds: [], addedUsersIds: [ownerId]}); - }, + changeOwner({ itemId, ownerId }) { + return RestAPIUtil.put( + `${baseUrl()}/${itemId}/permissions/${permissionTypes.OWNER}`, + { removedUsersIds: [], addedUsersIds: [ownerId] } + ); + }, - async checkItemStatus(dispatch, {itemId, versionId}) { - const response = await ItemsHelper.fetchVersion({itemId, versionId}); - let state = response && response.state || {}; - const {baseId, description, id, name, status} = response; - const item = await ItemsHelper.fetchItem(itemId); - dispatch({ - type: onboardingActionTypes.UPDATE_ITEM_STATUS, - itemState: state, - itemStatus: response.status, - archivedStatus: item.status, - updatedVersion: {baseId, description, id, name, status} - }); + async checkItemStatus(dispatch, { itemId, versionId }) { + const response = await ItemsHelper.fetchVersion({ itemId, versionId }); + let state = (response && response.state) || {}; + const { baseId, description, id, name, status } = response; + const item = await ItemsHelper.fetchItem(itemId); + dispatch({ + type: onboardingActionTypes.UPDATE_ITEM_STATUS, + itemState: state, + itemStatus: response.status, + archivedStatus: item.status, + updatedVersion: { baseId, description, id, name, status } + }); - return Promise.resolve({...response, archivedStatus: item.status}); - }, + return Promise.resolve({ ...response, archivedStatus: item.status }); + }, - fetchItem(itemId) { - return restToggle({restFunction: () => RestAPIUtil.fetch(`${baseUrl()}/${itemId}`), featureName: featureToggleNames.ARCHIVE_ITEM, mockResult: {}}); - }, + fetchItem(itemId) { + return restToggle({ + restFunction: () => RestAPIUtil.fetch(`${baseUrl()}/${itemId}`), + featureName: featureToggleNames.ARCHIVE_ITEM, + mockResult: {} + }); + }, - archiveItem(itemId) { - return RestAPIUtil.put(`${baseUrl()}/${itemId}/actions`, { - action: archiveActions.ARCHIVE - }); - }, - restoreItem(itemId) { - return RestAPIUtil.put(`${baseUrl()}/${itemId}/actions`, { - action: archiveActions.RESTORE - }); - } + archiveItem(itemId) { + return RestAPIUtil.put(`${baseUrl()}/${itemId}/actions`, { + action: archiveActions.ARCHIVE + }); + }, + restoreItem(itemId) { + return RestAPIUtil.put(`${baseUrl()}/${itemId}/actions`, { + action: archiveActions.RESTORE + }); + } }; export default ItemsHelper; diff --git a/openecomp-ui/src/sdc-app/common/helpers/ScreensHelper.js b/openecomp-ui/src/sdc-app/common/helpers/ScreensHelper.js index 7c05f8456b..6f69cd0e51 100644 --- a/openecomp-ui/src/sdc-app/common/helpers/ScreensHelper.js +++ b/openecomp-ui/src/sdc-app/common/helpers/ScreensHelper.js @@ -1,225 +1,356 @@ -import {itemTypes} from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { itemTypes } from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js'; +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; -import {actionTypes as SoftwareProductActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { actionTypes as SoftwareProductActionTypes } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; import versionPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; const ScreensHelper = { - async loadScreen(dispatch, {screen, screenType, props}) { - if(screen === enums.SCREEN.ONBOARDING_CATALOG) { - OnboardingActionHelper.navigateToOnboardingCatalog(dispatch); - return; - } - - screenType = !screenType ? this.getScreenType(screen) : screenType; + async loadScreen(dispatch, { screen, screenType, props }) { + if (screen === enums.SCREEN.ONBOARDING_CATALOG) { + OnboardingActionHelper.navigateToOnboardingCatalog(dispatch); + return; + } - if(screenType === screenTypes.LICENSE_MODEL) { - const {licenseModelId, version, licenseModel, usersList} = props; - const item = await ItemsHelper.fetchItem(licenseModelId); - let itemStatusPromise = version && screen ? - ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}) : - Promise.resolve(); - itemStatusPromise.then((updatedVersion) => { - if (updatedVersion && updatedVersion.status !== version.status) { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data: { - title: i18n('Commit error'), - msg: i18n('Item version was certified by Owner'), - cancelButtonText: i18n('Cancel') - } - }); - versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: licenseModelId}); - } - let newVersion = updatedVersion ? updatedVersion : version; - const screenProps = {licenseModelId, version: newVersion, status: item.status}; - switch (screen) { - case enums.SCREEN.LICENSE_MODEL_OVERVIEW: - OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, screenProps); - break; - case enums.SCREEN.LICENSE_AGREEMENTS: - OnboardingActionHelper.navigateToLicenseAgreements(dispatch, screenProps); - break; - case enums.SCREEN.FEATURE_GROUPS: - OnboardingActionHelper.navigateToFeatureGroups(dispatch, screenProps); - break; - case enums.SCREEN.ENTITLEMENT_POOLS: - OnboardingActionHelper.navigateToEntitlementPools(dispatch, screenProps); - break; - case enums.SCREEN.LICENSE_KEY_GROUPS: - OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, screenProps); - break; - case enums.SCREEN.ACTIVITY_LOG: - OnboardingActionHelper.navigateToLicenseModelActivityLog(dispatch, screenProps); - break; - case enums.SCREEN.VERSIONS_PAGE: - default: - OnboardingActionHelper.navigateToVersionsPage(dispatch, { - itemId: licenseModelId, - itemType: itemTypes.LICENSE_MODEL, - itemName: licenseModel.name, - users: usersList - }); - break; - } - }); - } + screenType = !screenType ? this.getScreenType(screen) : screenType; - else if(screenType === screenTypes.SOFTWARE_PRODUCT) { - const {softwareProductId, componentId, version, softwareProduct, usersList} = props; - const item = await ItemsHelper.fetchItem(softwareProductId); - let itemStatusPromise = version && screen ? - ItemsHelper.checkItemStatus(dispatch, {itemId: softwareProductId, versionId: version.id}) : - Promise.resolve(); - itemStatusPromise.then((updatedVersion) => { - if (updatedVersion && updatedVersion.status !== version.status) { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data: { - title: i18n('Commit error'), - msg: i18n('Item version already Certified'), - cancelButtonText: i18n('Cancel') - } - }); - versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.SOFTWARE_PRODUCT, itemId: softwareProductId}); - } + if (screenType === screenTypes.LICENSE_MODEL) { + const { licenseModelId, version, licenseModel, usersList } = props; + const item = await ItemsHelper.fetchItem(licenseModelId); + let itemStatusPromise = + version && screen + ? ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }) + : Promise.resolve(); + itemStatusPromise.then(updatedVersion => { + if ( + updatedVersion && + updatedVersion.status !== version.status + ) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: i18n('Commit error'), + msg: i18n('Item version was certified by Owner'), + cancelButtonText: i18n('Cancel') + } + }); + versionPageActionHelper.fetchVersions(dispatch, { + itemType: itemTypes.LICENSE_MODEL, + itemId: licenseModelId + }); + } + let newVersion = updatedVersion ? updatedVersion : version; + const screenProps = { + licenseModelId, + version: newVersion, + status: item.status + }; + switch (screen) { + case enums.SCREEN.LICENSE_MODEL_OVERVIEW: + OnboardingActionHelper.navigateToLicenseModelOverview( + dispatch, + screenProps + ); + break; + case enums.SCREEN.LICENSE_AGREEMENTS: + OnboardingActionHelper.navigateToLicenseAgreements( + dispatch, + screenProps + ); + break; + case enums.SCREEN.FEATURE_GROUPS: + OnboardingActionHelper.navigateToFeatureGroups( + dispatch, + screenProps + ); + break; + case enums.SCREEN.ENTITLEMENT_POOLS: + OnboardingActionHelper.navigateToEntitlementPools( + dispatch, + screenProps + ); + break; + case enums.SCREEN.LICENSE_KEY_GROUPS: + OnboardingActionHelper.navigateToLicenseKeyGroups( + dispatch, + screenProps + ); + break; + case enums.SCREEN.ACTIVITY_LOG: + OnboardingActionHelper.navigateToLicenseModelActivityLog( + dispatch, + screenProps + ); + break; + case enums.SCREEN.VERSIONS_PAGE: + default: + OnboardingActionHelper.navigateToVersionsPage( + dispatch, + { + itemId: licenseModelId, + itemType: itemTypes.LICENSE_MODEL, + itemName: licenseModel.name, + users: usersList + } + ); + break; + } + }); + } else if (screenType === screenTypes.SOFTWARE_PRODUCT) { + const { + softwareProductId, + componentId, + version, + softwareProduct, + usersList + } = props; + const item = await ItemsHelper.fetchItem(softwareProductId); + let itemStatusPromise = + version && screen + ? ItemsHelper.checkItemStatus(dispatch, { + itemId: softwareProductId, + versionId: version.id + }) + : Promise.resolve(); + itemStatusPromise.then(updatedVersion => { + if ( + updatedVersion && + updatedVersion.status !== version.status + ) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: i18n('Commit error'), + msg: i18n('Item version already Certified'), + cancelButtonText: i18n('Cancel') + } + }); + versionPageActionHelper.fetchVersions(dispatch, { + itemType: itemTypes.SOFTWARE_PRODUCT, + itemId: softwareProductId + }); + } - let newVersion = updatedVersion ? updatedVersion : version; - - const props = { - softwareProductId, - componentId, - version: newVersion, - status: item.status - }; - if (screen === screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL) { - OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, props); - } - - switch (screen) { - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: - OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: - OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: - OnboardingActionHelper.navigateToComponentCompute(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: - OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: - OnboardingActionHelper.navigateToComponentNetwork(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: - OnboardingActionHelper.navigateToComponentStorage(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: - OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: - OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: - OnboardingActionHelper.navigateToComponentImages(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: - OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: - OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP: - OnboardingActionHelper.navigateToSoftwareProductAttachmentsSetupTab(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION: - OnboardingActionHelper.navigateToSoftwareProductAttachmentsValidationTab(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: - OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: - OnboardingActionHelper.navigateToSoftwareProductDeployment(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: - OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: - OnboardingActionHelper.navigateToSoftwareProductDependencies(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: - OnboardingActionHelper.navigateToSoftwareProductActivityLog(dispatch, props); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: - OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, props); - dispatch({ - type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, - mapOfExpandedIds: { - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: true - } - }); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE: - default: - OnboardingActionHelper.navigateToVersionsPage(dispatch, { - itemId: softwareProductId, - itemType: itemTypes.SOFTWARE_PRODUCT, - itemName: softwareProduct.name, - users: usersList, - additionalProps: { - licenseModelId: softwareProduct.vendorId, - licensingVersion: softwareProduct.licensingVersion - } - }); - break; - } - }); - } - }, + let newVersion = updatedVersion ? updatedVersion : version; - getScreenType(screen) { - switch (screen) { - case enums.SCREEN.LICENSE_MODEL_OVERVIEW: - case enums.SCREEN.LICENSE_AGREEMENTS: - case enums.SCREEN.FEATURE_GROUPS: - case enums.SCREEN.ENTITLEMENT_POOLS: - case enums.SCREEN.LICENSE_KEY_GROUPS: - case enums.SCREEN.ACTIVITY_LOG: - return screenTypes.LICENSE_MODEL; - case screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: - case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: - case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: - case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: - case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: - case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: - case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: - case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: - case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: - return screenTypes.SOFTWARE_PRODUCT; - } - }, + const props = { + softwareProductId, + componentId, + version: newVersion, + status: item.status + }; + if ( + screen === + screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL + ) { + OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel( + dispatch, + props + ); + } - loadLandingScreen(dispatch, {previousScreenName, screenType, props: {licenseModelId, softwareProductId, version}}) { - let selectedScreenType = screenType ? screenType : this.getScreenType(previousScreenName); - let screen = selectedScreenType === screenTypes.SOFTWARE_PRODUCT ? - enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE : - enums.SCREEN.LICENSE_MODEL_OVERVIEW; - let props = {licenseModelId, softwareProductId, version}; - return this.loadScreen(dispatch, {screen, screenType: selectedScreenType, props}); - } + switch (screen) { + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: + OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: + OnboardingActionHelper.navigateToSoftwareProductComponentGeneral( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: + OnboardingActionHelper.navigateToComponentCompute( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: + OnboardingActionHelper.navigateToComponentLoadBalancing( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: + OnboardingActionHelper.navigateToComponentNetwork( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: + OnboardingActionHelper.navigateToComponentStorage( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: + OnboardingActionHelper.navigateToSoftwareProductComponentProcesses( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: + OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: + OnboardingActionHelper.navigateToComponentImages( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: + OnboardingActionHelper.navigateToSoftwareProductLandingPage( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: + OnboardingActionHelper.navigateToSoftwareProductDetails( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP: + OnboardingActionHelper.navigateToSoftwareProductAttachmentsSetupTab( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION: + OnboardingActionHelper.navigateToSoftwareProductAttachmentsValidationTab( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: + OnboardingActionHelper.navigateToSoftwareProductProcesses( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: + OnboardingActionHelper.navigateToSoftwareProductDeployment( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: + OnboardingActionHelper.navigateToSoftwareProductNetworks( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: + OnboardingActionHelper.navigateToSoftwareProductDependencies( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: + OnboardingActionHelper.navigateToSoftwareProductActivityLog( + dispatch, + props + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: + OnboardingActionHelper.navigateToSoftwareProductComponents( + dispatch, + props + ); + dispatch({ + type: + SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, + mapOfExpandedIds: { + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: true + } + }); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE: + default: + OnboardingActionHelper.navigateToVersionsPage( + dispatch, + { + itemId: softwareProductId, + itemType: itemTypes.SOFTWARE_PRODUCT, + itemName: softwareProduct.name, + users: usersList, + additionalProps: { + licenseModelId: softwareProduct.vendorId, + licensingVersion: + softwareProduct.licensingVersion + } + } + ); + break; + } + }); + } + }, + + getScreenType(screen) { + switch (screen) { + case enums.SCREEN.LICENSE_MODEL_OVERVIEW: + case enums.SCREEN.LICENSE_AGREEMENTS: + case enums.SCREEN.FEATURE_GROUPS: + case enums.SCREEN.ENTITLEMENT_POOLS: + case enums.SCREEN.LICENSE_KEY_GROUPS: + case enums.SCREEN.ACTIVITY_LOG: + return screenTypes.LICENSE_MODEL; + case screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: + case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: + case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: + case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: + case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: + case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: + case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: + case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: + case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: + return screenTypes.SOFTWARE_PRODUCT; + } + }, + + loadLandingScreen( + dispatch, + { + previousScreenName, + screenType, + props: { licenseModelId, softwareProductId, version } + } + ) { + let selectedScreenType = screenType + ? screenType + : this.getScreenType(previousScreenName); + let screen = + selectedScreenType === screenTypes.SOFTWARE_PRODUCT + ? enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE + : enums.SCREEN.LICENSE_MODEL_OVERVIEW; + let props = { licenseModelId, softwareProductId, version }; + return this.loadScreen(dispatch, { + screen, + screenType: selectedScreenType, + props + }); + } }; export default ScreensHelper; diff --git a/openecomp-ui/src/sdc-app/common/helpers/ValidationHelper.js b/openecomp-ui/src/sdc-app/common/helpers/ValidationHelper.js index cfa675278f..aa578c6692 100644 --- a/openecomp-ui/src/sdc-app/common/helpers/ValidationHelper.js +++ b/openecomp-ui/src/sdc-app/common/helpers/ValidationHelper.js @@ -13,80 +13,85 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes as commonActionTypes} from 'sdc-app/common/reducers/PlainDataReducerConstants.js'; -import {actionTypes as qcommonActionTypes} from 'sdc-app/common/reducers/JSONSchemaReducerConstants.js'; +import { actionTypes as commonActionTypes } from 'sdc-app/common/reducers/PlainDataReducerConstants.js'; +import { actionTypes as qcommonActionTypes } from 'sdc-app/common/reducers/JSONSchemaReducerConstants.js'; class ValidationHelper { + static dataChanged( + dispatch, + { deltaData, formName, customValidations = {} } + ) { + dispatch({ + type: commonActionTypes.DATA_CHANGED, + deltaData, + formName, + customValidations + }); + } - static dataChanged(dispatch, {deltaData, formName, customValidations = {}}){ - dispatch({ - type: commonActionTypes.DATA_CHANGED, - deltaData, - formName, - customValidations - }); - } + static validateForm(dispatch, formName) { + dispatch({ + type: commonActionTypes.VALIDATE_FORM, + formName + }); + } - static validateForm(dispatch, formName){ - dispatch({ - type: commonActionTypes.VALIDATE_FORM, - formName - }); - } + static validateData(dispatch, { formName, data }) { + dispatch({ + type: commonActionTypes.VALIDATE_DATA, + formName, + data + }); + } - static validateData(dispatch, {formName, data}) { - dispatch({ - type: commonActionTypes.VALIDATE_DATA, - formName, - data - }); - } + static qValidateData(dispatch, { data, qName, customValidations = {} }) { + dispatch({ + type: qcommonActionTypes.VALIDATE_DATA, + data, + qName, + customValidations + }); + } - static qValidateData(dispatch, {data, qName, customValidations = {}}) { - dispatch({ - type: qcommonActionTypes.VALIDATE_DATA, - data, - qName, - customValidations - }); - } + static qValidateForm(dispatch, qName, customValidations) { + dispatch({ + type: qcommonActionTypes.VALIDATE_FORM, + qName, + customValidations + }); + } - static qValidateForm(dispatch, qName, customValidations){ - dispatch({ - type: qcommonActionTypes.VALIDATE_FORM, - qName, - customValidations - }); - } + static qDataChanged( + dispatch, + { deltaData, qName, customValidations = {} } + ) { + dispatch({ + type: qcommonActionTypes.DATA_CHANGED, + deltaData, + qName, + customValidations + }); + } - static qDataChanged(dispatch, {deltaData, qName, customValidations = {}}){ - dispatch({ - type: qcommonActionTypes.DATA_CHANGED, - deltaData, - qName, - customValidations - }); - } + static qDataLoaded(dispatch, { qName, response: { qdata, qschema } }) { + dispatch({ + type: qcommonActionTypes.DATA_LOADED, + payload: { + qdata, + qschema + }, + qName + }); + } - static qDataLoaded(dispatch, {qName, response: {qdata, qschema}}) { - dispatch({ - type: qcommonActionTypes.DATA_LOADED, - payload: { - qdata, - qschema - }, - qName - }); - } - - static checkFormValid(genericFieldInfo) { - for (let field in genericFieldInfo) { - if (!genericFieldInfo[field].isValid) { - return false; - } - } - return true; - } + static checkFormValid(genericFieldInfo) { + for (let field in genericFieldInfo) { + if (!genericFieldInfo[field].isValid) { + return false; + } + } + return true; + } } export default ValidationHelper; diff --git a/openecomp-ui/src/sdc-app/common/merge/MergeEditor.js b/openecomp-ui/src/sdc-app/common/merge/MergeEditor.js index baf00cf0cf..81f7174623 100644 --- a/openecomp-ui/src/sdc-app/common/merge/MergeEditor.js +++ b/openecomp-ui/src/sdc-app/common/merge/MergeEditor.js @@ -13,25 +13,42 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import MergeEditorView from './MergeEditorView.jsx'; import MergeEditorActionHelper from './MergeEditorActionHelper.js'; -export const mapStateToProps = ({mergeEditor, currentScreen}) => { - let {props} = currentScreen; - let item = { - id: props.softwareProductId || props.licenseModelId, - version: props.version - }; - return {...mergeEditor, item, currentScreen}; +export const mapStateToProps = ({ mergeEditor, currentScreen }) => { + let { props } = currentScreen; + let item = { + id: props.softwareProductId || props.licenseModelId, + version: props.version + }; + return { ...mergeEditor, item, currentScreen }; }; -export const mapActionsToProps = (dispatch) => { - return { - fetchConflict: ({cid, itemId, version}) => MergeEditorActionHelper.fetchConflict(dispatch, {itemId, version, cid}), - onResolveConflict: ({conflictId, resolution, itemId, version, currentScreen}) => - MergeEditorActionHelper.resolveConflict(dispatch, {itemId, version, conflictId, resolution, currentScreen}) - }; +export const mapActionsToProps = dispatch => { + return { + fetchConflict: ({ cid, itemId, version }) => + MergeEditorActionHelper.fetchConflict(dispatch, { + itemId, + version, + cid + }), + onResolveConflict: ({ + conflictId, + resolution, + itemId, + version, + currentScreen + }) => + MergeEditorActionHelper.resolveConflict(dispatch, { + itemId, + version, + conflictId, + resolution, + currentScreen + }) + }; }; export default connect(mapStateToProps, mapActionsToProps)(MergeEditorView); diff --git a/openecomp-ui/src/sdc-app/common/merge/MergeEditorActionHelper.js b/openecomp-ui/src/sdc-app/common/merge/MergeEditorActionHelper.js index 92ec60b999..c54b9feb93 100644 --- a/openecomp-ui/src/sdc-app/common/merge/MergeEditorActionHelper.js +++ b/openecomp-ui/src/sdc-app/common/merge/MergeEditorActionHelper.js @@ -13,431 +13,532 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, rules, dataRules, SyncStates} from './MergeEditorConstants.js'; +import { + actionTypes, + rules, + dataRules, + SyncStates +} from './MergeEditorConstants.js'; import cloneDeep from 'lodash/cloneDeep.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import ItemsHelper from '../../common/helpers/ItemsHelper.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {optionsInputValues as epOptionsValues} from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js'; -import {optionsInputValues as laOptionsValues} from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js'; -import {optionsInputValues as processOptionValues} from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesConstants.js'; -import {selectValues as limitSelectValues} from 'sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js'; +import { optionsInputValues as epOptionsValues } from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js'; +import { optionsInputValues as laOptionsValues } from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js'; +import { optionsInputValues as processOptionValues } from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesConstants.js'; +import { selectValues as limitSelectValues } from 'sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js'; import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js'; import LicenseAgreementActionHelper from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js'; import moment from 'moment'; -import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { DATE_FORMAT } from 'sdc-app/onboarding/OnboardingConstants.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; function softwareProductCategoriesUrl() { - const restCatalogPrefix = Configuration.get('restCatalogPrefix'); - return `${restCatalogPrefix}/v1/categories/resources/`; + const restCatalogPrefix = Configuration.get('restCatalogPrefix'); + return `${restCatalogPrefix}/v1/categories/resources/`; } function versionUrl(itemId, versionId) { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/items/${itemId}/versions/${versionId}`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/items/${itemId}/versions/${versionId}`; } function baseUrl(itemId, version, conflictId) { - const versionId = version.id; - const restPrefix = Configuration.get('restPrefix'); - let baseUrl = `${restPrefix}/v1.0/items/${itemId}/versions/${versionId}/conflicts`; - return conflictId ? `${baseUrl}/${conflictId}` : baseUrl; + const versionId = version.id; + const restPrefix = Configuration.get('restPrefix'); + let baseUrl = `${restPrefix}/v1.0/items/${itemId}/versions/${versionId}/conflicts`; + return conflictId ? `${baseUrl}/${conflictId}` : baseUrl; } -function fetchConflicts({itemId, version}) { - return RestAPIUtil.fetch(`${baseUrl(itemId, version)}`); +function fetchConflicts({ itemId, version }) { + return RestAPIUtil.fetch(`${baseUrl(itemId, version)}`); } -function fetchConflictById({itemId, version, cid}) { - return RestAPIUtil.fetch(`${baseUrl(itemId, version, cid)}`); +function fetchConflictById({ itemId, version, cid }) { + return RestAPIUtil.fetch(`${baseUrl(itemId, version, cid)}`); } -function resolveConflict({itemId, version, conflictId, resolution}) { - return RestAPIUtil.put(`${baseUrl(itemId, version, conflictId)}`, {resolution}); +function resolveConflict({ itemId, version, conflictId, resolution }) { + return RestAPIUtil.put(`${baseUrl(itemId, version, conflictId)}`, { + resolution + }); } function fetchCategories() { - return RestAPIUtil.fetch(softwareProductCategoriesUrl()); + return RestAPIUtil.fetch(softwareProductCategoriesUrl()); } -function fetchVersion({vendorId, licensingVersion}) { - return RestAPIUtil.fetch(versionUrl(vendorId, licensingVersion)); +function fetchVersion({ vendorId, licensingVersion }) { + return RestAPIUtil.fetch(versionUrl(vendorId, licensingVersion)); } -function createCategoryStr(data, {categories}) { - - let {category, subCategory} = data; - let foundCat = categories.find(element => element.uniqueId === category); - if (!foundCat) { return ''; } - - let catName = foundCat.name; - let foundSub = foundCat.subcategories.find(element => element.uniqueId === subCategory); - if (!foundSub) { return `${catName}`; } - - let subcatName = foundSub.name; - return `${catName} - ${subcatName}`; - +function createCategoryStr(data, { categories }) { + let { category, subCategory } = data; + let foundCat = categories.find(element => element.uniqueId === category); + if (!foundCat) { + return ''; + } + + let catName = foundCat.name; + let foundSub = foundCat.subcategories.find( + element => element.uniqueId === subCategory + ); + if (!foundSub) { + return `${catName}`; + } + + let subcatName = foundSub.name; + return `${catName} - ${subcatName}`; } -function getEnumValues({enums, list}) { - - if (!list) { return ''; } - return list.map(item => enums.find(el => el.enum === item).title); - +function getEnumValues({ enums, list }) { + if (!list) { + return ''; + } + return list.map(item => enums.find(el => el.enum === item).title); } const MergeEditorActionHelper = { - - analyzeSyncResult(dispatch, {itemId, version}) { - return ItemsHelper.checkItemStatus(dispatch, {itemId, versionId: version.id}).then((response) => { - let inMerge = response && response.state && response.state.synchronizationState === SyncStates.MERGE; - if (inMerge) { - MergeEditorActionHelper.fetchConflicts(dispatch, {itemId, version}).then(() => - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.MERGE_EDITOR, - modalClassName: 'merge-editor-modal', - title: `${i18n('Merge Required')} - ${version.description}`, - onDeclined: () => { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - }, - modalComponentProps: { - size: 'lg', - type: 'default' - } - } - }) - ); - } - return Promise.resolve({updatedVersion: response, inMerge, isDirty: response.state.dirty}); - }); - }, - - fetchConflicts(dispatch, {itemId, version}) { - return fetchConflicts({itemId, version}).then( - (data) => { - dispatch({ - type: actionTypes.LOAD_CONFLICTS, - data - }); - return data; - } - ); - }, - - fetchConflict(dispatch, {itemId, version, cid}) { - fetchConflictById({itemId, version, cid}).then( - (data) => { - let newData = {}; - newData = MergeEditorActionHelper.processConflict(dispatch, {conflict: data, itemId, cid, version}); - dispatch({ - type: actionTypes.LOAD_CONFLICT, - data: newData - }); - } - ); - }, - - resolveConflict(dispatch, {itemId, version, conflictId, resolution, currentScreen}) { - resolveConflict({itemId, version, conflictId, resolution}).then(() => { - MergeEditorActionHelper.fetchConflicts(dispatch, {itemId, version}).then(conflicts => { - if(conflicts.conflictInfoList && conflicts.conflictInfoList.length === 0) { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - ScreensHelper.loadLandingScreen(dispatch, {previousScreenName: currentScreen.screen, props: currentScreen.props}); - ItemsHelper.checkItemStatus(dispatch, {itemId, versionId: version.id}); - } - }); - }); - }, - - createConflictObject(data, {cid, conflict, dispatch, itemId, version, isYours}) { - - let newData = {}; - - for (let key in data) { - - if (data.hasOwnProperty(key)) { - let value = data[key]; - let fieldRule = dataRules[conflict.type] && dataRules[conflict.type][key] || dataRules.general[key]; - - if (fieldRule) { - switch (fieldRule.rule) { - - case rules.SKIP: - break; - - case rules.BOOLEAN: - let {trueValue, falseValue} = fieldRule; - newData[key] = value === trueValue ? true : value === falseValue ? false : undefined; - break; - - case rules.PARSE: - let {moveFields, subFields} = fieldRule; - if (moveFields) { - let fields = subFields || Object.keys(value); - fields.forEach(field => { - newData[field] = MergeEditorActionHelper.createConflictObject( - value[field], {cid, conflict, dispatch, itemId, version, isYours} - ); - }); - } else { - newData[key] = MergeEditorActionHelper.createConflictObject( - value, {cid, conflict, dispatch, itemId, version, isYours} - ); - } - break; - - case rules.FUNCTION: - let {args, functionName} = fieldRule; - newData[key] = MergeEditorActionHelper[functionName](data, { - cid, conflict, dispatch, version, fieldName: key, isYours, itemId, args - }); - break; - - default: - newData[key] = value; - break; - } - - } else { - newData[key] = value; - - } - } - } - - return newData; - - }, - - getNamesFromIDs(data, {version, cid, dispatch, itemId, fieldName, isYours, args}) { - - let idList = data[fieldName] || []; - let {fetchFunction, fetchField} = args; - - let promises = idList.map(id => - new Promise(resolve => - MergeEditorActionHelper[fetchFunction]( - dispatch, {licenseModelId: itemId, [fetchField]: id, version} - ).then(item => resolve(item.name)) - ) - ); - - Promise.all(promises).then(fetchedItems => { - let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; - dispatch({ - type: actionTypes.DATA_PROCESSED, - data: { - cid, - [yoursOrTheirs]: { name: fieldName, value: fetchedItems } - } - }); - }); - - return idList; - - }, - - getFeatureGroups(data, {version, cid, dispatch, itemId, fieldName, isYours}) { - - let featureGroups = data[fieldName] || []; - if (!(featureGroups instanceof Array)) { - featureGroups = [featureGroups]; - } - - let promises = featureGroups.map(featureGroupId => - new Promise(resolve => - FeatureGroupsActionHelper.fetchFeatureGroup( - dispatch, {licenseModelId: itemId, featureGroupId, version} - ).then(featureGroup => resolve(featureGroup.name)) - .catch(reason => console.log(`getFeatureGroups Promise rejected ('${reason}')`)) - ) - ); - - Promise.all(promises).then(fetchedGroups => { - let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; - dispatch({ - type: actionTypes.DATA_PROCESSED, - data: { - cid, - [yoursOrTheirs]: { name: fieldName, value: fetchedGroups } - } - }); - }); - - return featureGroups; - - }, - - getLicenseAgreements(data, {version, cid, dispatch, itemId, fieldName, isYours}) { - - let licenseAgreements = data[fieldName] || []; - if (!(licenseAgreements instanceof Array)) { - licenseAgreements = [licenseAgreements]; - } - - let promises = licenseAgreements.map(licenseAgreementId => - new Promise(resolve => - LicenseAgreementActionHelper.fetchLicenseAgreement( - dispatch, {licenseModelId: itemId, licenseAgreementId, version} - ).then(licenseAgreement => resolve(licenseAgreement.name)) - .catch(reason => console.log(`getLicenseAgreements Promise rejected ('${reason}')`)) - ) - ); - - Promise.all(promises).then(fetchedAgreements => { - let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; - dispatch({ - type: actionTypes.DATA_PROCESSED, - data: { - cid, - [yoursOrTheirs]: { name: fieldName, value: fetchedAgreements } - } - }); - }); - - return licenseAgreements; - - }, - - processConflict(dispatch, {conflict, cid, version, itemId,}) { - - let {id, type, yours, theirs} = conflict; - - let newYours = MergeEditorActionHelper.createConflictObject( - cloneDeep(yours), {cid, conflict, dispatch, itemId, version, isYours: true} - ); - let newTheirs = MergeEditorActionHelper.createConflictObject( - cloneDeep(theirs), {cid, conflict, dispatch, itemId, version, isYours: false} - ); - - return { - id, - type, - yours: newYours, - theirs: newTheirs - }; - - }, - - reduceList(data, {fieldName, args}) { - - let {subField} = args; - return data[fieldName].map(el => el[subField]); - - }, - - getEnumList({fieldName}) { - - const enumLists = { - 'licenseTerm': laOptionsValues.LICENSE_MODEL_TYPE, - 'operationalScope': epOptionsValues.OPERATIONAL_SCOPE, - 'processType': processOptionValues.PROCESS_TYPE, - 'limitType': [ - {title: 'Service Provider', enum: 'ServiceProvider'}, - {title: 'Vendor', enum: 'Vendor'} - ], - 'limitUnit': limitSelectValues.UNIT - }; - - return enumLists[fieldName]; - - }, - - getEnumValue(data, {fieldName, args = {}}) { - - let value = data[fieldName]; - let enumValues = MergeEditorActionHelper.getEnumList({fieldName: args.listName || fieldName}); - let enumValue = enumValues.find(el => el.enum === value); - - return enumValue && enumValue.title || value; - - }, - - processChoice(data, {fieldName, args = {}}) { - - let value = data[fieldName]; - let enumValues = MergeEditorActionHelper.getEnumList({fieldName: args.listName || fieldName}); - let newValue = value.other || enumValues && enumValues.find(el => el.enum === value.choice).title || value.choice; - - return newValue; - - }, - - processChoices(data, {fieldName, args = {}}) { - - let value = data[fieldName]; - let enumValues = MergeEditorActionHelper.getEnumList({fieldName: args.listName || fieldName}); - let newValue = value.other || getEnumValues({enums: enumValues, list: value.choices}) || value.choices; - - return newValue; - - }, - - convertArrayToObject(data, {fieldName}) { - let value = data[fieldName]; - let newValue = {}; - value.forEach((el, index) => { - newValue[index] = el; - }); - return newValue; - }, - - fetchCategory(data, {cid, isYours, fieldName, dispatch}) { - - fetchCategories().then((categories) => { - let value = createCategoryStr(data, {categories}); - let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; - - dispatch({ - type: actionTypes.DATA_PROCESSED, - data: { - cid, - [yoursOrTheirs]: { name: fieldName, value } - } - }); - - }); - }, - - fetchLMVersion(data, {cid, dispatch, isYours}) { - - let {licensingVersion, vendorId} = data; - let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; - - if (licensingVersion) { - fetchVersion({licensingVersion, vendorId}).then(response => { - dispatch({ - type: actionTypes.DATA_PROCESSED, - data: { - cid, - [yoursOrTheirs]: { - name: 'licensingVersion', - value: response.name - } - } - }); - }); - } - - }, - - parseDate(data, {fieldName}) { - - let date = data[fieldName]; - return date && moment(date, DATE_FORMAT).format(DATE_FORMAT); - - } - + analyzeSyncResult(dispatch, { itemId, version }) { + return ItemsHelper.checkItemStatus(dispatch, { + itemId, + versionId: version.id + }).then(response => { + let inMerge = + response && + response.state && + response.state.synchronizationState === SyncStates.MERGE; + if (inMerge) { + MergeEditorActionHelper.fetchConflicts(dispatch, { + itemId, + version + }).then(() => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.MERGE_EDITOR, + modalClassName: 'merge-editor-modal', + title: `${i18n('Merge Required')} - ${ + version.description + }`, + onDeclined: () => { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + }, + modalComponentProps: { + size: 'lg', + type: 'default' + } + } + }) + ); + } + return Promise.resolve({ + updatedVersion: response, + inMerge, + isDirty: response.state.dirty + }); + }); + }, + + fetchConflicts(dispatch, { itemId, version }) { + return fetchConflicts({ itemId, version }).then(data => { + dispatch({ + type: actionTypes.LOAD_CONFLICTS, + data + }); + return data; + }); + }, + + fetchConflict(dispatch, { itemId, version, cid }) { + fetchConflictById({ itemId, version, cid }).then(data => { + let newData = {}; + newData = MergeEditorActionHelper.processConflict(dispatch, { + conflict: data, + itemId, + cid, + version + }); + dispatch({ + type: actionTypes.LOAD_CONFLICT, + data: newData + }); + }); + }, + + resolveConflict( + dispatch, + { itemId, version, conflictId, resolution, currentScreen } + ) { + resolveConflict({ itemId, version, conflictId, resolution }).then( + () => { + MergeEditorActionHelper.fetchConflicts(dispatch, { + itemId, + version + }).then(conflicts => { + if ( + conflicts.conflictInfoList && + conflicts.conflictInfoList.length === 0 + ) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + ScreensHelper.loadLandingScreen(dispatch, { + previousScreenName: currentScreen.screen, + props: currentScreen.props + }); + ItemsHelper.checkItemStatus(dispatch, { + itemId, + versionId: version.id + }); + } + }); + } + ); + }, + + createConflictObject( + data, + { cid, conflict, dispatch, itemId, version, isYours } + ) { + let newData = {}; + + for (let key in data) { + if (data.hasOwnProperty(key)) { + let value = data[key]; + let fieldRule = + (dataRules[conflict.type] && + dataRules[conflict.type][key]) || + dataRules.general[key]; + + if (fieldRule) { + switch (fieldRule.rule) { + case rules.SKIP: + break; + + case rules.BOOLEAN: + let { trueValue, falseValue } = fieldRule; + newData[key] = + value === trueValue + ? true + : value === falseValue ? false : undefined; + break; + + case rules.PARSE: + let { moveFields, subFields } = fieldRule; + if (moveFields) { + let fields = subFields || Object.keys(value); + fields.forEach(field => { + newData[ + field + ] = MergeEditorActionHelper.createConflictObject( + value[field], + { + cid, + conflict, + dispatch, + itemId, + version, + isYours + } + ); + }); + } else { + newData[ + key + ] = MergeEditorActionHelper.createConflictObject( + value, + { + cid, + conflict, + dispatch, + itemId, + version, + isYours + } + ); + } + break; + + case rules.FUNCTION: + let { args, functionName } = fieldRule; + newData[key] = MergeEditorActionHelper[ + functionName + ](data, { + cid, + conflict, + dispatch, + version, + fieldName: key, + isYours, + itemId, + args + }); + break; + + default: + newData[key] = value; + break; + } + } else { + newData[key] = value; + } + } + } + + return newData; + }, + + getNamesFromIDs( + data, + { version, cid, dispatch, itemId, fieldName, isYours, args } + ) { + let idList = data[fieldName] || []; + let { fetchFunction, fetchField } = args; + + let promises = idList.map( + id => + new Promise(resolve => + MergeEditorActionHelper[fetchFunction](dispatch, { + licenseModelId: itemId, + [fetchField]: id, + version + }).then(item => resolve(item.name)) + ) + ); + + Promise.all(promises).then(fetchedItems => { + let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; + dispatch({ + type: actionTypes.DATA_PROCESSED, + data: { + cid, + [yoursOrTheirs]: { name: fieldName, value: fetchedItems } + } + }); + }); + + return idList; + }, + + getFeatureGroups( + data, + { version, cid, dispatch, itemId, fieldName, isYours } + ) { + let featureGroups = data[fieldName] || []; + if (!(featureGroups instanceof Array)) { + featureGroups = [featureGroups]; + } + + let promises = featureGroups.map( + featureGroupId => + new Promise(resolve => + FeatureGroupsActionHelper.fetchFeatureGroup(dispatch, { + licenseModelId: itemId, + featureGroupId, + version + }) + .then(featureGroup => resolve(featureGroup.name)) + .catch(reason => + console.log( + `getFeatureGroups Promise rejected ('${reason}')` + ) + ) + ) + ); + + Promise.all(promises).then(fetchedGroups => { + let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; + dispatch({ + type: actionTypes.DATA_PROCESSED, + data: { + cid, + [yoursOrTheirs]: { name: fieldName, value: fetchedGroups } + } + }); + }); + + return featureGroups; + }, + + getLicenseAgreements( + data, + { version, cid, dispatch, itemId, fieldName, isYours } + ) { + let licenseAgreements = data[fieldName] || []; + if (!(licenseAgreements instanceof Array)) { + licenseAgreements = [licenseAgreements]; + } + + let promises = licenseAgreements.map( + licenseAgreementId => + new Promise(resolve => + LicenseAgreementActionHelper.fetchLicenseAgreement( + dispatch, + { + licenseModelId: itemId, + licenseAgreementId, + version + } + ) + .then(licenseAgreement => + resolve(licenseAgreement.name) + ) + .catch(reason => + console.log( + `getLicenseAgreements Promise rejected ('${reason}')` + ) + ) + ) + ); + + Promise.all(promises).then(fetchedAgreements => { + let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; + dispatch({ + type: actionTypes.DATA_PROCESSED, + data: { + cid, + [yoursOrTheirs]: { + name: fieldName, + value: fetchedAgreements + } + } + }); + }); + + return licenseAgreements; + }, + + processConflict(dispatch, { conflict, cid, version, itemId }) { + let { id, type, yours, theirs } = conflict; + + let newYours = MergeEditorActionHelper.createConflictObject( + cloneDeep(yours), + { cid, conflict, dispatch, itemId, version, isYours: true } + ); + let newTheirs = MergeEditorActionHelper.createConflictObject( + cloneDeep(theirs), + { cid, conflict, dispatch, itemId, version, isYours: false } + ); + + return { + id, + type, + yours: newYours, + theirs: newTheirs + }; + }, + + reduceList(data, { fieldName, args }) { + let { subField } = args; + return data[fieldName].map(el => el[subField]); + }, + + getEnumList({ fieldName }) { + const enumLists = { + licenseTerm: laOptionsValues.LICENSE_MODEL_TYPE, + operationalScope: epOptionsValues.OPERATIONAL_SCOPE, + processType: processOptionValues.PROCESS_TYPE, + limitType: [ + { title: 'Service Provider', enum: 'ServiceProvider' }, + { title: 'Vendor', enum: 'Vendor' } + ], + limitUnit: limitSelectValues.UNIT + }; + + return enumLists[fieldName]; + }, + + getEnumValue(data, { fieldName, args = {} }) { + let value = data[fieldName]; + let enumValues = MergeEditorActionHelper.getEnumList({ + fieldName: args.listName || fieldName + }); + let enumValue = enumValues.find(el => el.enum === value); + + return (enumValue && enumValue.title) || value; + }, + + processChoice(data, { fieldName, args = {} }) { + let value = data[fieldName]; + let enumValues = MergeEditorActionHelper.getEnumList({ + fieldName: args.listName || fieldName + }); + let newValue = + value.other || + (enumValues && + enumValues.find(el => el.enum === value.choice).title) || + value.choice; + + return newValue; + }, + + processChoices(data, { fieldName, args = {} }) { + let value = data[fieldName]; + let enumValues = MergeEditorActionHelper.getEnumList({ + fieldName: args.listName || fieldName + }); + let newValue = + value.other || + getEnumValues({ enums: enumValues, list: value.choices }) || + value.choices; + + return newValue; + }, + + convertArrayToObject(data, { fieldName }) { + let value = data[fieldName]; + let newValue = {}; + value.forEach((el, index) => { + newValue[index] = el; + }); + return newValue; + }, + + fetchCategory(data, { cid, isYours, fieldName, dispatch }) { + fetchCategories().then(categories => { + let value = createCategoryStr(data, { categories }); + let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; + + dispatch({ + type: actionTypes.DATA_PROCESSED, + data: { + cid, + [yoursOrTheirs]: { name: fieldName, value } + } + }); + }); + }, + + fetchLMVersion(data, { cid, dispatch, isYours }) { + let { licensingVersion, vendorId } = data; + let yoursOrTheirs = isYours ? 'yoursField' : 'theirsField'; + + if (licensingVersion) { + fetchVersion({ licensingVersion, vendorId }).then(response => { + dispatch({ + type: actionTypes.DATA_PROCESSED, + data: { + cid, + [yoursOrTheirs]: { + name: 'licensingVersion', + value: response.name + } + } + }); + }); + } + }, + + parseDate(data, { fieldName }) { + let date = data[fieldName]; + return date && moment(date, DATE_FORMAT).format(DATE_FORMAT); + } }; export default MergeEditorActionHelper; diff --git a/openecomp-ui/src/sdc-app/common/merge/MergeEditorConstants.js b/openecomp-ui/src/sdc-app/common/merge/MergeEditorConstants.js index f7f6d4195e..b82d08683f 100644 --- a/openecomp-ui/src/sdc-app/common/merge/MergeEditorConstants.js +++ b/openecomp-ui/src/sdc-app/common/merge/MergeEditorConstants.js @@ -17,208 +17,205 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - LOAD_CONFLICTS: null, - ADD_ACTIONS: null, - LOAD_CONFLICT: null, - DATA_PROCESSED: null + LOAD_CONFLICTS: null, + ADD_ACTIONS: null, + LOAD_CONFLICT: null, + DATA_PROCESSED: null }); export const rules = { - SKIP: 'skip', - PARSE: 'parse', - FUNCTION: 'function', - BOOLEAN: 'boolean' + SKIP: 'skip', + PARSE: 'parse', + FUNCTION: 'function', + BOOLEAN: 'boolean' }; export const SyncStates = { - MERGE : 'Merging', - OUT_OF_SYNC: 'OutOfSync', - UP_TO_DATE: 'UpToDate' + MERGE: 'Merging', + OUT_OF_SYNC: 'OutOfSync', + UP_TO_DATE: 'UpToDate' }; export const ResolutionTypes = { - YOURS: 'YOURS', - THEIRS: 'THEIRS' + YOURS: 'YOURS', + THEIRS: 'THEIRS' }; export const fileTypes = { - LKG : 'LicenseKeyGroup', - VLM : 'VendorLicenseModel', - EP : 'EntitlementPool', - FG : 'FeatureGroup', - LA : 'LicenseAgreement', - VSP : 'VendorSoftwareProduct', - LIMIT : 'Limit', - VSP_Q : 'VSPQuestionnaire', - COMPONENT : 'Component', - COMPONENT_Q : 'ComponentQuestionnaire', - COMPONENT_DEP : 'ComponentDependencies', - COMPUTE_Q : 'ComputeQuestionnaire', - COMPUTE : 'Compute', - COMPUTE_FLAVOR: 'ComputeFlavor', - NIC : 'Nic', - NIC_Q : 'NicQuestionnaire', - IMAGE : 'Image', - IMAGE_Q : 'ImageQuestionnaire', - PROCESS : 'Process', - DEPLOYMENT_FLAVOR : 'DeploymentFlavor', - VENDOR : 'Vendor', - NETWORK : 'Network', - ORCHESTRATION_TEMPLATE_CANDIDATE : 'OrchestrationTemplateCandidate' + LKG: 'LicenseKeyGroup', + VLM: 'VendorLicenseModel', + EP: 'EntitlementPool', + FG: 'FeatureGroup', + LA: 'LicenseAgreement', + VSP: 'VendorSoftwareProduct', + LIMIT: 'Limit', + VSP_Q: 'VSPQuestionnaire', + COMPONENT: 'Component', + COMPONENT_Q: 'ComponentQuestionnaire', + COMPONENT_DEP: 'ComponentDependencies', + COMPUTE_Q: 'ComputeQuestionnaire', + COMPUTE: 'Compute', + COMPUTE_FLAVOR: 'ComputeFlavor', + NIC: 'Nic', + NIC_Q: 'NicQuestionnaire', + IMAGE: 'Image', + IMAGE_Q: 'ImageQuestionnaire', + PROCESS: 'Process', + DEPLOYMENT_FLAVOR: 'DeploymentFlavor', + VENDOR: 'Vendor', + NETWORK: 'Network', + ORCHESTRATION_TEMPLATE_CANDIDATE: 'OrchestrationTemplateCandidate' }; export const dataRules = { - general: { - id: { - rule: rules.SKIP - }, - questionareData: { - rule: rules.PARSE, - moveFields: true - }, - startDate: { - rule: rules.FUNCTION, - functionName: 'parseDate' - }, - expiryDate: { - rule: rules.FUNCTION, - functionName: 'parseDate' - }, - featureGroups: { - rule: rules.FUNCTION, - functionName: 'reduceList', - args: {subField: 'name'} - }, - licenseKeyGroups: { - rule: rules.FUNCTION, - functionName: 'reduceList', - args: {subField: 'name'} - }, - entitlementPools: { - rule: rules.FUNCTION, - functionName: 'reduceList', - args: {subField: 'name'} - }, - }, - [fileTypes.COMPONENT] : { - }, - [fileTypes.COMPUTE_FLAVOR] : { - associatedToDeploymentFlavor: { - rule: rules.BOOLEAN, - trueValue: 'true' - } - }, - [fileTypes.COMPUTE_Q] : { - }, - [fileTypes.COMPONENT_Q] : { - isComponentMandatory: { - rule: rules.BOOLEAN, - trueValue: 'YES', - falseValue: 'NO' - } - }, - [fileTypes.EP] : { - referencingFeatureGroups: { - rule: rules.SKIP, - functionName: 'getFeatureGroups' - }, - operationalScope: { - rule: rules.FUNCTION, - functionName: 'processChoices' - }, - }, - [fileTypes.FG] : { - referencingLicenseAgreements: { - rule: rules.SKIP, - functionName: 'getLicenseAgreements' - } - }, - [fileTypes.LA] : { - licenseTerm : { - rule: rules.FUNCTION, - functionName: 'processChoice' - } - }, - [fileTypes.LIMIT] : { - type: { - rule: rules.FUNCTION, - functionName: 'getEnumValue', - args: {listName: 'limitType'} - }, - unit: { - rule: rules.FUNCTION, - functionName: 'getEnumValue', - args: {listName: 'limitUnit'} - } - }, - [fileTypes.LKG] : { - operationalScope: { - rule: rules.FUNCTION, - functionName: 'processChoices' - }, - referencingFeatureGroups: { - rule: rules.SKIP, - functionName: 'getFeatureGroups' - }, - }, - [fileTypes.NIC] : { - networkId: { - rule: rules.SKIP - } - }, - [fileTypes.NIC_Q] : { - }, - [fileTypes.PROCESS] : { - type: { - rule: rules.FUNCTION, - functionName: 'getEnumValue', - args: {listName: 'processType'} - } - }, - [fileTypes.VLM] : { - iconRef: { - rule: rules.SKIP - } - }, - [fileTypes.VSP] : { - vendorId: { - rule: rules.SKIP - }, - onboardingMethod: { - rule: rules.SKIP - }, - validationData: { - rule: rules.SKIP - }, - isOldVersion: { - rule: rules.SKIP - }, - licensingVersion: { - rule: rules.FUNCTION, - functionName: 'fetchLMVersion' - }, - category: { - rule: rules.FUNCTION, - functionName: 'fetchCategory' - }, - subCategory: { - rule: rules.SKIP - }, - }, - [fileTypes.VSP_Q] : { - affinityData: { - rule: rules.SKIP - }, - storageReplicationAcrossRegion: { - rule: rules.BOOLEAN, - trueValue: 'true', - falseValue: 'false' - } - }, - [fileTypes.ORCHESTRATION_TEMPLATE_CANDIDATE] : { - modules: { - rule: rules.FUNCTION, - functionName: 'convertArrayToObject' - }, - }, + general: { + id: { + rule: rules.SKIP + }, + questionareData: { + rule: rules.PARSE, + moveFields: true + }, + startDate: { + rule: rules.FUNCTION, + functionName: 'parseDate' + }, + expiryDate: { + rule: rules.FUNCTION, + functionName: 'parseDate' + }, + featureGroups: { + rule: rules.FUNCTION, + functionName: 'reduceList', + args: { subField: 'name' } + }, + licenseKeyGroups: { + rule: rules.FUNCTION, + functionName: 'reduceList', + args: { subField: 'name' } + }, + entitlementPools: { + rule: rules.FUNCTION, + functionName: 'reduceList', + args: { subField: 'name' } + } + }, + [fileTypes.COMPONENT]: {}, + [fileTypes.COMPUTE_FLAVOR]: { + associatedToDeploymentFlavor: { + rule: rules.BOOLEAN, + trueValue: 'true' + } + }, + [fileTypes.COMPUTE_Q]: {}, + [fileTypes.COMPONENT_Q]: { + isComponentMandatory: { + rule: rules.BOOLEAN, + trueValue: 'YES', + falseValue: 'NO' + } + }, + [fileTypes.EP]: { + referencingFeatureGroups: { + rule: rules.SKIP, + functionName: 'getFeatureGroups' + }, + operationalScope: { + rule: rules.FUNCTION, + functionName: 'processChoices' + } + }, + [fileTypes.FG]: { + referencingLicenseAgreements: { + rule: rules.SKIP, + functionName: 'getLicenseAgreements' + } + }, + [fileTypes.LA]: { + licenseTerm: { + rule: rules.FUNCTION, + functionName: 'processChoice' + } + }, + [fileTypes.LIMIT]: { + type: { + rule: rules.FUNCTION, + functionName: 'getEnumValue', + args: { listName: 'limitType' } + }, + unit: { + rule: rules.FUNCTION, + functionName: 'getEnumValue', + args: { listName: 'limitUnit' } + } + }, + [fileTypes.LKG]: { + operationalScope: { + rule: rules.FUNCTION, + functionName: 'processChoices' + }, + referencingFeatureGroups: { + rule: rules.SKIP, + functionName: 'getFeatureGroups' + } + }, + [fileTypes.NIC]: { + networkId: { + rule: rules.SKIP + } + }, + [fileTypes.NIC_Q]: {}, + [fileTypes.PROCESS]: { + type: { + rule: rules.FUNCTION, + functionName: 'getEnumValue', + args: { listName: 'processType' } + } + }, + [fileTypes.VLM]: { + iconRef: { + rule: rules.SKIP + } + }, + [fileTypes.VSP]: { + vendorId: { + rule: rules.SKIP + }, + onboardingMethod: { + rule: rules.SKIP + }, + validationData: { + rule: rules.SKIP + }, + isOldVersion: { + rule: rules.SKIP + }, + licensingVersion: { + rule: rules.FUNCTION, + functionName: 'fetchLMVersion' + }, + category: { + rule: rules.FUNCTION, + functionName: 'fetchCategory' + }, + subCategory: { + rule: rules.SKIP + } + }, + [fileTypes.VSP_Q]: { + affinityData: { + rule: rules.SKIP + }, + storageReplicationAcrossRegion: { + rule: rules.BOOLEAN, + trueValue: 'true', + falseValue: 'false' + } + }, + [fileTypes.ORCHESTRATION_TEMPLATE_CANDIDATE]: { + modules: { + rule: rules.FUNCTION, + functionName: 'convertArrayToObject' + } + } }; diff --git a/openecomp-ui/src/sdc-app/common/merge/MergeEditorReducer.js b/openecomp-ui/src/sdc-app/common/merge/MergeEditorReducer.js index 6985fcfaca..1630849b64 100644 --- a/openecomp-ui/src/sdc-app/common/merge/MergeEditorReducer.js +++ b/openecomp-ui/src/sdc-app/common/merge/MergeEditorReducer.js @@ -13,54 +13,54 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './MergeEditorConstants.js'; +import { actionTypes } from './MergeEditorConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.LOAD_CONFLICT: { - let cdata = {...action.data}; - // let data = state.conflicts ? {...state.conflicts.data} : {} ; - // data[cdata.id] = cdata; - let conflicts = state.conflicts ? {...state.conflicts} : {}; - conflicts[cdata.id] = cdata; - return { - ...state, - conflicts - }; - } - case actionTypes.DATA_PROCESSED: { - let conflicts = {...state.conflicts}; - let {data} = action; - if (data && data.cid) { - let yours = {...conflicts[data.cid].yours}; - let theirs = {...conflicts[data.cid].theirs}; - let {yoursField, theirsField} = data; - if (yoursField) { - yours[yoursField.name] = yoursField.value; - conflicts[data.cid].yours = yours; - } - if (theirsField) { - theirs[theirsField.name] = theirsField.value; - conflicts[data.cid].theirs = theirs; - } - } - return { - ...state, - conflicts: { - ...conflicts - } - }; - } - case actionTypes.LOAD_CONFLICTS: - let conflictFiles = []; - if (action.data) { - conflictFiles = [...action.data.conflictInfoList]; - } - return { - inMerge: conflictFiles.length > 0, - conflictFiles - }; - default: - return state; - } + switch (action.type) { + case actionTypes.LOAD_CONFLICT: { + let cdata = { ...action.data }; + // let data = state.conflicts ? {...state.conflicts.data} : {} ; + // data[cdata.id] = cdata; + let conflicts = state.conflicts ? { ...state.conflicts } : {}; + conflicts[cdata.id] = cdata; + return { + ...state, + conflicts + }; + } + case actionTypes.DATA_PROCESSED: { + let conflicts = { ...state.conflicts }; + let { data } = action; + if (data && data.cid) { + let yours = { ...conflicts[data.cid].yours }; + let theirs = { ...conflicts[data.cid].theirs }; + let { yoursField, theirsField } = data; + if (yoursField) { + yours[yoursField.name] = yoursField.value; + conflicts[data.cid].yours = yours; + } + if (theirsField) { + theirs[theirsField.name] = theirsField.value; + conflicts[data.cid].theirs = theirs; + } + } + return { + ...state, + conflicts: { + ...conflicts + } + }; + } + case actionTypes.LOAD_CONFLICTS: + let conflictFiles = []; + if (action.data) { + conflictFiles = [...action.data.conflictInfoList]; + } + return { + inMerge: conflictFiles.length > 0, + conflictFiles + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/common/merge/MergeEditorView.jsx b/openecomp-ui/src/sdc-app/common/merge/MergeEditorView.jsx index 34d86419e7..a7e36a39fc 100644 --- a/openecomp-ui/src/sdc-app/common/merge/MergeEditorView.jsx +++ b/openecomp-ui/src/sdc-app/common/merge/MergeEditorView.jsx @@ -24,233 +24,389 @@ import GridItem from 'nfvo-components/grid/GridItem.jsx'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import Radio from 'sdc-ui/lib/react/Radio.js'; import equal from 'deep-equal'; -import {ResolutionTypes} from './MergeEditorConstants.js'; +import { ResolutionTypes } from './MergeEditorConstants.js'; -class ConflictCategory extends React.Component { - state = { - resolution: ResolutionTypes.YOURS - }; +class ConflictCategory extends React.Component { + state = { + resolution: ResolutionTypes.YOURS + }; - getTitle(conflictType, conflictName) { - if (typeof conflictName === 'undefined' || conflictType === conflictName) { - return i18n(conflictType); - } else { - return `${i18n(conflictType)}: ${conflictName}`; - } - } + getTitle(conflictType, conflictName) { + if ( + typeof conflictName === 'undefined' || + conflictType === conflictName + ) { + return i18n(conflictType); + } else { + return `${i18n(conflictType)}: ${conflictName}`; + } + } - render() { - let {collapseExpand, conflict: {id: conflictId, type, name}, isCollapsed, item: {id: itemId, version}, onResolveConflict} = this.props; - let {resolution} = this.state; - const iconClass = isCollapsed ? 'merge-chevron' : 'merge-chevron right'; + render() { + let { + collapseExpand, + conflict: { id: conflictId, type, name }, + isCollapsed, + item: { id: itemId, version }, + onResolveConflict + } = this.props; + let { resolution } = this.state; + const iconClass = isCollapsed ? 'merge-chevron' : 'merge-chevron right'; - return ( -
    - - -
    - -
    {this.getTitle(type, name)}
    -
    -
    - - this.setState({resolution: ResolutionTypes.YOURS})} data-test-id={'radio_' + conflictId + '_yours'} /> - - - this.setState({resolution: ResolutionTypes.THEIRS})} data-test-id={'radio_' + conflictId + '_theirs'} /> - - - -
    -
    - {isCollapsed && this.props.children} -
    -
    - ); - } - -}; - -class TextCompare extends React.Component { - render() { - // let rand = Math.random() * (3000 - 1) + 1; - let {yours, theirs, field, type, isObjName, conflictsOnly} = this.props; - let typeYours = typeof yours; - let typeTheirs = typeof theirs; + return ( +
    + + +
    + +
    + {this.getTitle(type, name)} +
    +
    +
    + + + this.setState({ + resolution: ResolutionTypes.YOURS + }) + } + data-test-id={'radio_' + conflictId + '_yours'} + /> + + + + this.setState({ + resolution: ResolutionTypes.THEIRS + }) + } + data-test-id={'radio_' + conflictId + '_theirs'} + /> + + + + +
    +
    {isCollapsed && this.props.children}
    +
    + ); + } +} - let parsedType = `${type}/${field}`.replace(/\/[0-9]+/g,'/index'); - let level = type.split('/').length; +class TextCompare extends React.Component { + render() { + // let rand = Math.random() * (3000 - 1) + 1; + let { + yours, + theirs, + field, + type, + isObjName, + conflictsOnly + } = this.props; + let typeYours = typeof yours; + let typeTheirs = typeof theirs; - if (typeYours === 'boolean' || typeTheirs === 'boolean') { - yours = yours ? i18n('Yes') : i18n('No'); - theirs = theirs ? i18n('Yes') : i18n('No'); - } + let parsedType = `${type}/${field}`.replace(/\/[0-9]+/g, '/index'); + let level = type.split('/').length; + if (typeYours === 'boolean' || typeTheirs === 'boolean') { + yours = yours ? i18n('Yes') : i18n('No'); + theirs = theirs ? i18n('Yes') : i18n('No'); + } - /*if ((typeYours !== 'string' && typeYours !== 'undefined') || (typeTheirs !== 'string' && typeTheirs !== 'undefined')) { + /*if ((typeYours !== 'string' && typeYours !== 'undefined') || (typeTheirs !== 'string' && typeTheirs !== 'undefined')) { return (
    {field} cannot be parsed for display
    ); }*/ - let isDiff = yours !== theirs; - if (!isObjName && - ((!isDiff && conflictsOnly) || - (yours === '' && theirs === '') || - (typeYours === 'undefined' && typeTheirs === 'undefined') - ) - ) { - return null; - } + let isDiff = yours !== theirs; + if ( + !isObjName && + ((!isDiff && conflictsOnly) || + (yours === '' && theirs === '') || + (typeYours === 'undefined' && typeTheirs === 'undefined')) + ) { + return null; + } - return ( - - -
    - {i18n(parsedType)} -
    -
    - -
    {yours || (isObjName ? '' : '━━')}
    -
    - -
    {theirs || (isObjName ? '' : '━━')}
    -
    - -
    - ); - } -}; + return ( + + +
    + {i18n(parsedType)} +
    +
    + +
    + {yours || (isObjName ? '' : '━━')} +
    +
    + +
    + {theirs || (isObjName ? '' : '━━')} +
    +
    + +
    + ); + } +} class MergeEditorView extends React.Component { - state = { - collapsingSections: {}, - conflictsOnly: false - }; + state = { + collapsingSections: {}, + conflictsOnly: false + }; - render() { - let {conflicts, item, conflictFiles, onResolveConflict, currentScreen, resolution} = this.props; + render() { + let { + conflicts, + item, + conflictFiles, + onResolveConflict, + currentScreen, + resolution + } = this.props; - return ( -
    - {conflictFiles && this.renderConflictTableTitles()} -
    - {conflictFiles && conflictFiles.sort((a, b) => a.type > b.type).map(file => ( - {this.updateCollapseState(file.id);}} - onResolveConflict={cDetails => onResolveConflict({...cDetails, currentScreen})}> - {(conflicts && conflicts[file.id]) && - this.getUnion(conflicts[file.id].yours, conflicts[file.id].theirs).map(field => { - return this.renderField(field, file, conflicts[file.id].yours[field], conflicts[file.id].theirs[field], resolution); - })} - ))} -
    -
    ); - } + return ( +
    + {conflictFiles && this.renderConflictTableTitles()} +
    + {conflictFiles && + conflictFiles + .sort((a, b) => a.type > b.type) + .map(file => ( + { + this.updateCollapseState(file.id); + }} + onResolveConflict={cDetails => + onResolveConflict({ + ...cDetails, + currentScreen + }) + }> + {conflicts && + conflicts[file.id] && + this.getUnion( + conflicts[file.id].yours, + conflicts[file.id].theirs + ).map(field => { + return this.renderField( + field, + file, + conflicts[file.id].yours[field], + conflicts[file.id].theirs[ + field + ], + resolution + ); + })} + + ))} +
    +
    + ); + } - renderConflictTableTitles() - { - return ( - - {i18n('Page')} - - - {i18n('Local (Me)')} - - - {i18n('Last Committed')} - - - this.setState({conflictsOnly: e}) } /> - - ); - } - // this.setState({conflictsOnly: checked})} /> + renderConflictTableTitles() { + return ( + + {i18n('Page')} + {i18n('Local (Me)')} + {i18n('Last Committed')} + + this.setState({ conflictsOnly: e })} + /> + + + ); + } + // this.setState({conflictsOnly: checked})} /> - renderObjects(yours, theirs, fileType, field, id, resolution) { - if (equal(yours, theirs)) { - return; - } - let {conflictsOnly} = this.state; - return ( -
    - -
    -
    - {this.getUnion(yours, theirs).map(key => - this.renderField( - key, - {type: `${fileType}/${field}`, id}, - yours && yours[key], - theirs && theirs[key] - ) - )} -
    -
    -
    - ); - } + renderObjects(yours, theirs, fileType, field, id, resolution) { + if (equal(yours, theirs)) { + return; + } + let { conflictsOnly } = this.state; + return ( +
    + +
    +
    + {this.getUnion(yours, theirs).map(key => + this.renderField( + key, + { type: `${fileType}/${field}`, id }, + yours && yours[key], + theirs && theirs[key] + ) + )} +
    +
    +
    + ); + } - renderList(yours = [], theirs = [], type, field, id, resolution) { - let theirsList = theirs.join(', '); - let yoursList = yours.join(', '); - let {conflictsOnly} = this.state; - return (); - } + renderList(yours = [], theirs = [], type, field, id, resolution) { + let theirsList = theirs.join(', '); + let yoursList = yours.join(', '); + let { conflictsOnly } = this.state; + return ( + + ); + } - renderField(field, file, yours, theirs, resolution) { - if (yours) { - if (Array.isArray(yours)) { - return this.renderList(yours, theirs, file.type, field, file.id, resolution); - } - else if (typeof yours === 'object') { - return this.renderObjects(yours, theirs, file.type, field, file.id, resolution); - } - } else if (theirs) { - if (Array.isArray(theirs)) { - return this.renderList(yours, theirs, file.type, field, file.id, resolution); - } - else if (typeof theirs === 'object') { - return this.renderObjects(yours, theirs, file.type, field, file.id, resolution); - } - } - let {conflictsOnly} = this.state; - return (); - } + renderField(field, file, yours, theirs, resolution) { + if (yours) { + if (Array.isArray(yours)) { + return this.renderList( + yours, + theirs, + file.type, + field, + file.id, + resolution + ); + } else if (typeof yours === 'object') { + return this.renderObjects( + yours, + theirs, + file.type, + field, + file.id, + resolution + ); + } + } else if (theirs) { + if (Array.isArray(theirs)) { + return this.renderList( + yours, + theirs, + file.type, + field, + file.id, + resolution + ); + } else if (typeof theirs === 'object') { + return this.renderObjects( + yours, + theirs, + file.type, + field, + file.id, + resolution + ); + } + } + let { conflictsOnly } = this.state; + return ( + + ); + } - getUnion(yours = {},theirs = {}) { - let yoursKeys = Object.keys(yours); - let theirsKeys = Object.keys(theirs); - let myUn = union(yoursKeys, theirsKeys); - return myUn;//.sort((a, b) => a > b); - } + getUnion(yours = {}, theirs = {}) { + let yoursKeys = Object.keys(yours); + let theirsKeys = Object.keys(theirs); + let myUn = union(yoursKeys, theirsKeys); + return myUn; //.sort((a, b) => a > b); + } - updateCollapseState(conflictId) { - const {fetchConflict, item: {id: itemId, version}, /*conflicts*/} = this.props; - let isCollapsed = this.state.collapsingSections[conflictId]; - // if (!isCollapsed && !(conflicts && conflictId in conflicts)) { - if (!isCollapsed) { - fetchConflict({cid: conflictId, itemId, version}); - } - this.setState({ - collapsingSections: { - ...this.state.collapsingSections, - [conflictId]: !isCollapsed - } - }); - } + updateCollapseState(conflictId) { + const { + fetchConflict, + item: { id: itemId, version } /*conflicts*/ + } = this.props; + let isCollapsed = this.state.collapsingSections[conflictId]; + // if (!isCollapsed && !(conflicts && conflictId in conflicts)) { + if (!isCollapsed) { + fetchConflict({ cid: conflictId, itemId, version }); + } + this.setState({ + collapsingSections: { + ...this.state.collapsingSections, + [conflictId]: !isCollapsed + } + }); + } } export default MergeEditorView; diff --git a/openecomp-ui/src/sdc-app/common/modal/ModalContentMapper.js b/openecomp-ui/src/sdc-app/common/modal/ModalContentMapper.js index b17536f446..5b28c5d7fa 100644 --- a/openecomp-ui/src/sdc-app/common/modal/ModalContentMapper.js +++ b/openecomp-ui/src/sdc-app/common/modal/ModalContentMapper.js @@ -32,40 +32,40 @@ import Revisions from 'sdc-app/onboarding/revisions/Revisions.js'; import VendorSelector from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsVendorSelector.jsx'; export const modalContentMapper = { - SOFTWARE_PRODUCT_CREATION: 'SOFTWARE_PRODUCT_CREATION', - LICENSE_MODEL_CREATION: 'LICENSE_MODEL_CREATION', - SUMBIT_ERROR_RESPONSE: 'SUMBIT_ERROR_RESPONSE', - COMPONENT_COMPUTE_FLAVOR_EDITOR: 'COMPONENT_COMPUTE_FLAVOR_EDITOR', - NIC_EDITOR: 'NIC_EDITOR', - NIC_CREATION: 'NIC_CREATION', - COMPONENT_CREATION: 'COMPONENT_CREATION', - SOFTWARE_PRODUCT_COMPONENT_IMAGE_EDITOR : 'SOFTWARE_PRODUCT_COMPONENT_IMAGE_EDITOR', - DEPLOYMENT_FLAVOR_EDITOR: 'DEPLOYMENT_FLAVOR_EDITOR', - MANAGE_PERMISSIONS: 'MANAGE_PERMISSIONS', - VERSION_CREATION: 'VERSION_CREATION', - COMMIT_COMMENT: 'COMMIT_COMMENT', - VERSION_TREE: 'VERSION_TREE', - MERGE_EDITOR: 'MERGE_EDITOR', - REVISIONS_LIST: 'REVISIONS_LIST', - VENDOR_SELECTOR: 'VENDOR_SELECTOR' - + SOFTWARE_PRODUCT_CREATION: 'SOFTWARE_PRODUCT_CREATION', + LICENSE_MODEL_CREATION: 'LICENSE_MODEL_CREATION', + SUMBIT_ERROR_RESPONSE: 'SUMBIT_ERROR_RESPONSE', + COMPONENT_COMPUTE_FLAVOR_EDITOR: 'COMPONENT_COMPUTE_FLAVOR_EDITOR', + NIC_EDITOR: 'NIC_EDITOR', + NIC_CREATION: 'NIC_CREATION', + COMPONENT_CREATION: 'COMPONENT_CREATION', + SOFTWARE_PRODUCT_COMPONENT_IMAGE_EDITOR: + 'SOFTWARE_PRODUCT_COMPONENT_IMAGE_EDITOR', + DEPLOYMENT_FLAVOR_EDITOR: 'DEPLOYMENT_FLAVOR_EDITOR', + MANAGE_PERMISSIONS: 'MANAGE_PERMISSIONS', + VERSION_CREATION: 'VERSION_CREATION', + COMMIT_COMMENT: 'COMMIT_COMMENT', + VERSION_TREE: 'VERSION_TREE', + MERGE_EDITOR: 'MERGE_EDITOR', + REVISIONS_LIST: 'REVISIONS_LIST', + VENDOR_SELECTOR: 'VENDOR_SELECTOR' }; export const modalContentComponents = { - SUMBIT_ERROR_RESPONSE: SubmitErrorResponse, - SOFTWARE_PRODUCT_CREATION: SoftwareProductCreation, - VERSION_CREATION: VersionPageCreation, - LICENSE_MODEL_CREATION: LicenseModelCreation, - COMPONENT_COMPUTE_FLAVOR_EDITOR: ComputeFlavorEditor, - NIC_EDITOR: SoftwareProductComponentsNICEditor, - NIC_CREATION: NICCreation, - COMPONENT_CREATION: ComponentCreation, - SOFTWARE_PRODUCT_COMPONENT_IMAGE_EDITOR : SoftwareProductComponentImageEditor, - DEPLOYMENT_FLAVOR_EDITOR: SoftwareProductDeploymentEditor, - MANAGE_PERMISSIONS: PermissionsManager, - COMMIT_COMMENT: CommitCommentModal, - VERSION_TREE: Tree, - MERGE_EDITOR: MergeEditor, - REVISIONS_LIST: Revisions, - VENDOR_SELECTOR: VendorSelector + SUMBIT_ERROR_RESPONSE: SubmitErrorResponse, + SOFTWARE_PRODUCT_CREATION: SoftwareProductCreation, + VERSION_CREATION: VersionPageCreation, + LICENSE_MODEL_CREATION: LicenseModelCreation, + COMPONENT_COMPUTE_FLAVOR_EDITOR: ComputeFlavorEditor, + NIC_EDITOR: SoftwareProductComponentsNICEditor, + NIC_CREATION: NICCreation, + COMPONENT_CREATION: ComponentCreation, + SOFTWARE_PRODUCT_COMPONENT_IMAGE_EDITOR: SoftwareProductComponentImageEditor, + DEPLOYMENT_FLAVOR_EDITOR: SoftwareProductDeploymentEditor, + MANAGE_PERMISSIONS: PermissionsManager, + COMMIT_COMMENT: CommitCommentModal, + VERSION_TREE: Tree, + MERGE_EDITOR: MergeEditor, + REVISIONS_LIST: Revisions, + VENDOR_SELECTOR: VendorSelector }; diff --git a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js index 916f724b40..6ac6d753d4 100644 --- a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js +++ b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js @@ -13,133 +13,185 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './JSONSchemaReducerConstants.js'; +import { actionTypes } from './JSONSchemaReducerConstants.js'; import Validator from 'nfvo-utils/Validator.js'; import JSONSchema from 'nfvo-utils/json/JSONSchema.js'; import JSONPointer from 'nfvo-utils/json/JSONPointer.js'; import forOwn from 'lodash/forOwn.js'; import isArray from 'lodash/isArray.js'; - function flattenData(data, result, pointer = '') { - let newPointer = pointer; - if (typeof data === 'object' && !isArray(data)) { - for (let i in data) { - newPointer = newPointer ? newPointer + '/' + i : i; - flattenData(data[i], result, newPointer); - newPointer = pointer; - } - } else { - result[newPointer] = data; - } + let newPointer = pointer; + if (typeof data === 'object' && !isArray(data)) { + for (let i in data) { + newPointer = newPointer ? newPointer + '/' + i : i; + flattenData(data[i], result, newPointer); + newPointer = pointer; + } + } else { + result[newPointer] = data; + } } -function updateSchemaDataAndValidateReducer (state = {}, action, questionnaireName) { - let genericFieldInfoClone; - switch (action.type) { - case actionTypes.DATA_LOADED: - if (questionnaireName !== action.qName) {return {...state};} - const schema = action.payload.qschema; - let schemaLoader = new JSONSchema(); - schemaLoader.setSchema(schema); - schemaLoader.setSupportedValidationFunctions(Object.keys(Validator.globalValidationFunctions)); - let {genericFieldInfo} = schemaLoader.flattenSchema(); - - let data = action.payload.qdata; - let dataMap = {}; - flattenData(data, dataMap); - - return { - ...state, - qdata: action.payload.qdata, // the original hierarchical data. to be used for submit and save - qgenericFieldInfo : genericFieldInfo, // information about the fields that the view will require and reducer will need, such as validations, enum to use, etc. - dataMap // flattened schema data for ease of use - }; - - case actionTypes.DATA_CHANGED: - let changedData = action.deltaData; - if (questionnaireName !== action.qName) {return {...state};} - - genericFieldInfoClone = {...state.qgenericFieldInfo}; - let qDataClone = {...state.qdata}; - let dataMapClone = {...state.dataMap}; - - forOwn(changedData,(value, key) => { - if (state.qgenericFieldInfo[key]) { - let result = Validator.validate(key, value, state.qgenericFieldInfo[key].validations, state, action.customValidations); - genericFieldInfoClone[key] = {...genericFieldInfoClone[key], isValid: result.isValid, errorText: result.errorText}; - qDataClone = JSONPointer.setValue(state.qdata, '/' + key, value); - dataMapClone[key] = value; - } - }); - - return { - ...state, - qdata: qDataClone, - dataMap: dataMapClone, - qgenericFieldInfo: genericFieldInfoClone - }; - - case actionTypes.VALIDATE_DATA: - let specificFields = action.data; - if (questionnaireName !== action.qName) {return {...state};} - genericFieldInfoClone = {...state.qgenericFieldInfo}; - forOwn(specificFields,(value, key) => { - let result = Validator.validate(key, value, state.qgenericFieldInfo[key].validations, state, action.customValidations); - genericFieldInfoClone[key] = {...genericFieldInfoClone[key], isValid: result.isValid, errorText: result.errorText}; - }); - return { - ...state, - formReady: null, - qgenericFieldInfo: genericFieldInfoClone - }; - - case actionTypes.VALIDATE_FORM: - if (questionnaireName !== action.qName) {return {...state};} - genericFieldInfoClone = {...state.qgenericFieldInfo}; - let formReady = true; - forOwn(state.qgenericFieldInfo,(value, key) => { - let val = state.dataMap[key] ? state.dataMap[key] : ''; - let result = Validator.validate(key, val, state.qgenericFieldInfo[key].validations, state, action.customValidations); - genericFieldInfoClone[key] = {...genericFieldInfoClone[key], isValid: result.isValid, errorText: result.errorText}; - if (!result.isValid) { - formReady = false; - } - }); - return { - ...state, - formReady, - qgenericFieldInfo: genericFieldInfoClone - }; - - default: - return state; - } -}; +function updateSchemaDataAndValidateReducer( + state = {}, + action, + questionnaireName +) { + let genericFieldInfoClone; + switch (action.type) { + case actionTypes.DATA_LOADED: + if (questionnaireName !== action.qName) { + return { ...state }; + } + const schema = action.payload.qschema; + let schemaLoader = new JSONSchema(); + schemaLoader.setSchema(schema); + schemaLoader.setSupportedValidationFunctions( + Object.keys(Validator.globalValidationFunctions) + ); + let { genericFieldInfo } = schemaLoader.flattenSchema(); + + let data = action.payload.qdata; + let dataMap = {}; + flattenData(data, dataMap); + + return { + ...state, + qdata: action.payload.qdata, // the original hierarchical data. to be used for submit and save + qgenericFieldInfo: genericFieldInfo, // information about the fields that the view will require and reducer will need, such as validations, enum to use, etc. + dataMap // flattened schema data for ease of use + }; + + case actionTypes.DATA_CHANGED: + let changedData = action.deltaData; + if (questionnaireName !== action.qName) { + return { ...state }; + } + + genericFieldInfoClone = { ...state.qgenericFieldInfo }; + let qDataClone = { ...state.qdata }; + let dataMapClone = { ...state.dataMap }; + + forOwn(changedData, (value, key) => { + if (state.qgenericFieldInfo[key]) { + let result = Validator.validate( + key, + value, + state.qgenericFieldInfo[key].validations, + state, + action.customValidations + ); + genericFieldInfoClone[key] = { + ...genericFieldInfoClone[key], + isValid: result.isValid, + errorText: result.errorText + }; + qDataClone = JSONPointer.setValue( + state.qdata, + '/' + key, + value + ); + dataMapClone[key] = value; + } + }); + + return { + ...state, + qdata: qDataClone, + dataMap: dataMapClone, + qgenericFieldInfo: genericFieldInfoClone + }; + + case actionTypes.VALIDATE_DATA: + let specificFields = action.data; + if (questionnaireName !== action.qName) { + return { ...state }; + } + genericFieldInfoClone = { ...state.qgenericFieldInfo }; + forOwn(specificFields, (value, key) => { + let result = Validator.validate( + key, + value, + state.qgenericFieldInfo[key].validations, + state, + action.customValidations + ); + genericFieldInfoClone[key] = { + ...genericFieldInfoClone[key], + isValid: result.isValid, + errorText: result.errorText + }; + }); + return { + ...state, + formReady: null, + qgenericFieldInfo: genericFieldInfoClone + }; + + case actionTypes.VALIDATE_FORM: + if (questionnaireName !== action.qName) { + return { ...state }; + } + genericFieldInfoClone = { ...state.qgenericFieldInfo }; + let formReady = true; + forOwn(state.qgenericFieldInfo, (value, key) => { + let val = state.dataMap[key] ? state.dataMap[key] : ''; + let result = Validator.validate( + key, + val, + state.qgenericFieldInfo[key].validations, + state, + action.customValidations + ); + genericFieldInfoClone[key] = { + ...genericFieldInfoClone[key], + isValid: result.isValid, + errorText: result.errorText + }; + if (!result.isValid) { + formReady = false; + } + }); + return { + ...state, + formReady, + qgenericFieldInfo: genericFieldInfoClone + }; + + default: + return state; + } +} export function createJSONSchemaReducer(questionnaireName) { - return (state = {}, action) => { - return updateSchemaDataAndValidateReducer(state, action, questionnaireName); - }; -}; - -export function createComposedJSONSchemaReducer(questionnaireName, additionalActionsReducer) { - return (state = {}, action) => { - if(action.type === actionTypes.VALIDATE_DATA || - action.type === actionTypes.VALIDATE_FORM || - action.type === actionTypes.DATA_CHANGED || - action.type === actionTypes.DATA_LOADED - ) { - return updateSchemaDataAndValidateReducer(state, action, questionnaireName); - } else { - return additionalActionsReducer(state, action); - } - }; -}; - - - - - - + return (state = {}, action) => { + return updateSchemaDataAndValidateReducer( + state, + action, + questionnaireName + ); + }; +} +export function createComposedJSONSchemaReducer( + questionnaireName, + additionalActionsReducer +) { + return (state = {}, action) => { + if ( + action.type === actionTypes.VALIDATE_DATA || + action.type === actionTypes.VALIDATE_FORM || + action.type === actionTypes.DATA_CHANGED || + action.type === actionTypes.DATA_LOADED + ) { + return updateSchemaDataAndValidateReducer( + state, + action, + questionnaireName + ); + } else { + return additionalActionsReducer(state, action); + } + }; +} diff --git a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js index 6007b878dd..439613d949 100644 --- a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js +++ b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js @@ -16,8 +16,8 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - DATA_LOADED: null, - DATA_CHANGED: null, - VALIDATE_FORM: null, - VALIDATE_DATA: null + DATA_LOADED: null, + DATA_CHANGED: null, + VALIDATE_FORM: null, + VALIDATE_DATA: null }); diff --git a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js index 49f1e3d415..30497704b4 100644 --- a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js +++ b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js @@ -13,89 +13,135 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './PlainDataReducerConstants.js'; +import { actionTypes } from './PlainDataReducerConstants.js'; import Validator from 'nfvo-utils/Validator.js'; import forOwn from 'lodash/forOwn.js'; -import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx'; function updateDataAndValidateReducer(state = {}, action) { - let genericFieldInfoCopy; - switch (action.type) { - case actionTypes.DATA_CHANGED: - let changed = action.deltaData; - if (!action.formName || (state.formName !== action.formName)) {return {...state};} - genericFieldInfoCopy = {...state.genericFieldInfo}; - forOwn(changed,(value, key) => { - if (state.genericFieldInfo[key]) { - let result = Validator.validate(key, value, state.genericFieldInfo[key].validations, state, action.customValidations); - genericFieldInfoCopy[key] = {...genericFieldInfoCopy[key], isValid: result.isValid, errorText: result.errorText}; - } - }); - return { - ...state, - formReady: null, - data: { - ...state.data, - ...action.deltaData - }, - genericFieldInfo: genericFieldInfoCopy - }; - case actionTypes.VALIDATE_FORM: - if (!action.formName || (state.formName !== action.formName)) {return {...state};} - genericFieldInfoCopy = {...state.genericFieldInfo}; - let formReady = true; - forOwn(state.genericFieldInfo,(value, key) => { - let val = state.data && state.data[key] ? state.data[key] : ''; - let result = Validator.validate(key, val, state.genericFieldInfo[key].validations, state, {}); - if(val.choice !== undefined) { - result = Validator.validate(key, val.choice, state.genericFieldInfo[key].validations, state, {}); - } - if(val.choice !== undefined && val.choice === optionInputOther.OTHER) { - result = Validator.validate(key, val.other, state.genericFieldInfo[key].validations, state, {}); - } - genericFieldInfoCopy[key] = {...genericFieldInfoCopy[key], isValid: result.isValid, errorText: result.errorText}; - if (!result.isValid) { - formReady = false; - } - }); - return { - ...state, - formReady, - genericFieldInfo: genericFieldInfoCopy - }; - case actionTypes.VALIDATE_DATA: - let specificFields = action.data; - if (!action.formName || (state.formName !== action.formName)) {return {...state};} - genericFieldInfoCopy = {...state.genericFieldInfo}; - forOwn(specificFields,(value, key) => { - let result = Validator.validate(key, value, state.genericFieldInfo[key].validations, state, action.customValidations); - genericFieldInfoCopy[key] = {...genericFieldInfoCopy[key], isValid: result.isValid, errorText: result.errorText}; - }); - return { - ...state, - formReady: null, - genericFieldInfo: genericFieldInfoCopy - }; - default: - return state; - } -}; + let genericFieldInfoCopy; + switch (action.type) { + case actionTypes.DATA_CHANGED: + let changed = action.deltaData; + if (!action.formName || state.formName !== action.formName) { + return { ...state }; + } + genericFieldInfoCopy = { ...state.genericFieldInfo }; + forOwn(changed, (value, key) => { + if (state.genericFieldInfo[key]) { + let result = Validator.validate( + key, + value, + state.genericFieldInfo[key].validations, + state, + action.customValidations + ); + genericFieldInfoCopy[key] = { + ...genericFieldInfoCopy[key], + isValid: result.isValid, + errorText: result.errorText + }; + } + }); + return { + ...state, + formReady: null, + data: { + ...state.data, + ...action.deltaData + }, + genericFieldInfo: genericFieldInfoCopy + }; + case actionTypes.VALIDATE_FORM: + if (!action.formName || state.formName !== action.formName) { + return { ...state }; + } + genericFieldInfoCopy = { ...state.genericFieldInfo }; + let formReady = true; + forOwn(state.genericFieldInfo, (value, key) => { + let val = state.data && state.data[key] ? state.data[key] : ''; + let result = Validator.validate( + key, + val, + state.genericFieldInfo[key].validations, + state, + {} + ); + if (val.choice !== undefined) { + result = Validator.validate( + key, + val.choice, + state.genericFieldInfo[key].validations, + state, + {} + ); + } + if ( + val.choice !== undefined && + val.choice === optionInputOther.OTHER + ) { + result = Validator.validate( + key, + val.other, + state.genericFieldInfo[key].validations, + state, + {} + ); + } + genericFieldInfoCopy[key] = { + ...genericFieldInfoCopy[key], + isValid: result.isValid, + errorText: result.errorText + }; + if (!result.isValid) { + formReady = false; + } + }); + return { + ...state, + formReady, + genericFieldInfo: genericFieldInfoCopy + }; + case actionTypes.VALIDATE_DATA: + let specificFields = action.data; + if (!action.formName || state.formName !== action.formName) { + return { ...state }; + } + genericFieldInfoCopy = { ...state.genericFieldInfo }; + forOwn(specificFields, (value, key) => { + let result = Validator.validate( + key, + value, + state.genericFieldInfo[key].validations, + state, + action.customValidations + ); + genericFieldInfoCopy[key] = { + ...genericFieldInfoCopy[key], + isValid: result.isValid, + errorText: result.errorText + }; + }); + return { + ...state, + formReady: null, + genericFieldInfo: genericFieldInfoCopy + }; + default: + return state; + } +} export function createPlainDataReducer(loadReducer) { - return (state = {}, action) => { - if(action.type === actionTypes.VALIDATE_DATA || - action.type === actionTypes.VALIDATE_FORM || - action.type === actionTypes.DATA_CHANGED - ) { - return updateDataAndValidateReducer(state, action); - } else { - return loadReducer(state, action); - } - }; -}; - - - - - - + return (state = {}, action) => { + if ( + action.type === actionTypes.VALIDATE_DATA || + action.type === actionTypes.VALIDATE_FORM || + action.type === actionTypes.DATA_CHANGED + ) { + return updateDataAndValidateReducer(state, action); + } else { + return loadReducer(state, action); + } + }; +} diff --git a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js index 135361dd20..8c38483267 100644 --- a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js +++ b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js @@ -16,7 +16,7 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - DATA_CHANGED: null, - VALIDATE_FORM: null, - VALIDATE_DATA: null + DATA_CHANGED: null, + VALIDATE_FORM: null, + VALIDATE_DATA: null }); diff --git a/openecomp-ui/src/sdc-app/config/Configuration.js b/openecomp-ui/src/sdc-app/config/Configuration.js index 8444e3fa61..b450d47352 100644 --- a/openecomp-ui/src/sdc-app/config/Configuration.js +++ b/openecomp-ui/src/sdc-app/config/Configuration.js @@ -16,47 +16,55 @@ import configData from './config.json'; class Configuration { + get(key) { + return configData[key]; + } - get(key) { - return configData[key]; - } + set(key, value) { + var prev = configData[key]; + configData[key] = value; + return prev; + } - set(key, value) { - var prev = configData[key]; - configData[key] = value; - return prev; - } + setCatalogApiRoot(CatalogApiRoot) { + let restCatalogPrefix = CatalogApiRoot, + restPrefix = CatalogApiRoot.replace( + /\/feProxy\b[^:]*$/, + '/feProxy/onboarding-api' + ); - setCatalogApiRoot(CatalogApiRoot) { - let restCatalogPrefix = CatalogApiRoot, - restPrefix = CatalogApiRoot.replace(/\/feProxy\b[^:]*$/, '/feProxy/onboarding-api'); + this.set('restPrefix', restPrefix); + this.set('restCatalogPrefix', restCatalogPrefix); + } - this.set('restPrefix', restPrefix); - this.set('restCatalogPrefix', restCatalogPrefix); - } + setCatalogApiHeaders(CatalogApiHeaders) { + this.set('CatalogApiHeaders', CatalogApiHeaders); - setCatalogApiHeaders(CatalogApiHeaders) { - this.set('CatalogApiHeaders', CatalogApiHeaders); - - let {userId: {value: UserID} = {}} = CatalogApiHeaders; - this.set('UserID', UserID); - } + let { userId: { value: UserID } = {} } = CatalogApiHeaders; + this.set('UserID', UserID); + } } const configuration = new Configuration(); (function setDefaultRestPrefixes(configuration) { - configuration.set('restPrefix', configuration.get('defaultRestPrefix')); - configuration.set('restCatalogPrefix', configuration.get('defaultRestCatalogPrefix')); - configuration.set('appContextPath', configuration.get('appContextPath')); + configuration.set('restPrefix', configuration.get('defaultRestPrefix')); + configuration.set( + 'restCatalogPrefix', + configuration.get('defaultRestCatalogPrefix') + ); + configuration.set('appContextPath', configuration.get('appContextPath')); })(configuration); (function setDefaultWebsocketConfig(configuration) { - let websocketPort = configuration.get('defaultWebsocketPort'); - if (DEBUG) { - websocketPort = configuration.get('defaultDebugWebsocketPort'); - } - configuration.set('websocketPort', websocketPort); - configuration.set('websocketPath', configuration.get('defaultWebsocketPath')); + let websocketPort = configuration.get('defaultWebsocketPort'); + if (DEBUG) { + websocketPort = configuration.get('defaultDebugWebsocketPort'); + } + configuration.set('websocketPort', websocketPort); + configuration.set( + 'websocketPath', + configuration.get('defaultWebsocketPath') + ); })(configuration); export default configuration; diff --git a/openecomp-ui/src/sdc-app/features/FeaturesActionHelper.js b/openecomp-ui/src/sdc-app/features/FeaturesActionHelper.js index 5bb911d090..5ab5480167 100644 --- a/openecomp-ui/src/sdc-app/features/FeaturesActionHelper.js +++ b/openecomp-ui/src/sdc-app/features/FeaturesActionHelper.js @@ -15,26 +15,30 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from './FeaturesConstants.js'; - +import { actionTypes } from './FeaturesConstants.js'; function baseUrl() { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/togglz`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/togglz`; } function fetchList() { - return RestAPIUtil.fetch(baseUrl()); + return RestAPIUtil.fetch(baseUrl()); } export default { - getFeaturesList(dispatch) { - return fetchList().then(response => { - dispatch({ - type: actionTypes.FEATURES_LIST_LOADED, - features: response.features - }); - }).catch(() => console.error('An exception occured while trying to fetch the toggleZ features.') ); - } + getFeaturesList(dispatch) { + return fetchList() + .then(response => { + dispatch({ + type: actionTypes.FEATURES_LIST_LOADED, + features: response.features + }); + }) + .catch(() => + console.error( + 'An exception occured while trying to fetch the toggleZ features.' + ) + ); + } }; - diff --git a/openecomp-ui/src/sdc-app/features/FeaturesConstants.js b/openecomp-ui/src/sdc-app/features/FeaturesConstants.js index f962d243d5..314e86ad3d 100644 --- a/openecomp-ui/src/sdc-app/features/FeaturesConstants.js +++ b/openecomp-ui/src/sdc-app/features/FeaturesConstants.js @@ -16,10 +16,10 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - FEATURES_LIST_LOADED: null + FEATURES_LIST_LOADED: null }); export const featureToggleNames = { - ARCHIVE_ITEM: 'ARCHIVE_ITEM', - FILTER: 'FILTER' -}; \ No newline at end of file + ARCHIVE_ITEM: 'ARCHIVE_ITEM', + FILTER: 'FILTER' +}; diff --git a/openecomp-ui/src/sdc-app/features/FeaturesReducer.js b/openecomp-ui/src/sdc-app/features/FeaturesReducer.js index d7c8624d54..064afe992d 100644 --- a/openecomp-ui/src/sdc-app/features/FeaturesReducer.js +++ b/openecomp-ui/src/sdc-app/features/FeaturesReducer.js @@ -14,13 +14,13 @@ * permissions and limitations under the License. */ - import {actionTypes} from './FeaturesConstants.js'; +import { actionTypes } from './FeaturesConstants.js'; - export default (state = [], action) => { - switch (action.type) { - case actionTypes.FEATURES_LIST_LOADED: - return [...action.features]; - default: - return state; - } - }; \ No newline at end of file +export default (state = [], action) => { + switch (action.type) { + case actionTypes.FEATURES_LIST_LOADED: + return [...action.features]; + default: + return state; + } +}; diff --git a/openecomp-ui/src/sdc-app/features/featureToggle.js b/openecomp-ui/src/sdc-app/features/featureToggle.js index 5e0df1448f..d33c76e523 100644 --- a/openecomp-ui/src/sdc-app/features/featureToggle.js +++ b/openecomp-ui/src/sdc-app/features/featureToggle.js @@ -14,47 +14,48 @@ * permissions and limitations under the License. */ - - /** +/** * Feature toggling decorator - * usage: - * + * usage: + * * @featureToggle('FeatureName') * class Example extends React.Component { * render() { * return (
    test feature
    ); * } * } - * - * OR - * + * + * OR + * * const TestFeature = () => (
    test feature
    ) * export default featureToggle('FeatureName')(TestFeature) - * + * */ import React from 'react'; import PropTypes from 'prop-types'; -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; + +export const FeatureComponent = props => { + const { features = [], featureName, InnerComponent, ...otherProps } = props; + const AComp = InnerComponent.AComp ? InnerComponent.AComp : InnerComponent; -export const FeatureComponent = (props) => { - const {features = [], featureName, InnerComponent, ...otherProps} = props; - const AComp = InnerComponent.AComp ? InnerComponent.AComp : InnerComponent; - - return !!features.find(el => el.name === featureName && el.active) ? - - : InnerComponent.BComp ? : null; + return !!features.find(el => el.name === featureName && el.active) ? ( + + ) : InnerComponent.BComp ? ( + + ) : null; }; FeatureComponent.propTypes = { - features: PropTypes.array, - featureName: PropTypes.string.isRequired + features: PropTypes.array, + featureName: PropTypes.string.isRequired }; - export default function featureToggle(featureName) { - return (InnerComponent) => { - return connect(({features}) => {return {features, featureName, InnerComponent};})(FeatureComponent); - }; + return InnerComponent => { + return connect(({ features }) => { + return { features, featureName, InnerComponent }; + })(FeatureComponent); + }; } - diff --git a/openecomp-ui/src/sdc-app/features/restToggle.js b/openecomp-ui/src/sdc-app/features/restToggle.js index c90521dd7e..505dace4e7 100644 --- a/openecomp-ui/src/sdc-app/features/restToggle.js +++ b/openecomp-ui/src/sdc-app/features/restToggle.js @@ -16,9 +16,9 @@ import store from 'sdc-app/AppStore.js'; - -export default ({featureName, restFunction, mockResult}) => { - const {features} = store.getState(); - return !!features.find(el => el.name === featureName && el.active) ? - restFunction() : Promise.resolve(mockResult); -}; \ No newline at end of file +export default ({ featureName, restFunction, mockResult }) => { + const { features } = store.getState(); + return !!features.find(el => el.name === featureName && el.active) + ? restFunction() + : Promise.resolve(mockResult); +}; diff --git a/openecomp-ui/src/sdc-app/flows/FlowsActions.js b/openecomp-ui/src/sdc-app/flows/FlowsActions.js index 61a419b314..9fb65f37d4 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsActions.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsActions.js @@ -15,171 +15,204 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes, enums} from './FlowsConstants.js'; +import { actionTypes, enums } from './FlowsConstants.js'; import SequenceDiagramModelHelper from './SequenceDiagramModelHelper.js'; - function baseUrl(serviceId, artifactId = '') { - const restCatalogPrefix = Configuration.get('restCatalogPrefix'); - return `${restCatalogPrefix}/v1/catalog/services/${serviceId}/artifacts/${artifactId}`; + const restCatalogPrefix = Configuration.get('restCatalogPrefix'); + return `${restCatalogPrefix}/v1/catalog/services/${serviceId}/artifacts/${artifactId}`; } function encodeDataToBase64(dataAsString) { - return window.btoa(dataAsString); + return window.btoa(dataAsString); } function decodeDataToBase64(encodedData) { - return window.atob(encodedData); + return window.atob(encodedData); } function encodeContent(flowData) { - let data = { - VERSION: { - major: 1, - minor: 0 - }, - description: flowData.description, - sequenceDiagramModel: flowData.sequenceDiagramModel - }; - - return encodeDataToBase64(JSON.stringify(data)); + let data = { + VERSION: { + major: 1, + minor: 0 + }, + description: flowData.description, + sequenceDiagramModel: flowData.sequenceDiagramModel + }; + + return encodeDataToBase64(JSON.stringify(data)); } function decodeContent(base64Contents) { - let description, sequenceDiagramModel; - let payload = JSON.parse(decodeDataToBase64(base64Contents)); - - if (payload.VERSION === undefined) { - description = payload.description || 'Please, provide description...'; - sequenceDiagramModel = payload.data || payload; - sequenceDiagramModel = sequenceDiagramModel.model || sequenceDiagramModel; - - } - else if (payload.VERSION.major === 1) { - description = payload.description; - sequenceDiagramModel = payload.sequenceDiagramModel; - } - - return { - description, - sequenceDiagramModel - }; + let description, sequenceDiagramModel; + let payload = JSON.parse(decodeDataToBase64(base64Contents)); + + if (payload.VERSION === undefined) { + description = payload.description || 'Please, provide description...'; + sequenceDiagramModel = payload.data || payload; + sequenceDiagramModel = + sequenceDiagramModel.model || sequenceDiagramModel; + } else if (payload.VERSION.major === 1) { + description = payload.description; + sequenceDiagramModel = payload.sequenceDiagramModel; + } + + return { + description, + sequenceDiagramModel + }; } function createOrUpdate(flowData) { - let createOrUpdateRequest = { - payloadData: encodeContent(flowData), - artifactLabel: flowData.artifactLabel || flowData.artifactName, - artifactName: flowData.artifactName, - artifactType: flowData.artifactType, - artifactGroupType: enums.INFORMATIONAL, - description: flowData.description - }; - - return RestAPIUtil.post( - baseUrl(flowData.serviceID, flowData.uniqueId), - createOrUpdateRequest, - {md5: true} - ); + let createOrUpdateRequest = { + payloadData: encodeContent(flowData), + artifactLabel: flowData.artifactLabel || flowData.artifactName, + artifactName: flowData.artifactName, + artifactType: flowData.artifactType, + artifactGroupType: enums.INFORMATIONAL, + description: flowData.description + }; + + return RestAPIUtil.post( + baseUrl(flowData.serviceID, flowData.uniqueId), + createOrUpdateRequest, + { md5: true } + ); } const FlowsActions = Object.freeze({ - - fetchFlowArtifacts(dispatch, {artifacts, diagramType, participants, serviceID, readonly}) { - let results = []; - if (!Object.keys(artifacts).length) { - dispatch({type: actionTypes.FLOW_LIST_LOADED, results, participants, serviceID, diagramType, readonly}); - if (!readonly) { - FlowsActions.openFlowDetailsEditor(dispatch); - } - } - else { - Object.keys(artifacts).forEach(artifact => results.push({ - artifactType: diagramType, - participants, - serviceID, - ...artifacts[artifact] - })); - dispatch({type: actionTypes.FLOW_LIST_LOADED, results, participants, serviceID, diagramType, readonly}); - } - }, - - fetchArtifact(dispatch, {flow}){ - let {serviceID, uniqueId, participants} = flow; - return RestAPIUtil.fetch(baseUrl(serviceID, uniqueId)).then(response => { - - let {artifactName, base64Contents} = response; - let {sequenceDiagramModel, ...other} = decodeContent(base64Contents); - - if (!sequenceDiagramModel) { - sequenceDiagramModel = SequenceDiagramModelHelper.createModel({ - id: uniqueId, - name: artifactName, - lifelines: participants - }); - } - else { - sequenceDiagramModel = SequenceDiagramModelHelper.updateModel(sequenceDiagramModel, { - name: artifactName, - lifelines: participants - }); - } - - flow = { - ...flow, - ...other, - uniqueId, - artifactName, - sequenceDiagramModel - }; - - dispatch({type: actionTypes.ARTIFACT_LOADED, flow}); - FlowsActions.openFlowDiagramEditor(dispatch, {flow}); - }); - }, - - createOrUpdateFlow(dispatch, {flow}, isNew) { - if (!isNew && flow.sequenceDiagramModel) { - flow.sequenceDiagramModel = SequenceDiagramModelHelper.updateModel(flow.sequenceDiagramModel, { - name: flow.artifactName - }); - } - return createOrUpdate(flow).then(response => { - let {uniqueId, artifactLabel} = response; - flow = {...flow, uniqueId, artifactLabel}; - if (isNew) { - flow.sequenceDiagramModel = SequenceDiagramModelHelper.createModel({id: uniqueId, name: flow.artifactName}); - } - dispatch({type: actionTypes.ADD_OR_UPDATE_FLOW, flow}); - }); - }, - - deleteFlow(dispatch, {flow}) { - return RestAPIUtil.destroy(baseUrl(flow.serviceID, flow.uniqueId)).then(() => dispatch({ - type: actionTypes.DELETE_FLOW, - flow - })); - }, - - openFlowDetailsEditor(dispatch, flow) { - dispatch({type: actionTypes.OPEN_FLOW_DETAILS_EDITOR, flow}); - }, - - closeFlowDetailsEditor(dispatch) { - dispatch({type: actionTypes.CLOSE_FLOW_DETAILS_EDITOR}); - }, - - openFlowDiagramEditor(dispatch, {flow}) { - dispatch({type: actionTypes.OPEN_FLOW_DIAGRAM_EDITOR, flow}); - }, - - closeFlowDiagramEditor(dispatch) { - dispatch({type: actionTypes.CLOSE_FLOW_DIAGRAM_EDITOR}); - }, - - reset(dispatch) { - dispatch({type: actionTypes.RESET}); - } + fetchFlowArtifacts( + dispatch, + { artifacts, diagramType, participants, serviceID, readonly } + ) { + let results = []; + if (!Object.keys(artifacts).length) { + dispatch({ + type: actionTypes.FLOW_LIST_LOADED, + results, + participants, + serviceID, + diagramType, + readonly + }); + if (!readonly) { + FlowsActions.openFlowDetailsEditor(dispatch); + } + } else { + Object.keys(artifacts).forEach(artifact => + results.push({ + artifactType: diagramType, + participants, + serviceID, + ...artifacts[artifact] + }) + ); + dispatch({ + type: actionTypes.FLOW_LIST_LOADED, + results, + participants, + serviceID, + diagramType, + readonly + }); + } + }, + + fetchArtifact(dispatch, { flow }) { + let { serviceID, uniqueId, participants } = flow; + return RestAPIUtil.fetch(baseUrl(serviceID, uniqueId)).then( + response => { + let { artifactName, base64Contents } = response; + let { sequenceDiagramModel, ...other } = decodeContent( + base64Contents + ); + + if (!sequenceDiagramModel) { + sequenceDiagramModel = SequenceDiagramModelHelper.createModel( + { + id: uniqueId, + name: artifactName, + lifelines: participants + } + ); + } else { + sequenceDiagramModel = SequenceDiagramModelHelper.updateModel( + sequenceDiagramModel, + { + name: artifactName, + lifelines: participants + } + ); + } + + flow = { + ...flow, + ...other, + uniqueId, + artifactName, + sequenceDiagramModel + }; + + dispatch({ type: actionTypes.ARTIFACT_LOADED, flow }); + FlowsActions.openFlowDiagramEditor(dispatch, { flow }); + } + ); + }, + + createOrUpdateFlow(dispatch, { flow }, isNew) { + if (!isNew && flow.sequenceDiagramModel) { + flow.sequenceDiagramModel = SequenceDiagramModelHelper.updateModel( + flow.sequenceDiagramModel, + { + name: flow.artifactName + } + ); + } + return createOrUpdate(flow).then(response => { + let { uniqueId, artifactLabel } = response; + flow = { ...flow, uniqueId, artifactLabel }; + if (isNew) { + flow.sequenceDiagramModel = SequenceDiagramModelHelper.createModel( + { + id: uniqueId, + name: flow.artifactName + } + ); + } + dispatch({ type: actionTypes.ADD_OR_UPDATE_FLOW, flow }); + }); + }, + + deleteFlow(dispatch, { flow }) { + return RestAPIUtil.destroy(baseUrl(flow.serviceID, flow.uniqueId)).then( + () => + dispatch({ + type: actionTypes.DELETE_FLOW, + flow + }) + ); + }, + + openFlowDetailsEditor(dispatch, flow) { + dispatch({ type: actionTypes.OPEN_FLOW_DETAILS_EDITOR, flow }); + }, + + closeFlowDetailsEditor(dispatch) { + dispatch({ type: actionTypes.CLOSE_FLOW_DETAILS_EDITOR }); + }, + + openFlowDiagramEditor(dispatch, { flow }) { + dispatch({ type: actionTypes.OPEN_FLOW_DIAGRAM_EDITOR, flow }); + }, + + closeFlowDiagramEditor(dispatch) { + dispatch({ type: actionTypes.CLOSE_FLOW_DIAGRAM_EDITOR }); + }, + + reset(dispatch) { + dispatch({ type: actionTypes.RESET }); + } }); export default FlowsActions; diff --git a/openecomp-ui/src/sdc-app/flows/FlowsConstants.js b/openecomp-ui/src/sdc-app/flows/FlowsConstants.js index 2b3d86bae2..4dcd840ff3 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsConstants.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsConstants.js @@ -16,30 +16,28 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ + OPEN_FLOW_DETAILS_EDITOR: null, + CLOSE_FLOW_DETAILS_EDITOR: null, - OPEN_FLOW_DETAILS_EDITOR: null, - CLOSE_FLOW_DETAILS_EDITOR: null, + OPEN_FLOW_DIAGRAM_EDITOR: null, + CLOSE_FLOW_DIAGRAM_EDITOR: null, - OPEN_FLOW_DIAGRAM_EDITOR: null, - CLOSE_FLOW_DIAGRAM_EDITOR: null, + FLOW_LIST_LOADED: null, + ADD_OR_UPDATE_FLOW: null, + ARTIFACT_LOADED: null, + DELETE_FLOW: null, - FLOW_LIST_LOADED: null, - ADD_OR_UPDATE_FLOW: null, - ARTIFACT_LOADED: null, - DELETE_FLOW: null, - - CURRENT_FLOW_DATA_CHANGED: null, - - RESET: null + CURRENT_FLOW_DATA_CHANGED: null, + RESET: null }); export const enums = { - WORKFLOW: 'WORKFLOW', - NETWORK: 'NETWORK_CALL_FLOW', - INFORMATIONAL: 'INFORMATIONAL', - INSTANTIATION_FLOWS: 'instantiationflows', - MESSAGE_FLOWS: 'messageflows' + WORKFLOW: 'WORKFLOW', + NETWORK: 'NETWORK_CALL_FLOW', + INFORMATIONAL: 'INFORMATIONAL', + INSTANTIATION_FLOWS: 'instantiationflows', + MESSAGE_FLOWS: 'messageflows' }; export const FLOWS_EDITOR_FORM = 'FLOWS_FORM'; diff --git a/openecomp-ui/src/sdc-app/flows/FlowsEditorModal.js b/openecomp-ui/src/sdc-app/flows/FlowsEditorModal.js index f9585f985f..b45a9fc54e 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsEditorModal.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsEditorModal.js @@ -13,44 +13,57 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import FlowsEditorModalView from './FlowsEditorModalView.jsx'; import FlowsActions from './FlowsActions.js'; -import {FLOWS_EDITOR_FORM} from './FlowsConstants.js'; +import { FLOWS_EDITOR_FORM } from './FlowsConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -export const mapStateToProps = ({flows}) => { +export const mapStateToProps = ({ flows }) => { + let { + data = { artifactName: '', description: '' }, + serviceID, + diagramType, + flowParticipants, + genericFieldInfo, + formReady + } = flows; + if (!data.serviceID) { + data.serviceID = serviceID; + } + if (!data.artifactType) { + data.artifactType = diagramType; + } + if (!data.participants) { + data.participants = flowParticipants; + } + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - let {data = {artifactName: '', description: ''}, serviceID, diagramType, flowParticipants, genericFieldInfo, formReady} = flows; - if(!data.serviceID){ - data.serviceID = serviceID; - } - if(!data.artifactType){ - data.artifactType = diagramType; - } - if(!data.participants){ - data.participants = flowParticipants; - } - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - - return { - currentFlow: data, - genericFieldInfo, - isFormValid, - formReady - }; + return { + currentFlow: data, + genericFieldInfo, + isFormValid, + formReady + }; }; -const mapActionsToProps = (dispatch, {isNewArtifact}) => { - return { - onSubmit: flow => { - FlowsActions.closeFlowDetailsEditor(dispatch); - FlowsActions.createOrUpdateFlow(dispatch, {flow}, isNewArtifact); - }, - onCancel: () => FlowsActions.closeFlowDetailsEditor(dispatch), - onDataChanged: deltaData => ValidationHelper.dataChanged(dispatch, {deltaData, formName: FLOWS_EDITOR_FORM}), - onValidateForm: () => ValidationHelper.validateForm(dispatch, FLOWS_EDITOR_FORM) - }; +const mapActionsToProps = (dispatch, { isNewArtifact }) => { + return { + onSubmit: flow => { + FlowsActions.closeFlowDetailsEditor(dispatch); + FlowsActions.createOrUpdateFlow(dispatch, { flow }, isNewArtifact); + }, + onCancel: () => FlowsActions.closeFlowDetailsEditor(dispatch), + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: FLOWS_EDITOR_FORM + }), + onValidateForm: () => + ValidationHelper.validateForm(dispatch, FLOWS_EDITOR_FORM) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(FlowsEditorModalView); +export default connect(mapStateToProps, mapActionsToProps)( + FlowsEditorModalView +); diff --git a/openecomp-ui/src/sdc-app/flows/FlowsEditorModalView.jsx b/openecomp-ui/src/sdc-app/flows/FlowsEditorModalView.jsx index 1250a0b58e..8c805cca9c 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsEditorModalView.jsx +++ b/openecomp-ui/src/sdc-app/flows/FlowsEditorModalView.jsx @@ -13,52 +13,73 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import Form from 'nfvo-components/input/validation/Form.jsx'; class FlowsEditorModalView extends Component { + render() { + let { + onCancel, + onDataChanged, + currentFlow, + genericFieldInfo, + formReady, + isFormValid, + onValidateForm + } = this.props; + let { artifactName, description } = currentFlow; + return ( +
    + {genericFieldInfo && ( +
    this.onSaveClicked()} + onReset={onCancel} + formReady={formReady} + isValid={isFormValid} + onValidateForm={() => onValidateForm()}> + + onDataChanged({ artifactName }) + } + /> + + onDataChanged({ description }) + } + /> +
    + )} +
    + ); + } - render() { - let {onCancel, onDataChanged, currentFlow, genericFieldInfo, formReady, isFormValid, onValidateForm} = this.props; - let {artifactName, description} = currentFlow; - return ( -
    - {genericFieldInfo &&
    this.onSaveClicked()} - onReset={onCancel} formReady={formReady} isValid={isFormValid} onValidateForm={() => onValidateForm()} > - onDataChanged({artifactName})}/> - onDataChanged({description})}/> -
    } -
    - ); - } - - onSaveClicked() { - let {currentFlow, onSubmit} = this.props; - if (onSubmit) { - onSubmit(currentFlow); - } - } - + onSaveClicked() { + let { currentFlow, onSubmit } = this.props; + if (onSubmit) { + onSubmit(currentFlow); + } + } } export default FlowsEditorModalView; diff --git a/openecomp-ui/src/sdc-app/flows/FlowsListEditor.js b/openecomp-ui/src/sdc-app/flows/FlowsListEditor.js index 642c578eb7..2718c19aaa 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsListEditor.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsListEditor.js @@ -13,40 +13,50 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import FlowsActions from './FlowsActions.js'; import FlowsListEditorView from './FlowsListEditorView.jsx'; -export const mapStateToProps = ({flows}) => { - let {flowList = [], isDisplayModal, isModalInEditMode, shouldShowWorkflowsEditor = true, data = undefined, readonly} = flows; - let isCheckedOut = !readonly; - if(data && data.readonly){ - isCheckedOut = !data.readonly; - } +export const mapStateToProps = ({ flows }) => { + let { + flowList = [], + isDisplayModal, + isModalInEditMode, + shouldShowWorkflowsEditor = true, + data = undefined, + readonly + } = flows; + let isCheckedOut = !readonly; + if (data && data.readonly) { + isCheckedOut = !data.readonly; + } - return { - flowList, - isDisplayModal, - isCheckedOut, - isModalInEditMode, - shouldShowWorkflowsEditor, - currentFlow: data, - readonly - }; + return { + flowList, + isDisplayModal, + isCheckedOut, + isModalInEditMode, + shouldShowWorkflowsEditor, + currentFlow: data, + readonly + }; }; -const mapActionsToProps = (dispatch) => { - return { - onAddWorkflowClick: () => FlowsActions.openFlowDetailsEditor(dispatch), - onEditFlowDetailsClick: flow => FlowsActions.openFlowDetailsEditor(dispatch, flow), - onEditFlowDiagramClick: flow => FlowsActions.fetchArtifact(dispatch, {flow}), - onDeleteFlowClick: flow => FlowsActions.deleteFlow(dispatch, {flow}), - onSequenceDiagramSaveClick: flow => { - FlowsActions.closeFlowDiagramEditor(dispatch); - FlowsActions.createOrUpdateFlow(dispatch, {flow}); - }, - onSequenceDiagramCloseClick: () => FlowsActions.closeFlowDiagramEditor(dispatch) - }; +const mapActionsToProps = dispatch => { + return { + onAddWorkflowClick: () => FlowsActions.openFlowDetailsEditor(dispatch), + onEditFlowDetailsClick: flow => + FlowsActions.openFlowDetailsEditor(dispatch, flow), + onEditFlowDiagramClick: flow => + FlowsActions.fetchArtifact(dispatch, { flow }), + onDeleteFlowClick: flow => FlowsActions.deleteFlow(dispatch, { flow }), + onSequenceDiagramSaveClick: flow => { + FlowsActions.closeFlowDiagramEditor(dispatch); + FlowsActions.createOrUpdateFlow(dispatch, { flow }); + }, + onSequenceDiagramCloseClick: () => + FlowsActions.closeFlowDiagramEditor(dispatch) + }; }; export default connect(mapStateToProps, mapActionsToProps)(FlowsListEditorView); diff --git a/openecomp-ui/src/sdc-app/flows/FlowsListEditorView.jsx b/openecomp-ui/src/sdc-app/flows/FlowsListEditorView.jsx index 365b7f1bdf..3b2ff0619c 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/flows/FlowsListEditorView.jsx @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; @@ -25,125 +25,146 @@ import FlowsEditorModal from './FlowsEditorModal.js'; import SequenceDiagram from './SequenceDiagram.jsx'; class FlowsListEditorView extends Component { - - static propTypes = { - flowList: PropTypes.array, - currentFlow: PropTypes.object, - isDisplayModal: PropTypes.bool, - isModalInEditMode: PropTypes.bool, - isCheckedOut: PropTypes.bool, - shouldShowWorkflowsEditor: PropTypes.bool, - readonly: PropTypes.bool, - - onAddWorkflowClick: PropTypes.func, - onEditFlowDetailsClick: PropTypes.func, - onEditFlowDiagramClick: PropTypes.func, - onDeleteFlowClick: PropTypes.func, - onSequenceDiagramSaveClick: PropTypes.func, - onSequenceDiagramCloseClick: PropTypes.func - }; - - state = { - localFilter: '' - }; - - render() { - let CurrentView = null; - if (this.props.shouldShowWorkflowsEditor) { - CurrentView = this.renderWorkflowsEditor(); - } - else { - CurrentView = this.renderSequenceDiagramTool(); - } - - return CurrentView; - } - - renderWorkflowsEditor() { - let {isDisplayModal, onAddWorkflowClick, isCheckedOut} = this.props; - const {localFilter} = this.state; - - return ( -
    - - this.setState({localFilter: filter})} - isReadOnlyMode={!isCheckedOut}> - {this.filterList().map(flow => this.renderWorkflowListItem(flow, isCheckedOut))} - - - {isDisplayModal && this.renderWorkflowEditorModal()} - -
    - ); - } - - renderWorkflowEditorModal() { - let { isDisplayModal, isModalInEditMode} = this.props; - return ( - - - - {`${isModalInEditMode ? i18n('Edit Workflow') : i18n('Create New Workflow')}`} - - - - - - - ); - } - - renderSequenceDiagramTool() { - let {onSequenceDiagramSaveClick, onSequenceDiagramCloseClick, currentFlow} = this.props; - return ( - onSequenceDiagramSaveClick({...currentFlow, sequenceDiagramModel})} - onClose={onSequenceDiagramCloseClick} - model={currentFlow.sequenceDiagramModel}/> - ); - } - - filterList() { - let {flowList} = this.props; - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return flowList.filter(({name = '', description = ''}) => { - return escape(name).match(filter) || escape(description).match(filter); - }); - } - else { - return flowList; - } - } - - renderWorkflowListItem(flow, isCheckedOut) { - let {uniqueId, artifactName, description} = flow; - let {onEditFlowDetailsClick, onEditFlowDiagramClick, onDeleteFlowClick} = this.props; - return ( - onEditFlowDetailsClick(flow)} - onDelete={() => onDeleteFlowClick(flow)} - onEdit={() => onEditFlowDiagramClick(flow)} - className='list-editor-item-view' - isCheckedOut={isCheckedOut}> -
    -
    {i18n('Name')}
    -
    {artifactName}
    -
    -
    -
    {i18n('Description')}
    -
    {description}
    -
    -
    - ); - } - + static propTypes = { + flowList: PropTypes.array, + currentFlow: PropTypes.object, + isDisplayModal: PropTypes.bool, + isModalInEditMode: PropTypes.bool, + isCheckedOut: PropTypes.bool, + shouldShowWorkflowsEditor: PropTypes.bool, + readonly: PropTypes.bool, + + onAddWorkflowClick: PropTypes.func, + onEditFlowDetailsClick: PropTypes.func, + onEditFlowDiagramClick: PropTypes.func, + onDeleteFlowClick: PropTypes.func, + onSequenceDiagramSaveClick: PropTypes.func, + onSequenceDiagramCloseClick: PropTypes.func + }; + + state = { + localFilter: '' + }; + + render() { + let CurrentView = null; + if (this.props.shouldShowWorkflowsEditor) { + CurrentView = this.renderWorkflowsEditor(); + } else { + CurrentView = this.renderSequenceDiagramTool(); + } + + return CurrentView; + } + + renderWorkflowsEditor() { + let { isDisplayModal, onAddWorkflowClick, isCheckedOut } = this.props; + const { localFilter } = this.state; + + return ( +
    + + this.setState({ localFilter: filter })} + isReadOnlyMode={!isCheckedOut}> + {this.filterList().map(flow => + this.renderWorkflowListItem(flow, isCheckedOut) + )} + + + {isDisplayModal && this.renderWorkflowEditorModal()} +
    + ); + } + + renderWorkflowEditorModal() { + let { isDisplayModal, isModalInEditMode } = this.props; + return ( + + + + {`${ + isModalInEditMode + ? i18n('Edit Workflow') + : i18n('Create New Workflow') + }`} + + + + + + + ); + } + + renderSequenceDiagramTool() { + let { + onSequenceDiagramSaveClick, + onSequenceDiagramCloseClick, + currentFlow + } = this.props; + return ( + + onSequenceDiagramSaveClick({ + ...currentFlow, + sequenceDiagramModel + }) + } + onClose={onSequenceDiagramCloseClick} + model={currentFlow.sequenceDiagramModel} + /> + ); + } + + filterList() { + let { flowList } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return flowList.filter(({ name = '', description = '' }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) + ); + }); + } else { + return flowList; + } + } + + renderWorkflowListItem(flow, isCheckedOut) { + let { uniqueId, artifactName, description } = flow; + let { + onEditFlowDetailsClick, + onEditFlowDiagramClick, + onDeleteFlowClick + } = this.props; + return ( + onEditFlowDetailsClick(flow)} + onDelete={() => onDeleteFlowClick(flow)} + onEdit={() => onEditFlowDiagramClick(flow)} + className="list-editor-item-view" + isCheckedOut={isCheckedOut}> +
    +
    {i18n('Name')}
    +
    {artifactName}
    +
    +
    +
    {i18n('Description')}
    +
    {description}
    +
    +
    + ); + } } export default FlowsListEditorView; diff --git a/openecomp-ui/src/sdc-app/flows/FlowsListReducer.js b/openecomp-ui/src/sdc-app/flows/FlowsListReducer.js index 14bf595050..0279824ac4 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsListReducer.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsListReducer.js @@ -13,87 +13,91 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, FLOWS_EDITOR_FORM} from './FlowsConstants.js'; +import { actionTypes, FLOWS_EDITOR_FORM } from './FlowsConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.FLOW_LIST_LOADED: - return { - ...state, - flowList: action.results, - flowParticipants: action.participants, - serviceID: action.serviceID, - diagramType: action.diagramType, - readonly: action.readonly - }; - case actionTypes.ADD_OR_UPDATE_FLOW: - case actionTypes.ARTIFACT_LOADED: - let flowList = state.flowList || []; - let index = flowList.findIndex(flow => flow.uniqueId === action.flow.uniqueId); - if (index === -1) { - index = flowList.length; - } - let flowToBeUpdated = flowList[index]; - flowList = [ - ...flowList.slice(0, index), - {...flowToBeUpdated, ...action.flow}, - ...flowList.slice(index + 1) - ]; - return { - ...state, - flowList, - serviceID: action.flow.serviceID, - diagramType: action.flow.artifactType || state.diagramType - }; - case actionTypes.DELETE_FLOW: - return { - ...state, - flowList: state.flowList.filter(flow => flow.uniqueId !== action.flow.uniqueId) - }; - case actionTypes.OPEN_FLOW_DETAILS_EDITOR: - return { - ...state, - formName: FLOWS_EDITOR_FORM, - formReady: null, - genericFieldInfo: { - artifactName : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - }, - description: { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - } - }, - data: action.flow, - isDisplayModal: true, - isModalInEditMode: Boolean(action.flow && action.flow.uniqueId) - }; + switch (action.type) { + case actionTypes.FLOW_LIST_LOADED: + return { + ...state, + flowList: action.results, + flowParticipants: action.participants, + serviceID: action.serviceID, + diagramType: action.diagramType, + readonly: action.readonly + }; + case actionTypes.ADD_OR_UPDATE_FLOW: + case actionTypes.ARTIFACT_LOADED: + let flowList = state.flowList || []; + let index = flowList.findIndex( + flow => flow.uniqueId === action.flow.uniqueId + ); + if (index === -1) { + index = flowList.length; + } + let flowToBeUpdated = flowList[index]; + flowList = [ + ...flowList.slice(0, index), + { ...flowToBeUpdated, ...action.flow }, + ...flowList.slice(index + 1) + ]; + return { + ...state, + flowList, + serviceID: action.flow.serviceID, + diagramType: action.flow.artifactType || state.diagramType + }; + case actionTypes.DELETE_FLOW: + return { + ...state, + flowList: state.flowList.filter( + flow => flow.uniqueId !== action.flow.uniqueId + ) + }; + case actionTypes.OPEN_FLOW_DETAILS_EDITOR: + return { + ...state, + formName: FLOWS_EDITOR_FORM, + formReady: null, + genericFieldInfo: { + artifactName: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + }, + description: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + } + }, + data: action.flow, + isDisplayModal: true, + isModalInEditMode: Boolean(action.flow && action.flow.uniqueId) + }; - case actionTypes.CLOSE_FLOW_DETAILS_EDITOR: - return { - ...state, - data: undefined, - isDisplayModal: false, - isModalInEditMode: false - }; - case actionTypes.OPEN_FLOW_DIAGRAM_EDITOR: - return { - ...state, - data: action.flow, - shouldShowWorkflowsEditor: false - }; - case actionTypes.CLOSE_FLOW_DIAGRAM_EDITOR: - return { - ...state, - data: undefined, - shouldShowWorkflowsEditor: true - }; - case actionTypes.RESET: - return {}; - } + case actionTypes.CLOSE_FLOW_DETAILS_EDITOR: + return { + ...state, + data: undefined, + isDisplayModal: false, + isModalInEditMode: false + }; + case actionTypes.OPEN_FLOW_DIAGRAM_EDITOR: + return { + ...state, + data: action.flow, + shouldShowWorkflowsEditor: false + }; + case actionTypes.CLOSE_FLOW_DIAGRAM_EDITOR: + return { + ...state, + data: undefined, + shouldShowWorkflowsEditor: true + }; + case actionTypes.RESET: + return {}; + } - return state; + return state; }; diff --git a/openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx b/openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx index a2a5554203..7d302444e4 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx +++ b/openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx @@ -22,57 +22,66 @@ import FlowsListEditor from './FlowsListEditor.js'; import FlowsActions from './FlowsActions.js'; class FlowsListEditorPunchOutWrapper extends React.Component { + componentDidMount() { + let element = ReactDOM.findDOMNode(this); + element.addEventListener('click', event => { + if (event.target.tagName === 'A') { + event.preventDefault(); + } + }); + ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType => + element.addEventListener(eventType, event => + event.stopPropagation() + ) + ); + } - componentDidMount() { - let element = ReactDOM.findDOMNode(this); - element.addEventListener('click', event => { - if (event.target.tagName === 'A') { - event.preventDefault(); - } - }); - ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType => - element.addEventListener(eventType, event => event.stopPropagation()) - ); - } - - render() { - return ; - } + render() { + return ; + } } export default class DiagramPunchOut { + render({ options: { data, apiRoot, apiHeaders }, onEvent }, element) { + if (!this.isConfigSet) { + Configuration.setCatalogApiRoot(apiRoot); + Configuration.setCatalogApiHeaders(apiHeaders); + this.isConfigSet = true; + } - render({options: {data, apiRoot, apiHeaders}, onEvent}, element) { - - if (!this.isConfigSet) { - Configuration.setCatalogApiRoot(apiRoot); - Configuration.setCatalogApiHeaders(apiHeaders); - this.isConfigSet = true; - } - - this.onEvent = onEvent; - this.handleData(data); + this.onEvent = onEvent; + this.handleData(data); - if (!this.rendered) { - ReactDOM.render(
    , element); - this.rendered = true; - } - } + if (!this.rendered) { + ReactDOM.render( + +
    + +
    +
    , + element + ); + this.rendered = true; + } + } - unmount(element) { - let dispatch = action => store.dispatch(action); - ReactDOM.unmountComponentAtNode(element); - FlowsActions.reset(dispatch); - } + unmount(element) { + let dispatch = action => store.dispatch(action); + ReactDOM.unmountComponentAtNode(element); + FlowsActions.reset(dispatch); + } - handleData(data) { - let {serviceID, diagramType} = data; - let dispatch = action => store.dispatch(action); + handleData(data) { + let { serviceID, diagramType } = data; + let dispatch = action => store.dispatch(action); - if (serviceID !== this.prevServiceID || diagramType !== this.prevDiagramType) { - this.prevServiceID = serviceID; - this.prevDiagramType = diagramType; - FlowsActions.fetchFlowArtifacts(dispatch, {...data}); - } - } + if ( + serviceID !== this.prevServiceID || + diagramType !== this.prevDiagramType + ) { + this.prevServiceID = serviceID; + this.prevDiagramType = diagramType; + FlowsActions.fetchFlowArtifacts(dispatch, { ...data }); + } + } } diff --git a/openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js b/openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js index 54043498f0..c037f3eefd 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js @@ -15,8 +15,8 @@ */ import flowListReducer from './FlowsListReducer.js'; -import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js'; +import { createPlainDataReducer } from 'sdc-app/common/reducers/PlainDataReducer.js'; export default { - flows: createPlainDataReducer(flowListReducer) + flows: createPlainDataReducer(flowListReducer) }; diff --git a/openecomp-ui/src/sdc-app/flows/ImportantLogic.jsx b/openecomp-ui/src/sdc-app/flows/ImportantLogic.jsx index d0a5bf3251..8a634915ac 100644 --- a/openecomp-ui/src/sdc-app/flows/ImportantLogic.jsx +++ b/openecomp-ui/src/sdc-app/flows/ImportantLogic.jsx @@ -13,27 +13,31 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import md5 from 'md5'; class ImportantLogic extends Component { + state = { + whatToDisplay: false + }; - state = { - whatToDisplay: false - }; + componentWillReceiveProps(nextProps) { + this.setState({ + whatToDisplay: + md5(nextProps.display) === 'a55899b341525123628776dbf5755d51' + }); + } - componentWillReceiveProps(nextProps) { - this.setState({whatToDisplay: md5(nextProps.display) === 'a55899b341525123628776dbf5755d51'}); - } + render() { + if (this.state.whatToDisplay) { + setTimeout(() => this.setState({ whatToDisplay: false }), 5000); + } - render() { - if (this.state.whatToDisplay) { - setTimeout(() => this.setState({whatToDisplay: false}), 5000); - } - - return ( -
    - -
    - {} - {} -
    -
    - ); - } + }' + } + +
    + {} + {} +
    +
    + ); + } } export default ImportantLogic; diff --git a/openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx b/openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx index c128083774..ca24964472 100644 --- a/openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx +++ b/openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Button from 'sdc-ui/lib/react/Button.js'; import Sequencer from 'dox-sequence-diagram-ui'; @@ -21,31 +21,37 @@ import Sequencer from 'dox-sequence-diagram-ui'; import i18n from 'nfvo-utils/i18n/i18n.js'; class SequenceDiagram extends Component { + static propTypes = { + onSave: PropTypes.func.isRequired, + onClose: PropTypes.func, + model: PropTypes.object.isRequired + }; - static propTypes = { - onSave: PropTypes.func.isRequired, - onClose: PropTypes.func, - model: PropTypes.object.isRequired - }; - - onSave() { - this.props.onSave(this.refs.sequencer.getModel()); - } - - render() { - return ( -
    -
    - -
    -
    - - -
    -
    - ); - } + onSave() { + this.props.onSave(this.refs.sequencer.getModel()); + } + render() { + return ( +
    +
    + +
    +
    + + +
    +
    + ); + } } export default SequenceDiagram; diff --git a/openecomp-ui/src/sdc-app/flows/SequenceDiagramModelHelper.js b/openecomp-ui/src/sdc-app/flows/SequenceDiagramModelHelper.js index c83fdc91f0..23723dc91d 100644 --- a/openecomp-ui/src/sdc-app/flows/SequenceDiagramModelHelper.js +++ b/openecomp-ui/src/sdc-app/flows/SequenceDiagramModelHelper.js @@ -16,51 +16,54 @@ import emptyModel from './emptyModel.json'; function mergeLifelines(oldLifelines, newLifelines) { - let oldLifelinesMap = new Map(oldLifelines.map(lifeline => [lifeline.id, lifeline])); - let newLifelinesMap = new Map(newLifelines.map(lifeline => [lifeline.id, lifeline])); + let oldLifelinesMap = new Map( + oldLifelines.map(lifeline => [lifeline.id, lifeline]) + ); + let newLifelinesMap = new Map( + newLifelines.map(lifeline => [lifeline.id, lifeline]) + ); - let updatedLifelines = oldLifelines.map(lifeline => { - let newLifeline = newLifelinesMap.get(lifeline.id); - return { - ...lifeline, - name: newLifeline ? newLifeline.name : lifeline.name - }; - }); + let updatedLifelines = oldLifelines.map(lifeline => { + let newLifeline = newLifelinesMap.get(lifeline.id); + return { + ...lifeline, + name: newLifeline ? newLifeline.name : lifeline.name + }; + }); - let addedLifelines = newLifelines.filter(lifeline => !oldLifelinesMap.has(lifeline.id)); + let addedLifelines = newLifelines.filter( + lifeline => !oldLifelinesMap.has(lifeline.id) + ); - return [ - ...updatedLifelines, - ...addedLifelines - ]; + return [...updatedLifelines, ...addedLifelines]; } - const SequenceDiagramModelHelper = Object.freeze({ + createModel(options) { + return SequenceDiagramModelHelper.updateModel(emptyModel, options); + }, - createModel(options) { - return SequenceDiagramModelHelper.updateModel(emptyModel, options); - }, - - updateModel(model, options) { - const diagram = model.diagram; - const metadata = diagram.metadata || model.metadata; - const id = options.id || metadata.id; - const name = options.name || metadata.name; - const lifelines = options.lifelines ? mergeLifelines(diagram.lifelines, options.lifelines) : diagram.lifelines; + updateModel(model, options) { + const diagram = model.diagram; + const metadata = diagram.metadata || model.metadata; + const id = options.id || metadata.id; + const name = options.name || metadata.name; + const lifelines = options.lifelines + ? mergeLifelines(diagram.lifelines, options.lifelines) + : diagram.lifelines; - return { - diagram: { - ...diagram, - metadata: { - ...metadata, - id, - name - }, - lifelines - } - }; - } + return { + diagram: { + ...diagram, + metadata: { + ...metadata, + id, + name + }, + lifelines + } + }; + } }); export default SequenceDiagramModelHelper; diff --git a/openecomp-ui/src/sdc-app/heatValidation.app.jsx b/openecomp-ui/src/sdc-app/heatValidation.app.jsx index 5abe3091b3..bb9a4bbe9b 100644 --- a/openecomp-ui/src/sdc-app/heatValidation.app.jsx +++ b/openecomp-ui/src/sdc-app/heatValidation.app.jsx @@ -23,5 +23,9 @@ import ReactDOM from 'react-dom'; import UploadScreen from './heatvalidation/UploadScreen.jsx'; import Application from './Application.jsx'; - -ReactDOM.render(, document.getElementById('heat-validation-app')); +ReactDOM.render( + + + , + document.getElementById('heat-validation-app') +); diff --git a/openecomp-ui/src/sdc-app/heatvalidation/Attachments.js b/openecomp-ui/src/sdc-app/heatvalidation/Attachments.js index d3e30b0df8..4532c0a7d2 100644 --- a/openecomp-ui/src/sdc-app/heatvalidation/Attachments.js +++ b/openecomp-ui/src/sdc-app/heatvalidation/Attachments.js @@ -13,32 +13,53 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; -import {mapStateToProps as attachmentsMapStateToProps, mapActionsToProps as attachmentsMapActionsToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js'; +import { + mapStateToProps as attachmentsMapStateToProps, + mapActionsToProps as attachmentsMapActionsToProps +} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js'; // import AttachmentsView from './AttachmentsView.jsx'; import AttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx'; import UploadScreenActionHelper from './UploadScreenActionHelper.js'; import HeatSetup from './HeatSetup'; -export const mapStateToProps = (state) => { - let original = attachmentsMapStateToProps(state); - return { - ...original, - HeatSetupComponent: HeatSetup, - isReadOnlyMode: false - }; +export const mapStateToProps = state => { + let original = attachmentsMapStateToProps(state); + return { + ...original, + HeatSetupComponent: HeatSetup, + isReadOnlyMode: false + }; }; -const mapActionsToProps = (dispatch, {softwareProductId}) => { - let original = attachmentsMapActionsToProps(dispatch, {softwareProductId}); - return { - ...original, - onDownload: heatCandidate => UploadScreenActionHelper.downloadHeatFile(dispatch, heatCandidate), - onUpload: formData => UploadScreenActionHelper.uploadFile(dispatch, formData), - onSave: (heatCandidate) => SoftwareProductActionHelper.updateSoftwareProductHeatCandidate(dispatch, {softwareProductId, heatCandidate}), - onProcessAndValidate: (heatData, heatDataCache) => UploadScreenActionHelper.processAndValidateHeat(dispatch, heatData, heatDataCache) - }; +const mapActionsToProps = (dispatch, { softwareProductId }) => { + let original = attachmentsMapActionsToProps(dispatch, { + softwareProductId + }); + return { + ...original, + onDownload: heatCandidate => + UploadScreenActionHelper.downloadHeatFile(dispatch, heatCandidate), + onUpload: formData => + UploadScreenActionHelper.uploadFile(dispatch, formData), + onSave: heatCandidate => + SoftwareProductActionHelper.updateSoftwareProductHeatCandidate( + dispatch, + { + softwareProductId, + heatCandidate + } + ), + onProcessAndValidate: (heatData, heatDataCache) => + UploadScreenActionHelper.processAndValidateHeat( + dispatch, + heatData, + heatDataCache + ) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(AttachmentsView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(AttachmentsView); diff --git a/openecomp-ui/src/sdc-app/heatvalidation/HeatSetup.js b/openecomp-ui/src/sdc-app/heatvalidation/HeatSetup.js index 925b0095ba..a94cfd9f81 100644 --- a/openecomp-ui/src/sdc-app/heatvalidation/HeatSetup.js +++ b/openecomp-ui/src/sdc-app/heatvalidation/HeatSetup.js @@ -13,16 +13,26 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; -import HeatSetupView from '../onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx'; +import { connect } from 'react-redux'; +import HeatSetupView from '../onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx'; import UploadScreenActionHelper from './UploadScreenActionHelper.js'; -import {mapStateToProps, mapActionsToProps} from '../onboarding/softwareProduct/attachments/setup/HeatSetup.js'; +import { + mapStateToProps, + mapActionsToProps +} from '../onboarding/softwareProduct/attachments/setup/HeatSetup.js'; -const mapActionsToPropsExt = (dispatch) => { - return { - ...mapActionsToProps(dispatch,{}), - onProcessAndValidate: (heatData, heatDataCache) => UploadScreenActionHelper.processAndValidateHeat(dispatch, heatData, heatDataCache) - }; +const mapActionsToPropsExt = dispatch => { + return { + ...mapActionsToProps(dispatch, {}), + onProcessAndValidate: (heatData, heatDataCache) => + UploadScreenActionHelper.processAndValidateHeat( + dispatch, + heatData, + heatDataCache + ) + }; }; -export default connect(mapStateToProps, mapActionsToPropsExt, null, {withRef: true})(HeatSetupView); +export default connect(mapStateToProps, mapActionsToPropsExt, null, { + withRef: true +})(HeatSetupView); diff --git a/openecomp-ui/src/sdc-app/heatvalidation/UploadScreen.jsx b/openecomp-ui/src/sdc-app/heatvalidation/UploadScreen.jsx index 2d99c0f497..6d3d54b5cb 100644 --- a/openecomp-ui/src/sdc-app/heatvalidation/UploadScreen.jsx +++ b/openecomp-ui/src/sdc-app/heatvalidation/UploadScreen.jsx @@ -16,17 +16,14 @@ import React from 'react'; import SoftwareProductAttachmentsView from './Attachments.js'; - - class UploadScreen extends React.Component { - - render() { - return( -
    - -
    - ); - } + render() { + return ( +
    + +
    + ); + } } -export default UploadScreen; +export default UploadScreen; diff --git a/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenActionHelper.js b/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenActionHelper.js index fa2d4695ae..f5d9abd6d2 100644 --- a/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenActionHelper.js +++ b/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenActionHelper.js @@ -18,155 +18,197 @@ import showFileSaveDialog from 'nfvo-utils/ShowFileSaveDialog.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import isEqual from 'lodash/isEqual.js'; import cloneDeep from 'lodash/cloneDeep.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes as softwareProductsActionTypes} from '../onboarding/softwareProduct/SoftwareProductConstants.js'; -import {actionTypes as HeatSetupActions} from '../onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js'; - - +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes as softwareProductsActionTypes } from '../onboarding/softwareProduct/SoftwareProductConstants.js'; +import { actionTypes as HeatSetupActions } from '../onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js'; const options = { - headers: { - USER_ID: 'validationOnlyVspUser' - } + headers: { + USER_ID: 'validationOnlyVspUser' + } }; function fetchVspIdAndVersion() { - - let vspId = sessionStorage.getItem('validationAppVspId'); - let versionId = sessionStorage.getItem('validationAppVersionId'); - if (vspId) { - return Promise.resolve({value: vspId, versionId}); - }else { - return RestAPIUtil.fetch('/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/validation-vsp', options) - .then(response => { - sessionStorage.setItem('validationAppVspId', response.itemId); - sessionStorage.setItem('validationAppVersionId', response.version.id); - return Promise.resolve({value: response.itemId, versionId: response.version.id}); - }); - } - + let vspId = sessionStorage.getItem('validationAppVspId'); + let versionId = sessionStorage.getItem('validationAppVersionId'); + if (vspId) { + return Promise.resolve({ value: vspId, versionId }); + } else { + return RestAPIUtil.fetch( + '/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/validation-vsp', + options + ).then(response => { + sessionStorage.setItem('validationAppVspId', response.itemId); + sessionStorage.setItem( + 'validationAppVersionId', + response.version.id + ); + return Promise.resolve({ + value: response.itemId, + versionId: response.version.id + }); + }); + } } - function uploadFile(formData) { - return fetchVspIdAndVersion() - .then(response => { - return RestAPIUtil.post(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/${response.versionId}/orchestration-template-candidate`, formData, options); - }); + return fetchVspIdAndVersion().then(response => { + return RestAPIUtil.post( + `/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${ + response.value + }/versions/${response.versionId}/orchestration-template-candidate`, + formData, + options + ); + }); } -function loadSoftwareProductHeatCandidate(dispatch){ - return fetchVspIdAndVersion() - .then(response => { - return RestAPIUtil.fetch(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/${response.versionId}/orchestration-template-candidate/manifest`, options) - .then(response => dispatch({ - type: HeatSetupActions.MANIFEST_LOADED, - response - })); - }); +function loadSoftwareProductHeatCandidate(dispatch) { + return fetchVspIdAndVersion().then(response => { + return RestAPIUtil.fetch( + `/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${ + response.value + }/versions/${ + response.versionId + }/orchestration-template-candidate/manifest`, + options + ).then(response => + dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response + }) + ); + }); } function updateHeatCandidate(dispatch, heatCandidate) { - return fetchVspIdAndVersion() - .then(response => { - return RestAPIUtil.put(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/${response.versionId}/orchestration-template-candidate/manifest`, - heatCandidate.heatData, options) - .then(null, error => { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - title: i18n('Save Failed'), - modalComponentName: modalContentMapper.SUMBIT_ERROR_RESPONSE, - modalComponentProps: { - validationResponse: error.responseJSON - }, - cancelButtonText: i18n('Ok') - } - }); - return Promise.reject(error); - }); - }); + return fetchVspIdAndVersion().then(response => { + return RestAPIUtil.put( + `/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${ + response.value + }/versions/${ + response.versionId + }/orchestration-template-candidate/manifest`, + heatCandidate.heatData, + options + ).then(null, error => { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('Save Failed'), + modalComponentName: + modalContentMapper.SUMBIT_ERROR_RESPONSE, + modalComponentProps: { + validationResponse: error.responseJSON + }, + cancelButtonText: i18n('Ok') + } + }); + return Promise.reject(error); + }); + }); } function fetchSoftwareProduct() { - return fetchVspIdAndVersion() - .then(response => { - return RestAPIUtil.fetch(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/${response.versionId}`, options); - }); + return fetchVspIdAndVersion().then(response => { + return RestAPIUtil.fetch( + `/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${ + response.value + }/versions/${response.versionId}`, + options + ); + }); } function downloadHeatFile() { - return fetchVspIdAndVersion() - .then(response => { - RestAPIUtil.fetch(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/${response.versionId}/orchestration-template-candidate`, { - ...options, - dataType: 'binary' - }) - .done((response) => showFileSaveDialog({ - blob: response.blob, - headers: response.headers, - defaultFilename: 'HEAT_file.zip', - addTimestamp: true - })); - }); + return fetchVspIdAndVersion().then(response => { + RestAPIUtil.fetch( + `/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${ + response.value + }/versions/${response.versionId}/orchestration-template-candidate`, + { + ...options, + dataType: 'binary' + } + ).done(response => + showFileSaveDialog({ + blob: response.blob, + headers: response.headers, + defaultFilename: 'HEAT_file.zip', + addTimestamp: true + }) + ); + }); } function processAndValidateHeatCandidate(dispatch) { - return fetchVspIdAndVersion() - .then(response => { - return RestAPIUtil.put(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/${response.versionId}/orchestration-template-candidate/process`, {}, options) - .then(response => { - if (response.status === 'Success') { - fetchSoftwareProduct().then(response => { - dispatch({ - type: softwareProductsActionTypes.SOFTWARE_PRODUCT_LOADED, - response - }); - }); - } - }); - }); + return fetchVspIdAndVersion().then(response => { + return RestAPIUtil.put( + `/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${ + response.value + }/versions/${ + response.versionId + }/orchestration-template-candidate/process`, + {}, + options + ).then(response => { + if (response.status === 'Success') { + fetchSoftwareProduct().then(response => { + dispatch({ + type: + softwareProductsActionTypes.SOFTWARE_PRODUCT_LOADED, + response + }); + }); + } + }); + }); } const UploadScreenActionHelper = { - uploadFile(dispatch, formData) { - - return Promise.resolve() - .then(() => uploadFile(formData)) - .then(response => { - dispatch({ - type: softwareProductsActionTypes.SOFTWARE_PRODUCT_LOADED, - response - }); - dispatch({ - type: HeatSetupActions.FILL_HEAT_SETUP_CACHE, - payload:{} - }); - loadSoftwareProductHeatCandidate(dispatch); - }) - .catch(error => { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - title: i18n('File Upload Failed'), - msg: error.responseJSON.message, - cancelButtonText: i18n('Ok') - } - }); - }); - }, - - processAndValidateHeat(dispatch, heatData, heatDataCache){ - return isEqual(heatData, heatDataCache) ? Promise.resolve() : - updateHeatCandidate(dispatch, heatData) - .then(() => processAndValidateHeatCandidate(dispatch)) - .then(() => dispatch({type: HeatSetupActions.FILL_HEAT_SETUP_CACHE, payload: cloneDeep(heatData)})); - }, - - downloadHeatFile(){ - return downloadHeatFile(); - }, + uploadFile(dispatch, formData) { + return Promise.resolve() + .then(() => uploadFile(formData)) + .then(response => { + dispatch({ + type: softwareProductsActionTypes.SOFTWARE_PRODUCT_LOADED, + response + }); + dispatch({ + type: HeatSetupActions.FILL_HEAT_SETUP_CACHE, + payload: {} + }); + loadSoftwareProductHeatCandidate(dispatch); + }) + .catch(error => { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('File Upload Failed'), + msg: error.responseJSON.message, + cancelButtonText: i18n('Ok') + } + }); + }); + }, + + processAndValidateHeat(dispatch, heatData, heatDataCache) { + return isEqual(heatData, heatDataCache) + ? Promise.resolve() + : updateHeatCandidate(dispatch, heatData) + .then(() => processAndValidateHeatCandidate(dispatch)) + .then(() => + dispatch({ + type: HeatSetupActions.FILL_HEAT_SETUP_CACHE, + payload: cloneDeep(heatData) + }) + ); + }, + + downloadHeatFile() { + return downloadHeatFile(); + } }; export default UploadScreenActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/GridStyling.stories.js b/openecomp-ui/src/sdc-app/onboarding/GridStyling.stories.js index 81a29cf046..7b8c87e62c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/GridStyling.stories.js +++ b/openecomp-ui/src/sdc-app/onboarding/GridStyling.stories.js @@ -1,221 +1,151 @@ import React from 'react'; -import {storiesOf} from '@kadira/storybook'; -import {withKnobs} from '@kadira/storybook-addon-knobs'; +import { storiesOf } from '@kadira/storybook'; +import { withKnobs } from '@kadira/storybook-addon-knobs'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; - const stories = storiesOf('GridColumns', module); stories.addDecorator(withKnobs); var divStyle = { - 'border-style': 'solid', - 'border-size': 1 + 'border-style': 'solid', + 'border-size': 1 }; -const myDiv = (
    Text Text Text
    ); +const myDiv =
    Text Text Text
    ; stories - .add('Grid Options', () => ( -
    - - - {myDiv} - - - {myDiv} - - - - - - {myDiv} - - - {myDiv} - - - - - - {myDiv} - - - {myDiv} - - + .add('Grid Options', () => ( +
    + + {myDiv} + {myDiv} + -
    - )) - .add('Last Column', () => ( + + {myDiv} + + {myDiv} + + -
    - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - -
    - )) - .add('No Last Column', () => ( -
    - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - - - - {myDiv} - - - {myDiv} - - -
    - )) .add('Test LKG form', () => ( -
    - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - {myDiv} - - - {myDiv} - - -
    1
    -
    -
    -
    -)); \ No newline at end of file + + {myDiv} + + {myDiv} + + +
    + )) + .add('Last Column', () => ( +
    + + {myDiv} + + {myDiv} + + + + {myDiv} + {myDiv} + {myDiv} + + {myDiv} + + + + {myDiv} + {myDiv} + + {myDiv} + + + + {myDiv} + {myDiv} + + {myDiv} + + + + + {myDiv} + + + + {myDiv} + + {myDiv} + + + + {myDiv} + + {myDiv} + + +
    + )) + .add('No Last Column', () => ( +
    + + {myDiv} + {myDiv} + + + {myDiv} + {myDiv} + {myDiv} + {myDiv} + + + {myDiv} + {myDiv} + {myDiv} + + + {myDiv} + {myDiv} + {myDiv} + + + {myDiv} + + + {myDiv} + {myDiv} + + + {myDiv} + {myDiv} + +
    + )) + .add('Test LKG form', () => ( +
    + + {myDiv} + + {myDiv} + + {myDiv} + + {myDiv} + + {myDiv} + {myDiv} + {myDiv} + + {myDiv} + + +
    1
    +
    +
    +
    + )); diff --git a/openecomp-ui/src/sdc-app/onboarding/Onboarding.js b/openecomp-ui/src/sdc-app/onboarding/Onboarding.js index faec816d42..b894e3f031 100644 --- a/openecomp-ui/src/sdc-app/onboarding/Onboarding.js +++ b/openecomp-ui/src/sdc-app/onboarding/Onboarding.js @@ -15,8 +15,8 @@ */ import OnboardingView from './OnboardingView.jsx'; -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; -const mapStateToProps = ({currentScreen}) => ({currentScreen}); +const mapStateToProps = ({ currentScreen }) => ({ currentScreen }); const Onboarding = connect(mapStateToProps, null)(OnboardingView); export default Onboarding; diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js index d75c234caf..2fccfcbd2a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js @@ -34,289 +34,591 @@ import ComputeFlavorActionHelper from './softwareProduct/components/compute/Comp import OnboardActionHelper from './onboard/OnboardActionHelper.js'; import MergeEditorActionHelper from 'sdc-app/common/merge/MergeEditorActionHelper.js'; import SoftwareProductComponentsMonitoringAction from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js'; -import {actionTypes, enums} from './OnboardingConstants.js'; -import {actionTypes as SoftwareProductActionTypes, onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { actionTypes, enums } from './OnboardingConstants.js'; +import { + actionTypes as SoftwareProductActionTypes, + onboardingOriginTypes +} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; import ActivityLogActionHelper from 'sdc-app/common/activity-log/ActivityLogActionHelper.js'; import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; import SoftwareProductComponentsImageActionHelper from './softwareProduct/components/images/SoftwareProductComponentsImageActionHelper.js'; import licenseModelOverviewActionHelper from 'sdc-app/onboarding/licenseModel/overview/licenseModelOverviewActionHelper.js'; -import {tabsMapping as attachmentsTabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js'; +import { tabsMapping as attachmentsTabsMapping } from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js'; import SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js'; function setCurrentScreen(dispatch, screen, props = {}) { - dispatch({ - type: actionTypes.SET_CURRENT_SCREEN, - currentScreen: { - screen, - props, - forceBreadCrumbsUpdate: true - } - }); + dispatch({ + type: actionTypes.SET_CURRENT_SCREEN, + currentScreen: { + screen, + props, + forceBreadCrumbsUpdate: true + } + }); } export function updateCurrentScreenProps(dispatch, props = {}) { - dispatch({ - type: actionTypes.UPDATE_CURRENT_SCREEN_PROPS, - props - }); + dispatch({ + type: actionTypes.UPDATE_CURRENT_SCREEN_PROPS, + props + }); } const OnboardingActionHelper = { - - loadItemsLists(dispatch) { - LicenseModelActionHelper.fetchLicenseModels(dispatch); - LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch); - LicenseModelActionHelper.fetchArchivedLicenseModels(dispatch); - SoftwareProductActionHelper.fetchSoftwareProductList(dispatch); - SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(dispatch); - SoftwareProductActionHelper.fetchArchivedSoftwareProductList(dispatch); - }, - - navigateToOnboardingCatalog(dispatch) { - UsersActionHelper.fetchUsersList(dispatch); - this.loadItemsLists(dispatch); - OnboardActionHelper.resetOnboardStore(dispatch); - setCurrentScreen(dispatch, enums.SCREEN.ONBOARDING_CATALOG); - }, - - autoSaveBeforeNavigate(dispatch, {softwareProductId, version, vspComponentId, dataToSave}) { - if(softwareProductId) { - if(vspComponentId) { - return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, { - softwareProductId, version, vspComponentId, - componentData: dataToSave.componentData, - qdata: dataToSave.qdata - }); - } - return SoftwareProductActionHelper.updateSoftwareProduct(dispatch, { - softwareProduct: dataToSave.softwareProduct, - version, - qdata: dataToSave.qdata - }); - } - return Promise.resolve(); - }, - - navigateToLicenseModelOverview(dispatch, {licenseModelId, version, status}) { - - /** - * TODO change to specific rest - */ - - LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { - LicenseModelActionHelper.fetchLicenseModelItems(dispatch, {licenseModelId, version}).then(() => { - setCurrentScreen(dispatch, enums.SCREEN.LICENSE_MODEL_OVERVIEW, {licenseModelId, version, status}); - }); - licenseModelOverviewActionHelper.selectVLMListView(dispatch, {buttonTab: null}); - }); - }, - navigateToLicenseAgreements(dispatch, {licenseModelId, version, status}) { - LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version}); - LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { - setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, {licenseModelId, version, status}); - }); - }, - - navigateToFeatureGroups(dispatch, {licenseModelId, version, status}) { - FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version}); - setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, {licenseModelId, version, status}); - }, - - navigateToEntitlementPools(dispatch, {licenseModelId, version, status}) { - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); - setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, {licenseModelId, version, status}); - }, - - navigateToLicenseKeyGroups(dispatch, {licenseModelId, version, status}) { - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); - setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, {licenseModelId, version, status}); - }, - - navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version, status}){ - ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id}); - setCurrentScreen(dispatch, enums.SCREEN.ACTIVITY_LOG, {licenseModelId, version, status}); - }, - - navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version, status}) { - SoftwareProductComponentsActionHelper.clearComponentsStore(dispatch); - SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}).then(response => { - let {vendorId: licenseModelId, licensingVersion} = response[0]; - SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion}); - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version: version}); - if(response[0].onboardingOrigin === onboardingOriginTypes.ZIP) { - SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version: version}); - } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version, status}); - }); - }, - - navigateToSoftwareProductDetails(dispatch, {softwareProductId, version, status}) { - SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}).then(response => { - let {vendorId: licenseModelId, licensingVersion} = response[0]; - SoftwareProductActionHelper.loadLicensingVersionsList(dispatch, {licenseModelId}); - SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId, version, status}); - }); - }, - - navigateToSoftwareProductAttachmentsSetupTab(dispatch, {softwareProductId, version, status}) { - SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version}); - SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, {activeTab: attachmentsTabsMapping.SETUP}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version, status}); - }, - navigateToSoftwareProductAttachmentsValidationTab(dispatch, {softwareProductId, version, status}) { - SoftwareProductActionHelper.processAndValidateHeatCandidate(dispatch, {softwareProductId, version}).then(() => { - SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, {activeTab: attachmentsTabsMapping.VALIDATION}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version, status}); - }); - }, - - navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version, status}) { - if (softwareProductId) { - SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version}); - } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId, version, status}); - }, - - navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version, status}) { - if (softwareProductId) { - SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version}); - } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId, version, status}); - }, - - navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version, status}) { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}).then(result => { - if(result.listCount >= 2) { - SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, {softwareProductId, version, status}); - } - else { - this.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version, status}); - } - }); - }, - - navigateToSoftwareProductComponents(dispatch, {softwareProductId, version, status}) { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId, version, status}); - }, - navigateToSoftwareProductDeployment(dispatch, {softwareProductId, version, status}) { - SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList(dispatch, {softwareProductId, version}); - ComputeFlavorActionHelper.fetchComputesListForVSP(dispatch, {softwareProductId, version}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT, {softwareProductId, version, status}); - }, - navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version, status}){ - ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: softwareProductId, versionId: version.id}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, {softwareProductId, version, status}); - }, - - navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version, status}) { - if (componentId && softwareProductId) { - SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version}); - } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId, version, status}); - }, - - navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, version, componentId, status}){ - if (componentId && softwareProductId && version) { - SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId, version}); - } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId, version, status}); - }, - - navigateToComponentStorage(dispatch, {softwareProductId, componentId, version, status}) { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, version, componentId, status}); - }, - - navigateToComponentCompute(dispatch, {softwareProductId, componentId, version, status}) { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); - if (componentId && softwareProductId) { - ComputeFlavorActionHelper.fetchComputesList(dispatch, {softwareProductId, componentId, version}); - } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, version, componentId, status}); - }, - - navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version, status}) { - SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, version, componentId, status}); - }, - - navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version, status}) { - if (componentId && softwareProductId) { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); - } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, version, componentId, status}); - }, - - navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version, status}) { - this.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version, status}); - dispatch({ - type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, - mapOfExpandedIds: { - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: true, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS + '|' + componentId]: true - } - }); - }, - - navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version, status}) { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, version, componentId, status}); - }, - - navigateToComponentImages(dispatch, {softwareProductId, componentId, version, status}) { - SoftwareProductComponentsImageActionHelper.fetchImagesList(dispatch, { - softwareProductId, - componentId, - version - }); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES, {softwareProductId, version, componentId, status}); - }, - - navigateToVersionsPage(dispatch, {itemType, itemId, itemName, additionalProps, users}) { - PermissionsActionHelper.fetchItemUsers(dispatch, {itemId, allUsers: users}); - VersionsPageActionHelper.selectNone(dispatch); - VersionsPageActionHelper.fetchVersions(dispatch, {itemType, itemId}).then(() => { - ItemsHelper.fetchItem(itemId).then(result => { - setCurrentScreen(dispatch, enums.SCREEN.VERSIONS_PAGE, {status: result.status, itemType, itemId, itemName, additionalProps}); - }); - - }); - - }, - - checkMergeStatus(dispatch, {itemId, versionId, version}) { - return ItemsHelper.fetchVersion({itemId, versionId}).then(response => { - let state = response && response.state || {}; - let {synchronizationState} = state; - // let inMerge = synchronizationState === SyncStates.MERGE; - MergeEditorActionHelper.fetchConflicts(dispatch, {itemId, version}).then(data => { - dispatch({ - type: actionTypes.CHECK_MERGE_STATUS, - synchronizationState, - conflictInfoList: data.conflictInfoList - }); - }); - }); - }, - - forceBreadCrumbsUpdate(dispatch) { - dispatch({ - type: actionTypes.SET_CURRENT_SCREEN, - currentScreen: { - forceBreadCrumbsUpdate: true - } - }); - }, - - updateCurrentScreenVersion(dispatch, version) { - dispatch({ - type: actionTypes.SET_CURRENT_SCREEN_VERSION, - version - }); - } + loadItemsLists(dispatch) { + LicenseModelActionHelper.fetchLicenseModels(dispatch); + LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch); + LicenseModelActionHelper.fetchArchivedLicenseModels(dispatch); + SoftwareProductActionHelper.fetchSoftwareProductList(dispatch); + SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(dispatch); + SoftwareProductActionHelper.fetchArchivedSoftwareProductList(dispatch); + }, + + navigateToOnboardingCatalog(dispatch) { + UsersActionHelper.fetchUsersList(dispatch); + this.loadItemsLists(dispatch); + OnboardActionHelper.resetOnboardStore(dispatch); + setCurrentScreen(dispatch, enums.SCREEN.ONBOARDING_CATALOG); + }, + + autoSaveBeforeNavigate( + dispatch, + { softwareProductId, version, vspComponentId, dataToSave } + ) { + if (softwareProductId) { + if (vspComponentId) { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent( + dispatch, + { + softwareProductId, + version, + vspComponentId, + componentData: dataToSave.componentData, + qdata: dataToSave.qdata + } + ); + } + return SoftwareProductActionHelper.updateSoftwareProduct(dispatch, { + softwareProduct: dataToSave.softwareProduct, + version, + qdata: dataToSave.qdata + }); + } + return Promise.resolve(); + }, + + navigateToLicenseModelOverview( + dispatch, + { licenseModelId, version, status } + ) { + /** + * TODO change to specific rest + */ + + LicenseModelActionHelper.fetchLicenseModelById(dispatch, { + licenseModelId, + version + }).then(() => { + LicenseModelActionHelper.fetchLicenseModelItems(dispatch, { + licenseModelId, + version + }).then(() => { + setCurrentScreen( + dispatch, + enums.SCREEN.LICENSE_MODEL_OVERVIEW, + { licenseModelId, version, status } + ); + }); + licenseModelOverviewActionHelper.selectVLMListView(dispatch, { + buttonTab: null + }); + }); + }, + navigateToLicenseAgreements(dispatch, { licenseModelId, version, status }) { + LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, { + licenseModelId, + version + }); + LicenseModelActionHelper.fetchLicenseModelById(dispatch, { + licenseModelId, + version + }).then(() => { + setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, { + licenseModelId, + version, + status + }); + }); + }, + + navigateToFeatureGroups(dispatch, { licenseModelId, version, status }) { + FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, { + licenseModelId, + version + }); + setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, { + licenseModelId, + version, + status + }); + }, + + navigateToEntitlementPools(dispatch, { licenseModelId, version, status }) { + EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, { + licenseModelId, + version + }); + setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, { + licenseModelId, + version, + status + }); + }, + + navigateToLicenseKeyGroups(dispatch, { licenseModelId, version, status }) { + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, { + licenseModelId, + version + }); + setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, { + licenseModelId, + version, + status + }); + }, + + navigateToLicenseModelActivityLog( + dispatch, + { licenseModelId, version, status } + ) { + ActivityLogActionHelper.fetchActivityLog(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + setCurrentScreen(dispatch, enums.SCREEN.ACTIVITY_LOG, { + licenseModelId, + version, + status + }); + }, + + navigateToSoftwareProductLandingPage( + dispatch, + { softwareProductId, version, status } + ) { + SoftwareProductComponentsActionHelper.clearComponentsStore(dispatch); + SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, { + softwareProductId, + version + }).then(response => { + let { vendorId: licenseModelId, licensingVersion } = response[0]; + SoftwareProductActionHelper.loadSoftwareProductDetailsData( + dispatch, + { licenseModelId, licensingVersion } + ); + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents( + dispatch, + { softwareProductId, version: version } + ); + if (response[0].onboardingOrigin === onboardingOriginTypes.ZIP) { + SoftwareProductActionHelper.loadSoftwareProductHeatCandidate( + dispatch, + { softwareProductId, version: version } + ); + } + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + { softwareProductId, licenseModelId, version, status } + ); + }); + }, + + navigateToSoftwareProductDetails( + dispatch, + { softwareProductId, version, status } + ) { + SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, { + softwareProductId, + version + }).then(response => { + let { vendorId: licenseModelId, licensingVersion } = response[0]; + SoftwareProductActionHelper.loadLicensingVersionsList(dispatch, { + licenseModelId + }); + SoftwareProductActionHelper.loadSoftwareProductDetailsData( + dispatch, + { licenseModelId, licensingVersion } + ); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, { + softwareProductId, + version, + status + }); + }); + }, + + navigateToSoftwareProductAttachmentsSetupTab( + dispatch, + { softwareProductId, version, status } + ) { + SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, { + softwareProductId, + version + }); + SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, { + activeTab: attachmentsTabsMapping.SETUP + }); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, { + softwareProductId, + version, + status + }); + }, + navigateToSoftwareProductAttachmentsValidationTab( + dispatch, + { softwareProductId, version, status } + ) { + SoftwareProductActionHelper.processAndValidateHeatCandidate(dispatch, { + softwareProductId, + version + }).then(() => { + SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, { + activeTab: attachmentsTabsMapping.VALIDATION + }); + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, + { softwareProductId, version, status } + ); + }); + }, + + navigateToSoftwareProductProcesses( + dispatch, + { softwareProductId, version, status } + ) { + if (softwareProductId) { + SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, { + softwareProductId, + version + }); + } + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, { + softwareProductId, + version, + status + }); + }, + + navigateToSoftwareProductNetworks( + dispatch, + { softwareProductId, version, status } + ) { + if (softwareProductId) { + SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, { + softwareProductId, + version + }); + } + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, { + softwareProductId, + version, + status + }); + }, + + navigateToSoftwareProductDependencies( + dispatch, + { softwareProductId, version, status } + ) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents( + dispatch, + { softwareProductId, version } + ).then(result => { + if (result.listCount >= 2) { + SoftwareProductDependenciesActionHelper.fetchDependencies( + dispatch, + { softwareProductId, version } + ); + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, + { softwareProductId, version, status } + ); + } else { + this.navigateToSoftwareProductLandingPage(dispatch, { + softwareProductId, + version, + status + }); + } + }); + }, + + navigateToSoftwareProductComponents( + dispatch, + { softwareProductId, version, status } + ) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents( + dispatch, + { softwareProductId, version } + ); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, { + softwareProductId, + version, + status + }); + }, + navigateToSoftwareProductDeployment( + dispatch, + { softwareProductId, version, status } + ) { + SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList( + dispatch, + { softwareProductId, version } + ); + ComputeFlavorActionHelper.fetchComputesListForVSP(dispatch, { + softwareProductId, + version + }); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT, { + softwareProductId, + version, + status + }); + }, + navigateToSoftwareProductActivityLog( + dispatch, + { softwareProductId, version, status } + ) { + ActivityLogActionHelper.fetchActivityLog(dispatch, { + itemId: softwareProductId, + versionId: version.id + }); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, { + softwareProductId, + version, + status + }); + }, + + navigateToSoftwareProductComponentProcesses( + dispatch, + { softwareProductId, componentId, version, status } + ) { + if (componentId && softwareProductId) { + SoftwareProductComponentProcessesActionHelper.fetchProcessesList( + dispatch, + { componentId, softwareProductId, version } + ); + } + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, + { softwareProductId, componentId, version, status } + ); + }, + + navigateToSoftwareProductComponentMonitoring( + dispatch, + { softwareProductId, version, componentId, status } + ) { + if (componentId && softwareProductId && version) { + SoftwareProductComponentsMonitoringAction.fetchExistingFiles( + dispatch, + { componentId, softwareProductId, version } + ); + } + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, + { softwareProductId, componentId, version, status } + ); + }, + + navigateToComponentStorage( + dispatch, + { softwareProductId, componentId, version, status } + ) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent( + dispatch, + { softwareProductId, vspComponentId: componentId, version } + ); + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, + { softwareProductId, version, componentId, status } + ); + }, + + navigateToComponentCompute( + dispatch, + { softwareProductId, componentId, version, status } + ) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent( + dispatch, + { softwareProductId, vspComponentId: componentId, version } + ); + if (componentId && softwareProductId) { + ComputeFlavorActionHelper.fetchComputesList(dispatch, { + softwareProductId, + componentId, + version + }); + } + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, + { softwareProductId, version, componentId, status } + ); + }, + + navigateToComponentNetwork( + dispatch, + { softwareProductId, componentId, version, status } + ) { + SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, { + softwareProductId, + componentId, + version + }); + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, + { softwareProductId, version, componentId, status } + ); + }, + + navigateToSoftwareProductComponentGeneral( + dispatch, + { softwareProductId, componentId, version, status } + ) { + if (componentId && softwareProductId) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent( + dispatch, + { softwareProductId, vspComponentId: componentId, version } + ); + } + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, + { softwareProductId, version, componentId, status } + ); + }, + + navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel( + dispatch, + { softwareProductId, componentId, version, status } + ) { + this.navigateToSoftwareProductComponentGeneral(dispatch, { + softwareProductId, + componentId, + version, + status + }); + dispatch({ + type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, + mapOfExpandedIds: { + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: true, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS + + '|' + + componentId]: true + } + }); + }, + + navigateToComponentLoadBalancing( + dispatch, + { softwareProductId, componentId, version, status } + ) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent( + dispatch, + { softwareProductId, vspComponentId: componentId, version } + ); + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, + { softwareProductId, version, componentId, status } + ); + }, + + navigateToComponentImages( + dispatch, + { softwareProductId, componentId, version, status } + ) { + SoftwareProductComponentsImageActionHelper.fetchImagesList(dispatch, { + softwareProductId, + componentId, + version + }); + setCurrentScreen( + dispatch, + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES, + { softwareProductId, version, componentId, status } + ); + }, + + navigateToVersionsPage( + dispatch, + { itemType, itemId, itemName, additionalProps, users } + ) { + PermissionsActionHelper.fetchItemUsers(dispatch, { + itemId, + allUsers: users + }); + VersionsPageActionHelper.selectNone(dispatch); + VersionsPageActionHelper.fetchVersions(dispatch, { + itemType, + itemId + }).then(() => { + ItemsHelper.fetchItem(itemId).then(result => { + setCurrentScreen(dispatch, enums.SCREEN.VERSIONS_PAGE, { + status: result.status, + itemType, + itemId, + itemName, + additionalProps + }); + }); + }); + }, + + checkMergeStatus(dispatch, { itemId, versionId, version }) { + return ItemsHelper.fetchVersion({ itemId, versionId }).then( + response => { + let state = (response && response.state) || {}; + let { synchronizationState } = state; + // let inMerge = synchronizationState === SyncStates.MERGE; + MergeEditorActionHelper.fetchConflicts(dispatch, { + itemId, + version + }).then(data => { + dispatch({ + type: actionTypes.CHECK_MERGE_STATUS, + synchronizationState, + conflictInfoList: data.conflictInfoList + }); + }); + } + ); + }, + + forceBreadCrumbsUpdate(dispatch) { + dispatch({ + type: actionTypes.SET_CURRENT_SCREEN, + currentScreen: { + forceBreadCrumbsUpdate: true + } + }); + }, + + updateCurrentScreenVersion(dispatch, version) { + dispatch({ + type: actionTypes.SET_CURRENT_SCREEN_VERSION, + version + }); + } }; export default OnboardingActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js index 699fe9e357..36054397d9 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js @@ -18,83 +18,102 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const DATE_FORMAT = 'MM/DD/YYYY'; export const actionTypes = keyMirror({ - SET_CURRENT_SCREEN: null, - SET_CURRENT_LICENSE_MODEL: null, - SET_CURRENT_SCREEN_VERSION: null, - UPDATE_CURRENT_SCREEN_PROPS: null, - UPDATE_ITEM_STATUS: null + SET_CURRENT_SCREEN: null, + SET_CURRENT_LICENSE_MODEL: null, + SET_CURRENT_SCREEN_VERSION: null, + UPDATE_CURRENT_SCREEN_PROPS: null, + UPDATE_ITEM_STATUS: null }); export const screenTypes = keyMirror({ - LICENSE_MODEL: null, - SOFTWARE_PRODUCT: null, - SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL: null + LICENSE_MODEL: null, + SOFTWARE_PRODUCT: null, + SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL: null }); const breadcrumbsEnum = { - LICENSE_MODEL: 'LICENSE_MODEL', - VERSIONS_PAGE: 'VERSIONS_PAGE', - LICENSE_MODEL_OVERVIEW: 'LICENSE_MODEL_OVERVIEW', - LICENSE_AGREEMENTS: 'LICENSE_AGREEMENTS', - FEATURE_GROUPS: 'FEATURE_GROUPS', - ENTITLEMENT_POOLS: 'ENTITLEMENT_POOLS', - LICENSE_KEY_GROUPS: 'LICENSE_KEY_GROUPS', - ACTIVITY_LOG: 'ACTIVITY_LOG', + LICENSE_MODEL: 'LICENSE_MODEL', + VERSIONS_PAGE: 'VERSIONS_PAGE', + LICENSE_MODEL_OVERVIEW: 'LICENSE_MODEL_OVERVIEW', + LICENSE_AGREEMENTS: 'LICENSE_AGREEMENTS', + FEATURE_GROUPS: 'FEATURE_GROUPS', + ENTITLEMENT_POOLS: 'ENTITLEMENT_POOLS', + LICENSE_KEY_GROUPS: 'LICENSE_KEY_GROUPS', + ACTIVITY_LOG: 'ACTIVITY_LOG', - SOFTWARE_PRODUCT: 'SOFTWARE_PRODUCT', - SOFTWARE_PRODUCT_VERSIONS_PAGE: 'SOFTWARE_PRODUCT_VERSIONS_PAGE', - SOFTWARE_PRODUCT_LANDING_PAGE: 'SOFTWARE_PRODUCT_LANDING_PAGE', - SOFTWARE_PRODUCT_DETAILS: 'SOFTWARE_PRODUCT_DETAILS', - SOFTWARE_PRODUCT_ATTACHMENTS: 'SOFTWARE_PRODUCT_ATTACHMENTS', - SOFTWARE_PRODUCT_PROCESSES: 'SOFTWARE_PRODUCT_PROCESSES', - SOFTWARE_PRODUCT_DEPLOYMENT: 'SOFTWARE_PRODUCT_DEPLOYMENT', - SOFTWARE_PRODUCT_NETWORKS: 'SOFTWARE_PRODUCT_NETWORKS', - SOFTWARE_PRODUCT_DEPENDENCIES: 'SOFTWARE_PRODUCT_DEPENDENCIES', - SOFTWARE_PRODUCT_ACTIVITY_LOG: 'SOFTWARE_PRODUCT_ACTIVITY_LOG', - SOFTWARE_PRODUCT_COMPONENTS: 'SOFTWARE_PRODUCT_COMPONENTS', - SOFTWARE_PRODUCT_COMPONENT_PROCESSES: 'SOFTWARE_PRODUCT_COMPONENT_PROCESSES', - SOFTWARE_PRODUCT_COMPONENT_NETWORK: 'SOFTWARE_PRODUCT_COMPONENT_NETWORK', - SOFTWARE_PRODUCT_COMPONENT_STORAGE: 'SOFTWARE_PRODUCT_COMPONENT_STORAGE', - SOFTWARE_PRODUCT_COMPONENT_GENERAL: 'SOFTWARE_PRODUCT_COMPONENT_GENERAL', - SOFTWARE_PRODUCT_COMPONENT_COMPUTE: 'SOFTWARE_PRODUCT_COMPONENT_COMPUTE', - SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: 'SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING', - SOFTWARE_PRODUCT_COMPONENT_MONITORING: 'SOFTWARE_PRODUCT_COMPONENT_MONITORING', - SOFTWARE_PRODUCT_COMPONENT_IMAGES: 'SOFTWARE_PRODUCT_COMPONENT_IMAGES' + SOFTWARE_PRODUCT: 'SOFTWARE_PRODUCT', + SOFTWARE_PRODUCT_VERSIONS_PAGE: 'SOFTWARE_PRODUCT_VERSIONS_PAGE', + SOFTWARE_PRODUCT_LANDING_PAGE: 'SOFTWARE_PRODUCT_LANDING_PAGE', + SOFTWARE_PRODUCT_DETAILS: 'SOFTWARE_PRODUCT_DETAILS', + SOFTWARE_PRODUCT_ATTACHMENTS: 'SOFTWARE_PRODUCT_ATTACHMENTS', + SOFTWARE_PRODUCT_PROCESSES: 'SOFTWARE_PRODUCT_PROCESSES', + SOFTWARE_PRODUCT_DEPLOYMENT: 'SOFTWARE_PRODUCT_DEPLOYMENT', + SOFTWARE_PRODUCT_NETWORKS: 'SOFTWARE_PRODUCT_NETWORKS', + SOFTWARE_PRODUCT_DEPENDENCIES: 'SOFTWARE_PRODUCT_DEPENDENCIES', + SOFTWARE_PRODUCT_ACTIVITY_LOG: 'SOFTWARE_PRODUCT_ACTIVITY_LOG', + SOFTWARE_PRODUCT_COMPONENTS: 'SOFTWARE_PRODUCT_COMPONENTS', + SOFTWARE_PRODUCT_COMPONENT_PROCESSES: + 'SOFTWARE_PRODUCT_COMPONENT_PROCESSES', + SOFTWARE_PRODUCT_COMPONENT_NETWORK: 'SOFTWARE_PRODUCT_COMPONENT_NETWORK', + SOFTWARE_PRODUCT_COMPONENT_STORAGE: 'SOFTWARE_PRODUCT_COMPONENT_STORAGE', + SOFTWARE_PRODUCT_COMPONENT_GENERAL: 'SOFTWARE_PRODUCT_COMPONENT_GENERAL', + SOFTWARE_PRODUCT_COMPONENT_COMPUTE: 'SOFTWARE_PRODUCT_COMPONENT_COMPUTE', + SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: + 'SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING', + SOFTWARE_PRODUCT_COMPONENT_MONITORING: + 'SOFTWARE_PRODUCT_COMPONENT_MONITORING', + SOFTWARE_PRODUCT_COMPONENT_IMAGES: 'SOFTWARE_PRODUCT_COMPONENT_IMAGES' }; export const enums = keyMirror({ + BREADCRUMS: { ...breadcrumbsEnum }, - BREADCRUMS: {...breadcrumbsEnum}, + SCREEN: { + ONBOARDING_CATALOG: 'ONBOARDING_CATALOG', + VERSIONS_PAGE: breadcrumbsEnum.VERSIONS_PAGE, + LICENSE_MODEL_OVERVIEW: breadcrumbsEnum.LICENSE_MODEL_OVERVIEW, + LICENSE_AGREEMENTS: breadcrumbsEnum.LICENSE_AGREEMENTS, + FEATURE_GROUPS: breadcrumbsEnum.FEATURE_GROUPS, + ENTITLEMENT_POOLS: breadcrumbsEnum.ENTITLEMENT_POOLS, + LICENSE_KEY_GROUPS: breadcrumbsEnum.LICENSE_KEY_GROUPS, + ACTIVITY_LOG: breadcrumbsEnum.ACTIVITY_LOG, - SCREEN: { - ONBOARDING_CATALOG: 'ONBOARDING_CATALOG', - VERSIONS_PAGE: breadcrumbsEnum.VERSIONS_PAGE, - LICENSE_MODEL_OVERVIEW: breadcrumbsEnum.LICENSE_MODEL_OVERVIEW, - LICENSE_AGREEMENTS: breadcrumbsEnum.LICENSE_AGREEMENTS, - FEATURE_GROUPS: breadcrumbsEnum.FEATURE_GROUPS, - ENTITLEMENT_POOLS: breadcrumbsEnum.ENTITLEMENT_POOLS, - LICENSE_KEY_GROUPS: breadcrumbsEnum.LICENSE_KEY_GROUPS, - ACTIVITY_LOG: breadcrumbsEnum.ACTIVITY_LOG, - - SOFTWARE_PRODUCT_VERSIONS_PAGE: breadcrumbsEnum.SOFTWARE_PRODUCT_VERSIONS_PAGE, - SOFTWARE_PRODUCT_LANDING_PAGE: breadcrumbsEnum.SOFTWARE_PRODUCT_LANDING_PAGE, - SOFTWARE_PRODUCT_DETAILS: breadcrumbsEnum.SOFTWARE_PRODUCT_DETAILS, - SOFTWARE_PRODUCT_ATTACHMENTS: breadcrumbsEnum.SOFTWARE_PRODUCT_ATTACHMENTS, - SOFTWARE_PRODUCT_ATTACHMENTS_SETUP: 'SOFTWARE_PRODUCT_ATTACHMENTS_SETUP', - SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION: 'SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION', - SOFTWARE_PRODUCT_PROCESSES: breadcrumbsEnum.SOFTWARE_PRODUCT_PROCESSES, - SOFTWARE_PRODUCT_DEPLOYMENT: breadcrumbsEnum.SOFTWARE_PRODUCT_DEPLOYMENT, - SOFTWARE_PRODUCT_NETWORKS: breadcrumbsEnum.SOFTWARE_PRODUCT_NETWORKS, - SOFTWARE_PRODUCT_DEPENDENCIES: breadcrumbsEnum.SOFTWARE_PRODUCT_DEPENDENCIES, - SOFTWARE_PRODUCT_ACTIVITY_LOG: breadcrumbsEnum.SOFTWARE_PRODUCT_ACTIVITY_LOG, - SOFTWARE_PRODUCT_COMPONENTS: breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENTS, - SOFTWARE_PRODUCT_COMPONENT_PROCESSES: breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, - SOFTWARE_PRODUCT_COMPONENT_COMPUTE: breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, - SOFTWARE_PRODUCT_COMPONENT_STORAGE: breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_STORAGE, - SOFTWARE_PRODUCT_COMPONENT_NETWORK: breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_NETWORK, - SOFTWARE_PRODUCT_COMPONENT_GENERAL: breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_GENERAL, - SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, - SOFTWARE_PRODUCT_COMPONENT_MONITORING: breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_MONITORING, - SOFTWARE_PRODUCT_COMPONENT_IMAGES: breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_IMAGES - } + SOFTWARE_PRODUCT_VERSIONS_PAGE: + breadcrumbsEnum.SOFTWARE_PRODUCT_VERSIONS_PAGE, + SOFTWARE_PRODUCT_LANDING_PAGE: + breadcrumbsEnum.SOFTWARE_PRODUCT_LANDING_PAGE, + SOFTWARE_PRODUCT_DETAILS: breadcrumbsEnum.SOFTWARE_PRODUCT_DETAILS, + SOFTWARE_PRODUCT_ATTACHMENTS: + breadcrumbsEnum.SOFTWARE_PRODUCT_ATTACHMENTS, + SOFTWARE_PRODUCT_ATTACHMENTS_SETUP: + 'SOFTWARE_PRODUCT_ATTACHMENTS_SETUP', + SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION: + 'SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION', + SOFTWARE_PRODUCT_PROCESSES: breadcrumbsEnum.SOFTWARE_PRODUCT_PROCESSES, + SOFTWARE_PRODUCT_DEPLOYMENT: + breadcrumbsEnum.SOFTWARE_PRODUCT_DEPLOYMENT, + SOFTWARE_PRODUCT_NETWORKS: breadcrumbsEnum.SOFTWARE_PRODUCT_NETWORKS, + SOFTWARE_PRODUCT_DEPENDENCIES: + breadcrumbsEnum.SOFTWARE_PRODUCT_DEPENDENCIES, + SOFTWARE_PRODUCT_ACTIVITY_LOG: + breadcrumbsEnum.SOFTWARE_PRODUCT_ACTIVITY_LOG, + SOFTWARE_PRODUCT_COMPONENTS: + breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENTS, + SOFTWARE_PRODUCT_COMPONENT_PROCESSES: + breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, + SOFTWARE_PRODUCT_COMPONENT_COMPUTE: + breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, + SOFTWARE_PRODUCT_COMPONENT_STORAGE: + breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_STORAGE, + SOFTWARE_PRODUCT_COMPONENT_NETWORK: + breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_NETWORK, + SOFTWARE_PRODUCT_COMPONENT_GENERAL: + breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_GENERAL, + SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: + breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, + SOFTWARE_PRODUCT_COMPONENT_MONITORING: + breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_MONITORING, + SOFTWARE_PRODUCT_COMPONENT_IMAGES: + breadcrumbsEnum.SOFTWARE_PRODUCT_COMPONENT_IMAGES + } }); diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx index e04f9b7309..f462dd790b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx @@ -16,7 +16,7 @@ import React from 'react'; -import {render} from 'react-dom'; +import { render } from 'react-dom'; import ReactDOM from 'react-dom'; import isEqual from 'lodash/isEqual.js'; @@ -29,460 +29,812 @@ import store from 'sdc-app/AppStore.js'; import Configuration from 'sdc-app/config/Configuration.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; +import { + onboardingMethod as onboardingMethodTypes, + onboardingOriginTypes +} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; -import {onboardingMethod as onboardingMethodTypes, onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { itemTypes } from './versionsPage/VersionsPageConstants.js'; -import {itemTypes} from './versionsPage/VersionsPageConstants.js'; - -import {AppContainer} from 'react-hot-loader'; +import { AppContainer } from 'react-hot-loader'; import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js'; -import {actionTypes, enums, screenTypes} from './OnboardingConstants.js'; +import { actionTypes, enums, screenTypes } from './OnboardingConstants.js'; import OnboardingActionHelper from './OnboardingActionHelper.js'; import Onboarding from './Onboarding.js'; export default class OnboardingPunchOut { - - render({options: {data, apiRoot, apiHeaders}, onEvent}, element) { - if (!this.unsubscribeFromStore) { - this.unsubscribeFromStore = store.subscribe(() => this.handleStoreChange()); - } - - if (!this.isConfigSet) { - Configuration.setCatalogApiRoot(apiRoot); - Configuration.setCatalogApiHeaders(apiHeaders); - this.isConfigSet = true; - } - - this.onEvent = (...args) => onEvent(...args); - this.handleData(data); - - if (!this.rendered) { - render( - - - - - , - element - ); - if (module.hot) { - module.hot.accept('sdc-app/onboarding/Onboarding.js', () => { - const NextOnboarding = require('sdc-app/onboarding/Onboarding.js').default; - render( - - - - - , - element - ); - }); - } - this.rendered = true; - } - } - - unmount(element) { - ReactDOM.unmountComponentAtNode(element); - this.rendered = false; - this.unsubscribeFromStore(); - this.unsubscribeFromStore = null; - } - - handleData(data) { - let {breadcrumbs: {selectedKeys = []} = {}} = data; - let dispatch = action => store.dispatch(action); - let {currentScreen, users: {usersList}, softwareProductList, finalizedSoftwareProductList, licenseModelList, finalizedLicenseModelList, - softwareProduct: {softwareProductEditor: {data: vspData = {}}, - softwareProductComponents = {}, softwareProductQuestionnaire = {}}, archivedLicenseModelList} = store.getState(); - const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList]; - const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList, ...archivedLicenseModelList]; - - let {props: {version, isReadOnlyMode}, screen} = currentScreen; - let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents; - if (this.programmaticBreadcrumbsUpdate) { - this.prevSelectedKeys = selectedKeys; - this.programmaticBreadcrumbsUpdate = false; - return; - } - if (!isEqual(selectedKeys, this.prevSelectedKeys)) { - this.breadcrumbsPrefixSelected = isEqual(selectedKeys, this.prevSelectedKeys && this.prevSelectedKeys.slice(0, selectedKeys.length)); - - const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || []; - let preNavigate = Promise.resolve(); - if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && screen !== 'VERSIONS_PAGE' && !isReadOnlyMode) { - let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {}; - preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, { - softwareProductId: prevVspId, - version, - vspComponentId: prevComponentId, - dataToSave - }); - } - - let {currentScreen: {props: {softwareProductId}}, softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}} = store.getState(); - let heatSetupPopupPromise = currentScreen.screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ? - HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) : - Promise.resolve(); - Promise.all([preNavigate, heatSetupPopupPromise]).then(() => { - this.prevSelectedKeys = selectedKeys; - if (selectedKeys.length === 0) { - ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.ONBOARDING_CATALOG}); - - } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) { - let [licenseModelId, , licenseModelScreen] = selectedKeys; - let licenseModel = wholeLicenseModelList.find(vlm => vlm.id === licenseModelId); - ScreensHelper.loadScreen(dispatch, {screen: licenseModelScreen, screenType: screenTypes.LICENSE_MODEL, - props: {licenseModelId, version, licenseModel, usersList}}); - - } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) { - let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys; - let softwareProduct = softwareProductId ? - wholeSoftwareProductList.find(({id}) => id === softwareProductId) : - wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); - if (!softwareProductId) { - softwareProductId = softwareProduct.id; - } - if (softwareProductScreen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS) { - softwareProduct = vspData; - //check current vsp fields to determine which file has uploaded - if(vspData.onboardingOrigin === onboardingOriginTypes.ZIP || vspData.candidateOnboardingOrigin === onboardingOriginTypes.ZIP) { - softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP; - } - else if(vspData.onboardingOrigin === onboardingOriginTypes.CSAR) { - softwareProductScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION; - } - } - - ScreensHelper.loadScreen(dispatch, {screen: softwareProductScreen, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, softwareProduct, version, usersList}}); - - } else if (selectedKeys.length === 5 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { - let [licenseModelId, , softwareProductId, , componentId] = selectedKeys; - let softwareProduct = softwareProductId ? - wholeSoftwareProductList.find(({id}) => id === softwareProductId) : - wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); - if (!softwareProductId) { - softwareProductId = softwareProduct.id; - } - ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, softwareProduct, componentId, version, usersList}}); - - } else if (selectedKeys.length === 6 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && selectedKeys[3] === enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS) { - let [licenseModelId, , softwareProductId, , componentId, componentScreen] = selectedKeys; - let softwareProduct = softwareProductId ? - wholeSoftwareProductList.find(({id}) => id === softwareProductId) : - wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); - if (!softwareProductId) { - softwareProductId = softwareProduct.id; - } - ScreensHelper.loadScreen(dispatch, {screen: componentScreen, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, softwareProduct, componentId, version, usersList}}); - - } else { - console.error('Unknown breadcrumbs path: ', selectedKeys); - } - }).catch(() => { - store.dispatch({ - type: actionTypes.SET_CURRENT_SCREEN, - currentScreen: { - ...currentScreen, - forceBreadCrumbsUpdate: true - } - }); - }); - } - } - - handleStoreChange() { - let {currentScreen, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList, versionsPage: - {versionsList: {itemType, itemId}}, - softwareProduct: {softwareProductEditor: {data: currentSoftwareProduct = {onboardingMethod: ''}}, - softwareProductComponents: {componentsList}}, archivedLicenseModelList, archivedSoftwareProductList} = store.getState(); - const wholeSoftwareProductList = lodashUnionBy(softwareProductList, [...finalizedSoftwareProductList, ...archivedSoftwareProductList], 'id'); - const wholeLicenseModelList = lodashUnionBy(licenseModelList, [...finalizedLicenseModelList, ...archivedLicenseModelList], 'id'); - let breadcrumbsData = {itemType, itemId, currentScreen, wholeLicenseModelList, wholeSoftwareProductList, currentSoftwareProduct, componentsList}; - - if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) { - this.prevBreadcrumbsData = breadcrumbsData; - this.breadcrumbsPrefixSelected = false; - this.programmaticBreadcrumbsUpdate = true; - let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData); - this.onEvent('breadcrumbsupdated', breadcrumbs); - store.dispatch({ - type: actionTypes.SET_CURRENT_SCREEN, - currentScreen: { - ...currentScreen, - forceBreadCrumbsUpdate: false - } - }); - } - } - - buildBreadcrumbs({currentScreen: {screen, props}, itemType, itemId, currentSoftwareProduct, - wholeLicenseModelList, wholeSoftwareProductList, componentsList}) { - let {onboardingMethod, onboardingOrigin, candidateOnboardingOrigin} = currentSoftwareProduct; - let screenToBreadcrumb; - switch (screen) { - case enums.SCREEN.ONBOARDING_CATALOG: - return []; - - case enums.SCREEN.VERSIONS_PAGE: - let firstMenuItems = itemType === itemTypes.LICENSE_MODEL ? [ - { - selectedKey: itemId, - menuItems: wholeLicenseModelList.map(({id, name}) => ({ - key: id, - displayText: name - })) - }] : [ - { - selectedKey: props.additionalProps.licenseModelId || currentSoftwareProduct.vendorId, - menuItems: wholeLicenseModelList.map(({id, name}) => ({ - key: id, - displayText: name - })) - }, - { - selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, - menuItems: [{ - key: enums.BREADCRUMS.LICENSE_MODEL, - displayText: i18n('License Model') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT, - displayText: i18n('Software Products') - }] - }, - { - selectedKey: itemId, - menuItems: wholeSoftwareProductList - .filter(({id, vendorId}) => vendorId === currentSoftwareProduct.vendorId || id === itemId) - .map(({id, name}) => ({ - key: id, - displayText: name - })) - }, - ]; - return [ - ...firstMenuItems, - { - selectedKey: enums.BREADCRUMS.VERSIONS_PAGE, - menuItems: [{key: enums.BREADCRUMS.VERSIONS_PAGE, displayText: i18n('Versions Page')}] - } - ]; - - case enums.SCREEN.LICENSE_AGREEMENTS: - case enums.SCREEN.FEATURE_GROUPS: - case enums.SCREEN.ENTITLEMENT_POOLS: - case enums.SCREEN.LICENSE_KEY_GROUPS: - case enums.SCREEN.LICENSE_MODEL_OVERVIEW: - case enums.SCREEN.ACTIVITY_LOG: - screenToBreadcrumb = { - [enums.SCREEN.LICENSE_AGREEMENTS]: enums.BREADCRUMS.LICENSE_AGREEMENTS, - [enums.SCREEN.FEATURE_GROUPS]: enums.BREADCRUMS.FEATURE_GROUPS, - [enums.SCREEN.ENTITLEMENT_POOLS]: enums.BREADCRUMS.ENTITLEMENT_POOLS, - [enums.SCREEN.LICENSE_KEY_GROUPS]: enums.BREADCRUMS.LICENSE_KEY_GROUPS, - [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, - [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG - }; - return [ - { - selectedKey: props.licenseModelId, - menuItems: wholeLicenseModelList.map(({id, name}) => ({ - key: id, - displayText: name - })) - }, - { - selectedKey: enums.BREADCRUMS.LICENSE_MODEL, - menuItems: [{ - key: enums.BREADCRUMS.LICENSE_MODEL, - displayText: i18n('License Model') - }, - ...(wholeSoftwareProductList.findIndex(({vendorId}) => vendorId === props.licenseModelId) === -1 ? [] : [{ - key: enums.BREADCRUMS.SOFTWARE_PRODUCT, - displayText: i18n('Software Products') - }])] - }, { - selectedKey: screenToBreadcrumb[screen], - menuItems: [{ - key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, - displayText: i18n('Overview') - },{ - key: enums.BREADCRUMS.LICENSE_AGREEMENTS, - displayText: i18n('License Agreements') - }, { - key: enums.BREADCRUMS.FEATURE_GROUPS, - displayText: i18n('Feature Groups') - }, { - key: enums.BREADCRUMS.ENTITLEMENT_POOLS, - displayText: i18n('Entitlement Pools') - }, { - key: enums.BREADCRUMS.LICENSE_KEY_GROUPS, - displayText: i18n('License Key Groups') - }, { - key: enums.BREADCRUMS.ACTIVITY_LOG, - displayText: i18n('Activity Log') - }] - } - ]; - - case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: - case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: - case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: - case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: - case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: - case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: - case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: - case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: - - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: - screenToBreadcrumb = { - [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, - [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, - [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, - [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, - [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, - [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, - [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, - [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG - }; - let componentScreenToBreadcrumb = { - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING - }; - let licenseModelId = currentSoftwareProduct.vendorId; - let returnedBreadcrumb = [ - { - selectedKey: licenseModelId, - menuItems: wholeLicenseModelList.map(({id, name}) => ({ - key: id, - displayText: name - })) - }, - { - selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, - menuItems: [{ - key: enums.BREADCRUMS.LICENSE_MODEL, - displayText: i18n('License Model') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT, - displayText: i18n('Software Products') - }] - }, - { - selectedKey: props.softwareProductId, - menuItems: wholeSoftwareProductList - .filter(({vendorId, id}) => vendorId === licenseModelId || id === props.softwareProductId) - .map(({id, name}) => ({ - key: id, - displayText: name - })) - }, - ...(/*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [{ - selectedKey: screenToBreadcrumb[screen] || enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, - menuItems: [{ - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, - displayText: i18n('Overview') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, - displayText: i18n('General') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, - displayText: i18n('Deployment Flavors') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, - displayText: i18n('Process Details') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, - displayText: i18n('Networks') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, - displayText: i18n('Components Dependencies') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, - displayText: i18n('Attachments') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG, - displayText: i18n('Activity Log') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, - displayText: i18n('Components') - }].filter(item => { - switch (item.key) { - case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: - let isHeatData = onboardingOrigin !== onboardingOriginTypes.NONE || candidateOnboardingOrigin === onboardingOriginTypes.ZIP; - return isHeatData; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: - return (componentsList.length > 0); - case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT: - let isManualMode = onboardingMethod === onboardingMethodTypes.MANUAL; - return isManualMode; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: - return (componentsList.length > 1); - default: - return true; - } - }) - }]) - ]; - if(props.componentId) { - returnedBreadcrumb = [ - ...returnedBreadcrumb, { - selectedKey: props.componentId, - menuItems: componentsList - .map(({id, displayName}) => ({ - key: id, - displayText: displayName - })) - }, - ...[{ - selectedKey: componentScreenToBreadcrumb[screen], - menuItems: [{ - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, - displayText: i18n('General') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, - displayText: i18n('Compute') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, - displayText: i18n('High Availability & Load Balancing') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, - displayText: i18n('Networks') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, - displayText: i18n('Storage') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, - displayText: i18n('Images') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, - displayText: i18n('Process Details') - }, { - key: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING, - displayText: i18n('Monitoring') - }] - }] - ]; - } - return returnedBreadcrumb; - } - } + render({ options: { data, apiRoot, apiHeaders }, onEvent }, element) { + if (!this.unsubscribeFromStore) { + this.unsubscribeFromStore = store.subscribe(() => + this.handleStoreChange() + ); + } + + if (!this.isConfigSet) { + Configuration.setCatalogApiRoot(apiRoot); + Configuration.setCatalogApiHeaders(apiHeaders); + this.isConfigSet = true; + } + + this.onEvent = (...args) => onEvent(...args); + this.handleData(data); + + if (!this.rendered) { + render( + + + + + , + element + ); + if (module.hot) { + module.hot.accept('sdc-app/onboarding/Onboarding.js', () => { + const NextOnboarding = require('sdc-app/onboarding/Onboarding.js') + .default; + render( + + + + + , + element + ); + }); + } + this.rendered = true; + } + } + + unmount(element) { + ReactDOM.unmountComponentAtNode(element); + this.rendered = false; + this.unsubscribeFromStore(); + this.unsubscribeFromStore = null; + } + + handleData(data) { + let { breadcrumbs: { selectedKeys = [] } = {} } = data; + let dispatch = action => store.dispatch(action); + let { + currentScreen, + users: { usersList }, + softwareProductList, + finalizedSoftwareProductList, + licenseModelList, + finalizedLicenseModelList, + softwareProduct: { + softwareProductEditor: { data: vspData = {} }, + softwareProductComponents = {}, + softwareProductQuestionnaire = {} + }, + archivedLicenseModelList + } = store.getState(); + const wholeSoftwareProductList = [ + ...softwareProductList, + ...finalizedSoftwareProductList + ]; + const wholeLicenseModelList = [ + ...licenseModelList, + ...finalizedLicenseModelList, + ...archivedLicenseModelList + ]; + + let { props: { version, isReadOnlyMode }, screen } = currentScreen; + let { + componentEditor: { + data: componentData = {}, + qdata: componentQData = {} + } + } = softwareProductComponents; + if (this.programmaticBreadcrumbsUpdate) { + this.prevSelectedKeys = selectedKeys; + this.programmaticBreadcrumbsUpdate = false; + return; + } + if (!isEqual(selectedKeys, this.prevSelectedKeys)) { + this.breadcrumbsPrefixSelected = isEqual( + selectedKeys, + this.prevSelectedKeys && + this.prevSelectedKeys.slice(0, selectedKeys.length) + ); + + const [, screenType, prevVspId, , prevComponentId] = + this.prevSelectedKeys || []; + let preNavigate = Promise.resolve(); + if ( + screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && + screen !== 'VERSIONS_PAGE' && + !isReadOnlyMode + ) { + let dataToSave = prevVspId + ? prevComponentId + ? { componentData, qdata: componentQData } + : { + softwareProduct: vspData, + qdata: softwareProductQuestionnaire.qdata + } + : {}; + preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate( + dispatch, + { + softwareProductId: prevVspId, + version, + vspComponentId: prevComponentId, + dataToSave + } + ); + } + + let { + currentScreen: { props: { softwareProductId } }, + softwareProduct: { + softwareProductAttachments: { heatSetup, heatSetupCache } + } + } = store.getState(); + let heatSetupPopupPromise = + currentScreen.screen === + enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS + ? HeatSetupActionHelper.heatSetupLeaveConfirmation( + dispatch, + { softwareProductId, heatSetup, heatSetupCache } + ) + : Promise.resolve(); + Promise.all([preNavigate, heatSetupPopupPromise]) + .then(() => { + this.prevSelectedKeys = selectedKeys; + if (selectedKeys.length === 0) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.ONBOARDING_CATALOG + }); + } else if ( + selectedKeys.length === 1 || + selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL + ) { + let [ + licenseModelId, + , + licenseModelScreen + ] = selectedKeys; + let licenseModel = wholeLicenseModelList.find( + vlm => vlm.id === licenseModelId + ); + ScreensHelper.loadScreen(dispatch, { + screen: licenseModelScreen, + screenType: screenTypes.LICENSE_MODEL, + props: { + licenseModelId, + version, + licenseModel, + usersList + } + }); + } else if ( + selectedKeys.length <= 4 && + selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT + ) { + let [ + licenseModelId, + , + softwareProductId, + softwareProductScreen + ] = selectedKeys; + let softwareProduct = softwareProductId + ? wholeSoftwareProductList.find( + ({ id }) => id === softwareProductId + ) + : wholeSoftwareProductList.find( + ({ vendorId }) => vendorId === licenseModelId + ); + if (!softwareProductId) { + softwareProductId = softwareProduct.id; + } + if ( + softwareProductScreen === + enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS + ) { + softwareProduct = vspData; + //check current vsp fields to determine which file has uploaded + if ( + vspData.onboardingOrigin === + onboardingOriginTypes.ZIP || + vspData.candidateOnboardingOrigin === + onboardingOriginTypes.ZIP + ) { + softwareProductScreen = + enums.SCREEN + .SOFTWARE_PRODUCT_ATTACHMENTS_SETUP; + } else if ( + vspData.onboardingOrigin === + onboardingOriginTypes.CSAR + ) { + softwareProductScreen = + enums.SCREEN + .SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION; + } + } + + ScreensHelper.loadScreen(dispatch, { + screen: softwareProductScreen, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + softwareProduct, + version, + usersList + } + }); + } else if ( + selectedKeys.length === 5 && + selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && + selectedKeys[3] === + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS + ) { + let [ + licenseModelId, + , + softwareProductId, + , + componentId + ] = selectedKeys; + let softwareProduct = softwareProductId + ? wholeSoftwareProductList.find( + ({ id }) => id === softwareProductId + ) + : wholeSoftwareProductList.find( + ({ vendorId }) => vendorId === licenseModelId + ); + if (!softwareProductId) { + softwareProductId = softwareProduct.id; + } + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + softwareProduct, + componentId, + version, + usersList + } + }); + } else if ( + selectedKeys.length === 6 && + selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT && + selectedKeys[3] === + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS + ) { + let [ + licenseModelId, + , + softwareProductId, + , + componentId, + componentScreen + ] = selectedKeys; + let softwareProduct = softwareProductId + ? wholeSoftwareProductList.find( + ({ id }) => id === softwareProductId + ) + : wholeSoftwareProductList.find( + ({ vendorId }) => vendorId === licenseModelId + ); + if (!softwareProductId) { + softwareProductId = softwareProduct.id; + } + ScreensHelper.loadScreen(dispatch, { + screen: componentScreen, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + softwareProduct, + componentId, + version, + usersList + } + }); + } else { + console.error( + 'Unknown breadcrumbs path: ', + selectedKeys + ); + } + }) + .catch(() => { + store.dispatch({ + type: actionTypes.SET_CURRENT_SCREEN, + currentScreen: { + ...currentScreen, + forceBreadCrumbsUpdate: true + } + }); + }); + } + } + + handleStoreChange() { + let { + currentScreen, + licenseModelList, + finalizedLicenseModelList, + softwareProductList, + finalizedSoftwareProductList, + versionsPage: { versionsList: { itemType, itemId } }, + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct = { onboardingMethod: '' } + }, + softwareProductComponents: { componentsList } + }, + archivedLicenseModelList, + archivedSoftwareProductList + } = store.getState(); + const wholeSoftwareProductList = lodashUnionBy( + softwareProductList, + [...finalizedSoftwareProductList, ...archivedSoftwareProductList], + 'id' + ); + const wholeLicenseModelList = lodashUnionBy( + licenseModelList, + [...finalizedLicenseModelList, ...archivedLicenseModelList], + 'id' + ); + let breadcrumbsData = { + itemType, + itemId, + currentScreen, + wholeLicenseModelList, + wholeSoftwareProductList, + currentSoftwareProduct, + componentsList + }; + + if ( + currentScreen.forceBreadCrumbsUpdate || + !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || + this.breadcrumbsPrefixSelected + ) { + this.prevBreadcrumbsData = breadcrumbsData; + this.breadcrumbsPrefixSelected = false; + this.programmaticBreadcrumbsUpdate = true; + let breadcrumbs = this.buildBreadcrumbs(breadcrumbsData); + this.onEvent('breadcrumbsupdated', breadcrumbs); + store.dispatch({ + type: actionTypes.SET_CURRENT_SCREEN, + currentScreen: { + ...currentScreen, + forceBreadCrumbsUpdate: false + } + }); + } + } + + buildBreadcrumbs({ + currentScreen: { screen, props }, + itemType, + itemId, + currentSoftwareProduct, + wholeLicenseModelList, + wholeSoftwareProductList, + componentsList + }) { + let { + onboardingMethod, + onboardingOrigin, + candidateOnboardingOrigin + } = currentSoftwareProduct; + let screenToBreadcrumb; + switch (screen) { + case enums.SCREEN.ONBOARDING_CATALOG: + return []; + + case enums.SCREEN.VERSIONS_PAGE: + let firstMenuItems = + itemType === itemTypes.LICENSE_MODEL + ? [ + { + selectedKey: itemId, + menuItems: wholeLicenseModelList.map( + ({ id, name }) => ({ + key: id, + displayText: name + }) + ) + } + ] + : [ + { + selectedKey: + props.additionalProps.licenseModelId || + currentSoftwareProduct.vendorId, + menuItems: wholeLicenseModelList.map( + ({ id, name }) => ({ + key: id, + displayText: name + }) + ) + }, + { + selectedKey: + enums.BREADCRUMS.SOFTWARE_PRODUCT, + menuItems: [ + { + key: enums.BREADCRUMS.LICENSE_MODEL, + displayText: i18n('License Model') + }, + { + key: + enums.BREADCRUMS.SOFTWARE_PRODUCT, + displayText: i18n('Software Products') + } + ] + }, + { + selectedKey: itemId, + menuItems: wholeSoftwareProductList + .filter( + ({ id, vendorId }) => + vendorId === + currentSoftwareProduct.vendorId || + id === itemId + ) + .map(({ id, name }) => ({ + key: id, + displayText: name + })) + } + ]; + return [ + ...firstMenuItems, + { + selectedKey: enums.BREADCRUMS.VERSIONS_PAGE, + menuItems: [ + { + key: enums.BREADCRUMS.VERSIONS_PAGE, + displayText: i18n('Versions Page') + } + ] + } + ]; + + case enums.SCREEN.LICENSE_AGREEMENTS: + case enums.SCREEN.FEATURE_GROUPS: + case enums.SCREEN.ENTITLEMENT_POOLS: + case enums.SCREEN.LICENSE_KEY_GROUPS: + case enums.SCREEN.LICENSE_MODEL_OVERVIEW: + case enums.SCREEN.ACTIVITY_LOG: + screenToBreadcrumb = { + [enums.SCREEN.LICENSE_AGREEMENTS]: + enums.BREADCRUMS.LICENSE_AGREEMENTS, + [enums.SCREEN.FEATURE_GROUPS]: + enums.BREADCRUMS.FEATURE_GROUPS, + [enums.SCREEN.ENTITLEMENT_POOLS]: + enums.BREADCRUMS.ENTITLEMENT_POOLS, + [enums.SCREEN.LICENSE_KEY_GROUPS]: + enums.BREADCRUMS.LICENSE_KEY_GROUPS, + [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: + enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, + [enums.SCREEN.ACTIVITY_LOG]: enums.BREADCRUMS.ACTIVITY_LOG + }; + return [ + { + selectedKey: props.licenseModelId, + menuItems: wholeLicenseModelList.map( + ({ id, name }) => ({ + key: id, + displayText: name + }) + ) + }, + { + selectedKey: enums.BREADCRUMS.LICENSE_MODEL, + menuItems: [ + { + key: enums.BREADCRUMS.LICENSE_MODEL, + displayText: i18n('License Model') + }, + ...(wholeSoftwareProductList.findIndex( + ({ vendorId }) => + vendorId === props.licenseModelId + ) === -1 + ? [] + : [ + { + key: + enums.BREADCRUMS.SOFTWARE_PRODUCT, + displayText: i18n('Software Products') + } + ]) + ] + }, + { + selectedKey: screenToBreadcrumb[screen], + menuItems: [ + { + key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, + displayText: i18n('Overview') + }, + { + key: enums.BREADCRUMS.LICENSE_AGREEMENTS, + displayText: i18n('License Agreements') + }, + { + key: enums.BREADCRUMS.FEATURE_GROUPS, + displayText: i18n('Feature Groups') + }, + { + key: enums.BREADCRUMS.ENTITLEMENT_POOLS, + displayText: i18n('Entitlement Pools') + }, + { + key: enums.BREADCRUMS.LICENSE_KEY_GROUPS, + displayText: i18n('License Key Groups') + }, + { + key: enums.BREADCRUMS.ACTIVITY_LOG, + displayText: i18n('Activity Log') + } + ] + } + ]; + + case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: + case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: + case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: + case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: + case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: + case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: + case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: + case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: + + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: + screenToBreadcrumb = { + [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE, + [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS, + [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS, + [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES, + [enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPLOYMENT, + [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, + [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, + [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG + }; + let componentScreenToBreadcrumb = { + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_IMAGES, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING + }; + let licenseModelId = currentSoftwareProduct.vendorId; + let returnedBreadcrumb = [ + { + selectedKey: licenseModelId, + menuItems: wholeLicenseModelList.map( + ({ id, name }) => ({ + key: id, + displayText: name + }) + ) + }, + { + selectedKey: enums.BREADCRUMS.SOFTWARE_PRODUCT, + menuItems: [ + { + key: enums.BREADCRUMS.LICENSE_MODEL, + displayText: i18n('License Model') + }, + { + key: enums.BREADCRUMS.SOFTWARE_PRODUCT, + displayText: i18n('Software Products') + } + ] + }, + { + selectedKey: props.softwareProductId, + menuItems: wholeSoftwareProductList + .filter( + ({ vendorId, id }) => + vendorId === licenseModelId || + id === props.softwareProductId + ) + .map(({ id, name }) => ({ + key: id, + displayText: name + })) + }, + .../*screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] :*/ [ + { + selectedKey: + screenToBreadcrumb[screen] || + enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS, + menuItems: [ + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_LANDING_PAGE, + displayText: i18n('Overview') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_DETAILS, + displayText: i18n('General') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_DEPLOYMENT, + displayText: i18n('Deployment Flavors') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_PROCESSES, + displayText: i18n('Process Details') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_NETWORKS, + displayText: i18n('Networks') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_DEPENDENCIES, + displayText: i18n('Components Dependencies') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_ATTACHMENTS, + displayText: i18n('Attachments') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_ACTIVITY_LOG, + displayText: i18n('Activity Log') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENTS, + displayText: i18n('Components') + } + ].filter(item => { + switch (item.key) { + case enums.BREADCRUMS + .SOFTWARE_PRODUCT_ATTACHMENTS: + let isHeatData = + onboardingOrigin !== + onboardingOriginTypes.NONE || + candidateOnboardingOrigin === + onboardingOriginTypes.ZIP; + return isHeatData; + case enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENTS: + return componentsList.length > 0; + case enums.BREADCRUMS + .SOFTWARE_PRODUCT_DEPLOYMENT: + let isManualMode = + onboardingMethod === + onboardingMethodTypes.MANUAL; + return isManualMode; + case enums.BREADCRUMS + .SOFTWARE_PRODUCT_DEPENDENCIES: + return componentsList.length > 1; + default: + return true; + } + }) + } + ] + ]; + if (props.componentId) { + returnedBreadcrumb = [ + ...returnedBreadcrumb, + { + selectedKey: props.componentId, + menuItems: componentsList.map( + ({ id, displayName }) => ({ + key: id, + displayText: displayName + }) + ) + }, + ...[ + { + selectedKey: + componentScreenToBreadcrumb[screen], + menuItems: [ + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENT_GENERAL, + displayText: i18n('General') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENT_COMPUTE, + displayText: i18n('Compute') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, + displayText: i18n( + 'High Availability & Load Balancing' + ) + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENT_NETWORK, + displayText: i18n('Networks') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENT_STORAGE, + displayText: i18n('Storage') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENT_IMAGES, + displayText: i18n('Images') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENT_PROCESSES, + displayText: i18n('Process Details') + }, + { + key: + enums.BREADCRUMS + .SOFTWARE_PRODUCT_COMPONENT_MONITORING, + displayText: i18n('Monitoring') + } + ] + } + ] + ]; + } + return returnedBreadcrumb; + } + } } diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingReducers.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingReducers.js index 16c0e61491..9abae2d1c1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingReducers.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingReducers.js @@ -13,130 +13,159 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, enums} from './OnboardingConstants.js'; -import {actionTypes as permissionActionTypes} from './permissions/PermissionsConstants.js'; -import {actionTypes as licenseModelCreateActionTypes} from './licenseModel/creation/LicenseModelCreationConstants.js'; -import {actionTypes as softwareProductCreateActionTypes} from './softwareProduct/creation/SoftwareProductCreationConstants.js'; -import {actionTypes as versionCreateActionTypes} from './versionsPage/creation/VersionsPageCreationConstants.js'; -import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js'; - -import {catalogItemStatuses} from './onboard/onboardingCatalog/OnboardingCatalogConstants.js'; +import { actionTypes, enums } from './OnboardingConstants.js'; +import { actionTypes as permissionActionTypes } from './permissions/PermissionsConstants.js'; +import { actionTypes as licenseModelCreateActionTypes } from './licenseModel/creation/LicenseModelCreationConstants.js'; +import { actionTypes as softwareProductCreateActionTypes } from './softwareProduct/creation/SoftwareProductCreationConstants.js'; +import { actionTypes as versionCreateActionTypes } from './versionsPage/creation/VersionsPageCreationConstants.js'; +import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js'; + +import { catalogItemStatuses } from './onboard/onboardingCatalog/OnboardingCatalogConstants.js'; import Configuration from 'sdc-app/config/Configuration.js'; -const checkReadOnly = ({isCollaborator = true, inMerge = false, isCertified = false, isArchived = false}) => !isCollaborator || inMerge || isCertified || isArchived; - -const currentScreen = (state = { - forceBreadCrumbsUpdate: false, - screen: enums.SCREEN.ONBOARDING_CATALOG, - itemPermission: {}, - props: {} -}, action) => { - - switch (action.type) { - - case actionTypes.SET_CURRENT_SCREEN: { - let itemPermission = {...state.itemPermission}; - let {currentScreen} = action; - itemPermission.isArchived = currentScreen.props.status === catalogItemStatuses.ARCHIVED; - - if (currentScreen.props.version) { - let {status} = currentScreen.props.version; - itemPermission.isCertified = itemPermission.isCertified && status === catalogItemStatuses.CERTIFIED; - } - - let isReadOnlyMode = checkReadOnly(itemPermission); - let props = {...currentScreen.props, isReadOnlyMode}; - - return { - ...state, - ...currentScreen, - itemPermission, - props - }; - } - - case actionTypes.UPDATE_CURRENT_SCREEN_PROPS: - return { - ...state, - props: { - ...state.props, - ...action.props, - isReadOnlyMode: checkReadOnly(state.itemPermission) - } - }; - - case actionTypes.SET_CURRENT_SCREEN_VERSION: - return { - ...state, - props: { - ...state.props, - version: action.version, - isReadOnlyMode: checkReadOnly({...state.itemPermission,itemStatus: state.props.status}) - } - }; - - case licenseModelCreateActionTypes.LICENSE_MODEL_CREATED: - case softwareProductCreateActionTypes.SOFTWARE_PRODUCT_CREATED: - case versionCreateActionTypes.VERSION_CREATED: - return { - ...state, - itemPermission: { - isCollaborator: true, - inMerge: false, - isCertified: false - }, - props: { - ...state.props, - isReadOnlyMode: false - } - }; - - case permissionActionTypes.ITEM_USERS_LOADED: { - let userId = Configuration.get('UserID'); - let isCollaborator = false; - - if (userId === action.owner.userId) { - isCollaborator = true; - } else { - isCollaborator = action.contributors.reduce( - (foundUser, contributor) => foundUser || contributor.userId === userId, false - ); - } - - let itemPermission = {...state.itemPermission, isCollaborator}; - let isReadOnlyMode = checkReadOnly(itemPermission); - let props = {...state.props, isReadOnlyMode}; - - return { - ...state, - itemPermission, - props - }; - } - - case actionTypes.UPDATE_ITEM_STATUS: { - const {itemState: {synchronizationState, dirty}, itemStatus, updatedVersion, archivedStatus} = action; - const inMerge = synchronizationState === SyncStates.MERGE; - const isOutOfSync = synchronizationState === SyncStates.OUT_OF_SYNC; - const isUpToDate = synchronizationState === SyncStates.UP_TO_DATE; - const isCertified = itemStatus === catalogItemStatuses.CERTIFIED; - const isArchived = archivedStatus === catalogItemStatuses.ARCHIVED; - const itemPermission = {...state.itemPermission, inMerge, isDirty: dirty, isOutOfSync, isUpToDate, isCertified, isArchived}; - const isReadOnlyMode = checkReadOnly(itemPermission); - const props = {...state.props, isReadOnlyMode, version: {...state.props.version, ...updatedVersion}}; - - return { - ...state, - itemPermission, - props - }; - } - - default: - return state; - - } - +const checkReadOnly = ({ + isCollaborator = true, + inMerge = false, + isCertified = false, + isArchived = false +}) => !isCollaborator || inMerge || isCertified || isArchived; + +const currentScreen = ( + state = { + forceBreadCrumbsUpdate: false, + screen: enums.SCREEN.ONBOARDING_CATALOG, + itemPermission: {}, + props: {} + }, + action +) => { + switch (action.type) { + case actionTypes.SET_CURRENT_SCREEN: { + let itemPermission = { ...state.itemPermission }; + let { currentScreen } = action; + itemPermission.isArchived = + currentScreen.props.status === catalogItemStatuses.ARCHIVED; + + if (currentScreen.props.version) { + let { status } = currentScreen.props.version; + itemPermission.isCertified = + itemPermission.isCertified && + status === catalogItemStatuses.CERTIFIED; + } + + let isReadOnlyMode = checkReadOnly(itemPermission); + let props = { ...currentScreen.props, isReadOnlyMode }; + + return { + ...state, + ...currentScreen, + itemPermission, + props + }; + } + + case actionTypes.UPDATE_CURRENT_SCREEN_PROPS: + return { + ...state, + props: { + ...state.props, + ...action.props, + isReadOnlyMode: checkReadOnly(state.itemPermission) + } + }; + + case actionTypes.SET_CURRENT_SCREEN_VERSION: + return { + ...state, + props: { + ...state.props, + version: action.version, + isReadOnlyMode: checkReadOnly({ + ...state.itemPermission, + itemStatus: state.props.status + }) + } + }; + + case licenseModelCreateActionTypes.LICENSE_MODEL_CREATED: + case softwareProductCreateActionTypes.SOFTWARE_PRODUCT_CREATED: + case versionCreateActionTypes.VERSION_CREATED: + return { + ...state, + itemPermission: { + isCollaborator: true, + inMerge: false, + isCertified: false + }, + props: { + ...state.props, + isReadOnlyMode: false + } + }; + + case permissionActionTypes.ITEM_USERS_LOADED: { + let userId = Configuration.get('UserID'); + let isCollaborator = false; + + if (userId === action.owner.userId) { + isCollaborator = true; + } else { + isCollaborator = action.contributors.reduce( + (foundUser, contributor) => + foundUser || contributor.userId === userId, + false + ); + } + + let itemPermission = { ...state.itemPermission, isCollaborator }; + let isReadOnlyMode = checkReadOnly(itemPermission); + let props = { ...state.props, isReadOnlyMode }; + + return { + ...state, + itemPermission, + props + }; + } + + case actionTypes.UPDATE_ITEM_STATUS: { + const { + itemState: { synchronizationState, dirty }, + itemStatus, + updatedVersion, + archivedStatus + } = action; + const inMerge = synchronizationState === SyncStates.MERGE; + const isOutOfSync = synchronizationState === SyncStates.OUT_OF_SYNC; + const isUpToDate = synchronizationState === SyncStates.UP_TO_DATE; + const isCertified = itemStatus === catalogItemStatuses.CERTIFIED; + const isArchived = archivedStatus === catalogItemStatuses.ARCHIVED; + const itemPermission = { + ...state.itemPermission, + inMerge, + isDirty: dirty, + isOutOfSync, + isUpToDate, + isCertified, + isArchived + }; + const isReadOnlyMode = checkReadOnly(itemPermission); + const props = { + ...state.props, + isReadOnlyMode, + version: { ...state.props.version, ...updatedVersion } + }; + + return { + ...state, + itemPermission, + props + }; + } + + default: + return state; + } }; export default currentScreen; diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingReducersMap.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingReducersMap.js index 5b678b1d43..3b526a67f6 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingReducersMap.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingReducersMap.js @@ -30,19 +30,19 @@ import revisionsReducer from './revisions/RevisionsReducer.js'; import featuresReducer from 'sdc-app/features/FeaturesReducer.js'; export default { - currentScreen: currentScreenReducer, - licenseModel: licenseModelReducer, - licenseModelList: licenseModelListReducer, - archivedLicenseModelList: archivedLicenseModelListReducer, - archivedSoftwareProductList: archivedSoftwareProductListReducer, - finalizedLicenseModelList: finalizedLicenseModelListReducer, - finalizedSoftwareProductList: finalizedSoftwareProductReducer, - mergeEditor: mergeEditorReducer, - onboard: onboardReducer, - softwareProduct: softwareProductReducer, - softwareProductList: softwareProductListReducer, - users: usersReducer, - versionsPage: versionsPageReducer, - revisions: revisionsReducer, - features: featuresReducer + currentScreen: currentScreenReducer, + licenseModel: licenseModelReducer, + licenseModelList: licenseModelListReducer, + archivedLicenseModelList: archivedLicenseModelListReducer, + archivedSoftwareProductList: archivedSoftwareProductListReducer, + finalizedLicenseModelList: finalizedLicenseModelListReducer, + finalizedSoftwareProductList: finalizedSoftwareProductReducer, + mergeEditor: mergeEditorReducer, + onboard: onboardReducer, + softwareProduct: softwareProductReducer, + softwareProductList: softwareProductListReducer, + users: usersReducer, + versionsPage: versionsPageReducer, + revisions: revisionsReducer, + features: featuresReducer }; diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingView.jsx b/openecomp-ui/src/sdc-app/onboarding/OnboardingView.jsx index 7877085316..69e514bc6e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingView.jsx @@ -25,8 +25,8 @@ import FeatureGroupListEditor from './licenseModel/featureGroups/FeatureGroupLis import LicenseKeyGroupsListEditor from './licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js'; import EntitlementPoolsListEditor from './licenseModel/entitlementPools/EntitlementPoolsListEditor.js'; import SoftwareProduct from './softwareProduct/SoftwareProduct.js'; -import SoftwareProductLandingPage from './softwareProduct/landingPage/SoftwareProductLandingPage.js'; -import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDetails.js'; +import SoftwareProductLandingPage from './softwareProduct/landingPage/SoftwareProductLandingPage.js'; +import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDetails.js'; import SoftwareProductAttachments from './softwareProduct/attachments/SoftwareProductAttachments.js'; import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js'; import SoftwareProductDeployment from './softwareProduct/deployment/SoftwareProductDeployment.js'; @@ -48,136 +48,243 @@ import PropTypes from 'prop-types'; import React from 'react'; import ReactDOM from 'react-dom'; -import {enums} from './OnboardingConstants.js'; +import { enums } from './OnboardingConstants.js'; export default class OnboardingView extends React.Component { - static propTypes = { - currentScreen: PropTypes.shape({ - screen: PropTypes.oneOf(objectValues(enums.SCREEN)).isRequired, - props: PropTypes.object.isRequired, - itemPermission: PropTypes.object - }).isRequired - }; + static propTypes = { + currentScreen: PropTypes.shape({ + screen: PropTypes.oneOf(objectValues(enums.SCREEN)).isRequired, + props: PropTypes.object.isRequired, + itemPermission: PropTypes.object + }).isRequired + }; - componentDidMount() { - let element = ReactDOM.findDOMNode(this); - element.addEventListener('click', event => { - if (event.target.tagName === 'A') { - event.preventDefault(); - } - }); - ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType => - element.addEventListener(eventType, event => event.stopPropagation()) - ); - } + componentDidMount() { + let element = ReactDOM.findDOMNode(this); + element.addEventListener('click', event => { + if (event.target.tagName === 'A') { + event.preventDefault(); + } + }); + ['wheel', 'mousewheel', 'DOMMouseScroll'].forEach(eventType => + element.addEventListener(eventType, event => + event.stopPropagation() + ) + ); + } - render() { - let {currentScreen} = this.props; - let {screen, props} = currentScreen; + render() { + let { currentScreen } = this.props; + let { screen, props } = currentScreen; - return ( -
    - {(() => { - switch (screen) { - case enums.SCREEN.ONBOARDING_CATALOG: - return ; - case enums.SCREEN.VERSIONS_PAGE: - return ; + return ( +
    + {(() => { + switch (screen) { + case enums.SCREEN.ONBOARDING_CATALOG: + return ; + case enums.SCREEN.VERSIONS_PAGE: + return ; - case enums.SCREEN.LICENSE_AGREEMENTS: - case enums.SCREEN.FEATURE_GROUPS: - case enums.SCREEN.ENTITLEMENT_POOLS: - case enums.SCREEN.LICENSE_KEY_GROUPS: - case enums.SCREEN.LICENSE_MODEL_OVERVIEW: - case enums.SCREEN.ACTIVITY_LOG: - return ( - - { - (()=>{ - switch(screen) { - case enums.SCREEN.LICENSE_MODEL_OVERVIEW: - return ; - case enums.SCREEN.LICENSE_AGREEMENTS: - return ; - case enums.SCREEN.FEATURE_GROUPS: - return ; - case enums.SCREEN.ENTITLEMENT_POOLS: - return ; - case enums.SCREEN.LICENSE_KEY_GROUPS: - return ; - case enums.SCREEN.ACTIVITY_LOG: - return ; - } - })() - } - - ); + case enums.SCREEN.LICENSE_AGREEMENTS: + case enums.SCREEN.FEATURE_GROUPS: + case enums.SCREEN.ENTITLEMENT_POOLS: + case enums.SCREEN.LICENSE_KEY_GROUPS: + case enums.SCREEN.LICENSE_MODEL_OVERVIEW: + case enums.SCREEN.ACTIVITY_LOG: + return ( + + {(() => { + switch (screen) { + case enums.SCREEN + .LICENSE_MODEL_OVERVIEW: + return ( + + ); + case enums.SCREEN + .LICENSE_AGREEMENTS: + return ( + + ); + case enums.SCREEN.FEATURE_GROUPS: + return ( + + ); + case enums.SCREEN.ENTITLEMENT_POOLS: + return ( + + ); + case enums.SCREEN + .LICENSE_KEY_GROUPS: + return ( + + ); + case enums.SCREEN.ACTIVITY_LOG: + return ( + + ); + } + })()} + + ); - case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: - case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: - case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: - case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: - case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: - case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: - case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: - case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: - return ( - - { - (()=>{ - switch(screen) { - case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: - return ; - case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: - return ; - } - })() - } - - ); - } - })()} -
    - ); - } + case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: + case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: + case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: + case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: + case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: + case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: + case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: + case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: + return ( + + {(() => { + switch (screen) { + case enums.SCREEN + .SOFTWARE_PRODUCT_LANDING_PAGE: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_DETAILS: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_ATTACHMENTS: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_PROCESSES: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_DEPLOYMENT: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_NETWORKS: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_DEPENDENCIES: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENTS: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENT_PROCESSES: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENT_STORAGE: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENT_NETWORK: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENT_GENERAL: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENT_COMPUTE: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENT_IMAGES: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_COMPONENT_MONITORING: + return ( + + ); + case enums.SCREEN + .SOFTWARE_PRODUCT_ACTIVITY_LOG: + return ( + + ); + } + })()} + + ); + } + })()} +
    + ); + } } - diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/ArchivedLicenseModelListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/ArchivedLicenseModelListReducer.js index 8e4750e666..d5563f41ba 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/ArchivedLicenseModelListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/ArchivedLicenseModelListReducer.js @@ -13,13 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {actionTypes} from './LicenseModelConstants.js'; +import { actionTypes } from './LicenseModelConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.ARCHIVED_LICENSE_MODELS_LIST_LOADED: - return [...action.response.results]; - default: - return state; - } + switch (action.type) { + case actionTypes.ARCHIVED_LICENSE_MODELS_LIST_LOADED: + return [...action.response.results]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/FinalizedLicenseModelListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/FinalizedLicenseModelListReducer.js index cc9d9c536d..b5c2bff4ba 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/FinalizedLicenseModelListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/FinalizedLicenseModelListReducer.js @@ -13,13 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './LicenseModelConstants.js'; +import { actionTypes } from './LicenseModelConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.FINALIZED_LICENSE_MODELS_LIST_LOADED: - return [...action.response.results]; - default: - return state; - } + switch (action.type) { + case actionTypes.FINALIZED_LICENSE_MODELS_LIST_LOADED: + return [...action.response.results]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js index c390ecc9b0..cea369d2ec 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js @@ -4,173 +4,220 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import TabulatedEditor from 'src/nfvo-components/editor/TabulatedEditor.jsx'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import PermissionsActionHelper from './../permissions/PermissionsActionHelper.js'; import RevisionsActionHelper from './../revisions/RevisionsActionHelper.js'; import LicenseModelActionHelper from './LicenseModelActionHelper.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'; +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) => { - const {id, vendorName, version} = licenseModel; - const meta = {version}; - - const groups = [{ - id, - name: vendorName, - items: [ - { - id: enums.SCREEN.LICENSE_MODEL_OVERVIEW, - name: i18n('Overview'), - meta - }, - { - id: enums.SCREEN.LICENSE_AGREEMENTS, - name: i18n('License Agreements'), - meta - }, - { - id: enums.SCREEN.FEATURE_GROUPS, - name: i18n('Feature Groups'), - meta - }, - { - id: enums.SCREEN.ENTITLEMENT_POOLS, - name: i18n('Entitlement Pools'), - meta - }, - { - id: enums.SCREEN.LICENSE_KEY_GROUPS, - name: i18n('License Key Groups'), - meta - }, - { - id: enums.SCREEN.ACTIVITY_LOG, - name: i18n('Activity Log'), - meta - } - ] - }]; - - return { - activeItemId: screen, groups - }; + const { id, vendorName, version } = licenseModel; + const meta = { version }; + + const groups = [ + { + id, + name: vendorName, + items: [ + { + id: enums.SCREEN.LICENSE_MODEL_OVERVIEW, + name: i18n('Overview'), + meta + }, + { + id: enums.SCREEN.LICENSE_AGREEMENTS, + name: i18n('License Agreements'), + meta + }, + { + id: enums.SCREEN.FEATURE_GROUPS, + name: i18n('Feature Groups'), + meta + }, + { + id: enums.SCREEN.ENTITLEMENT_POOLS, + name: i18n('Entitlement Pools'), + meta + }, + { + id: enums.SCREEN.LICENSE_KEY_GROUPS, + name: i18n('License Key Groups'), + meta + }, + { + id: enums.SCREEN.ACTIVITY_LOG, + name: i18n('Activity Log'), + meta + } + ] + } + ]; + + return { + activeItemId: screen, + groups + }; }; - const buildVersionControllerProps = ({ - licenseModelEditor = {data: {}}, - versions, - currentVersion, - userInfo, - usersList, - permissions, - isArchived, - itemPermission, - isReadOnlyMode + licenseModelEditor = { data: {} }, + versions, + currentVersion, + userInfo, + usersList, + permissions, + isArchived, + itemPermission, + isReadOnlyMode }) => { - const {isValidityData = true} = licenseModelEditor; - return { - version: currentVersion, - viewableVersions: versions, - isFormDataValid: isValidityData, - permissions, - userInfo, - usersList, - isArchived, - itemName: licenseModelEditor.data.vendorName, - itemPermission, - isReadOnlyMode - }; + const { isValidityData = true } = licenseModelEditor; + return { + version: currentVersion, + viewableVersions: versions, + isFormDataValid: isValidityData, + permissions, + userInfo, + usersList, + isArchived, + itemName: licenseModelEditor.data.vendorName, + itemPermission, + isReadOnlyMode + }; }; - -const mapStateToProps = ({ - users: {userInfo, usersList}, - licenseModel: {licenseModelEditor}, - versionsPage: {permissions, versionsList: {versions, itemName}} -}, { - currentScreen: {screen, itemPermission, props: {isReadOnlyMode, version: currentVersion}} -}) => { - return { - versionControllerProps: buildVersionControllerProps({ - licenseModelEditor, - versions, - currentVersion, - userInfo, - permissions, - usersList, - isArchived: itemPermission.isArchived, - itemPermission, - isReadOnlyMode - }), - navigationBarProps: buildNavigationBarProps(licenseModelEditor.data, screen) - }; +const mapStateToProps = ( + { + users: { userInfo, usersList }, + licenseModel: { licenseModelEditor }, + versionsPage: { permissions, versionsList: { versions } } + }, + { + currentScreen: { + screen, + itemPermission, + props: { isReadOnlyMode, version: currentVersion } + } + } +) => { + return { + versionControllerProps: buildVersionControllerProps({ + licenseModelEditor, + versions, + currentVersion, + userInfo, + permissions, + usersList, + isArchived: itemPermission.isArchived, + itemPermission, + isReadOnlyMode + }), + navigationBarProps: buildNavigationBarProps( + licenseModelEditor.data, + screen + ) + }; }; - -const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {licenseModelId, version}}}) => { - - return { - 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}}); - }), - - 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}}); - }, - - 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}}); - } - }; +const mapActionsToProps = ( + dispatch, + { currentScreen: { screen, props: { licenseModelId, version } } } +) => { + return { + 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 } + }); + }), + + 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 } + }); + }, + + 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 } + }); + } + }; }; export default connect(mapStateToProps, mapActionsToProps)(TabulatedEditor); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js index d1d3a77d92..cfff9f1fcd 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js @@ -15,195 +15,279 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from './LicenseModelConstants.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {actionsEnum as vcActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import { actionTypes } from './LicenseModelConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionsEnum as vcActionsEnum } from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.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 {default as ItemsHelper} from 'sdc-app/common/helpers/ItemsHelper.js'; +import { default as ItemsHelper } from 'sdc-app/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 { 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'; +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'); - return `${restPrefix}/v1.0/vendor-license-models/`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-license-models/`; } function fetchLicenseModels() { - return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=${catalogItemStatuses.DRAFT}`); + return RestAPIUtil.fetch( + `${baseUrl()}?versionFilter=${catalogItemStatuses.DRAFT}` + ); } function fetchFinalizedLicenseModels() { - return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=${catalogItemStatuses.CERTIFIED}`); + return RestAPIUtil.fetch( + `${baseUrl()}?versionFilter=${catalogItemStatuses.CERTIFIED}` + ); } function fetchArchivedLicenseModels() { - return RestAPIUtil.fetch(`${baseUrl()}?Status=${catalogItemStatuses.ARCHIVED}`); + return RestAPIUtil.fetch( + `${baseUrl()}?Status=${catalogItemStatuses.ARCHIVED}` + ); } function fetchLicenseModelById(licenseModelId, version) { - const {id: versionId} = version; - return RestAPIUtil.fetch(`${baseUrl()}${licenseModelId}/versions/${versionId}`); + const { id: versionId } = version; + return RestAPIUtil.fetch( + `${baseUrl()}${licenseModelId}/versions/${versionId}` + ); } function putLicenseModel(licenseModel) { - let {id, vendorName, description, iconRef, version: {id: versionId}} = licenseModel; - return RestAPIUtil.put(`${baseUrl()}${id}/versions/${versionId}`, { - vendorName, - description, - iconRef - }); + let { + id, + vendorName, + description, + iconRef, + version: { id: versionId } + } = licenseModel; + return RestAPIUtil.put(`${baseUrl()}${id}/versions/${versionId}`, { + vendorName, + description, + iconRef + }); } -function putLicenseModelAction({itemId, action, version}) { - const {id: versionId} = version; - return RestAPIUtil.put(`${baseUrl()}${itemId}/versions/${versionId}/actions`, {action: action}); +function putLicenseModelAction({ itemId, action, version }) { + const { id: versionId } = version; + return RestAPIUtil.put( + `${baseUrl()}${itemId}/versions/${versionId}/actions`, + { action: action } + ); } const LicenseModelActionHelper = { + fetchLicenseModels(dispatch) { + return fetchLicenseModels().then(response => { + dispatch({ + type: actionTypes.LICENSE_MODELS_LIST_LOADED, + response + }); + }); + }, - fetchLicenseModels(dispatch) { - return fetchLicenseModels().then(response => { - dispatch({ - type: actionTypes.LICENSE_MODELS_LIST_LOADED, - response - }); - }); - }, + fetchFinalizedLicenseModels(dispatch) { + return fetchFinalizedLicenseModels().then(response => + dispatch({ + type: actionTypes.FINALIZED_LICENSE_MODELS_LIST_LOADED, + response + }) + ); + }, - fetchFinalizedLicenseModels(dispatch) { - return fetchFinalizedLicenseModels().then(response => dispatch({ - type: actionTypes.FINALIZED_LICENSE_MODELS_LIST_LOADED, - response - })); + fetchArchivedLicenseModels(dispatch) { + return fetchArchivedLicenseModels().then(response => + dispatch({ + type: actionTypes.ARCHIVED_LICENSE_MODELS_LIST_LOADED, + response + }) + ); + }, - }, + fetchLicenseModelById(dispatch, { licenseModelId, version }) { + return fetchLicenseModelById(licenseModelId, version).then(response => { + dispatch({ + type: actionTypes.LICENSE_MODEL_LOADED, + response: { ...response, version } + }); + }); + }, - fetchArchivedLicenseModels(dispatch) { - return fetchArchivedLicenseModels().then(response => dispatch({ - type: actionTypes.ARCHIVED_LICENSE_MODELS_LIST_LOADED, - response - })); + fetchLicenseModelItems(dispatch, { licenseModelId, version }) { + return Promise.all([ + LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, { + licenseModelId, + version + }), + FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, { + licenseModelId, + version + }), + EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, { + licenseModelId, + version + }), + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, { + licenseModelId, + version + }) + ]); + }, - }, + 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 }); + }, - fetchLicenseModelById(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'), + msg: i18n('This license model successfully submitted'), + cancelButtonText: i18n('OK'), + timeout: 2000 + } + }); + versionPageActionHelper.fetchVersions(dispatch, { + itemType: itemTypes.LICENSE_MODEL, + itemId: licenseModelId + }); + return Promise.resolve(updatedVersion); + }); + }); + }, - return fetchLicenseModelById(licenseModelId, version).then(response => { - dispatch({ - type: actionTypes.LICENSE_MODEL_LOADED, - response: {...response, version} - }); - }); - }, - - fetchLicenseModelItems(dispatch, {licenseModelId, version}) { - return Promise.all([ - LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version}), - FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version}), - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}), - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}) - ]); - }, - - 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'), - msg: i18n('This license model successfully submitted'), - cancelButtonText: i18n('OK'), - timeout: 2000 - } - }); - versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: licenseModelId}); - return Promise.resolve(updatedVersion); - }); - }); - }, - - performVCAction(dispatch, {licenseModelId, action, version, comment}) { - return MergeEditorActionHelper.analyzeSyncResult(dispatch, {itemId: licenseModelId, version}).then(({inMerge, isDirty, updatedVersion}) => { - if ( (updatedVersion.status === catalogItemStatuses.CERTIFIED || updatedVersion.archivedStatus === catalogItemStatuses.ARCHIVED) && - (action === VersionControllerActionsEnum.COMMIT || action === VersionControllerActionsEnum.SYNC)) { - versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: licenseModelId}); - const msg = updatedVersion.archivedStatus === catalogItemStatuses.ARCHIVED ? i18n('Item was Archived') : i18n('Item version already Certified'); - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data: { - title: i18n('Commit error'), - msg, - 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.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}); - } - }); - }); - } + performVCAction(dispatch, { licenseModelId, action, version, comment }) { + return MergeEditorActionHelper.analyzeSyncResult(dispatch, { + itemId: licenseModelId, + version + }).then(({ inMerge, isDirty, updatedVersion }) => { + if ( + (updatedVersion.status === catalogItemStatuses.CERTIFIED || + updatedVersion.archivedStatus === + catalogItemStatuses.ARCHIVED) && + (action === VersionControllerActionsEnum.COMMIT || + action === VersionControllerActionsEnum.SYNC) + ) { + versionPageActionHelper.fetchVersions(dispatch, { + itemType: itemTypes.LICENSE_MODEL, + itemId: licenseModelId + }); + const msg = + updatedVersion.archivedStatus === + catalogItemStatuses.ARCHIVED + ? i18n('Item was Archived') + : i18n('Item version already Certified'); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: i18n('Commit error'), + msg, + 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.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 + }); + } + }); + }); + } }; export default LicenseModelActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js index 08009ee305..d97f682535 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js @@ -17,23 +17,22 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; export const actionTypes = keyMirror({ - LICENSE_MODEL_LOADED: null, - LICENSE_MODELS_LIST_LOADED: null, - FINALIZED_LICENSE_MODELS_LIST_LOADED: null, - ARCHIVED_LICENSE_MODELS_LIST_LOADED: null, - EDIT_LICENSE_MODEL: null + LICENSE_MODEL_LOADED: null, + LICENSE_MODELS_LIST_LOADED: null, + FINALIZED_LICENSE_MODELS_LIST_LOADED: null, + ARCHIVED_LICENSE_MODELS_LIST_LOADED: null, + EDIT_LICENSE_MODEL: null }); - export const thresholdUnitType = { - ABSOLUTE: 'Absolute', - PERCENTAGE: 'Percentage' + ABSOLUTE: 'Absolute', + PERCENTAGE: 'Percentage' }; export const optionsInputValues = { - THRESHOLD_UNITS: [ - {enum: '', title: i18n('please select…')}, - {enum: thresholdUnitType.ABSOLUTE, title: 'Absolute'}, - {enum: thresholdUnitType.PERCENTAGE, title: '%'} - ] -}; \ No newline at end of file + THRESHOLD_UNITS: [ + { enum: '', title: i18n('please select…') }, + { enum: thresholdUnitType.ABSOLUTE, title: 'Absolute' }, + { enum: thresholdUnitType.PERCENTAGE, title: '%' } + ] +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelEditorReducer.js index add5ac6a98..2d27679283 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelEditorReducer.js @@ -13,16 +13,16 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './LicenseModelConstants.js'; +import { actionTypes } from './LicenseModelConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.LICENSE_MODEL_LOADED: - return { - ...state, - data: action.response - }; - default: - return state; - } + switch (action.type) { + case actionTypes.LICENSE_MODEL_LOADED: + return { + ...state, + data: action.response + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js index 36a190a39c..00d669c7d1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js @@ -13,13 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './LicenseModelConstants.js'; +import { actionTypes } from './LicenseModelConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.LICENSE_MODELS_LIST_LOADED: - return [...action.response.results]; - default: - return state; - } + switch (action.type) { + case actionTypes.LICENSE_MODELS_LIST_LOADED: + return [...action.response.results]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js index f635532348..f102d286f0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {combineReducers} from 'redux'; +import { combineReducers } from 'redux'; import activityLogReducer from 'sdc-app/common/activity-log/ActivityLogReducer.js'; @@ -32,56 +32,75 @@ import entitlementPoolsEditorReducer from './entitlementPools/EntitlementPoolsEd import licenseKeyGroupsEditorReducer from './licenseKeyGroups/LicenseKeyGroupsEditorReducer.js'; import licenseKeyGroupsListReducer from './licenseKeyGroups/LicenseKeyGroupsListReducer.js'; -import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js'; +import { createPlainDataReducer } from 'sdc-app/common/reducers/PlainDataReducer.js'; -import {actionTypes as licenseModelOverviewConstants, VLM_DESCRIPTION_FORM} from './overview/LicenseModelOverviewConstants.js'; -import limitEditorReducer from './limits/LimitEditorReducer.js'; +import { + actionTypes as licenseModelOverviewConstants, + VLM_DESCRIPTION_FORM +} from './overview/LicenseModelOverviewConstants.js'; +import limitEditorReducer from './limits/LimitEditorReducer.js'; export default combineReducers({ - licenseModelCreation: createPlainDataReducer(licenseModelCreationReducer), - licenseModelEditor: licenseModelEditorReducer, + licenseModelCreation: createPlainDataReducer(licenseModelCreationReducer), + licenseModelEditor: licenseModelEditorReducer, - licenseAgreement: combineReducers({ - licenseAgreementEditor: createPlainDataReducer(licenseAgreementEditorReducer), - licenseAgreementList: licenseAgreementListReducer - }), - featureGroup: combineReducers({ - featureGroupEditor: createPlainDataReducer(featureGroupsEditorReducer), - featureGroupsList: featureGroupsListReducer - }), - entitlementPool: combineReducers({ - entitlementPoolEditor: createPlainDataReducer(entitlementPoolsEditorReducer), - entitlementPoolsList: entitlementPoolsListReducer - }), - licenseKeyGroup: combineReducers({ - licenseKeyGroupsEditor: createPlainDataReducer(licenseKeyGroupsEditorReducer), - licenseKeyGroupsList: licenseKeyGroupsListReducer - }), - licenseModelOverview: combineReducers({ - selectedTab: (state = null, action) => action.type === licenseModelOverviewConstants.LICENSE_MODEL_OVERVIEW_TAB_SELECTED ? action.buttonTab : state, - descriptionEditor: createPlainDataReducer(function(state = false, action) { - if (action.type === licenseModelOverviewConstants.LM_DATA_CHANGED) { - return { - ...state, - data : { - description : action.description - }, - formReady: null, - formName: VLM_DESCRIPTION_FORM, - genericFieldInfo: { - 'description': { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 1000}] - } - } - }; - //return action.description; - } else { - return state; - } - } - )}), - limitEditor: createPlainDataReducer(limitEditorReducer), - activityLog: activityLogReducer + licenseAgreement: combineReducers({ + licenseAgreementEditor: createPlainDataReducer( + licenseAgreementEditorReducer + ), + licenseAgreementList: licenseAgreementListReducer + }), + featureGroup: combineReducers({ + featureGroupEditor: createPlainDataReducer(featureGroupsEditorReducer), + featureGroupsList: featureGroupsListReducer + }), + entitlementPool: combineReducers({ + entitlementPoolEditor: createPlainDataReducer( + entitlementPoolsEditorReducer + ), + entitlementPoolsList: entitlementPoolsListReducer + }), + licenseKeyGroup: combineReducers({ + licenseKeyGroupsEditor: createPlainDataReducer( + licenseKeyGroupsEditorReducer + ), + licenseKeyGroupsList: licenseKeyGroupsListReducer + }), + licenseModelOverview: combineReducers({ + selectedTab: (state = null, action) => + action.type === + licenseModelOverviewConstants.LICENSE_MODEL_OVERVIEW_TAB_SELECTED + ? action.buttonTab + : state, + descriptionEditor: createPlainDataReducer(function( + state = false, + action + ) { + if (action.type === licenseModelOverviewConstants.LM_DATA_CHANGED) { + return { + ...state, + data: { + description: action.description + }, + formReady: null, + formName: VLM_DESCRIPTION_FORM, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 1000 } + ] + } + } + }; + //return action.description; + } else { + return state; + } + }) + }), + limitEditor: createPlainDataReducer(limitEditorReducer), + activityLog: activityLogReducer }); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelValidations.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelValidations.js index 64bae3b6a0..340d345609 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelValidations.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelValidations.js @@ -14,28 +14,34 @@ * permissions and limitations under the License. */ import i18n from 'nfvo-utils/i18n/i18n.js'; -import {thresholdUnitType} from './LicenseModelConstants.js'; +import { thresholdUnitType } from './LicenseModelConstants.js'; import Validator from 'nfvo-utils/Validator.js'; export function validateStartDate(value, state) { - if (state.data.expiryDate) { - if (!value) { - return {isValid: false, errorText: i18n('Start date has to be specified if expiry date is specified')}; - } - } - return {isValid: true, errorText: ''}; + if (state.data.expiryDate) { + if (!value) { + return { + isValid: false, + errorText: i18n( + 'Start date has to be specified if expiry date is specified' + ) + }; + } + } + return { isValid: true, errorText: '' }; } export function thresholdValueValidation(value, state) { - let unit = state.data.thresholdUnits; - if (unit === thresholdUnitType.PERCENTAGE) { - return Validator.validate('thresholdValue', value, [ - {type: 'numeric', data: true}, - {type: 'maximum', data: 100}, - {type: 'minimum', data: 0}]); - } else { - return Validator.validate('thresholdValue', value, [ - {type: 'numeric', data: true}, - ]); - } + let unit = state.data.thresholdUnits; + if (unit === thresholdUnitType.PERCENTAGE) { + return Validator.validate('thresholdValue', value, [ + { type: 'numeric', data: true }, + { type: 'maximum', data: 100 }, + { type: 'minimum', data: 0 } + ]); + } else { + return Validator.validate('thresholdValue', value, [ + { type: 'numeric', data: true } + ]); + } } 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 bcd6e7fe5b..4bbab865fa 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js @@ -13,48 +13,84 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; 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 { 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 { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import PermissionsActionHelper from 'sdc-app/onboarding/permissions/PermissionsActionHelper.js'; -export const mapStateToProps = ({users: {usersList}, licenseModelList, finalizedLicenseModelList, archivedLicenseModelList, licenseModel: {licenseModelCreation}}) => { - let {genericFieldInfo} = licenseModelCreation; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - let VLMNames = {}; +export const mapStateToProps = ({ + users: { usersList }, + licenseModelList, + finalizedLicenseModelList, + archivedLicenseModelList, + licenseModel: { licenseModelCreation } +}) => { + let { genericFieldInfo } = licenseModelCreation; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + let VLMNames = {}; - const allVlmList = [...licenseModelList, ...finalizedLicenseModelList,...archivedLicenseModelList]; - allVlmList.map((item) => { - VLMNames[item.name.toLowerCase()] = item.id; - }); + const allVlmList = [ + ...licenseModelList, + ...finalizedLicenseModelList, + ...archivedLicenseModelList + ]; + allVlmList.map(item => { + VLMNames[item.name.toLowerCase()] = item.id; + }); - return {...licenseModelCreation, isFormValid: isFormValid, VLMNames, usersList}; + 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, usersList) => { - LicenseModelCreationActionHelper.close(dispatch); - LicenseModelCreationActionHelper.createLicenseModel(dispatch, {licenseModel}).then(response => { - 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) - }; +export const mapActionsToProps = dispatch => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onCancel: () => LicenseModelCreationActionHelper.close(dispatch), + onSubmit: (licenseModel, usersList) => { + LicenseModelCreationActionHelper.close(dispatch); + LicenseModelCreationActionHelper.createLicenseModel(dispatch, { + licenseModel + }).then(response => { + 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) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(LicenseModelCreationView); +export default connect(mapStateToProps, mapActionsToProps)( + LicenseModelCreationView +); 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 87df1386b6..e2b8d55ffe 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js @@ -15,59 +15,56 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from './LicenseModelCreationConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes } from './LicenseModelCreationConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; function baseUrl() { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-license-models/`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-license-models/`; } function createLicenseModel(licenseModel) { - return RestAPIUtil.post(baseUrl(), { - vendorName: licenseModel.vendorName, - description: licenseModel.description, - iconRef: 'icon' - }); + return RestAPIUtil.post(baseUrl(), { + vendorName: licenseModel.vendorName, + description: licenseModel.description, + iconRef: 'icon' + }); } - export default { + open(dispatch) { + dispatch({ + type: actionTypes.OPEN + }); - open(dispatch) { - dispatch({ - type: actionTypes.OPEN - }); - - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.LICENSE_MODEL_CREATION, - title: i18n('New License Model') - } - }); - }, - - close(dispatch){ - dispatch({ - type: actionTypes.CLOSE - }); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.LICENSE_MODEL_CREATION, + title: i18n('New License Model') + } + }); + }, - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - }, + close(dispatch) { + dispatch({ + type: actionTypes.CLOSE + }); - createLicenseModel(dispatch, {licenseModel}){ - return createLicenseModel(licenseModel).then(result => { - dispatch({ - type: actionTypes.LICENSE_MODEL_CREATED, - result - }); - return result; - }); - } + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + }, + createLicenseModel(dispatch, { 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 e9b1c46bef..1cd61a9e4b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationConstants.js @@ -16,9 +16,9 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - OPEN: null, - CLOSE: null, - LICENSE_MODEL_CREATED: null + OPEN: 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/LicenseModelCreationReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationReducer.js index 879d356de2..7137230cc7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationReducer.js @@ -13,32 +13,41 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, LICENSE_MODEL_CREATION_FORM_NAME} from './LicenseModelCreationConstants.js'; +import { + actionTypes, + LICENSE_MODEL_CREATION_FORM_NAME +} from './LicenseModelCreationConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.OPEN: - return { - ...state, - formReady: null, - formName: LICENSE_MODEL_CREATION_FORM_NAME, - data: {}, - genericFieldInfo: { - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 1000}] - }, - 'vendorName' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 25}] - } - } - }; - case actionTypes.CLOSE: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.OPEN: + return { + ...state, + formReady: null, + formName: LICENSE_MODEL_CREATION_FORM_NAME, + data: {}, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 1000 } + ] + }, + vendorName: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 25 } + ] + } + } + }; + case actionTypes.CLOSE: + return {}; + default: + return state; + } }; 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 948bdc158d..59c4152213 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx @@ -19,84 +19,112 @@ 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'; +import { LICENSE_MODEL_CREATION_FORM_NAME } from './LicenseModelCreationConstants.js'; const LicenseModelPropType = PropTypes.shape({ - id: PropTypes.string, - vendorName: PropTypes.string, - description: PropTypes.string + id: PropTypes.string, + vendorName: PropTypes.string, + description: PropTypes.string }); class LicenseModelCreationView extends React.Component { + static propTypes = { + data: LicenseModelPropType, + VLMNames: PropTypes.object, + usersList: PropTypes.array, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onValidateForm: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired + }; - static propTypes = { - data: LicenseModelPropType, - VLMNames: PropTypes.object, - usersList: PropTypes.array, - onDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onValidateForm: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired - }; + render() { + let { data = {}, onDataChanged, genericFieldInfo } = this.props; + let { vendorName, description } = data; + return ( +
    + {genericFieldInfo && ( +
    this.submit()} + submitButtonText={i18n('Create')} + onReset={() => this.props.onCancel()} + labledButtons={true} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => this.validate()}> + + onDataChanged( + { vendorName }, + LICENSE_MODEL_CREATION_FORM_NAME, + { + vendorName: name => + this.validateName(name) + } + ) + } + isValid={genericFieldInfo.vendorName.isValid} + errorText={genericFieldInfo.vendorName.errorText} + type="text" + isRequired={true} + className="field-section" + /> + + onDataChanged( + { description }, + LICENSE_MODEL_CREATION_FORM_NAME + ) + } + isValid={genericFieldInfo.description.isValid} + errorText={genericFieldInfo.description.errorText} + type="textarea" + className="field-section" + /> +
    + )} +
    + ); + } - render() { - let {data = {}, onDataChanged, genericFieldInfo} = this.props; - let {vendorName, description} = data; - return ( -
    - {genericFieldInfo &&
    this.submit() } - submitButtonText={i18n('Create')} - onReset={ () => this.props.onCancel() } - labledButtons={true} - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.validate() }> - onDataChanged({vendorName}, LICENSE_MODEL_CREATION_FORM_NAME, {vendorName: name => this.validateName(name)})} - isValid={genericFieldInfo.vendorName.isValid} - errorText={genericFieldInfo.vendorName.errorText} - type='text' - isRequired={true} - className='field-section'/> - onDataChanged({description}, LICENSE_MODEL_CREATION_FORM_NAME)} - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} - type='textarea' - className='field-section'/> -
    } -
    - ); - } + submit() { + const { data: licenseModel, usersList } = this.props; + this.props.onSubmit(licenseModel, usersList); + } + validateName(value) { + const { data: { id }, VLMNames } = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({ + itemId: id, + itemName: value, + list: VLMNames + }); - submit() { - const {data:licenseModel, usersList} = this.props; - this.props.onSubmit(licenseModel, usersList); - } + return !isExists + ? { isValid: true, errorText: '' } + : { + isValid: false, + errorText: i18n( + "License model by the name '" + + value + + "' already exists. License model name must be unique" + ) + }; + } - validateName(value) { - const {data: {id}, VLMNames} = this.props; - const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: VLMNames}); - - return !isExists ? {isValid: true, errorText: ''} : - {isValid: false, errorText: i18n('License model by the name \'' + value + '\' already exists. License model name must be unique')}; - } - - validate() { - this.props.onValidateForm(LICENSE_MODEL_CREATION_FORM_NAME); - } + validate() { + this.props.onValidateForm(LICENSE_MODEL_CREATION_FORM_NAME); + } } export default LicenseModelCreationView; 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 84bdac804c..181fc11c9d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js @@ -15,197 +15,281 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes as entitlementPoolsActionTypes } from './EntitlementPoolsConstants.js'; -import {actionTypes as limitEditorActions} from 'sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js'; -import {default as getValue, getStrValue} from 'nfvo-utils/getValue.js'; +import { actionTypes as entitlementPoolsActionTypes } from './EntitlementPoolsConstants.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'); - const {id: versionId} = version; - return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/entitlement-pools`; + const restPrefix = Configuration.get('restPrefix'); + const { id: versionId } = version; + return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/entitlement-pools`; } function fetchEntitlementPoolsList(licenseModelId, version) { - return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } function postEntitlementPool(licenseModelId, entitlementPool, version) { - return RestAPIUtil.post(baseUrl(licenseModelId, version), { - name: entitlementPool.name, - description: entitlementPool.description, - thresholdValue: entitlementPool.thresholdValue, - thresholdUnits: getValue(entitlementPool.thresholdUnits), - increments: entitlementPool.increments, - operationalScope: getValue(entitlementPool.operationalScope), - time: entitlementPool.time, - startDate: entitlementPool.startDate, - expiryDate: entitlementPool.expiryDate - }); + return RestAPIUtil.post(baseUrl(licenseModelId, version), { + name: entitlementPool.name, + description: entitlementPool.description, + thresholdValue: entitlementPool.thresholdValue, + thresholdUnits: getValue(entitlementPool.thresholdUnits), + increments: entitlementPool.increments, + operationalScope: getValue(entitlementPool.operationalScope), + time: entitlementPool.time, + startDate: entitlementPool.startDate, + expiryDate: entitlementPool.expiryDate + }); } - -function putEntitlementPool(licenseModelId, previousEntitlementPool, entitlementPool, version) { - - return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${entitlementPool.id}`, { - name: entitlementPool.name, - description: entitlementPool.description, - thresholdValue: entitlementPool.thresholdValue, - thresholdUnits: getValue(entitlementPool.thresholdUnits), - increments: entitlementPool.increments, - operationalScope: getValue(entitlementPool.operationalScope), - time: entitlementPool.time, - startDate: entitlementPool.startDate, - expiryDate: entitlementPool.expiryDate - }); +function putEntitlementPool( + licenseModelId, + previousEntitlementPool, + entitlementPool, + version +) { + return RestAPIUtil.put( + `${baseUrl(licenseModelId, version)}/${entitlementPool.id}`, + { + name: entitlementPool.name, + description: entitlementPool.description, + thresholdValue: entitlementPool.thresholdValue, + thresholdUnits: getValue(entitlementPool.thresholdUnits), + increments: entitlementPool.increments, + operationalScope: getValue(entitlementPool.operationalScope), + time: entitlementPool.time, + startDate: entitlementPool.startDate, + expiryDate: entitlementPool.expiryDate + } + ); } function deleteEntitlementPool(licenseModelId, entitlementPoolId, version) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}`); + return RestAPIUtil.destroy( + `${baseUrl(licenseModelId, version)}/${entitlementPoolId}` + ); } function fetchLimitsList(licenseModelId, entitlementPoolId, version) { - return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits`); + return RestAPIUtil.fetch( + `${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits` + ); } function deleteLimit(licenseModelId, entitlementPoolId, version, limitId) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits/${limitId}`); + return RestAPIUtil.destroy( + `${baseUrl( + licenseModelId, + version + )}/${entitlementPoolId}/limits/${limitId}` + ); } function postLimit(licenseModelId, entitlementPoolId, version, limit) { - return RestAPIUtil.post(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits`, { - name: limit.name, - type: limit.type, - description: limit.description, - metric: getStrValue(limit.metric), - value: limit.value, - unit: getStrValue(limit.unit), - aggregationFunction: getValue(limit.aggregationFunction), - time: getValue(limit.time) - }); + return RestAPIUtil.post( + `${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits`, + { + name: limit.name, + type: limit.type, + description: limit.description, + metric: getStrValue(limit.metric), + value: limit.value, + unit: getStrValue(limit.unit), + aggregationFunction: getValue(limit.aggregationFunction), + time: getValue(limit.time) + } + ); } function putLimit(licenseModelId, entitlementPoolId, version, limit) { - - return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits/${limit.id}`, { - name: limit.name, - type: limit.type, - description: limit.description, - metric: getStrValue(limit.metric), - value: limit.value, - unit: getStrValue(limit.unit), - aggregationFunction: getValue(limit.aggregationFunction), - time: getValue(limit.time) - }); + return RestAPIUtil.put( + `${baseUrl(licenseModelId, version)}/${entitlementPoolId}/limits/${ + limit.id + }`, + { + name: limit.name, + type: limit.type, + description: limit.description, + metric: getStrValue(limit.metric), + value: limit.value, + unit: getStrValue(limit.unit), + aggregationFunction: getValue(limit.aggregationFunction), + time: getValue(limit.time) + } + ); } export default { + fetchEntitlementPoolsList(dispatch, { licenseModelId, version }) { + return fetchEntitlementPoolsList(licenseModelId, version).then( + response => + dispatch({ + type: + entitlementPoolsActionTypes.ENTITLEMENT_POOLS_LIST_LOADED, + response + }) + ); + }, + + openEntitlementPoolsEditor( + dispatch, + { entitlementPool, licenseModelId, version } = {} + ) { + if (licenseModelId && version) { + this.fetchLimits(dispatch, { + licenseModelId, + version, + entitlementPool + }); + } + dispatch({ + type: entitlementPoolsActionTypes.entitlementPoolsEditor.OPEN, + entitlementPool + }); + }, + + deleteEntitlementPool( + dispatch, + { licenseModelId, entitlementPoolId, version } + ) { + return deleteEntitlementPool( + licenseModelId, + entitlementPoolId, + version + ).then(() => { + dispatch({ + type: entitlementPoolsActionTypes.DELETE_ENTITLEMENT_POOL, + entitlementPoolId + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + }, + + entitlementPoolsEditorDataChanged(dispatch, { deltaData }) { + dispatch({ + type: + entitlementPoolsActionTypes.entitlementPoolsEditor.DATA_CHANGED, + deltaData + }); + }, + + closeEntitlementPoolsEditor(dispatch) { + dispatch({ + type: entitlementPoolsActionTypes.entitlementPoolsEditor.CLOSE + }); + }, + + saveEntitlementPool( + dispatch, + { licenseModelId, previousEntitlementPool, entitlementPool, version } + ) { + if (previousEntitlementPool) { + return putEntitlementPool( + licenseModelId, + previousEntitlementPool, + entitlementPool, + version + ).then(() => { + dispatch({ + type: entitlementPoolsActionTypes.EDIT_ENTITLEMENT_POOL, + entitlementPool + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + } else { + return postEntitlementPool( + licenseModelId, + entitlementPool, + version + ).then(response => { + dispatch({ + type: entitlementPoolsActionTypes.ADD_ENTITLEMENT_POOL, + entitlementPool: { + ...entitlementPool, + referencingFeatureGroups: [], + id: response.value + } + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + } + }, + + hideDeleteConfirm(dispatch) { + dispatch({ + type: entitlementPoolsActionTypes.ENTITLEMENT_POOLS_DELETE_CONFIRM, + entitlementPoolToDelete: false + }); + }, + openDeleteEntitlementPoolConfirm(dispatch, { entitlementPool }) { + dispatch({ + type: entitlementPoolsActionTypes.ENTITLEMENT_POOLS_DELETE_CONFIRM, + entitlementPoolToDelete: entitlementPool + }); + }, + + fetchLimits(dispatch, { licenseModelId, version, entitlementPool }) { + return fetchLimitsList( + licenseModelId, + entitlementPool.id, + version + ).then(response => { + dispatch({ + type: + entitlementPoolsActionTypes.entitlementPoolsEditor + .LIMITS_LIST_LOADED, + response + }); + }); + }, + + submitLimit(dispatch, { licenseModelId, version, entitlementPool, limit }) { + const propmise = limit.id + ? putLimit(licenseModelId, entitlementPool.id, version, limit) + : postLimit(licenseModelId, entitlementPool.id, version, limit); + return propmise.then(() => { + dispatch({ + type: limitEditorActions.CLOSE + }); + this.fetchLimits(dispatch, { + licenseModelId, + version, + entitlementPool + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + }, - fetchEntitlementPoolsList(dispatch, {licenseModelId, version}) { - return fetchEntitlementPoolsList(licenseModelId, version).then(response => dispatch({ - type: entitlementPoolsActionTypes.ENTITLEMENT_POOLS_LIST_LOADED, - response - })); - }, - - openEntitlementPoolsEditor(dispatch, {entitlementPool, licenseModelId, version} = {}) { - if (licenseModelId && version) { - this.fetchLimits(dispatch, {licenseModelId, version, entitlementPool}); - } - dispatch({ - type: entitlementPoolsActionTypes.entitlementPoolsEditor.OPEN, - entitlementPool - }); - }, - - deleteEntitlementPool(dispatch, {licenseModelId, entitlementPoolId, version}) { - return deleteEntitlementPool(licenseModelId, entitlementPoolId, version).then(() => { - dispatch({ - type: entitlementPoolsActionTypes.DELETE_ENTITLEMENT_POOL, - entitlementPoolId - }); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - }, - - entitlementPoolsEditorDataChanged(dispatch, {deltaData}) { - dispatch({ - type: entitlementPoolsActionTypes.entitlementPoolsEditor.DATA_CHANGED, - deltaData - }); - }, - - closeEntitlementPoolsEditor(dispatch) { - dispatch({ - type: entitlementPoolsActionTypes.entitlementPoolsEditor.CLOSE - }); - }, - - saveEntitlementPool(dispatch, {licenseModelId, previousEntitlementPool, entitlementPool, version}) { - if (previousEntitlementPool) { - return putEntitlementPool(licenseModelId, previousEntitlementPool, entitlementPool, version).then(() => { - dispatch({ - type: entitlementPoolsActionTypes.EDIT_ENTITLEMENT_POOL, - entitlementPool - }); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } - else { - return postEntitlementPool(licenseModelId, entitlementPool, version).then(response => { - dispatch({ - type: entitlementPoolsActionTypes.ADD_ENTITLEMENT_POOL, - entitlementPool: { - ...entitlementPool, - referencingFeatureGroups: [], - id: response.value - } - }); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } - }, - - hideDeleteConfirm(dispatch) { - dispatch({ - type: entitlementPoolsActionTypes.ENTITLEMENT_POOLS_DELETE_CONFIRM, - entitlementPoolToDelete: false - }); - }, - openDeleteEntitlementPoolConfirm(dispatch, {entitlementPool}) { - dispatch({ - type: entitlementPoolsActionTypes.ENTITLEMENT_POOLS_DELETE_CONFIRM, - entitlementPoolToDelete: entitlementPool - }); - }, - - - - fetchLimits(dispatch, {licenseModelId, version, entitlementPool}) { - return fetchLimitsList(licenseModelId, entitlementPool.id, version). then (response => { - dispatch({ - type: entitlementPoolsActionTypes.entitlementPoolsEditor.LIMITS_LIST_LOADED, - response - }); - }); - }, - - submitLimit(dispatch, {licenseModelId, version, entitlementPool, limit}) { - const propmise = limit.id ? putLimit(licenseModelId,entitlementPool.id, version, limit) - : postLimit(licenseModelId,entitlementPool.id, version, limit); - return propmise.then(() => { - dispatch({ - type: limitEditorActions.CLOSE - }); - this.fetchLimits(dispatch, {licenseModelId, version, entitlementPool}); - return 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}); - return 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 + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js index de2a87ceaf..e69ff688ab 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js @@ -15,104 +15,112 @@ */ import keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import InputOptions, { + other as optionInputOther +} from 'nfvo-components/input/validation/InputOptions.jsx'; export const actionTypes = keyMirror({ + ENTITLEMENT_POOLS_LIST_LOADED: null, + ADD_ENTITLEMENT_POOL: null, + EDIT_ENTITLEMENT_POOL: null, + DELETE_ENTITLEMENT_POOL: null, - ENTITLEMENT_POOLS_LIST_LOADED: null, - ADD_ENTITLEMENT_POOL: null, - EDIT_ENTITLEMENT_POOL: null, - DELETE_ENTITLEMENT_POOL: null, - - entitlementPoolsEditor: { - OPEN: null, - CLOSE: null, - DATA_CHANGED: null, - LIMITS_LIST_LOADED: null - } - + entitlementPoolsEditor: { + OPEN: null, + CLOSE: null, + DATA_CHANGED: null, + LIMITS_LIST_LOADED: null + } }); export const enums = keyMirror({ - SELECTED_FEATURE_GROUP_TAB: { - GENERAL: 1, - ENTITLEMENT_POOLS: 2, - LICENCE_KEY_GROUPS: 3 - }, - SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: { - ASSOCIATED_ENTITLEMENT_POOLS: 1, - AVAILABLE_ENTITLEMENT_POOLS: 2 - } + SELECTED_FEATURE_GROUP_TAB: { + GENERAL: 1, + ENTITLEMENT_POOLS: 2, + LICENCE_KEY_GROUPS: 3 + }, + SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: { + ASSOCIATED_ENTITLEMENT_POOLS: 1, + AVAILABLE_ENTITLEMENT_POOLS: 2 + } }); export const defaultState = { - ENTITLEMENT_POOLS_EDITOR_DATA: { - entitlementMetric: {choice: '', other: ''}, - aggregationFunction: {choice: '', other: ''}, - operationalScope: {choices: [], other: ''}, - time: {choice: '', other: ''} - } + ENTITLEMENT_POOLS_EDITOR_DATA: { + entitlementMetric: { choice: '', other: '' }, + aggregationFunction: { choice: '', other: '' }, + operationalScope: { choices: [], other: '' }, + time: { choice: '', other: '' } + } }; export const thresholdUnitType = { - ABSOLUTE: 'Absolute', - PERCENTAGE: 'Percentage' + ABSOLUTE: 'Absolute', + PERCENTAGE: 'Percentage' }; export const optionsInputValues = { - OPERATIONAL_SCOPE: [ - {enum: '', title: i18n('please select…')}, - {enum: 'Network_Wide', title: 'Network Wide'}, - {enum: 'Availability_Zone', title: 'Availability Zone'}, - {enum: 'Data_Center', title: 'Data Center'}, - {enum: 'Tenant', title: 'Tenant'}, - {enum: 'VM', title: 'VM'}, - {enum: 'CPU', title: 'CPU'}, - {enum: 'Core', title: 'Core'} - ], - TIME: [ - {enum: '', title: i18n('please select…')}, - {enum: 'Hour', title: 'Hour'}, - {enum: 'Day', title: 'Day'}, - {enum: 'Month', title: 'Month'} - ], - AGGREGATE_FUNCTION: [ - {enum: '', title: i18n('please select…')}, - {enum: 'Peak', title: 'Peak'}, - {enum: 'Average', title: 'Average'} - ], - ENTITLEMENT_METRIC: [ - {enum: '', title: i18n('please select…')}, - {enum: 'Software_Instances_Count', title: 'Software Instances'}, - {enum: 'Core', title: 'Core'}, - {enum: 'CPU', title: 'CPU'}, - {enum: 'Trunks', title: 'Trunks'}, - {enum: 'User', title: 'User'}, - {enum: 'Subscribers', title: 'Subscribers'}, - {enum: 'Tenants', title: 'Tenants'}, - {enum: 'Tokens', title: 'Tokens'}, - {enum: 'Seats', title: 'Seats'}, - {enum: 'Units_TB', title: 'Units-TB'}, - {enum: 'Units_GB', title: 'Units-GB'}, - {enum: 'Units_MB', title: 'Units-MB'} - ] + OPERATIONAL_SCOPE: [ + { enum: '', title: i18n('please select…') }, + { enum: 'Network_Wide', title: 'Network Wide' }, + { enum: 'Availability_Zone', title: 'Availability Zone' }, + { enum: 'Data_Center', title: 'Data Center' }, + { enum: 'Tenant', title: 'Tenant' }, + { enum: 'VM', title: 'VM' }, + { enum: 'CPU', title: 'CPU' }, + { enum: 'Core', title: 'Core' } + ], + TIME: [ + { enum: '', title: i18n('please select…') }, + { enum: 'Hour', title: 'Hour' }, + { enum: 'Day', title: 'Day' }, + { enum: 'Month', title: 'Month' } + ], + AGGREGATE_FUNCTION: [ + { enum: '', title: i18n('please select…') }, + { enum: 'Peak', title: 'Peak' }, + { enum: 'Average', title: 'Average' } + ], + ENTITLEMENT_METRIC: [ + { enum: '', title: i18n('please select…') }, + { enum: 'Software_Instances_Count', title: 'Software Instances' }, + { enum: 'Core', title: 'Core' }, + { enum: 'CPU', title: 'CPU' }, + { enum: 'Trunks', title: 'Trunks' }, + { enum: 'User', title: 'User' }, + { enum: 'Subscribers', title: 'Subscribers' }, + { enum: 'Tenants', title: 'Tenants' }, + { enum: 'Tokens', title: 'Tokens' }, + { enum: 'Seats', title: 'Seats' }, + { enum: 'Units_TB', title: 'Units-TB' }, + { enum: 'Units_GB', title: 'Units-GB' }, + { enum: 'Units_MB', title: 'Units-MB' } + ] }; -export const extractValue = (item) => { - if (item === undefined) {return '';} //TODO fix it later - return item ? item.choice === optionInputOther.OTHER ? item.other : InputOptions.getTitleByName(optionsInputValues, item.choice) : ''; +export const extractValue = item => { + if (item === undefined) { + return ''; + } //TODO fix it later + return item + ? item.choice === optionInputOther.OTHER + ? item.other + : InputOptions.getTitleByName(optionsInputValues, item.choice) + : ''; }; -export const extractUnits = (units) => { - if (units === undefined) {return '';} //TODO fix it later - return units === 'Absolute' ? '' : '%'; +export const extractUnits = units => { + if (units === undefined) { + return ''; + } //TODO fix it later + return units === 'Absolute' ? '' : '%'; }; export const tabIds = { - GENERAL: 'GENERAL', - SP_LIMITS: 'SP_LIMITS', - VENDOR_LIMITS: 'VENDOR_LIMITS', - ADD_LIMIT_BUTTON: 'ADD_LIMIT_BUTTON' + GENERAL: 'GENERAL', + SP_LIMITS: 'SP_LIMITS', + VENDOR_LIMITS: 'VENDOR_LIMITS', + ADD_LIMIT_BUTTON: 'ADD_LIMIT_BUTTON' }; -export const SP_ENTITLEMENT_POOL_FORM = 'SPENTITLEMENTPOOL'; \ No newline at end of file +export const SP_ENTITLEMENT_POOL_FORM = 'SPENTITLEMENTPOOL'; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js index 23c260f793..5fcdad992a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js @@ -13,54 +13,80 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; import EntitlementPoolsEditorView from './EntitlementPoolsEditorView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import LimitEditorActionHelper from '../limits/LimitEditorActionHelper.js'; -const mapStateToProps = ({licenseModel: {entitlementPool}}) => { +const mapStateToProps = ({ licenseModel: { entitlementPool } }) => { + let { + data, + genericFieldInfo, + formReady, + limitsList + } = entitlementPool.entitlementPoolEditor; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - let {data, genericFieldInfo, formReady, limitsList} = entitlementPool.entitlementPoolEditor; + let previousData, + EPNames = {}; + const entitlementPoolId = data ? data.id : null; + if (entitlementPoolId) { + previousData = entitlementPool.entitlementPoolsList.find( + entitlementPool => entitlementPool.id === entitlementPoolId + ); + } - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + const list = entitlementPool.entitlementPoolsList; + for (let i = 0; i < list.length; i++) { + EPNames[list[i].name.toLowerCase()] = list[i].id; + } - let previousData, EPNames = {}; - const entitlementPoolId = data ? data.id : null; - if(entitlementPoolId) { - previousData = entitlementPool.entitlementPoolsList.find(entitlementPool => entitlementPool.id === entitlementPoolId); - } - - const list = entitlementPool.entitlementPoolsList; - for (let i = 0; i < list.length; i++) { - EPNames[list[i].name.toLowerCase()] = list[i].id; - } - - return { - data, - genericFieldInfo, - previousData, - isFormValid, - formReady, - EPNames, - limitsList - }; + return { + data, + genericFieldInfo, + previousData, + isFormValid, + formReady, + EPNames, + limitsList + }; }; -const mapActionsToProps = (dispatch, {licenseModelId, version}) => { - return { - onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), - onCancel: () => EntitlementPoolsActionHelper.closeEntitlementPoolsEditor(dispatch), - onSubmit: ({previousEntitlementPool, entitlementPool, keepOpen}) => { - if (!keepOpen) {EntitlementPoolsActionHelper.closeEntitlementPoolsEditor(dispatch);} - EntitlementPoolsActionHelper.saveEntitlementPool(dispatch, {licenseModelId, previousEntitlementPool, entitlementPool, version}); - }, - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName), - onCloseLimitEditor: () => LimitEditorActionHelper.closeLimitsEditor(dispatch), - onOpenLimitEditor: (limit) => LimitEditorActionHelper.openLimitsEditor(dispatch, {limit}) - }; +const mapActionsToProps = (dispatch, { licenseModelId, version }) => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onCancel: () => + EntitlementPoolsActionHelper.closeEntitlementPoolsEditor(dispatch), + onSubmit: ({ previousEntitlementPool, entitlementPool, keepOpen }) => { + if (!keepOpen) { + EntitlementPoolsActionHelper.closeEntitlementPoolsEditor( + dispatch + ); + } + EntitlementPoolsActionHelper.saveEntitlementPool(dispatch, { + licenseModelId, + previousEntitlementPool, + entitlementPool, + version + }); + }, + onValidateForm: formName => + ValidationHelper.validateForm(dispatch, formName), + onCloseLimitEditor: () => + LimitEditorActionHelper.closeLimitsEditor(dispatch), + onOpenLimitEditor: limit => + LimitEditorActionHelper.openLimitsEditor(dispatch, { limit }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(EntitlementPoolsEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + EntitlementPoolsEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js index be100f6802..4556b87129 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js @@ -13,87 +13,101 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, defaultState, SP_ENTITLEMENT_POOL_FORM} from './EntitlementPoolsConstants.js'; +import { + actionTypes, + defaultState, + SP_ENTITLEMENT_POOL_FORM +} from './EntitlementPoolsConstants.js'; import moment from 'moment'; -import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { DATE_FORMAT } from 'sdc-app/onboarding/OnboardingConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.entitlementPoolsEditor.OPEN: - let entitlementPoolData = {...action.entitlementPool}; - let {startDate, expiryDate} = entitlementPoolData; - if (startDate) { - entitlementPoolData.startDate = moment(startDate, DATE_FORMAT).format(DATE_FORMAT); - } - if (expiryDate) { - entitlementPoolData.expiryDate = moment(expiryDate, DATE_FORMAT).format(DATE_FORMAT); - } - return { - ...state, - formReady: null, - formName: SP_ENTITLEMENT_POOL_FORM, - genericFieldInfo: { - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}] - }, - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}] - }, - 'increments' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 120}] - }, - 'operationalScope' : { - isValid: true, - errorText: '', - validations: [] - }, - 'thresholdUnits' : { - isValid: true, - errorText: '', - validations: [] - }, - 'thresholdValue' : { - isValid: true, - errorText: '', - validations: [] - }, - 'startDate': { - isValid: true, - errorText: '', - validations: [] - }, - 'expiryDate': { - isValid: true, - errorText: '', - validations: [] - } - }, - data: action.entitlementPool ? entitlementPoolData : defaultState.ENTITLEMENT_POOLS_EDITOR_DATA - }; - case actionTypes.entitlementPoolsEditor.DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData - } - }; - case actionTypes.entitlementPoolsEditor.CLOSE: - return {}; - - case actionTypes.entitlementPoolsEditor.LIMITS_LIST_LOADED: - return { - ...state, - limitsList: action.response.results - }; - default: - return state; - } + switch (action.type) { + case actionTypes.entitlementPoolsEditor.OPEN: + let entitlementPoolData = { ...action.entitlementPool }; + let { startDate, expiryDate } = entitlementPoolData; + if (startDate) { + entitlementPoolData.startDate = moment( + startDate, + DATE_FORMAT + ).format(DATE_FORMAT); + } + if (expiryDate) { + entitlementPoolData.expiryDate = moment( + expiryDate, + DATE_FORMAT + ).format(DATE_FORMAT); + } + return { + ...state, + formReady: null, + formName: SP_ENTITLEMENT_POOL_FORM, + genericFieldInfo: { + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 120 } + ] + }, + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }] + }, + increments: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 120 }] + }, + operationalScope: { + isValid: true, + errorText: '', + validations: [] + }, + thresholdUnits: { + isValid: true, + errorText: '', + validations: [] + }, + thresholdValue: { + isValid: true, + errorText: '', + validations: [] + }, + startDate: { + isValid: true, + errorText: '', + validations: [] + }, + expiryDate: { + isValid: true, + errorText: '', + validations: [] + } + }, + data: action.entitlementPool + ? entitlementPoolData + : defaultState.ENTITLEMENT_POOLS_EDITOR_DATA + }; + case actionTypes.entitlementPoolsEditor.DATA_CHANGED: + return { + ...state, + data: { + ...state.data, + ...action.deltaData + } + }; + case actionTypes.entitlementPoolsEditor.CLOSE: + return {}; + case actionTypes.entitlementPoolsEditor.LIMITS_LIST_LOADED: + return { + ...state, + limitsList: action.response.results + }; + default: + return state; + } }; 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 efae7f3ad2..46eda622b5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx @@ -25,307 +25,479 @@ import Form from 'nfvo-components/input/validation/Form.jsx'; import Button from 'sdc-ui/lib/react/Button.js'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {optionsInputValues as EntitlementPoolsOptionsInputValues, SP_ENTITLEMENT_POOL_FORM, tabIds} from './EntitlementPoolsConstants.js'; -import {optionsInputValues as LicenseModelOptionsInputValues} from '../LicenseModelConstants.js'; -import {validateStartDate, thresholdValueValidation} from '../LicenseModelValidations.js'; -import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js'; -import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { + optionsInputValues as EntitlementPoolsOptionsInputValues, + SP_ENTITLEMENT_POOL_FORM, + tabIds +} from './EntitlementPoolsConstants.js'; +import { optionsInputValues as LicenseModelOptionsInputValues } from '../LicenseModelConstants.js'; +import { + validateStartDate, + thresholdValueValidation +} from '../LicenseModelValidations.js'; +import { DATE_FORMAT } from 'sdc-app/onboarding/OnboardingConstants.js'; +import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx'; import Tabs from 'sdc-ui/lib/react/Tabs.js'; import Tab from 'sdc-ui/lib/react/Tab.js'; import EntitlementPoolsLimits from './EntitlementPoolsLimits.js'; -import {limitType, NEW_LIMIT_TEMP_ID} from '../limits/LimitEditorConstants.js'; +import { + limitType, + NEW_LIMIT_TEMP_ID +} from '../limits/LimitEditorConstants.js'; const EntitlementPoolPropType = PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - description: PropTypes.string, - operationalScope: PropTypes.shape({ - choices: PropTypes.array, - other: PropTypes.string - }), - thresholdUnits: PropTypes.string, - thresholdValue: PropTypes.string, - increments: PropTypes.string, - startDate: PropTypes.string, - expiryDate: PropTypes.string + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + operationalScope: PropTypes.shape({ + choices: PropTypes.array, + other: PropTypes.string + }), + thresholdUnits: PropTypes.string, + thresholdValue: PropTypes.string, + increments: PropTypes.string, + startDate: PropTypes.string, + expiryDate: PropTypes.string }); -const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, validateName, - thresholdValueValidation, validateStartDate}) => { +const EntitlementPoolsFormContent = ({ + data, + genericFieldInfo, + onDataChanged, + validateName, + thresholdValueValidation, + validateStartDate +}) => { + let { + name, + description, + operationalScope, + thresholdUnits, + thresholdValue, + increments, + startDate, + expiryDate + } = data; + return ( + + + + onDataChanged({ name }, SP_ENTITLEMENT_POOL_FORM, { + name: validateName + }) + } + isValid={genericFieldInfo.name.isValid} + isRequired={true} + errorText={genericFieldInfo.name.errorText} + label={i18n('Name')} + value={name} + data-test-id="create-ep-name" + type="text" + /> + + + {}} + isMultiSelect={true} + onEnumChange={operationalScope => + onDataChanged( + { + operationalScope: { + choices: operationalScope, + other: '' + } + }, + SP_ENTITLEMENT_POOL_FORM + ) + } + onOtherChange={operationalScope => + onDataChanged( + { + operationalScope: { + choices: [optionInputOther.OTHER], + other: operationalScope + } + }, + SP_ENTITLEMENT_POOL_FORM + ) + } + label={i18n('Operational Scope')} + data-test-id="create-ep-operational-scope" + type="select" + multiSelectedEnum={ + operationalScope && operationalScope.choices + } + otherValue={operationalScope && operationalScope.other} + values={ + EntitlementPoolsOptionsInputValues.OPERATIONAL_SCOPE + } + isValid={genericFieldInfo.operationalScope.isValid} + errorText={genericFieldInfo.operationalScope.errorText} + /> + + + + onDataChanged({ description }, SP_ENTITLEMENT_POOL_FORM) + } + isValid={genericFieldInfo.description.isValid} + errorText={genericFieldInfo.description.errorText} + label={i18n('Description')} + value={description} + data-test-id="create-ep-description" + type="textarea" + /> + + +
    + { + // setting the unit to the correct value + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onDataChanged( + { thresholdUnits: val }, + SP_ENTITLEMENT_POOL_FORM + ); + // TODO make sure that the value is valid too + if (thresholdValue && thresholdValue !== '') { + onDataChanged( + { thresholdValue: thresholdValue }, + SP_ENTITLEMENT_POOL_FORM, + { thresholdValue: thresholdValueValidation } + ); + } + }} + value={thresholdUnits} + label={i18n('Threshold Units')} + data-test-id="create-ep-threshold-units" + isValid={genericFieldInfo.thresholdUnits.isValid} + errorText={genericFieldInfo.thresholdUnits.errorText} + groupClassName="bootstrap-input-options" + className="input-options-select" + type="select"> + {LicenseModelOptionsInputValues.THRESHOLD_UNITS.map( + mtype => ( + + ) + )} + - let {name, description, operationalScope, thresholdUnits, thresholdValue, - increments, startDate, expiryDate} = data; - return ( - - - onDataChanged({name}, SP_ENTITLEMENT_POOL_FORM, {name: validateName})} - isValid={genericFieldInfo.name.isValid} - isRequired={true} - errorText={genericFieldInfo.name.errorText} - label={i18n('Name')} - value={name} - data-test-id='create-ep-name' - type='text'/> - - - {}} - isMultiSelect={true} - onEnumChange={operationalScope => onDataChanged({operationalScope:{choices: operationalScope, other: ''}}, - SP_ENTITLEMENT_POOL_FORM)} - onOtherChange={operationalScope => onDataChanged({operationalScope:{choices: [optionInputOther.OTHER], - other: operationalScope}}, SP_ENTITLEMENT_POOL_FORM)} - label={i18n('Operational Scope')} - data-test-id='create-ep-operational-scope' - type='select' - multiSelectedEnum={operationalScope && operationalScope.choices} - otherValue={operationalScope && operationalScope.other} - values={EntitlementPoolsOptionsInputValues.OPERATIONAL_SCOPE} - isValid={genericFieldInfo.operationalScope.isValid} - errorText={genericFieldInfo.operationalScope.errorText} /> - - - onDataChanged({description}, SP_ENTITLEMENT_POOL_FORM)} - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} - label={i18n('Description')} - value={description} - data-test-id='create-ep-description' - type='textarea'/> - - -
    - { - // setting the unit to the correct value - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onDataChanged({thresholdUnits: val}, SP_ENTITLEMENT_POOL_FORM); - // TODO make sure that the value is valid too - if(thresholdValue && thresholdValue !== '') { - onDataChanged({thresholdValue: thresholdValue}, SP_ENTITLEMENT_POOL_FORM,{thresholdValue : thresholdValueValidation}); - }} - - } - value={thresholdUnits} - label={i18n('Threshold Units')} - data-test-id='create-ep-threshold-units' - isValid={genericFieldInfo.thresholdUnits.isValid} - errorText={genericFieldInfo.thresholdUnits.errorText} - groupClassName='bootstrap-input-options' - className='input-options-select' - type='select' > - {LicenseModelOptionsInputValues.THRESHOLD_UNITS.map(mtype => - )} - - - onDataChanged({thresholdValue}, SP_ENTITLEMENT_POOL_FORM, - {thresholdValue : thresholdValueValidation})} - label={i18n('Threshold Value')} - isValid={genericFieldInfo.thresholdValue.isValid} - errorText={genericFieldInfo.thresholdValue.errorText} - data-test-id='create-ep-threshold-value' - value={thresholdValue} - type='text'/> -
    - onDataChanged({increments}, SP_ENTITLEMENT_POOL_FORM)} - label={i18n('Increments')} - value={increments} - data-test-id='create-ep-increments' - type='text'/> -
    - onDataChanged( - {startDate: startDate ? startDate.format(DATE_FORMAT) : ''}, - SP_ENTITLEMENT_POOL_FORM, - {startDate: validateStartDate} - )} - isValid={genericFieldInfo.startDate.isValid} - errorText={genericFieldInfo.startDate.errorText} - selectsStart/> - { - onDataChanged({expiryDate: expiryDate ? expiryDate.format(DATE_FORMAT) : ''}, SP_ENTITLEMENT_POOL_FORM); - onDataChanged({startDate}, SP_ENTITLEMENT_POOL_FORM, {startDate: validateStartDate}); - }} - isValid={genericFieldInfo.expiryDate.isValid} - errorText={genericFieldInfo.expiryDate.errorText} - selectsEnd/> -
    -
    -
    - ); + + onDataChanged( + { thresholdValue }, + SP_ENTITLEMENT_POOL_FORM, + { + thresholdValue: thresholdValueValidation + } + ) + } + label={i18n('Threshold Value')} + isValid={genericFieldInfo.thresholdValue.isValid} + errorText={genericFieldInfo.thresholdValue.errorText} + data-test-id="create-ep-threshold-value" + value={thresholdValue} + type="text" + /> +
    + + onDataChanged({ increments }, SP_ENTITLEMENT_POOL_FORM) + } + label={i18n('Increments')} + value={increments} + data-test-id="create-ep-increments" + type="text" + /> +
    + + onDataChanged( + { + startDate: startDate + ? startDate.format(DATE_FORMAT) + : '' + }, + SP_ENTITLEMENT_POOL_FORM, + { startDate: validateStartDate } + ) + } + isValid={genericFieldInfo.startDate.isValid} + errorText={genericFieldInfo.startDate.errorText} + selectsStart + /> + { + onDataChanged( + { + expiryDate: expiryDate + ? expiryDate.format(DATE_FORMAT) + : '' + }, + SP_ENTITLEMENT_POOL_FORM + ); + onDataChanged( + { startDate }, + SP_ENTITLEMENT_POOL_FORM, + { + startDate: validateStartDate + } + ); + }} + isValid={genericFieldInfo.expiryDate.isValid} + errorText={genericFieldInfo.expiryDate.errorText} + selectsEnd + /> +
    +
    +
    + ); }; class EntitlementPoolsEditorView extends React.Component { + static propTypes = { + data: EntitlementPoolPropType, + previousData: EntitlementPoolPropType, + EPNames: PropTypes.object, + isReadOnlyMode: PropTypes.bool, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired + }; - static propTypes = { - data: EntitlementPoolPropType, - previousData: EntitlementPoolPropType, - EPNames: PropTypes.object, - isReadOnlyMode: PropTypes.bool, - onDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired - }; - - static defaultProps = { - data: {} - }; - - componentDidUpdate(prevProps) { - if (this.props.formReady && this.props.formReady !== prevProps.formReady) { // if form validation succeeded -> continue with submit - this.submit(); - } - } + static defaultProps = { + data: {} + }; - state = { - selectedTab: tabIds.GENERAL, - selectedLimit: '' - }; + componentDidUpdate(prevProps) { + if ( + this.props.formReady && + this.props.formReady !== prevProps.formReady + ) { + // if form validation succeeded -> continue with submit + this.submit(); + } + } - render() { - let {data = {}, onDataChanged, isReadOnlyMode, genericFieldInfo, onCloseLimitEditor, limitsList = []} = this.props; - const {selectedTab} = this.state; - const isTabsDisabled = !data.id || !this.props.isFormValid; + state = { + selectedTab: tabIds.GENERAL, + selectedLimit: '' + }; - return ( -
    - { - if (tabIndex === tabIds.ADD_LIMIT_BUTTON) { - this.onAddLimit(); - } else { - this.setState({selectedTab: tabIndex}); - this.setState({selectedLimit: ''}); - onCloseLimitEditor(); - } - }} - invalidTabs={[]}> - - { - genericFieldInfo &&
    this.props.onValidateForm(SP_ENTITLEMENT_POOL_FORM) } - className='license-model-form entitlement-pools-form'> - this.validateName(value)} - validateStartDate={(value, state) => validateStartDate(value, state)} - thresholdValueValidation={(value, state) => thresholdValueValidation(value, state)}/> - - } -
    - - {selectedTab === tabIds.SP_LIMITS && - item.type === limitType.SERVICE_PROVIDER)} - selectedLimit={this.state.selectedLimit} - onCloseLimitEditor={() => this.onCloseLimitEditor()} - onSelectLimit={limit => this.onSelectLimit(limit)}/>} - - - {selectedTab === tabIds.VENDOR_LIMITS && - item.type === limitType.VENDOR)} - selectedLimit={this.state.selectedLimit} - onCloseLimitEditor={() => this.onCloseLimitEditor()} - onSelectLimit={limit => this.onSelectLimit(limit)}/>} - - { - selectedTab !== tabIds.GENERAL ? - - : -
    // Render empty div to not break tabs - } -
    - - {!this.state.selectedLimit && - - } - - -
    - ); - } + render() { + let { + data = {}, + onDataChanged, + isReadOnlyMode, + genericFieldInfo, + onCloseLimitEditor, + limitsList = [] + } = this.props; + const { selectedTab } = this.state; + const isTabsDisabled = !data.id || !this.props.isFormValid; - submit() { - const {data: entitlementPool, previousData: previousEntitlementPool, formReady} = this.props; - if (!formReady) { - this.props.onValidateForm(SP_ENTITLEMENT_POOL_FORM); - } else { - this.props.onSubmit({entitlementPool, previousEntitlementPool}); - } - } + return ( +
    + { + if (tabIndex === tabIds.ADD_LIMIT_BUTTON) { + this.onAddLimit(); + } else { + this.setState({ selectedTab: tabIndex }); + this.setState({ selectedLimit: '' }); + onCloseLimitEditor(); + } + }} + invalidTabs={[]}> + + {genericFieldInfo && ( +
    + this.props.onValidateForm( + SP_ENTITLEMENT_POOL_FORM + ) + } + className="license-model-form entitlement-pools-form"> + + this.validateName(value) + } + validateStartDate={(value, state) => + validateStartDate(value, state) + } + thresholdValueValidation={(value, state) => + thresholdValueValidation(value, state) + } + /> + + )} +
    + + {selectedTab === tabIds.SP_LIMITS && ( + + item.type === limitType.SERVICE_PROVIDER + )} + selectedLimit={this.state.selectedLimit} + onCloseLimitEditor={() => + this.onCloseLimitEditor() + } + onSelectLimit={limit => + this.onSelectLimit(limit) + } + /> + )} + + + {selectedTab === tabIds.VENDOR_LIMITS && ( + item.type === limitType.VENDOR + )} + selectedLimit={this.state.selectedLimit} + onCloseLimitEditor={() => + this.onCloseLimitEditor() + } + onSelectLimit={limit => + this.onSelectLimit(limit) + } + /> + )} + + {selectedTab !== tabIds.GENERAL ? ( + + ) : ( +
    + ) // Render empty div to not break tabs + } + + + {!this.state.selectedLimit && ( + + )} + + +
    + ); + } - validateName(value) { - const {data: {id}, EPNames} = this.props; - const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: EPNames}); + submit() { + const { + data: entitlementPool, + previousData: previousEntitlementPool, + formReady + } = this.props; + if (!formReady) { + this.props.onValidateForm(SP_ENTITLEMENT_POOL_FORM); + } else { + this.props.onSubmit({ entitlementPool, previousEntitlementPool }); + } + } - return !isExists ? {isValid: true, errorText: ''} : - {isValid: false, errorText: i18n('Entitlement pool by the name \'' + value + '\' already exists. Entitlement pool name must be unique')}; - } + validateName(value) { + const { data: { id }, EPNames } = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({ + itemId: id, + itemName: value, + list: EPNames + }); - onSelectLimit(limit) { - if (limit.id === this.state.selectedLimit) { - this.setState({selectedLimit: ''}); - return; - } - this.setState({selectedLimit: limit.id}); - this.props.onOpenLimitEditor(limit); - } + return !isExists + ? { isValid: true, errorText: '' } + : { + isValid: false, + errorText: i18n( + "Entitlement pool by the name '" + + value + + "' already exists. Entitlement pool name must be unique" + ) + }; + } - onCloseLimitEditor() { - this.setState({selectedLimit: ''}); - this.props.onCloseLimitEditor(); - } + onSelectLimit(limit) { + if (limit.id === this.state.selectedLimit) { + this.setState({ selectedLimit: '' }); + return; + } + this.setState({ selectedLimit: limit.id }); + this.props.onOpenLimitEditor(limit); + } - onAddLimit() { - this.setState({selectedLimit: NEW_LIMIT_TEMP_ID}); - this.props.onOpenLimitEditor(); - } + onCloseLimitEditor() { + this.setState({ selectedLimit: '' }); + this.props.onCloseLimitEditor(); + } + onAddLimit() { + this.setState({ selectedLimit: NEW_LIMIT_TEMP_ID }); + 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 8300594098..fd5fe6dd21 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsLimits.js @@ -13,44 +13,74 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import Limits from 'sdc-app/onboarding/licenseModel/limits/Limits.jsx'; -import {actionTypes as globalModalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as globalModalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; -const mapStateToProps = ({licenseModel: {entitlementPool: {entitlementPoolEditor: {data}}, limitEditor}, currentScreen}) => { - let {props: {licenseModelId, version}} = currentScreen; - return { - parent: data, - limitEditor, - licenseModelId, - version - }; +const mapStateToProps = ({ + licenseModel: { + entitlementPool: { entitlementPoolEditor: { data } }, + limitEditor + }, + currentScreen +}) => { + let { props: { licenseModelId, version } } = currentScreen; + return { + parent: data, + limitEditor, + licenseModelId, + version + }; }; -const mapActionsToProps = (dispatch) => { - return { - onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), - onSubmit: (limit, entitlementPool, licenseModelId, version) => EntitlementPoolsActionHelper.submitLimit(dispatch, - { - limit, - entitlementPool, - licenseModelId, - version}), - onDelete: ({limit, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit}) => dispatch({ - type: globalModalActionTypes.GLOBAL_MODAL_WARNING, - data:{ - 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(() => - selectedLimit === limit.id && onCloseLimitEditor() - ) - } - }) - }; +const mapActionsToProps = dispatch => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onSubmit: (limit, entitlementPool, licenseModelId, version) => + EntitlementPoolsActionHelper.submitLimit(dispatch, { + limit, + entitlementPool, + licenseModelId, + version + }), + onDelete: ({ + limit, + parent, + licenseModelId, + version, + onCloseLimitEditor, + selectedLimit + }) => + dispatch({ + type: globalModalActionTypes.GLOBAL_MODAL_WARNING, + data: { + 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( + () => + selectedLimit === limit.id && + onCloseLimitEditor() + ) + } + }) + }; }; 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 f1dc1f8542..819fb7d824 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js @@ -13,45 +13,60 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; -import EntitlementPoolsListEditorView, {generateConfirmationMsg} from './EntitlementPoolsListEditorView.jsx'; -import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; +import EntitlementPoolsListEditorView, { + generateConfirmationMsg +} from './EntitlementPoolsListEditorView.jsx'; +import { actionTypes as globalMoadlActions } from 'nfvo-components/modal/GlobalModalConstants.js'; -const mapStateToProps = ({licenseModel: {entitlementPool, licenseModelEditor}}) => { - - const {entitlementPoolsList} = entitlementPool; - const {data} = entitlementPool.entitlementPoolEditor; - const {vendorName} = licenseModelEditor.data; - - return { - vendorName, - entitlementPoolsList, - isDisplayModal: Boolean(data), - isModalInEditMode: Boolean(data && data.id), - }; +const mapStateToProps = ({ + licenseModel: { entitlementPool, licenseModelEditor } +}) => { + const { entitlementPoolsList } = entitlementPool; + const { data } = entitlementPool.entitlementPoolEditor; + const { vendorName } = licenseModelEditor.data; + return { + vendorName, + entitlementPoolsList, + isDisplayModal: Boolean(data), + isModalInEditMode: Boolean(data && data.id) + }; }; -const mapActionsToProps = (dispatch, {licenseModelId, version}) => { - return { - onAddEntitlementPoolClick: () => EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch), - onEditEntitlementPoolClick: entitlementPool => EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch, {entitlementPool, licenseModelId, version}), - onDeleteEntitlementPool: entitlementPool => dispatch({ - type: globalMoadlActions.GLOBAL_MODAL_WARNING, - data:{ - msg: generateConfirmationMsg(entitlementPool), - confirmationButtonText: i18n('Delete'), - title: i18n('Delete'), - onConfirmed: () => EntitlementPoolsActionHelper.deleteEntitlementPool(dispatch, { - licenseModelId, - entitlementPoolId: entitlementPool.id, - version - }) - } - }) - }; +const mapActionsToProps = (dispatch, { licenseModelId, version }) => { + return { + onAddEntitlementPoolClick: () => + EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch), + onEditEntitlementPoolClick: entitlementPool => + EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch, { + entitlementPool, + licenseModelId, + version + }), + onDeleteEntitlementPool: entitlementPool => + dispatch({ + type: globalMoadlActions.GLOBAL_MODAL_WARNING, + data: { + msg: generateConfirmationMsg(entitlementPool), + confirmationButtonText: i18n('Delete'), + title: i18n('Delete'), + onConfirmed: () => + EntitlementPoolsActionHelper.deleteEntitlementPool( + dispatch, + { + licenseModelId, + entitlementPoolId: entitlementPool.id, + version + } + ) + } + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(EntitlementPoolsListEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + EntitlementPoolsListEditorView +); 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 cc0cda1992..7a07f94bd5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx @@ -22,120 +22,162 @@ import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import EntitlementPoolsEditor from './EntitlementPoolsEditor.js'; -import {extractUnits} from './EntitlementPoolsConstants'; +import { extractUnits } from './EntitlementPoolsConstants'; class EntitlementPoolsListEditorView extends React.Component { - static propTypes = { - 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 propTypes = { + 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 = { - entitlementPoolsList: [] - }; + static defaultProps = { + entitlementPoolsList: [] + }; - state = { - localFilter: '' - }; + state = { + localFilter: '' + }; - render() { - let {licenseModelId, isReadOnlyMode, isDisplayModal, isModalInEditMode, version} = this.props; - let {onAddEntitlementPoolClick} = this.props; - const {localFilter} = this.state; + render() { + let { + licenseModelId, + isReadOnlyMode, + isDisplayModal, + isModalInEditMode, + version + } = this.props; + let { onAddEntitlementPoolClick } = this.props; + const { localFilter } = this.state; - return ( -
    - this.setState({localFilter: value})} - isReadOnlyMode={isReadOnlyMode}> - {this.filterList().map(entitlementPool => this.renderEntitlementPoolListItem(entitlementPool, isReadOnlyMode))} - - - - {`${isModalInEditMode ? i18n('Edit Entitlement Pool') : i18n('Create New Entitlement Pool')}`} - - - { - isDisplayModal && ( - - ) - } - - -
    - ); - } + return ( +
    + this.setState({ localFilter: value })} + isReadOnlyMode={isReadOnlyMode}> + {this.filterList().map(entitlementPool => + this.renderEntitlementPoolListItem( + entitlementPool, + isReadOnlyMode + ) + )} + + + + {`${ + isModalInEditMode + ? i18n('Edit Entitlement Pool') + : i18n('Create New Entitlement Pool') + }`} + + + {isDisplayModal && ( + + )} + + +
    + ); + } - filterList() { - let {entitlementPoolsList} = this.props; - let {localFilter} = this.state; - if(localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return entitlementPoolsList.filter(({name = '', description = ''}) => { - return escape(name).match(filter) || escape(description).match(filter); - }); - } - else { - return entitlementPoolsList; - } - } + filterList() { + let { entitlementPoolsList } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return entitlementPoolsList.filter( + ({ name = '', description = '' }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) + ); + } + ); + } else { + return entitlementPoolsList; + } + } - renderEntitlementPoolListItem(entitlementPool, isReadOnlyMode) { - let {id, name, description, thresholdValue, thresholdUnits} = entitlementPool; - let {onEditEntitlementPoolClick, onDeleteEntitlementPool} = this.props; - return ( - onEditEntitlementPoolClick(entitlementPool)} - onDelete={() => onDeleteEntitlementPool(entitlementPool)} - className='list-editor-item-view' - isReadOnlyMode={isReadOnlyMode}> -
    + renderEntitlementPoolListItem(entitlementPool, isReadOnlyMode) { + let { + id, + name, + description, + thresholdValue, + thresholdUnits + } = entitlementPool; + let { + onEditEntitlementPoolClick, + onDeleteEntitlementPool + } = this.props; + return ( + onEditEntitlementPoolClick(entitlementPool)} + onDelete={() => onDeleteEntitlementPool(entitlementPool)} + className="list-editor-item-view" + isReadOnlyMode={isReadOnlyMode}> +
    +
    {i18n('Name')}
    +
    +
    {name}
    +
    +
    -
    {i18n('Name')}
    -
    {name}
    -
    - -
    -
    {i18n('Entitlement')}
    -
    {thresholdValue && `${thresholdValue} ${extractUnits(thresholdUnits)}`}
    -
    - -
    -
    {i18n('Description')}
    -
    {description}
    -
    -
    - ); - } +
    +
    {i18n('Entitlement')}
    +
    + {thresholdValue && + `${thresholdValue} ${extractUnits(thresholdUnits)}`} +
    +
    +
    +
    {i18n('Description')}
    +
    {description}
    +
    + + ); + } } export default EntitlementPoolsListEditorView; export function generateConfirmationMsg(entitlementPoolToDelete) { - let poolName = entitlementPoolToDelete ? entitlementPoolToDelete.name : ''; - let msg = i18n('Are you sure you want to delete "{poolName}"?', {poolName: poolName}); - let subMsg = entitlementPoolToDelete - && entitlementPoolToDelete.referencingFeatureGroups - && entitlementPoolToDelete.referencingFeatureGroups.length > 0 ? - i18n('This entitlement pool is associated with one or more feature groups') : - ''; - return ( -
    -

    {msg}

    -

    {subMsg}

    -
    - ); + let poolName = entitlementPoolToDelete ? entitlementPoolToDelete.name : ''; + let msg = i18n('Are you sure you want to delete "{poolName}"?', { + poolName: poolName + }); + let subMsg = + entitlementPoolToDelete && + entitlementPoolToDelete.referencingFeatureGroups && + entitlementPoolToDelete.referencingFeatureGroups.length > 0 + ? i18n( + 'This entitlement pool is associated with one or more feature groups' + ) + : ''; + return ( +
    +

    {msg}

    +

    {subMsg}

    +
    + ); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListReducer.js index fefd823207..3c8621d9d8 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListReducer.js @@ -13,19 +13,29 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './EntitlementPoolsConstants'; +import { actionTypes } from './EntitlementPoolsConstants'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.ENTITLEMENT_POOLS_LIST_LOADED: - return [...action.response.results]; - case actionTypes.ADD_ENTITLEMENT_POOL: - return [...state, action.entitlementPool]; - case actionTypes.EDIT_ENTITLEMENT_POOL: - const indexForEdit = state.findIndex(entitlementPool => entitlementPool.id === action.entitlementPool.id); - return [...state.slice(0, indexForEdit), action.entitlementPool, ...state.slice(indexForEdit + 1)]; - case actionTypes.DELETE_ENTITLEMENT_POOL: - return state.filter(entitlementPool => entitlementPool.id !== action.entitlementPoolId); - default: - return state; - } + switch (action.type) { + case actionTypes.ENTITLEMENT_POOLS_LIST_LOADED: + return [...action.response.results]; + case actionTypes.ADD_ENTITLEMENT_POOL: + return [...state, action.entitlementPool]; + case actionTypes.EDIT_ENTITLEMENT_POOL: + const indexForEdit = state.findIndex( + entitlementPool => + entitlementPool.id === action.entitlementPool.id + ); + return [ + ...state.slice(0, indexForEdit), + action.entitlementPool, + ...state.slice(indexForEdit + 1) + ]; + case actionTypes.DELETE_ENTITLEMENT_POOL: + return state.filter( + entitlementPool => + entitlementPool.id !== action.entitlementPoolId + ); + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js index 6edb1e1f0c..997a6e09ed 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js @@ -13,66 +13,92 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; import FeatureGroupEditorView from './FeatureGroupEditorView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -export const mapStateToProps = ({licenseModel: {featureGroup, entitlementPool, licenseKeyGroup}}) => { - let {entitlementPoolsList = []} = entitlementPool; - let {licenseKeyGroupsList = []} = licenseKeyGroup; - const {featureGroupEditor} = featureGroup; - let {data, selectedTab, genericFieldInfo, formReady} = featureGroupEditor; - const featureGroupId = data ? data.id : null; - const list = featureGroup.featureGroupsList; +export const mapStateToProps = ({ + licenseModel: { featureGroup, entitlementPool, licenseKeyGroup } +}) => { + let { entitlementPoolsList = [] } = entitlementPool; + let { licenseKeyGroupsList = [] } = licenseKeyGroup; + const { featureGroupEditor } = featureGroup; + let { data, selectedTab, genericFieldInfo, formReady } = featureGroupEditor; + const featureGroupId = data ? data.id : null; + const list = featureGroup.featureGroupsList; - let previousData, FGNames = {}, isFormValid = true, invalidTabs = []; + let previousData, + FGNames = {}, + isFormValid = true, + invalidTabs = []; - if (featureGroupId) { - previousData = list.find(featureGroup => featureGroup.id === featureGroupId); - } + if (featureGroupId) { + previousData = list.find( + featureGroup => featureGroup.id === featureGroupId + ); + } - for (let i = 0; i < list.length; i++) { - FGNames[list[i].name.toLowerCase()] = list[i].id; - } + for (let i = 0; i < list.length; i++) { + FGNames[list[i].name.toLowerCase()] = list[i].id; + } - for (let field in genericFieldInfo) { - if (!genericFieldInfo[field].isValid) { - isFormValid = false; - let tabId = genericFieldInfo[field].tabId; - if (invalidTabs.indexOf(tabId) === -1) { - invalidTabs[invalidTabs.length] = genericFieldInfo[field].tabId; - } - } - } + for (let field in genericFieldInfo) { + if (!genericFieldInfo[field].isValid) { + isFormValid = false; + let tabId = genericFieldInfo[field].tabId; + if (invalidTabs.indexOf(tabId) === -1) { + invalidTabs[invalidTabs.length] = genericFieldInfo[field].tabId; + } + } + } - return { - data, - previousData, - selectedTab, - entitlementPoolsList, - licenseKeyGroupsList, - isFormValid, - formReady, - genericFieldInfo, - invalidTabs, - FGNames - }; + return { + data, + previousData, + selectedTab, + entitlementPoolsList, + licenseKeyGroupsList, + isFormValid, + formReady, + genericFieldInfo, + invalidTabs, + FGNames + }; }; - -const mapActionsToProps = (dispatch, {licenseModelId, version}) => { - return { - onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), - onTabSelect: tab => FeatureGroupsActionHelper.selectEntitlementPoolsEditorTab(dispatch, {tab}), - onSubmit: (previousFeatureGroup, featureGroup) => { - FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch); - FeatureGroupsActionHelper.saveFeatureGroup(dispatch, {licenseModelId, previousFeatureGroup, featureGroup, version}); - }, - onCancel: () => FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch), - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) - }; +const mapActionsToProps = (dispatch, { licenseModelId, version }) => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onTabSelect: tab => + FeatureGroupsActionHelper.selectEntitlementPoolsEditorTab( + dispatch, + { + tab + } + ), + onSubmit: (previousFeatureGroup, featureGroup) => { + FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch); + FeatureGroupsActionHelper.saveFeatureGroup(dispatch, { + licenseModelId, + previousFeatureGroup, + featureGroup, + version + }); + }, + onCancel: () => + FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch), + onValidateForm: formName => + ValidationHelper.validateForm(dispatch, formName) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(FeatureGroupEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + FeatureGroupEditorView +); 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 6d0acaa65d..fc8269332a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx @@ -19,211 +19,320 @@ 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'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {TabsForm as Form} from 'nfvo-components/input/validation/Form.jsx'; +import { TabsForm as Form } from 'nfvo-components/input/validation/Form.jsx'; import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx'; import Input from 'nfvo-components/input/validation/Input.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Validator from 'nfvo-utils/Validator.js'; -import {state as FeatureGroupStateConstants, FG_EDITOR_FORM} from './FeatureGroupsConstants.js'; +import { + state as FeatureGroupStateConstants, + FG_EDITOR_FORM +} from './FeatureGroupsConstants.js'; 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) + 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 ( - - - onDataChanged({name}, FG_EDITOR_FORM, {name: validateName})} - label={i18n('Name')} - data-test-id='create-fg-name' - value={name} - name='feature-group-name' - type='text' - isRequired={true} - isValid={genericFieldInfo.name.isValid} - errorText={genericFieldInfo.name.errorText} /> - - - onDataChanged({description}, FG_EDITOR_FORM)} - data-test-id='create-fg-description' - label={i18n('Description')} - value={description} - name='feature-group-description' - type='textarea' - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} /> - - - onDataChanged({partNumber}, FG_EDITOR_FORM)} - label={i18n('Part Number')} - data-test-id='create-fg-part-number' - value={partNumber} - isRequired={true} - type='text' - isValid={genericFieldInfo.partNumber.isValid} - errorText={genericFieldInfo.partNumber.errorText} /> - - - onDataChanged({manufacturerReferenceNumber}, FG_EDITOR_FORM)} - label={i18n('Manufacturer Reference Number')} - data-test-id='create-fg-reference-number' - value={manufacturerReferenceNumber} - isRequired={true} - type='text' - isValid={genericFieldInfo.manufacturerReferenceNumber.isValid} - errorText={genericFieldInfo.manufacturerReferenceNumber.errorText} /> - - - ); +const GeneralTab = ({ + data = {}, + onDataChanged, + genericFieldInfo, + validateName +}) => { + let { name, description, partNumber, manufacturerReferenceNumber } = data; + return ( + + + + onDataChanged({ name }, FG_EDITOR_FORM, { + name: validateName + }) + } + label={i18n('Name')} + data-test-id="create-fg-name" + value={name} + name="feature-group-name" + type="text" + isRequired={true} + isValid={genericFieldInfo.name.isValid} + errorText={genericFieldInfo.name.errorText} + /> + + + + onDataChanged({ description }, FG_EDITOR_FORM) + } + data-test-id="create-fg-description" + label={i18n('Description')} + value={description} + name="feature-group-description" + type="textarea" + isValid={genericFieldInfo.description.isValid} + errorText={genericFieldInfo.description.errorText} + /> + + + + onDataChanged({ partNumber }, FG_EDITOR_FORM) + } + label={i18n('Part Number')} + data-test-id="create-fg-part-number" + value={partNumber} + isRequired={true} + type="text" + isValid={genericFieldInfo.partNumber.isValid} + errorText={genericFieldInfo.partNumber.errorText} + /> + + + + onDataChanged( + { manufacturerReferenceNumber }, + FG_EDITOR_FORM + ) + } + label={i18n('Manufacturer Reference Number')} + data-test-id="create-fg-reference-number" + value={manufacturerReferenceNumber} + isRequired={true} + type="text" + isValid={ + genericFieldInfo.manufacturerReferenceNumber.isValid + } + errorText={ + genericFieldInfo.manufacturerReferenceNumber.errorText + } + /> + + + ); }; -const EntitlementPoolsTab = ({entitlementPoolsList, data, onDataChanged, isReadOnlyMode}) => { - const dualBoxFilterTitle = { - left: i18n('Available Entitlement Pools'), - right: i18n('Selected Entitlement Pools') - }; - if (entitlementPoolsList.length > 0) { - return ( - onDataChanged( { entitlementPoolsIds: selectedValuesList }, FG_EDITOR_FORM )}/> - ); - } else { - return ( -

    {i18n('There are no available entitlement pools')}

    - ); - } +const EntitlementPoolsTab = ({ + entitlementPoolsList, + data, + onDataChanged, + isReadOnlyMode +}) => { + const dualBoxFilterTitle = { + left: i18n('Available Entitlement Pools'), + right: i18n('Selected Entitlement Pools') + }; + if (entitlementPoolsList.length > 0) { + return ( + + onDataChanged( + { entitlementPoolsIds: selectedValuesList }, + FG_EDITOR_FORM + ) + } + /> + ); + } else { + return

    {i18n('There are no available entitlement pools')}

    ; + } }; -const LKGTab = ({licenseKeyGroupsList, data, onDataChanged, isReadOnlyMode}) => { - const dualBoxFilterTitle = { - left: i18n('Available License Key Groups'), - right: i18n('Selected License Key Groups') - }; - if (licenseKeyGroupsList.length > 0) { - return ( - onDataChanged( { licenseKeyGroupsIds: selectedValuesList }, FG_EDITOR_FORM )}/> - ); - } else { - return ( -

    {i18n('There are no available license key groups')}

    - ); - } +const LKGTab = ({ + licenseKeyGroupsList, + data, + onDataChanged, + isReadOnlyMode +}) => { + const dualBoxFilterTitle = { + left: i18n('Available License Key Groups'), + right: i18n('Selected License Key Groups') + }; + if (licenseKeyGroupsList.length > 0) { + return ( + + onDataChanged( + { licenseKeyGroupsIds: selectedValuesList }, + FG_EDITOR_FORM + ) + } + /> + ); + } else { + return

    {i18n('There are no available license key groups')}

    ; + } }; class FeatureGroupEditorView extends React.Component { + static propTypes = { + data: FeatureGroupsPropType, + previousData: FeatureGroupsPropType, + isReadOnlyMode: PropTypes.bool, + FGNames: PropTypes.object, + onSubmit: PropTypes.func, + onCancel: PropTypes.func, - static propTypes = { - data: FeatureGroupsPropType, - previousData: FeatureGroupsPropType, - isReadOnlyMode: PropTypes.bool, - FGNames: PropTypes.object, - - onSubmit: PropTypes.func, - onCancel: PropTypes.func, - - selectedTab: PropTypes.number, - onTabSelect: PropTypes.func, - - entitlementPoolsList: DualListboxView.propTypes.availableList, - licenseKeyGroupsList: DualListboxView.propTypes.availableList - }; - - - static defaultProps = { - data: {}, - selectedTab: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL, - }; - - state = { - localEntitlementPoolsListFilter: '', - localLicenseKeyGroupsListFilter: '' - }; - - - render() { - let {selectedTab, onTabSelect, isReadOnlyMode, invalidTabs, data, onDataChanged, genericFieldInfo, entitlementPoolsList, licenseKeyGroupsList} = this.props; - return ( -
    - { genericFieldInfo &&
    this.submit() } - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.props.onValidateForm(FG_EDITOR_FORM) } - onReset={ () => this.props.onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - name='feature-group-validation-form' - className='license-model-form feature-group-form'> - - -
    - this.validateName(value)}/> -
    -
    - -
    - -
    -
    - -
    - -
    -
    -
    - -
    } -
    - ); - } - - submit() { - const {data: featureGroup, previousData: previousFeatureGroup} = this.props; - this.props.onSubmit(previousFeatureGroup, featureGroup); - } - - validateName(value) { - const {data: {id}, FGNames} = this.props; - const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: FGNames}); - - return !isExists ? {isValid: true, errorText: ''} : - {isValid: false, errorText: i18n('Feature group by the name \'' + value + '\' already exists. Feature group name must be unique')}; - } -} + selectedTab: PropTypes.number, + onTabSelect: PropTypes.func, + + entitlementPoolsList: DualListboxView.propTypes.availableList, + licenseKeyGroupsList: DualListboxView.propTypes.availableList + }; + + static defaultProps = { + data: {}, + selectedTab: + FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL + }; + + state = { + localEntitlementPoolsListFilter: '', + localLicenseKeyGroupsListFilter: '' + }; + render() { + let { + selectedTab, + onTabSelect, + isReadOnlyMode, + invalidTabs, + data, + onDataChanged, + genericFieldInfo, + entitlementPoolsList, + licenseKeyGroupsList + } = this.props; + return ( +
    + {genericFieldInfo && ( +
    this.submit()} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => + this.props.onValidateForm(FG_EDITOR_FORM) + } + onReset={() => this.props.onCancel()} + labledButtons={true} + isReadOnlyMode={isReadOnlyMode} + name="feature-group-validation-form" + className="license-model-form feature-group-form"> + + +
    + + this.validateName(value) + } + /> +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
    +
    + )} +
    + ); + } + + submit() { + const { + data: featureGroup, + previousData: previousFeatureGroup + } = this.props; + this.props.onSubmit(previousFeatureGroup, featureGroup); + } + + validateName(value) { + const { data: { id }, FGNames } = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({ + itemId: id, + itemName: value, + list: FGNames + }); + + return !isExists + ? { isValid: true, errorText: '' } + : { + isValid: false, + errorText: i18n( + "Feature group by the name '" + + value + + "' already exists. Feature group name must be unique" + ) + }; + } +} export default FeatureGroupEditorView; 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 26925487db..55e2710231 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js @@ -13,48 +13,62 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; -import FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; -import FeatureGroupListEditorView, {generateConfirmationMsg} from './FeatureGroupListEditorView.jsx'; +import { connect } from 'react-redux'; +import FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; +import FeatureGroupListEditorView, { + generateConfirmationMsg +} from './FeatureGroupListEditorView.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as globalMoadlActions } from 'nfvo-components/modal/GlobalModalConstants.js'; -export const mapStateToProps = ({licenseModel: {featureGroup, licenseModelEditor}}) => { - - const {featureGroupEditor: {data}, featureGroupsList} = featureGroup; - const {vendorName, version} = licenseModelEditor.data; - - return { - vendorName, - version, - featureGroupsModal: { - show: Boolean(data), - editMode: Boolean(data && data.id) - }, - featureGroupsList - }; +export const mapStateToProps = ({ + licenseModel: { featureGroup, licenseModelEditor } +}) => { + const { featureGroupEditor: { data }, featureGroupsList } = featureGroup; + const { vendorName, version } = licenseModelEditor.data; + return { + vendorName, + version, + featureGroupsModal: { + show: Boolean(data), + editMode: Boolean(data && data.id) + }, + featureGroupsList + }; }; - -const mapActionsToProps = (dispatch, {licenseModelId}) => { - return { - onDeleteFeatureGroupClick: (featureGroup, version) => dispatch({ - type: globalMoadlActions.GLOBAL_MODAL_WARNING, - data:{ - msg: generateConfirmationMsg(featureGroup), - confirmationButtonText: i18n('Delete'), - title: i18n('Delete'), - onConfirmed: ()=>FeatureGroupsActionHelper.deleteFeatureGroup(dispatch, {featureGroupId: featureGroup.id, licenseModelId, version}) - } - }), - onAddFeatureGroupClick: (actualVersion) => FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, {licenseModelId, version: actualVersion}), - onEditFeatureGroupClick: (featureGroup, actualVersion) => FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, { - featureGroup, - licenseModelId, - version: actualVersion - }) - }; +const mapActionsToProps = (dispatch, { licenseModelId }) => { + return { + onDeleteFeatureGroupClick: (featureGroup, version) => + dispatch({ + type: globalMoadlActions.GLOBAL_MODAL_WARNING, + data: { + msg: generateConfirmationMsg(featureGroup), + confirmationButtonText: i18n('Delete'), + title: i18n('Delete'), + onConfirmed: () => + FeatureGroupsActionHelper.deleteFeatureGroup(dispatch, { + featureGroupId: featureGroup.id, + licenseModelId, + version + }) + } + }), + onAddFeatureGroupClick: actualVersion => + FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, { + licenseModelId, + version: actualVersion + }), + onEditFeatureGroupClick: (featureGroup, actualVersion) => + FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, { + featureGroup, + licenseModelId, + version: actualVersion + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(FeatureGroupListEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + FeatureGroupListEditorView +); 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 f59e000c21..91f77b3111 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx @@ -24,147 +24,184 @@ import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.js import FeatureGroupEditor from './FeatureGroupEditor.js'; class FeatureGroupListEditorView extends React.Component { - static propTypes = { - vendorName: PropTypes.string, - licenseModelId: PropTypes.string.isRequired, - featureGroupsModal: PropTypes.shape({ - show: PropTypes.bool, - editMode: PropTypes.bool - }), - isReadOnlyMode: PropTypes.bool.isRequired, - onAddFeatureGroupClick: PropTypes.func, - onEditFeatureGroupClick: PropTypes.func, - onDeleteFeatureGroupClick: PropTypes.func, - onCancelFeatureGroupsEditor: PropTypes.func, - featureGroupsList: PropTypes.array - }; - - static defaultProps = { - featureGroupsList: [], - featureGroupsModal: { - show: false, - editMode: false - } - }; - - state = { - localFilter: '' - }; - - render() { - let {licenseModelId, featureGroupsModal, isReadOnlyMode, onAddFeatureGroupClick, version} = this.props; - const {localFilter} = this.state; - return ( -
    - this.setState({localFilter: value})} - onAdd={() => onAddFeatureGroupClick(version)} - isReadOnlyMode={isReadOnlyMode}> - {this.filterList().map(listItem => this.renderFeatureGroupListItem(listItem, isReadOnlyMode, version))} - - {featureGroupsModal.show && - - {`${featureGroupsModal.editMode ? i18n('Edit Feature Group') : i18n('Create New Feature Group')}`} - - - - - - } - -
    - ); - } - - - renderFeatureGroupListItem(listItem, isReadOnlyMode, version) { - let {name, description, manufacturerReferenceNumber, entitlementPoolsIds = [], licenseKeyGroupsIds = []} = listItem; - return ( - this.deleteFeatureGroupItem(listItem, version)} - onSelect={() => this.editFeatureGroupItem(listItem, version)} - className='list-editor-item-view' - isReadOnlyMode={isReadOnlyMode}> -
    -
    {i18n('Name')}
    -
    {name}
    -
    - -
    -
    -
    {i18n('EP')}
    -
    {entitlementPoolsIds.length || 0}
    -
    -
    -
    -
    -
    {i18n('LKG')}
    -
    {licenseKeyGroupsIds.length || 0}
    -
    -
    - -
    -
    -
    {i18n('Manufacturer Reference Number')}
    -
    {manufacturerReferenceNumber}
    -
    -
    - -
    -
    {i18n('Description')}
    -
    {description}
    -
    - - - -
    - ); - } - - filterList() { - let {featureGroupsList} = this.props; - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return featureGroupsList.filter(({name = '', description = ''}) => { - return escape(name).match(filter) || escape(description).match(filter); - }); - } - else { - return featureGroupsList; - } - } - - editFeatureGroupItem(featureGroup, version) { - this.props.onEditFeatureGroupClick(featureGroup, version); - } - - deleteFeatureGroupItem(featureGroup, version) { - this.props.onDeleteFeatureGroupClick(featureGroup, version); - } + static propTypes = { + vendorName: PropTypes.string, + licenseModelId: PropTypes.string.isRequired, + featureGroupsModal: PropTypes.shape({ + show: PropTypes.bool, + editMode: PropTypes.bool + }), + isReadOnlyMode: PropTypes.bool.isRequired, + onAddFeatureGroupClick: PropTypes.func, + onEditFeatureGroupClick: PropTypes.func, + onDeleteFeatureGroupClick: PropTypes.func, + onCancelFeatureGroupsEditor: PropTypes.func, + featureGroupsList: PropTypes.array + }; + + static defaultProps = { + featureGroupsList: [], + featureGroupsModal: { + show: false, + editMode: false + } + }; + + state = { + localFilter: '' + }; + + render() { + let { + licenseModelId, + featureGroupsModal, + isReadOnlyMode, + onAddFeatureGroupClick, + version + } = this.props; + const { localFilter } = this.state; + return ( +
    + this.setState({ localFilter: value })} + onAdd={() => onAddFeatureGroupClick(version)} + isReadOnlyMode={isReadOnlyMode}> + {this.filterList().map(listItem => + this.renderFeatureGroupListItem( + listItem, + isReadOnlyMode, + version + ) + )} + + {featureGroupsModal.show && ( + + + {`${ + featureGroupsModal.editMode + ? i18n('Edit Feature Group') + : i18n('Create New Feature Group') + }`} + + + + + + )} +
    + ); + } + + renderFeatureGroupListItem(listItem, isReadOnlyMode, version) { + let { + name, + description, + manufacturerReferenceNumber, + entitlementPoolsIds = [], + licenseKeyGroupsIds = [] + } = listItem; + return ( + this.deleteFeatureGroupItem(listItem, version)} + onSelect={() => this.editFeatureGroupItem(listItem, version)} + className="list-editor-item-view" + isReadOnlyMode={isReadOnlyMode}> +
    +
    {i18n('Name')}
    +
    {name}
    +
    + +
    +
    +
    {i18n('EP')}
    +
    + {entitlementPoolsIds.length || 0} +
    +
    +
    +
    +
    +
    {i18n('LKG')}
    +
    + {licenseKeyGroupsIds.length || 0} +
    +
    +
    + +
    +
    +
    + {i18n('Manufacturer Reference Number')} +
    +
    + {manufacturerReferenceNumber} +
    +
    +
    + +
    +
    {i18n('Description')}
    +
    {description}
    +
    +
    + ); + } + + filterList() { + let { featureGroupsList } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return featureGroupsList.filter( + ({ name = '', description = '' }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) + ); + } + ); + } else { + return featureGroupsList; + } + } + + editFeatureGroupItem(featureGroup, version) { + this.props.onEditFeatureGroupClick(featureGroup, version); + } + + deleteFeatureGroupItem(featureGroup, version) { + this.props.onDeleteFeatureGroupClick(featureGroup, version); + } } export default FeatureGroupListEditorView; export function generateConfirmationMsg(featureGroupToDelete) { - let name = featureGroupToDelete ? featureGroupToDelete.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') : - ''; - return ( -
    -

    {msg}

    -

    {subMsg}

    -
    - ); + let name = featureGroupToDelete ? featureGroupToDelete.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' + ) + : ''; + return ( +
    +

    {msg}

    +

    {subMsg}

    +
    + ); } 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 9e7fe8e0dd..22e21a613a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js @@ -15,132 +15,202 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes as featureGroupsActionConstants} from './FeatureGroupsConstants.js'; +import { actionTypes as featureGroupsActionConstants } from './FeatureGroupsConstants.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'); - const {id: versionId} = version; - return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/feature-groups`; + const restPrefix = Configuration.get('restPrefix'); + const { id: versionId } = 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}`); + return RestAPIUtil.fetch( + `${baseUrl(licenseModelId, version)}/${featureGroupId}` + ); } function fetchFeatureGroupsList(licenseModelId, version) { - return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } function deleteFeatureGroup(licenseModelId, featureGroupId, version) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${featureGroupId}`); + return RestAPIUtil.destroy( + `${baseUrl(licenseModelId, version)}/${featureGroupId}` + ); } function addFeatureGroup(licenseModelId, featureGroup, version) { - return RestAPIUtil.post(baseUrl(licenseModelId, version), { - name: featureGroup.name, - description: featureGroup.description, - partNumber: featureGroup.partNumber, - manufacturerReferenceNumber: featureGroup.manufacturerReferenceNumber, - addedLicenseKeyGroupsIds: featureGroup.licenseKeyGroupsIds, - addedEntitlementPoolsIds: featureGroup.entitlementPoolsIds - }); + return RestAPIUtil.post(baseUrl(licenseModelId, version), { + name: featureGroup.name, + description: featureGroup.description, + partNumber: featureGroup.partNumber, + manufacturerReferenceNumber: featureGroup.manufacturerReferenceNumber, + addedLicenseKeyGroupsIds: featureGroup.licenseKeyGroupsIds, + addedEntitlementPoolsIds: featureGroup.entitlementPoolsIds + }); } -function updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup, version) { - - const {licenseKeyGroupsIds = []} = featureGroup; - const {licenseKeyGroupsIds: prevLicenseKeyGroupsIds = []} = previousFeatureGroup; - const {entitlementPoolsIds = []} = featureGroup; - const {entitlementPoolsIds: prevEntitlementPoolsIds = []} = previousFeatureGroup; - return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${featureGroup.id}`, { - name: featureGroup.name, - description: featureGroup.description, - partNumber: featureGroup.partNumber, - manufacturerReferenceNumber: featureGroup.manufacturerReferenceNumber, - addedLicenseKeyGroupsIds: licenseKeyGroupsIds.filter(licenseKeyGroupId => prevLicenseKeyGroupsIds.indexOf(licenseKeyGroupId) === -1), - removedLicenseKeyGroupsIds: prevLicenseKeyGroupsIds.filter(prevLicenseKeyGroupId => licenseKeyGroupsIds.indexOf(prevLicenseKeyGroupId) === -1), - addedEntitlementPoolsIds: entitlementPoolsIds.filter(entitlementPoolId => prevEntitlementPoolsIds.indexOf(entitlementPoolId) === -1), - removedEntitlementPoolsIds: prevEntitlementPoolsIds.filter(prevEntitlementPoolId => entitlementPoolsIds.indexOf(prevEntitlementPoolId) === -1) - - }); +function updateFeatureGroup( + licenseModelId, + previousFeatureGroup, + featureGroup, + version +) { + const { licenseKeyGroupsIds = [] } = featureGroup; + const { + licenseKeyGroupsIds: prevLicenseKeyGroupsIds = [] + } = previousFeatureGroup; + const { entitlementPoolsIds = [] } = featureGroup; + const { + entitlementPoolsIds: prevEntitlementPoolsIds = [] + } = previousFeatureGroup; + return RestAPIUtil.put( + `${baseUrl(licenseModelId, version)}/${featureGroup.id}`, + { + name: featureGroup.name, + description: featureGroup.description, + partNumber: featureGroup.partNumber, + manufacturerReferenceNumber: + featureGroup.manufacturerReferenceNumber, + addedLicenseKeyGroupsIds: licenseKeyGroupsIds.filter( + licenseKeyGroupId => + prevLicenseKeyGroupsIds.indexOf(licenseKeyGroupId) === -1 + ), + removedLicenseKeyGroupsIds: prevLicenseKeyGroupsIds.filter( + prevLicenseKeyGroupId => + licenseKeyGroupsIds.indexOf(prevLicenseKeyGroupId) === -1 + ), + addedEntitlementPoolsIds: entitlementPoolsIds.filter( + entitlementPoolId => + prevEntitlementPoolsIds.indexOf(entitlementPoolId) === -1 + ), + removedEntitlementPoolsIds: prevEntitlementPoolsIds.filter( + prevEntitlementPoolId => + entitlementPoolsIds.indexOf(prevEntitlementPoolId) === -1 + ) + } + ); } export default { - fetchFeatureGroup(dispatch, {licenseModelId, featureGroupId, version}) { - return fetchFeatureGroup(licenseModelId, featureGroupId, version); - }, + 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, - response - })); - }, + fetchFeatureGroupsList(dispatch, { licenseModelId, version }) { + return fetchFeatureGroupsList(licenseModelId, version).then(response => + dispatch({ + type: featureGroupsActionConstants.FEATURE_GROUPS_LIST_LOADED, + response + }) + ); + }, - deleteFeatureGroup(dispatch, {licenseModelId, featureGroupId, version}) { - return deleteFeatureGroup(licenseModelId, featureGroupId, version).then(() => { - dispatch({ - type: featureGroupsActionConstants.DELETE_FEATURE_GROUPS, - featureGroupId - }); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - }, + deleteFeatureGroup(dispatch, { licenseModelId, featureGroupId, version }) { + return deleteFeatureGroup(licenseModelId, featureGroupId, version).then( + () => { + dispatch({ + type: featureGroupsActionConstants.DELETE_FEATURE_GROUPS, + featureGroupId + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + } + ); + }, - saveFeatureGroup(dispatch, {licenseModelId, previousFeatureGroup, featureGroup, version}) { - if (previousFeatureGroup) { - return updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup, version).then(() =>{ - dispatch({ - type: featureGroupsActionConstants.EDIT_FEATURE_GROUPS, - featureGroup - }); - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } - else { - return addFeatureGroup(licenseModelId, featureGroup, version).then(response => { - dispatch({ - type: featureGroupsActionConstants.ADD_FEATURE_GROUPS, - featureGroup: { - ...featureGroup, - id: response.value, - referencingLicenseAgreements: [] - } - }); - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } - }, + saveFeatureGroup( + dispatch, + { licenseModelId, previousFeatureGroup, featureGroup, version } + ) { + if (previousFeatureGroup) { + return updateFeatureGroup( + licenseModelId, + previousFeatureGroup, + featureGroup, + version + ).then(() => { + dispatch({ + type: featureGroupsActionConstants.EDIT_FEATURE_GROUPS, + featureGroup + }); + EntitlementPoolsActionHelper.fetchEntitlementPoolsList( + dispatch, + { licenseModelId, version } + ); + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList( + dispatch, + { licenseModelId, version } + ); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + } else { + return addFeatureGroup(licenseModelId, featureGroup, version).then( + response => { + dispatch({ + type: featureGroupsActionConstants.ADD_FEATURE_GROUPS, + featureGroup: { + ...featureGroup, + id: response.value, + referencingLicenseAgreements: [] + } + }); + EntitlementPoolsActionHelper.fetchEntitlementPoolsList( + dispatch, + { licenseModelId, version } + ); + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList( + dispatch, + { licenseModelId, version } + ); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + } + ); + } + }, - selectEntitlementPoolsEditorTab(dispatch, {tab}) { - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.SELECT_TAB, - tab - }); - }, + selectEntitlementPoolsEditorTab(dispatch, { tab }) { + dispatch({ + type: featureGroupsActionConstants.featureGroupsEditor.SELECT_TAB, + tab + }); + }, - openFeatureGroupsEditor(dispatch, {featureGroup, licenseModelId, version}) { - return Promise.all([ - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}), - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}) - ]).then(() => { - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.OPEN, - featureGroup - }); - }); - }, + openFeatureGroupsEditor( + dispatch, + { featureGroup, licenseModelId, version } + ) { + return Promise.all([ + EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, { + licenseModelId, + version + }), + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, { + licenseModelId, + version + }) + ]).then(() => { + dispatch({ + type: featureGroupsActionConstants.featureGroupsEditor.OPEN, + featureGroup + }); + }); + }, - closeFeatureGroupsEditor(dispatch) { - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.CLOSE - }); - } + closeFeatureGroupsEditor(dispatch) { + dispatch({ + type: featureGroupsActionConstants.featureGroupsEditor.CLOSE + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js index 4c5a94f239..feeb5b6c39 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js @@ -16,27 +16,27 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - FEATURE_GROUPS_LIST_LOADED: null, - ADD_FEATURE_GROUPS: null, - EDIT_FEATURE_GROUPS: null, - DELETE_FEATURE_GROUPS: null, + FEATURE_GROUPS_LIST_LOADED: null, + ADD_FEATURE_GROUPS: null, + EDIT_FEATURE_GROUPS: null, + DELETE_FEATURE_GROUPS: null, - ENTITLEMENT_POOLS_LIST_LOADED: null, + ENTITLEMENT_POOLS_LIST_LOADED: null, - featureGroupsEditor: { - OPEN: null, - CLOSE: null, - DATA_CHANGED: null, - SELECT_TAB: null - } + featureGroupsEditor: { + OPEN: null, + CLOSE: null, + DATA_CHANGED: null, + SELECT_TAB: null + } }); export const FG_EDITOR_FORM = 'FG_EDITOR_FORM'; export const state = keyMirror({ - SELECTED_FEATURE_GROUP_TAB: { - GENERAL: 1, - ENTITLEMENT_POOLS: 2, - LICENSE_KEY_GROUPS: 3 - } + SELECTED_FEATURE_GROUP_TAB: { + GENERAL: 1, + ENTITLEMENT_POOLS: 2, + LICENSE_KEY_GROUPS: 3 + } }); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js index 5688fc0f16..aa1081ed20 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js @@ -14,65 +14,82 @@ * permissions and limitations under the License. */ -import {actionTypes, FG_EDITOR_FORM, state as FeatureGroupStateConstants} from './FeatureGroupsConstants.js'; - - +import { + actionTypes, + FG_EDITOR_FORM, + state as FeatureGroupStateConstants +} from './FeatureGroupsConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.featureGroupsEditor.OPEN: - return { - ...state, - data: action.featureGroup || {}, - formReady: null, - formName: FG_EDITOR_FORM, - genericFieldInfo: { - 'description': { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}], - tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL - }, - 'partNumber': { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}], - tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL - }, - 'manufacturerReferenceNumber': { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 100}], - tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL - }, - 'name': { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}], - tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL - } - } - }; - case actionTypes.featureGroupsEditor.CLOSE: - return {}; - case actionTypes.featureGroupsEditor.SELECT_TAB: - return { - ...state, - selectedTab: action.tab - }; - - case actionTypes.featureGroupsEditor.SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: - return { - ...state, - selectedEntitlementPoolsButtonTab: action.buttonTab - }; - case actionTypes.featureGroupsEditor.SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB: - return { - ...state, - selectedLicenseKeyGroupsButtonTab: action.buttonTab - }; - default: - return state; - } + switch (action.type) { + case actionTypes.featureGroupsEditor.OPEN: + return { + ...state, + data: action.featureGroup || {}, + formReady: null, + formName: FG_EDITOR_FORM, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }], + tabId: + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB.GENERAL + }, + partNumber: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }], + tabId: + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB.GENERAL + }, + manufacturerReferenceNumber: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 100 } + ], + tabId: + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB.GENERAL + }, + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 120 } + ], + tabId: + FeatureGroupStateConstants + .SELECTED_FEATURE_GROUP_TAB.GENERAL + } + } + }; + case actionTypes.featureGroupsEditor.CLOSE: + return {}; + case actionTypes.featureGroupsEditor.SELECT_TAB: + return { + ...state, + selectedTab: action.tab + }; + case actionTypes.featureGroupsEditor + .SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: + return { + ...state, + selectedEntitlementPoolsButtonTab: action.buttonTab + }; + case actionTypes.featureGroupsEditor + .SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB: + return { + ...state, + selectedLicenseKeyGroupsButtonTab: action.buttonTab + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js index 3b5f1c55e4..072bba403d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js @@ -13,19 +13,27 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './FeatureGroupsConstants.js'; +import { actionTypes } from './FeatureGroupsConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.FEATURE_GROUPS_LIST_LOADED: - return [...action.response.results]; - case actionTypes.ADD_FEATURE_GROUPS: - return [...state, action.featureGroup]; - case actionTypes.EDIT_FEATURE_GROUPS: - const indexForEdit = state.findIndex(featureGroup => featureGroup.id === action.featureGroup.id); - return [...state.slice(0, indexForEdit), action.featureGroup, ...state.slice(indexForEdit + 1)]; - case actionTypes.DELETE_FEATURE_GROUPS: - return state.filter(featureGroup => featureGroup.id !== action.featureGroupId); - default: - return state; - } + switch (action.type) { + case actionTypes.FEATURE_GROUPS_LIST_LOADED: + return [...action.response.results]; + case actionTypes.ADD_FEATURE_GROUPS: + return [...state, action.featureGroup]; + case actionTypes.EDIT_FEATURE_GROUPS: + const indexForEdit = state.findIndex( + featureGroup => featureGroup.id === action.featureGroup.id + ); + return [ + ...state.slice(0, indexForEdit), + action.featureGroup, + ...state.slice(indexForEdit + 1) + ]; + case actionTypes.DELETE_FEATURE_GROUPS: + return state.filter( + featureGroup => featureGroup.id !== action.featureGroupId + ); + default: + return state; + } }; 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 b1b4ee8fdd..e07777f69e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js @@ -15,109 +15,181 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes as licenseAgreementActionTypes} from './LicenseAgreementConstants.js'; +import { actionTypes as licenseAgreementActionTypes } from './LicenseAgreementConstants.js'; import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js'; import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; function baseUrl(licenseModelId, version) { - const restPrefix = Configuration.get('restPrefix'); - const {id: versionId} = version; - return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/license-agreements`; + const restPrefix = Configuration.get('restPrefix'); + const { id: versionId } = version; + return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/license-agreements`; } function fetchLicenseAgreementList(licenseModelId, version) { - return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } function fetchLicenseAgreement(licenseModelId, licenseAgreementId, version) { - return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}/${licenseAgreementId}`); + return RestAPIUtil.fetch( + `${baseUrl(licenseModelId, version)}/${licenseAgreementId}` + ); } function postLicenseAgreement(licenseModelId, licenseAgreement, version) { - return RestAPIUtil.post(baseUrl(licenseModelId, version), { - name: licenseAgreement.name, - description: licenseAgreement.description, - licenseTerm: licenseAgreement.licenseTerm, - requirementsAndConstrains: licenseAgreement.requirementsAndConstrains, - addedFeatureGroupsIds: licenseAgreement.featureGroupsIds - }); + return RestAPIUtil.post(baseUrl(licenseModelId, version), { + name: licenseAgreement.name, + description: licenseAgreement.description, + licenseTerm: licenseAgreement.licenseTerm, + requirementsAndConstrains: licenseAgreement.requirementsAndConstrains, + addedFeatureGroupsIds: licenseAgreement.featureGroupsIds + }); } -function putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAgreement, version) { - const {featureGroupsIds = []} = licenseAgreement; - const {featureGroupsIds: prevFeatureGroupsIds = []} = previousLicenseAgreement; - return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${licenseAgreement.id}`, { - name: licenseAgreement.name, - description: licenseAgreement.description, - licenseTerm: licenseAgreement.licenseTerm, - requirementsAndConstrains: licenseAgreement.requirementsAndConstrains, - addedFeatureGroupsIds: featureGroupsIds.filter(featureGroupId => prevFeatureGroupsIds.indexOf(featureGroupId) === -1), - removedFeatureGroupsIds: prevFeatureGroupsIds.filter(prevFeatureGroupsId => featureGroupsIds.indexOf(prevFeatureGroupsId) === -1) - }); +function putLicenseAgreement( + licenseModelId, + previousLicenseAgreement, + licenseAgreement, + version +) { + const { featureGroupsIds = [] } = licenseAgreement; + const { + featureGroupsIds: prevFeatureGroupsIds = [] + } = previousLicenseAgreement; + return RestAPIUtil.put( + `${baseUrl(licenseModelId, version)}/${licenseAgreement.id}`, + { + name: licenseAgreement.name, + description: licenseAgreement.description, + licenseTerm: licenseAgreement.licenseTerm, + requirementsAndConstrains: + licenseAgreement.requirementsAndConstrains, + addedFeatureGroupsIds: featureGroupsIds.filter( + featureGroupId => + prevFeatureGroupsIds.indexOf(featureGroupId) === -1 + ), + removedFeatureGroupsIds: prevFeatureGroupsIds.filter( + prevFeatureGroupsId => + featureGroupsIds.indexOf(prevFeatureGroupsId) === -1 + ) + } + ); } function deleteLicenseAgreement(licenseModelId, licenseAgreementId, version) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${licenseAgreementId}`); + return RestAPIUtil.destroy( + `${baseUrl(licenseModelId, version)}/${licenseAgreementId}` + ); } export default { + fetchLicenseAgreementList(dispatch, { licenseModelId, version }) { + return fetchLicenseAgreementList(licenseModelId, version).then( + response => + dispatch({ + type: + licenseAgreementActionTypes.LICENSE_AGREEMENT_LIST_LOADED, + response + }) + ); + }, - fetchLicenseAgreementList(dispatch, {licenseModelId, version}) { - return fetchLicenseAgreementList(licenseModelId, version).then(response => dispatch({ - type: licenseAgreementActionTypes.LICENSE_AGREEMENT_LIST_LOADED, - response - })); - }, + fetchLicenseAgreement( + dispatch, + { licenseModelId, licenseAgreementId, version } + ) { + return fetchLicenseAgreement( + licenseModelId, + licenseAgreementId, + version + ); + }, - fetchLicenseAgreement(dispatch, {licenseModelId, licenseAgreementId, version}) { - return fetchLicenseAgreement(licenseModelId, licenseAgreementId, version); - }, + openLicenseAgreementEditor( + dispatch, + { licenseModelId, licenseAgreement, version } + ) { + FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, { + licenseModelId, + version + }); + dispatch({ + type: licenseAgreementActionTypes.licenseAgreementEditor.OPEN, + licenseAgreement + }); + }, - openLicenseAgreementEditor(dispatch, {licenseModelId, licenseAgreement, version}) { - FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version}); - dispatch({ - type: licenseAgreementActionTypes.licenseAgreementEditor.OPEN, - licenseAgreement - }); - }, + closeLicenseAgreementEditor(dispatch) { + dispatch({ + type: licenseAgreementActionTypes.licenseAgreementEditor.CLOSE + }); + }, - closeLicenseAgreementEditor(dispatch) { - dispatch({ - type: licenseAgreementActionTypes.licenseAgreementEditor.CLOSE - }); - }, + saveLicenseAgreement( + dispatch, + { licenseModelId, previousLicenseAgreement, licenseAgreement, version } + ) { + if (previousLicenseAgreement) { + return putLicenseAgreement( + licenseModelId, + previousLicenseAgreement, + licenseAgreement, + version + ).then(() => { + this.fetchLicenseAgreementList(dispatch, { + licenseModelId, + version + }); + return 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 + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + } + }, + deleteLicenseAgreement( + dispatch, + { licenseModelId, licenseAgreementId, version } + ) { + return deleteLicenseAgreement( + licenseModelId, + licenseAgreementId, + version + ).then(() => { + dispatch({ + type: licenseAgreementActionTypes.DELETE_LICENSE_AGREEMENT, + licenseAgreementId + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + }, - saveLicenseAgreement(dispatch, {licenseModelId, previousLicenseAgreement, licenseAgreement, version}) { - if (previousLicenseAgreement) { - return putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAgreement, version).then(() => { - this.fetchLicenseAgreementList(dispatch, {licenseModelId, version}); - return 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}); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } - }, - - deleteLicenseAgreement(dispatch, {licenseModelId, licenseAgreementId, version}) { - return deleteLicenseAgreement(licenseModelId, licenseAgreementId, version).then(() => { - dispatch({ - type: licenseAgreementActionTypes.DELETE_LICENSE_AGREEMENT, - licenseAgreementId - }); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - }, - - selectLicenseAgreementEditorTab(dispatch, {tab}) { - dispatch({ - type: licenseAgreementActionTypes.licenseAgreementEditor.SELECT_TAB, - tab - }); - } + selectLicenseAgreementEditorTab(dispatch, { tab }) { + dispatch({ + type: licenseAgreementActionTypes.licenseAgreementEditor.SELECT_TAB, + tab + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js index 181171d4cd..65a45348ca 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js @@ -15,49 +15,54 @@ */ import keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import InputOptions, { + other as optionInputOther +} from 'nfvo-components/input/validation/InputOptions.jsx'; export const actionTypes = keyMirror({ - LICENSE_AGREEMENT_LIST_LOADED: null, - DELETE_LICENSE_AGREEMENT: null, - - licenseAgreementEditor: { - OPEN: null, - CLOSE: null, - DATA_CHANGED: null, - SELECT_TAB: null - } + LICENSE_AGREEMENT_LIST_LOADED: null, + DELETE_LICENSE_AGREEMENT: null, + licenseAgreementEditor: { + OPEN: null, + CLOSE: null, + DATA_CHANGED: null, + SELECT_TAB: null + } }); export const LA_EDITOR_FORM = 'LA_EDITOR_FORM'; export const enums = keyMirror({ - SELECTED_LICENSE_AGREEMENT_TAB: { - GENERAL: 1, - FEATURE_GROUPS: 2 - } + SELECTED_LICENSE_AGREEMENT_TAB: { + GENERAL: 1, + FEATURE_GROUPS: 2 + } }); export const defaultState = { - LICENSE_AGREEMENT_EDITOR_DATA: { - licenseTerm: {choice: '', other: ''} - } + LICENSE_AGREEMENT_EDITOR_DATA: { + licenseTerm: { choice: '', other: '' } + } }; export const optionsInputValues = { - LICENSE_MODEL_TYPE: [ - {enum: '', title: i18n('please select…')}, - {enum: 'Fixed_Term', title: 'Fixed Term'}, - {enum: 'Perpetual', title: 'Perpetual'}, - {enum: 'Unlimited', title: 'Unlimited'} - ] + LICENSE_MODEL_TYPE: [ + { enum: '', title: i18n('please select…') }, + { enum: 'Fixed_Term', title: 'Fixed Term' }, + { enum: 'Perpetual', title: 'Perpetual' }, + { enum: 'Unlimited', title: 'Unlimited' } + ] }; -export const extractValue = (item) => { - if (item === undefined) { - return ''; - } //TODO fix it later +export const extractValue = item => { + if (item === undefined) { + return ''; + } //TODO fix it later - return item ? item.choice === optionInputOther.OTHER ? item.other : InputOptions.getTitleByName(optionsInputValues, item.choice) : ''; + return item + ? item.choice === optionInputOther.OTHER + ? item.other + : InputOptions.getTitleByName(optionsInputValues, item.choice) + : ''; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js index 7d70da6ea5..735531a175 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js @@ -13,66 +13,93 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import LicenseAgreementActionHelper from './LicenseAgreementActionHelper.js'; import LicenseAgreementEditorView from './LicenseAgreementEditorView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -export const mapStateToProps = ({licenseModel: {licenseAgreement, featureGroup}}) => { +export const mapStateToProps = ({ + licenseModel: { licenseAgreement, featureGroup } +}) => { + let { + data, + selectedTab, + genericFieldInfo, + formReady + } = licenseAgreement.licenseAgreementEditor; + const list = licenseAgreement.licenseAgreementList; + const LANames = {}; + let previousData; + const licenseAgreementId = data ? data.id : null; + if (licenseAgreementId) { + previousData = licenseAgreement.licenseAgreementList.find( + licenseAgreement => licenseAgreement.id === licenseAgreementId + ); + } - let {data, selectedTab, genericFieldInfo, formReady} = licenseAgreement.licenseAgreementEditor; - const list = licenseAgreement.licenseAgreementList; - const LANames = {}; + for (let i = 0; i < list.length; i++) { + LANames[list[i].name.toLowerCase()] = list[i].id; + } - let previousData; - const licenseAgreementId = data ? data.id : null; - if(licenseAgreementId) { - previousData = licenseAgreement.licenseAgreementList.find(licenseAgreement => licenseAgreement.id === licenseAgreementId); - } + const { featureGroupsList = [] } = featureGroup; - for (let i = 0; i < list.length; i++) { - LANames[list[i].name.toLowerCase()] = list[i].id; - } + let isFormValid = true; + let invalidTabs = []; + for (let field in genericFieldInfo) { + if (!genericFieldInfo[field].isValid) { + isFormValid = false; + let tabId = genericFieldInfo[field].tabId; + if (invalidTabs.indexOf(tabId) === -1) { + invalidTabs[invalidTabs.length] = genericFieldInfo[field].tabId; + } + } + } - const {featureGroupsList = []} = featureGroup; - - let isFormValid = true; - let invalidTabs = []; - for (let field in genericFieldInfo) { - if (!genericFieldInfo[field].isValid) { - isFormValid = false; - let tabId = genericFieldInfo[field].tabId; - if (invalidTabs.indexOf(tabId) === -1) { - invalidTabs[invalidTabs.length] = genericFieldInfo[field].tabId; - } - } - } - - return { - data, - previousData, - selectedTab, - featureGroupsList, - LANames, - genericFieldInfo, - isFormValid, - formReady, - invalidTabs - }; + return { + data, + previousData, + selectedTab, + featureGroupsList, + LANames, + genericFieldInfo, + isFormValid, + formReady, + invalidTabs + }; }; -export const mapActionsToProps = (dispatch, {licenseModelId, version}) => { - return { - onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), - onTabSelect: tab => LicenseAgreementActionHelper.selectLicenseAgreementEditorTab(dispatch, {tab}), - onCancel: () => LicenseAgreementActionHelper.closeLicenseAgreementEditor(dispatch), - onSubmit: ({previousLicenseAgreement, licenseAgreement}) => { - LicenseAgreementActionHelper.closeLicenseAgreementEditor(dispatch); - LicenseAgreementActionHelper.saveLicenseAgreement(dispatch, {licenseModelId, previousLicenseAgreement, licenseAgreement, version}); - }, - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) - }; +export const mapActionsToProps = (dispatch, { licenseModelId, version }) => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onTabSelect: tab => + LicenseAgreementActionHelper.selectLicenseAgreementEditorTab( + dispatch, + { + tab + } + ), + onCancel: () => + LicenseAgreementActionHelper.closeLicenseAgreementEditor(dispatch), + onSubmit: ({ previousLicenseAgreement, licenseAgreement }) => { + LicenseAgreementActionHelper.closeLicenseAgreementEditor(dispatch); + LicenseAgreementActionHelper.saveLicenseAgreement(dispatch, { + licenseModelId, + previousLicenseAgreement, + licenseAgreement, + version + }); + }, + onValidateForm: formName => + ValidationHelper.validateForm(dispatch, formName) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(LicenseAgreementEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + LicenseAgreementEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js index 9cff2792ff..0d3fb2a3b6 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js @@ -13,53 +13,76 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, defaultState, LA_EDITOR_FORM, enums as LicenseAgreementEnums} from './LicenseAgreementConstants.js'; -import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { + actionTypes, + defaultState, + LA_EDITOR_FORM, + enums as LicenseAgreementEnums +} from './LicenseAgreementConstants.js'; +import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.licenseAgreementEditor.OPEN: - return { - ...state, - formReady: null, - formName: LA_EDITOR_FORM, - genericFieldInfo: { - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}], - tabId: LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB.GENERAL - }, - 'requirementsAndConstrains' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}], - tabId: LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB.GENERAL - }, - 'licenseTerm' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'requiredChoiceWithOther', data: optionInputOther.OTHER}], - tabId: LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB.GENERAL - }, - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 25}], - tabId: LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB.GENERAL - } - }, - data: action.licenseAgreement ? { ...action.licenseAgreement } : defaultState.LICENSE_AGREEMENT_EDITOR_DATA - }; - case actionTypes.licenseAgreementEditor.CLOSE: - return {}; - case actionTypes.licenseAgreementEditor.SELECT_TAB: - return { - ...state, - selectedTab: action.tab - }; - default: - return state; - } - + switch (action.type) { + case actionTypes.licenseAgreementEditor.OPEN: + return { + ...state, + formReady: null, + formName: LA_EDITOR_FORM, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }], + tabId: + LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB + .GENERAL + }, + requirementsAndConstrains: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }], + tabId: + LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB + .GENERAL + }, + licenseTerm: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { + type: 'requiredChoiceWithOther', + data: optionInputOther.OTHER + } + ], + tabId: + LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB + .GENERAL + }, + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 25 } + ], + tabId: + LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB + .GENERAL + } + }, + data: action.licenseAgreement + ? { ...action.licenseAgreement } + : defaultState.LICENSE_AGREEMENT_EDITOR_DATA + }; + case actionTypes.licenseAgreementEditor.CLOSE: + return {}; + case actionTypes.licenseAgreementEditor.SELECT_TAB: + return { + ...state, + selectedTab: action.tab + }; + default: + return state; + } }; 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 a3e73f4f14..cc16dd996d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx @@ -17,7 +17,7 @@ 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'; +import { TabsForm as Form } from 'nfvo-components/input/validation/Form.jsx'; import Tabs from 'nfvo-components/input/validation/Tabs.jsx'; import Tab from 'sdc-ui/lib/react/Tab.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; @@ -25,176 +25,278 @@ import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Validator from 'nfvo-utils/Validator.js'; -import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx'; -import {enums as LicenseAgreementEnums, optionsInputValues as LicenseAgreementOptionsInputValues, LA_EDITOR_FORM} from './LicenseAgreementConstants.js'; +import { + enums as LicenseAgreementEnums, + optionsInputValues as LicenseAgreementOptionsInputValues, + LA_EDITOR_FORM +} from './LicenseAgreementConstants.js'; const dualBoxFilterTitle = { - left: i18n('Available Feature Groups'), - right: i18n('Selected Feature Groups') + left: i18n('Available Feature Groups'), + right: i18n('Selected Feature Groups') }; 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 + 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 ( - - - onDataChanged({name}, LA_EDITOR_FORM, { name: validateName })} - label={i18n('Name')} - value={name} - data-test-id='create-la-name' - name='license-agreement-name' - isRequired={true} - type='text'/> - onDataChanged({requirementsAndConstrains}, LA_EDITOR_FORM)} - label={i18n('Requirements and Constraints')} - value={requirementsAndConstrains} - data-test-id='create-la-requirements-constants' - name='license-agreement-requirements-and-constraints' - type='textarea'/> - {}} - isMultiSelect={false} - onEnumChange={licenseTerm => onDataChanged({licenseTerm:{choice: licenseTerm, other: ''}}, - LA_EDITOR_FORM)} - onOtherChange={licenseTerm => onDataChanged({licenseTerm:{choice: optionInputOther.OTHER, - other: licenseTerm}}, LA_EDITOR_FORM)} - label={i18n('License Term')} - data-test-id='create-la-license-term' - isRequired={true} - type='select' - selectedEnum={licenseTerm && licenseTerm.choice} - otherValue={licenseTerm && licenseTerm.other} - values={LicenseAgreementOptionsInputValues.LICENSE_MODEL_TYPE} - isValid={genericFieldInfo.licenseTerm.isValid} - errorText={genericFieldInfo.licenseTerm.errorText} /> - - - onDataChanged({description}, LA_EDITOR_FORM)} - label={i18n('Description')} - value={description} - overlayPos='bottom' - data-test-id='create-la-description' - name='license-agreement-description' - type='textarea'/> - - - ); +const GeneralTabContent = ({ + data, + genericFieldInfo, + onDataChanged, + validateName +}) => { + let { name, description, requirementsAndConstrains, licenseTerm } = data; + return ( + + + + onDataChanged({ name }, LA_EDITOR_FORM, { + name: validateName + }) + } + label={i18n('Name')} + value={name} + data-test-id="create-la-name" + name="license-agreement-name" + isRequired={true} + type="text" + /> + + onDataChanged( + { requirementsAndConstrains }, + LA_EDITOR_FORM + ) + } + label={i18n('Requirements and Constraints')} + value={requirementsAndConstrains} + data-test-id="create-la-requirements-constants" + name="license-agreement-requirements-and-constraints" + type="textarea" + /> + {}} + isMultiSelect={false} + onEnumChange={licenseTerm => + onDataChanged( + { licenseTerm: { choice: licenseTerm, other: '' } }, + LA_EDITOR_FORM + ) + } + onOtherChange={licenseTerm => + onDataChanged( + { + licenseTerm: { + choice: optionInputOther.OTHER, + other: licenseTerm + } + }, + LA_EDITOR_FORM + ) + } + label={i18n('License Term')} + data-test-id="create-la-license-term" + isRequired={true} + type="select" + selectedEnum={licenseTerm && licenseTerm.choice} + otherValue={licenseTerm && licenseTerm.other} + values={ + LicenseAgreementOptionsInputValues.LICENSE_MODEL_TYPE + } + isValid={genericFieldInfo.licenseTerm.isValid} + errorText={genericFieldInfo.licenseTerm.errorText} + /> + + + + onDataChanged({ description }, LA_EDITOR_FORM) + } + label={i18n('Description')} + value={description} + overlayPos="bottom" + data-test-id="create-la-description" + name="license-agreement-description" + type="textarea" + /> + + + ); }; class LicenseAgreementEditorView extends React.Component { + static propTypes = { + data: LicenseAgreementPropType, + previousData: LicenseAgreementPropType, + LANames: PropTypes.object, + isReadOnlyMode: PropTypes.bool, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired, - static propTypes = { - data: LicenseAgreementPropType, - previousData: LicenseAgreementPropType, - LANames: PropTypes.object, - isReadOnlyMode: PropTypes.bool, - onDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired, - - selectedTab: PropTypes.number, - onTabSelect: PropTypes.func, + selectedTab: PropTypes.number, + onTabSelect: PropTypes.func, - selectedFeatureGroupsButtonTab: PropTypes.number, - onFeatureGroupsButtonTabSelect: PropTypes.func, - featureGroupsList: DualListboxView.propTypes.availableList - }; + selectedFeatureGroupsButtonTab: PropTypes.number, + onFeatureGroupsButtonTabSelect: PropTypes.func, + featureGroupsList: DualListboxView.propTypes.availableList + }; - static defaultProps = { - selectedTab: LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB.GENERAL, - data: {} - }; + static defaultProps = { + selectedTab: + LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB.GENERAL, + data: {} + }; - state = { - localFeatureGroupsListFilter: '' - }; + state = { + localFeatureGroupsListFilter: '' + }; - render() { - let {selectedTab, onTabSelect, isReadOnlyMode, featureGroupsList, data, onDataChanged, genericFieldInfo} = this.props; - return ( -
    - {genericFieldInfo &&
    this.submit() } - onReset={ () => this.props.onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.props.onValidateForm(LA_EDITOR_FORM) } - className='license-model-form license-agreement-form'> - - -
    - this.validateLTChoice(value)} - validateName={(value)=>this.validateName(value)}/> -
    -
    - -
    - {featureGroupsList.length > 0 ? - onDataChanged( { featureGroupsIds: selectedValuesList }, LA_EDITOR_FORM )}/> : -

    {i18n('There are no available feature groups')}

    } -
    -
    -
    -
    } -
    - ); - } + render() { + let { + selectedTab, + onTabSelect, + isReadOnlyMode, + featureGroupsList, + data, + onDataChanged, + genericFieldInfo + } = this.props; + return ( +
    + {genericFieldInfo && ( +
    this.submit()} + onReset={() => this.props.onCancel()} + labledButtons={true} + isReadOnlyMode={isReadOnlyMode} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => + this.props.onValidateForm(LA_EDITOR_FORM) + } + className="license-model-form license-agreement-form"> + + +
    + + this.validateLTChoice(value) + } + validateName={value => + this.validateName(value) + } + /> +
    +
    + +
    + {featureGroupsList.length > 0 ? ( + + onDataChanged( + { + featureGroupsIds: selectedValuesList + }, + LA_EDITOR_FORM + ) + } + /> + ) : ( +

    + {i18n( + 'There are no available feature groups' + )} +

    + )} +
    +
    +
    +
    + )} +
    + ); + } - submit() { - const {data: licenseAgreement, previousData: previousLicenseAgreement} = this.props; - this.props.onSubmit({licenseAgreement, previousLicenseAgreement}); - } + submit() { + const { + data: licenseAgreement, + previousData: previousLicenseAgreement + } = this.props; + this.props.onSubmit({ licenseAgreement, previousLicenseAgreement }); + } - validateLTChoice(value) { - if (!value.choice) { - return {isValid: false, errorText: i18n('Field is required')}; - } - return {isValid: true, errorText: ''}; - } + 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; - const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: LANames}); + validateName(value) { + const { data: { id }, LANames } = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({ + itemId: id, + itemName: value, + list: LANames + }); - return !isExists ? {isValid: true, errorText: ''} : - {isValid: false, errorText: i18n('License Agreement by the name \'' + value + '\' already exists. License agreement name must be unique')}; - } + return !isExists + ? { isValid: true, errorText: '' } + : { + isValid: false, + errorText: i18n( + "License Agreement by the name '" + + value + + "' already exists. License agreement name must be unique" + ) + }; + } } export default LicenseAgreementEditorView; 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 72474ecdd3..cba39731b5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js @@ -13,42 +13,64 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import LicenseAgreementActionHelper from './LicenseAgreementActionHelper.js'; import LicenseAgreementListEditorView from './LicenseAgreementListEditorView.jsx'; -import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.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; - - return { - vendorName, - version, - licenseAgreementList, - isDisplayModal: Boolean(data), - isModalInEditMode: Boolean(data && data.id) - }; +const mapStateToProps = ({ + licenseModel: { licenseAgreement, licenseModelEditor } +}) => { + let { licenseAgreementList } = licenseAgreement; + let { data } = licenseAgreement.licenseAgreementEditor; + let { vendorName, version } = licenseModelEditor.data; + return { + vendorName, + version, + licenseAgreementList, + isDisplayModal: Boolean(data), + isModalInEditMode: Boolean(data && data.id) + }; }; -const mapActionsToProps = (dispatch, {licenseModelId}) => { - return { - onAddLicenseAgreementClick: (version) => LicenseAgreementActionHelper.openLicenseAgreementEditor(dispatch, {licenseModelId, version}), - onEditLicenseAgreementClick: (licenseAgreement, version) => LicenseAgreementActionHelper.openLicenseAgreementEditor(dispatch, {licenseModelId, licenseAgreement, version}), - onDeleteLicenseAgreement: (licenseAgreement, version) => dispatch({ - type: globalMoadlActions.GLOBAL_MODAL_WARNING, - data:{ - 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}) - } - }) - }; +const mapActionsToProps = (dispatch, { licenseModelId }) => { + return { + onAddLicenseAgreementClick: version => + LicenseAgreementActionHelper.openLicenseAgreementEditor(dispatch, { + licenseModelId, + version + }), + onEditLicenseAgreementClick: (licenseAgreement, version) => + LicenseAgreementActionHelper.openLicenseAgreementEditor(dispatch, { + licenseModelId, + licenseAgreement, + version + }), + onDeleteLicenseAgreement: (licenseAgreement, version) => + dispatch({ + type: globalMoadlActions.GLOBAL_MODAL_WARNING, + data: { + 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 + } + ) + } + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(LicenseAgreementListEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + LicenseAgreementListEditorView +); 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 ad3cdb0b58..acec1e0ddb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx @@ -21,107 +21,151 @@ import Modal from 'nfvo-components/modal/Modal.jsx'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import LicenseAgreementEditor from './LicenseAgreementEditor.js'; -import {extractValue} from './LicenseAgreementConstants'; +import { extractValue } from './LicenseAgreementConstants'; class LicenseAgreementListEditorView extends React.Component { - static propTypes = { - 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 propTypes = { + 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 = { - licenseAgreementList: [] - }; + static defaultProps = { + licenseAgreementList: [] + }; - state = { - localFilter: '' - }; + state = { + localFilter: '' + }; - render() { - const {licenseModelId, isReadOnlyMode, isDisplayModal, isModalInEditMode, version} = this.props; - const {onAddLicenseAgreementClick} = this.props; - const {localFilter} = this.state; + render() { + const { + licenseModelId, + isReadOnlyMode, + isDisplayModal, + isModalInEditMode, + version + } = this.props; + const { onAddLicenseAgreementClick } = this.props; + const { localFilter } = this.state; - return ( -
    - onAddLicenseAgreementClick(version)} - filterValue={localFilter} - onFilter={value => this.setState({localFilter: value})} - isReadOnlyMode={isReadOnlyMode}> - {this.filterList().map(licenseAgreement => this.renderLicenseAgreementListItem(licenseAgreement, isReadOnlyMode, version))} - - - - {`${isModalInEditMode ? i18n('Edit License Agreement') : i18n('Create New License Agreement')}`} - - - { - isDisplayModal && ( - - ) - } - - -
    - ); - } + return ( +
    + onAddLicenseAgreementClick(version)} + filterValue={localFilter} + onFilter={value => this.setState({ localFilter: value })} + isReadOnlyMode={isReadOnlyMode}> + {this.filterList().map(licenseAgreement => + this.renderLicenseAgreementListItem( + licenseAgreement, + isReadOnlyMode, + version + ) + )} + + + + {`${ + isModalInEditMode + ? i18n('Edit License Agreement') + : i18n('Create New License Agreement') + }`} + + + {isDisplayModal && ( + + )} + + +
    + ); + } - filterList() { - let {licenseAgreementList} = this.props; - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return licenseAgreementList.filter(({name = '', description = '', licenseTerm = ''}) => { - return escape(name).match(filter) || escape(description).match(filter) || escape(extractValue(licenseTerm)).match(filter); - }); - } - else { - return licenseAgreementList; - } - } + filterList() { + let { licenseAgreementList } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return licenseAgreementList.filter( + ({ name = '', description = '', licenseTerm = '' }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) || + escape(extractValue(licenseTerm)).match(filter) + ); + } + ); + } else { + return licenseAgreementList; + } + } - renderLicenseAgreementListItem(licenseAgreement, isReadOnlyMode, version) { - let {id, name, description, licenseTerm, featureGroupsIds = []} = licenseAgreement; - let {onEditLicenseAgreementClick, onDeleteLicenseAgreement} = this.props; - return ( - onEditLicenseAgreementClick(licenseAgreement, version)} - onDelete={() => onDeleteLicenseAgreement(licenseAgreement, version)} - className='list-editor-item-view' - isReadOnlyMode={isReadOnlyMode}> -
    -
    {i18n('Name')}
    -
    {name}
    -
    -
    -
    -
    {i18n('Type')}
    -
    {extractValue(licenseTerm)}
    -
    -
    -
    {i18n('Feature')}
    -
    {i18n('Groups')}
    -
    {featureGroupsIds.length}
    -
    -
    -
    -
    {i18n('Description')}
    -
    {description}
    -
    -
    - ); - } + renderLicenseAgreementListItem(licenseAgreement, isReadOnlyMode, version) { + let { + id, + name, + description, + licenseTerm, + featureGroupsIds = [] + } = licenseAgreement; + let { + onEditLicenseAgreementClick, + onDeleteLicenseAgreement + } = this.props; + return ( + + onEditLicenseAgreementClick(licenseAgreement, version) + } + onDelete={() => + onDeleteLicenseAgreement(licenseAgreement, version) + } + className="list-editor-item-view" + isReadOnlyMode={isReadOnlyMode}> +
    +
    {i18n('Name')}
    +
    {name}
    +
    +
    +
    +
    {i18n('Type')}
    +
    + {extractValue(licenseTerm)} +
    +
    +
    +
    {i18n('Feature')}
    +
    {i18n('Groups')}
    +
    + {featureGroupsIds.length} +
    +
    +
    +
    +
    {i18n('Description')}
    +
    {description}
    +
    +
    + ); + } } export default LicenseAgreementListEditorView; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListReducer.js index 7d1a5ef8ee..213a63d565 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListReducer.js @@ -13,15 +13,18 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes as licenseAgreementActionTypes} from './LicenseAgreementConstants'; +import { actionTypes as licenseAgreementActionTypes } from './LicenseAgreementConstants'; export default (state = [], action) => { - switch (action.type) { - case licenseAgreementActionTypes.LICENSE_AGREEMENT_LIST_LOADED: - return [...action.response.results]; - case licenseAgreementActionTypes.DELETE_LICENSE_AGREEMENT: - return state.filter(licenseAgreement => licenseAgreement.id !== action.licenseAgreementId); - default: - return state; - } + switch (action.type) { + case licenseAgreementActionTypes.LICENSE_AGREEMENT_LIST_LOADED: + return [...action.response.results]; + case licenseAgreementActionTypes.DELETE_LICENSE_AGREEMENT: + return state.filter( + licenseAgreement => + licenseAgreement.id !== action.licenseAgreementId + ); + default: + return state; + } }; 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 674c329515..ebbe84abd3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js @@ -15,191 +15,268 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes as licenseKeyGroupsConstants} from './LicenseKeyGroupsConstants.js'; -import {actionTypes as limitEditorActions} from 'sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js'; -import {default as getValue, getStrValue} from 'nfvo-utils/getValue.js'; +import { actionTypes as licenseKeyGroupsConstants } from './LicenseKeyGroupsConstants.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'); - const {id: versionId} = version; - return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/license-key-groups`; + const restPrefix = Configuration.get('restPrefix'); + const { id: versionId } = version; + return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/license-key-groups`; } function fetchLicenseKeyGroupsList(licenseModelId, version) { - return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } function deleteLicenseKeyGroup(licenseModelId, licenseKeyGroupId, version) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}`); + return RestAPIUtil.destroy( + `${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}` + ); } function postLicenseKeyGroup(licenseModelId, licenseKeyGroup, version) { - return RestAPIUtil.post(baseUrl(licenseModelId, version), { - name: licenseKeyGroup.name, - description: licenseKeyGroup.description, - operationalScope: getValue(licenseKeyGroup.operationalScope), - type: licenseKeyGroup.type, - increments: licenseKeyGroup.increments, - thresholdValue: licenseKeyGroup.thresholdValue, - thresholdUnits: getValue(licenseKeyGroup.thresholdUnits), - startDate: licenseKeyGroup.startDate, - expiryDate: licenseKeyGroup.expiryDate - }); + return RestAPIUtil.post(baseUrl(licenseModelId, version), { + name: licenseKeyGroup.name, + description: licenseKeyGroup.description, + operationalScope: getValue(licenseKeyGroup.operationalScope), + type: licenseKeyGroup.type, + increments: licenseKeyGroup.increments, + thresholdValue: licenseKeyGroup.thresholdValue, + thresholdUnits: getValue(licenseKeyGroup.thresholdUnits), + startDate: licenseKeyGroup.startDate, + expiryDate: licenseKeyGroup.expiryDate + }); } function putLicenseKeyGroup(licenseModelId, licenseKeyGroup, version) { - return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${licenseKeyGroup.id}`, { - name: licenseKeyGroup.name, - description: licenseKeyGroup.description, - operationalScope: getValue(licenseKeyGroup.operationalScope), - type: licenseKeyGroup.type, - increments: licenseKeyGroup.increments, - thresholdValue: licenseKeyGroup.thresholdValue, - thresholdUnits: getValue(licenseKeyGroup.thresholdUnits), - startDate: licenseKeyGroup.startDate, - expiryDate: licenseKeyGroup.expiryDate - }); + return RestAPIUtil.put( + `${baseUrl(licenseModelId, version)}/${licenseKeyGroup.id}`, + { + name: licenseKeyGroup.name, + description: licenseKeyGroup.description, + operationalScope: getValue(licenseKeyGroup.operationalScope), + type: licenseKeyGroup.type, + increments: licenseKeyGroup.increments, + thresholdValue: licenseKeyGroup.thresholdValue, + thresholdUnits: getValue(licenseKeyGroup.thresholdUnits), + startDate: licenseKeyGroup.startDate, + expiryDate: licenseKeyGroup.expiryDate + } + ); } function fetchLimitsList(licenseModelId, licenseKeyGroupId, version) { - return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits`); + return RestAPIUtil.fetch( + `${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits` + ); } function deleteLimit(licenseModelId, licenseKeyGroupId, version, limitId) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits/${limitId}`); + return RestAPIUtil.destroy( + `${baseUrl( + licenseModelId, + version + )}/${licenseKeyGroupId}/limits/${limitId}` + ); } function postLimit(licenseModelId, licenseKeyGroupId, version, limit) { - return RestAPIUtil.post(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits`, { - name: limit.name, - type: limit.type, - description: limit.description, - metric: getStrValue(limit.metric), - value: limit.value, - unit: getStrValue(limit.unit), - aggregationFunction: getValue(limit.aggregationFunction), - time: getValue(limit.time) - }); + return RestAPIUtil.post( + `${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits`, + { + name: limit.name, + type: limit.type, + description: limit.description, + metric: getStrValue(limit.metric), + value: limit.value, + unit: getStrValue(limit.unit), + aggregationFunction: getValue(limit.aggregationFunction), + time: getValue(limit.time) + } + ); } function putLimit(licenseModelId, licenseKeyGroupId, version, limit) { - - return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits/${limit.id}`, { - name: limit.name, - type: limit.type, - description: limit.description, - metric: getStrValue(limit.metric), - value: limit.value, - unit: getStrValue(limit.unit), - aggregationFunction: getValue(limit.aggregationFunction), - time: getValue(limit.time) - }); + return RestAPIUtil.put( + `${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}/limits/${ + limit.id + }`, + { + name: limit.name, + type: limit.type, + description: limit.description, + metric: getStrValue(limit.metric), + value: limit.value, + unit: getStrValue(limit.unit), + aggregationFunction: getValue(limit.aggregationFunction), + time: getValue(limit.time) + } + ); } export default { - fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}) { - return fetchLicenseKeyGroupsList(licenseModelId, version).then(response => dispatch({ - type: licenseKeyGroupsConstants.LICENSE_KEY_GROUPS_LIST_LOADED, - response - })); - }, - - openLicenseKeyGroupsEditor(dispatch, {licenseKeyGroup, licenseModelId, version} = {}) { - if (licenseModelId && version) { - this.fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}); - } - dispatch({ - type: licenseKeyGroupsConstants.licenseKeyGroupsEditor.OPEN, - licenseKeyGroup - }); - }, - - closeLicenseKeyGroupEditor(dispatch){ - dispatch({ - type: licenseKeyGroupsConstants.licenseKeyGroupsEditor.CLOSE - }); - }, - - saveLicenseKeyGroup(dispatch, {licenseModelId, previousLicenseKeyGroup, licenseKeyGroup, version}) { - if (previousLicenseKeyGroup) { - return putLicenseKeyGroup(licenseModelId, licenseKeyGroup, version).then(() => { - dispatch({ - type: licenseKeyGroupsConstants.EDIT_LICENSE_KEY_GROUP, - licenseKeyGroup - }); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } - else { - return postLicenseKeyGroup(licenseModelId, licenseKeyGroup, version).then(response => { - dispatch({ - type: licenseKeyGroupsConstants.ADD_LICENSE_KEY_GROUP, - licenseKeyGroup: { - ...licenseKeyGroup, - referencingFeatureGroups: [], - id: response.value - } - }); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } - - - }, - - deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId, version}){ - return deleteLicenseKeyGroup(licenseModelId, licenseKeyGroupId, version).then(()=> { - dispatch({ - type: licenseKeyGroupsConstants.DELETE_LICENSE_KEY_GROUP, - licenseKeyGroupId - }); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - }, - - hideDeleteConfirm(dispatch) { - dispatch({ - type: licenseKeyGroupsConstants.LICENSE_KEY_GROUPS_DELETE_CONFIRM, - licenseKeyGroupToDelete: false - }); - }, - - openDeleteLicenseAgreementConfirm(dispatch, {licenseKeyGroup}) { - dispatch({ - type: licenseKeyGroupsConstants.LICENSE_KEY_GROUPS_DELETE_CONFIRM, - licenseKeyGroupToDelete: licenseKeyGroup - }); - }, - - - fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}) { - return fetchLimitsList(licenseModelId, licenseKeyGroup.id, version).then(response => { - dispatch({ - type: licenseKeyGroupsConstants.licenseKeyGroupsEditor.LIMITS_LIST_LOADED, - response - }); - }); - }, - - submitLimit(dispatch, {licenseModelId, version, licenseKeyGroup, limit}) { - const promise = limit.id ? putLimit(licenseModelId,licenseKeyGroup.id, version, limit) : - postLimit(licenseModelId,licenseKeyGroup.id, version, limit); - return promise.then(() => { - dispatch({ - type: limitEditorActions.CLOSE - }); - this.fetchLimits(dispatch, {licenseModelId, version, licenseKeyGroup}); - return 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}); - return ItemsHelper.checkItemStatus(dispatch, {itemId: licenseModelId, versionId: version.id}); - }); - } + fetchLicenseKeyGroupsList(dispatch, { licenseModelId, version }) { + return fetchLicenseKeyGroupsList(licenseModelId, version).then( + response => + dispatch({ + type: + licenseKeyGroupsConstants.LICENSE_KEY_GROUPS_LIST_LOADED, + response + }) + ); + }, + + openLicenseKeyGroupsEditor( + dispatch, + { licenseKeyGroup, licenseModelId, version } = {} + ) { + if (licenseModelId && version) { + this.fetchLimits(dispatch, { + licenseModelId, + version, + licenseKeyGroup + }); + } + dispatch({ + type: licenseKeyGroupsConstants.licenseKeyGroupsEditor.OPEN, + licenseKeyGroup + }); + }, + + closeLicenseKeyGroupEditor(dispatch) { + dispatch({ + type: licenseKeyGroupsConstants.licenseKeyGroupsEditor.CLOSE + }); + }, + + saveLicenseKeyGroup( + dispatch, + { licenseModelId, previousLicenseKeyGroup, licenseKeyGroup, version } + ) { + if (previousLicenseKeyGroup) { + return putLicenseKeyGroup( + licenseModelId, + licenseKeyGroup, + version + ).then(() => { + dispatch({ + type: licenseKeyGroupsConstants.EDIT_LICENSE_KEY_GROUP, + licenseKeyGroup + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + } else { + return postLicenseKeyGroup( + licenseModelId, + licenseKeyGroup, + version + ).then(response => { + dispatch({ + type: licenseKeyGroupsConstants.ADD_LICENSE_KEY_GROUP, + licenseKeyGroup: { + ...licenseKeyGroup, + referencingFeatureGroups: [], + id: response.value + } + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + } + }, + + deleteLicenseKeyGroup( + dispatch, + { licenseModelId, licenseKeyGroupId, version } + ) { + return deleteLicenseKeyGroup( + licenseModelId, + licenseKeyGroupId, + version + ).then(() => { + dispatch({ + type: licenseKeyGroupsConstants.DELETE_LICENSE_KEY_GROUP, + licenseKeyGroupId + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + }, + + hideDeleteConfirm(dispatch) { + dispatch({ + type: licenseKeyGroupsConstants.LICENSE_KEY_GROUPS_DELETE_CONFIRM, + licenseKeyGroupToDelete: false + }); + }, + + openDeleteLicenseAgreementConfirm(dispatch, { licenseKeyGroup }) { + dispatch({ + type: licenseKeyGroupsConstants.LICENSE_KEY_GROUPS_DELETE_CONFIRM, + licenseKeyGroupToDelete: licenseKeyGroup + }); + }, + + fetchLimits(dispatch, { licenseModelId, version, licenseKeyGroup }) { + return fetchLimitsList( + licenseModelId, + licenseKeyGroup.id, + version + ).then(response => { + dispatch({ + type: + licenseKeyGroupsConstants.licenseKeyGroupsEditor + .LIMITS_LIST_LOADED, + response + }); + }); + }, + submitLimit(dispatch, { licenseModelId, version, licenseKeyGroup, limit }) { + const promise = limit.id + ? putLimit(licenseModelId, licenseKeyGroup.id, version, limit) + : postLimit(licenseModelId, licenseKeyGroup.id, version, limit); + return promise.then(() => { + dispatch({ + type: limitEditorActions.CLOSE + }); + this.fetchLimits(dispatch, { + licenseModelId, + version, + licenseKeyGroup + }); + return 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 + }); + return ItemsHelper.checkItemStatus(dispatch, { + itemId: licenseModelId, + versionId: version.id + }); + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js index c376cb3fbc..aad0a0b1fb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js @@ -15,73 +15,88 @@ */ import keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import InputOptions, { + other as optionInputOther +} from 'nfvo-components/input/validation/InputOptions.jsx'; export const actionTypes = keyMirror({ - - LICENSE_KEY_GROUPS_LIST_LOADED: null, - DELETE_LICENSE_KEY_GROUP: null, - EDIT_LICENSE_KEY_GROUP: null, - ADD_LICENSE_KEY_GROUP: null, - LICENSE_KEY_GROUPS_DELETE_CONFIRM: null, - licenseKeyGroupsEditor: { - OPEN: null, - CLOSE: null, - DATA_CHANGED: null, - LIMITS_LIST_LOADED: null - } + LICENSE_KEY_GROUPS_LIST_LOADED: null, + DELETE_LICENSE_KEY_GROUP: null, + EDIT_LICENSE_KEY_GROUP: null, + ADD_LICENSE_KEY_GROUP: null, + LICENSE_KEY_GROUPS_DELETE_CONFIRM: null, + licenseKeyGroupsEditor: { + OPEN: null, + CLOSE: null, + DATA_CHANGED: null, + LIMITS_LIST_LOADED: null + } }); export const defaultState = { - licenseKeyGroupsEditor: { - type: '', - operationalScope: {choices: [], other: ''} - } + licenseKeyGroupsEditor: { + type: '', + operationalScope: { choices: [], other: '' } + } }; export const LKG_FORM_NAME = 'LKGFORM'; export const optionsInputValues = { - OPERATIONAL_SCOPE: [ - {enum: '', title: i18n('please select…')}, - {enum: 'Network_Wide', title: 'Network Wide'}, - {enum: 'Availability_Zone', title: 'Availability Zone'}, - {enum: 'Data_Center', title: 'Data Center'}, - {enum: 'Tenant', title: 'Tenant'}, - {enum: 'VM', title: 'VM'}, - {enum: 'CPU', title: 'CPU'}, - {enum: 'Core', title: 'Core'} - ], - TYPE: [ - {enum: '', title: i18n('please select…')}, - {enum: 'Universal', title: 'Universal'}, - {enum: 'Unique', title: 'Unique'}, - {enum: 'One_Time', title: 'One Time'} - ] + OPERATIONAL_SCOPE: [ + { enum: '', title: i18n('please select…') }, + { enum: 'Network_Wide', title: 'Network Wide' }, + { enum: 'Availability_Zone', title: 'Availability Zone' }, + { enum: 'Data_Center', title: 'Data Center' }, + { enum: 'Tenant', title: 'Tenant' }, + { enum: 'VM', title: 'VM' }, + { enum: 'CPU', title: 'CPU' }, + { enum: 'Core', title: 'Core' } + ], + TYPE: [ + { enum: '', title: i18n('please select…') }, + { enum: 'Universal', title: 'Universal' }, + { enum: 'Unique', title: 'Unique' }, + { enum: 'One_Time', title: 'One Time' } + ] }; -export const extractValue = (item) => { - if (item === undefined) {return '';} //TODO fix it later +export const extractValue = item => { + if (item === undefined) { + return ''; + } //TODO fix it later - return item ? item === optionInputOther.OTHER ? item : InputOptions.getTitleByName(optionsInputValues, item) : ''; + return item + ? item === optionInputOther.OTHER + ? item + : InputOptions.getTitleByName(optionsInputValues, item) + : ''; }; -export const getOperationalScopes = (operationalScope) => { - if(operationalScope.choices.toString() === i18n(optionInputOther.OTHER) && operationalScope.other !== '') { - return operationalScope.other; - } - else { - let allOpScopes = ''; - for (let opScope of operationalScope.choices) { - allOpScopes += allOpScopes === '' ? InputOptions.getTitleByName(optionsInputValues, opScope) : `, ${InputOptions.getTitleByName(optionsInputValues, opScope)}`; - } - return allOpScopes; - } +export const getOperationalScopes = operationalScope => { + if ( + operationalScope.choices.toString() === i18n(optionInputOther.OTHER) && + operationalScope.other !== '' + ) { + return operationalScope.other; + } else { + let allOpScopes = ''; + for (let opScope of operationalScope.choices) { + allOpScopes += + allOpScopes === '' + ? InputOptions.getTitleByName(optionsInputValues, opScope) + : `, ${InputOptions.getTitleByName( + optionsInputValues, + opScope + )}`; + } + return allOpScopes; + } }; export const tabIds = { - GENERAL: 'GENERAL', - SP_LIMITS: 'SP_LIMITS', - VENDOR_LIMITS: 'VENDOR_LIMITS', - ADD_LIMIT_BUTTON: 'ADD_LIMIT_BUTTON' + GENERAL: 'GENERAL', + SP_LIMITS: 'SP_LIMITS', + VENDOR_LIMITS: 'VENDOR_LIMITS', + ADD_LIMIT_BUTTON: 'ADD_LIMIT_BUTTON' }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js index 028fa9d3e4..fa62bba669 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js @@ -13,53 +13,79 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; import LicenseKeyGroupsEditorView from './LicenseKeyGroupsEditorView.jsx'; import LimitEditorActionHelper from '../limits/LimitEditorActionHelper.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -const mapStateToProps = ({licenseModel: {licenseKeyGroup}}) => { +const mapStateToProps = ({ licenseModel: { licenseKeyGroup } }) => { + let { + data, + genericFieldInfo, + formReady, + limitsList + } = licenseKeyGroup.licenseKeyGroupsEditor; + let previousData, + LKGNames = {}; + const licenseKeyGroupId = data ? data.id : null; + if (licenseKeyGroupId) { + previousData = licenseKeyGroup.licenseKeyGroupsList.find( + licenseKeyGroup => licenseKeyGroup.id === licenseKeyGroupId + ); + } - let {data, genericFieldInfo, formReady, limitsList} = licenseKeyGroup.licenseKeyGroupsEditor; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - let previousData, LKGNames = {}; - const licenseKeyGroupId = data ? data.id : null; - if(licenseKeyGroupId) { - previousData = licenseKeyGroup.licenseKeyGroupsList.find(licenseKeyGroup => licenseKeyGroup.id === licenseKeyGroupId); - } + const list = licenseKeyGroup.licenseKeyGroupsList; + for (let i = 0; i < list.length; i++) { + LKGNames[list[i].name.toLowerCase()] = list[i].id; + } - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - - const list = licenseKeyGroup.licenseKeyGroupsList; - for (let i = 0; i < list.length; i++) { - LKGNames[list[i].name.toLowerCase()] = list[i].id; - } - - return { - data, - previousData, - genericFieldInfo, - isFormValid, - formReady, - LKGNames, - limitsList - }; + return { + data, + previousData, + genericFieldInfo, + isFormValid, + formReady, + LKGNames, + limitsList + }; }; -const mapActionsToProps = (dispatch, {licenseModelId, version}) => { - return { - onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), - onCancel: () => LicenseKeyGroupsActionHelper.closeLicenseKeyGroupEditor(dispatch), - onSubmit: ({previousLicenseKeyGroup, licenseKeyGroup, keepOpen}) => { - if (!keepOpen) {LicenseKeyGroupsActionHelper.closeLicenseKeyGroupEditor(dispatch);} - LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(dispatch, {licenseModelId, previousLicenseKeyGroup, licenseKeyGroup, version}); - }, - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName), - onCloseLimitEditor: () => LimitEditorActionHelper.closeLimitsEditor(dispatch), - onOpenLimitEditor: (limit) => LimitEditorActionHelper.openLimitsEditor(dispatch, {limit}) - }; +const mapActionsToProps = (dispatch, { licenseModelId, version }) => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onCancel: () => + LicenseKeyGroupsActionHelper.closeLicenseKeyGroupEditor(dispatch), + onSubmit: ({ previousLicenseKeyGroup, licenseKeyGroup, keepOpen }) => { + if (!keepOpen) { + LicenseKeyGroupsActionHelper.closeLicenseKeyGroupEditor( + dispatch + ); + } + LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(dispatch, { + licenseModelId, + previousLicenseKeyGroup, + licenseKeyGroup, + version + }); + }, + onValidateForm: formName => + ValidationHelper.validateForm(dispatch, formName), + onCloseLimitEditor: () => + LimitEditorActionHelper.closeLimitsEditor(dispatch), + onOpenLimitEditor: limit => + LimitEditorActionHelper.openLimitsEditor(dispatch, { limit }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(LicenseKeyGroupsEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + LicenseKeyGroupsEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js index b1a22f3d9a..e948e9cef8 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js @@ -13,82 +13,97 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, defaultState, LKG_FORM_NAME} from './LicenseKeyGroupsConstants.js'; +import { + actionTypes, + defaultState, + LKG_FORM_NAME +} from './LicenseKeyGroupsConstants.js'; import moment from 'moment'; -import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { DATE_FORMAT } from 'sdc-app/onboarding/OnboardingConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.licenseKeyGroupsEditor.OPEN: - let licenseKeyGroupData = {...action.licenseKeyGroup}; - let {startDate, expiryDate} = licenseKeyGroupData; - if (startDate) { - licenseKeyGroupData.startDate = moment(startDate, DATE_FORMAT).format(DATE_FORMAT); - } - if (expiryDate) { - licenseKeyGroupData.expiryDate = moment(expiryDate, DATE_FORMAT).format(DATE_FORMAT); - } - return { - ...state, - data: action.licenseKeyGroup ? licenseKeyGroupData : defaultState.licenseKeyGroupsEditor, - formReady: null, - formName: LKG_FORM_NAME, - genericFieldInfo: { - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}] - }, - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}] - }, - 'type' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - }, - 'operationalScope' : { - isValid: true, - errorText: '', - validations: [] - }, - 'thresholdUnits' : { - isValid: true, - errorText: '', - validations: [] - }, - 'thresholdValue' : { - isValid: true, - errorText: '', - validations: [] - }, - 'increments' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 120}] - }, - 'startDate': { - isValid: true, - errorText: '', - validations: [] - }, - 'expiryDate': { - isValid: true, - errorText: '', - validations: [] - } - } - }; - case actionTypes.licenseKeyGroupsEditor.LIMITS_LIST_LOADED: - return { - ...state, - limitsList: action.response.results - }; - case actionTypes.licenseKeyGroupsEditor.CLOSE: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.licenseKeyGroupsEditor.OPEN: + let licenseKeyGroupData = { ...action.licenseKeyGroup }; + let { startDate, expiryDate } = licenseKeyGroupData; + if (startDate) { + licenseKeyGroupData.startDate = moment( + startDate, + DATE_FORMAT + ).format(DATE_FORMAT); + } + if (expiryDate) { + licenseKeyGroupData.expiryDate = moment( + expiryDate, + DATE_FORMAT + ).format(DATE_FORMAT); + } + return { + ...state, + data: action.licenseKeyGroup + ? licenseKeyGroupData + : defaultState.licenseKeyGroupsEditor, + formReady: null, + formName: LKG_FORM_NAME, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }] + }, + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 120 } + ] + }, + type: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + }, + operationalScope: { + isValid: true, + errorText: '', + validations: [] + }, + thresholdUnits: { + isValid: true, + errorText: '', + validations: [] + }, + thresholdValue: { + isValid: true, + errorText: '', + validations: [] + }, + increments: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 120 }] + }, + startDate: { + isValid: true, + errorText: '', + validations: [] + }, + expiryDate: { + isValid: true, + errorText: '', + validations: [] + } + } + }; + case actionTypes.licenseKeyGroupsEditor.LIMITS_LIST_LOADED: + return { + ...state, + limitsList: action.response.results + }; + case actionTypes.licenseKeyGroupsEditor.CLOSE: + return {}; + default: + return state; + } }; 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 7cbab61a8a..a820f28dfd 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx @@ -26,328 +26,498 @@ import Form from 'nfvo-components/input/validation/Form.jsx'; import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {optionsInputValues as licenseKeyGroupOptionsInputValues, LKG_FORM_NAME, tabIds} from './LicenseKeyGroupsConstants.js'; -import {optionsInputValues as LicenseModelOptionsInputValues} from '../LicenseModelConstants.js'; -import {validateStartDate, thresholdValueValidation} from '../LicenseModelValidations.js'; -import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { + optionsInputValues as licenseKeyGroupOptionsInputValues, + LKG_FORM_NAME, + tabIds +} from './LicenseKeyGroupsConstants.js'; +import { optionsInputValues as LicenseModelOptionsInputValues } from '../LicenseModelConstants.js'; +import { + validateStartDate, + thresholdValueValidation +} from '../LicenseModelValidations.js'; +import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx'; import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; -import {DATE_FORMAT} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { DATE_FORMAT } from 'sdc-app/onboarding/OnboardingConstants.js'; import LicenseKeyGroupsLimits from './LicenseKeyGroupsLimits.js'; -import {limitType, NEW_LIMIT_TEMP_ID} from '../limits/LimitEditorConstants.js'; +import { + limitType, + NEW_LIMIT_TEMP_ID +} from '../limits/LimitEditorConstants.js'; - 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: PropTypes.string, - thresholdUnits: PropTypes.string, - thresholdValue: PropTypes.number, - startDate: PropTypes.string, - expiryDate: 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: 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 ( - - - onDataChanged({name}, LKG_FORM_NAME, {name: validateName})} - label={i18n('Name')} - data-test-id='create-lkg-name' - value={name} - isValid={genericFieldInfo.name.isValid} - errorText={genericFieldInfo.name.errorText} - isRequired={true} - type='text'/> - - - {}} - isMultiSelect={true} - onEnumChange={operationalScope => onDataChanged({operationalScope:{choices: operationalScope, other: ''}}, - LKG_FORM_NAME)} - onOtherChange={operationalScope => onDataChanged({operationalScope:{choices: [optionInputOther.OTHER], - other: operationalScope}}, LKG_FORM_NAME)} - label={i18n('Operational Scope')} - data-test-id='create-lkg-operational-scope' - type='select' - multiSelectedEnum={operationalScope && operationalScope.choices} - otherValue={operationalScope && operationalScope.other} - values={licenseKeyGroupOptionsInputValues.OPERATIONAL_SCOPE} - isValid={genericFieldInfo.operationalScope.isValid} - errorText={genericFieldInfo.operationalScope.errorText} /> - - - onDataChanged({description}, LKG_FORM_NAME)} - label={i18n('Description')} - data-test-id='create-lkg-description' - value={description} - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} - type='textarea' - overlayPos='bottom' /> - - - { const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onDataChanged({type: val}, LKG_FORM_NAME);}} - value={type} - label={i18n('Type')} - data-test-id='create-lkg-type' - isValid={genericFieldInfo.type.isValid} - errorText={genericFieldInfo.type.errorText} - groupClassName='bootstrap-input-options' - className='input-options-select' - overlayPos='bottom' - type='select' > - { - licenseKeyGroupOptionsInputValues.TYPE.map(type => - ()) - } - - - - { - // setting the unit to the correct value - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onDataChanged({thresholdUnits: val}, LKG_FORM_NAME); - // TODO make sure that the value is valid too - onDataChanged({thresholdValue: thresholdValue}, LKG_FORM_NAME,{thresholdValue : thresholdValueValidation});} - - } - value={thresholdUnits} - label={i18n('Threshold Units')} - data-test-id='create-ep-threshold-units' - isValid={genericFieldInfo.thresholdUnits.isValid} - errorText={genericFieldInfo.thresholdUnits.errorText} - groupClassName='bootstrap-input-options' - className='input-options-select' - type='select' > - {LicenseModelOptionsInputValues.THRESHOLD_UNITS.map(mtype => - )} - - - - onDataChanged({thresholdValue}, LKG_FORM_NAME, - {thresholdValue : thresholdValueValidation})} - label={i18n('Threshold Value')} - isValid={genericFieldInfo.thresholdValue.isValid} - errorText={genericFieldInfo.thresholdValue.errorText} - data-test-id='create-ep-threshold-value' - value={thresholdValue} - type='text'/> - - - onDataChanged( - {startDate: startDate ? startDate.format(DATE_FORMAT) : ''}, - LKG_FORM_NAME, - {startDate: validateStartDate} - )} - isValid={genericFieldInfo.startDate.isValid} - errorText={genericFieldInfo.startDate.errorText} - selectsStart/> - - - { - onDataChanged({expiryDate: expiryDate ? expiryDate.format(DATE_FORMAT) : ''}, LKG_FORM_NAME); - onDataChanged({startDate}, LKG_FORM_NAME, {startDate: validateStartDate}); - }} - isValid={genericFieldInfo.expiryDate.isValid} - errorText={genericFieldInfo.expiryDate.errorText} - selectsEnd/> - - - onDataChanged({increments}, LKG_FORM_NAME)} - label={i18n('Increments')} - value={increments} - data-test-id='create-ep-increments' - type='text'/> - - - ); +const LicenseKeyGroupFormContent = ({ + data, + onDataChanged, + genericFieldInfo, + validateName, + validateStartDate, + thresholdValueValidation +}) => { + let { + name, + description, + increments, + operationalScope, + type, + thresholdUnits, + thresholdValue, + startDate, + expiryDate + } = data; + return ( + + + + onDataChanged({ name }, LKG_FORM_NAME, { + name: validateName + }) + } + label={i18n('Name')} + data-test-id="create-lkg-name" + value={name} + isValid={genericFieldInfo.name.isValid} + errorText={genericFieldInfo.name.errorText} + isRequired={true} + type="text" + /> + + + {}} + isMultiSelect={true} + onEnumChange={operationalScope => + onDataChanged( + { + operationalScope: { + choices: operationalScope, + other: '' + } + }, + LKG_FORM_NAME + ) + } + onOtherChange={operationalScope => + onDataChanged( + { + operationalScope: { + choices: [optionInputOther.OTHER], + other: operationalScope + } + }, + LKG_FORM_NAME + ) + } + label={i18n('Operational Scope')} + data-test-id="create-lkg-operational-scope" + type="select" + multiSelectedEnum={ + operationalScope && operationalScope.choices + } + otherValue={operationalScope && operationalScope.other} + values={licenseKeyGroupOptionsInputValues.OPERATIONAL_SCOPE} + isValid={genericFieldInfo.operationalScope.isValid} + errorText={genericFieldInfo.operationalScope.errorText} + /> + + + + onDataChanged({ description }, LKG_FORM_NAME) + } + label={i18n('Description')} + data-test-id="create-lkg-description" + value={description} + isValid={genericFieldInfo.description.isValid} + errorText={genericFieldInfo.description.errorText} + type="textarea" + overlayPos="bottom" + /> + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onDataChanged({ type: val }, LKG_FORM_NAME); + }} + value={type} + label={i18n('Type')} + data-test-id="create-lkg-type" + isValid={genericFieldInfo.type.isValid} + errorText={genericFieldInfo.type.errorText} + groupClassName="bootstrap-input-options" + className="input-options-select" + overlayPos="bottom" + type="select"> + {licenseKeyGroupOptionsInputValues.TYPE.map(type => ( + + ))} + + + + { + // setting the unit to the correct value + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onDataChanged({ thresholdUnits: val }, LKG_FORM_NAME); + // TODO make sure that the value is valid too + onDataChanged( + { thresholdValue: thresholdValue }, + LKG_FORM_NAME, + { + thresholdValue: thresholdValueValidation + } + ); + }} + value={thresholdUnits} + label={i18n('Threshold Units')} + data-test-id="create-ep-threshold-units" + isValid={genericFieldInfo.thresholdUnits.isValid} + errorText={genericFieldInfo.thresholdUnits.errorText} + groupClassName="bootstrap-input-options" + className="input-options-select" + type="select"> + {LicenseModelOptionsInputValues.THRESHOLD_UNITS.map( + mtype => ( + + ) + )} + + + + + onDataChanged({ thresholdValue }, LKG_FORM_NAME, { + thresholdValue: thresholdValueValidation + }) + } + label={i18n('Threshold Value')} + isValid={genericFieldInfo.thresholdValue.isValid} + errorText={genericFieldInfo.thresholdValue.errorText} + data-test-id="create-ep-threshold-value" + value={thresholdValue} + type="text" + /> + + + + onDataChanged( + { + startDate: startDate + ? startDate.format(DATE_FORMAT) + : '' + }, + LKG_FORM_NAME, + { startDate: validateStartDate } + ) + } + isValid={genericFieldInfo.startDate.isValid} + errorText={genericFieldInfo.startDate.errorText} + selectsStart + /> + + + { + onDataChanged( + { + expiryDate: expiryDate + ? expiryDate.format(DATE_FORMAT) + : '' + }, + LKG_FORM_NAME + ); + onDataChanged({ startDate }, LKG_FORM_NAME, { + startDate: validateStartDate + }); + }} + isValid={genericFieldInfo.expiryDate.isValid} + errorText={genericFieldInfo.expiryDate.errorText} + selectsEnd + /> + + + + onDataChanged({ increments }, LKG_FORM_NAME) + } + label={i18n('Increments')} + value={increments} + data-test-id="create-ep-increments" + type="text" + /> + + + ); }; class LicenseKeyGroupsEditorView extends React.Component { - static propTypes = { - data: LicenseKeyGroupPropType, - previousData: LicenseKeyGroupPropType, - LKGNames: PropTypes.object, - isReadOnlyMode: PropTypes.bool, - onDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired - }; - - static defaultProps = { - data: {} - }; - - componentDidUpdate(prevProps) { - if (this.props.formReady && this.props.formReady !== prevProps.formReady) { // if form validation succeeded -> continue with submit - this.submit(); - } - } + static propTypes = { + data: LicenseKeyGroupPropType, + previousData: LicenseKeyGroupPropType, + LKGNames: PropTypes.object, + isReadOnlyMode: PropTypes.bool, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired + }; - state = { - localFeatureGroupsListFilter: '', - selectedTab: tabIds.GENERAL, - selectedLimit: '' - }; + static defaultProps = { + data: {} + }; - render() { - let {data = {}, onDataChanged, isReadOnlyMode, onCloseLimitEditor, genericFieldInfo, limitsList = []} = this.props; - let {selectedTab} = this.state; - const isTabsDisabled = !data.id || !this.props.isFormValid; - return ( -
    - { - if (tabIndex === tabIds.ADD_LIMIT_BUTTON) { - this.onAddLimit(); - } else { - this.setState({selectedTab: tabIndex}); - onCloseLimitEditor(); - this.setState({selectedLimit: ''}); - } - }} - invalidTabs={[]}> - - { genericFieldInfo && -
    this.props.onValidateForm(LKG_FORM_NAME) } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - className='license-model-form license-key-groups-form'> - this.validateName(value)} - validateStartDate={(value, state)=> validateStartDate(value, state)} - thresholdValueValidation={(value, state) => thresholdValueValidation(value, state)}/> - } + componentDidUpdate(prevProps) { + if ( + this.props.formReady && + this.props.formReady !== prevProps.formReady + ) { + // if form validation succeeded -> continue with submit + this.submit(); + } + } -
    - - {selectedTab === tabIds.SP_LIMITS && - item.type === limitType.SERVICE_PROVIDER)} - selectedLimit={this.state.selectedLimit} - onCloseLimitEditor={() => this.onCloseLimitEditor()} - onSelectLimit={limit => this.onSelectLimit(limit)} - isReadOnlyMode={isReadOnlyMode} />} - - - {selectedTab === tabIds.VENDOR_LIMITS && - item.type === limitType.VENDOR)} - selectedLimit={this.state.selectedLimit} - onCloseLimitEditor={() => this.onCloseLimitEditor()} - onSelectLimit={limit => this.onSelectLimit(limit)} - isReadOnlyMode={isReadOnlyMode} />} - - {selectedTab !== tabIds.GENERAL ? - - : -
    // Render empty div to not break tabs - } -
    + state = { + localFeatureGroupsListFilter: '', + selectedTab: tabIds.GENERAL, + selectedLimit: '' + }; - - {!this.state.selectedLimit && - - } - - -
    + render() { + let { + data = {}, + onDataChanged, + isReadOnlyMode, + onCloseLimitEditor, + genericFieldInfo, + limitsList = [] + } = this.props; + let { selectedTab } = this.state; + const isTabsDisabled = !data.id || !this.props.isFormValid; + return ( +
    + { + if (tabIndex === tabIds.ADD_LIMIT_BUTTON) { + this.onAddLimit(); + } else { + this.setState({ selectedTab: tabIndex }); + onCloseLimitEditor(); + this.setState({ selectedLimit: '' }); + } + }} + invalidTabs={[]}> + + {genericFieldInfo && ( +
    + this.props.onValidateForm(LKG_FORM_NAME) + } + labledButtons={true} + isReadOnlyMode={isReadOnlyMode} + className="license-model-form license-key-groups-form"> + + this.validateName(value) + } + validateStartDate={(value, state) => + validateStartDate(value, state) + } + thresholdValueValidation={(value, state) => + thresholdValueValidation(value, state) + } + /> + + )} +
    + + {selectedTab === tabIds.SP_LIMITS && ( + + item.type === limitType.SERVICE_PROVIDER + )} + selectedLimit={this.state.selectedLimit} + onCloseLimitEditor={() => + this.onCloseLimitEditor() + } + onSelectLimit={limit => + this.onSelectLimit(limit) + } + isReadOnlyMode={isReadOnlyMode} + /> + )} + + + {selectedTab === tabIds.VENDOR_LIMITS && ( + item.type === limitType.VENDOR + )} + selectedLimit={this.state.selectedLimit} + onCloseLimitEditor={() => + this.onCloseLimitEditor() + } + onSelectLimit={limit => + this.onSelectLimit(limit) + } + isReadOnlyMode={isReadOnlyMode} + /> + )} + + {selectedTab !== tabIds.GENERAL ? ( + + ) : ( +
    + ) // Render empty div to not break tabs + } + - ); - } + + {!this.state.selectedLimit && ( + + )} + + +
    + ); + } - submit() { - const {data: licenseKeyGroup, previousData: previousLicenseKeyGroup, formReady, onValidateForm, onSubmit} = this.props; - if (!formReady) { - onValidateForm(LKG_FORM_NAME); - } else { - onSubmit({licenseKeyGroup, previousLicenseKeyGroup}); - } - } + submit() { + const { + data: licenseKeyGroup, + previousData: previousLicenseKeyGroup, + formReady, + onValidateForm, + onSubmit + } = this.props; + if (!formReady) { + onValidateForm(LKG_FORM_NAME); + } else { + onSubmit({ licenseKeyGroup, previousLicenseKeyGroup }); + } + } - validateName(value) { - const {data: {id}, LKGNames} = this.props; - const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: LKGNames}); + validateName(value) { + const { data: { id }, LKGNames } = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({ + itemId: id, + itemName: value, + list: LKGNames + }); - return !isExists ? {isValid: true, errorText: ''} : - {isValid: false, errorText: i18n('License key group by the name \'' + value + '\' already exists. License key group name must be unique')}; - } + return !isExists + ? { isValid: true, errorText: '' } + : { + isValid: false, + errorText: i18n( + "License key group by the name '" + + value + + "' already exists. License key group name must be unique" + ) + }; + } - onSelectLimit(limit) { - if (limit.id === this.state.selectedLimit) { - this.setState({selectedLimit: ''}); - return; - } - this.setState({selectedLimit: limit.id}); - this.props.onOpenLimitEditor(limit); - } + onSelectLimit(limit) { + if (limit.id === this.state.selectedLimit) { + this.setState({ selectedLimit: '' }); + return; + } + this.setState({ selectedLimit: limit.id }); + this.props.onOpenLimitEditor(limit); + } - onCloseLimitEditor() { - this.setState({selectedLimit: ''}); - this.props.onCloseLimitEditor(); - } + onCloseLimitEditor() { + this.setState({ selectedLimit: '' }); + this.props.onCloseLimitEditor(); + } - onAddLimit() { - this.setState({selectedLimit: NEW_LIMIT_TEMP_ID}); - this.props.onOpenLimitEditor(); - } + onAddLimit() { + this.setState({ selectedLimit: NEW_LIMIT_TEMP_ID }); + this.props.onOpenLimitEditor(); + } } export default LicenseKeyGroupsEditorView; 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 bd8f21a7c5..ad14c6c249 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsLimits.js @@ -13,45 +13,75 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as globalModalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as globalModalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import Limits from 'sdc-app/onboarding/licenseModel/limits/Limits.jsx'; import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; -const mapStateToProps = ({licenseModel: {licenseKeyGroup: {licenseKeyGroupsEditor: {data}}, limitEditor}, currentScreen}) => { - let {props: {licenseModelId, version}} = currentScreen; - return { - parent: data, - limitEditor, - licenseModelId, - version - }; +const mapStateToProps = ({ + licenseModel: { + licenseKeyGroup: { licenseKeyGroupsEditor: { data } }, + limitEditor + }, + currentScreen +}) => { + let { props: { licenseModelId, version } } = currentScreen; + return { + parent: data, + limitEditor, + licenseModelId, + version + }; }; -const mapActionsToProps = (dispatch) => { - return { - onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), - onSubmit: (limit, licenseKeyGroup, licenseModelId, version) => LicenseKeyGroupsActionHelper.submitLimit(dispatch, - { - limit, - licenseKeyGroup, - licenseModelId, - version}), - onDelete: ({limit, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit}) => dispatch({ - type: globalModalActionTypes.GLOBAL_MODAL_WARNING, - data:{ - 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(() => - selectedLimit === limit.id && onCloseLimitEditor() - ) - } - }) - }; +const mapActionsToProps = dispatch => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onSubmit: (limit, licenseKeyGroup, licenseModelId, version) => + LicenseKeyGroupsActionHelper.submitLimit(dispatch, { + limit, + licenseKeyGroup, + licenseModelId, + version + }), + onDelete: ({ + limit, + parent, + licenseModelId, + version, + onCloseLimitEditor, + selectedLimit + }) => + dispatch({ + type: globalModalActionTypes.GLOBAL_MODAL_WARNING, + data: { + 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( + () => + selectedLimit === limit.id && + onCloseLimitEditor() + ) + } + }) + }; }; 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 00c2092b83..6151c5997d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js @@ -13,41 +13,62 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as globalMoadlActions } from 'nfvo-components/modal/GlobalModalConstants.js'; import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; -import LicenseKeyGroupsListEditorView, {generateConfirmationMsg} from './LicenseKeyGroupsListEditorView.jsx'; +import LicenseKeyGroupsListEditorView, { + generateConfirmationMsg +} from './LicenseKeyGroupsListEditorView.jsx'; -const mapStateToProps = ({licenseModel: {licenseKeyGroup, licenseModelEditor}}) => { - let {licenseKeyGroupsList} = licenseKeyGroup; - let {data} = licenseKeyGroup.licenseKeyGroupsEditor; - let {vendorName} = licenseModelEditor.data; +const mapStateToProps = ({ + licenseModel: { licenseKeyGroup, licenseModelEditor } +}) => { + let { licenseKeyGroupsList } = licenseKeyGroup; + let { data } = licenseKeyGroup.licenseKeyGroupsEditor; + let { vendorName } = licenseModelEditor.data; - return { - vendorName, - licenseKeyGroupsList, - isDisplayModal: Boolean(data), - isModalInEditMode: Boolean(data && data.id) - }; + return { + vendorName, + licenseKeyGroupsList, + isDisplayModal: Boolean(data), + isModalInEditMode: Boolean(data && data.id) + }; }; -const mapActionsToProps = (dispatch, {licenseModelId, version}) => { - return { - onAddLicenseKeyGroupClick: () => LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch), - onEditLicenseKeyGroupClick: licenseKeyGroup => LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch, {licenseKeyGroup, licenseModelId, version}), - onDeleteLicenseKeyGroupClick: licenseKeyGroup => dispatch({ - type: globalMoadlActions.GLOBAL_MODAL_WARNING, - data:{ - msg: generateConfirmationMsg(licenseKeyGroup), - confirmationButtonText: i18n('Delete'), - title: i18n('Delete'), - onConfirmed: () => LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId:licenseKeyGroup.id, version}) - } - }) - }; +const mapActionsToProps = (dispatch, { licenseModelId, version }) => { + return { + onAddLicenseKeyGroupClick: () => + LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch), + onEditLicenseKeyGroupClick: licenseKeyGroup => + LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch, { + licenseKeyGroup, + licenseModelId, + version + }), + onDeleteLicenseKeyGroupClick: licenseKeyGroup => + dispatch({ + type: globalMoadlActions.GLOBAL_MODAL_WARNING, + data: { + msg: generateConfirmationMsg(licenseKeyGroup), + confirmationButtonText: i18n('Delete'), + title: i18n('Delete'), + onConfirmed: () => + LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup( + dispatch, + { + licenseModelId, + licenseKeyGroupId: licenseKeyGroup.id, + version + } + ) + } + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(LicenseKeyGroupsListEditorView); +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 5a98b7f575..4c8c8cee6f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx @@ -21,143 +21,205 @@ import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import LicenseKeyGroupsEditor from './LicenseKeyGroupsEditor.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; -import {optionsInputValues} from './LicenseKeyGroupsConstants'; +import InputOptions, { + other as optionInputOther +} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { optionsInputValues } from './LicenseKeyGroupsConstants'; class LicenseKeyGroupsListEditorView extends React.Component { - static propTypes = { - 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 = { - licenseKeyGroupsList: [] - }; - - state = { - localFilter: '' - }; - - render() { - let {licenseModelId, isReadOnlyMode, isDisplayModal, isModalInEditMode, version} = this.props; - let {onAddLicenseKeyGroupClick} = this.props; - const {localFilter} = this.state; - - return ( -
    - this.setState({localFilter: value})} - isReadOnlyMode={isReadOnlyMode}> - {this.filterList().map(licenseKeyGroup => (this.renderLicenseKeyGroupListItem(licenseKeyGroup, isReadOnlyMode)))} - - - - {`${isModalInEditMode ? i18n('Edit License Key Group') : i18n('Create New License Key Group')}`} - - - { - isDisplayModal && ( - - ) - } - - -
    - ); - } - - filterList() { - let {licenseKeyGroupsList} = this.props; - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return licenseKeyGroupsList.filter(({name = '', description = '', operationalScope = '', type = ''}) => { - return escape(name).match(filter) || escape(description).match(filter) || escape(this.extractValue(operationalScope)).match(filter) || escape(type).match(filter); - }); - } - else { - return licenseKeyGroupsList; - } - } - - renderLicenseKeyGroupListItem(licenseKeyGroup, isReadOnlyMode) { - let {id, name, description, operationalScope, type} = licenseKeyGroup; - let {onEditLicenseKeyGroupClick, onDeleteLicenseKeyGroupClick} = this.props; - return ( - onEditLicenseKeyGroupClick(licenseKeyGroup)} - onDelete={() => onDeleteLicenseKeyGroupClick(licenseKeyGroup)} - className='list-editor-item-view' - isReadOnlyMode={isReadOnlyMode}> -
    -
    {i18n('Name')}
    -
    {name}
    -
    - -
    -
    {i18n('Operational Scope')}
    -
    {operationalScope && this.getOperationalScopes(operationalScope)}
    - -
    {i18n('Type')}
    -
    {InputOptions.getTitleByName(optionsInputValues, type)}
    -
    -
    -
    {i18n('Description')}
    -
    {description}
    -
    -
    - ); - } - - getOperationalScopes(operationalScope) { - - if (operationalScope.choices && operationalScope.choices.toString() === i18n(optionInputOther.OTHER)) { - return operationalScope.other; - } 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 { - return ''; - } - } - - extractValue(item) { - if (item === undefined) { - return ''; - } //TODO fix it sooner rather than later - - return item ? item.choice === optionInputOther.OTHER ? item.other : InputOptions.getTitleByName(optionsInputValues, item.choice) : ''; - } + static propTypes = { + 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 = { + licenseKeyGroupsList: [] + }; + + state = { + localFilter: '' + }; + + render() { + let { + licenseModelId, + isReadOnlyMode, + isDisplayModal, + isModalInEditMode, + version + } = this.props; + let { onAddLicenseKeyGroupClick } = this.props; + const { localFilter } = this.state; + + return ( +
    + this.setState({ localFilter: value })} + isReadOnlyMode={isReadOnlyMode}> + {this.filterList().map(licenseKeyGroup => + this.renderLicenseKeyGroupListItem( + licenseKeyGroup, + isReadOnlyMode + ) + )} + + + + {`${ + isModalInEditMode + ? i18n('Edit License Key Group') + : i18n('Create New License Key Group') + }`} + + + {isDisplayModal && ( + + )} + + +
    + ); + } + + filterList() { + let { licenseKeyGroupsList } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return licenseKeyGroupsList.filter( + ({ + name = '', + description = '', + operationalScope = '', + type = '' + }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) || + escape(this.extractValue(operationalScope)).match( + filter + ) || + escape(type).match(filter) + ); + } + ); + } else { + return licenseKeyGroupsList; + } + } + + renderLicenseKeyGroupListItem(licenseKeyGroup, isReadOnlyMode) { + let { id, name, description, operationalScope, type } = licenseKeyGroup; + let { + onEditLicenseKeyGroupClick, + onDeleteLicenseKeyGroupClick + } = this.props; + return ( + onEditLicenseKeyGroupClick(licenseKeyGroup)} + onDelete={() => onDeleteLicenseKeyGroupClick(licenseKeyGroup)} + className="list-editor-item-view" + isReadOnlyMode={isReadOnlyMode}> +
    +
    {i18n('Name')}
    +
    {name}
    +
    + +
    +
    {i18n('Operational Scope')}
    +
    + {operationalScope && + this.getOperationalScopes(operationalScope)} +
    + +
    {i18n('Type')}
    +
    + {InputOptions.getTitleByName(optionsInputValues, type)} +
    +
    +
    +
    {i18n('Description')}
    +
    {description}
    +
    +
    + ); + } + + getOperationalScopes(operationalScope) { + if ( + operationalScope.choices && + operationalScope.choices.toString() === i18n(optionInputOther.OTHER) + ) { + return operationalScope.other; + } 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 { + return ''; + } + } + + extractValue(item) { + if (item === undefined) { + return ''; + } //TODO fix it sooner rather than later + + return item + ? item.choice === optionInputOther.OTHER + ? item.other + : InputOptions.getTitleByName(optionsInputValues, item.choice) + : ''; + } } export default LicenseKeyGroupsListEditorView; export function generateConfirmationMsg(licenseKeyGroupToDelete) { - let name = licenseKeyGroupToDelete ? licenseKeyGroupToDelete.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') : - ''; - return ( -
    -

    {msg}

    -

    {subMsg}

    -
    - ); + let name = licenseKeyGroupToDelete ? licenseKeyGroupToDelete.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' + ) + : ''; + return ( +
    +

    {msg}

    +

    {subMsg}

    +
    + ); } diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListReducer.js index 1f0a64e295..1cd1da0d82 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListReducer.js @@ -13,20 +13,29 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './LicenseKeyGroupsConstants.js'; +import { actionTypes } from './LicenseKeyGroupsConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.LICENSE_KEY_GROUPS_LIST_LOADED: - return [...action.response.results]; - case actionTypes.DELETE_LICENSE_KEY_GROUP: - return state.filter(licenseKeyGroup => licenseKeyGroup.id !== action.licenseKeyGroupId); - case actionTypes.ADD_LICENSE_KEY_GROUP: - return [...state, action.licenseKeyGroup]; - case actionTypes.EDIT_LICENSE_KEY_GROUP: - const indexForEdit = state.findIndex(licenseKeyGroup => licenseKeyGroup.id === action.licenseKeyGroup.id); - return [...state.slice(0, indexForEdit), action.licenseKeyGroup, ...state.slice(indexForEdit + 1)]; - default: - return state; - } + switch (action.type) { + case actionTypes.LICENSE_KEY_GROUPS_LIST_LOADED: + return [...action.response.results]; + case actionTypes.DELETE_LICENSE_KEY_GROUP: + return state.filter( + licenseKeyGroup => + licenseKeyGroup.id !== action.licenseKeyGroupId + ); + case actionTypes.ADD_LICENSE_KEY_GROUP: + return [...state, action.licenseKeyGroup]; + case actionTypes.EDIT_LICENSE_KEY_GROUP: + const indexForEdit = state.findIndex( + licenseKeyGroup => + licenseKeyGroup.id === action.licenseKeyGroup.id + ); + return [ + ...state.slice(0, indexForEdit), + action.licenseKeyGroup, + ...state.slice(indexForEdit + 1) + ]; + default: + return state; + } }; - diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.js index d483383472..76ea36db98 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.js @@ -1,25 +1,30 @@ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import LimitEditor from './LimitEditor.jsx'; -const mapStateToProps = ({licenseModel: {limitEditor}}) => { +const mapStateToProps = ({ licenseModel: { limitEditor } }) => { + let { data, genericFieldInfo, formReady } = limitEditor; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - let {data, genericFieldInfo, formReady} = limitEditor; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - - return { - data, - genericFieldInfo, - isFormValid, - formReady - }; + return { + data, + genericFieldInfo, + isFormValid, + formReady + }; }; -const mapActionsToProps = (dispatch) => { - return { - onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) - }; +const mapActionsToProps = dispatch => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onValidateForm: formName => + ValidationHelper.validateForm(dispatch, formName) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(LimitEditor); \ No newline at end of file +export default connect(mapStateToProps, mapActionsToProps)(LimitEditor); 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 54f057eaa4..0d1d4eaf10 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditor.jsx @@ -5,206 +5,349 @@ import Form from 'nfvo-components/input/validation/Form.jsx'; import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {LIMITS_FORM_NAME, selectValues} from './LimitEditorConstants.js'; +import { LIMITS_FORM_NAME, selectValues } from './LimitEditorConstants.js'; import Button from 'sdc-ui/lib/react/Button.js'; import Validator from 'nfvo-utils/Validator.js'; -import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx'; import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; const LimitPropType = PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - description: PropTypes.string, - metric: PropTypes.shape({ - choice: PropTypes.string, - other: PropTypes.string - }), - value: PropTypes.string, - aggregationFunction: PropTypes.string, - time: PropTypes.string, - unit: PropTypes.shape({ - choice: PropTypes.string, - other: PropTypes.string - }) + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + metric: PropTypes.shape({ + choice: PropTypes.string, + other: 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: 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 - }; + static propTypes = { + data: LimitPropType, + 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) { - if (this.props.formReady && this.props.formReady !== prevProps.formReady) { - this.submit(); - } - } + componentDidUpdate(prevProps) { + if ( + this.props.formReady && + this.props.formReady !== prevProps.formReady + ) { + this.submit(); + } + } - render() { - let {data = {}, onDataChanged, isReadOnlyMode, genericFieldInfo, onCancel, isFormValid, formReady, onValidateForm} = this.props; - let {name, description, metric, value, aggregationFunction, time, unit} = data; - return ( -
    - {!data.id && -
    - {data.name ? data.name : i18n('NEW LIMIT')} -
    } - { - genericFieldInfo && -
    onValidateForm(LIMITS_FORM_NAME) } - labledButtons={false} - isReadOnlyMode={isReadOnlyMode} - className='limit-editor-form'> - - - onDataChanged({name}, LIMITS_FORM_NAME, {name: () => this.validateName(name)})} - label={i18n('Name')} - data-test-id='limit-editor-name' - value={name} - isValid={genericFieldInfo.name.isValid} - errorText={genericFieldInfo.name.errorText} - isRequired={true} - type='text'/> - - - onDataChanged({description}, LIMITS_FORM_NAME)} - label={i18n('Description')} - data-test-id='limit-editor-description' - value={description} - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} - isRequired={false} - type='text'/> - - - {}} - isMultiSelect={false} - isRequired={true} - onEnumChange={metric => onDataChanged({metric:{choice: metric, other: ''}}, - LIMITS_FORM_NAME)} - onOtherChange={metric => onDataChanged({metric:{choice: optionInputOther.OTHER, - other: metric}}, LIMITS_FORM_NAME)} - label={i18n('Metric')} - data-test-id='limit-editor-metric' - type='select' - required={true} - selectedEnum={metric && metric.choice} - otherValue={metric && metric.other} - values={selectValues.METRIC} - isValid={genericFieldInfo.metric.isValid} - errorText={genericFieldInfo.metric.errorText} /> - - - onDataChanged({value}, LIMITS_FORM_NAME)} - label={i18n('Metric value')} - data-test-id='limit-editor-metric-value' - value={value} - isValid={genericFieldInfo.value.isValid} - errorText={genericFieldInfo.value.errorText} - isRequired={true} - type='text'/> - - - {}} - isMultiSelect={false} - isRequired={false} - onEnumChange={unit => onDataChanged({unit:{choice: unit, other: ''}}, - LIMITS_FORM_NAME)} - onOtherChange={unit => onDataChanged({unit:{choice: optionInputOther.OTHER, - other: unit}}, LIMITS_FORM_NAME)} - label={i18n('Units')} - data-test-id='limit-editor-units' - type='select' - required={false} - selectedEnum={unit && unit.choice} - otherValue={unit && unit.other} - values={selectValues.UNIT} - isValid={genericFieldInfo.unit.isValid} - errorText={genericFieldInfo.unit.errorText} /> - - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onDataChanged({aggregationFunction: val}, LIMITS_FORM_NAME);} - } - value={aggregationFunction} - label={i18n('Aggregation Function')} - data-test-id='limit-editor-aggregation-function' - isValid={genericFieldInfo.aggregationFunction.isValid} - errorText={genericFieldInfo.aggregationFunction.errorText} - groupClassName='bootstrap-input-options' - className='input-options-select' - type='select' > - {selectValues.AGGREGATION_FUNCTION.map(mtype => - )} - - - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onDataChanged({time: val}, LIMITS_FORM_NAME);} - } - value={time} - label={i18n('Time')} - data-test-id='limit-editor-time' - isValid={genericFieldInfo.time.isValid} - errorText={genericFieldInfo.time.errorText} - groupClassName='bootstrap-input-options' - className='input-options-select' - type='select' > - {selectValues.TIME.map(mtype => - )} - - - - - - - -
    - } -
    - ); - } + render() { + let { + data = {}, + onDataChanged, + isReadOnlyMode, + genericFieldInfo, + onCancel, + isFormValid, + formReady, + onValidateForm + } = this.props; + let { + name, + description, + metric, + value, + aggregationFunction, + time, + unit + } = data; + return ( +
    + {!data.id && ( +
    + {data.name ? data.name : i18n('NEW LIMIT')} +
    + )} + {genericFieldInfo && ( +
    onValidateForm(LIMITS_FORM_NAME)} + labledButtons={false} + isReadOnlyMode={isReadOnlyMode} + className="limit-editor-form"> + + + + onDataChanged( + { name }, + LIMITS_FORM_NAME, + { + name: () => + this.validateName(name) + } + ) + } + label={i18n('Name')} + data-test-id="limit-editor-name" + value={name} + isValid={genericFieldInfo.name.isValid} + errorText={genericFieldInfo.name.errorText} + isRequired={true} + type="text" + /> + + + + onDataChanged( + { description }, + LIMITS_FORM_NAME + ) + } + label={i18n('Description')} + data-test-id="limit-editor-description" + value={description} + isValid={ + genericFieldInfo.description.isValid + } + errorText={ + genericFieldInfo.description.errorText + } + isRequired={false} + type="text" + /> + + + {}} + isMultiSelect={false} + isRequired={true} + onEnumChange={metric => + onDataChanged( + { + metric: { + choice: metric, + other: '' + } + }, + LIMITS_FORM_NAME + ) + } + onOtherChange={metric => + onDataChanged( + { + metric: { + choice: + optionInputOther.OTHER, + other: metric + } + }, + LIMITS_FORM_NAME + ) + } + label={i18n('Metric')} + data-test-id="limit-editor-metric" + type="select" + required={true} + selectedEnum={metric && metric.choice} + otherValue={metric && metric.other} + values={selectValues.METRIC} + isValid={genericFieldInfo.metric.isValid} + errorText={ + genericFieldInfo.metric.errorText + } + /> + + + + onDataChanged( + { value }, + LIMITS_FORM_NAME + ) + } + label={i18n('Metric value')} + data-test-id="limit-editor-metric-value" + value={value} + isValid={genericFieldInfo.value.isValid} + errorText={genericFieldInfo.value.errorText} + isRequired={true} + type="text" + /> + + + {}} + isMultiSelect={false} + isRequired={false} + onEnumChange={unit => + onDataChanged( + { + unit: { + choice: unit, + other: '' + } + }, + LIMITS_FORM_NAME + ) + } + onOtherChange={unit => + onDataChanged( + { + unit: { + choice: + optionInputOther.OTHER, + other: unit + } + }, + LIMITS_FORM_NAME + ) + } + label={i18n('Units')} + data-test-id="limit-editor-units" + type="select" + required={false} + selectedEnum={unit && unit.choice} + otherValue={unit && unit.other} + values={selectValues.UNIT} + isValid={genericFieldInfo.unit.isValid} + errorText={genericFieldInfo.unit.errorText} + /> + + + { + const selectedIndex = + e.target.selectedIndex; + const val = + e.target.options[selectedIndex] + .value; + onDataChanged( + { aggregationFunction: val }, + LIMITS_FORM_NAME + ); + }} + value={aggregationFunction} + label={i18n('Aggregation Function')} + data-test-id="limit-editor-aggregation-function" + isValid={ + genericFieldInfo.aggregationFunction + .isValid + } + errorText={ + genericFieldInfo.aggregationFunction + .errorText + } + groupClassName="bootstrap-input-options" + className="input-options-select" + type="select"> + {selectValues.AGGREGATION_FUNCTION.map( + mtype => ( + + ) + )} + + + + { + const selectedIndex = + e.target.selectedIndex; + const val = + e.target.options[selectedIndex] + .value; + onDataChanged( + { time: val }, + LIMITS_FORM_NAME + ); + }} + value={time} + label={i18n('Time')} + data-test-id="limit-editor-time" + isValid={genericFieldInfo.time.isValid} + errorText={genericFieldInfo.time.errorText} + groupClassName="bootstrap-input-options" + className="input-options-select" + type="select"> + {selectValues.TIME.map(mtype => ( + + ))} + + + + + + + +
    + )} +
    + ); + } - validateName(value) { - const {data: {id}, limitsNames} = this.props; - const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: limitsNames}); + validateName(value) { + const { data: { id }, limitsNames } = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({ + itemId: id, + itemName: value, + list: limitsNames + }); - return !isExists ? {isValid: true, errorText: ''} : - {isValid: false, errorText: i18n('Limit by the name \'' + value + '\' already exists. Limit name must be unique')}; - } + return !isExists + ? { isValid: true, errorText: '' } + : { + isValid: false, + errorText: i18n( + "Limit by the name '" + + value + + "' already exists. Limit name must be unique" + ) + }; + } - - submit() { - if (!this.props.formReady) { - this.props.onValidateForm(LIMITS_FORM_NAME); - } else { - this.props.onSubmit(); - } - } + submit() { + if (!this.props.formReady) { + this.props.onValidateForm(LIMITS_FORM_NAME); + } else { + this.props.onSubmit(); + } + } } export default LimitEditor; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorActionHelper.js index 8ac845a1a7..a275808d01 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorActionHelper.js @@ -14,41 +14,47 @@ * permissions and limitations under the License. */ -import {actionTypes, selectValues} from './LimitEditorConstants.js'; -import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; - +import { actionTypes, selectValues } from './LimitEditorConstants.js'; +import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx'; const LimitEditorActionHelper = { - openLimitsEditor(dispatch, {limit}) { - let modifiedLimit = {...limit}; - if (limit && limit.metric) { - modifiedLimit.metric = LimitEditorActionHelper.createChoiceObject(modifiedLimit.metric, selectValues.METRIC); - } - if (limit && limit.unit) { - modifiedLimit.unit = LimitEditorActionHelper.createChoiceObject(modifiedLimit.unit, selectValues.UNIT); - } - dispatch({type: actionTypes.OPEN, limitItem: modifiedLimit}); - }, + openLimitsEditor(dispatch, { limit }) { + let modifiedLimit = { ...limit }; + if (limit && limit.metric) { + modifiedLimit.metric = LimitEditorActionHelper.createChoiceObject( + modifiedLimit.metric, + selectValues.METRIC + ); + } + if (limit && limit.unit) { + modifiedLimit.unit = LimitEditorActionHelper.createChoiceObject( + modifiedLimit.unit, + selectValues.UNIT + ); + } + dispatch({ type: actionTypes.OPEN, limitItem: modifiedLimit }); + }, - closeLimitsEditor(dispatch) { - dispatch({type: actionTypes.CLOSE}); - }, + closeLimitsEditor(dispatch) { + dispatch({ type: actionTypes.CLOSE }); + }, - createChoiceObject(value, optionsList) { - let option = optionsList.find(function(item) { return item.enum === value; }); - if (!option) { - return { - choice: optionInputOther.OTHER, - other: value - }; - } - else { - return { - choice: value, - other: '' - }; - } - } + createChoiceObject(value, optionsList) { + let option = optionsList.find(function(item) { + return item.enum === value; + }); + if (!option) { + return { + choice: optionInputOther.OTHER, + other: value + }; + } else { + return { + choice: value, + other: '' + }; + } + } }; export default LimitEditorActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js index 9829e696c3..a916b9594c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorConstants.js @@ -3,62 +3,61 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; // import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; export const actionTypes = keyMirror({ - OPEN: null, - CLOSE: null, - DATA_CHANGED: null, + OPEN: null, + CLOSE: null, + DATA_CHANGED: null }); export const LIMITS_FORM_NAME = 'LIMITSFORM'; export const selectValues = { - METRIC: [ - {enum: '', title: i18n('please select…')}, - {enum: 'BWTH', title: 'BWTH'}, - {enum: 'Country', title: 'Country'}, - {enum: 'Session', title: 'Session'}, - {enum: 'LoB', title: 'LoB'}, - {enum: 'Site', title: 'Site'}, - {enum: 'Usage', title: 'Usage'} - ], - UNIT: [ - {enum: '', title: i18n('please select…')}, - {enum: 'trunk', title: 'Trunks'}, - {enum: 'user', title: 'Users'}, - {enum: 'subscriber', title: 'Subscribers'}, - {enum: 'session', title: 'Sessions'}, - {enum: 'tenant', title: 'Tenants'}, - {enum: 'token', title: 'Tokens'}, - {enum: 'seats', title: 'Seats'}, - {enum: 'TB', title: 'TB'}, - {enum: 'GB', title: 'GB'}, - {enum: 'MB', title: 'MB'} - ], - AGGREGATION_FUNCTION: [ - {enum: '', title: i18n('please select…')}, - {enum: 'Peak', title: 'Peak'}, - {enum: 'Average', title: 'Average'} - ], - TIME: [ - {enum: '', title: i18n('please select…')}, - {enum: 'Day', title: 'Day'}, - {enum: 'Month', title: 'Month'}, - {enum: 'Hour', title: 'Hour'}, - {enum: 'Minute', title: 'Minute'}, - {enum: 'Second', title: 'Second'}, - {enum: 'Milli-Second', title: 'Milli-Second'} - ] - + METRIC: [ + { enum: '', title: i18n('please select…') }, + { enum: 'BWTH', title: 'BWTH' }, + { enum: 'Country', title: 'Country' }, + { enum: 'Session', title: 'Session' }, + { enum: 'LoB', title: 'LoB' }, + { enum: 'Site', title: 'Site' }, + { enum: 'Usage', title: 'Usage' } + ], + UNIT: [ + { enum: '', title: i18n('please select…') }, + { enum: 'trunk', title: 'Trunks' }, + { enum: 'user', title: 'Users' }, + { enum: 'subscriber', title: 'Subscribers' }, + { enum: 'session', title: 'Sessions' }, + { enum: 'tenant', title: 'Tenants' }, + { enum: 'token', title: 'Tokens' }, + { enum: 'seats', title: 'Seats' }, + { enum: 'TB', title: 'TB' }, + { enum: 'GB', title: 'GB' }, + { enum: 'MB', title: 'MB' } + ], + AGGREGATION_FUNCTION: [ + { enum: '', title: i18n('please select…') }, + { enum: 'Peak', title: 'Peak' }, + { enum: 'Average', title: 'Average' } + ], + TIME: [ + { enum: '', title: i18n('please select…') }, + { enum: 'Day', title: 'Day' }, + { enum: 'Month', title: 'Month' }, + { enum: 'Hour', title: 'Hour' }, + { enum: 'Minute', title: 'Minute' }, + { enum: 'Second', title: 'Second' }, + { enum: 'Milli-Second', title: 'Milli-Second' } + ] }; export const limitType = { - SERVICE_PROVIDER: 'ServiceProvider', - VENDOR: 'Vendor' + SERVICE_PROVIDER: 'ServiceProvider', + VENDOR: 'Vendor' }; export const defaultState = { - LIMITS_EDITOR_DATA: { - metric: {choice: '', other: ''}, - } + LIMITS_EDITOR_DATA: { + metric: { choice: '', other: '' } + } }; export const NEW_LIMIT_TEMP_ID = 'NEW_LIMIT_TEMP_ID'; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorReducer.js index 99d94a09cc..a0c3b0b1b1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitEditorReducer.js @@ -14,58 +14,73 @@ * permissions and limitations under the License. */ -import {actionTypes, LIMITS_FORM_NAME, defaultState} from './LimitEditorConstants.js'; -import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { + actionTypes, + LIMITS_FORM_NAME, + defaultState +} from './LimitEditorConstants.js'; +import { other as optionInputOther } from 'nfvo-components/input/validation/InputOptions.jsx'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.OPEN: - return { - ...state, - data: action.limitItem ? {...action.limitItem} : defaultState.LIMITS_EDITOR_DATA, - formReady: null, - formName: LIMITS_FORM_NAME, - genericFieldInfo: { - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}] - }, - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}] - }, - 'metric' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'requiredChoiceWithOther', data: optionInputOther.OTHER}] - }, - 'value' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - }, - 'unit' : { - isValid: true, - errorText: '', - validations: [] - }, - 'aggregationFunction' : { - isValid: true, - errorText: '', - validations: [] - }, - 'time' : { - isValid: true, - errorText: '', - validations: [] - } - } - }; - case actionTypes.CLOSE: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.OPEN: + return { + ...state, + data: action.limitItem + ? { ...action.limitItem } + : defaultState.LIMITS_EDITOR_DATA, + formReady: null, + formName: LIMITS_FORM_NAME, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }] + }, + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 120 } + ] + }, + metric: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { + type: 'requiredChoiceWithOther', + data: optionInputOther.OTHER + } + ] + }, + value: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + }, + unit: { + isValid: true, + errorText: '', + validations: [] + }, + aggregationFunction: { + isValid: true, + errorText: '', + validations: [] + }, + time: { + isValid: true, + errorText: '', + validations: [] + } + } + }; + case actionTypes.CLOSE: + return {}; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/Limits.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/Limits.jsx index 4841d0335c..2667560935 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/Limits.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/Limits.jsx @@ -18,99 +18,157 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import LimitEditor from './LimitEditor.js'; -import {NEW_LIMIT_TEMP_ID, selectValues} from './LimitEditorConstants.js'; +import { NEW_LIMIT_TEMP_ID, selectValues } from './LimitEditorConstants.js'; -const LimitItem = ({isReadOnlyMode, limit, onDelete, onSelect}) => { - const {name, description, value, metric, aggregationFunction = '', time = ''} = limit; - const timeLabel = time ? `per ${time}` : ''; - let metricOption = selectValues.METRIC.find(item => item.enum === metric); - metricOption = metricOption ? metricOption.title : metric; +const LimitItem = ({ isReadOnlyMode, limit, onDelete, onSelect }) => { + const { + name, + description, + value, + metric, + aggregationFunction = '', + time = '' + } = limit; + const timeLabel = time ? `per ${time}` : ''; + let metricOption = selectValues.METRIC.find(item => item.enum === metric); + metricOption = metricOption ? metricOption.title : metric; - return ( - -
    -
    {name}
    -
    + return ( + +
    +
    {name}
    +
    -
    -
    {description}
    -
    +
    +
    {description}
    +
    -
    -
    {`${metricOption} ${value} ${aggregationFunction} ${timeLabel}`}
    -
    -
    - ); +
    +
    {`${metricOption} ${value} ${aggregationFunction} ${timeLabel}`}
    +
    +
    + ); }; class Limits extends React.Component { + state = { + localFilter: '' + }; + render() { + const { + isReadOnlyMode = false, + limitEditor, + limitsList = [], + onCloseLimitEditor, + selectedLimit + } = this.props; + let limitsNames = {}; + for (let i = 0; i < limitsList.length; i++) { + limitsNames[limitsList[i].name.toLowerCase()] = limitsList[i].id; + } + return ( +
    + + {this.props.selectedLimit === NEW_LIMIT_TEMP_ID && + limitEditor.data && ( + this.submit()} + isReadOnlyMode={isReadOnlyMode} + /> + )} + {limitsList.length === 0 && + !limitEditor.data && ( +
    + {i18n('There are no limits')} +
    + )} + {limitsList.map(limit => ( +
    + this.deleteLimit(limit)} + onSelect={ + selectedLimit + ? undefined + : () => this.props.onSelectLimit(limit) + } + clickable={!selectedLimit} + isReadOnlyMode={isReadOnlyMode} + limit={limit} + /> + {limit.id === selectedLimit && + limitEditor.data && ( + this.submit()} + isReadOnlyMode={isReadOnlyMode} + /> + )} +
    + ))} +
    +
    + ); + } - state = { - localFilter: '' - }; + submit() { + let { + onSubmit, + onCloseLimitEditor, + parent, + limitEditor, + licenseModelId, + version, + limitType + } = this.props; + onSubmit( + { type: limitType, ...limitEditor.data }, + parent, + licenseModelId, + version + ).then(() => onCloseLimitEditor()); + } - render() { - const {isReadOnlyMode = false, limitEditor, limitsList = [], onCloseLimitEditor, selectedLimit} = this.props; - let limitsNames = {}; - for (let i = 0; i < limitsList.length; i++) { - limitsNames[limitsList[i].name.toLowerCase()] = limitsList[i].id; - } - return ( -
    - - {this.props.selectedLimit === NEW_LIMIT_TEMP_ID && limitEditor.data && - this.submit()} isReadOnlyMode={isReadOnlyMode}/> - } - {limitsList.length === 0 && !limitEditor.data &&
    {i18n('There are no limits')}
    } - {limitsList.map(limit => -
    - this.deleteLimit(limit)} - onSelect={selectedLimit ? undefined : () => this.props.onSelectLimit(limit)} - clickable={!selectedLimit} - isReadOnlyMode={isReadOnlyMode} - limit={limit}/> - {limit.id === selectedLimit && limitEditor.data && - this.submit()} - isReadOnlyMode={isReadOnlyMode} /> - } -
    )} -
    + deleteLimit(limit) { + let { + onDelete, + parent, + licenseModelId, + version, + onCloseLimitEditor, + selectedLimit + } = this.props; + onDelete({ + limit, + parent, + licenseModelId, + version, + onCloseLimitEditor, + selectedLimit + }); + } -
    - ); - } - - submit() { - let {onSubmit, onCloseLimitEditor, parent, limitEditor, licenseModelId, version, limitType} = this.props; - onSubmit({type: limitType, ...limitEditor.data}, parent, licenseModelId, version).then(() => onCloseLimitEditor()); - } - - deleteLimit(limit) { - let {onDelete, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit} = this.props; - onDelete({limit, parent, licenseModelId, version, onCloseLimitEditor, selectedLimit}); - } - - filterList() { - let {limitsList = []} = this.props; - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return limitsList.filter(({name = '', description = ''}) => { - return escape(name).match(filter) || escape(description).match(filter); - }); - } - else { - return limitsList; - } - } + filterList() { + let { limitsList = [] } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return limitsList.filter(({ name = '', description = '' }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) + ); + }); + } else { + return limitsList; + } + } } export default Limits; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitsServer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitsServer.js index 1b8ecb9d94..679f9975e5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitsServer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/limits/LimitsServer.js @@ -16,31 +16,29 @@ // items/{itemId}/users -let list = [ - -]; +let list = []; export default { - fetch() { - return Promise.resolve({ - listCount: list.length, - results: list - }); - }, + fetch() { + return Promise.resolve({ + listCount: list.length, + results: list + }); + }, - put(url, payload) { - // let {removedUsers, addedUsers} = payload; - // users = users.filter(user => !removedUsers.map(user => user.userId).includes(user.userId)).concat(addedUsers); - payload.id = Math.random() * (1000 - 1) + 1; - list.push(payload); - return Promise.resolve(); - }, + put(url, payload) { + // let {removedUsers, addedUsers} = payload; + // users = users.filter(user => !removedUsers.map(user => user.userId).includes(user.userId)).concat(addedUsers); + payload.id = Math.random() * (1000 - 1) + 1; + list.push(payload); + return Promise.resolve(); + }, - destroy(url) { - const parts = url.split('/'); - const id = parts[parts.length - 1]; - let newList = list.filter(item => item.id !== id); - list = newList; - return Promise.resolve(); - } -}; \ No newline at end of file + destroy(url) { + const parts = url.split('/'); + const id = parts[parts.length - 1]; + let newList = list.filter(item => item.id !== id); + list = newList; + return Promise.resolve(); + } +}; 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 54941aaaf0..2b10e426d1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js @@ -13,161 +13,214 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; import LicenseModelOverviewView from './LicenseModelOverviewView.jsx'; -import {overviewEditorHeaders, selectedButton} from './LicenseModelOverviewConstants.js'; +import { + overviewEditorHeaders, + selectedButton +} from './LicenseModelOverviewConstants.js'; import licenseModelOverviewActionHelper from './licenseModelOverviewActionHelper.js'; export const mapStateToProps = ({ - licenseModel: { - licenseModelEditor, - entitlementPool, - licenseAgreement, - featureGroup, - licenseKeyGroup, - licenseModelOverview - } + licenseModel: { + licenseModelEditor, + entitlementPool, + licenseAgreement, + featureGroup, + licenseKeyGroup, + licenseModelOverview + } }) => { - - let modalHeader, licensingDataList; - let isDisplayModal = false; - - const reduceLicenseKeyGroups = (accum, licenseKeyGroupId) => { - let curLicenseKeyGroup = licenseKeyGroup.licenseKeyGroupsList.find(item => {return item.id === licenseKeyGroupId;}); - if (curLicenseKeyGroup) { - accum.push({ - ...curLicenseKeyGroup, - itemType: overviewEditorHeaders.LICENSE_KEY_GROUP - }); - } - return accum; - }; - - const reduceEntitlementPools = (accum, entitlementPoolId) => { - let curEntitlementPool = entitlementPool.entitlementPoolsList.find(item => {return item.id === entitlementPoolId;}); - if (curEntitlementPool) { - accum.push ({ - ...curEntitlementPool, - itemType: overviewEditorHeaders.ENTITLEMENT_POOL - }); - } - return accum; - }; - - const reduceFeatureGroups = (accum, featureGroupId) => { - let curFeatureGroup = featureGroup.featureGroupsList.find(item => {return item.id === featureGroupId;}); - if (curFeatureGroup) { - let {entitlementPoolsIds = [], licenseKeyGroupsIds = []} = curFeatureGroup; - accum.push({ - ...curFeatureGroup, - itemType: overviewEditorHeaders.FEATURE_GROUP, - children: [ - ...entitlementPoolsIds.length ? entitlementPoolsIds.reduce(reduceEntitlementPools, []) : [], - ...licenseKeyGroupsIds.length ? licenseKeyGroupsIds.reduce(reduceLicenseKeyGroups, []) : [] - ] - }); - } - return accum; - }; - - - const checkEP = (accum, elem) => { - if (!elem.referencingFeatureGroups || !elem.referencingFeatureGroups.length) { - accum.push({ - ...elem, - itemType: overviewEditorHeaders.ENTITLEMENT_POOL - }); - } - return accum; - }; - - const checkLG = (accum, elem) => { - if (!elem.referencingFeatureGroups || !elem.referencingFeatureGroups.length) { - accum.push({ - ...elem, - itemType: overviewEditorHeaders.LICENSE_KEY_GROUP - }); - } - return accum; - }; - - const checkFG = (accum, elem) => { - if (!elem.referencingLicenseAgreements || !elem.referencingLicenseAgreements.length) { - let {entitlementPoolsIds = [], licenseKeyGroupsIds = []} = elem; - accum.push({ - ...elem, - itemType: overviewEditorHeaders.FEATURE_GROUP, - - children: [ - ...entitlementPoolsIds.length ? entitlementPoolsIds.reduce(reduceEntitlementPools, []) : [], - ...licenseKeyGroupsIds.length ? licenseKeyGroupsIds.reduce(reduceLicenseKeyGroups, []) : [] - ] - - }); - } - return accum; - }; - - - - const mapLicenseAgreementData = licenseAgreement => { - let {featureGroupsIds = []} = licenseAgreement; - return { - ...licenseAgreement, - itemType: overviewEditorHeaders.LICENSE_AGREEMENT, - children: featureGroupsIds.length ? featureGroupsIds.reduce(reduceFeatureGroups, []) : [] - }; - }; - - if (entitlementPool.entitlementPoolEditor && entitlementPool.entitlementPoolEditor.data) { - modalHeader = overviewEditorHeaders.ENTITLEMENT_POOL; - isDisplayModal = true; - }else - if (licenseAgreement.licenseAgreementEditor && licenseAgreement.licenseAgreementEditor.data) { - modalHeader = overviewEditorHeaders.LICENSE_AGREEMENT; - isDisplayModal = true; - }else - if (featureGroup.featureGroupEditor && featureGroup.featureGroupEditor.data) { - modalHeader = overviewEditorHeaders.FEATURE_GROUP; - isDisplayModal = true; - }else - if (licenseKeyGroup.licenseKeyGroupsEditor && licenseKeyGroup.licenseKeyGroupsEditor.data) { - modalHeader = overviewEditorHeaders.LICENSE_KEY_GROUP; - isDisplayModal = true; - } - - let orphanDataList = [ - ...featureGroup.featureGroupsList.reduce(checkFG, []), - ...entitlementPool.entitlementPoolsList.reduce(checkEP, []), - ...licenseKeyGroup.licenseKeyGroupsList.reduce(checkLG, []) - ]; - - licensingDataList = licenseAgreement.licenseAgreementList && licenseAgreement.licenseAgreementList.length ? licenseAgreement.licenseAgreementList.map(mapLicenseAgreementData) : []; - let selectedTab = licenseModelOverview.selectedTab; - // on first entry, we will decide what tab to open depending on data. if there are no connections, we will open the orphans - if (selectedTab === null) { - selectedTab = (licensingDataList.length) ? selectedButton.VLM_LIST_VIEW : selectedButton.NOT_IN_USE; - } - - return { - isDisplayModal, - modalHeader, - licenseModelId: licenseModelEditor.data.id, - version: licenseModelEditor.data.version, - licensingDataList, - orphanDataList, - selectedTab - }; + let modalHeader, licensingDataList; + let isDisplayModal = false; + + const reduceLicenseKeyGroups = (accum, licenseKeyGroupId) => { + let curLicenseKeyGroup = licenseKeyGroup.licenseKeyGroupsList.find( + item => { + return item.id === licenseKeyGroupId; + } + ); + if (curLicenseKeyGroup) { + accum.push({ + ...curLicenseKeyGroup, + itemType: overviewEditorHeaders.LICENSE_KEY_GROUP + }); + } + return accum; + }; + + const reduceEntitlementPools = (accum, entitlementPoolId) => { + let curEntitlementPool = entitlementPool.entitlementPoolsList.find( + item => { + return item.id === entitlementPoolId; + } + ); + if (curEntitlementPool) { + accum.push({ + ...curEntitlementPool, + itemType: overviewEditorHeaders.ENTITLEMENT_POOL + }); + } + return accum; + }; + + const reduceFeatureGroups = (accum, featureGroupId) => { + let curFeatureGroup = featureGroup.featureGroupsList.find(item => { + return item.id === featureGroupId; + }); + if (curFeatureGroup) { + let { + entitlementPoolsIds = [], + licenseKeyGroupsIds = [] + } = curFeatureGroup; + accum.push({ + ...curFeatureGroup, + itemType: overviewEditorHeaders.FEATURE_GROUP, + children: [ + ...(entitlementPoolsIds.length + ? entitlementPoolsIds.reduce(reduceEntitlementPools, []) + : []), + ...(licenseKeyGroupsIds.length + ? licenseKeyGroupsIds.reduce(reduceLicenseKeyGroups, []) + : []) + ] + }); + } + return accum; + }; + + const checkEP = (accum, elem) => { + if ( + !elem.referencingFeatureGroups || + !elem.referencingFeatureGroups.length + ) { + accum.push({ + ...elem, + itemType: overviewEditorHeaders.ENTITLEMENT_POOL + }); + } + return accum; + }; + + const checkLG = (accum, elem) => { + if ( + !elem.referencingFeatureGroups || + !elem.referencingFeatureGroups.length + ) { + accum.push({ + ...elem, + itemType: overviewEditorHeaders.LICENSE_KEY_GROUP + }); + } + return accum; + }; + + const checkFG = (accum, elem) => { + if ( + !elem.referencingLicenseAgreements || + !elem.referencingLicenseAgreements.length + ) { + let { entitlementPoolsIds = [], licenseKeyGroupsIds = [] } = elem; + accum.push({ + ...elem, + itemType: overviewEditorHeaders.FEATURE_GROUP, + + children: [ + ...(entitlementPoolsIds.length + ? entitlementPoolsIds.reduce(reduceEntitlementPools, []) + : []), + ...(licenseKeyGroupsIds.length + ? licenseKeyGroupsIds.reduce(reduceLicenseKeyGroups, []) + : []) + ] + }); + } + return accum; + }; + + const mapLicenseAgreementData = licenseAgreement => { + let { featureGroupsIds = [] } = licenseAgreement; + return { + ...licenseAgreement, + itemType: overviewEditorHeaders.LICENSE_AGREEMENT, + children: featureGroupsIds.length + ? featureGroupsIds.reduce(reduceFeatureGroups, []) + : [] + }; + }; + + if ( + entitlementPool.entitlementPoolEditor && + entitlementPool.entitlementPoolEditor.data + ) { + modalHeader = overviewEditorHeaders.ENTITLEMENT_POOL; + isDisplayModal = true; + } else if ( + licenseAgreement.licenseAgreementEditor && + licenseAgreement.licenseAgreementEditor.data + ) { + modalHeader = overviewEditorHeaders.LICENSE_AGREEMENT; + isDisplayModal = true; + } else if ( + featureGroup.featureGroupEditor && + featureGroup.featureGroupEditor.data + ) { + modalHeader = overviewEditorHeaders.FEATURE_GROUP; + isDisplayModal = true; + } else if ( + licenseKeyGroup.licenseKeyGroupsEditor && + licenseKeyGroup.licenseKeyGroupsEditor.data + ) { + modalHeader = overviewEditorHeaders.LICENSE_KEY_GROUP; + isDisplayModal = true; + } + + let orphanDataList = [ + ...featureGroup.featureGroupsList.reduce(checkFG, []), + ...entitlementPool.entitlementPoolsList.reduce(checkEP, []), + ...licenseKeyGroup.licenseKeyGroupsList.reduce(checkLG, []) + ]; + + licensingDataList = + licenseAgreement.licenseAgreementList && + licenseAgreement.licenseAgreementList.length + ? licenseAgreement.licenseAgreementList.map(mapLicenseAgreementData) + : []; + let selectedTab = licenseModelOverview.selectedTab; + // on first entry, we will decide what tab to open depending on data. if there are no connections, we will open the orphans + if (selectedTab === null) { + selectedTab = licensingDataList.length + ? selectedButton.VLM_LIST_VIEW + : selectedButton.NOT_IN_USE; + } + + return { + isDisplayModal, + modalHeader, + licenseModelId: licenseModelEditor.data.id, + version: licenseModelEditor.data.version, + licensingDataList, + orphanDataList, + selectedTab + }; }; -const mapActionsToProps = (dispatch, {licenseModelId}) => { - return { - onCallVCAction: action => { - LicenseModelActionHelper.performVCAction(dispatch, {licenseModelId, action}); - }, - onTabSelect: (buttonTab) => licenseModelOverviewActionHelper.selectVLMListView(dispatch,{buttonTab}) - }; +const mapActionsToProps = (dispatch, { licenseModelId }) => { + return { + onCallVCAction: action => { + LicenseModelActionHelper.performVCAction(dispatch, { + licenseModelId, + action + }); + }, + onTabSelect: buttonTab => + licenseModelOverviewActionHelper.selectVLMListView(dispatch, { + buttonTab + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(LicenseModelOverviewView); +export default connect(mapStateToProps, mapActionsToProps)( + LicenseModelOverviewView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js index 56b23384a7..b05da582f4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js @@ -16,27 +16,27 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const overviewItems = keyMirror({ - LICENSE_AGREEMENTS: 'License Agreements', - FEATURE_GROUPS: 'Feature Groups', - ENTITLEMENT_POOLS: 'Entitlement Pools', - LICENSE_KEY_GROUPS: 'License Key Groups' + LICENSE_AGREEMENTS: 'License Agreements', + FEATURE_GROUPS: 'Feature Groups', + ENTITLEMENT_POOLS: 'Entitlement Pools', + LICENSE_KEY_GROUPS: 'License Key Groups' }); export const overviewEditorHeaders = keyMirror({ - LICENSE_AGREEMENT: 'License Agreement', - FEATURE_GROUP: 'Feature Group', - ENTITLEMENT_POOL: 'Entitlement Pool', - LICENSE_KEY_GROUP: 'License Key Group' + LICENSE_AGREEMENT: 'License Agreement', + FEATURE_GROUP: 'Feature Group', + ENTITLEMENT_POOL: 'Entitlement Pool', + LICENSE_KEY_GROUP: 'License Key Group' }); export const actionTypes = keyMirror({ - LICENSE_MODEL_OVERVIEW_TAB_SELECTED: null, - LM_DATA_CHANGED: null + LICENSE_MODEL_OVERVIEW_TAB_SELECTED: null, + LM_DATA_CHANGED: null }); export const selectedButton = { - VLM_LIST_VIEW: 'VLM_LIST_VIEW', - NOT_IN_USE: 'NOT_IN_USE' + VLM_LIST_VIEW: 'VLM_LIST_VIEW', + NOT_IN_USE: 'NOT_IN_USE' }; export const VLM_DESCRIPTION_FORM = 'VLMDEWSCRIPTIONFORM'; 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 39109af9a3..6899360597 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx @@ -23,87 +23,137 @@ import EntitlementPoolsEditor from '../entitlementPools/EntitlementPoolsEditor.j import FeatureGroupEditor from '../featureGroups/FeatureGroupEditor.js'; import LicenseAgreementEditor from '../licenseAgreement/LicenseAgreementEditor.js'; import LicenseKeyGroupsEditor from '../licenseKeyGroups/LicenseKeyGroupsEditor.js'; -import {overviewEditorHeaders, selectedButton} from './LicenseModelOverviewConstants.js'; +import { + overviewEditorHeaders, + selectedButton +} from './LicenseModelOverviewConstants.js'; import SummaryView from './SummaryView.jsx'; import VLMListView from './VLMListView.jsx'; import ListButtons from './summary/ListButtons.jsx'; - -const setModalClassName = (modalHeader) => { - switch (modalHeader) { - case overviewEditorHeaders.ENTITLEMENT_POOL: - return 'entitlement-pools-modal'; - case overviewEditorHeaders.LICENSE_AGREEMENT: - return 'license-agreement-modal'; - case overviewEditorHeaders.FEATURE_GROUP: - return 'feature-group-modal'; - case overviewEditorHeaders.LICENSE_KEY_GROUP: - return 'license-key-groups-modal'; - default: - return ''; - } +const setModalClassName = modalHeader => { + switch (modalHeader) { + case overviewEditorHeaders.ENTITLEMENT_POOL: + return 'entitlement-pools-modal'; + case overviewEditorHeaders.LICENSE_AGREEMENT: + return 'license-agreement-modal'; + case overviewEditorHeaders.FEATURE_GROUP: + return 'feature-group-modal'; + case overviewEditorHeaders.LICENSE_KEY_GROUP: + return 'license-key-groups-modal'; + default: + return ''; + } }; class LicenseModelOverviewView extends React.Component { + static propTypes = { + 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 + }; - static propTypes = { - 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, isReadOnlyMode} = this.props; - let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE; - let dataList = selectedInUse ? licensingDataList : orphanDataList; - return( -
    - -
    -
    - 0} - hasLicensing={licensingDataList.length > 0}/> -
    - -
    - { - isDisplayModal && - - - {`${i18n('Create New ')}${i18n(modalHeader)}`} - - - {this.renderModalBody(modalHeader)} - - - } -
    - ); - } + render() { + let { + isDisplayModal, + modalHeader, + licensingDataList, + selectedTab, + onTabSelect, + orphanDataList, + isReadOnlyMode + } = this.props; + let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE; + let dataList = selectedInUse ? licensingDataList : orphanDataList; + return ( +
    + +
    +
    + 0} + hasLicensing={licensingDataList.length > 0} + /> +
    + +
    + {isDisplayModal && ( + + + {`${i18n('Create New ')}${i18n( + modalHeader + )}`} + + + {this.renderModalBody(modalHeader)} + + + )} +
    + ); + } - renderModalBody(modalHeader) { - let {licenseModelId, version, isReadOnlyMode} = this.props; - switch (modalHeader) { - case overviewEditorHeaders.ENTITLEMENT_POOL: - return ; - case overviewEditorHeaders.LICENSE_AGREEMENT: - return ; - case overviewEditorHeaders.FEATURE_GROUP: - return ; - case overviewEditorHeaders.LICENSE_KEY_GROUP: - return ; - } - } + renderModalBody(modalHeader) { + let { licenseModelId, version, isReadOnlyMode } = this.props; + switch (modalHeader) { + case overviewEditorHeaders.ENTITLEMENT_POOL: + return ( + + ); + case overviewEditorHeaders.LICENSE_AGREEMENT: + return ( + + ); + case overviewEditorHeaders.FEATURE_GROUP: + return ( + + ); + case overviewEditorHeaders.LICENSE_KEY_GROUP: + return ( + + ); + } + } } -export default LicenseModelOverviewView; +export default LicenseModelOverviewView; 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 4053f14ced..f416b0a07f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx @@ -13,24 +13,24 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} 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'; +import { default as VendorDataView } from './summary/VendorDataView.js'; +import { default as SummaryCountList } from './summary/SummaryCountList.js'; class SummaryView extends Component { - render() { - const {isReadOnlyMode} = this.props; - return( -
    -
    {i18n('overview')}
    -
    - - -
    -
    - ); - } + render() { + const { isReadOnlyMode } = this.props; + return ( +
    +
    {i18n('overview')}
    +
    + + +
    +
    + ); + } } 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 012bd6e158..d91960e6a3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx @@ -13,114 +13,130 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import {Collapse} from 'react-bootstrap'; +import { Collapse } from 'react-bootstrap'; import LicenseAgreement from './listItems/LicenseAgreement.jsx'; import EntitlementPool from './listItems/EntitlementPool.jsx'; import FeatureGroup from './listItems/FeatureGroup.jsx'; import LicenseKeyGroup from './listItems/LicenseKeyGroup.jsx'; -import {overviewEditorHeaders} from './LicenseModelOverviewConstants.js'; +import { overviewEditorHeaders } from './LicenseModelOverviewConstants.js'; class VLMListView extends Component { + static propTypes = { + licensingDataList: PropTypes.array, + showInUse: PropTypes.bool + }; - static propTypes = { - licensingDataList: PropTypes.array, - showInUse: PropTypes.bool - }; + state = {}; - state = { + render() { + let { licensingDataList = [] } = this.props; + return ( +
    +
    +
      + {licensingDataList.map(item => + this.renderLicensingItem(item) + )} +
    +
    +
    + ); + } - }; + renderLicensingItem(item) { + switch (item.itemType) { + case overviewEditorHeaders.LICENSE_AGREEMENT: + return this.renderLicenseAgreementItem(item); + case overviewEditorHeaders.FEATURE_GROUP: + return this.renderFeatureGroupItem(item); + case overviewEditorHeaders.LICENSE_KEY_GROUP: + return this.renderLicenseKeyGroupItem(item); + case overviewEditorHeaders.ENTITLEMENT_POOL: + return this.renderEntitlementPoolItem(item); + default: + return; + } + } - render() { - let {licensingDataList = []} = this.props; - return ( -
    -
    -
      - {licensingDataList.map(item => this.renderLicensingItem(item))} -
    -
    -
    - ); - } + renderLicenseAgreementItem(licenseAgreement) { + return ( +
  • + + this.updateCollapsable(event, licenseAgreement.id) + } + isOrphan={!this.props.showInUse} + /> + +
      + {licenseAgreement.children && + licenseAgreement.children.map(item => + this.renderLicensingItem(item) + )} +
    +
    +
  • + ); + } - renderLicensingItem(item) { - switch (item.itemType) { - case overviewEditorHeaders.LICENSE_AGREEMENT : - return this.renderLicenseAgreementItem(item); - case overviewEditorHeaders.FEATURE_GROUP : - return this.renderFeatureGroupItem(item); - case overviewEditorHeaders.LICENSE_KEY_GROUP : - return this.renderLicenseKeyGroupItem(item); - case overviewEditorHeaders.ENTITLEMENT_POOL: - return this.renderEntitlementPoolItem(item); - default: - return; - } - } + renderFeatureGroupItem(featureGroup) { + const { showInUse } = this.props; + return ( +
  • + + this.updateCollapsable(event, featureGroup.id) + } + isOrphan={!this.props.showInUse} + /> + {showInUse && ( + +
      + {featureGroup.children && + featureGroup.children.map(item => + this.renderLicensingItem(item) + )} +
    +
    + )} +
  • + ); + } - renderLicenseAgreementItem(licenseAgreement) { - return ( -
  • - this.updateCollapsable(event, licenseAgreement.id) } - isOrphan={!this.props.showInUse}/> - -
      - {licenseAgreement.children && licenseAgreement.children.map(item => this.renderLicensingItem(item))} -
    -
    -
  • - ); - } + renderEntitlementPoolItem(entitlementPool) { + return ( +
  • + +
  • + ); + } - renderFeatureGroupItem(featureGroup) { - const {showInUse} = this.props; - return ( -
  • - this.updateCollapsable(event, featureGroup.id) } - isOrphan={!this.props.showInUse}/> - { - showInUse && -
      - {featureGroup.children && featureGroup.children.map(item => this.renderLicensingItem(item))} + renderLicenseKeyGroupItem(licenseKeyGroup) { + return ( +
    • + +
    • + ); + } -
    -
    - } -
  • - ); - } - - renderEntitlementPoolItem(entitlementPool) { - return ( -
  • - -
  • - ); - } - - renderLicenseKeyGroupItem(licenseKeyGroup) { - return ( -
  • - -
  • - ); - } - - updateCollapsable(event, id) { - event.stopPropagation(); - let obj = {}; - obj[id] = !this.state[id]; - this.setState(obj); - } + updateCollapsable(event, id) { + event.stopPropagation(); + let obj = {}; + obj[id] = !this.state[id]; + this.setState(obj); + } } export default VLMListView; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/licenseModelOverviewActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/licenseModelOverviewActionHelper.js index af9bc22b07..0e9fca7b4a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/licenseModelOverviewActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/licenseModelOverviewActionHelper.js @@ -13,27 +13,27 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './LicenseModelOverviewConstants.js'; +import { actionTypes } from './LicenseModelOverviewConstants.js'; export default { - selectVLMListView(dispatch, {buttonTab}) { - dispatch({ - type: actionTypes.LICENSE_MODEL_OVERVIEW_TAB_SELECTED, - buttonTab - }); - }, + selectVLMListView(dispatch, { buttonTab }) { + dispatch({ + type: actionTypes.LICENSE_MODEL_OVERVIEW_TAB_SELECTED, + buttonTab + }); + }, - editDescriptionOpen(dispatch, {description}) { - dispatch({ - type: actionTypes.LM_DATA_CHANGED, - description - }); - }, + editDescriptionOpen(dispatch, { description }) { + dispatch({ + type: actionTypes.LM_DATA_CHANGED, + description + }); + }, - editDescriptionClose(dispatch) { - dispatch({ - type: actionTypes.LM_DATA_CHANGED, - description: undefined - }); - } + editDescriptionClose(dispatch) { + dispatch({ + type: actionTypes.LM_DATA_CHANGED, + description: undefined + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx index 34d2ee6db5..60eba401c7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx @@ -13,33 +13,46 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {extractUnits} from '../../entitlementPools/EntitlementPoolsConstants.js'; +import { extractUnits } from '../../entitlementPools/EntitlementPoolsConstants.js'; import ArrowCol from './listItemsComponents/ArrowCol.jsx'; import ItemInfo from './listItemsComponents/ItemInfo.jsx'; import IconCol from './listItemsComponents/IconCol.jsx'; -import {AdditionalDataCol, AdditionalDataElement} from './listItemsComponents/AdditionalDataCol.jsx'; +import { + AdditionalDataCol, + AdditionalDataElement +} from './listItemsComponents/AdditionalDataCol.jsx'; class EntitlementPool extends Component { - render() { - let {epData: {name, description, thresholdValue, thresholdUnits}, isOrphan} = this.props; - return ( -
    - {!isOrphan && } - - - - {thresholdValue && - } - -
    - ); - } - + render() { + let { + epData: { name, description, thresholdValue, thresholdUnits }, + isOrphan + } = this.props; + return ( +
    + {!isOrphan && } + + + + {thresholdValue && ( + + )} + +
    + ); + } } export default EntitlementPool; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx index 6d97dea358..df1d813408 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx @@ -13,49 +13,83 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; -import {overviewEditorHeaders} from '../LicenseModelOverviewConstants.js'; +import React, { Component } from 'react'; +import { overviewEditorHeaders } from '../LicenseModelOverviewConstants.js'; import ArrowCol from './listItemsComponents/ArrowCol.jsx'; import ItemInfo from './listItemsComponents/ItemInfo.jsx'; import IconCol from './listItemsComponents/IconCol.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {AdditionalDataCol, AdditionalDataElement} from './listItemsComponents/AdditionalDataCol.jsx'; +import { + AdditionalDataCol, + AdditionalDataElement +} from './listItemsComponents/AdditionalDataCol.jsx'; class FeatureGroup extends Component { - render() { - let {fgData: {name, manufacturerReferenceNumber, description, children = []}, isCollapsed, onClick, isOrphan} = this.props; - return ( -
    onClick(e)} - className={`vlm-list-item vlm-list-item-fg ${isOrphan ? 'orphan-list-item' : ''} ${children.length && !isOrphan ? 'clickable' : ''}`} data-test-id='vlm-list-item-fg'> - {!isOrphan && } - - -
    - - {i18n('Entitlement Pools: ')} - - {`${children.filter(child => child.itemType === overviewEditorHeaders.ENTITLEMENT_POOL).length}`} - - - | - - {i18n('License Key Groups: ')} - - {`${children.filter(child => child.itemType === overviewEditorHeaders.LICENSE_KEY_GROUP).length}`} - - -
    -
    - - - -
    - ); - } + render() { + let { + fgData: { + name, + manufacturerReferenceNumber, + description, + children = [] + }, + isCollapsed, + onClick, + isOrphan + } = this.props; + return ( +
    onClick(e)} + className={`vlm-list-item vlm-list-item-fg ${ + isOrphan ? 'orphan-list-item' : '' + } ${children.length && !isOrphan ? 'clickable' : ''}`} + data-test-id="vlm-list-item-fg"> + {!isOrphan && ( + + )} + + +
    + + {i18n('Entitlement Pools: ')} + + {`${ + children.filter( + child => + child.itemType === + overviewEditorHeaders.ENTITLEMENT_POOL + ).length + }`} + + + | + + {i18n('License Key Groups: ')} + + {`${ + children.filter( + child => + child.itemType === + overviewEditorHeaders.LICENSE_KEY_GROUP + ).length + }`} + + +
    +
    + + + +
    + ); + } } export default FeatureGroup; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx index dfbbe20d69..b409776c27 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx @@ -13,44 +13,73 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; -import {optionsInputValues} from '../../licenseAgreement/LicenseAgreementConstants.js'; +import InputOptions, { + other as optionInputOther +} from 'nfvo-components/input/validation/InputOptions.jsx'; +import { optionsInputValues } from '../../licenseAgreement/LicenseAgreementConstants.js'; import ArrowCol from './listItemsComponents/ArrowCol.jsx'; import ItemInfo from './listItemsComponents/ItemInfo.jsx'; import IconCol from './listItemsComponents/IconCol.jsx'; -import {AdditionalDataCol, AdditionalDataElement} from './listItemsComponents/AdditionalDataCol.jsx'; +import { + AdditionalDataCol, + AdditionalDataElement +} from './listItemsComponents/AdditionalDataCol.jsx'; class LicenseAgreement extends Component { - render() { - let {laData: {name, description, licenseTerm, children = []}, isCollapsed, onClick, isOrphan} = this.props; - return ( -
    onClick(e)} - className={`vlm-list-item vlm-list-item-la ${isOrphan ? 'orphan-list-item' : ''} ${children.length && !isOrphan ? 'clickable' : ''} `} - data-test-id='vlm-list-la-item'> - {!isOrphan && } - - -
    - {i18n('Feature Groups: ')}{`${children.length}`} -
    -
    - - - -
    - ); - } + render() { + let { + laData: { name, description, licenseTerm, children = [] }, + isCollapsed, + onClick, + isOrphan + } = this.props; + return ( +
    onClick(e)} + className={`vlm-list-item vlm-list-item-la ${ + isOrphan ? 'orphan-list-item' : '' + } ${children.length && !isOrphan ? 'clickable' : ''} `} + data-test-id="vlm-list-la-item"> + {!isOrphan && ( + + )} + + +
    + + {i18n('Feature Groups: ')} + {`${ + children.length + }`} + +
    +
    + + + +
    + ); + } - extractValue(item) { - if (item === undefined) {return '';} //TODO fix it later + extractValue(item) { + if (item === undefined) { + return ''; + } //TODO fix it later - return item ? item.choice === optionInputOther.OTHER ? item.other : InputOptions.getTitleByName(optionsInputValues, item.choice) : ''; - } + return item + ? item.choice === optionInputOther.OTHER + ? item.other + : InputOptions.getTitleByName(optionsInputValues, item.choice) + : ''; + } } export default LicenseAgreement; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx index b1036aae23..555acf8dbe 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx @@ -13,36 +13,53 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {extractValue, getOperationalScopes} from '../../licenseKeyGroups/LicenseKeyGroupsConstants.js'; +import { + extractValue, + getOperationalScopes +} from '../../licenseKeyGroups/LicenseKeyGroupsConstants.js'; import ArrowCol from './listItemsComponents/ArrowCol.jsx'; import ItemInfo from './listItemsComponents/ItemInfo.jsx'; import IconCol from './listItemsComponents/IconCol.jsx'; -import {AdditionalDataCol, AdditionalDataElement} from './listItemsComponents/AdditionalDataCol.jsx'; +import { + AdditionalDataCol, + AdditionalDataElement +} from './listItemsComponents/AdditionalDataCol.jsx'; class LicenseKeyGroup extends Component { - render() { - let {lkgData: {name, description, operationalScope, type}, isOrphan} = this.props; - return ( -
    - {!isOrphan && } - - - - {operationalScope && operationalScope.choices && } - - -
    - ); - } - + render() { + let { + lkgData: { name, description, operationalScope, type }, + isOrphan + } = this.props; + return ( +
    + {!isOrphan && } + + + + {operationalScope && + operationalScope.choices && ( + + )} + + +
    + ); + } } export default LicenseKeyGroup; 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 ffc0991354..0f9c783eac 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 @@ -16,37 +16,35 @@ import React from 'react'; import PropTypes from 'prop-types'; -function AdditionalDataCol({children}) { - return ( -
    -
    -
    - {children} -
    -
    - ); +function AdditionalDataCol({ children }) { + return ( +
    +
    +
    {children}
    +
    + ); } AdditionalDataCol.propTypes = { - children: PropTypes.oneOfType([ - PropTypes.arrayOf(PropTypes.node), - PropTypes.node - ]) + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node + ]) }; -function AdditionalDataElement({className, name, value}) { - return ( -
    - {name}: - {value} -
    - ); +function AdditionalDataElement({ className, name, value }) { + return ( +
    + {name}: + {value} +
    + ); } AdditionalDataElement.propTypes = { - name: PropTypes.string, - value: PropTypes.string, - className: PropTypes.string + name: PropTypes.string, + value: PropTypes.string, + className: PropTypes.string }; -export {AdditionalDataCol, AdditionalDataElement}; +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 29aec64bdd..de12eae7d5 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 @@ -17,20 +17,24 @@ import React from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; -function ArrowCol ({isCollapsed, length}) { - return ( -
    -
    0}, - {'down': (length > 0 && isCollapsed)}, - {'right': (length > 0 && (!isCollapsed))})} > -
    -
    - ); +function ArrowCol({ isCollapsed, length }) { + return ( +
    +
    0 }, + { down: length > 0 && isCollapsed }, + { right: length > 0 && !isCollapsed } + )} + /> +
    + ); } ArrowCol.propTypes = { - isCollapsed: PropTypes.bool, - length: PropTypes.number + isCollapsed: PropTypes.bool, + length: PropTypes.number }; export default ArrowCol; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/IconCol.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/IconCol.jsx index 826248e510..61eeb03496 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/IconCol.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/IconCol.jsx @@ -15,12 +15,14 @@ */ import React from 'react'; -function IconCol({className, text}) { - return ( -
    -
    {text}
    -
    - ); +function IconCol({ className, text }) { + return ( +
    +
    + {text} +
    +
    + ); } export default IconCol; 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 95ae123974..2d2cc8f754 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 @@ -16,25 +16,27 @@ import React from 'react'; import PropTypes from 'prop-types'; -function ItemInfo({name, description, children}) { - return ( -
    -
    -
    {name}
    - {children} -
    -
    {description}
    -
    - ); +function ItemInfo({ name, description, children }) { + return ( +
    +
    +
    + {name} +
    + {children} +
    +
    {description}
    +
    + ); } ItemInfo.propTypes = { - name: PropTypes.string, - description: PropTypes.string, - children: PropTypes.oneOfType([ - PropTypes.arrayOf(PropTypes.node), - PropTypes.node - ]) + name: PropTypes.string, + description: PropTypes.string, + children: PropTypes.oneOfType([ + PropTypes.arrayOf(PropTypes.node), + PropTypes.node + ]) }; export default ItemInfo; 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 af759f1206..04a00177d3 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 @@ -18,42 +18,54 @@ 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 {isValid, errorText} = genericFieldInfo.description; - let saveButtonClassName = isValid ? 'description-save' : 'description-save disabled'; - return( -
    + render() { + //TODO check if buttons + let { onDataChanged, description, genericFieldInfo } = this.props; + let { isValid, errorText } = genericFieldInfo.description; + let saveButtonClassName = isValid + ? 'description-save' + : 'description-save disabled'; + return ( +
    + onDataChanged({ description })} + value={description} + isValid={isValid} + errorText={errorText} + className="description-edit-textarea" + type="textarea" + /> +
    +
    +
    this.submit()} + className={saveButtonClassName} + data-test-id="vlm-summary-vendor-desc-save-btn"> + {i18n('Save')} +
    +
    this.onClose()} + className="description-button" + data-test-id="vlm-summary-vendor-desc-cancel-btn"> + {i18n('Cancel')} +
    +
    +
    +
    + ); + } - onDataChanged({description})} - value={description} - isValid={isValid} - errorText={errorText} - className='description-edit-textarea' - type='textarea'/> -
    -
    -
    this.submit()} className={saveButtonClassName} data-test-id='vlm-summary-vendor-desc-save-btn'>{i18n('Save')}
    -
    this.onClose()} className='description-button' data-test-id='vlm-summary-vendor-desc-cancel-btn'>{i18n('Cancel')}
    -
    -
    -
    - ); - } + onClose() { + this.props.onClose(); + } - onClose() { - this.props.onClose(); - } - - submit() { - let {onSubmit, data, description} = this.props; - onSubmit({ - ...data, - description: description.trim() - }); - } + submit() { + let { onSubmit, data, description } = this.props; + onSubmit({ + ...data, + description: description.trim() + }); + } } export default LicenseModelDescriptionEdit; 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 3fcac3c1d8..d422d5d4b2 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 @@ -15,37 +15,39 @@ */ import React from 'react'; import PropTypes from 'prop-types'; -import {selectedButton} from '../LicenseModelOverviewConstants.js'; +import { selectedButton } from '../LicenseModelOverviewConstants.js'; import Tabs from 'sdc-ui/lib/react/Tabs.js'; import Tab from 'sdc-ui/lib/react/Tab.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -function ListButtons ({onTabSelect, selectedTab, hasOrphans, hasLicensing}) { - // no data, no tabs - if (!hasLicensing && !hasOrphans) { - return null; - } - return ( - onTabSelect(tabId)} - activeTab={selectedTab} - className='overview-buttons-section' - type='header' > - - - - ); +function ListButtons({ onTabSelect, selectedTab, hasOrphans, hasLicensing }) { + // no data, no tabs + if (!hasLicensing && !hasOrphans) { + return null; + } + return ( + onTabSelect(tabId)} + activeTab={selectedTab} + className="overview-buttons-section" + type="header"> + + + + ); } ListButtons.propTypes = { - onTabSelect: PropTypes.func, - selectedInUse: 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 50c547e042..144d9bcc1b 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 @@ -16,19 +16,43 @@ import React from 'react'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; -function SummaryCountItem ({name, counter, onAdd, onNavigate, isReadOnlyMode}) { - //TODO check for buttons - return( -
    -
    - {name} - ({counter}) -
    - -
    - ); +function SummaryCountItem({ + name, + counter, + onAdd, + onNavigate, + isReadOnlyMode +}) { + //TODO check for buttons + return ( +
    +
    + + {name} + + + ({counter}) + +
    + +
    + ); } export default SummaryCountItem; - 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 15b6649543..711bb7a374 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 @@ -14,123 +14,158 @@ * permissions and limitations under the License. */ import React from 'react'; -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import EntitlementPoolsActionHelper from '../../entitlementPools/EntitlementPoolsActionHelper.js'; import LicenseAgreementActionHelper from '../../licenseAgreement/LicenseAgreementActionHelper.js'; import LicenseKeyGroupsActionHelper from '../../licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; import FeatureGroupsActionHelper from '../../featureGroups/FeatureGroupsActionHelper.js'; -import {overviewItems} from '../LicenseModelOverviewConstants.js'; +import { overviewItems } from '../LicenseModelOverviewConstants.js'; import SummaryCountItem from './SummaryCountItem.jsx'; export const mapStateToProps = ({ - licenseModel: { - licenseModelEditor, - licenseAgreement: {licenseAgreementList}, - featureGroup: {featureGroupsList}, - entitlementPool: {entitlementPoolsList}, - licenseKeyGroup: {licenseKeyGroupsList} - } + licenseModel: { + licenseModelEditor, + licenseAgreement: { licenseAgreementList }, + featureGroup: { featureGroupsList }, + entitlementPool: { entitlementPoolsList }, + licenseKeyGroup: { licenseKeyGroupsList } + } }) => { + let { vendorName, description, id, version } = 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 + } + ]; - let {vendorName, description, id, version} = 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, - version - }; - + return { + vendorName, + licenseModelId: id, + description, + counts, + version + }; }; -const mapActionsToProps = (dispatch) => { - return { - onEditorOpenClick: (name, licenseModelId, version) => { - switch (name) { - case overviewItems.ENTITLEMENT_POOLS: - EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch); - break; - case overviewItems.FEATURE_GROUPS: - FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, {licenseModelId, version}); - break; - case overviewItems.LICENSE_AGREEMENTS: - LicenseAgreementActionHelper.openLicenseAgreementEditor(dispatch, {licenseModelId, version}); - break; - case overviewItems.LICENSE_KEY_GROUPS: - LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch); - break; - default: - break; - } - }, - onNavigateClick: ({name, licenseModelId, version}) => { - let screenToNavigate; - switch (name) { - case overviewItems.ENTITLEMENT_POOLS: - screenToNavigate = enums.SCREEN.ENTITLEMENT_POOLS; - break; - case overviewItems.FEATURE_GROUPS: - screenToNavigate = enums.SCREEN.FEATURE_GROUPS; - break; - case overviewItems.LICENSE_AGREEMENTS: - screenToNavigate = enums.SCREEN.LICENSE_AGREEMENTS; - break; - case overviewItems.LICENSE_KEY_GROUPS: - screenToNavigate = enums.SCREEN.LICENSE_KEY_GROUPS; - break; - default: - break; - } - ScreensHelper.loadScreen(dispatch, { - screen: screenToNavigate, screenType: screenTypes.LICENSE_MODEL, - props: {licenseModelId, version} - }); - } - }; +const mapActionsToProps = dispatch => { + return { + onEditorOpenClick: (name, licenseModelId, version) => { + switch (name) { + case overviewItems.ENTITLEMENT_POOLS: + EntitlementPoolsActionHelper.openEntitlementPoolsEditor( + dispatch + ); + break; + case overviewItems.FEATURE_GROUPS: + FeatureGroupsActionHelper.openFeatureGroupsEditor( + dispatch, + { + licenseModelId, + version + } + ); + break; + case overviewItems.LICENSE_AGREEMENTS: + LicenseAgreementActionHelper.openLicenseAgreementEditor( + dispatch, + { + licenseModelId, + version + } + ); + break; + case overviewItems.LICENSE_KEY_GROUPS: + LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor( + dispatch + ); + break; + default: + break; + } + }, + onNavigateClick: ({ name, licenseModelId, version }) => { + let screenToNavigate; + switch (name) { + case overviewItems.ENTITLEMENT_POOLS: + screenToNavigate = enums.SCREEN.ENTITLEMENT_POOLS; + break; + case overviewItems.FEATURE_GROUPS: + screenToNavigate = enums.SCREEN.FEATURE_GROUPS; + break; + case overviewItems.LICENSE_AGREEMENTS: + screenToNavigate = enums.SCREEN.LICENSE_AGREEMENTS; + break; + case overviewItems.LICENSE_KEY_GROUPS: + screenToNavigate = enums.SCREEN.LICENSE_KEY_GROUPS; + break; + default: + break; + } + ScreensHelper.loadScreen(dispatch, { + screen: screenToNavigate, + screenType: screenTypes.LICENSE_MODEL, + props: { licenseModelId, version } + }); + } + }; }; export class SummaryCountList extends React.Component { + render() { + let { counts } = this.props; + return ( +
    + {counts.map(item => this.renderItem(item))} +
    + ); + } - render() { - let {counts} = this.props; - return( -
    - {counts.map(item => this.renderItem(item))} -
    - ); - } - - renderItem(item){ - const {name, count} = item; - const {isReadOnlyMode} = this.props; - return( - this.onNavigate(name)} onAdd={() => this.onAdd(name)} key={name} /> - ); - } + renderItem(item) { + const { name, count } = item; + const { isReadOnlyMode } = this.props; + return ( + this.onNavigate(name)} + onAdd={() => this.onAdd(name)} + key={name} + /> + ); + } - onAdd(name) { - let {onEditorOpenClick, licenseModelId, isReadOnlyMode, version} = this.props; - if (!isReadOnlyMode) { - onEditorOpenClick(name, licenseModelId, version); - } - } + onAdd(name) { + let { + onEditorOpenClick, + licenseModelId, + isReadOnlyMode, + version + } = this.props; + if (!isReadOnlyMode) { + onEditorOpenClick(name, licenseModelId, version); + } + } - onNavigate(name) { - let {onNavigateClick, licenseModelId, version} = this.props; - onNavigateClick({licenseModelId, name, version}); - } + onNavigate(name) { + let { onNavigateClick, licenseModelId, version } = this.props; + onNavigateClick({ licenseModelId, name, version }); + } } export default connect(mapStateToProps, mapActionsToProps)(SummaryCountList); 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 616355de41..62fc2c3cb3 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 @@ -13,8 +13,8 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; -import {connect} from 'react-redux'; +import React, { Component } from 'react'; +import { connect } from 'react-redux'; import Tooltip from 'react-bootstrap/lib/Tooltip.js'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; @@ -23,89 +23,139 @@ 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 {VLM_DESCRIPTION_FORM} from '../LicenseModelOverviewConstants.js'; +import { VLM_DESCRIPTION_FORM } from '../LicenseModelOverviewConstants.js'; export const mapStateToProps = ({ - licenseModel: { - licenseModelEditor: {data}, - licenseModelOverview: {descriptionEditor: {data: descriptionData = {}, genericFieldInfo}} - } + licenseModel: { + licenseModelEditor: { data }, + licenseModelOverview: { + descriptionEditor: { data: descriptionData = {}, genericFieldInfo } + } + } }) => { - let {description} = descriptionData; - return { - data, - description, - genericFieldInfo - }; + let { description } = descriptionData; + return { + data, + description, + genericFieldInfo + }; }; -const mapActionsToProps = (dispatch) => { - return { - onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: VLM_DESCRIPTION_FORM}), - onCancel: () => licenseModelOverviewActionHelper.editDescriptionClose(dispatch), - onSubmit: (licenseModel) => { - licenseModelOverviewActionHelper.editDescriptionClose(dispatch); - LicenseModelActionHelper.saveLicenseModel(dispatch, {licenseModel}); - }, - onVendorDescriptionEdit: description => licenseModelOverviewActionHelper.editDescriptionOpen(dispatch,{description}) - }; +const mapActionsToProps = dispatch => { + return { + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: VLM_DESCRIPTION_FORM + }), + onCancel: () => + licenseModelOverviewActionHelper.editDescriptionClose(dispatch), + onSubmit: licenseModel => { + licenseModelOverviewActionHelper.editDescriptionClose(dispatch); + LicenseModelActionHelper.saveLicenseModel(dispatch, { + licenseModel + }); + }, + onVendorDescriptionEdit: description => + licenseModelOverviewActionHelper.editDescriptionOpen(dispatch, { + description + }) + }; }; export class VendorDataView extends Component { - render() { - let {data: {vendorName}, description, isReadOnlyMode} = this.props; - return ( -
    -
    vendor
    -
    {vendorName}
    - { - description !== undefined && !isReadOnlyMode ? this.renderDescriptionEdit() : this.renderDescription() - } -
    - ); - } + render() { + let { data: { vendorName }, description, isReadOnlyMode } = this.props; + return ( +
    +
    vendor
    +
    + {vendorName} +
    + {description !== undefined && !isReadOnlyMode + ? this.renderDescriptionEdit() + : this.renderDescription()} +
    + ); + } - componentWillUnmount() { - this.props.onCancel(); - } + componentWillUnmount() { + this.props.onCancel(); + } + renderDescription() { + let { + data: { description }, + onVendorDescriptionEdit, + isReadOnlyMode + } = this.props; + return ( +
    { + if (!isReadOnlyMode) { + onVendorDescriptionEdit(description); + } + }} + className={ + !isReadOnlyMode + ? 'vendor-description' + : 'vendor-description-readonly' + }> + {this.renderOverlay( +
    + {description} + {!isReadOnlyMode && } +
    + )} +
    + ); + } - renderDescription() { - let {data: {description}, onVendorDescriptionEdit, isReadOnlyMode} = this.props; - return ( -
    {if (!isReadOnlyMode) {onVendorDescriptionEdit(description);}}} className={!isReadOnlyMode ? 'vendor-description' : 'vendor-description-readonly'}> - {this.renderOverlay( -
    - {description} - {!isReadOnlyMode && } -
    - )} -
    - ); - } - - renderDescriptionEdit() { - let {onCancel, onDataChanged, onSubmit, description, genericFieldInfo, data} = this.props; - return( - - ); - } - - renderOverlay(children) { - let {data: {description}, isReadOnlyMode} = this.props; - if (isReadOnlyMode) { - return ( - {description}} - delayShow={400}> - {children} - - ); - } - return children; - } + renderDescriptionEdit() { + let { + onCancel, + onDataChanged, + onSubmit, + description, + genericFieldInfo, + data + } = this.props; + return ( + + ); + } + renderOverlay(children) { + let { data: { description }, isReadOnlyMode } = this.props; + if (isReadOnlyMode) { + return ( + + {description} + + } + delayShow={400}> + {children} + + ); + } + return children; + } } export default connect(mapStateToProps, mapActionsToProps)(VendorDataView); diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx index 345c91e01b..7f361d2742 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx @@ -16,71 +16,96 @@ import React from 'react'; import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {catalogItemTypes, migrationStatusMapper} from './onboardingCatalog/OnboardingCatalogConstants.js'; -import {Tile, TileInfo, TileInfoLine, TileFooter, TileFooterCell} from 'sdc-ui/lib/react'; -import {TooltipWrapper} from './onboardingCatalog/Tooltip.jsx'; +import { + catalogItemTypes, + migrationStatusMapper +} from './onboardingCatalog/OnboardingCatalogConstants.js'; +import { + Tile, + TileInfo, + TileInfoLine, + TileFooter, + TileFooterCell +} from 'sdc-ui/lib/react'; +import { TooltipWrapper } from './onboardingCatalog/Tooltip.jsx'; const ITEM_TYPE_MAP = { - [catalogItemTypes.LICENSE_MODEL]: { - headerText: i18n('VLM'), - contentIconName: 'vlm', - color: 'purple' - }, - [catalogItemTypes.SOFTWARE_PRODUCT]: { - headerText: i18n('VSP'), - contentIconName: 'vsp', - color: 'blue' - } + [catalogItemTypes.LICENSE_MODEL]: { + headerText: i18n('VLM'), + contentIconName: 'vlm', + color: 'purple' + }, + [catalogItemTypes.SOFTWARE_PRODUCT]: { + headerText: i18n('VSP'), + contentIconName: 'vsp', + color: 'blue' + } }; -const CatalogItemDetails = ({catalogItemData, catalogItemTypeClass, onSelect, onMigrate}) => { +const CatalogItemDetails = ({ + catalogItemData, + catalogItemTypeClass, + onSelect, + onMigrate +}) => { + let { vendorName, name, owner } = catalogItemData; + let { headerText, color, contentIconName } = ITEM_TYPE_MAP[ + catalogItemTypeClass + ]; - let {vendorName, name, owner} = catalogItemData; - let {headerText, color, contentIconName} = ITEM_TYPE_MAP[catalogItemTypeClass]; - - let onClick = (e) => { - e.stopPropagation(); - e.preventDefault(); - if (catalogItemData.isOldVersion && catalogItemData.isOldVersion === migrationStatusMapper.OLD_VERSION) { - onMigrate({softwareProduct: catalogItemData}); - } else { - onSelect(); - } - }; - - return ( - - - {vendorName && - - {vendorName} - - } - - {name} - - - - {owner && - Owner - {owner} - } - - - ); + let onClick = e => { + e.stopPropagation(); + e.preventDefault(); + if ( + catalogItemData.isOldVersion && + catalogItemData.isOldVersion === migrationStatusMapper.OLD_VERSION + ) { + onMigrate({ softwareProduct: catalogItemData }); + } else { + onSelect(); + } + }; + return ( + + + {vendorName && ( + + + {vendorName} + + + )} + + + {name} + + + + + {owner && Owner - {owner}} + + + ); }; CatalogItemDetails.PropTypes = { - catalogItemData: PropTypes.obj, - catalogItemTypeClass: PropTypes.string, - onSelect: PropTypes.func, - onMigrate: PropTypes.func + catalogItemData: PropTypes.obj, + catalogItemTypeClass: PropTypes.string, + onSelect: PropTypes.func, + onMigrate: PropTypes.func }; export default CatalogItemDetails; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.stories.js b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.stories.js index 156adfc5e7..d01b9d0d04 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.stories.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.stories.js @@ -1,33 +1,48 @@ import React from 'react'; -import {storiesOf, action} from '@kadira/storybook'; -import {select, withKnobs} from '@kadira/storybook-addon-knobs'; +import { storiesOf, action } from '@kadira/storybook'; +import { select, withKnobs } from '@kadira/storybook-addon-knobs'; import CatalogItemDetails from './CatalogItemDetails.jsx'; -import {catalogItemTypes, catalogItemStatuses} from './onboardingCatalog/OnboardingCatalogConstants.js'; -import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import { + catalogItemTypes, + catalogItemStatuses +} from './onboardingCatalog/OnboardingCatalogConstants.js'; +import { FinalizedLicenseModelFactory } from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; const stories = storiesOf('CatalogTiles', module); stories.addDecorator(withKnobs); const types = [ - catalogItemTypes.LICENSE_MODEL, - catalogItemTypes.SOFTWARE_PRODUCT + catalogItemTypes.LICENSE_MODEL, + catalogItemTypes.SOFTWARE_PRODUCT ]; function selectType() { - return select('Item type' , types, types[0]); + return select('Item type', types, types[0]); } -let vlm = {...FinalizedLicenseModelFactory.build({name: 'Test-VLM'}), itemStatus: catalogItemStatuses.DRAFT}; -let certifiedVlm = {...vlm, itemStatus: catalogItemStatuses.CERTIFIED}; +let vlm = { + ...FinalizedLicenseModelFactory.build({ name: 'Test-VLM' }), + itemStatus: catalogItemStatuses.DRAFT +}; +let certifiedVlm = { ...vlm, itemStatus: catalogItemStatuses.CERTIFIED }; -stories - .add('preview', () => ( -
    -
    -
    - - -
    -
    -
    - )); +stories.add('preview', () => ( +
    +
    +
    + + +
    +
    +
    +)); diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogList.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogList.jsx index 10d855c862..b00ceeb48f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogList.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogList.jsx @@ -17,37 +17,61 @@ import React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; -const SoftwareProductListHeader = ({selectedVendor, onBack}) => ( -
    - -
    -
    {selectedVendor.name}
    -
    +const SoftwareProductListHeader = ({ selectedVendor, onBack }) => ( +
    + +
    +
    {selectedVendor.name}
    +
    ); -const CatalogList = ({children, onAddVLM, onAddVSP, vendorPageOptions}) => ( -
    - {vendorPageOptions && } -
    - { (onAddVLM || onAddVSP) && -
    - {onAddVLM && } - {onAddVSP && onAddVSP()} dataTestId={'catalog-add-new-vsp'} className='vsp-type' title={i18n('CREATE NEW VSP')}/>} -
    - } - {children} -
    -
    +const CatalogList = ({ children, onAddVLM, onAddVSP, vendorPageOptions }) => ( +
    + {vendorPageOptions && ( + + )} +
    + {(onAddVLM || onAddVSP) && ( +
    + {onAddVLM && ( + + )} + {onAddVSP && ( + onAddVSP()} + dataTestId={'catalog-add-new-vsp'} + className="vsp-type" + title={i18n('CREATE NEW VSP')} + /> + )} +
    + )} + {children} +
    +
    ); -const CreateItemTile = ({onClick, dataTestId, title, className = ''}) => { - //TODO check for buttons - return ( -
    -
    -
    {title}
    -
    - ); +const CreateItemTile = ({ onClick, dataTestId, title, className = '' }) => { + //TODO check for buttons + return ( +
    +
    + +
    +
    {title}
    +
    + ); }; export default CatalogList; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogModal.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogModal.jsx index 1ef9c82822..90496c9be4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogModal.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogModal.jsx @@ -14,49 +14,52 @@ * permissions and limitations under the License. */ import React from 'react'; -import {modalMapper, catalogItemTypes, catalogItemTypeClasses } from './onboardingCatalog/OnboardingCatalogConstants.js'; +import { + modalMapper, + catalogItemTypes, + catalogItemTypeClasses +} from './onboardingCatalog/OnboardingCatalogConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; import LicenseModelCreation from '../licenseModel/creation/LicenseModelCreation.js'; import SoftwareProductCreation from '../softwareProduct/creation/SoftwareProductCreation.js'; -class CatalogModal extends React.Component{ +class CatalogModal extends React.Component { + getModalDetails() { + const { modalToShow } = this.props; + switch (modalToShow) { + case catalogItemTypes.LICENSE_MODEL: + return { + title: i18n('New License Model'), + element: + }; + case catalogItemTypes.SOFTWARE_PRODUCT: + return { + title: i18n('New Software Product'), + element: + }; + } + } - getModalDetails(){ - const {modalToShow} = this.props; - switch (modalToShow) { - case catalogItemTypes.LICENSE_MODEL: - return { - title: i18n('New License Model'), - element: - }; - case catalogItemTypes.SOFTWARE_PRODUCT: - return { - title: i18n('New Software Product'), - element: - }; - } - } + render() { + const { modalToShow } = this.props; + const modalDetails = this.getModalDetails(modalToShow); - render(){ - const {modalToShow} = this.props; - const modalDetails = this.getModalDetails(modalToShow); - - return ( - - - {modalDetails && modalDetails.title} - - - { - modalDetails && modalDetails.element - } - - - ); - } + return ( + + + + {modalDetails && modalDetails.title} + + + {modalDetails && modalDetails.element} + + ); + } } export default CatalogModal; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/DetailsCatalogView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/DetailsCatalogView.jsx index ea6cf5e9bc..771c0eb6c1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/DetailsCatalogView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/DetailsCatalogView.jsx @@ -15,42 +15,66 @@ */ import React from 'react'; import PropTypes from 'prop-types'; -import {catalogItemTypes} from './onboardingCatalog/OnboardingCatalogConstants.js'; -import {filterCatalogItemsByType} from './onboardingCatalog/OnboardingCatalogUtils.js'; +import { catalogItemTypes } from './onboardingCatalog/OnboardingCatalogConstants.js'; +import { filterCatalogItemsByType } from './onboardingCatalog/OnboardingCatalogUtils.js'; import CatalogList from './CatalogList.jsx'; import CatalogItemDetails from './CatalogItemDetails.jsx'; -class DetailsCatalogView extends React.Component{ +class DetailsCatalogView extends React.Component { + static propTypes = { + VLMList: PropTypes.array, + VSPList: PropTypes.array, + onSelectVLM: PropTypes.func.isRequired, + onSelectVSP: PropTypes.func.isRequired, + onAddVLM: PropTypes.func, + onAddVSP: PropTypes.func, + filter: PropTypes.string.isRequired + }; - static propTypes = { - VLMList: PropTypes.array, - VSPList: PropTypes.array, - onSelectVLM: PropTypes.func.isRequired, - onSelectVSP: PropTypes.func.isRequired, - onAddVLM: PropTypes.func, - onAddVSP: PropTypes.func, - filter: PropTypes.string.isRequired - }; + renderCatalogItems({ items, type, filter, onSelect, onMigrate, users }) { + return filterCatalogItemsByType({ items, filter }).map(item => ( + onSelect(item, users)} + /> + )); + } - renderCatalogItems({items, type, filter, onSelect, onMigrate, users}){ - return filterCatalogItemsByType({items, filter}).map(item => - onSelect(item, users)} /> - ); - } - - render() { - let {VLMList, VSPList, users, onAddVSP, onAddVLM, onSelectVLM, onSelectVSP, filter = '', onMigrate} = this.props; - return ( - - {this.renderCatalogItems({items: VLMList, type: catalogItemTypes.LICENSE_MODEL, filter, onSelect: onSelectVLM, onMigrate, users})} - {this.renderCatalogItems({items: VSPList, type: catalogItemTypes.SOFTWARE_PRODUCT, filter, onSelect: onSelectVSP, onMigrate, users})} - - ); - } + render() { + let { + VLMList, + VSPList, + users, + onAddVSP, + onAddVLM, + onSelectVLM, + onSelectVSP, + filter = '', + onMigrate + } = this.props; + return ( + + {this.renderCatalogItems({ + items: VLMList, + type: catalogItemTypes.LICENSE_MODEL, + filter, + onSelect: onSelectVLM, + onMigrate, + users + })} + {this.renderCatalogItems({ + items: VSPList, + type: catalogItemTypes.SOFTWARE_PRODUCT, + filter, + onSelect: onSelectVSP, + onMigrate, + users + })} + + ); + } } export default DetailsCatalogView; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js b/openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js index 9535147a46..a1e0018114 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js @@ -14,109 +14,121 @@ * limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import OnboardView from './OnboardView.jsx'; import OnboardingCatalogActionHelper from './onboardingCatalog/OnboardingCatalogActionHelper.js'; import OnboardActionHelper from './OnboardActionHelper.js'; import LicenseModelCreationActionHelper from '../licenseModel/creation/LicenseModelCreationActionHelper.js'; import SoftwareProductCreationActionHelper from '../softwareProduct/creation/SoftwareProductCreationActionHelper.js'; import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js'; -import {tabsMapping} from './onboardingCatalog/OnboardingCatalogConstants.js'; -import {itemsType} from './filter/FilterConstants.js'; +import { tabsMapping } from './onboardingCatalog/OnboardingCatalogConstants.js'; +import { itemsType } from './filter/FilterConstants.js'; export const mapStateToProps = ({ - onboard: { - onboardingCatalog, - activeTab, - searchValue, - filter - }, - licenseModelList, - users, - archivedLicenseModelList, - archivedSoftwareProductList, - finalizedLicenseModelList, - softwareProductList, - finalizedSoftwareProductList + onboard: { onboardingCatalog, activeTab, searchValue, filter }, + licenseModelList, + users, + archivedLicenseModelList, + archivedSoftwareProductList, + finalizedLicenseModelList, + softwareProductList, + finalizedSoftwareProductList }) => { + const fullSoftwareProducts = softwareProductList + .filter( + vsp => + !finalizedSoftwareProductList.find(fvsp => fvsp.id === vsp.id) + ) + .concat(finalizedSoftwareProductList); - const fullSoftwareProducts = softwareProductList.filter(vsp => - !finalizedSoftwareProductList - .find(fvsp => fvsp.id === vsp.id) - ).concat(finalizedSoftwareProductList); + const reduceLicenseModelList = (accum, vlm) => { + let currentSoftwareProductList = sortByStringProperty( + fullSoftwareProducts.filter(vsp => vsp.vendorId === vlm.id), + 'name' + ); + accum.push({ ...vlm, softwareProductList: currentSoftwareProductList }); + return accum; + }; - const reduceLicenseModelList = (accum, vlm) => { - let currentSoftwareProductList = sortByStringProperty( - fullSoftwareProducts - .filter(vsp => vsp.vendorId === vlm.id), - 'name' - ); - accum.push({...vlm, softwareProductList: currentSoftwareProductList}); - return accum; - }; + licenseModelList = sortByStringProperty( + licenseModelList.reduce(reduceLicenseModelList, []), + 'name' + ); - licenseModelList = sortByStringProperty( - licenseModelList - .reduce(reduceLicenseModelList, []), - 'name' - ); + finalizedLicenseModelList = sortByStringProperty( + finalizedLicenseModelList.reduce(reduceLicenseModelList, []), + 'name' + ); - finalizedLicenseModelList = sortByStringProperty( - finalizedLicenseModelList - .reduce(reduceLicenseModelList, []), - 'name' - ); + const fullLicenseModelList = licenseModelList + .filter( + vlm => !finalizedLicenseModelList.find(fvlm => fvlm.id === vlm.id) + ) + .concat(finalizedLicenseModelList); - const fullLicenseModelList = licenseModelList.filter(vlm => - !finalizedLicenseModelList - .find(fvlm => fvlm.id === vlm.id) - ).concat(finalizedLicenseModelList); - - let {activeTab: catalogActiveTab, vendorCatalog: {vspOverlay, selectedVendor}} = onboardingCatalog; - if (filter.byVendorView) { - catalogActiveTab = tabsMapping.BY_VENDOR; - } - else if (filter.itemsType && filter.itemsType === itemsType.ARCHIVED) { - catalogActiveTab = tabsMapping.ARCHIVE; - } - - return { - finalizedLicenseModelList, - finalizedSoftwareProductList, - licenseModelList, - softwareProductList, - archivedLicenseModelList, - archivedSoftwareProductList, - fullLicenseModelList, - activeTab, - catalogActiveTab, - searchValue, - vspOverlay, - selectedVendor, - users: users.usersList - }; + let { + activeTab: catalogActiveTab, + vendorCatalog: { vspOverlay, selectedVendor } + } = onboardingCatalog; + if (filter.byVendorView) { + catalogActiveTab = tabsMapping.BY_VENDOR; + } else if (filter.itemsType && filter.itemsType === itemsType.ARCHIVED) { + catalogActiveTab = tabsMapping.ARCHIVE; + } + return { + finalizedLicenseModelList, + finalizedSoftwareProductList, + licenseModelList, + softwareProductList, + archivedLicenseModelList, + archivedSoftwareProductList, + fullLicenseModelList, + activeTab, + catalogActiveTab, + searchValue, + vspOverlay, + selectedVendor, + users: users.usersList + }; }; -const mapActionsToProps = (dispatch) => { - - return { - onSelectLicenseModel({id: licenseModelId, name}, users, tab) { - OnboardActionHelper.loadVLMScreen(dispatch, {id: licenseModelId, name}, users, tab); - }, - onSelectSoftwareProduct(softwareProduct, users, tab) { - OnboardActionHelper.loadVSPScreen(dispatch, softwareProduct, users, tab); - }, - onAddSoftwareProductClick: (vendorId) => SoftwareProductCreationActionHelper.open(dispatch, vendorId), - onAddLicenseModelClick: () => LicenseModelCreationActionHelper.open(dispatch), - onVspOverlayChange: (vendor) => OnboardingCatalogActionHelper.changeVspOverlay(dispatch, vendor), - closeVspOverlay: () => OnboardingCatalogActionHelper.closeVspOverlay(dispatch), - onCatalogTabClick: (tab) => OnboardingCatalogActionHelper.changeActiveTab(dispatch, tab), - onTabClick: (tab) => OnboardActionHelper.changeActiveTab(dispatch, tab), - onSearch: (searchValue) => OnboardActionHelper.changeSearchValue(dispatch, searchValue), - onVendorSelect: (vendor) => OnboardingCatalogActionHelper.onVendorSelect(dispatch, {vendor}), - onMigrate: ({softwareProduct}) => OnboardingCatalogActionHelper.onMigrate(dispatch, softwareProduct) - }; +const mapActionsToProps = dispatch => { + return { + onSelectLicenseModel({ id: licenseModelId, name }, users, tab) { + OnboardActionHelper.loadVLMScreen( + dispatch, + { id: licenseModelId, name }, + users, + tab + ); + }, + onSelectSoftwareProduct(softwareProduct, users, tab) { + OnboardActionHelper.loadVSPScreen( + dispatch, + softwareProduct, + users, + tab + ); + }, + onAddSoftwareProductClick: vendorId => + SoftwareProductCreationActionHelper.open(dispatch, vendorId), + onAddLicenseModelClick: () => + LicenseModelCreationActionHelper.open(dispatch), + onVspOverlayChange: vendor => + OnboardingCatalogActionHelper.changeVspOverlay(dispatch, vendor), + closeVspOverlay: () => + OnboardingCatalogActionHelper.closeVspOverlay(dispatch), + onCatalogTabClick: tab => + OnboardingCatalogActionHelper.changeActiveTab(dispatch, tab), + onTabClick: tab => OnboardActionHelper.changeActiveTab(dispatch, tab), + onSearch: searchValue => + OnboardActionHelper.changeSearchValue(dispatch, searchValue), + onVendorSelect: vendor => + OnboardingCatalogActionHelper.onVendorSelect(dispatch, { vendor }), + onMigrate: ({ softwareProduct }) => + OnboardingCatalogActionHelper.onMigrate(dispatch, softwareProduct) + }; }; export default connect(mapStateToProps, mapActionsToProps)(OnboardView); diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js index 892056855f..87ec2d148e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js @@ -13,97 +13,146 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {tabsMapping, actionTypes} from './OnboardConstants.js'; +import { tabsMapping, actionTypes } from './OnboardConstants.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import VersionsPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js'; -import {catalogItemStatuses} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; -import {itemTypes} from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js'; +import { catalogItemStatuses } from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; +import { itemTypes } from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js'; import PermissionsActionHelper from 'sdc-app/onboarding/permissions/PermissionsActionHelper.js'; const OnboardActionHelper = { - resetOnboardStore(dispatch) { - dispatch({ - type: actionTypes.RESET_ONBOARD_STORE - }); - }, - changeActiveTab(dispatch, activeTab) { - this.clearSearchValue(dispatch); - dispatch({ - type: actionTypes.CHANGE_ACTIVE_ONBOARD_TAB, - activeTab - }); - }, - changeSearchValue(dispatch, searchValue) { - dispatch({ - type: actionTypes.CHANGE_SEARCH_VALUE, - searchValue - }); - }, - clearSearchValue(dispatch) { - dispatch({ - type: actionTypes.CHANGE_SEARCH_VALUE, - searchValue: '' - }); - }, + resetOnboardStore(dispatch) { + dispatch({ + type: actionTypes.RESET_ONBOARD_STORE + }); + }, + changeActiveTab(dispatch, activeTab) { + this.clearSearchValue(dispatch); + dispatch({ + type: actionTypes.CHANGE_ACTIVE_ONBOARD_TAB, + activeTab + }); + }, + changeSearchValue(dispatch, searchValue) { + dispatch({ + type: actionTypes.CHANGE_SEARCH_VALUE, + searchValue + }); + }, + clearSearchValue(dispatch) { + dispatch({ + type: actionTypes.CHANGE_SEARCH_VALUE, + searchValue: '' + }); + }, - loadVLMScreen(dispatch, {id: licenseModelId, name}, users, tab) { - if (tab === tabsMapping.WORKSPACE) { - VersionsPageActionHelper.fetchVersions(dispatch, {itemId: licenseModelId, itemType: itemTypes.LICENSE_MODEL}).then(({results})=> { - results = results.filter((version) => version.status === catalogItemStatuses.DRAFT); - if (results.length !== 1) { - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.VERSIONS_PAGE, screenType: screenTypes.LICENSE_MODEL, - props: {licenseModelId, licenseModel: {name}, usersList: users} - }); - } - else { - PermissionsActionHelper.fetchItemUsers(dispatch, {itemId: licenseModelId, allUsers: users}).then(() => - ScreensHelper.loadLandingScreen(dispatch, {screenType: screenTypes.LICENSE_MODEL, props: {licenseModelId, version: results[0]}}) - ); - } - }); - } - if (tab === tabsMapping.CATALOG) { - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.VERSIONS_PAGE, screenType: screenTypes.LICENSE_MODEL, - props: {licenseModelId, licenseModel: {name}, usersList: users} - }); - } - }, - loadVSPScreen(dispatch, softwareProduct, users, tab) { - let {id: softwareProductId, vendorId: licenseModelId, licensingVersion, name} = softwareProduct; - if (tab === tabsMapping.WORKSPACE) { - VersionsPageActionHelper.fetchVersions(dispatch,{itemId: softwareProductId, itemType: itemTypes.SOFTWARE_PRODUCT}).then(({results})=> { - results = results.filter((version) => version.status === catalogItemStatuses.DRAFT); - if (results.length !== 1) { - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: { - softwareProductId, - softwareProduct: {name, vendorId: licenseModelId, licensingVersion}, - usersList: users - } - }); - } - else { - PermissionsActionHelper.fetchItemUsers(dispatch, {itemId: softwareProductId, allUsers: users}).then(() => - ScreensHelper.loadLandingScreen(dispatch, {screenType: screenTypes.SOFTWARE_PRODUCT, props: {softwareProductId, licenseModelId, version: results[0]}}) - ); - } - }); - } - if (tab === tabsMapping.CATALOG) { - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: { - softwareProductId, - softwareProduct: {name, vendorId: licenseModelId, licensingVersion}, - usersList: users - } - }); - } - } + loadVLMScreen(dispatch, { id: licenseModelId, name }, users, tab) { + if (tab === tabsMapping.WORKSPACE) { + VersionsPageActionHelper.fetchVersions(dispatch, { + itemId: licenseModelId, + itemType: itemTypes.LICENSE_MODEL + }).then(({ results }) => { + results = results.filter( + version => version.status === catalogItemStatuses.DRAFT + ); + if (results.length !== 1) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.VERSIONS_PAGE, + screenType: screenTypes.LICENSE_MODEL, + props: { + licenseModelId, + licenseModel: { name }, + usersList: users + } + }); + } else { + PermissionsActionHelper.fetchItemUsers(dispatch, { + itemId: licenseModelId, + allUsers: users + }).then(() => + ScreensHelper.loadLandingScreen(dispatch, { + screenType: screenTypes.LICENSE_MODEL, + props: { licenseModelId, version: results[0] } + }) + ); + } + }); + } + if (tab === tabsMapping.CATALOG) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.VERSIONS_PAGE, + screenType: screenTypes.LICENSE_MODEL, + props: { + licenseModelId, + licenseModel: { name }, + usersList: users + } + }); + } + }, + loadVSPScreen(dispatch, softwareProduct, users, tab) { + let { + id: softwareProductId, + vendorId: licenseModelId, + licensingVersion, + name + } = softwareProduct; + if (tab === tabsMapping.WORKSPACE) { + VersionsPageActionHelper.fetchVersions(dispatch, { + itemId: softwareProductId, + itemType: itemTypes.SOFTWARE_PRODUCT + }).then(({ results }) => { + results = results.filter( + version => version.status === catalogItemStatuses.DRAFT + ); + if (results.length !== 1) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + softwareProduct: { + name, + vendorId: licenseModelId, + licensingVersion + }, + usersList: users + } + }); + } else { + PermissionsActionHelper.fetchItemUsers(dispatch, { + itemId: softwareProductId, + allUsers: users + }).then(() => + ScreensHelper.loadLandingScreen(dispatch, { + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + licenseModelId, + version: results[0] + } + }) + ); + } + }); + } + if (tab === tabsMapping.CATALOG) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + softwareProduct: { + name, + vendorId: licenseModelId, + licensingVersion + }, + usersList: users + } + }); + } + } }; export default OnboardActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardConstants.js b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardConstants.js index 41128bfb11..6fbf265afb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardConstants.js @@ -16,13 +16,13 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const tabsMapping = { - 'WORKSPACE': 1, - 'CATALOG': 2 + WORKSPACE: 1, + CATALOG: 2 }; export const actionTypes = keyMirror({ - CHANGE_ACTIVE_ONBOARD_TAB: null, - CHANGE_SEARCH_VALUE: null, - RESET_ONBOARD_STORE: null, - VSP_MIGRATION: null + CHANGE_ACTIVE_ONBOARD_TAB: null, + CHANGE_SEARCH_VALUE: null, + RESET_ONBOARD_STORE: null, + VSP_MIGRATION: null }); diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardReducer.js b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardReducer.js index b2e7b0479b..39ceb31b34 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardReducer.js @@ -13,21 +13,27 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, tabsMapping} from './OnboardConstants.js'; -import {combineReducers} from 'redux'; +import { actionTypes, tabsMapping } from './OnboardConstants.js'; +import { combineReducers } from 'redux'; import onboardingCatalogReducer from './onboardingCatalog/OnboardingCatalogReducer.js'; import filterReducer from './filter/FilterReducer.js'; const onboardReducer = combineReducers({ - onboardingCatalog: onboardingCatalogReducer, - filter: filterReducer, - activeTab: (state = tabsMapping.WORKSPACE, action) => action.type === actionTypes.CHANGE_ACTIVE_ONBOARD_TAB ? action.activeTab : state, - searchValue: (state = '', action) => action.type === actionTypes.CHANGE_SEARCH_VALUE ? action.searchValue : state + onboardingCatalog: onboardingCatalogReducer, + filter: filterReducer, + activeTab: (state = tabsMapping.WORKSPACE, action) => + action.type === actionTypes.CHANGE_ACTIVE_ONBOARD_TAB + ? action.activeTab + : state, + searchValue: (state = '', action) => + action.type === actionTypes.CHANGE_SEARCH_VALUE + ? action.searchValue + : state }); export default (state, action) => { - if (action.type === actionTypes.RESET_ONBOARD_STORE) { - state = undefined; - } - return onboardReducer(state, action); + if (action.type === actionTypes.RESET_ONBOARD_STORE) { + state = undefined; + } + return onboardReducer(state, action); }; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardView.jsx index c045a3739a..dcaeaa787d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardView.jsx @@ -17,89 +17,99 @@ import React from 'react'; import PropTypes from 'prop-types'; import OnboardingCatalogView from './onboardingCatalog/OnboardingCatalogView.jsx'; import WorkspaceView from './workspace/WorkspaceView.jsx'; -import {tabsMapping} from './OnboardConstants.js'; +import { tabsMapping } from './OnboardConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import classnames from 'classnames'; import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx'; import objectValues from 'lodash/values.js'; -import {catalogItemTypes} from './onboardingCatalog/OnboardingCatalogConstants.js'; +import { catalogItemTypes } from './onboardingCatalog/OnboardingCatalogConstants.js'; import NotificationsView from 'sdc-app/onboarding/userNotifications/NotificationsView.jsx'; import Filter from 'sdc-app/onboarding/onboard/filter/Filter.jsx'; -const OnboardHeaderTabs = ({onTabClick, activeTab}) => ( -
    -
    onTabClick(tabsMapping.WORKSPACE)} - data-test-id='onboard-workspace-tab'> - {i18n('WORKSPACE')} -
    -
    onTabClick(tabsMapping.CATALOG)} - data-test-id='onboard-onboard-tab'> - {i18n('ONBOARD CATALOG')} -
    -
    +const OnboardHeaderTabs = ({ onTabClick, activeTab }) => ( +
    +
    onTabClick(tabsMapping.WORKSPACE)} + data-test-id="onboard-workspace-tab"> + {i18n('WORKSPACE')} +
    +
    onTabClick(tabsMapping.CATALOG)} + data-test-id="onboard-onboard-tab"> + {i18n('ONBOARD CATALOG')} +
    +
    ); -const OnboardHeader = ({onSearch, activeTab, onTabClick, searchValue}) => ( -
    - - - -
    +const OnboardHeader = ({ onSearch, activeTab, onTabClick, searchValue }) => ( +
    + + + +
    ); class OnboardView extends React.Component { - static propTypes = { - licenseModelList: PropTypes.array, - softwareProductList: PropTypes.array, - finalizedLicenseModelList: PropTypes.array, - finalizedSoftwareProductList: PropTypes.array, - archivedSoftwareProductList: PropTypes.array, - archivedLicenseModelList: PropTypes.array, - modalToShow: PropTypes.oneOf(objectValues(catalogItemTypes)), - onSelectLicenseModel: PropTypes.func.isRequired, - onSelectSoftwareProduct: PropTypes.func.isRequired, - onAddLicenseModelClick: PropTypes.func.isRequired, - onAddSoftwareProductClick: PropTypes.func.isRequired, - closeVspOverlay: PropTypes.func.isRequired, - onVspOverlayChange: PropTypes.func.isRequired, - onTabClick: PropTypes.func.isRequired, - onCatalogTabClick: PropTypes.func.isRequired, - onSearch: PropTypes.func.isRequired, - activeTab: PropTypes.number.isRequired, - catalogActiveTab: PropTypes.number.isRequired, - searchValue: PropTypes.string.isRequired, - onMigrate: PropTypes.func.isRequired, - }; - renderViewByTab(activeTab){ - switch (activeTab){ - case tabsMapping.WORKSPACE: - return ; - case tabsMapping.CATALOG: - return ; - default: - return ; - } - } + static propTypes = { + licenseModelList: PropTypes.array, + softwareProductList: PropTypes.array, + finalizedLicenseModelList: PropTypes.array, + finalizedSoftwareProductList: PropTypes.array, + archivedSoftwareProductList: PropTypes.array, + archivedLicenseModelList: PropTypes.array, + modalToShow: PropTypes.oneOf(objectValues(catalogItemTypes)), + onSelectLicenseModel: PropTypes.func.isRequired, + onSelectSoftwareProduct: PropTypes.func.isRequired, + onAddLicenseModelClick: PropTypes.func.isRequired, + onAddSoftwareProductClick: PropTypes.func.isRequired, + closeVspOverlay: PropTypes.func.isRequired, + onVspOverlayChange: PropTypes.func.isRequired, + onTabClick: PropTypes.func.isRequired, + onCatalogTabClick: PropTypes.func.isRequired, + onSearch: PropTypes.func.isRequired, + activeTab: PropTypes.number.isRequired, + catalogActiveTab: PropTypes.number.isRequired, + searchValue: PropTypes.string.isRequired, + onMigrate: PropTypes.func.isRequired + }; + renderViewByTab(activeTab) { + switch (activeTab) { + case tabsMapping.WORKSPACE: + return ; + case tabsMapping.CATALOG: + return ; + default: + return ; + } + } - render() { - let {activeTab, onTabClick, onSearch, searchValue} = this.props; - return ( -
    - -
    - onSearch(value)}/> - {this.renderViewByTab(activeTab)} -
    -
    - ); - } + render() { + let { activeTab, onTabClick, onSearch, searchValue } = this.props; + return ( +
    + +
    + onSearch(value)} + /> + {this.renderViewByTab(activeTab)} +
    +
    + ); + } } export default OnboardView; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/filter/Filter.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/filter/Filter.jsx index d8d04f242b..c80232de0a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/filter/Filter.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/filter/Filter.jsx @@ -14,83 +14,166 @@ * limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import React from 'react'; import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import Accordion from 'nfvo-components/accordion/Accordion.jsx'; -import {actionTypes} from './FilterConstants.js'; +import { actionTypes } from './FilterConstants.js'; import featureToggle from 'sdc-app/features/featureToggle.js'; -import {featureToggleNames} from 'sdc-app/features/FeaturesConstants.js'; -import {tabsMapping as onboardTabsMapping} from '../OnboardConstants.js'; -import {itemsType as itemsTypeConstants} from './FilterConstants.js'; +import { featureToggleNames } from 'sdc-app/features/FeaturesConstants.js'; +import { tabsMapping as onboardTabsMapping } from '../OnboardConstants.js'; +import { itemsType as itemsTypeConstants } from './FilterConstants.js'; -const mapStateToProps = ({onboard: {filter, activeTab}}) => { - return { - data: filter, - activeTab - }; +const mapStateToProps = ({ onboard: { filter, activeTab } }) => { + return { + data: filter, + activeTab + }; }; -const mapActionsToProps = (dispatch) => { - return { - onDataChanged: (deltaData) => - dispatch({ - type: actionTypes.FILTER_DATA_CHANGED, - deltaData - }) - }; +const mapActionsToProps = dispatch => { + return { + onDataChanged: deltaData => + dispatch({ + type: actionTypes.FILTER_DATA_CHANGED, + deltaData + }) + }; }; -const Filter = ({onDataChanged, data: {entityTypeVsp, entityTypeVlm, roleOwner, roleContributor, roleViewer, - procedureNetwork, procedureManual, recentlyUpdated, byVendorView, itemsType}, activeTab}) => ( -
    - {activeTab === onboardTabsMapping.CATALOG && onDataChanged({itemsType: e.target.value})}> - - - } - {activeTab === onboardTabsMapping.CATALOG && onDataChanged({byVendorView})} - data-test-id='filter-by-vendor-view' value='' /> - } - onDataChanged({recentlyUpdated})} data-test-id='filter-recently-updated' value='' /> +const Filter = ({ + onDataChanged, + data: { + entityTypeVsp, + entityTypeVlm, + roleOwner, + roleContributor, + roleViewer, + procedureNetwork, + procedureManual, + recentlyUpdated, + byVendorView, + itemsType + }, + activeTab +}) => ( +
    + {activeTab === onboardTabsMapping.CATALOG && ( + onDataChanged({ itemsType: e.target.value })}> + + + + )} + {activeTab === onboardTabsMapping.CATALOG && ( + onDataChanged({ byVendorView })} + data-test-id="filter-by-vendor-view" + value="" + /> + )} + onDataChanged({ recentlyUpdated })} + data-test-id="filter-recently-updated" + value="" + /> - - onDataChanged({entityTypeVsp})} data-test-id='filter-type-vsp' value='' /> - onDataChanged({entityTypeVlm})} data-test-id='filter-type-vlm' value='' /> - + + onDataChanged({ entityTypeVsp })} + data-test-id="filter-type-vsp" + value="" + /> + onDataChanged({ entityTypeVlm })} + data-test-id="filter-type-vlm" + value="" + /> + - - onDataChanged({roleOwner})} data-test-id='filter-role-owner' value='' /> - onDataChanged({roleContributor})} data-test-id='filter-role-contributor' value='' /> - onDataChanged({roleViewer})} data-test-id='filter-role-viewr' value='' /> - - - - onDataChanged({procedureNetwork})} data-test-id='filter-procedure-network' value='' /> - onDataChanged({procedureManual})} data-test-id='filter-procedure-manual' value='' /> - + + onDataChanged({ roleOwner })} + data-test-id="filter-role-owner" + value="" + /> + onDataChanged({ roleContributor })} + data-test-id="filter-role-contributor" + value="" + /> + onDataChanged({ roleViewer })} + data-test-id="filter-role-viewr" + value="" + /> + + + + + onDataChanged({ procedureNetwork }) + } + data-test-id="filter-procedure-network" + value="" + /> + onDataChanged({ procedureManual })} + data-test-id="filter-procedure-manual" + value="" + /> +
    ); Filter.PropTypes = { - onDataChanged: PropTypes.func, - data: PropTypes.object + onDataChanged: PropTypes.func, + data: PropTypes.object }; -export default featureToggle(featureToggleNames.FILTER)(connect(mapStateToProps, mapActionsToProps)(Filter)); +export default featureToggle(featureToggleNames.FILTER)( + connect(mapStateToProps, mapActionsToProps)(Filter) +); diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterConstants.js b/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterConstants.js index d944cb02fb..edfe592877 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterConstants.js @@ -17,10 +17,10 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - FILTER_DATA_CHANGED: null + FILTER_DATA_CHANGED: null }); export const itemsType = { - ACTIVE: '1', - ARCHIVED: '2' -}; \ No newline at end of file + ACTIVE: '1', + ARCHIVED: '2' +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterReducer.js b/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterReducer.js index 963226cd38..f1e857498a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterReducer.js @@ -13,16 +13,16 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {actionTypes} from './FilterConstants.js'; +import { actionTypes } from './FilterConstants.js'; -export default (state = {}, action) => { - switch (action.type) { - case actionTypes.FILTER_DATA_CHANGED: - return { - ...state, - ...action.deltaData - }; - default: - return state; - } +export default (state = {}, action) => { + switch (action.type) { + case actionTypes.FILTER_DATA_CHANGED: + return { + ...state, + ...action.deltaData + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js index a85c79edd9..aebb829a88 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js @@ -15,69 +15,88 @@ */ import React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes} from './OnboardingCatalogConstants.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes } from './OnboardingCatalogConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import OnboardActionHelper from '../OnboardActionHelper.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; - function getMessageForMigration(name) { - return ( -
    -
    {i18n('{name} needs to be updated. Click ‘Checkout & Update’, to proceed.', {name: name})}
    -
    {i18n('Please don’t forget to submit afterwards')}
    -
    - ); + return ( +
    +
    + {i18n( + '{name} needs to be updated. Click ‘Checkout & Update’, to proceed.', + { name: name } + )} +
    +
    {i18n('Please don’t forget to submit afterwards')}
    +
    + ); } const OnboardingCatalogActionHelper = { - changeVspOverlay(dispatch, vendor) { - dispatch({ - type: actionTypes.CHANGE_VSP_OVERLAY, - vendorId: vendor ? vendor.id : null - }); - }, - closeVspOverlay(dispatch) { - dispatch({ - type: actionTypes.CLOSE_VSP_OVERLAY - }); - }, - changeActiveTab(dispatch, activeTab) { - OnboardActionHelper.clearSearchValue(dispatch); - dispatch({ - type: actionTypes.CHANGE_ACTIVE_CATALOG_TAB, - activeTab - }); - }, - onVendorSelect(dispatch, {vendor}) { - OnboardActionHelper.clearSearchValue(dispatch); - dispatch({ - type: actionTypes.ONBOARDING_CATALOG_OPEN_VENDOR_PAGE, - selectedVendor: vendor - }); - }, - onMigrate(dispatch, softwareProduct) { - const {name, lockingUser} = softwareProduct; - if (NaN === NaN) { // TODO - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data: { - title: 'WARNING', - msg: i18n('{name} is locked by user {lockingUser} for self-healing', {name: name, lockingUser: lockingUser}) - } - }); - } else { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data:{ - title: 'WARNING', - msg: getMessageForMigration(softwareProduct.name.toUpperCase()), - confirmationButtonText: i18n('Checkout & Update'), - onConfirmed: ()=>SoftwareProductActionHelper.migrateSoftwareProduct(dispatch, {softwareProduct}) - } - }); - } - } + changeVspOverlay(dispatch, vendor) { + dispatch({ + type: actionTypes.CHANGE_VSP_OVERLAY, + vendorId: vendor ? vendor.id : null + }); + }, + closeVspOverlay(dispatch) { + dispatch({ + type: actionTypes.CLOSE_VSP_OVERLAY + }); + }, + changeActiveTab(dispatch, activeTab) { + OnboardActionHelper.clearSearchValue(dispatch); + dispatch({ + type: actionTypes.CHANGE_ACTIVE_CATALOG_TAB, + activeTab + }); + }, + onVendorSelect(dispatch, { vendor }) { + OnboardActionHelper.clearSearchValue(dispatch); + dispatch({ + type: actionTypes.ONBOARDING_CATALOG_OPEN_VENDOR_PAGE, + selectedVendor: vendor + }); + }, + onMigrate(dispatch, softwareProduct) { + const { name, lockingUser } = softwareProduct; + if (NaN === NaN) { + // TODO + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: 'WARNING', + msg: i18n( + '{name} is locked by user {lockingUser} for self-healing', + { + name: name, + lockingUser: lockingUser + } + ) + } + }); + } else { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: 'WARNING', + msg: getMessageForMigration( + softwareProduct.name.toUpperCase() + ), + confirmationButtonText: i18n('Checkout & Update'), + onConfirmed: () => + SoftwareProductActionHelper.migrateSoftwareProduct( + dispatch, + { + softwareProduct + } + ) + } + }); + } + } }; export default OnboardingCatalogActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js index 239ae4545f..f0cefdcde3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js @@ -16,41 +16,41 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const catalogItemTypes = Object.freeze({ - LICENSE_MODEL: 'license-model', - SOFTWARE_PRODUCT: 'software-product' + LICENSE_MODEL: 'license-model', + SOFTWARE_PRODUCT: 'software-product' }); export const catalogItemTypeClasses = { - LICENSE_MODEL: 'license-model-type', - SOFTWARE_PRODUCT: 'software-product-type', - VENDOR: 'vendor-type' + LICENSE_MODEL: 'license-model-type', + SOFTWARE_PRODUCT: 'software-product-type', + VENDOR: 'vendor-type' }; export const catalogItemStatuses = { - DRAFT: 'Draft', - CERTIFIED: 'Certified', - ARCHIVED: 'ARCHIVED' + DRAFT: 'Draft', + CERTIFIED: 'Certified', + ARCHIVED: 'ARCHIVED' }; export const modalMapper = { - 'license-model': 'LICENSE_MODEL', - 'software-product': 'SOFTWARE_PRODUCT' + 'license-model': 'LICENSE_MODEL', + 'software-product': 'SOFTWARE_PRODUCT' }; export const tabsMapping = { - 'BY_VENDOR': 1, - 'ACTIVE': 2, - 'ARCHIVE': 3 + BY_VENDOR: 1, + ACTIVE: 2, + ARCHIVE: 3 }; export const migrationStatusMapper = { - OLD_VERSION: 'True', + OLD_VERSION: 'True' }; export const actionTypes = keyMirror({ - ONBOARDING_CATALOG_OPEN_VENDOR_PAGE: null, - CHANGE_ACTIVE_CATALOG_TAB: null, - CHANGE_SEARCH_VALUE: null, - CHANGE_VSP_OVERLAY: null, - CLOSE_VSP_OVERLAY: null + ONBOARDING_CATALOG_OPEN_VENDOR_PAGE: null, + CHANGE_ACTIVE_CATALOG_TAB: null, + CHANGE_SEARCH_VALUE: null, + CHANGE_VSP_OVERLAY: null, + CLOSE_VSP_OVERLAY: null }); diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogReducer.js b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogReducer.js index 3f8a833074..9796cf8918 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogReducer.js @@ -13,18 +13,21 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import {actionTypes, tabsMapping} from './OnboardingCatalogConstants.js'; -import {combineReducers} from 'redux'; +import { actionTypes, tabsMapping } from './OnboardingCatalogConstants.js'; +import { combineReducers } from 'redux'; import vendorCatalogReducer from './VendorCatalogReducer.js'; const onboardingCatalogReducer = combineReducers({ - vendorCatalog: vendorCatalogReducer, - activeTab: (state = tabsMapping.ACTIVE, action) => action.type === actionTypes.CHANGE_ACTIVE_CATALOG_TAB ? action.activeTab : state + vendorCatalog: vendorCatalogReducer, + activeTab: (state = tabsMapping.ACTIVE, action) => + action.type === actionTypes.CHANGE_ACTIVE_CATALOG_TAB + ? action.activeTab + : state }); export default (state, action) => { - if (action.type === actionTypes.RESET_ONBOARDING_CATALOG_STORE) { - state = undefined; - } - return onboardingCatalogReducer(state, action); + if (action.type === actionTypes.RESET_ONBOARDING_CATALOG_STORE) { + state = undefined; + } + return onboardingCatalogReducer(state, action); }; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogUtils.js b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogUtils.js index 78258255ec..d1e401f57d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogUtils.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogUtils.js @@ -14,6 +14,8 @@ * permissions and limitations under the License. */ -export const filterCatalogItemsByType = ({items, filter}) => { - return items.filter(item => item.name.toLowerCase().indexOf(filter.toLowerCase()) > -1); +export const filterCatalogItemsByType = ({ items, filter }) => { + return items.filter( + item => item.name.toLowerCase().indexOf(filter.toLowerCase()) > -1 + ); }; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx index 8ae8549688..2cc32c2936 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx @@ -18,120 +18,202 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import classnames from 'classnames'; import DetailsCatalogView from 'sdc-app/onboarding/onboard/DetailsCatalogView.jsx'; import VendorCatalogView from './VendorCatalogView.jsx'; -import { tabsMapping} from './OnboardingCatalogConstants.js'; -import {tabsMapping as WCTabsMapping} from 'sdc-app/onboarding/onboard/OnboardConstants.js'; +import { tabsMapping } from './OnboardingCatalogConstants.js'; +import { tabsMapping as WCTabsMapping } from 'sdc-app/onboarding/onboard/OnboardConstants.js'; import featureToggle from 'sdc-app/features/featureToggle.js'; -import {featureToggleNames} from 'sdc-app/features/FeaturesConstants.js'; +import { featureToggleNames } from 'sdc-app/features/FeaturesConstants.js'; -const Separator = () => ( -
    -); +const Separator = () =>
    ; -const Tab = ({onTabPress, title, dataTestId, activeTab, tabMapping}) => ( -
    onTabPress(tabMapping)} - data-test-id={dataTestId}> - {title} -
    +const Tab = ({ onTabPress, title, dataTestId, activeTab, tabMapping }) => ( +
    onTabPress(tabMapping)} + data-test-id={dataTestId}> + {title} +
    ); const ArchiveTab = featureToggle(featureToggleNames.ARCHIVE_ITEM)(Tab); -const ArchiveTabSeparator = featureToggle(featureToggleNames.ARCHIVE_ITEM)(Separator); +const ArchiveTabSeparator = featureToggle(featureToggleNames.ARCHIVE_ITEM)( + Separator +); -const CatalogHeaderTabs = (props) => ( -
    - - - - - -
    +const CatalogHeaderTabs = props => ( +
    + + + + + +
    ); -const CatalogHeader = ({activeTab, onTabPress}) => ( -
    - -
    +const CatalogHeader = ({ activeTab, onTabPress }) => ( +
    + +
    ); const FilterCatalogHeader = () => ( -
    -
    -
    - {i18n('ONBOARD CATALOG')} -
    -
    -
    +
    +
    +
    + {i18n('ONBOARD CATALOG')} +
    +
    +
    ); - -const FeaturedCatalogHeader = featureToggle(featureToggleNames.FILTER)({AComp: FilterCatalogHeader, BComp: CatalogHeader}); +const FeaturedCatalogHeader = featureToggle(featureToggleNames.FILTER)({ + AComp: FilterCatalogHeader, + BComp: CatalogHeader +}); class OnboardingCatalogView extends React.Component { - renderViewByTab(activeTab){ - const {finalizedLicenseModelList: licenseModelList, fullLicenseModelList, users, vspOverlay, finalizedSoftwareProductList: softwareProductList, onSelectLicenseModel, onSelectSoftwareProduct, - onAddLicenseModelClick, onAddSoftwareProductClick, onVspOverlayChange, onVendorSelect, selectedVendor, searchValue, onMigrate, - archivedSoftwareProductList, archivedLicenseModelList} = this.props; + renderViewByTab(activeTab) { + const { + finalizedLicenseModelList: licenseModelList, + fullLicenseModelList, + users, + vspOverlay, + finalizedSoftwareProductList: softwareProductList, + onSelectLicenseModel, + onSelectSoftwareProduct, + onAddLicenseModelClick, + onAddSoftwareProductClick, + onVspOverlayChange, + onVendorSelect, + selectedVendor, + searchValue, + onMigrate, + archivedSoftwareProductList, + archivedLicenseModelList + } = this.props; - switch (activeTab){ - case tabsMapping.ARCHIVE: - return ( - onSelectLicenseModel(item, users, WCTabsMapping.CATALOG)} - onSelectVSP={(item, users) => onSelectSoftwareProduct(item, users, WCTabsMapping.CATALOG)} - filter={searchValue} - onMigrate={onMigrate}/> - ); - case tabsMapping.ACTIVE: - return ( - onSelectLicenseModel(item, users, WCTabsMapping.CATALOG)} - onSelectVSP={(item, users) => onSelectSoftwareProduct(item, users, WCTabsMapping.CATALOG)} - filter={searchValue} - onMigrate={onMigrate}/> - ); - case tabsMapping.BY_VENDOR: - default: - return ( - onSelectSoftwareProduct(item, users, WCTabsMapping.CATALOG)} - onSelectVLM={(item, users) => onSelectLicenseModel(item, users, WCTabsMapping.CATALOG)} - vspOverlay={vspOverlay} - onVendorSelect={onVendorSelect} - selectedVendor={selectedVendor} - onVspOverlayChange={onVspOverlayChange} - onMigrate={onMigrate} - filter={searchValue}/> - ); - } - } + switch (activeTab) { + case tabsMapping.ARCHIVE: + return ( + + onSelectLicenseModel( + item, + users, + WCTabsMapping.CATALOG + ) + } + onSelectVSP={(item, users) => + onSelectSoftwareProduct( + item, + users, + WCTabsMapping.CATALOG + ) + } + filter={searchValue} + onMigrate={onMigrate} + /> + ); + case tabsMapping.ACTIVE: + return ( + + onSelectLicenseModel( + item, + users, + WCTabsMapping.CATALOG + ) + } + onSelectVSP={(item, users) => + onSelectSoftwareProduct( + item, + users, + WCTabsMapping.CATALOG + ) + } + filter={searchValue} + onMigrate={onMigrate} + /> + ); + case tabsMapping.BY_VENDOR: + default: + return ( + + onSelectSoftwareProduct( + item, + users, + WCTabsMapping.CATALOG + ) + } + onSelectVLM={(item, users) => + onSelectLicenseModel( + item, + users, + WCTabsMapping.CATALOG + ) + } + vspOverlay={vspOverlay} + onVendorSelect={onVendorSelect} + selectedVendor={selectedVendor} + onVspOverlayChange={onVspOverlayChange} + onMigrate={onMigrate} + filter={searchValue} + /> + ); + } + } - render() { - const {selectedVendor, catalogActiveTab: activeTab, onCatalogTabClick, onSearch, searchValue} = this.props; - return ( -
    - {!selectedVendor && onSearch(event.target.value)} - activeTab={activeTab} - onTabPress={tab => onCatalogTabClick(tab)} - searchValue={searchValue}/>} - {this.renderViewByTab(activeTab)} -
    - ); - } + render() { + const { + selectedVendor, + catalogActiveTab: activeTab, + onCatalogTabClick, + onSearch, + searchValue + } = this.props; + return ( +
    + {!selectedVendor && ( + onSearch(event.target.value)} + activeTab={activeTab} + onTabPress={tab => onCatalogTabClick(tab)} + searchValue={searchValue} + /> + )} + {this.renderViewByTab(activeTab)} +
    + ); + } } export default OnboardingCatalogView; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/Tooltip.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/Tooltip.jsx index 80d9b07ac9..2f00bf95ed 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/Tooltip.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/Tooltip.jsx @@ -19,13 +19,27 @@ import Tooltip from 'react-bootstrap/lib/Tooltip.js'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; const tooltip = (msg, className = '') => ( - {msg} + + {msg} + ); -export const TooltipWrapper = ({placement = 'top', className = '', tooltipClassName = '', dataTestId, delayShow = 0, children}) => ( - -
    {children}
    -
    +export const TooltipWrapper = ({ + placement = 'top', + className = '', + tooltipClassName = '', + dataTestId, + delayShow = 0, + children +}) => ( + +
    + {children} +
    +
    ); export default tooltip; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx index a2852e5afa..c2eb8250f8 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx @@ -16,36 +16,52 @@ import React from 'react'; import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {migrationStatusMapper} from './OnboardingCatalogConstants.js'; +import { migrationStatusMapper } from './OnboardingCatalogConstants.js'; -const VSPOverlay = ({VSPList, onSelectVSP, onSeeMore, onMigrate}) => ( -
    { - e.stopPropagation(); - e.preventDefault(); - }}> -
    -
    -
    {i18n('Recently Edited')}
    -
    - {VSPList.slice(0, 5).map(vsp =>
    { - if (vsp.isOldVersion && vsp.isOldVersion === migrationStatusMapper.OLD_VERSION) { - onMigrate({ - softwareProduct: vsp - }); - } else { - onSelectVSP(vsp); - } - } - }>{i18n(vsp.name)}
    )} -
    - {VSPList.length > 5 &&
    {i18n('See More')}
    } -
    -
    +const VSPOverlay = ({ VSPList, onSelectVSP, onSeeMore, onMigrate }) => ( +
    { + e.stopPropagation(); + e.preventDefault(); + }}> +
    +
    +
    {i18n('Recently Edited')}
    +
    + {VSPList.slice(0, 5).map(vsp => ( +
    { + if ( + vsp.isOldVersion && + vsp.isOldVersion === + migrationStatusMapper.OLD_VERSION + ) { + onMigrate({ + softwareProduct: vsp + }); + } else { + onSelectVSP(vsp); + } + }}> + {i18n(vsp.name)} +
    + ))} +
    + {VSPList.length > 5 && ( +
    + {i18n('See More')} +
    + )} +
    +
    ); VSPOverlay.PropTypes = { - VSPList: PropTypes.array, - onSelectVSP: PropTypes.func + VSPList: PropTypes.array, + onSelectVSP: PropTypes.func }; export default VSPOverlay; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogReducer.js b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogReducer.js index dd8b41bd22..2d22a2db90 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogReducer.js @@ -13,26 +13,26 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './OnboardingCatalogConstants.js'; +import { actionTypes } from './OnboardingCatalogConstants.js'; export default (state = {}, action) => { - switch(action.type) { - case actionTypes.ONBOARDING_CATALOG_OPEN_VENDOR_PAGE: - return { - ...state, - selectedVendor: action.selectedVendor - }; - case actionTypes.CHANGE_VSP_OVERLAY: - return { - ...state, - vspOverlay: action.vendorId - }; - case actionTypes.CLOSE_VSP_OVERLAY: - return { - ...state, - vspOverlay: null - }; - default: - return state; - } + switch (action.type) { + case actionTypes.ONBOARDING_CATALOG_OPEN_VENDOR_PAGE: + return { + ...state, + selectedVendor: action.selectedVendor + }; + case actionTypes.CHANGE_VSP_OVERLAY: + return { + ...state, + vspOverlay: action.vendorId + }; + case actionTypes.CLOSE_VSP_OVERLAY: + return { + ...state, + vspOverlay: null + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogView.jsx index 9914ea2154..02f8d50c5c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogView.jsx @@ -17,58 +17,100 @@ import React from 'react'; import VendorItem from './VendorItem.jsx'; import CatalogList from '../CatalogList.jsx'; import CatalogItemDetails from '../CatalogItemDetails.jsx'; -import {catalogItemTypes} from './OnboardingCatalogConstants.js'; -import {filterCatalogItemsByType} from './OnboardingCatalogUtils.js'; +import { catalogItemTypes } from './OnboardingCatalogConstants.js'; +import { filterCatalogItemsByType } from './OnboardingCatalogUtils.js'; -const VendorList = ({onAddVLM, onAddVSP, onSelectVSP, licenseModelList = [], vspOverlay: currentOverlay, onVspOverlayChange, onVendorSelect, filter, onMigrate, users}) => { - return( - - { - filterCatalogItemsByType({items: licenseModelList, filter}).map(vlm => - onSelectVSP(vsp, users)} - shouldShowOverlay={currentOverlay === vlm.id} - onVSPButtonClick={(hasVSP) => onVspOverlayChange(vlm.id === currentOverlay || !hasVSP ? null : vlm)} - onVendorSelect={onVendorSelect} - onMigrate={onMigrate} - vendor={vlm}/>) - } - - ); +const VendorList = ({ + onAddVLM, + onAddVSP, + onSelectVSP, + licenseModelList = [], + vspOverlay: currentOverlay, + onVspOverlayChange, + onVendorSelect, + filter, + onMigrate, + users +}) => { + return ( + + {filterCatalogItemsByType({ items: licenseModelList, filter }).map( + vlm => ( + onSelectVSP(vsp, users)} + shouldShowOverlay={currentOverlay === vlm.id} + onVSPButtonClick={hasVSP => + onVspOverlayChange( + vlm.id === currentOverlay || !hasVSP + ? null + : vlm + ) + } + onVendorSelect={onVendorSelect} + onMigrate={onMigrate} + vendor={vlm} + /> + ) + )} + + ); }; -const SoftwareProductListByVendor = ({onAddVSP, selectedVendor, onVendorSelect, onSelectVSP, onSelectVLM, filter, onMigrate, users}) => { - return( -
    - {onAddVSP(selectedVendor.id);}} vendorPageOptions={{selectedVendor, onBack: () => onVendorSelect(false)}}> - onSelectVLM(selectedVendor, users)} - catalogItemTypeClass={catalogItemTypes.LICENSE_MODEL} - onMigrate={onMigrate} - catalogItemData={selectedVendor}/> - { - filterCatalogItemsByType({items: selectedVendor.softwareProductList, filter}).map(vsp => - onSelectVSP(vsp, users)} - catalogItemData={vsp}/> - ) - } - -
    - ); +const SoftwareProductListByVendor = ({ + onAddVSP, + selectedVendor, + onVendorSelect, + onSelectVSP, + onSelectVLM, + filter, + onMigrate, + users +}) => { + return ( +
    + { + onAddVSP(selectedVendor.id); + }} + vendorPageOptions={{ + selectedVendor, + onBack: () => onVendorSelect(false) + }}> + onSelectVLM(selectedVendor, users)} + catalogItemTypeClass={catalogItemTypes.LICENSE_MODEL} + onMigrate={onMigrate} + catalogItemData={selectedVendor} + /> + {filterCatalogItemsByType({ + items: selectedVendor.softwareProductList, + filter + }).map(vsp => ( + onSelectVSP(vsp, users)} + catalogItemData={vsp} + /> + ))} + +
    + ); }; class VendorCatalogView extends React.Component { - render() { - let {selectedVendor} = this.props; - return( selectedVendor ? : ); - } + render() { + let { selectedVendor } = this.props; + return selectedVendor ? ( + + ) : ( + + ); + } } export default VendorCatalogView; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx index 158282cc48..bef47d5acf 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx @@ -16,82 +16,102 @@ import React from 'react'; import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {Tile, TileInfo, TileInfoLine, TileFooter, TileFooterCell, Button} from 'sdc-ui/lib/react'; +import { + Tile, + TileInfo, + TileInfoLine, + TileFooter, + TileFooterCell, + Button +} from 'sdc-ui/lib/react'; import VSPOverlay from './VSPOverlay.jsx'; -import {TooltipWrapper} from './Tooltip.jsx'; +import { TooltipWrapper } from './Tooltip.jsx'; class VendorItem extends React.Component { + static PropTypes = { + softwareProductList: PropTypes.array, + vendor: PropTypes.object, + shouldShowOverlay: PropTypes.bool, + onSelectVSP: PropTypes.func, + onVendorSelect: PropTypes.func, + onAddVSP: PropTypes.func, + onVSPButtonClick: PropTypes.func + }; - static PropTypes = { - softwareProductList: PropTypes.array, - vendor: PropTypes.object, - shouldShowOverlay: PropTypes.bool, - onSelectVSP: PropTypes.func, - onVendorSelect: PropTypes.func, - onAddVSP: PropTypes.func, - onVSPButtonClick: PropTypes.func - }; + render() { + let { + vendor, + onSelectVSP, + shouldShowOverlay, + onVendorSelect, + onMigrate + } = this.props; + let { softwareProductList = [], name } = vendor; + return ( + onVendorSelect(vendor)}> + + + + {name} + + + + + {shouldShowOverlay && + softwareProductList.length > 0 && ( + onVendorSelect(vendor)} + /> + )} + + + + + + + + + ); + } - render() { - let {vendor, onSelectVSP, shouldShowOverlay, onVendorSelect, onMigrate} = this.props; - let {softwareProductList = [], name} = vendor; - return ( - onVendorSelect(vendor)}> - - - {name} - - - - {shouldShowOverlay && softwareProductList.length > 0 && - onVendorSelect(vendor)} /> - } - - - - - - - - - ); - } - - onCreateVspClick(e) { - e.stopPropagation(); - e.preventDefault(); - const {onAddVSP, vendor: {id}} = this.props; - onAddVSP(id); - } - - handleVspCountClick(e){ - e.stopPropagation(); - e.preventDefault(); - const {onVSPButtonClick, vendor: {softwareProductList}} = this.props; - const hasVSP = Boolean(softwareProductList.length); - onVSPButtonClick(hasVSP); - } + onCreateVspClick(e) { + e.stopPropagation(); + e.preventDefault(); + const { onAddVSP, vendor: { id } } = this.props; + onAddVSP(id); + } + handleVspCountClick(e) { + e.stopPropagation(); + e.preventDefault(); + const { + onVSPButtonClick, + vendor: { softwareProductList } + } = this.props; + const hasVSP = Boolean(softwareProductList.length); + onVSPButtonClick(hasVSP); + } } export default VendorItem; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx index a937c11d85..2f17867af1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx @@ -16,31 +16,43 @@ import React from 'react'; import DetailsCatalogView from '../DetailsCatalogView.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {tabsMapping} from 'sdc-app/onboarding/onboard/OnboardConstants.js'; +import { tabsMapping } from 'sdc-app/onboarding/onboard/OnboardConstants.js'; -const WorkspaceView = (props) => { - let { - licenseModelList, softwareProductList, onAddLicenseModelClick, users, - onAddSoftwareProductClick, onSelectLicenseModel, onSelectSoftwareProduct, searchValue, onMigrate - } = props; +const WorkspaceView = props => { + let { + licenseModelList, + softwareProductList, + onAddLicenseModelClick, + users, + onAddSoftwareProductClick, + onSelectLicenseModel, + onSelectSoftwareProduct, + searchValue, + onMigrate + } = props; - return ( -
    -
    - {i18n('WORKSPACE')} -
    - onSelectLicenseModel(item, users, tabsMapping.WORKSPACE)} - onSelectVSP={(item, users) => onSelectSoftwareProduct(item, users, tabsMapping.WORKSPACE)} - onMigrate={onMigrate} - filter={searchValue} /> -
    - ); + return ( +
    +
    + {i18n('WORKSPACE')} +
    + + onSelectLicenseModel(item, users, tabsMapping.WORKSPACE) + } + onSelectVSP={(item, users) => + onSelectSoftwareProduct(item, users, tabsMapping.WORKSPACE) + } + onMigrate={onMigrate} + filter={searchValue} + /> +
    + ); }; export default WorkspaceView; diff --git a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsActionHelper.js index c25d93f2fc..d42a2f83ad 100644 --- a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsActionHelper.js @@ -15,94 +15,110 @@ */ import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {actionTypes} from './PermissionsConstants.js'; -import {permissionTypes} from './PermissionsConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {askForRightsMsg} from './PermissionsManager.jsx'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes } from './PermissionsConstants.js'; +import { permissionTypes } from './PermissionsConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { askForRightsMsg } from './PermissionsManager.jsx'; import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; const PermissionsActionHelper = { - openPermissonsManager(dispatch, {itemId, askForRights}) { - if (askForRights) { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - title: i18n('Ask For Contributers Rights'), - msg: askForRightsMsg(), - confirmationButtonText: i18n('SEND'), - onConfirmed: () => this.askForContributorRights() - } - }); - } else { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.MANAGE_PERMISSIONS, - title: i18n('Manage Permissions'), - modalComponentProps: { - itemId - } - } - }); - } - }, + openPermissonsManager(dispatch, { itemId, askForRights }) { + if (askForRights) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + title: i18n('Ask For Contributers Rights'), + msg: askForRightsMsg(), + confirmationButtonText: i18n('SEND'), + onConfirmed: () => this.askForContributorRights() + } + }); + } else { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.MANAGE_PERMISSIONS, + title: i18n('Manage Permissions'), + modalComponentProps: { + itemId + } + } + }); + } + }, - closePermissionManager(dispatch) { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - }, + closePermissionManager(dispatch) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + }, - saveItemUsers(dispatch, {itemId, removedUsersIds, addedUsersIds, allUsers}) { - return ItemsHelper.updateContributors({itemId, removedUsersIds, addedUsersIds}).then(() => - PermissionsActionHelper.fetchItemUsers(dispatch, {itemId, allUsers}) - ); - }, + saveItemUsers( + dispatch, + { itemId, removedUsersIds, addedUsersIds, allUsers } + ) { + return ItemsHelper.updateContributors({ + itemId, + removedUsersIds, + addedUsersIds + }).then(() => + PermissionsActionHelper.fetchItemUsers(dispatch, { + itemId, + allUsers + }) + ); + }, - changeOwner(dispatch, {itemId, newOwnerId, allUsers}) { - return ItemsHelper.changeOwner({itemId, ownerId: newOwnerId}).then(() => - PermissionsActionHelper.fetchItemUsers(dispatch, {itemId, allUsers}) - ); - }, + changeOwner(dispatch, { itemId, newOwnerId, allUsers }) { + return ItemsHelper.changeOwner({ itemId, ownerId: newOwnerId }).then( + () => + PermissionsActionHelper.fetchItemUsers(dispatch, { + itemId, + allUsers + }) + ); + }, - fetchItemUsers(dispatch, {itemId, allUsers}) { - return ItemsHelper.fetchUsers({itemId}).then(response => { + fetchItemUsers(dispatch, { itemId, allUsers }) { + return ItemsHelper.fetchUsers({ itemId }).then(response => { + let allContributors = response.results; - let allContributors = response.results; - - let owner = {}; - let contributors = []; - allContributors.map(user => { - let userObject = allUsers.find(userObject => userObject.userId === user.userId); - if (userObject) { - user = {...user, fullName: userObject.fullName, role: userObject.role}; - - switch(user.permission) { - case permissionTypes.OWNER: - owner = user; - break; - case permissionTypes.CONTRIBUTOR: - contributors.push(user); - break; - } - } - }); - - dispatch({ - type: actionTypes.ITEM_USERS_LOADED, - contributors, - owner - }); - }); - }, - - askForContributorRights() { - console.log('asked for contributor rights'); - } + let owner = {}; + let contributors = []; + allContributors.map(user => { + let userObject = allUsers.find( + userObject => userObject.userId === user.userId + ); + if (userObject) { + user = { + ...user, + fullName: userObject.fullName, + role: userObject.role + }; + switch (user.permission) { + case permissionTypes.OWNER: + owner = user; + break; + case permissionTypes.CONTRIBUTOR: + contributors.push(user); + break; + } + } + }); + dispatch({ + type: actionTypes.ITEM_USERS_LOADED, + contributors, + owner + }); + }); + }, + askForContributorRights() { + console.log('asked for contributor rights'); + } }; export default PermissionsActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsConstants.js b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsConstants.js index 48a3461799..686aaaf0dd 100644 --- a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsConstants.js @@ -16,12 +16,13 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - ITEM_USERS_LOADED: null + ITEM_USERS_LOADED: null }); export const permissionTypes = { - OWNER: 'Owner', - CONTRIBUTOR: 'Contributor' + OWNER: 'Owner', + CONTRIBUTOR: 'Contributor' }; -export const changeOwnerMessage = 'You will no longer be able to manage the permissions of this item.\nYour permission level will be set to contributor.'; +export const changeOwnerMessage = + 'You will no longer be able to manage the permissions of this item.\nYour permission level will be set to contributor.'; diff --git a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsManager.js b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsManager.js index ba6562b28f..3b6d62bc15 100644 --- a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsManager.js +++ b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsManager.js @@ -14,30 +14,55 @@ * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import PermissionsManager from './PermissionsManager.jsx'; import PermissionsActionHelper from './PermissionsActionHelper.js'; -export const mapStateToProps = ({versionsPage, users: {usersList, userInfo}}) => { - let {permissions} = versionsPage; +export const mapStateToProps = ({ + versionsPage, + users: { usersList, userInfo } +}) => { + let { permissions } = versionsPage; - return { - users: usersList, - userInfo, - owner: permissions.owner, - itemUsers: permissions.contributors - }; + return { + users: usersList, + userInfo, + owner: permissions.owner, + itemUsers: permissions.contributors + }; }; -const mapActionsToProps = (dispatch) => { - return { - onCancel: () => PermissionsActionHelper.closePermissionManager(dispatch), - onSubmit: ({itemId, addedUsersIds, removedUsersIds, allUsers, newOwnerId}) => { - return PermissionsActionHelper.saveItemUsers(dispatch,{itemId, addedUsersIds, removedUsersIds, allUsers}).then(() => { - return newOwnerId ? PermissionsActionHelper.changeOwner(dispatch, {itemId, newOwnerId, allUsers}) : Promise.resolve(); - }).then(() => PermissionsActionHelper.closePermissionManager(dispatch)); - } - }; +const mapActionsToProps = dispatch => { + return { + onCancel: () => + PermissionsActionHelper.closePermissionManager(dispatch), + onSubmit: ({ + itemId, + addedUsersIds, + removedUsersIds, + allUsers, + newOwnerId + }) => { + return PermissionsActionHelper.saveItemUsers(dispatch, { + itemId, + addedUsersIds, + removedUsersIds, + allUsers + }) + .then(() => { + return newOwnerId + ? PermissionsActionHelper.changeOwner(dispatch, { + itemId, + newOwnerId, + allUsers + }) + : Promise.resolve(); + }) + .then(() => + PermissionsActionHelper.closePermissionManager(dispatch) + ); + } + }; }; export default connect(mapStateToProps, mapActionsToProps)(PermissionsManager); diff --git a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsManager.jsx b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsManager.jsx index b7d5d57cca..ab6add8ac2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsManager.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsManager.jsx @@ -21,97 +21,154 @@ import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; import Tooltip from 'react-bootstrap/lib/Tooltip.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {permissionTypes, changeOwnerMessage} from './PermissionsConstants.js'; +import { permissionTypes, changeOwnerMessage } from './PermissionsConstants.js'; export const askForRightsMsg = () => { - return ( -
    -

    {i18n('Send a Contributor rights reguest to Owner')}

    -
    - ); + return ( +
    +

    {i18n('Send a Contributor rights reguest to Owner')}

    +
    + ); }; - class Permissions extends React.Component { - constructor(props) { - super(props); - this.state = { - itemUsers: props.itemUsers, - newOwnerId: '', - showChangeOwner: false - }; - } + constructor(props) { + super(props); + this.state = { + itemUsers: props.itemUsers, + newOwnerId: '', + showChangeOwner: false + }; + } - buildUserOptions() { - let {users, owner} = this.props; - return users.filter(user => user.userId !== owner.userId).map(item => {return {label: item.fullName, value: item.userId};}); - } + buildUserOptions() { + let { users, owner } = this.props; + return users.filter(user => user.userId !== owner.userId).map(item => { + return { label: item.fullName, value: item.userId }; + }); + } - render() { - let {onCancel, owner} = this.props; - let {newOwnerId} = this.state; - return ( -
    -
    this.onsaveItemUsers()} - onReset={() => onCancel() } - labledButtons={true}> -
    {i18n('Owner')}
    -
    - {owner.fullName} - this.setState({showChangeOwner: !this.state.showChangeOwner})}>{i18n('Change Owner')} -
    - {this.state.showChangeOwner &&
    -
    - {i18n('Change Owner')} - {i18n(changeOwnerMessage)} }> - - -
    - item.userId)} - className='options-input contributors-select' - clearable={false} - onMultiSelectChanged={(value) => {this.onChangeItemUsers({itemUsers: value});}} - options={this.buildUserOptions()} - multi/> - -
    - ); - } + render() { + let { onCancel, owner } = this.props; + let { newOwnerId } = this.state; + return ( +
    +
    this.onsaveItemUsers()} + onReset={() => onCancel()} + labledButtons={true}> +
    + {i18n('Owner')} +
    +
    + {owner.fullName} + + this.setState({ + showChangeOwner: !this.state.showChangeOwner + }) + }> + {i18n('Change Owner')} + +
    + {this.state.showChangeOwner && ( +
    +
    + + {i18n('Change Owner')} + + + {i18n(changeOwnerMessage)} + + }> + + +
    + item.userId)} + className="options-input contributors-select" + clearable={false} + onMultiSelectChanged={value => { + this.onChangeItemUsers({ itemUsers: value }); + }} + options={this.buildUserOptions()} + multi + /> + +
    + ); + } - onChangeItemUsers({itemUsers}) { - this.setState({ - itemUsers: itemUsers.map(contributor => { - let contributorFromProps = this.props.itemUsers.find(user => user.userId === contributor.userId); - return { - userId: contributor.value, - fullName: contributor.label, - permission: contributorFromProps ? contributorFromProps.permission : permissionTypes.CONTRIBUTOR - }; - }) - }); - } + onChangeItemUsers({ itemUsers }) { + this.setState({ + itemUsers: itemUsers.map(contributor => { + let contributorFromProps = this.props.itemUsers.find( + user => user.userId === contributor.userId + ); + return { + userId: contributor.value, + fullName: contributor.label, + permission: contributorFromProps + ? contributorFromProps.permission + : permissionTypes.CONTRIBUTOR + }; + }) + }); + } - onsaveItemUsers() { - let {itemUsers: newUsers, newOwnerId} = this.state; - let {itemUsers: oldUsers, onSubmit, itemId, users} = this.props; - let addedUsersIds = newUsers.filter(newUser => !oldUsers.map(oldUser => oldUser.userId).includes(newUser.userId)) - .map(user => user.userId); - let removedUsersIds = oldUsers.filter(oldUser => !newUsers.map(newUser => newUser.userId).includes(oldUser.userId)) - .map(user => user.userId); - onSubmit({itemId, addedUsersIds, removedUsersIds, allUsers: users, newOwnerId}); - } + onsaveItemUsers() { + let { itemUsers: newUsers, newOwnerId } = this.state; + let { itemUsers: oldUsers, onSubmit, itemId, users } = this.props; + let addedUsersIds = newUsers + .filter( + newUser => + !oldUsers + .map(oldUser => oldUser.userId) + .includes(newUser.userId) + ) + .map(user => user.userId); + let removedUsersIds = oldUsers + .filter( + oldUser => + !newUsers + .map(newUser => newUser.userId) + .includes(oldUser.userId) + ) + .map(user => user.userId); + onSubmit({ + itemId, + addedUsersIds, + removedUsersIds, + allUsers: users, + newOwnerId + }); + } } export default Permissions; diff --git a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsReducer.js b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsReducer.js index b4ab78964d..6e817ae3db 100644 --- a/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/permissions/PermissionsReducer.js @@ -13,16 +13,16 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './PermissionsConstants.js'; +import { actionTypes } from './PermissionsConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.ITEM_USERS_LOADED: - return { - owner: action.owner, - contributors: action.contributors - }; - default: - return state; - } -}; \ No newline at end of file + switch (action.type) { + case actionTypes.ITEM_USERS_LOADED: + return { + owner: action.owner, + contributors: action.contributors + }; + default: + return state; + } +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/revisions/Revisions.js b/openecomp-ui/src/sdc-app/onboarding/revisions/Revisions.js index 73ee5dea21..738e7459fe 100644 --- a/openecomp-ui/src/sdc-app/onboarding/revisions/Revisions.js +++ b/openecomp-ui/src/sdc-app/onboarding/revisions/Revisions.js @@ -14,24 +14,31 @@ * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import RevisionsView from './RevisionsView.jsx'; import RevisionsActionHelper from './RevisionsActionHelper.js'; -export const mapStateToProps = ({revisions, users}) => { - return { - revisions: revisions, - users: users.usersList - }; +export const mapStateToProps = ({ revisions, users }) => { + return { + revisions: revisions, + users: users.usersList + }; }; -export const mapActionsToProps = (dispatch, {itemId, version, itemType}) => { - return { - onCancel: () => RevisionsActionHelper.closeRevisionsView(dispatch), - onRevert: (revisionId) => { - RevisionsActionHelper.revertToRevision(dispatch, {itemId, version, revisionId, itemType}); - } - }; +export const mapActionsToProps = (dispatch, { itemId, version, itemType }) => { + return { + onCancel: () => RevisionsActionHelper.closeRevisionsView(dispatch), + onRevert: revisionId => { + RevisionsActionHelper.revertToRevision(dispatch, { + itemId, + version, + revisionId, + itemType + }); + } + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(RevisionsView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(RevisionsView); diff --git a/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsActionHelper.js index 4fd9082b5b..61ccad0cc4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsActionHelper.js @@ -16,85 +16,89 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {actionsEnum as vcActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionsEnum as vcActionsEnum } from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; -import {actionTypes} from './RevisionsConstants.js'; +import { actionTypes } from './RevisionsConstants.js'; function baseUrl(itemId, version) { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/items/${itemId}/versions/${version.id}`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/items/${itemId}/versions/${version.id}`; } -function fetchRevisions(itemId, version){ - let fetchUrl = `${baseUrl(itemId, version)}/revisions`; - return RestAPIUtil.fetch(fetchUrl); +function fetchRevisions(itemId, version) { + let fetchUrl = `${baseUrl(itemId, version)}/revisions`; + return RestAPIUtil.fetch(fetchUrl); } function revertToRevision(itemId, version, revisionId) { - let putUrl = `${baseUrl(itemId, version)}/actions`; - let requestBody = { - action: vcActionsEnum.REVERT, - revisionRequest: { - revisionId: revisionId - } - }; - return RestAPIUtil.put(putUrl, requestBody); + let putUrl = `${baseUrl(itemId, version)}/actions`; + let requestBody = { + action: vcActionsEnum.REVERT, + revisionRequest: { + revisionId: revisionId + } + }; + return RestAPIUtil.put(putUrl, requestBody); } const RevisionaActionHelper = { - openRevisionsView(dispatch, {itemId, version, itemType}) { - this.fetchRevisions(dispatch, {itemId, version}).then(() => { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.REVISIONS_LIST, - modalClassName: 'manage-revisions-modal', - title: i18n('Revert'), - modalComponentProps: { - itemId: itemId, - version: version, - itemType - } - } - }); - }); - }, + openRevisionsView(dispatch, { itemId, version, itemType }) { + this.fetchRevisions(dispatch, { itemId, version }).then(() => { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.REVISIONS_LIST, + modalClassName: 'manage-revisions-modal', + title: i18n('Revert'), + modalComponentProps: { + itemId: itemId, + version: version, + itemType + } + } + }); + }); + }, - closeRevisionsView(dispatch) { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - }, + closeRevisionsView(dispatch) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + }, + fetchRevisions(dispatch, { itemId, version }) { + return fetchRevisions(itemId, version).then(response => { + dispatch({ + type: actionTypes.ITEM_REVISIONS_LOADED, + response: response + }); + }); + }, - fetchRevisions(dispatch, {itemId, version}) { - return fetchRevisions(itemId, version).then((response) => { - dispatch({ - type: actionTypes.ITEM_REVISIONS_LOADED, - response: response - }); - }); - }, - - revertToRevision(dispatch, {itemId, version, revisionId, itemType}) { - return revertToRevision(itemId, version, revisionId).then(() => { - this.closeRevisionsView(dispatch); - if (itemType === screenTypes.LICENSE_MODEL) { - ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.LICENSE_MODEL_OVERVIEW, screenType: screenTypes.LICENSE_MODEL, - props: {licenseModelId: itemId, version}}); - } else { - ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId: itemId, version}}); - } - }); - - } + revertToRevision(dispatch, { itemId, version, revisionId, itemType }) { + return revertToRevision(itemId, version, revisionId).then(() => { + this.closeRevisionsView(dispatch); + if (itemType === screenTypes.LICENSE_MODEL) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.LICENSE_MODEL_OVERVIEW, + screenType: screenTypes.LICENSE_MODEL, + props: { licenseModelId: itemId, version } + }); + } else { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId: itemId, version } + }); + } + }); + } }; export default RevisionaActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsConstants.js b/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsConstants.js index 28a9fa0ff5..dc1845c59c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsConstants.js @@ -16,5 +16,5 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - ITEM_REVISIONS_LOADED: null + ITEM_REVISIONS_LOADED: null }); diff --git a/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsReducer.js b/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsReducer.js index 778350b93f..a3e6ce8ab0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsReducer.js @@ -13,13 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './RevisionsConstants.js'; +import { actionTypes } from './RevisionsConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.ITEM_REVISIONS_LOADED: - return action.response.results; - default: - return state; - } -}; \ No newline at end of file + switch (action.type) { + case actionTypes.ITEM_REVISIONS_LOADED: + return action.response.results; + default: + return state; + } +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsView.jsx b/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsView.jsx index d6ef604a22..1fc8c06925 100644 --- a/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/revisions/RevisionsView.jsx @@ -23,65 +23,111 @@ import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; - class RevisionsView extends React.Component { - constructor(props) { - super(props); - this.state = { - revertId : null - }; - } - - render() { - let {onCancel, onRevert, revisions, users} = this.props; - return ( -
    -
    onRevert(this.state.revertId)} - onReset={() => onCancel() } - submitButtonText={i18n('Revert')} - labledButtons={true}> - - {revisions.map((revision) => { - return ( -
    - this.setState({revertId : revision.id})}> - -
    -
    - userObject.userId === revision.user).fullName} labelPosition='right'/> -
    -
    - {i18n.dateNormal(revision.time, { - year: 'numeric', month: 'numeric', day: 'numeric' - })} - {i18n.dateNormal(revision.time, { - hour: 'numeric', minute: 'numeric', - hour12: true - })} -
    -
    - {revision.message && - {revision.message} - }
    -
    -
    -
    -
    - - ); - })} -
    -
    -
    - ); - } + constructor(props) { + super(props); + this.state = { + revertId: null + }; + } + render() { + let { onCancel, onRevert, revisions, users } = this.props; + return ( +
    +
    onRevert(this.state.revertId)} + onReset={() => onCancel()} + submitButtonText={i18n('Revert')} + labledButtons={true}> + + {revisions.map(revision => { + return ( +
    + + this.setState({ + revertId: revision.id + }) + }> + +
    +
    + + userObject.userId === + revision.user + ).fullName + } + labelPosition="right" + /> +
    +
    + + {i18n.dateNormal( + revision.time, + { + year: 'numeric', + month: + 'numeric', + day: 'numeric' + } + )} + + + {i18n.dateNormal( + revision.time, + { + hour: 'numeric', + minute: + 'numeric', + hour12: true + } + )} + +
    +
    + {revision.message && ( + + {revision.message} + + )} +
    +
    +
    +
    +
    + ); + })} +
    +
    +
    + ); + } } export default RevisionsView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/ArchivedSoftwareProductReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/ArchivedSoftwareProductReducer.js index b484f5e0a0..9faa6ffd68 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/ArchivedSoftwareProductReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/ArchivedSoftwareProductReducer.js @@ -13,13 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductConstants.js'; +import { actionTypes } from './SoftwareProductConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.ARCHIVED_SOFTWARE_PRODUCT_LIST_LOADED: - return [...action.response.results]; - default: - return state; - } + switch (action.type) { + case actionTypes.ARCHIVED_SOFTWARE_PRODUCT_LIST_LOADED: + return [...action.response.results]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/FinalizedSoftwareProductReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/FinalizedSoftwareProductReducer.js index 396f65f5d7..f91c8f31e3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/FinalizedSoftwareProductReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/FinalizedSoftwareProductReducer.js @@ -13,13 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductConstants.js'; +import { actionTypes } from './SoftwareProductConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.FINALIZED_SOFTWARE_PRODUCT_LIST_LOADED: - return [...action.response.results]; - default: - return state; - } + switch (action.type) { + case actionTypes.FINALIZED_SOFTWARE_PRODUCT_LIST_LOADED: + return [...action.response.results]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js index e3ea7e1907..db3cc04f76 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js @@ -13,359 +13,668 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; import TabulatedEditor from 'src/nfvo-components/editor/TabulatedEditor.jsx'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; -import {onboardingMethod as onboardingMethodTypes, onboardingOriginTypes} from './SoftwareProductConstants.js'; +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; +import { + onboardingMethod as onboardingMethodTypes, + onboardingOriginTypes +} from './SoftwareProductConstants.js'; import SoftwareProductActionHelper from './SoftwareProductActionHelper.js'; import SoftwareProductComponentsActionHelper from './components/SoftwareProductComponentsActionHelper.js'; import PermissionsActionHelper from './../permissions/PermissionsActionHelper.js'; import RevisionsActionHelper from './../revisions/RevisionsActionHelper.js'; import HeatSetupActionHelper from './attachments/setup/HeatSetupActionHelper.js'; import { actionsEnum as versionControllerActions } from 'nfvo-components/panel/versionController/VersionControllerConstants.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'; -import {onboardingMethod as onboardingMethodType} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; -import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js'; -import {catalogItemStatuses} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.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'; +import { onboardingMethod as onboardingMethodType } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js'; +import { catalogItemStatuses } from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; function getActiveNavigationId(screen, componentId) { - let activeItemId = componentId ? screen + '|' + componentId : screen; - return activeItemId; + let activeItemId = componentId ? screen + '|' + componentId : screen; + return activeItemId; } -const buildComponentNavigationBarGroups = ({componentId, meta}) => { - const groups = ([ - { - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL + '|' + componentId, - name: i18n('General'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE + '|' + componentId, - name: i18n('Compute'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING + '|' + componentId, - name: i18n('High Availability & Load Balancing'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK + '|' + componentId, - name: i18n('Networks'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE + '|' + componentId, - name: i18n('Storage'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES + '|' + componentId, - name: i18n('Images'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES + '|' + componentId, - name: i18n('Process Details'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING + '|' + componentId, - name: i18n('Monitoring'), - disabled: false, - meta - } - ]); +const buildComponentNavigationBarGroups = ({ componentId, meta }) => { + const groups = [ + { + id: + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL + + '|' + + componentId, + name: i18n('General'), + disabled: false, + meta + }, + { + id: + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE + + '|' + + componentId, + name: i18n('Compute'), + disabled: false, + meta + }, + { + id: + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING + + '|' + + componentId, + name: i18n('High Availability & Load Balancing'), + disabled: false, + meta + }, + { + id: + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK + + '|' + + componentId, + name: i18n('Networks'), + disabled: false, + meta + }, + { + id: + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE + + '|' + + componentId, + name: i18n('Storage'), + disabled: false, + meta + }, + { + id: + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES + + '|' + + componentId, + name: i18n('Images'), + disabled: false, + meta + }, + { + id: + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES + + '|' + + componentId, + name: i18n('Process Details'), + disabled: false, + meta + }, + { + id: + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING + + '|' + + componentId, + name: i18n('Monitoring'), + disabled: false, + meta + } + ]; - return groups; + return groups; }; -const buildNavigationBarProps = ({softwareProduct, meta, screen, componentId, componentsList, mapOfExpandedIds}) => { - const {softwareProductEditor: {data: currentSoftwareProduct = {}}} = softwareProduct; - const {id, name, onboardingMethod, candidateOnboardingOrigin, onboardingOrigin} = currentSoftwareProduct; - const groups = [{ - id: id, - name: name, - items: [ - { - id: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, - name: i18n('Overview'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, - name: i18n('General'), - disabled: false, - meta - }, - { - id: enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT, - name: i18n('Deployment Flavors'), - disabled: false, - hidden: onboardingMethod !== onboardingMethodTypes.MANUAL, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, - name: i18n('Process Details'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, - name: i18n('Networks'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, - name: i18n('Attachments'), - disabled: false, - hidden: !candidateOnboardingOrigin && !onboardingOrigin, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, - name: i18n('Activity Log'), - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, - name: i18n('Component Dependencies'), - hidden: componentsList.length <= 1, - disabled: false, - meta - }, { - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, - name: i18n('Components'), - hidden: componentsList.length <= 0, - meta, - expanded: mapOfExpandedIds[enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS] === true && screen !== enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, - items: [ - ...componentsList.map(({id, displayName}) => ({ - id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS + '|' + id, - name: displayName, - meta, - expanded: mapOfExpandedIds[enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS + '|' + id] === true && screen !== enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, - items: buildComponentNavigationBarGroups({componentId: id, meta}) - })) - ] - } - ] - }]; - let activeItemId = getActiveNavigationId(screen, componentId); - return { - activeItemId, groups, disabled: !!candidateOnboardingOrigin - }; +const buildNavigationBarProps = ({ + softwareProduct, + meta, + screen, + componentId, + componentsList, + mapOfExpandedIds +}) => { + const { + softwareProductEditor: { data: currentSoftwareProduct = {} } + } = softwareProduct; + const { + id, + name, + onboardingMethod, + candidateOnboardingOrigin, + onboardingOrigin + } = currentSoftwareProduct; + const groups = [ + { + id: id, + name: name, + items: [ + { + id: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + name: i18n('Overview'), + disabled: false, + meta + }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, + name: i18n('General'), + disabled: false, + meta + }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT, + name: i18n('Deployment Flavors'), + disabled: false, + hidden: onboardingMethod !== onboardingMethodTypes.MANUAL, + meta + }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, + name: i18n('Process Details'), + disabled: false, + meta + }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, + name: i18n('Networks'), + disabled: false, + meta + }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, + name: i18n('Attachments'), + disabled: false, + hidden: !candidateOnboardingOrigin && !onboardingOrigin, + meta + }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, + name: i18n('Activity Log'), + disabled: false, + meta + }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, + name: i18n('Component Dependencies'), + hidden: componentsList.length <= 1, + disabled: false, + meta + }, + { + id: enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, + name: i18n('Components'), + hidden: componentsList.length <= 0, + meta, + expanded: + mapOfExpandedIds[ + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS + ] === true && + screen !== enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + items: [ + ...componentsList.map(({ id, displayName }) => ({ + id: + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS + + '|' + + id, + name: displayName, + meta, + expanded: + mapOfExpandedIds[ + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS + + '|' + + id + ] === true && + screen !== + enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + items: buildComponentNavigationBarGroups({ + componentId: id, + meta + }) + })) + ] + } + ] + } + ]; + let activeItemId = getActiveNavigationId(screen, componentId); + return { + activeItemId, + groups, + disabled: !!candidateOnboardingOrigin + }; }; -const buildVersionControllerProps = ({softwareProduct, versions, currentVersion, permissions, userInfo, isArchived, usersList, itemPermission, isReadOnlyMode}) => { - const {softwareProductEditor = {data: {}}} = softwareProduct; - const {isValidityData = true, data: {name, onboardingMethod, candidateOnboardingOrigin}} = softwareProductEditor; - - return { - version: currentVersion, - viewableVersions: versions, - isFormDataValid: isValidityData, - permissions, - itemName: name, - itemPermission, - isReadOnlyMode, - isArchived, - userInfo, - usersList, - isManual: onboardingMethod === onboardingMethodType.MANUAL, - candidateInProcess: !!candidateOnboardingOrigin - }; +const buildVersionControllerProps = ({ + softwareProduct, + versions, + currentVersion, + permissions, + userInfo, + isArchived, + usersList, + itemPermission, + isReadOnlyMode +}) => { + const { softwareProductEditor = { data: {} } } = softwareProduct; + const { + isValidityData = true, + data: { name, onboardingMethod, candidateOnboardingOrigin } + } = softwareProductEditor; + + return { + version: currentVersion, + viewableVersions: versions, + isFormDataValid: isValidityData, + permissions, + itemName: name, + itemPermission, + isReadOnlyMode, + isArchived, + userInfo, + usersList, + isManual: onboardingMethod === onboardingMethodType.MANUAL, + candidateInProcess: !!candidateOnboardingOrigin + }; }; -function buildMeta({softwareProduct, componentId, softwareProductDependencies, isReadOnlyMode}) { - const {softwareProductEditor, softwareProductComponents, softwareProductQuestionnaire, softwareProductAttachments} = softwareProduct; - const {data: currentSoftwareProduct = {}} = softwareProductEditor; - const {version, onboardingOrigin, candidateOnboardingOrigin} = currentSoftwareProduct; - const {qdata} = softwareProductQuestionnaire; - const {heatSetup, heatSetupCache} = softwareProductAttachments; - let currentComponentMeta = {}; - if(componentId) { - const {componentEditor: {data: componentData = {} , qdata: componentQdata}} = softwareProductComponents; - currentComponentMeta = {componentData, componentQdata}; - } - const meta = {softwareProduct: currentSoftwareProduct, qdata, version, onboardingOrigin, candidateOnboardingOrigin, heatSetup, heatSetupCache, - isReadOnlyMode, currentComponentMeta, softwareProductDependencies}; - return meta; +function buildMeta({ + softwareProduct, + componentId, + softwareProductDependencies, + isReadOnlyMode +}) { + const { + softwareProductEditor, + softwareProductComponents, + softwareProductQuestionnaire, + softwareProductAttachments + } = softwareProduct; + const { data: currentSoftwareProduct = {} } = softwareProductEditor; + const { + version, + onboardingOrigin, + candidateOnboardingOrigin + } = currentSoftwareProduct; + const { qdata } = softwareProductQuestionnaire; + const { heatSetup, heatSetupCache } = softwareProductAttachments; + let currentComponentMeta = {}; + if (componentId) { + const { + componentEditor: { data: componentData = {}, qdata: componentQdata } + } = softwareProductComponents; + currentComponentMeta = { componentData, componentQdata }; + } + const meta = { + softwareProduct: currentSoftwareProduct, + qdata, + version, + onboardingOrigin, + candidateOnboardingOrigin, + heatSetup, + heatSetupCache, + isReadOnlyMode, + currentComponentMeta, + softwareProductDependencies + }; + return meta; } const mapStateToProps = ( - { - softwareProduct, - users: {usersList, userInfo}, - versionsPage: {versionsList: {versions}, permissions} - }, - { - currentScreen: {screen, itemPermission, props: {version: currentVersion, componentId, isReadOnlyMode}} - } + { + softwareProduct, + users: { usersList, userInfo }, + versionsPage: { versionsList: { versions }, permissions } + }, + { + currentScreen: { + screen, + itemPermission, + props: { version: currentVersion, componentId, isReadOnlyMode } + } + } ) => { - const {softwareProductEditor, softwareProductComponents, softwareProductDependencies} = softwareProduct; - const {mapOfExpandedIds = []} = softwareProductEditor; - const {componentsList = []} = softwareProductComponents; + const { + softwareProductEditor, + softwareProductComponents, + softwareProductDependencies + } = softwareProduct; + const { mapOfExpandedIds = [] } = softwareProductEditor; + const { componentsList = [] } = softwareProductComponents; - const meta = buildMeta({softwareProduct, componentId, softwareProductDependencies, isReadOnlyMode}); - return { - versionControllerProps: buildVersionControllerProps({ - softwareProduct, - versions, - currentVersion, - userInfo, - usersList, - isArchived: itemPermission.isArchived, - permissions, - itemPermission: {...itemPermission, isDirty: true}, - isReadOnlyMode - }), - navigationBarProps: buildNavigationBarProps({softwareProduct, meta, screen, componentId, componentsList, mapOfExpandedIds}), - meta - }; + const meta = buildMeta({ + softwareProduct, + componentId, + softwareProductDependencies, + isReadOnlyMode + }); + return { + versionControllerProps: buildVersionControllerProps({ + softwareProduct, + versions, + currentVersion, + userInfo, + usersList, + isArchived: itemPermission.isArchived, + permissions, + itemPermission: { ...itemPermission, isDirty: true }, + isReadOnlyMode + }), + navigationBarProps: buildNavigationBarProps({ + softwareProduct, + meta, + screen, + componentId, + componentsList, + mapOfExpandedIds + }), + meta + }; }; -const autoSaveBeforeNavigate = ({dispatch, screen, softwareProductId, version, componentId, - meta: {isReadOnlyMode, softwareProduct, qdata, - currentComponentMeta: {componentData, componentQdata}}}) => { - let promise; - if (isReadOnlyMode) { - promise = Promise.resolve(); - } else { - switch(screen) { - case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: - promise = SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {softwareProduct, version, qdata}); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: - promise = SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, - {softwareProductId, version, vspComponentId: componentId, componentData, qdata: componentQdata}); - break; - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: - promise = SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId: componentId, qdata: componentQdata}); - break; - default: - promise = Promise.resolve(); - break; - } - } - return promise; +const autoSaveBeforeNavigate = ({ + dispatch, + screen, + softwareProductId, + version, + componentId, + meta: { + isReadOnlyMode, + softwareProduct, + qdata, + currentComponentMeta: { componentData, componentQdata } + } +}) => { + let promise; + if (isReadOnlyMode) { + promise = Promise.resolve(); + } else { + switch (screen) { + case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: + promise = SoftwareProductActionHelper.updateSoftwareProduct( + dispatch, + { softwareProduct, version, qdata } + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: + promise = SoftwareProductComponentsActionHelper.updateSoftwareProductComponent( + dispatch, + { + softwareProductId, + version, + vspComponentId: componentId, + componentData, + qdata: componentQdata + } + ); + break; + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_IMAGES: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: + promise = SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire( + dispatch, + { + softwareProductId, + version, + vspComponentId: componentId, + qdata: componentQdata + } + ); + break; + default: + promise = Promise.resolve(); + break; + } + } + return promise; }; +const mapActionsToProps = ( + dispatch, + { + currentScreen: { + screen, + props: { + softwareProductId, + licenseModelId, + version, + componentId: currentComponentId + } + } + } +) => { + const props = { + onVersionSwitching: (versionToSwitch, meta) => { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId: meta.softwareProduct.id, + version: versionToSwitch + } + }); + }, + onOpenPermissions: ({ users }) => { + return PermissionsActionHelper.fetchItemUsers(dispatch, { + itemId: softwareProductId, + allUsers: users + }); + }, + onOpenRevisionsModal: () => { + return RevisionsActionHelper.openRevisionsView(dispatch, { + itemId: softwareProductId, + version: version, + itemType: screenTypes.SOFTWARE_PRODUCT + }); + }, + onOpenCommentCommitModal: ({ onCommit, title }) => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.COMMIT_COMMENT, + modalComponentProps: { + onCommit, + type: CommitModalType.COMMIT + }, + title + } + }), + onMoreVersionsClick: ({ itemName, users }) => { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + softwareProduct: { + name: itemName, + vendorId: licenseModelId + }, + usersList: users + } + }); + }, + onToggle: (groups, itemIdToExpand) => + groups.map(({ items }) => + SoftwareProductActionHelper.toggleNavigationItems(dispatch, { + items, + itemIdToExpand + }) + ), + onNavigate: ({ id, meta, newVersion }) => { + let navigationVersion = newVersion || version; + let { + onboardingOrigin, + candidateOnboardingOrigin, + heatSetup, + heatSetupCache + } = meta; + let heatSetupPopupPromise = + screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS + ? HeatSetupActionHelper.heatSetupLeaveConfirmation( + dispatch, + { softwareProductId, heatSetup, heatSetupCache } + ) + : Promise.resolve(); + let preNavigate = meta + ? autoSaveBeforeNavigate({ + dispatch, + screen, + meta, + version, + softwareProductId, + componentId: currentComponentId + }) + : Promise.resolve(); + version = version || (meta ? meta.version : undefined); + Promise.all([preNavigate, heatSetupPopupPromise]) + .then(() => { + let [nextScreen, nextComponentId] = id.split('|'); + if ( + nextScreen === + enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS && + nextComponentId && + nextComponentId === currentComponentId + ) { + ScreensHelper.loadScreen(dispatch, { + screen: nextScreen, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + version: navigationVersion + } + }); + } else { + if ( + nextScreen === + enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS + ) { + if ( + onboardingOrigin === + onboardingOriginTypes.ZIP || + candidateOnboardingOrigin === + onboardingOriginTypes.ZIP + ) { + nextScreen = + enums.SCREEN + .SOFTWARE_PRODUCT_ATTACHMENTS_SETUP; + } else if ( + onboardingOrigin === onboardingOriginTypes.CSAR + ) { + nextScreen = + enums.SCREEN + .SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION; + } + } + ScreensHelper.loadScreen(dispatch, { + screen: nextScreen, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + version: navigationVersion, + componentId: nextComponentId + } + }); + } + }) + .catch(e => { + console.error(e); + }); + } + }; -const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {softwareProductId, licenseModelId, version, componentId: currentComponentId}}}) => { - - const props = { - onVersionSwitching: (versionToSwitch, meta) => { - ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId: meta.softwareProduct.id, version: versionToSwitch}}); - }, - onOpenPermissions: ({users}) => { - return PermissionsActionHelper.fetchItemUsers(dispatch, {itemId: softwareProductId, allUsers: users}); - }, - onOpenRevisionsModal: () => { - return RevisionsActionHelper.openRevisionsView(dispatch, {itemId: softwareProductId, version: version, itemType: screenTypes.SOFTWARE_PRODUCT}); - }, - onOpenCommentCommitModal: ({onCommit, title}) => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.COMMIT_COMMENT, - modalComponentProps: { - onCommit, - type: CommitModalType.COMMIT - }, - title - } - }), - onMoreVersionsClick: ({itemName, users}) => { - ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, softwareProduct: {name: itemName, vendorId: licenseModelId}, usersList: users}}); - - }, - onToggle: (groups, itemIdToExpand) => groups.map(({items}) => SoftwareProductActionHelper.toggleNavigationItems(dispatch, {items, itemIdToExpand})), - onNavigate: ({id, meta, newVersion}) => { - let navigationVersion = newVersion || version; - let {onboardingOrigin, candidateOnboardingOrigin, heatSetup, heatSetupCache} = meta; - let heatSetupPopupPromise = screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS ? - HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) : - Promise.resolve(); - let preNavigate = meta ? autoSaveBeforeNavigate({dispatch, screen, meta, version, softwareProductId, componentId: currentComponentId}) : Promise.resolve(); - version = version || (meta ? meta.version : undefined); - Promise.all([preNavigate, heatSetupPopupPromise]).then(() => { - let [nextScreen, nextComponentId] = id.split('|'); - if(nextScreen === enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS && nextComponentId && nextComponentId === currentComponentId) { - ScreensHelper.loadScreen(dispatch, { - screen: nextScreen, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version: navigationVersion} - }); - } - else { - if(nextScreen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS) { - if(onboardingOrigin === onboardingOriginTypes.ZIP || candidateOnboardingOrigin === onboardingOriginTypes.ZIP) { - nextScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP; - } - else if(onboardingOrigin === onboardingOriginTypes.CSAR) { - nextScreen = enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION; - } - } - ScreensHelper.loadScreen(dispatch, { - screen: nextScreen, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version: navigationVersion, componentId: nextComponentId} - }); - } - }).catch((e) => {console.error(e);}); - } - }; - - switch (screen) { - case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: - case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: - case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: - case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: - case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: - case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: - case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: - case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: - props.onSave = () => Promise.resolve(); - break; - default: - props.onSave = ({softwareProduct, qdata}) => SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {softwareProduct, qdata, version}); - break; - } - + switch (screen) { + case enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE: + case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: + case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: + case enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS: + case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: + case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS: + case enums.SCREEN.SOFTWARE_PRODUCT_DEPLOYMENT: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: + case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: + props.onSave = () => Promise.resolve(); + break; + default: + props.onSave = ({ softwareProduct, qdata }) => + SoftwareProductActionHelper.updateSoftwareProduct(dispatch, { + softwareProduct, + qdata, + version + }); + break; + } - props.onVersionControllerAction = (action, version, comment, meta) => { - let {heatSetup, heatSetupCache} = meta; - let autoSavePromise = meta ? autoSaveBeforeNavigate({dispatch, screen, meta, version, softwareProductId, componentId: currentComponentId}) : Promise.resolve(); - let heatSetupPopupPromise = screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS && action === versionControllerActions.COMMIT ? - HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) : - Promise.resolve(); - Promise.all([autoSavePromise, heatSetupPopupPromise]).then(() => { - return SoftwareProductActionHelper.performVCAction(dispatch, {softwareProductId, action, version, comment, meta}).then(updatedVersion => { - const inMerge = updatedVersion && updatedVersion.state && updatedVersion.state.synchronizationState === SyncStates.MERGE; - if((action === versionControllerActions.SYNC && !inMerge) || - ((action === versionControllerActions.COMMIT || action === versionControllerActions.SYNC) && updatedVersion.status === catalogItemStatuses.CERTIFIED)) { - ScreensHelper.loadLandingScreen(dispatch, {previousScreenName: screen, props: {softwareProductId, version: updatedVersion}}); - } else { - ScreensHelper.loadScreen(dispatch, {screen, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version: updatedVersion, componentId: currentComponentId}}); - } - }); - }).catch((e) => {console.error(e);}); - }; + props.onVersionControllerAction = (action, version, comment, meta) => { + let { heatSetup, heatSetupCache } = meta; + let autoSavePromise = meta + ? autoSaveBeforeNavigate({ + dispatch, + screen, + meta, + version, + softwareProductId, + componentId: currentComponentId + }) + : Promise.resolve(); + let heatSetupPopupPromise = + screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS && + action === versionControllerActions.COMMIT + ? HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, { + softwareProductId, + heatSetup, + heatSetupCache + }) + : Promise.resolve(); + Promise.all([autoSavePromise, heatSetupPopupPromise]) + .then(() => { + return SoftwareProductActionHelper.performVCAction(dispatch, { + softwareProductId, + action, + version, + comment, + meta + }).then(updatedVersion => { + const inMerge = + updatedVersion && + updatedVersion.state && + updatedVersion.state.synchronizationState === + SyncStates.MERGE; + if ( + (action === versionControllerActions.SYNC && + !inMerge) || + ((action === versionControllerActions.COMMIT || + action === versionControllerActions.SYNC) && + updatedVersion.status === + catalogItemStatuses.CERTIFIED) + ) { + ScreensHelper.loadLandingScreen(dispatch, { + previousScreenName: screen, + props: { + softwareProductId, + version: updatedVersion + } + }); + } else { + ScreensHelper.loadScreen(dispatch, { + screen, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + version: updatedVersion, + componentId: currentComponentId + } + }); + } + }); + }) + .catch(e => { + console.error(e); + }); + }; - props.onManagePermissions = () => PermissionsActionHelper.openPermissonsManager(dispatch, {itemId: softwareProductId, askForRights: false}); - return props; + props.onManagePermissions = () => + PermissionsActionHelper.openPermissonsManager(dispatch, { + itemId: softwareProductId, + askForRights: false + }); + return props; }; export default connect(mapStateToProps, mapActionsToProps)(TabulatedEditor); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js index 42786bf752..4a2d7a2ece 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js @@ -21,553 +21,769 @@ import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseMod import LicenseAgreementActionHelper from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js'; import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js'; -import {actionTypes, onboardingOriginTypes, PRODUCT_QUESTIONNAIRE, forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { + actionTypes, + onboardingOriginTypes, + PRODUCT_QUESTIONNAIRE, + forms +} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; import SoftwareProductComponentsActionHelper from './components/SoftwareProductComponentsActionHelper.js'; -import {actionsEnum as VersionControllerActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; -import {actionTypes as HeatSetupActions} from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js'; -import {actionTypes as featureGroupsActionConstants} from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js'; -import {actionTypes as licenseAgreementActionTypes} from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js'; -import {actionTypes as componentActionTypes} from './components/SoftwareProductComponentsConstants.js'; +import { actionsEnum as VersionControllerActionsEnum } from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import { actionTypes as HeatSetupActions } from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js'; +import { actionTypes as featureGroupsActionConstants } from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js'; +import { actionTypes as licenseAgreementActionTypes } from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js'; +import { actionTypes as componentActionTypes } from './components/SoftwareProductComponentsConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {default as ItemsHelper} from 'sdc-app/common/helpers/ItemsHelper.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { default as ItemsHelper } from 'sdc-app/common/helpers/ItemsHelper.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import MergeEditorActionHelper from 'sdc-app/common/merge/MergeEditorActionHelper.js'; -import {CommitModalType} from 'nfvo-components/panel/versionController/components/CommitCommentModal.jsx'; -import {actionTypes as commonActionTypes} from 'sdc-app/common/reducers/PlainDataReducerConstants.js'; +import { CommitModalType } from 'nfvo-components/panel/versionController/components/CommitCommentModal.jsx'; +import { actionTypes as commonActionTypes } from 'sdc-app/common/reducers/PlainDataReducerConstants.js'; 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 { itemTypes } from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js'; +import { catalogItemStatuses } from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; import getValue from 'nfvo-utils/getValue.js'; function getLicensingData(licensingData = {}) { - const {licenseAgreement, featureGroups} = licensingData; - const newlicenseAgreement = getValue(licenseAgreement); - const newfeatureGroups = getValue(featureGroups); - return newlicenseAgreement ? { - licenseAgreement: newlicenseAgreement, - featureGroups: newfeatureGroups - } : undefined; -}; + const { licenseAgreement, featureGroups } = licensingData; + const newlicenseAgreement = getValue(licenseAgreement); + const newfeatureGroups = getValue(featureGroups); + return newlicenseAgreement + ? { + licenseAgreement: newlicenseAgreement, + featureGroups: newfeatureGroups + } + : undefined; +} function baseUrl() { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/`; } function softwareProductCategoriesUrl() { - const restCatalogPrefix = Configuration.get('restCatalogPrefix'); - return `${restCatalogPrefix}/v1/categories/resources/`; + const restCatalogPrefix = Configuration.get('restCatalogPrefix'); + return `${restCatalogPrefix}/v1/categories/resources/`; } function uploadFile(vspId, formData, version) { - return RestAPIUtil.post(`${baseUrl()}${vspId}/versions/${version.id}/orchestration-template-candidate`, formData); - + return RestAPIUtil.post( + `${baseUrl()}${vspId}/versions/${ + version.id + }/orchestration-template-candidate`, + formData + ); } -function putSoftwareProduct({softwareProduct, version}) { - return RestAPIUtil.put(`${baseUrl()}${softwareProduct.id}/versions/${version.id}`, { - name: softwareProduct.name, - description: softwareProduct.description, - category: softwareProduct.category, - subCategory: softwareProduct.subCategory, - vendorId: softwareProduct.vendorId, - vendorName: softwareProduct.vendorName, - licensingVersion: softwareProduct.licensingVersion ? softwareProduct.licensingVersion : undefined, - icon: softwareProduct.icon, - licensingData: getLicensingData(softwareProduct.licensingData) - }); +function putSoftwareProduct({ softwareProduct, version }) { + return RestAPIUtil.put( + `${baseUrl()}${softwareProduct.id}/versions/${version.id}`, + { + name: softwareProduct.name, + description: softwareProduct.description, + category: softwareProduct.category, + subCategory: softwareProduct.subCategory, + vendorId: softwareProduct.vendorId, + vendorName: softwareProduct.vendorName, + licensingVersion: softwareProduct.licensingVersion + ? softwareProduct.licensingVersion + : undefined, + icon: softwareProduct.icon, + licensingData: getLicensingData(softwareProduct.licensingData) + } + ); } function putSoftwareProductQuestionnaire(vspId, qdata, version) { - return RestAPIUtil.put(`${baseUrl()}${vspId}/versions/${version.id}/questionnaire`, qdata); + return RestAPIUtil.put( + `${baseUrl()}${vspId}/versions/${version.id}/questionnaire`, + qdata + ); } function putSoftwareProductAction(id, action, version) { - return RestAPIUtil.put(`${baseUrl()}${id}/versions/${version.id}/actions`, {action: action}); + return RestAPIUtil.put(`${baseUrl()}${id}/versions/${version.id}/actions`, { + action: action + }); } function fetchSoftwareProductList() { - return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=${catalogItemStatuses.DRAFT}`); + return RestAPIUtil.fetch( + `${baseUrl()}?versionFilter=${catalogItemStatuses.DRAFT}` + ); } function fetchArchivedSoftwareProductList() { - return RestAPIUtil.fetch(`${baseUrl()}?Status=${catalogItemStatuses.ARCHIVED}`); + return RestAPIUtil.fetch( + `${baseUrl()}?Status=${catalogItemStatuses.ARCHIVED}` + ); } function fetchFinalizedSoftwareProductList() { - return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=${catalogItemStatuses.CERTIFIED}`); + return RestAPIUtil.fetch( + `${baseUrl()}?versionFilter=${catalogItemStatuses.CERTIFIED}` + ); } function fetchSoftwareProduct(vspId, version) { - return RestAPIUtil.fetch(`${baseUrl()}${vspId}/versions/${version.id}`); + return RestAPIUtil.fetch(`${baseUrl()}${vspId}/versions/${version.id}`); } function fetchSoftwareProductQuestionnaire(vspId, version) { - return RestAPIUtil.fetch(`${baseUrl()}${vspId}/versions/${version.id}/questionnaire`); + return RestAPIUtil.fetch( + `${baseUrl()}${vspId}/versions/${version.id}/questionnaire` + ); } -function updateSoftwareProductHeatCandidate(softwareProductId, heatCandidate, version) { - return RestAPIUtil.put(`${baseUrl()}${softwareProductId}/versions/${version.id}/orchestration-template-candidate/manifest`, heatCandidate); +function updateSoftwareProductHeatCandidate( + softwareProductId, + heatCandidate, + version +) { + return RestAPIUtil.put( + `${baseUrl()}${softwareProductId}/versions/${ + version.id + }/orchestration-template-candidate/manifest`, + heatCandidate + ); } function validateHeatCandidate(softwareProductId, version) { - return RestAPIUtil.put(`${baseUrl()}${softwareProductId}/versions/${version.id}/orchestration-template-candidate/process`); + return RestAPIUtil.put( + `${baseUrl()}${softwareProductId}/versions/${ + version.id + }/orchestration-template-candidate/process` + ); } -function fetchOrchestrationTemplateCandidate(softwareProductId, version, ) { - return RestAPIUtil.fetch(`${baseUrl()}${softwareProductId}/versions/${version.id}/orchestration-template-candidate`, {dataType: 'binary'}); +function fetchOrchestrationTemplateCandidate(softwareProductId, version) { + return RestAPIUtil.fetch( + `${baseUrl()}${softwareProductId}/versions/${ + version.id + }/orchestration-template-candidate`, + { dataType: 'binary' } + ); } function abortValidationProcess(softwareProductId, version) { - return RestAPIUtil.destroy(`${baseUrl()}${softwareProductId}/versions/${version.id}/orchestration-template-candidate`); + return RestAPIUtil.destroy( + `${baseUrl()}${softwareProductId}/versions/${ + version.id + }/orchestration-template-candidate` + ); } function objToString(obj) { - let str = ''; - if (obj instanceof Array) { - obj.forEach((item) => { - str += objToString(item) + '\n'; - }); - } - else { - for (let p in obj) { - if (obj.hasOwnProperty(p)) { - str += obj[p] + '\n'; - } - } - } - return str.replace(/\n$/, ''); + let str = ''; + if (obj instanceof Array) { + obj.forEach(item => { + str += objToString(item) + '\n'; + }); + } else { + for (let p in obj) { + if (obj.hasOwnProperty(p)) { + str += obj[p] + '\n'; + } + } + } + return str.replace(/\n$/, ''); } function parseUploadErrorMsg(error) { - let message = ''; - for (let key in error) { - if (error.hasOwnProperty(key)) { - message += objToString(error[key]) + '\n'; - } - } - return message.replace(/\n$/, ''); + let message = ''; + for (let key in error) { + if (error.hasOwnProperty(key)) { + message += objToString(error[key]) + '\n'; + } + } + return message.replace(/\n$/, ''); } function fetchSoftwareProductCategories(dispatch) { - let handleResponse = response => dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_CATEGORIES_LOADED, - softwareProductCategories: response - }); - return RestAPIUtil.fetch(softwareProductCategoriesUrl()) - .then(handleResponse) - .catch(() => handleResponse(null)); + let handleResponse = response => + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_CATEGORIES_LOADED, + softwareProductCategories: response + }); + return RestAPIUtil.fetch(softwareProductCategoriesUrl()) + .then(handleResponse) + .catch(() => handleResponse(null)); } -function loadLicensingData(dispatch, {licenseModelId, licensingVersion}) { - return ItemsHelper.fetchVersion({itemId: licenseModelId, versionId: licensingVersion}).then(() => { - return Promise.all([ - LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version: {id: licensingVersion}}), - FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version: {id: licensingVersion}}) - ]); - }); +function loadLicensingData(dispatch, { licenseModelId, licensingVersion }) { + return ItemsHelper.fetchVersion({ + itemId: licenseModelId, + versionId: licensingVersion + }).then(() => { + return Promise.all([ + LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, { + licenseModelId, + version: { id: licensingVersion } + }), + FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, { + licenseModelId, + version: { id: licensingVersion } + }) + ]); + }); } function getExpandedItemsId(items, itemIdToToggle) { - for (let i = 0; i < items.length; i++) { - if (items[i].id === itemIdToToggle) { - if (items[i].expanded) { - return {}; - } - else { - return {[itemIdToToggle]: true}; - } - } - else if (items[i].items && items[i].items.length > 0) { - let mapOfExpandedIds = getExpandedItemsId(items[i].items, itemIdToToggle); - if (mapOfExpandedIds !== false) { - mapOfExpandedIds[items[i].id] = true; - return mapOfExpandedIds; - } - } - } - return false; + for (let i = 0; i < items.length; i++) { + if (items[i].id === itemIdToToggle) { + if (items[i].expanded) { + return {}; + } else { + return { [itemIdToToggle]: true }; + } + } else if (items[i].items && items[i].items.length > 0) { + let mapOfExpandedIds = getExpandedItemsId( + items[i].items, + itemIdToToggle + ); + if (mapOfExpandedIds !== false) { + mapOfExpandedIds[items[i].id] = true; + return mapOfExpandedIds; + } + } + } + return false; } function migrateSoftwareProduct(vspId, version) { - return RestAPIUtil.put(`${baseUrl()}${vspId}/versions/${version.id}/heal`); + return RestAPIUtil.put(`${baseUrl()}${vspId}/versions/${version.id}/heal`); } - - const SoftwareProductActionHelper = { - - fetchFinalizedSoftwareProductList(dispatch) { - return fetchFinalizedSoftwareProductList().then(response => dispatch({ - type: actionTypes.FINALIZED_SOFTWARE_PRODUCT_LIST_LOADED, - response - })); - }, - - fetchArchivedSoftwareProductList(dispatch) { - return fetchArchivedSoftwareProductList().then(response => dispatch({ - type: actionTypes.ARCHIVED_SOFTWARE_PRODUCT_LIST_LOADED, - response - })); - }, - - loadSoftwareProductAssociatedData(dispatch) { - fetchSoftwareProductCategories(dispatch); - LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch); - }, - - loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion}) { - SoftwareProductActionHelper.loadSoftwareProductAssociatedData(dispatch); - if (licensingVersion) { - return loadLicensingData(dispatch, {licenseModelId, licensingVersion}); - } - return Promise.resolve(); - }, - - fetchSoftwareProductList(dispatch) { - return fetchSoftwareProductList().then(response => dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_LIST_LOADED, - response - })); - }, - - loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version}){ - return RestAPIUtil.fetch(`${baseUrl()}${softwareProductId}/versions/${version.id}/orchestration-template-candidate/manifest`).then(response => dispatch({ - type: HeatSetupActions.MANIFEST_LOADED, - response - })); - }, - - loadLicensingVersionsList(dispatch, {licenseModelId}){ - return ItemsHelper.fetchVersions({itemId: licenseModelId}).then(response => { - dispatch({ - type: actionTypes.LOAD_LICENSING_VERSIONS_LIST, - licensingVersionsList: response.results - }); - }); - }, - updateSoftwareProductHeatCandidate(dispatch, {softwareProductId, heatCandidate, version}){ - return updateSoftwareProductHeatCandidate(softwareProductId, heatCandidate, version); - }, - - processAndValidateHeatCandidate(dispatch, {softwareProductId, version}){ - return validateHeatCandidate(softwareProductId, version).then(response => { - if (response.status === 'Success') { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); - SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); - } else { - SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); - } - }); - }, - - uploadFile(dispatch, {softwareProductId, formData, failedNotificationTitle, version}) { - dispatch({ - type: HeatSetupActions.FILL_HEAT_SETUP_CACHE, - payload: {} - }); - - Promise.resolve() - .then(() => uploadFile(softwareProductId, formData, version)) - .then(response => { - if (response.status === 'Success') { - dispatch({ - type: commonActionTypes.DATA_CHANGED, - deltaData: {onboardingOrigin: response.onboardingOrigin}, - formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS - }); - switch(response.onboardingOrigin){ - case onboardingOriginTypes.ZIP: - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version} - }); - dispatch({ - type: actionTypes.CANDIDATE_IN_PROCESS, - inProcess: true - }); - break; - case onboardingOriginTypes.CSAR: - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version} - }); - break; - } - } - else { - throw new Error(parseUploadErrorMsg(response.errors)); - } - }) - .catch(error => { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - title: failedNotificationTitle, - msg: error.message || (error.responseJSON && error.responseJSON.message) - } - }); - }); - }, - - downloadHeatFile(dispatch, {softwareProductId, heatCandidate, isReadOnlyMode, version}){ - let p = isReadOnlyMode ? Promise.resolve() : SoftwareProductActionHelper.updateSoftwareProductHeatCandidate(dispatch, { - softwareProductId, - heatCandidate, - version}); - p.then(() => { - fetchOrchestrationTemplateCandidate(softwareProductId, version) - .then((response) => { - showFileSaveDialog({ - blob: response.blob, - headers: response.headers, - defaultFilename: 'HEAT_file.zip', - addTimestamp: true - }); - }); - }, null/* do not download if data was not saved correctly*/); - }, - - hideUploadConfirm (dispatch) { - dispatch({ - type: actionTypes.softwareProductEditor.UPLOAD_CONFIRMATION - }); - }, - updateSoftwareProduct(dispatch, {softwareProduct, version, qdata}) { - return Promise.all([ - SoftwareProductActionHelper.updateSoftwareProductData(dispatch, {softwareProduct, version}).then( - () => dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_LIST_EDIT, - payload: {softwareProduct} - }) - ), - SoftwareProductActionHelper.updateSoftwareProductQuestionnaire(dispatch, { - softwareProductId: softwareProduct.id, - qdata, - version - }) - ]); - }, - - updateSoftwareProductData(dispatch, {softwareProduct, version}) { - return putSoftwareProduct({softwareProduct, version}); - }, - - updateSoftwareProductQuestionnaire(dispatch, {softwareProductId, qdata, version}) { - return putSoftwareProductQuestionnaire(softwareProductId, qdata, version); - }, - - softwareProductEditorDataChanged(dispatch, {deltaData}) { - dispatch({ - type: actionTypes.softwareProductEditor.DATA_CHANGED, - deltaData - }); - }, - - softwareProductQuestionnaireUpdate(dispatch, {data}) { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_QUESTIONNAIRE_UPDATE, - payload: {qdata: data} - }); - }, - - softwareProductEditorVendorChanged(dispatch, {deltaData, formName}) { - if (deltaData.licensingVersion){ - return loadLicensingData(dispatch, {licenseModelId: deltaData.vendorId, licensingVersion: deltaData.licensingVersion}).then(() => { - ValidationHelper.dataChanged(dispatch, {deltaData, formName}); - return Promise.resolve(); - }); - } else if (deltaData.vendorId) { - ValidationHelper.dataChanged(dispatch, {deltaData, formName}); - return SoftwareProductActionHelper.loadLicensingVersionsList(dispatch, { - licenseModelId: deltaData.vendorId - }).then( () => - OnboardingActionHelper.forceBreadCrumbsUpdate(dispatch) - ); - } else { - ValidationHelper.dataChanged(dispatch, {deltaData, formName}); - - dispatch({ - type: licenseAgreementActionTypes.LICENSE_AGREEMENT_LIST_LOADED, - response: {results: []} - }); - - dispatch({ - type: featureGroupsActionConstants.FEATURE_GROUPS_LIST_LOADED, - response: {results: []} - }); - } - - }, - - setIsValidityData(dispatch, {isValidityData}) { - dispatch({ - type: actionTypes.softwareProductEditor.IS_VALIDITY_DATA_CHANGED, - isValidityData - }); - }, - - fetchSoftwareProduct(dispatch, {softwareProductId, version}) { - return Promise.all([ - fetchSoftwareProduct(softwareProductId, version).then(response => { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_LOADED, - response - }); - return response; - }), - fetchSoftwareProductQuestionnaire(softwareProductId, version).then(response => { - ValidationHelper.qDataLoaded(dispatch, {response: {qdata: response.data ? JSON.parse(response.data) : {}, - qschema: JSON.parse(response.schema)}, qName: PRODUCT_QUESTIONNAIRE}); - }) - ]); - }, - - manageSubmitAction(dispatch, {softwareProductId, version, isDirty}) { - if (isDirty) { - const onCommit = comment => { - return this.performVCAction(dispatch, {softwareProductId, action: VersionControllerActionsEnum.COMMIT, version, comment}).then(() => { - return this.performSubmitAction(dispatch, {softwareProductId, version}); - }); - }; - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.COMMIT_COMMENT, - modalComponentProps: { - onCommit, - type: CommitModalType.COMMIT_SUBMIT - }, - title: i18n('Commit & Submit') - } - }); - return Promise.resolve(version); - } - return this.performSubmitAction(dispatch, {softwareProductId, version}); - }, - - performSubmitAction(dispatch, {softwareProductId, version}) { - return putSoftwareProductAction(softwareProductId, VersionControllerActionsEnum.SUBMIT, version).then(() => { - return putSoftwareProductAction(softwareProductId, VersionControllerActionsEnum.CREATE_PACKAGE, version).then(() => { - return ItemsHelper.checkItemStatus(dispatch, {itemId: softwareProductId, versionId: version.id}).then(updatedVersion => { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SUCCESS, - data: { - title: i18n('Submit Succeeded'), - msg: i18n('This software product successfully submitted'), - cancelButtonText: i18n('OK'), - timeout: 2000 - } - }); - versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.SOFTWARE_PRODUCT, itemId: softwareProductId}); - return Promise.resolve(updatedVersion); - }); - }); - }, error => - { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - modalComponentName: modalContentMapper.SUMBIT_ERROR_RESPONSE, - title: i18n('Submit Failed'), - modalComponentProps: { - validationResponse: error.responseJSON - }, - cancelButtonText: i18n('OK') - } - }); - return Promise.reject(error.responseJSON); - }); - }, - - performVCAction(dispatch, {softwareProductId, action, version, comment}) { - return MergeEditorActionHelper.analyzeSyncResult(dispatch, {itemId: softwareProductId, version}).then(({inMerge, isDirty, updatedVersion}) => { - if ((updatedVersion.status === catalogItemStatuses.CERTIFIED || updatedVersion.archivedStatus === catalogItemStatuses.ARCHIVED) && - (action === VersionControllerActionsEnum.COMMIT || action === VersionControllerActionsEnum.SYNC)) { - versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.SOFTWARE_PRODUCT, itemId: softwareProductId}); - const msg = updatedVersion.archivedStatus === catalogItemStatuses.ARCHIVED ? i18n('Item was Archived') : i18n('Item version already Certified'); - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data: { - title: i18n('Commit error'), - msg, - cancelButtonText: i18n('Cancel') - } - }); - return Promise.resolve(updatedVersion); - } - if (!inMerge) { - if (action === VersionControllerActionsEnum.SUBMIT) { - return this.manageSubmitAction(dispatch, {softwareProductId, version, isDirty}); - } - else { - let isCallActionValid = action !== VersionControllerActionsEnum.COMMIT || isDirty; - if(isCallActionValid) { - return ItemsHelper.performVCAction({itemId: softwareProductId, action, version, comment}).then(() => { - versionPageActionHelper.fetchVersions(dispatch, {itemType: itemTypes.LICENSE_MODEL, itemId: softwareProductId}); - if (action === VersionControllerActionsEnum.SYNC) { - return MergeEditorActionHelper.analyzeSyncResult(dispatch, {itemId: softwareProductId, version}).then(({updatedVersion}) => { - return Promise.resolve(updatedVersion); - }); - } else { - return ItemsHelper.checkItemStatus(dispatch, {itemId: softwareProductId, versionId: version.id}); - } - }); - } - else { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - title: i18n('Commit Failed'), - msg: i18n('There is nothing to commit') - } - }); - } - } - } - }); - }, - - toggleNavigationItems(dispatch, {items, itemIdToExpand}) { - let mapOfExpandedIds = getExpandedItemsId(items, itemIdToExpand); - dispatch({ - type: actionTypes.TOGGLE_NAVIGATION_ITEM, - mapOfExpandedIds - }); - }, - - /** for the next verision */ - addComponent(dispatch, {softwareProductId, modalClassName, version}) { - SoftwareProductComponentsActionHelper.clearComponentCreationData(dispatch); - dispatch({ - type: componentActionTypes.COMPONENT_CREATE_OPEN - }); - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.COMPONENT_CREATION, - modalComponentProps: {softwareProductId, version}, - modalClassName, - title: 'Create Virtual Function Component' - } - }); - }, - - migrateSoftwareProduct(dispatch, {softwareProduct}) { - let {id: softwareProductId, version} = softwareProduct; - const newVer = version.id; - migrateSoftwareProduct(softwareProductId, version).then(() => ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version: {id: newVer, label: newVer}} - })); - }, - - abortCandidateValidation(dispatch, {softwareProductId, version}) { - return abortValidationProcess(softwareProductId, version); - } - + fetchFinalizedSoftwareProductList(dispatch) { + return fetchFinalizedSoftwareProductList().then(response => + dispatch({ + type: actionTypes.FINALIZED_SOFTWARE_PRODUCT_LIST_LOADED, + response + }) + ); + }, + + fetchArchivedSoftwareProductList(dispatch) { + return fetchArchivedSoftwareProductList().then(response => + dispatch({ + type: actionTypes.ARCHIVED_SOFTWARE_PRODUCT_LIST_LOADED, + response + }) + ); + }, + + loadSoftwareProductAssociatedData(dispatch) { + fetchSoftwareProductCategories(dispatch); + LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch); + }, + + loadSoftwareProductDetailsData( + dispatch, + { licenseModelId, licensingVersion } + ) { + SoftwareProductActionHelper.loadSoftwareProductAssociatedData(dispatch); + if (licensingVersion) { + return loadLicensingData(dispatch, { + licenseModelId, + licensingVersion + }); + } + return Promise.resolve(); + }, + + fetchSoftwareProductList(dispatch) { + return fetchSoftwareProductList().then(response => + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_LIST_LOADED, + response + }) + ); + }, + + loadSoftwareProductHeatCandidate(dispatch, { softwareProductId, version }) { + return RestAPIUtil.fetch( + `${baseUrl()}${softwareProductId}/versions/${ + version.id + }/orchestration-template-candidate/manifest` + ).then(response => + dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response + }) + ); + }, + + loadLicensingVersionsList(dispatch, { licenseModelId }) { + return ItemsHelper.fetchVersions({ itemId: licenseModelId }).then( + response => { + dispatch({ + type: actionTypes.LOAD_LICENSING_VERSIONS_LIST, + licensingVersionsList: response.results + }); + } + ); + }, + updateSoftwareProductHeatCandidate( + dispatch, + { softwareProductId, heatCandidate, version } + ) { + return updateSoftwareProductHeatCandidate( + softwareProductId, + heatCandidate, + version + ); + }, + + processAndValidateHeatCandidate(dispatch, { softwareProductId, version }) { + return validateHeatCandidate(softwareProductId, version).then( + response => { + if (response.status === 'Success') { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents( + dispatch, + { softwareProductId, version } + ); + SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, { + softwareProductId, + version + }); + } else { + SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, { + softwareProductId, + version + }); + } + } + ); + }, + + uploadFile( + dispatch, + { softwareProductId, formData, failedNotificationTitle, version } + ) { + dispatch({ + type: HeatSetupActions.FILL_HEAT_SETUP_CACHE, + payload: {} + }); + + Promise.resolve() + .then(() => uploadFile(softwareProductId, formData, version)) + .then(response => { + if (response.status === 'Success') { + dispatch({ + type: commonActionTypes.DATA_CHANGED, + deltaData: { + onboardingOrigin: response.onboardingOrigin + }, + formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS + }); + switch (response.onboardingOrigin) { + case onboardingOriginTypes.ZIP: + ScreensHelper.loadScreen(dispatch, { + screen: + enums.SCREEN + .SOFTWARE_PRODUCT_ATTACHMENTS_SETUP, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId, version } + }); + dispatch({ + type: actionTypes.CANDIDATE_IN_PROCESS, + inProcess: true + }); + break; + case onboardingOriginTypes.CSAR: + ScreensHelper.loadScreen(dispatch, { + screen: + enums.SCREEN + .SOFTWARE_PRODUCT_ATTACHMENTS_VALIDATION, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId, version } + }); + break; + } + } else { + throw new Error(parseUploadErrorMsg(response.errors)); + } + }) + .catch(error => { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: failedNotificationTitle, + msg: + error.message || + (error.responseJSON && error.responseJSON.message) + } + }); + }); + }, + + downloadHeatFile( + dispatch, + { softwareProductId, heatCandidate, isReadOnlyMode, version } + ) { + let p = isReadOnlyMode + ? Promise.resolve() + : SoftwareProductActionHelper.updateSoftwareProductHeatCandidate( + dispatch, + { + softwareProductId, + heatCandidate, + version + } + ); + p.then(() => { + fetchOrchestrationTemplateCandidate( + softwareProductId, + version + ).then(response => { + showFileSaveDialog({ + blob: response.blob, + headers: response.headers, + defaultFilename: 'HEAT_file.zip', + addTimestamp: true + }); + }); + }, null /* do not download if data was not saved correctly*/); + }, + + hideUploadConfirm(dispatch) { + dispatch({ + type: actionTypes.softwareProductEditor.UPLOAD_CONFIRMATION + }); + }, + updateSoftwareProduct(dispatch, { softwareProduct, version, qdata }) { + return Promise.all([ + SoftwareProductActionHelper.updateSoftwareProductData(dispatch, { + softwareProduct, + version + }).then(() => + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_LIST_EDIT, + payload: { softwareProduct } + }) + ), + SoftwareProductActionHelper.updateSoftwareProductQuestionnaire( + dispatch, + { + softwareProductId: softwareProduct.id, + qdata, + version + } + ) + ]); + }, + + updateSoftwareProductData(dispatch, { softwareProduct, version }) { + return putSoftwareProduct({ softwareProduct, version }); + }, + + updateSoftwareProductQuestionnaire( + dispatch, + { softwareProductId, qdata, version } + ) { + return putSoftwareProductQuestionnaire( + softwareProductId, + qdata, + version + ); + }, + + softwareProductEditorDataChanged(dispatch, { deltaData }) { + dispatch({ + type: actionTypes.softwareProductEditor.DATA_CHANGED, + deltaData + }); + }, + + softwareProductQuestionnaireUpdate(dispatch, { data }) { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_QUESTIONNAIRE_UPDATE, + payload: { qdata: data } + }); + }, + + softwareProductEditorVendorChanged(dispatch, { deltaData, formName }) { + if (deltaData.licensingVersion) { + return loadLicensingData(dispatch, { + licenseModelId: deltaData.vendorId, + licensingVersion: deltaData.licensingVersion + }).then(() => { + ValidationHelper.dataChanged(dispatch, { deltaData, formName }); + return Promise.resolve(); + }); + } else if (deltaData.vendorId) { + ValidationHelper.dataChanged(dispatch, { deltaData, formName }); + return SoftwareProductActionHelper.loadLicensingVersionsList( + dispatch, + { + licenseModelId: deltaData.vendorId + } + ).then(() => + OnboardingActionHelper.forceBreadCrumbsUpdate(dispatch) + ); + } else { + ValidationHelper.dataChanged(dispatch, { deltaData, formName }); + + dispatch({ + type: licenseAgreementActionTypes.LICENSE_AGREEMENT_LIST_LOADED, + response: { results: [] } + }); + + dispatch({ + type: featureGroupsActionConstants.FEATURE_GROUPS_LIST_LOADED, + response: { results: [] } + }); + } + }, + + setIsValidityData(dispatch, { isValidityData }) { + dispatch({ + type: actionTypes.softwareProductEditor.IS_VALIDITY_DATA_CHANGED, + isValidityData + }); + }, + + fetchSoftwareProduct(dispatch, { softwareProductId, version }) { + return Promise.all([ + fetchSoftwareProduct(softwareProductId, version).then(response => { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_LOADED, + response + }); + return response; + }), + fetchSoftwareProductQuestionnaire(softwareProductId, version).then( + response => { + ValidationHelper.qDataLoaded(dispatch, { + response: { + qdata: response.data + ? JSON.parse(response.data) + : {}, + qschema: JSON.parse(response.schema) + }, + qName: PRODUCT_QUESTIONNAIRE + }); + } + ) + ]); + }, + + manageSubmitAction(dispatch, { softwareProductId, version, isDirty }) { + if (isDirty) { + const onCommit = comment => { + return this.performVCAction(dispatch, { + softwareProductId, + action: VersionControllerActionsEnum.COMMIT, + version, + comment + }).then(() => { + return this.performSubmitAction(dispatch, { + softwareProductId, + version + }); + }); + }; + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.COMMIT_COMMENT, + modalComponentProps: { + onCommit, + type: CommitModalType.COMMIT_SUBMIT + }, + title: i18n('Commit & Submit') + } + }); + return Promise.resolve(version); + } + return this.performSubmitAction(dispatch, { + softwareProductId, + version + }); + }, + + performSubmitAction(dispatch, { softwareProductId, version }) { + return putSoftwareProductAction( + softwareProductId, + VersionControllerActionsEnum.SUBMIT, + version + ).then( + () => { + return putSoftwareProductAction( + softwareProductId, + VersionControllerActionsEnum.CREATE_PACKAGE, + version + ).then(() => { + return ItemsHelper.checkItemStatus(dispatch, { + itemId: softwareProductId, + versionId: version.id + }).then(updatedVersion => { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SUCCESS, + data: { + title: i18n('Submit Succeeded'), + msg: i18n( + 'This software product successfully submitted' + ), + cancelButtonText: i18n('OK'), + timeout: 2000 + } + }); + versionPageActionHelper.fetchVersions(dispatch, { + itemType: itemTypes.SOFTWARE_PRODUCT, + itemId: softwareProductId + }); + return Promise.resolve(updatedVersion); + }); + }); + }, + error => { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + modalComponentName: + modalContentMapper.SUMBIT_ERROR_RESPONSE, + title: i18n('Submit Failed'), + modalComponentProps: { + validationResponse: error.responseJSON + }, + cancelButtonText: i18n('OK') + } + }); + return Promise.reject(error.responseJSON); + } + ); + }, + + performVCAction(dispatch, { softwareProductId, action, version, comment }) { + return MergeEditorActionHelper.analyzeSyncResult(dispatch, { + itemId: softwareProductId, + version + }).then(({ inMerge, isDirty, updatedVersion }) => { + if ( + (updatedVersion.status === catalogItemStatuses.CERTIFIED || + updatedVersion.archivedStatus === + catalogItemStatuses.ARCHIVED) && + (action === VersionControllerActionsEnum.COMMIT || + action === VersionControllerActionsEnum.SYNC) + ) { + versionPageActionHelper.fetchVersions(dispatch, { + itemType: itemTypes.SOFTWARE_PRODUCT, + itemId: softwareProductId + }); + const msg = + updatedVersion.archivedStatus === + catalogItemStatuses.ARCHIVED + ? i18n('Item was Archived') + : i18n('Item version already Certified'); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: i18n('Commit error'), + msg, + cancelButtonText: i18n('Cancel') + } + }); + return Promise.resolve(updatedVersion); + } + if (!inMerge) { + if (action === VersionControllerActionsEnum.SUBMIT) { + return this.manageSubmitAction(dispatch, { + softwareProductId, + version, + isDirty + }); + } else { + let isCallActionValid = + action !== VersionControllerActionsEnum.COMMIT || + isDirty; + if (isCallActionValid) { + return ItemsHelper.performVCAction({ + itemId: softwareProductId, + action, + version, + comment + }).then(() => { + versionPageActionHelper.fetchVersions(dispatch, { + itemType: itemTypes.LICENSE_MODEL, + itemId: softwareProductId + }); + if (action === VersionControllerActionsEnum.SYNC) { + return MergeEditorActionHelper.analyzeSyncResult( + dispatch, + { itemId: softwareProductId, version } + ).then(({ updatedVersion }) => { + return Promise.resolve(updatedVersion); + }); + } else { + return ItemsHelper.checkItemStatus(dispatch, { + itemId: softwareProductId, + versionId: version.id + }); + } + }); + } else { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('Commit Failed'), + msg: i18n('There is nothing to commit') + } + }); + } + } + } + }); + }, + + toggleNavigationItems(dispatch, { items, itemIdToExpand }) { + let mapOfExpandedIds = getExpandedItemsId(items, itemIdToExpand); + dispatch({ + type: actionTypes.TOGGLE_NAVIGATION_ITEM, + mapOfExpandedIds + }); + }, + + /** for the next verision */ + addComponent(dispatch, { softwareProductId, modalClassName, version }) { + SoftwareProductComponentsActionHelper.clearComponentCreationData( + dispatch + ); + dispatch({ + type: componentActionTypes.COMPONENT_CREATE_OPEN + }); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.COMPONENT_CREATION, + modalComponentProps: { softwareProductId, version }, + modalClassName, + title: 'Create Virtual Function Component' + } + }); + }, + + migrateSoftwareProduct(dispatch, { softwareProduct }) { + let { id: softwareProductId, version } = softwareProduct; + const newVer = version.id; + migrateSoftwareProduct(softwareProductId, version).then(() => + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + version: { id: newVer, label: newVer } + } + }) + ); + }, + + abortCandidateValidation(dispatch, { softwareProductId, version }) { + return abortValidationProcess(softwareProductId, version); + } }; export default SoftwareProductActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js index 9b147415f9..d1ba947f81 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js @@ -14,17 +14,21 @@ * permissions and limitations under the License. */ export default { - - getCurrentCategoryOfSubCategory(selectedSubCategory, softwareProductCategories) { - let category, subCategory; - for (var i = 0; i < softwareProductCategories.length; i++) { - let {subcategories = []} = softwareProductCategories[i]; - subCategory = subcategories.find(sub => sub.uniqueId === selectedSubCategory); - if (subCategory) { - category = softwareProductCategories[i].uniqueId; - break; - } - } - return category; - } + getCurrentCategoryOfSubCategory( + selectedSubCategory, + softwareProductCategories + ) { + let category, subCategory; + for (var i = 0; i < softwareProductCategories.length; i++) { + let { subcategories = [] } = softwareProductCategories[i]; + subCategory = subcategories.find( + sub => sub.uniqueId === selectedSubCategory + ); + if (subCategory) { + category = softwareProductCategories[i].uniqueId; + break; + } + } + return category; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js index d33eb822cf..711bbf8db8 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js @@ -16,41 +16,38 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - SOFTWARE_PRODUCT_LOADED: null, - SOFTWARE_PRODUCT_LIST_LOADED: null, - ARCHIVED_SOFTWARE_PRODUCT_LIST_LOADED: null, - FINALIZED_SOFTWARE_PRODUCT_LIST_LOADED: null, - SOFTWARE_PRODUCT_LIST_EDIT: null, - SOFTWARE_PRODUCT_CATEGORIES_LOADED: null, - SOFTWARE_PRODUCT_QUESTIONNAIRE_UPDATE: null, - LOAD_LICENSING_VERSIONS_LIST: null, - TOGGLE_NAVIGATION_ITEM: null, - CANDIDATE_IN_PROCESS: null, - - softwareProductEditor: { - OPEN: null, - CLOSE: null, - DATA_CHANGED: null, - IS_VALIDITY_DATA_CHANGED: null - } + SOFTWARE_PRODUCT_LOADED: null, + SOFTWARE_PRODUCT_LIST_LOADED: null, + ARCHIVED_SOFTWARE_PRODUCT_LIST_LOADED: null, + FINALIZED_SOFTWARE_PRODUCT_LIST_LOADED: null, + SOFTWARE_PRODUCT_LIST_EDIT: null, + SOFTWARE_PRODUCT_CATEGORIES_LOADED: null, + SOFTWARE_PRODUCT_QUESTIONNAIRE_UPDATE: null, + LOAD_LICENSING_VERSIONS_LIST: null, + TOGGLE_NAVIGATION_ITEM: null, + CANDIDATE_IN_PROCESS: null, + + softwareProductEditor: { + OPEN: null, + CLOSE: null, + DATA_CHANGED: null, + IS_VALIDITY_DATA_CHANGED: null + } }); - - export const onboardingMethod = { - MANUAL: 'Manual', - NETWORK_PACKAGE: 'NetworkPackage' + MANUAL: 'Manual', + NETWORK_PACKAGE: 'NetworkPackage' }; export const onboardingOriginTypes = { - NONE: 'none', - ZIP: 'zip', - CSAR: 'csar' + NONE: 'none', + ZIP: 'zip', + CSAR: 'csar' }; export const forms = keyMirror({ - VENDOR_SOFTWARE_PRODUCT_DETAILS: 'vendor-software-product-details', + VENDOR_SOFTWARE_PRODUCT_DETAILS: 'vendor-software-product-details' }); export const PRODUCT_QUESTIONNAIRE = 'product'; - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductListReducer.js index 31be338ff5..f52153a29f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductListReducer.js @@ -13,16 +13,22 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductConstants.js'; +import { actionTypes } from './SoftwareProductConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.SOFTWARE_PRODUCT_LIST_LOADED: - return [...action.response.results]; - case actionTypes.SOFTWARE_PRODUCT_LIST_EDIT: - const indexForEdit = state.findIndex(vsp => vsp.id === action.payload.softwareProduct.id); - return [...state.slice(0, indexForEdit), action.payload.softwareProduct, ...state.slice(indexForEdit + 1)]; - default: - return state; - } + switch (action.type) { + case actionTypes.SOFTWARE_PRODUCT_LIST_LOADED: + return [...action.response.results]; + case actionTypes.SOFTWARE_PRODUCT_LIST_EDIT: + const indexForEdit = state.findIndex( + vsp => vsp.id === action.payload.softwareProduct.id + ); + return [ + ...state.slice(0, indexForEdit), + action.payload.softwareProduct, + ...state.slice(indexForEdit + 1) + ]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js index d7a6c2ef5c..f3de517a1c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js @@ -13,12 +13,15 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {combineReducers} from 'redux'; -import {actionTypes, PRODUCT_QUESTIONNAIRE} from './SoftwareProductConstants.js'; +import { combineReducers } from 'redux'; +import { + actionTypes, + PRODUCT_QUESTIONNAIRE +} from './SoftwareProductConstants.js'; import SoftwareProductAttachmentsReducer from './attachments/SoftwareProductAttachmentsReducer.js'; import HeatValidationReducer from './attachments/validation/HeatValidationReducer.js'; import HeatSetupReducer from './attachments/setup/HeatSetupReducer.js'; -import {actionTypes as heatSetupActionTypes} from './attachments/setup/HeatSetupConstants.js'; +import { actionTypes as heatSetupActionTypes } from './attachments/setup/HeatSetupConstants.js'; import SoftwareProductCreationReducer from './creation/SoftwareProductCreationReducer.js'; import SoftwareProductDetailsReducer from './details/SoftwareProductDetailsReducer.js'; import SoftwareProductProcessesListReducer from './processes/SoftwareProductProcessesListReducer.js'; @@ -28,10 +31,10 @@ import SoftwareProductDeploymentEditorReducer from './deployment/editor/Software import SoftwareProductNetworksListReducer from './networks/SoftwareProductNetworksListReducer.js'; import SoftwareProductComponentsListReducer from './components/SoftwareProductComponentsListReducer.js'; import SoftwareProductComponentEditorReducer from './components/SoftwareProductComponentEditorReducer.js'; -import {actionTypes as processesActionTypes} from './processes/SoftwareProductProcessesConstants.js'; -import SoftwareProductComponentProcessesListReducer from './components/processes/SoftwareProductComponentProcessesListReducer.js'; +import { actionTypes as processesActionTypes } from './processes/SoftwareProductProcessesConstants.js'; +import SoftwareProductComponentProcessesListReducer from './components/processes/SoftwareProductComponentProcessesListReducer.js'; import SoftwareProductComponentProcessesEditorReducer from './components/processes/SoftwareProductComponentProcessesEditorReducer.js'; -import {actionTypes as componentProcessesActionTypes} from './components/processes/SoftwareProductComponentProcessesConstants.js'; +import { actionTypes as componentProcessesActionTypes } from './components/processes/SoftwareProductComponentProcessesConstants.js'; import SoftwareProductComponentsNICListReducer from './components/network/SoftwareProductComponentsNICListReducer.js'; import SoftwareProductComponentsNICEditorReducer from './components/network/SoftwareProductComponentsNICEditorReducer.js'; import SoftwareProductComponentsImageListReducer from './components/images/SoftwareProductComponentsImageListReducer.js'; @@ -40,63 +43,112 @@ import SoftwareProductComponentsNICCreationReducer from './components/network/NI import SoftwareProductComponentsMonitoringReducer from './components/monitoring/SoftwareProductComponentsMonitoringReducer.js'; import SoftwareProductComponentsComputeFlavorListReducer from './components/compute/computeComponents/computeFlavor/ComputeFlavorListReducer.js'; import SoftwareProductComponentsComputeFlavorReducer from './components/compute/computeComponents/computeFlavor/ComputeFlavorReducer.js'; -import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js'; +import { createPlainDataReducer } from 'sdc-app/common/reducers/PlainDataReducer.js'; import SoftwareProductDependenciesReducer from './dependencies/SoftwareProductDependenciesReducer.js'; -import {createJSONSchemaReducer, createComposedJSONSchemaReducer} from 'sdc-app/common/reducers/JSONSchemaReducer.js'; -import {COMPONENTS_QUESTIONNAIRE, COMPONENTS_COMPUTE_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; -import {NIC_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js'; -import {IMAGE_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageConstants.js'; +import { + createJSONSchemaReducer, + createComposedJSONSchemaReducer +} from 'sdc-app/common/reducers/JSONSchemaReducer.js'; +import { + COMPONENTS_QUESTIONNAIRE, + COMPONENTS_COMPUTE_QUESTIONNAIRE +} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { NIC_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js'; +import { IMAGE_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageConstants.js'; export default combineReducers({ - softwareProductAttachments: combineReducers({ - attachmentsDetails: SoftwareProductAttachmentsReducer, - heatValidation: HeatValidationReducer, - heatSetup: HeatSetupReducer, - heatSetupCache: (state = {}, action) => action.type === heatSetupActionTypes.FILL_HEAT_SETUP_CACHE ? action.payload : state - }), - softwareProductCreation: createPlainDataReducer(SoftwareProductCreationReducer), - softwareProductEditor: createPlainDataReducer(SoftwareProductDetailsReducer), - softwareProductProcesses: combineReducers({ - processesList: SoftwareProductProcessesListReducer, - processesEditor: createPlainDataReducer(SoftwareProductProcessesEditorReducer), - processToDelete: (state = false, action) => action.type === processesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM ? action.processToDelete : state - }), - softwareProductDeployment: combineReducers({ - deploymentFlavors: SoftwareProductDeploymentListReducer, - deploymentFlavorEditor: createPlainDataReducer(SoftwareProductDeploymentEditorReducer) - }), - softwareProductNetworks: combineReducers({ - networksList: SoftwareProductNetworksListReducer - }), - softwareProductDependencies: SoftwareProductDependenciesReducer, - softwareProductComponents: combineReducers({ - componentsList: SoftwareProductComponentsListReducer, - componentEditor: createPlainDataReducer(createComposedJSONSchemaReducer(COMPONENTS_QUESTIONNAIRE, SoftwareProductComponentEditorReducer)), - componentProcesses: combineReducers({ - processesList: SoftwareProductComponentProcessesListReducer, - processesEditor: createPlainDataReducer(SoftwareProductComponentProcessesEditorReducer), - processToDelete: (state = false, action) => action.type === componentProcessesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM ? action.processToDelete : state, - }), - network: combineReducers({ - nicList: SoftwareProductComponentsNICListReducer, - nicEditor: createPlainDataReducer(createComposedJSONSchemaReducer(NIC_QUESTIONNAIRE, SoftwareProductComponentsNICEditorReducer)), - nicCreation: createPlainDataReducer(SoftwareProductComponentsNICCreationReducer) - }), - images: combineReducers({ - imagesList: SoftwareProductComponentsImageListReducer, - imageEditor: createPlainDataReducer(createComposedJSONSchemaReducer(IMAGE_QUESTIONNAIRE, SoftwareProductComponentsImageEditorReducer)) - }), - computeFlavor: combineReducers({ - computesList: SoftwareProductComponentsComputeFlavorListReducer, - computeEditor: createPlainDataReducer(createComposedJSONSchemaReducer(COMPONENTS_COMPUTE_QUESTIONNAIRE, SoftwareProductComponentsComputeFlavorReducer)), - }), - monitoring: SoftwareProductComponentsMonitoringReducer - }), - softwareProductCategories: (state = [], action) => { - if (action.type === actionTypes.SOFTWARE_PRODUCT_CATEGORIES_LOADED) { - return action.softwareProductCategories; - } - return state; - }, - softwareProductQuestionnaire: createJSONSchemaReducer(PRODUCT_QUESTIONNAIRE) + softwareProductAttachments: combineReducers({ + attachmentsDetails: SoftwareProductAttachmentsReducer, + heatValidation: HeatValidationReducer, + heatSetup: HeatSetupReducer, + heatSetupCache: (state = {}, action) => + action.type === heatSetupActionTypes.FILL_HEAT_SETUP_CACHE + ? action.payload + : state + }), + softwareProductCreation: createPlainDataReducer( + SoftwareProductCreationReducer + ), + softwareProductEditor: createPlainDataReducer( + SoftwareProductDetailsReducer + ), + softwareProductProcesses: combineReducers({ + processesList: SoftwareProductProcessesListReducer, + processesEditor: createPlainDataReducer( + SoftwareProductProcessesEditorReducer + ), + processToDelete: (state = false, action) => + action.type === + processesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM + ? action.processToDelete + : state + }), + softwareProductDeployment: combineReducers({ + deploymentFlavors: SoftwareProductDeploymentListReducer, + deploymentFlavorEditor: createPlainDataReducer( + SoftwareProductDeploymentEditorReducer + ) + }), + softwareProductNetworks: combineReducers({ + networksList: SoftwareProductNetworksListReducer + }), + softwareProductDependencies: SoftwareProductDependenciesReducer, + softwareProductComponents: combineReducers({ + componentsList: SoftwareProductComponentsListReducer, + componentEditor: createPlainDataReducer( + createComposedJSONSchemaReducer( + COMPONENTS_QUESTIONNAIRE, + SoftwareProductComponentEditorReducer + ) + ), + componentProcesses: combineReducers({ + processesList: SoftwareProductComponentProcessesListReducer, + processesEditor: createPlainDataReducer( + SoftwareProductComponentProcessesEditorReducer + ), + processToDelete: (state = false, action) => + action.type === + componentProcessesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM + ? action.processToDelete + : state + }), + network: combineReducers({ + nicList: SoftwareProductComponentsNICListReducer, + nicEditor: createPlainDataReducer( + createComposedJSONSchemaReducer( + NIC_QUESTIONNAIRE, + SoftwareProductComponentsNICEditorReducer + ) + ), + nicCreation: createPlainDataReducer( + SoftwareProductComponentsNICCreationReducer + ) + }), + images: combineReducers({ + imagesList: SoftwareProductComponentsImageListReducer, + imageEditor: createPlainDataReducer( + createComposedJSONSchemaReducer( + IMAGE_QUESTIONNAIRE, + SoftwareProductComponentsImageEditorReducer + ) + ) + }), + computeFlavor: combineReducers({ + computesList: SoftwareProductComponentsComputeFlavorListReducer, + computeEditor: createPlainDataReducer( + createComposedJSONSchemaReducer( + COMPONENTS_COMPUTE_QUESTIONNAIRE, + SoftwareProductComponentsComputeFlavorReducer + ) + ) + }), + monitoring: SoftwareProductComponentsMonitoringReducer + }), + softwareProductCategories: (state = [], action) => { + if (action.type === actionTypes.SOFTWARE_PRODUCT_CATEGORIES_LOADED) { + return action.softwareProductCategories; + } + return state; + }, + softwareProductQuestionnaire: createJSONSchemaReducer(PRODUCT_QUESTIONNAIRE) }); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js index d942172973..4d5887be6f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js @@ -13,100 +13,142 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; import HeatSetupActionHelper from './setup/HeatSetupActionHelper.js'; import SoftwareProductAttachmentsView from './SoftwareProductAttachmentsView.jsx'; -import {errorLevels} from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js'; +import { errorLevels } from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js'; import HeatSetup from './setup/HeatSetup.js'; -import {doesHeatDataExist} from './SoftwareProductAttachmentsUtils.js'; +import { doesHeatDataExist } from './SoftwareProductAttachmentsUtils.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import SoftwareProductAttachmentsActionHelper from './SoftwareProductAttachmentsActionHelper.js'; -export const mapStateToProps = (state) => { - let { - softwareProduct: { - softwareProductEditor:{data: currentSoftwareProduct = {}}, - softwareProductAttachments: {attachmentsDetails: {activeTab}, heatSetup, heatSetupCache, heatValidation : {errorList}} - } - } = state; +export const mapStateToProps = state => { + let { + softwareProduct: { + softwareProductEditor: { data: currentSoftwareProduct = {} }, + softwareProductAttachments: { + attachmentsDetails: { activeTab }, + heatSetup, + heatSetupCache, + heatValidation: { errorList } + } + } + } = state; - let {unassigned = [], modules = []} = heatSetup; - let goToOverview = true; - if (errorList) { - for (let i = 0 ; i < errorList.length ; i++) { - if (errorList[i].level === errorLevels.ERROR) { - goToOverview = false; - } - } - } - let heatDataExist = doesHeatDataExist(heatSetup); + let { unassigned = [], modules = [] } = heatSetup; + let goToOverview = true; + if (errorList) { + for (let i = 0; i < errorList.length; i++) { + if (errorList[i].level === errorLevels.ERROR) { + goToOverview = false; + } + } + } + let heatDataExist = doesHeatDataExist(heatSetup); - let {version, onboardingOrigin} = currentSoftwareProduct; - return { - isValidationAvailable: unassigned.length === 0 && modules.length > 0, - heatSetup, - heatSetupCache, - heatDataExist, - goToOverview, - HeatSetupComponent: HeatSetup, - version, - onboardingOrigin, - activeTab, - candidateInProcess: !!currentSoftwareProduct.candidateOnboardingOrigin - }; + let { version, onboardingOrigin } = currentSoftwareProduct; + return { + isValidationAvailable: unassigned.length === 0 && modules.length > 0, + heatSetup, + heatSetupCache, + heatDataExist, + goToOverview, + HeatSetupComponent: HeatSetup, + version, + onboardingOrigin, + activeTab, + candidateInProcess: !!currentSoftwareProduct.candidateOnboardingOrigin + }; }; -export const mapActionsToProps = (dispatch, {softwareProductId, version}) => { - return { - onDownload: ({heatCandidate, isReadOnlyMode}) => SoftwareProductActionHelper.downloadHeatFile(dispatch, {softwareProductId, heatCandidate, isReadOnlyMode, version}), - onUpload: (formData) => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data:{ - msg: i18n('Upload will erase existing data. Do you want to continue?'), - confirmationButtonText: i18n('Continue'), - title: i18n('WARNING'), +export const mapActionsToProps = (dispatch, { softwareProductId, version }) => { + return { + onDownload: ({ heatCandidate, isReadOnlyMode }) => + SoftwareProductActionHelper.downloadHeatFile(dispatch, { + softwareProductId, + heatCandidate, + isReadOnlyMode, + version + }), + onUpload: formData => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + msg: i18n( + 'Upload will erase existing data. Do you want to continue?' + ), + confirmationButtonText: i18n('Continue'), + title: i18n('WARNING'), - onConfirmed: ()=>SoftwareProductActionHelper.uploadFile(dispatch, { - softwareProductId, - formData, - failedNotificationTitle: i18n('Upload validation failed'), - version - }) - } - }), - onUploadAbort: () => { - SoftwareProductActionHelper.abortCandidateValidation(dispatch, {softwareProductId, version}) - .then(()=>{ - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version} - }); - }); - }, - onInvalidFileUpload: () => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - title: i18n('Upload Failed'), - confirmationButtonText: i18n('Continue'), - msg: i18n('no zip or csar file was uploaded or expected file doesn\'t exist') - } - }), - onSave: (heatCandidate) => SoftwareProductActionHelper.updateSoftwareProductHeatCandidate(dispatch, {softwareProductId, heatCandidate, version}), - onGoToOverview: () => ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version} - }), - onProcessAndValidate: ({heatData, heatDataCache, isReadOnlyMode}) => { - return HeatSetupActionHelper.processAndValidateHeat(dispatch, - {softwareProductId, heatData, heatDataCache, isReadOnlyMode, version}); - }, - setActiveTab: ({activeTab}) => SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, {activeTab}) - - }; + onConfirmed: () => + SoftwareProductActionHelper.uploadFile(dispatch, { + softwareProductId, + formData, + failedNotificationTitle: i18n( + 'Upload validation failed' + ), + version + }) + } + }), + onUploadAbort: () => { + SoftwareProductActionHelper.abortCandidateValidation(dispatch, { + softwareProductId, + version + }).then(() => { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId, version } + }); + }); + }, + onInvalidFileUpload: () => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('Upload Failed'), + confirmationButtonText: i18n('Continue'), + msg: i18n( + "no zip or csar file was uploaded or expected file doesn't exist" + ) + } + }), + onSave: heatCandidate => + SoftwareProductActionHelper.updateSoftwareProductHeatCandidate( + dispatch, + { + softwareProductId, + heatCandidate, + version + } + ), + onGoToOverview: () => + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId, version } + }), + onProcessAndValidate: ({ heatData, heatDataCache, isReadOnlyMode }) => { + return HeatSetupActionHelper.processAndValidateHeat(dispatch, { + softwareProductId, + heatData, + heatDataCache, + isReadOnlyMode, + version + }); + }, + setActiveTab: ({ activeTab }) => + SoftwareProductAttachmentsActionHelper.setActiveTab(dispatch, { + activeTab + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductAttachmentsView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductAttachmentsView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js index ae4a615a40..2d35bc27ee 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js @@ -14,13 +14,13 @@ * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductAttachmentsConstants'; +import { actionTypes } from './SoftwareProductAttachmentsConstants'; export default { - setActiveTab(dispatch, {activeTab}) { - dispatch({ - type: actionTypes.SET_ACTIVE_TAB, - activeTab - }); - } + setActiveTab(dispatch, { activeTab }) { + dispatch({ + type: actionTypes.SET_ACTIVE_TAB, + activeTab + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js index 67265909d7..aff0a3dbdf 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js @@ -16,10 +16,10 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const tabsMapping = { - SETUP: 1, - VALIDATION: 2 + SETUP: 1, + VALIDATION: 2 }; export const actionTypes = keyMirror({ - SET_ACTIVE_TAB: null + SET_ACTIVE_TAB: null }); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js index 5f6538ab7e..5d9a37f98a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js @@ -13,13 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductAttachmentsConstants.js'; +import { actionTypes } from './SoftwareProductAttachmentsConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.SET_ACTIVE_TAB: - return {activeTab: action.activeTab}; - default: - return state; - } + switch (action.type) { + case actionTypes.SET_ACTIVE_TAB: + return { activeTab: action.activeTab }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsUtils.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsUtils.js index 2e76b11630..f4e77229e9 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsUtils.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsUtils.js @@ -15,11 +15,11 @@ */ export function doesHeatDataExist(heatData) { - let result = false; - for (let key of Object.keys(heatData)) { - if(heatData[key].length > 0) { - result = true; - } - } - return result; + let result = false; + for (let key of Object.keys(heatData)) { + if (heatData[key].length > 0) { + result = true; + } + } + return result; } diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx index 2a849f376e..2007493d48 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx @@ -13,140 +13,208 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import accept from 'attr-accept'; -import {SVGIcon, Tab, Tabs} from 'sdc-ui/lib/react'; -import {tabsMapping} from './SoftwareProductAttachmentsConstants.js'; +import { SVGIcon, Tab, Tabs } from 'sdc-ui/lib/react'; +import { tabsMapping } from './SoftwareProductAttachmentsConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import HeatValidation from './validation/HeatValidation.js'; -import {onboardingOriginTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { onboardingOriginTypes } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; import Button from 'sdc-ui/lib/react/Button.js'; class HeatScreenView extends Component { + static propTypes = { + isValidationAvailable: PropTypes.bool, + goToOverview: PropTypes.bool, + setActiveTab: PropTypes.func + }; - static propTypes = { - isValidationAvailable: PropTypes.bool, - goToOverview: PropTypes.bool, - setActiveTab: PropTypes.func - }; + componentDidMount() { + if (!this.props.goToOverview && this.props.candidateInProcess) { + this.props.setActiveTab({ activeTab: tabsMapping.VALIDATION }); + } + } - componentDidMount() { - if (!this.props.goToOverview && this.props.candidateInProcess) { - this.props.setActiveTab({activeTab: tabsMapping.VALIDATION}); - } - } + render() { + let { + isValidationAvailable, + isReadOnlyMode, + heatDataExist, + onDownload, + softwareProductId, + onProcessAndValidate, + onUploadAbort, + candidateInProcess, + heatSetup, + HeatSetupComponent, + onGoToOverview, + version, + onboardingOrigin, + activeTab, + setActiveTab, + ...other + } = this.props; - render() { - let {isValidationAvailable, isReadOnlyMode, heatDataExist, onDownload, softwareProductId, onProcessAndValidate, onUploadAbort, - candidateInProcess, heatSetup, HeatSetupComponent, onGoToOverview, version, onboardingOrigin, activeTab, setActiveTab, ...other} = this.props; + return ( +
    +
    + {activeTab === tabsMapping.SETUP && + candidateInProcess && ( + + )} + {candidateInProcess && ( + + )} + {activeTab === tabsMapping.VALIDATION && + softwareProductId && ( + + )} +
    + + onDownload({ + heatCandidate: heatSetup, + isReadOnlyMode: + isReadOnlyMode || + !candidateInProcess, + version + }) + : undefined + } + data-test-id="download-heat" + /> + + this.refs.hiddenImportFileInput.click(evt) + } + data-test-id="upload-heat" + /> + this.handleImport(evt)} + /> +
    + this.handleTabPress(key)}> + + + setActiveTab({ activeTab: tab }) + } + onProcessAndValidate={onProcessAndValidate} + softwareProductId={softwareProductId} + isReadOnlyMode={isReadOnlyMode} + version={version} + /> + + + + + +
    + ); + } - return ( -
    -
    - {(activeTab === tabsMapping.SETUP) && candidateInProcess && - - } - {candidateInProcess && - } - {(activeTab === tabsMapping.VALIDATION && softwareProductId) && - } -
    - onDownload({heatCandidate: heatSetup, isReadOnlyMode: isReadOnlyMode || !candidateInProcess, version}) : undefined} - data-test-id='download-heat'/> - this.refs.hiddenImportFileInput.click(evt)} - data-test-id='upload-heat'/> - this.handleImport(evt)}/> -
    - this.handleTabPress(key)}> - - setActiveTab({activeTab: tab})} - onProcessAndValidate={onProcessAndValidate} - softwareProductId={softwareProductId} - isReadOnlyMode={isReadOnlyMode} - version={version}/> - - - - - -
    - ); - } - - handleTabPress(key) { - let {setActiveTab} = this.props; - switch (key) { - case tabsMapping.VALIDATION: - setActiveTab({activeTab: tabsMapping.VALIDATION}); - return; - case tabsMapping.SETUP: - setActiveTab({activeTab: tabsMapping.SETUP}); - return; - } - } - - handleImport(evt) { - evt.preventDefault(); - let file = this.refs.hiddenImportFileInput.files[0]; - if(! (file && file.size && accept(file, ['.zip', '.csar'])) ) { - this.props.onInvalidFileUpload(); - return; - } - let {version} = this.props; - let formData = new FormData(); - formData.append('upload', file); - this.refs.hiddenImportFileInput.value = ''; - this.props.onUpload(formData, version); - } - validate() { - let {heatSetup, heatSetupCache, onProcessAndValidate, isReadOnlyMode, version, setActiveTab} = this.props; - onProcessAndValidate({heatData: heatSetup, heatDataCache: heatSetupCache, isReadOnlyMode, version}).then( - () => setActiveTab({activeTab: tabsMapping.VALIDATION}) - ); - } - save() { - return this.props.onboardingOrigin === onboardingOriginTypes.ZIP ? - this.props.onSave(this.props.heatSetup, this.props.version) : - Promise.resolve(); - } + handleTabPress(key) { + let { setActiveTab } = this.props; + switch (key) { + case tabsMapping.VALIDATION: + setActiveTab({ activeTab: tabsMapping.VALIDATION }); + return; + case tabsMapping.SETUP: + setActiveTab({ activeTab: tabsMapping.SETUP }); + return; + } + } + handleImport(evt) { + evt.preventDefault(); + let file = this.refs.hiddenImportFileInput.files[0]; + if (!(file && file.size && accept(file, ['.zip', '.csar']))) { + this.props.onInvalidFileUpload(); + return; + } + let { version } = this.props; + let formData = new FormData(); + formData.append('upload', file); + this.refs.hiddenImportFileInput.value = ''; + this.props.onUpload(formData, version); + } + validate() { + let { + heatSetup, + heatSetupCache, + onProcessAndValidate, + isReadOnlyMode, + version, + setActiveTab + } = this.props; + onProcessAndValidate({ + heatData: heatSetup, + heatDataCache: heatSetupCache, + isReadOnlyMode, + version + }).then(() => setActiveTab({ activeTab: tabsMapping.VALIDATION })); + } + save() { + return this.props.onboardingOrigin === onboardingOriginTypes.ZIP + ? this.props.onSave(this.props.heatSetup, this.props.version) + : Promise.resolve(); + } } export default HeatScreenView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetup.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetup.js index 4c3adc6a7d..d75d464f9e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetup.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetup.js @@ -13,50 +13,65 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import HeatSetupView from './HeatSetupView.jsx'; import HeatSetupActionHelper from './HeatSetupActionHelper.js'; - const BASE = true; function baseExists(modules) { - for (let i in modules) { - if (modules[i].isBase) { - return true; - } - } - return false; + for (let i in modules) { + if (modules[i].isBase) { + return true; + } + } + return false; } -export const mapStateToProps = ({softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}}) => { - let {modules = [], unassigned = [], artifacts = [], nested = []} = heatSetup; - let isBaseExist = baseExists(modules); +export const mapStateToProps = ({ + softwareProduct: { + softwareProductAttachments: { heatSetup, heatSetupCache } + } +}) => { + let { + modules = [], + unassigned = [], + artifacts = [], + nested = [] + } = heatSetup; + let isBaseExist = baseExists(modules); - return { - heatSetupCache, - modules, - unassigned, - artifacts, - nested, - isBaseExist - }; + return { + heatSetupCache, + modules, + unassigned, + artifacts, + nested, + isBaseExist + }; }; export const mapActionsToProps = (dispatch, {}) => { - return { - onModuleRename: (oldName, newName) => HeatSetupActionHelper.renameModule(dispatch, {oldName, newName}), - onModuleAdd: () => HeatSetupActionHelper.addModule(dispatch, !BASE), - onBaseAdd: () => HeatSetupActionHelper.addModule(dispatch, BASE), - onModuleDelete: moduleName => HeatSetupActionHelper.deleteModule(dispatch, moduleName), - onModuleFileTypeChange: ({module, value, type}) => HeatSetupActionHelper.changeModuleFileType(dispatch, { - module, - value, - type - }), - onArtifactListChange: artifacts => HeatSetupActionHelper.changeArtifactList(dispatch, artifacts), - onAddAllUnassigned: () => HeatSetupActionHelper.addAllUnassignedFilesToArtifacts(dispatch) - }; + return { + onModuleRename: (oldName, newName) => + HeatSetupActionHelper.renameModule(dispatch, { oldName, newName }), + onModuleAdd: () => HeatSetupActionHelper.addModule(dispatch, !BASE), + onBaseAdd: () => HeatSetupActionHelper.addModule(dispatch, BASE), + onModuleDelete: moduleName => + HeatSetupActionHelper.deleteModule(dispatch, moduleName), + onModuleFileTypeChange: ({ module, value, type }) => + HeatSetupActionHelper.changeModuleFileType(dispatch, { + module, + value, + type + }), + onArtifactListChange: artifacts => + HeatSetupActionHelper.changeArtifactList(dispatch, artifacts), + onAddAllUnassigned: () => + HeatSetupActionHelper.addAllUnassignedFilesToArtifacts(dispatch) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(HeatSetupView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(HeatSetupView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js index 87953bb8aa..05ac408fbb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './HeatSetupConstants.js'; +import { actionTypes } from './HeatSetupConstants.js'; import isEqual from 'lodash/isEqual.js'; import cloneDeep from 'lodash/cloneDeep.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; @@ -21,46 +21,72 @@ import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/Soft // import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; export default { + addModule(dispatch, isBase) { + dispatch({ type: actionTypes.ADD_MODULE, data: { isBase } }); + }, - addModule(dispatch, isBase){ - dispatch({type: actionTypes.ADD_MODULE, data: {isBase}}); - }, + deleteModule(dispatch, moduleName) { + dispatch({ type: actionTypes.REMOVE_MODULE, data: { moduleName } }); + }, - deleteModule(dispatch, moduleName){ - dispatch({type: actionTypes.REMOVE_MODULE, data: {moduleName}}); - }, + renameModule(dispatch, { oldName, newName }) { + dispatch({ + type: actionTypes.RENAME_MODULE, + data: { oldName, newName } + }); + }, - renameModule(dispatch, {oldName, newName}){ - dispatch({type: actionTypes.RENAME_MODULE, data: {oldName, newName}}); - }, + changeModuleFileType(dispatch, { module, value, type }) { + if (!value) { + value = { value: '' }; + } + dispatch({ + type: actionTypes.FILE_ASSIGN_CHANGED, + data: { module, value, type } + }); + }, - changeModuleFileType(dispatch, {module, value, type}){ - if (!value) { - value = {value: ''}; - } - dispatch({type: actionTypes.FILE_ASSIGN_CHANGED, data: {module, value, type}}); - }, + changeArtifactList(dispatch, artifacts) { + dispatch({ + type: actionTypes.ARTIFACT_LIST_CHANGE, + data: { artifacts: artifacts.map(artifact => artifact.value) } + }); + }, - changeArtifactList(dispatch, artifacts){ - dispatch({type: actionTypes.ARTIFACT_LIST_CHANGE, data: {artifacts: artifacts.map(artifact => artifact.value)}}); - }, + processAndValidateHeat( + dispatch, + { softwareProductId, heatData, heatDataCache, isReadOnlyMode, version } + ) { + return isEqual({ ...heatData, softwareProductId }, heatDataCache) || + isReadOnlyMode + ? Promise.resolve() + : SoftwareProductActionHelper.updateSoftwareProductHeatCandidate( + dispatch, + { softwareProductId, heatCandidate: heatData, version } + ) + .then(() => + SoftwareProductActionHelper.processAndValidateHeatCandidate( + dispatch, + { softwareProductId, version } + ) + ) + .then(() => + dispatch({ + type: actionTypes.FILL_HEAT_SETUP_CACHE, + payload: { ...cloneDeep(heatData), softwareProductId } + }) + ); + }, - processAndValidateHeat(dispatch, {softwareProductId, heatData, heatDataCache, isReadOnlyMode, version}){ - return (isEqual({...heatData, softwareProductId}, heatDataCache) || isReadOnlyMode) ? Promise.resolve() : - SoftwareProductActionHelper.updateSoftwareProductHeatCandidate(dispatch, {softwareProductId, heatCandidate: heatData, version}) - .then(() => SoftwareProductActionHelper.processAndValidateHeatCandidate(dispatch, {softwareProductId, version})) - .then(() => dispatch({type: actionTypes.FILL_HEAT_SETUP_CACHE, payload: {...cloneDeep(heatData), softwareProductId}})); - }, + addAllUnassignedFilesToArtifacts(dispatch) { + dispatch({ type: actionTypes.ADD_ALL_UNASSIGNED_TO_ARTIFACTS }); + }, - addAllUnassignedFilesToArtifacts(dispatch){ - dispatch({type: actionTypes.ADD_ALL_UNASSIGNED_TO_ARTIFACTS}); - }, + heatSetupLeaveConfirmation() { + return Promise.resolve(); + } - heatSetupLeaveConfirmation() { - return Promise.resolve(); - } - - /*heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) { + /*heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) { return new Promise((resolve, reject) => { if (isEqual({...heatSetup, softwareProductId}, heatSetupCache)) { resolve(); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js index 2d6bd574a7..ff53fad27f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js @@ -16,27 +16,25 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ + ARTIFACT_LIST_CHANGE: null, + ADD_ALL_UNASSIGNED_TO_ARTIFACTS: null, + ADD_ALL_ARTIFACTS_TO_UNASSIGNED: null, - ARTIFACT_LIST_CHANGE: null, - ADD_ALL_UNASSIGNED_TO_ARTIFACTS: null, - ADD_ALL_ARTIFACTS_TO_UNASSIGNED: null, + ADD_MODULE: null, + REMOVE_MODULE: null, + RENAME_MODULE: null, + FILL_HEAT_SETUP_CACHE: null, + FILE_ASSIGN_CHANGED: null, - ADD_MODULE: null, - REMOVE_MODULE: null, - RENAME_MODULE: null, - FILL_HEAT_SETUP_CACHE: null, - FILE_ASSIGN_CHANGED: null, - - MANIFEST_LOADED: null, - - GO_TO_VALIDATION: null, - IN_VALIDATION: null + MANIFEST_LOADED: null, + GO_TO_VALIDATION: null, + IN_VALIDATION: null }); export const fileTypes = { - YAML: {label: 'yaml', regex: /(yaml|yml)/g}, - ENV: {label: 'env', regex: /env/g}, - VOL: {label: 'vol', regex: /(yaml|yml)/g}, - VOL_ENV: {label: 'volEnv', regex: /env/g} + YAML: { label: 'yaml', regex: /(yaml|yml)/g }, + ENV: { label: 'env', regex: /env/g }, + VOL: { label: 'vol', regex: /(yaml|yml)/g }, + VOL_ENV: { label: 'volEnv', regex: /env/g } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupReducer.js index f49339ce35..8840a11c3e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupReducer.js @@ -13,112 +13,163 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './HeatSetupConstants.js'; +import { actionTypes } from './HeatSetupConstants.js'; import differenceWith from 'lodash/differenceWith.js'; - const emptyModule = (isBase, currentLength) => ({ - name: `${isBase ? 'base_' : 'module_'}${currentLength + 1}`, - isBase: isBase + name: `${isBase ? 'base_' : 'module_'}${currentLength + 1}`, + isBase: isBase }); -function syncUnassignedFilesWithArtifactsChanges(unassigned, artifacts, oldArtifacts) { - if (artifacts.length > oldArtifacts.length) { - return differenceWith(unassigned, artifacts, (unassignedFile, artifact) => unassignedFile === artifact); - } - else { - const removedArtifact = differenceWith(oldArtifacts, artifacts, (oldArtifact, artifact) => artifact === oldArtifact); - return [...unassigned, removedArtifact[0]]; - } +function syncUnassignedFilesWithArtifactsChanges( + unassigned, + artifacts, + oldArtifacts +) { + if (artifacts.length > oldArtifacts.length) { + return differenceWith( + unassigned, + artifacts, + (unassignedFile, artifact) => unassignedFile === artifact + ); + } else { + const removedArtifact = differenceWith( + oldArtifacts, + artifacts, + (oldArtifact, artifact) => artifact === oldArtifact + ); + return [...unassigned, removedArtifact[0]]; + } } function findModuleIndexByName(modules, name) { - return modules.findIndex(module => module.name === name); + return modules.findIndex(module => module.name === name); } -function addDeletedModuleFilesToUnassigned(unassigned, deletedModule){ - let files = []; - for(let i in deletedModule){ - if (deletedModule.hasOwnProperty(i)) { - if (typeof deletedModule[i] === 'string' && deletedModule[i] && i !== 'name') { - files.push(deletedModule[i]); - } - } - } +function addDeletedModuleFilesToUnassigned(unassigned, deletedModule) { + let files = []; + for (let i in deletedModule) { + if (deletedModule.hasOwnProperty(i)) { + if ( + typeof deletedModule[i] === 'string' && + deletedModule[i] && + i !== 'name' + ) { + files.push(deletedModule[i]); + } + } + } - return unassigned.concat(files); + return unassigned.concat(files); } export default (state = {}, action) => { - switch (action.type) { - case actionTypes.MANIFEST_LOADED: - return { - ...state, - ...action.response, - modules: action.response.modules.map(module => ({...module, name: module.name || module.yaml.substring(0, module.yaml.lastIndexOf('.'))})) - }; - case actionTypes.ARTIFACT_LIST_CHANGE: - return { - ...state, - artifacts: action.data.artifacts, - unassigned: syncUnassignedFilesWithArtifactsChanges(state.unassigned, action.data.artifacts, state.artifacts) - }; - case actionTypes.ADD_ALL_UNASSIGNED_TO_ARTIFACTS: - return { - ...state, - artifacts: [...state.artifacts,...state.unassigned], - unassigned: [] - }; - case actionTypes.ADD_ALL_ARTIFACTS_TO_UNASSIGNED: - return { - ...state, - artifacts: [], - unassigned: [...state.unassigned, ...state.artifacts] - }; - case actionTypes.ADD_MODULE: - return { - ...state, - modules: state.modules.concat({...emptyModule(action.data.isBase, state.modules.length)}) - }; - case actionTypes.REMOVE_MODULE: - const moduleIndexToDelete = findModuleIndexByName(state.modules, action.data.moduleName); - let unassigned = addDeletedModuleFilesToUnassigned(state.unassigned, state.modules[moduleIndexToDelete]); - return { - ...state, - unassigned, - modules: [...state.modules.slice(0, moduleIndexToDelete), ...state.modules.slice(moduleIndexToDelete + 1)] - }; - case actionTypes.RENAME_MODULE: - const indexToRename = findModuleIndexByName(state.modules, action.data.oldName); - let moduleToRename = state.modules[indexToRename]; - moduleToRename.name = action.data.newName; - return { - ...state, - modules: [...state.modules.slice(0, indexToRename), moduleToRename, ...state.modules.slice(indexToRename + 1)] - }; - case actionTypes.FILE_ASSIGN_CHANGED: - let {module, value:{value}, type} = action.data; - const moduleIndexToModify = findModuleIndexByName(state.modules, module.name); - let moduleToModify = state.modules[moduleIndexToModify]; - let dumpedFile = moduleToModify[type]; - if (dumpedFile !== value) { - if(value) { - moduleToModify[type] = value; - } - else { - delete moduleToModify[type]; - } - const newUnassignedList = dumpedFile ? [...state.unassigned.filter(file => file !== value), dumpedFile] : state.unassigned.filter(file => file !== value); - return { - ...state, - modules: [...state.modules.slice(0, moduleIndexToModify), moduleToModify, ...state.modules.slice(moduleIndexToModify + 1)], - unassigned: newUnassignedList - }; - } - else { - return state; - } - default: - return state; - } + switch (action.type) { + case actionTypes.MANIFEST_LOADED: + return { + ...state, + ...action.response, + modules: action.response.modules.map(module => ({ + ...module, + name: + module.name || + module.yaml.substring(0, module.yaml.lastIndexOf('.')) + })) + }; + case actionTypes.ARTIFACT_LIST_CHANGE: + return { + ...state, + artifacts: action.data.artifacts, + unassigned: syncUnassignedFilesWithArtifactsChanges( + state.unassigned, + action.data.artifacts, + state.artifacts + ) + }; + case actionTypes.ADD_ALL_UNASSIGNED_TO_ARTIFACTS: + return { + ...state, + artifacts: [...state.artifacts, ...state.unassigned], + unassigned: [] + }; + case actionTypes.ADD_ALL_ARTIFACTS_TO_UNASSIGNED: + return { + ...state, + artifacts: [], + unassigned: [...state.unassigned, ...state.artifacts] + }; + case actionTypes.ADD_MODULE: + return { + ...state, + modules: state.modules.concat({ + ...emptyModule(action.data.isBase, state.modules.length) + }) + }; + case actionTypes.REMOVE_MODULE: + const moduleIndexToDelete = findModuleIndexByName( + state.modules, + action.data.moduleName + ); + let unassigned = addDeletedModuleFilesToUnassigned( + state.unassigned, + state.modules[moduleIndexToDelete] + ); + return { + ...state, + unassigned, + modules: [ + ...state.modules.slice(0, moduleIndexToDelete), + ...state.modules.slice(moduleIndexToDelete + 1) + ] + }; + case actionTypes.RENAME_MODULE: + const indexToRename = findModuleIndexByName( + state.modules, + action.data.oldName + ); + let moduleToRename = state.modules[indexToRename]; + moduleToRename.name = action.data.newName; + return { + ...state, + modules: [ + ...state.modules.slice(0, indexToRename), + moduleToRename, + ...state.modules.slice(indexToRename + 1) + ] + }; + case actionTypes.FILE_ASSIGN_CHANGED: + let { module, value: { value }, type } = action.data; + const moduleIndexToModify = findModuleIndexByName( + state.modules, + module.name + ); + let moduleToModify = state.modules[moduleIndexToModify]; + let dumpedFile = moduleToModify[type]; + if (dumpedFile !== value) { + if (value) { + moduleToModify[type] = value; + } else { + delete moduleToModify[type]; + } + const newUnassignedList = dumpedFile + ? [ + ...state.unassigned.filter(file => file !== value), + dumpedFile + ] + : state.unassigned.filter(file => file !== value); + return { + ...state, + modules: [ + ...state.modules.slice(0, moduleIndexToModify), + moduleToModify, + ...state.modules.slice(moduleIndexToModify + 1) + ], + unassigned: newUnassignedList + }; + } else { + return state; + } + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx index ce6d5260d7..1d4efd9104 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import Button from 'sdc-ui/lib/react/Button.js'; import Tooltip from 'react-bootstrap/lib/Tooltip.js'; import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; @@ -21,307 +21,476 @@ import FormControl from 'react-bootstrap/lib/FormControl.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SelectInput from 'nfvo-components/input/SelectInput.jsx'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; -import {fileTypes} from './HeatSetupConstants.js'; -import {tabsMapping} from '../SoftwareProductAttachmentsConstants.js'; -import {sortable} from 'react-sortable'; +import { fileTypes } from './HeatSetupConstants.js'; +import { tabsMapping } from '../SoftwareProductAttachmentsConstants.js'; +import { sortable } from 'react-sortable'; class ListItem extends Component { - - render() { - return ( -
  • {this.props.children}
  • - ); - } + render() { + return
  • {this.props.children}
  • ; + } } - const SortableListItem = sortable(ListItem); class SortableModuleFileList extends Component { - - state = { - draggingIndex: null, - data: this.props.modules - }; - - - componentWillReceiveProps(nextProps) { - this.setState({data: nextProps.modules}); - } - - render() { - - let {unassigned, onModuleRename, onModuleDelete, onModuleAdd, onBaseAdd, onModuleFileTypeChange, isBaseExist, isReadOnlyMode} = this.props; - const childProps = module => ({ - module, - onModuleRename, - onModuleDelete, - onModuleFileTypeChange: (value, type) => onModuleFileTypeChange({module, value, type}), - files: unassigned - }); - let listItems = this.state.data.map(function (item, i) { - return ( - this.setState(data)} - items={this.state.data} - draggingIndex={this.state.draggingIndex} - sortId={i} - outline='list'> - ); - }, this); - - return ( -
    0) ? 'modules-list-wrapper-divider' : ''}`}> -
    - {!isBaseExist &&
    } -
    -
    - {(listItems.length > 0) &&
      {listItems}
    } -
    - ); - } + state = { + draggingIndex: null, + data: this.props.modules + }; + + componentWillReceiveProps(nextProps) { + this.setState({ data: nextProps.modules }); + } + + render() { + let { + unassigned, + onModuleRename, + onModuleDelete, + onModuleAdd, + onBaseAdd, + onModuleFileTypeChange, + isBaseExist, + isReadOnlyMode + } = this.props; + const childProps = module => ({ + module, + onModuleRename, + onModuleDelete, + onModuleFileTypeChange: (value, type) => + onModuleFileTypeChange({ module, value, type }), + files: unassigned + }); + let listItems = this.state.data.map(function(item, i) { + return ( + this.setState(data)} + items={this.state.data} + draggingIndex={this.state.draggingIndex} + sortId={i} + outline="list"> + + + ); + }, this); + + return ( +
    0 ? 'modules-list-wrapper-divider' : '' + }`}> +
    + {!isBaseExist && ( +
    + +
    + )} +
    + +
    +
    + {listItems.length > 0 &&
      {listItems}
    } +
    + ); + } } -const tooltip = (name) => {name}; -const UnassignedFileList = (props) => { - return ( -
    -
    -
    -
    {i18n('UNASSIGNED FILES')}
    -
    {props.children}
    -
    -
    - ); +const tooltip = name => {name}; +const UnassignedFileList = props => { + return ( +
    +
    +
    +
    + {i18n('UNASSIGNED FILES')} +
    +
    {props.children}
    +
    +
    + ); }; const EmptyListContent = props => { - let {heatDataExist} = props; - let displayText = heatDataExist ? 'All Files Are Assigned' : ''; - return ( -
    -
    {i18n(displayText)}
    -
    - ); + let { heatDataExist } = props; + let displayText = heatDataExist ? 'All Files Are Assigned' : ''; + return ( +
    +
    {i18n(displayText)}
    +
    + ); }; -const UnassignedFile = (props) => ( - -
  • {props.name}
  • -
    +const UnassignedFile = props => ( + +
  • + {props.name} +
  • +
    ); -const AddOrDeleteVolumeFiles = ({add = true, onAdd, onDelete, isReadOnlyMode}) => { - const displayText = add ? 'Add Volume Files' : 'Delete Volume Files'; - const action = add ? onAdd : onDelete; - return ( - - ); +const AddOrDeleteVolumeFiles = ({ + add = true, + onAdd, + onDelete, + isReadOnlyMode +}) => { + const displayText = add ? 'Add Volume Files' : 'Delete Volume Files'; + const action = add ? onAdd : onDelete; + return ( + + ); }; -const SelectWithFileType = ({type, selected, files, onChange}) => { - - let filteredFiledAccordingToType = files.filter(file => file.label.search(type.regex) > -1); - if (selected) { - filteredFiledAccordingToType = filteredFiledAccordingToType.concat({label: selected, value: selected}); - } - - return ( - value !== selected && onChange(value, type.label)} - disabled={filteredFiledAccordingToType.length === 0} - placeholder={filteredFiledAccordingToType.length === 0 ? '' : undefined} - clearable={true} - options={filteredFiledAccordingToType} /> - ); +const SelectWithFileType = ({ type, selected, files, onChange }) => { + let filteredFiledAccordingToType = files.filter( + file => file.label.search(type.regex) > -1 + ); + if (selected) { + filteredFiledAccordingToType = filteredFiledAccordingToType.concat({ + label: selected, + value: selected + }); + } + + return ( + + value !== selected && onChange(value, type.label) + } + disabled={filteredFiledAccordingToType.length === 0} + placeholder={ + filteredFiledAccordingToType.length === 0 ? '' : undefined + } + clearable={true} + options={filteredFiledAccordingToType} + /> + ); }; class NameEditInput extends Component { - componentDidMount() { - this.input.focus(); - } - - render() { - return ( - this.input = input}/> - ); - } + componentDidMount() { + this.input.focus(); + } + + render() { + return ( + (this.input = input)} + /> + ); + } } class ModuleFile extends Component { - constructor(props) { - super(props); - this.state = { - isInNameEdit: false, - displayVolumes: Boolean(props.module.vol || props.module.volEnv) - }; - } - - handleSubmit(event, name) { - if (event.keyCode === 13) { - this.handleModuleRename(event, name); - } - } - - componentWillReceiveProps(nextProps) { - this.setState({displayVolumes: Boolean(nextProps.module.vol || nextProps.module.volEnv)}); - } - - handleModuleRename(event, name) { - this.setState({isInNameEdit: false}); - this.props.onModuleRename(name, event.target.value); - } - - deleteVolumeFiles() { - const { onModuleFileTypeChange} = this.props; - onModuleFileTypeChange(null, fileTypes.VOL.label); - onModuleFileTypeChange(null, fileTypes.VOL_ENV.label); - this.setState({displayVolumes: false}); - } - - renderNameAccordingToEditState() { - const {module: {name}} = this.props; - if (this.state.isInNameEdit) { - return ( this.handleModuleRename(evt, name)} onKeyDown={evt => this.handleSubmit(evt, name)}/>); - } - return ({name}); - } - - render() { - const {module: {name, isBase, yaml, env, vol, volEnv}, onModuleDelete, files, onModuleFileTypeChange, isReadOnlyMode} = this.props; - const {displayVolumes} = this.state; - const moduleType = isBase ? 'BASE' : 'MODULE'; - return ( -
    -
    -
    - - {`${moduleType}: `} -
    - {this.renderNameAccordingToEditState()} - {!this.state.isInNameEdit && this.setState({isInNameEdit: true})} - data-test-id={isBase ? 'base-name' : 'module-name'}/>} -
    -
    - onModuleDelete(name)} data-test-id='module-delete'/> -
    -
    - - - {displayVolumes && } - {displayVolumes && } - this.setState({displayVolumes: true})} onDelete={() => this.deleteVolumeFiles()} add={!displayVolumes}/> -
    -
    - ); - } + constructor(props) { + super(props); + this.state = { + isInNameEdit: false, + displayVolumes: Boolean(props.module.vol || props.module.volEnv) + }; + } + + handleSubmit(event, name) { + if (event.keyCode === 13) { + this.handleModuleRename(event, name); + } + } + + componentWillReceiveProps(nextProps) { + this.setState({ + displayVolumes: Boolean( + nextProps.module.vol || nextProps.module.volEnv + ) + }); + } + + handleModuleRename(event, name) { + this.setState({ isInNameEdit: false }); + this.props.onModuleRename(name, event.target.value); + } + + deleteVolumeFiles() { + const { onModuleFileTypeChange } = this.props; + onModuleFileTypeChange(null, fileTypes.VOL.label); + onModuleFileTypeChange(null, fileTypes.VOL_ENV.label); + this.setState({ displayVolumes: false }); + } + + renderNameAccordingToEditState() { + const { module: { name } } = this.props; + if (this.state.isInNameEdit) { + return ( + this.handleModuleRename(evt, name)} + onKeyDown={evt => this.handleSubmit(evt, name)} + /> + ); + } + return {name}; + } + + render() { + const { + module: { name, isBase, yaml, env, vol, volEnv }, + onModuleDelete, + files, + onModuleFileTypeChange, + isReadOnlyMode + } = this.props; + const { displayVolumes } = this.state; + const moduleType = isBase ? 'BASE' : 'MODULE'; + return ( +
    +
    +
    + + {`${moduleType}: `} +
    + {this.renderNameAccordingToEditState()} + {!this.state.isInNameEdit && ( + + this.setState({ isInNameEdit: true }) + } + data-test-id={ + isBase ? 'base-name' : 'module-name' + } + /> + )} +
    +
    + onModuleDelete(name)} + data-test-id="module-delete" + /> +
    +
    + + + {displayVolumes && ( + + )} + {displayVolumes && ( + + )} + this.setState({ displayVolumes: true })} + onDelete={() => this.deleteVolumeFiles()} + add={!displayVolumes} + /> +
    +
    + ); + } } class ArtifactOrNestedFileList extends Component { - - render() { - let {type, title, selected, options, onSelectChanged, onAddAllUnassigned, isReadOnlyMode, headerClassName} = this.props; - return ( -
    -
    - - {type === 'artifact' && ()} - {`${title}`} - - {type === 'artifact' && } -
    - {type === 'nested' ? ( -
      {selected.map(nested => -
    • {nested}
    • - )}
    ) : - ( { - })} - value={selected} - clearable={false} - placeholder={i18n('Add Artifact')} - multi/>) - } -
    - ); - } + render() { + let { + type, + title, + selected, + options, + onSelectChanged, + onAddAllUnassigned, + isReadOnlyMode, + headerClassName + } = this.props; + return ( +
    +
    + + {type === 'artifact' && ( + + )} + {`${title}`} + + {type === 'artifact' && ( + + )} +
    + {type === 'nested' ? ( +
      + {selected.map(nested => ( +
    • + {nested} +
    • + ))} +
    + ) : ( + {})} + value={selected} + clearable={false} + placeholder={i18n('Add Artifact')} + multi + /> + )} +
    + ); + } } -const buildLabelValueObject = str => (typeof str === 'string' ? {value: str, label: str} : str); +const buildLabelValueObject = str => + typeof str === 'string' ? { value: str, label: str } : str; class SoftwareProductHeatSetupView extends Component { - - processAndValidateHeat(heatData, heatDataCache){ - let {onProcessAndValidate, changeAttachmentsTab, version} = this.props; - onProcessAndValidate({heatData, heatDataCache, version}).then( - () => changeAttachmentsTab(tabsMapping.VALIDATION) - ); - } - - render() { - let {modules, isReadOnlyMode, heatDataExist, unassigned, artifacts, nested, onArtifactListChange, onAddAllUnassigned} = this.props; - - const formattedUnassigned = unassigned.map(buildLabelValueObject); - const formattedArtifacts = artifacts.map(buildLabelValueObject); - return ( -
    -
    - - 0) ? 'with-list-items' : ''} - onAddAllUnassigned={onAddAllUnassigned}/> - -
    - - { - formattedUnassigned.length > 0 ? - (
      {formattedUnassigned.map(file => )}
    ) - : - () - } -
    -
    - ); - } - + processAndValidateHeat(heatData, heatDataCache) { + let { + onProcessAndValidate, + changeAttachmentsTab, + version + } = this.props; + onProcessAndValidate({ heatData, heatDataCache, version }).then(() => + changeAttachmentsTab(tabsMapping.VALIDATION) + ); + } + + render() { + let { + modules, + isReadOnlyMode, + heatDataExist, + unassigned, + artifacts, + nested, + onArtifactListChange, + onAddAllUnassigned + } = this.props; + + const formattedUnassigned = unassigned.map(buildLabelValueObject); + const formattedArtifacts = artifacts.map(buildLabelValueObject); + return ( +
    +
    + + 0 + ? 'with-list-items' + : '' + } + onAddAllUnassigned={onAddAllUnassigned} + /> + +
    + + {formattedUnassigned.length > 0 ? ( +
      + {formattedUnassigned.map(file => ( + + ))} +
    + ) : ( + + )} +
    +
    + ); + } } export default SoftwareProductHeatSetupView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidation.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidation.js index 21f6e6c77f..00130e4bc7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidation.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidation.js @@ -13,39 +13,55 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import HeatValidationView from './HeatValidationView.jsx'; import HeatValidationActionHelper from './HeatValidationActionHelper.js'; -import {errorLevels, nodeFilters} from './HeatValidationConstants.js'; +import { errorLevels, nodeFilters } from './HeatValidationConstants.js'; -export const mapStateToProps = ({softwareProduct: {softwareProductAttachments: {heatValidation}}}) => { - let {attachmentsTree, selectedNode, errorList} = heatValidation; - let currentErrors = [], currentWarnings = []; - if (errorList) { - for (let i = 0 ; i < errorList.length ; i++) { - if (errorList[i].level === errorLevels.ERROR && (errorList[i].name === selectedNode || selectedNode === nodeFilters.ALL)) { - currentErrors[currentErrors.length] = errorList[i]; - } - if (errorList[i].level === errorLevels.WARNING && (errorList[i].name === selectedNode || selectedNode === nodeFilters.ALL)) { - currentWarnings[currentWarnings.length] = errorList[i]; - } - } - } - return { - attachmentsTree, - selectedNode, - errorList, - currentErrors, - currentWarnings - }; +export const mapStateToProps = ({ + softwareProduct: { softwareProductAttachments: { heatValidation } } +}) => { + let { attachmentsTree, selectedNode, errorList } = heatValidation; + let currentErrors = [], + currentWarnings = []; + if (errorList) { + for (let i = 0; i < errorList.length; i++) { + if ( + errorList[i].level === errorLevels.ERROR && + (errorList[i].name === selectedNode || + selectedNode === nodeFilters.ALL) + ) { + currentErrors[currentErrors.length] = errorList[i]; + } + if ( + errorList[i].level === errorLevels.WARNING && + (errorList[i].name === selectedNode || + selectedNode === nodeFilters.ALL) + ) { + currentWarnings[currentWarnings.length] = errorList[i]; + } + } + } + return { + attachmentsTree, + selectedNode, + errorList, + currentErrors, + currentWarnings + }; }; -const mapActionsToProps = (dispatch) => { - return { - toggleExpanded: (path) => HeatValidationActionHelper.toggleExpanded(dispatch, {path}), - onSelectNode: (nodeName) => HeatValidationActionHelper.onSelectNode(dispatch, {nodeName}), - onDeselectNode: () => HeatValidationActionHelper.onDeselectNode(dispatch) - }; +const mapActionsToProps = dispatch => { + return { + toggleExpanded: path => + HeatValidationActionHelper.toggleExpanded(dispatch, { path }), + onSelectNode: nodeName => + HeatValidationActionHelper.onSelectNode(dispatch, { nodeName }), + onDeselectNode: () => + HeatValidationActionHelper.onDeselectNode(dispatch) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(HeatValidationView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(HeatValidationView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js index 73366c20cc..5e8e49cf8a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js @@ -13,27 +13,26 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './HeatValidationConstants.js'; +import { actionTypes } from './HeatValidationConstants.js'; export default { + toggleExpanded(dispatch, { path }) { + dispatch({ + type: actionTypes.TOGGLE_EXPANDED, + path + }); + }, - toggleExpanded(dispatch, {path}) { - dispatch({ - type: actionTypes.TOGGLE_EXPANDED, - path - }); - }, + onSelectNode(dispatch, { nodeName }) { + dispatch({ + type: actionTypes.SELECTED_NODE, + nodeName + }); + }, - onSelectNode(dispatch, {nodeName}) { - dispatch({ - type: actionTypes.SELECTED_NODE, - nodeName - }); - }, - - onDeselectNode(dispatch) { - dispatch({ - type: actionTypes.UNSELECTED_NODE - }); - } + onDeselectNode(dispatch) { + dispatch({ + type: actionTypes.UNSELECTED_NODE + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js index f783fe6482..8c9f54b5ba 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js @@ -17,41 +17,48 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; export const actionTypes = keyMirror({ - TOGGLE_EXPANDED: null, - SELECTED_NODE: null, - UNSELECTED_NODE: null + TOGGLE_EXPANDED: null, + SELECTED_NODE: null, + UNSELECTED_NODE: null }); export const errorTypes = keyMirror({ - MISSING_FILE_IN_ZIP: i18n('missing file in zip'), - MISSING_FILE_IN_MANIFEST: i18n('missing file in manifest'), - MISSING_OR_ILLEGAL_FILE_TYPE_IN_MANIFEST: i18n('missing or illegal file type in manifest'), - FILE_IS_YML_WITHOUT_YML_EXTENSION: i18n('file is defined as a heat file but it doesn\'t have .yml or .yaml extension'), - FILE_IS_ENV_WITHOUT_ENV_EXTENSION: i18n('file is defined as an env file but it doesn\'t have .env extension'), - ILLEGAL_YAML_FILE_CONTENT: i18n('illegal yaml file content'), - ILLEGAL_HEAT_YAML_FILE_CONTENT: i18n('illegal HEAT yaml file content'), - MISSING_FILE_NAME_IN_MANIFEST: i18n('a file is written in manifest without file name'), - MISSING_ENV_FILE_IN_ZIP: i18n('missing env file in zip'), - ARTIFACT_NOT_IN_USE: i18n('artifact not in use') + MISSING_FILE_IN_ZIP: i18n('missing file in zip'), + MISSING_FILE_IN_MANIFEST: i18n('missing file in manifest'), + MISSING_OR_ILLEGAL_FILE_TYPE_IN_MANIFEST: i18n( + 'missing or illegal file type in manifest' + ), + FILE_IS_YML_WITHOUT_YML_EXTENSION: i18n( + "file is defined as a heat file but it doesn't have .yml or .yaml extension" + ), + FILE_IS_ENV_WITHOUT_ENV_EXTENSION: i18n( + "file is defined as an env file but it doesn't have .env extension" + ), + ILLEGAL_YAML_FILE_CONTENT: i18n('illegal yaml file content'), + ILLEGAL_HEAT_YAML_FILE_CONTENT: i18n('illegal HEAT yaml file content'), + MISSING_FILE_NAME_IN_MANIFEST: i18n( + 'a file is written in manifest without file name' + ), + MISSING_ENV_FILE_IN_ZIP: i18n('missing env file in zip'), + ARTIFACT_NOT_IN_USE: i18n('artifact not in use') }); export const errorLevels = keyMirror({ - WARNING: 'WARNING', - ERROR: 'ERROR' + WARNING: 'WARNING', + ERROR: 'ERROR' }); export const nodeFilters = keyMirror({ - ALL: 'All' + ALL: 'All' }); export const nodeTypes = keyMirror({ - heat: i18n('Heat'), - volume: i18n('Volume'), - network: i18n('Network'), - artifact: i18n('Artifact'), - env: i18n('Environment'), - other: i18n('') + heat: i18n('Heat'), + volume: i18n('Volume'), + network: i18n('Network'), + artifact: i18n('Artifact'), + env: i18n('Environment'), + other: i18n('') }); export const mouseActions = keyMirror({ - MOUSE_BUTTON_CLICK: 0 + MOUSE_BUTTON_CLICK: 0 }); - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js index 1d11bdd6b7..67e36ca040 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js @@ -13,185 +13,242 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes as softwareProductsActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; -import {actionTypes, nodeFilters} from './HeatValidationConstants.js'; +import { actionTypes as softwareProductsActionTypes } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { actionTypes, nodeFilters } from './HeatValidationConstants.js'; -const mapVolumeData = ({fileName, env, errors}) => ({ - name: fileName, - expanded: true, - type: 'volume', - children: env && [{ - name: env.fileName, - errors: env.errors, - type: 'env' - }], - errors +const mapVolumeData = ({ fileName, env, errors }) => ({ + name: fileName, + expanded: true, + type: 'volume', + children: env && [ + { + name: env.fileName, + errors: env.errors, + type: 'env' + } + ], + errors }); -const mapNetworkData = ({fileName, env, errors}) => ({ - name: fileName, - expanded: true, - type: 'network', - children: env && [{ - name: env.fileName, - errors: env.errors, - type: 'env' - }], - errors +const mapNetworkData = ({ fileName, env, errors }) => ({ + name: fileName, + expanded: true, + type: 'network', + children: env && [ + { + name: env.fileName, + errors: env.errors, + type: 'env' + } + ], + errors }); -const mapArtifactsData = ({fileName, errors}) => ({ - name: fileName, - type: 'artifact', - errors +const mapArtifactsData = ({ fileName, errors }) => ({ + name: fileName, + type: 'artifact', + errors }); -const mapOtherData = ({fileName, errors}) => ({ - name: fileName, - type: 'other', - errors +const mapOtherData = ({ fileName, errors }) => ({ + name: fileName, + type: 'other', + errors }); - -const mapHeatData = ({fileName, env, nested, volume, network, artifacts, errors, other}) => ({ - name: fileName, - expanded: true, - type: 'heat', - errors, - children: [ - ...(volume ? volume.map(mapVolumeData) : []), - ...(network ? network.map(mapNetworkData) : []), - ...(env ? [{ - name: env.fileName, - errors: env.errors, - type: 'env' - }] : []), - ...(artifacts ? artifacts.map(mapArtifactsData) : []), - ...(other ? other.map(mapOtherData) : []), - ...(nested ? nested.map(mapHeatData) : []) - ] +const mapHeatData = ({ + fileName, + env, + nested, + volume, + network, + artifacts, + errors, + other +}) => ({ + name: fileName, + expanded: true, + type: 'heat', + errors, + children: [ + ...(volume ? volume.map(mapVolumeData) : []), + ...(network ? network.map(mapNetworkData) : []), + ...(env + ? [ + { + name: env.fileName, + errors: env.errors, + type: 'env' + } + ] + : []), + ...(artifacts ? artifacts.map(mapArtifactsData) : []), + ...(other ? other.map(mapOtherData) : []), + ...(nested ? nested.map(mapHeatData) : []) + ] }); function createErrorList(node, parent, deep = 0, errorList = []) { - if (node.errors) { - errorList.push(...node.errors.map((error) => ({ - level: error.level, - errorMessage: error.message, - name: node.name, - hasParent: deep > 2, - parentName: parent.name, - type: node.type, - }))); - } - if (node.children && node.children.length) { - node.children.map((child) => createErrorList(child, node, deep + 1, errorList)); - } - return errorList; + if (node.errors) { + errorList.push( + ...node.errors.map(error => ({ + level: error.level, + errorMessage: error.message, + name: node.name, + hasParent: deep > 2, + parentName: parent.name, + type: node.type + })) + ); + } + if (node.children && node.children.length) { + node.children.map(child => + createErrorList(child, node, deep + 1, errorList) + ); + } + return errorList; } const mapValidationDataToTree = (validationData, packageName) => { - let {heat, nested, volume, network, artifacts, other} = validationData.importStructure || {}; - return { - children: [ - { - name: packageName, - expanded: true, - type: 'heat', - header: true, - children: (heat ? heat.map(mapHeatData) : nested ? nested.map(mapHeatData) : []) - }, - ...(artifacts ? [{ - name: 'artifacts', - expanded: true, - type: 'artifact', - children: (artifacts ? artifacts.map(mapArtifactsData) : []) - }] : []), - ...(network ? [{ - name: 'networks', - expanded: true, - type: 'network', - children: (network ? network.map(mapNetworkData) : []), - }] : []), - ...(volume ? [{ - name: 'volume', - expanded: true, - type: 'volume', - children: (volume ? volume.map(mapVolumeData) : []), - }] : []), - ...(other ? [{ - name: 'other', - expanded: true, - type: 'other', - children: (other ? other.map(mapOtherData) : []), - }] : []) - ] - }; + let { heat, nested, volume, network, artifacts, other } = + validationData.importStructure || {}; + return { + children: [ + { + name: packageName, + expanded: true, + type: 'heat', + header: true, + children: heat + ? heat.map(mapHeatData) + : nested ? nested.map(mapHeatData) : [] + }, + ...(artifacts + ? [ + { + name: 'artifacts', + expanded: true, + type: 'artifact', + children: artifacts + ? artifacts.map(mapArtifactsData) + : [] + } + ] + : []), + ...(network + ? [ + { + name: 'networks', + expanded: true, + type: 'network', + children: network ? network.map(mapNetworkData) : [] + } + ] + : []), + ...(volume + ? [ + { + name: 'volume', + expanded: true, + type: 'volume', + children: volume ? volume.map(mapVolumeData) : [] + } + ] + : []), + ...(other + ? [ + { + name: 'other', + expanded: true, + type: 'other', + children: other ? other.map(mapOtherData) : [] + } + ] + : []) + ] + }; }; const toggleExpanded = (node, path) => { - let newNode = {...node}; - if (path.length === 0) { - newNode.expanded = !node.expanded; - } else { - let index = path[0]; - newNode.children = [ - ...node.children.slice(0, index), - toggleExpanded(node.children[index], path.slice(1)), - ...node.children.slice(index + 1) - ]; - } - return newNode; + let newNode = { ...node }; + if (path.length === 0) { + newNode.expanded = !node.expanded; + } else { + let index = path[0]; + newNode.children = [ + ...node.children.slice(0, index), + toggleExpanded(node.children[index], path.slice(1)), + ...node.children.slice(index + 1) + ]; + } + return newNode; }; const expandSelected = (node, selectedNode) => { - let shouldExpand = node.name === selectedNode; - let children = node.children && node.children.map(child => { - let {shouldExpand: shouldExpandChild, node: newChild} = expandSelected(child, selectedNode); - shouldExpand = shouldExpand || shouldExpandChild; - return newChild; - }); + let shouldExpand = node.name === selectedNode; + let children = + node.children && + node.children.map(child => { + let { + shouldExpand: shouldExpandChild, + node: newChild + } = expandSelected(child, selectedNode); + shouldExpand = shouldExpand || shouldExpandChild; + return newChild; + }); - return { - node: { - ...node, - expanded: node.expanded || shouldExpand, - children - }, - shouldExpand - }; + return { + node: { + ...node, + expanded: node.expanded || shouldExpand, + children + }, + shouldExpand + }; }; -export default (state = {attachmentsTree: {}}, action) => { - switch (action.type) { - case softwareProductsActionTypes.SOFTWARE_PRODUCT_LOADED: - let currentSoftwareProduct = action.response; - const packageName = currentSoftwareProduct.networkPackageName; - let attachmentsTree = currentSoftwareProduct.validationData ? mapValidationDataToTree(currentSoftwareProduct.validationData, packageName) : {}; - let errorList = createErrorList(attachmentsTree); - return { - ...state, - attachmentsTree, - errorList, - selectedNode: nodeFilters.ALL - }; - case actionTypes.TOGGLE_EXPANDED: - return { - ...state, - attachmentsTree: toggleExpanded(state.attachmentsTree, action.path) - }; - case actionTypes.SELECTED_NODE: - let selectedNode = action.nodeName; - return { - ...state, - attachmentsTree: expandSelected(state.attachmentsTree, selectedNode).node, - selectedNode - }; - case actionTypes.UNSELECTED_NODE: - return { - ...state, - selectedNode: nodeFilters.ALL - }; - default: - return state; - } +export default (state = { attachmentsTree: {} }, action) => { + switch (action.type) { + case softwareProductsActionTypes.SOFTWARE_PRODUCT_LOADED: + let currentSoftwareProduct = action.response; + const packageName = currentSoftwareProduct.networkPackageName; + let attachmentsTree = currentSoftwareProduct.validationData + ? mapValidationDataToTree( + currentSoftwareProduct.validationData, + packageName + ) + : {}; + let errorList = createErrorList(attachmentsTree); + return { + ...state, + attachmentsTree, + errorList, + selectedNode: nodeFilters.ALL + }; + case actionTypes.TOGGLE_EXPANDED: + return { + ...state, + attachmentsTree: toggleExpanded( + state.attachmentsTree, + action.path + ) + }; + case actionTypes.SELECTED_NODE: + let selectedNode = action.nodeName; + return { + ...state, + attachmentsTree: expandSelected( + state.attachmentsTree, + selectedNode + ).node, + selectedNode + }; + case actionTypes.UNSELECTED_NODE: + return { + ...state, + selectedNode: nodeFilters.ALL + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx index 3fdaa9c591..c6ee5efd36 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx @@ -13,254 +13,352 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import Collapse from 'react-bootstrap/lib/Collapse.js'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {mouseActions, errorLevels, nodeFilters} from './HeatValidationConstants.js'; +import { + mouseActions, + errorLevels, + nodeFilters +} from './HeatValidationConstants.js'; const leftPanelWidth = 250; const typeToIcon = Object.freeze({ - heat: 'nestedHeat', - volume: 'base', - network: 'network', - artifact: 'artifacts', - env: 'env', - other: 'other' + heat: 'nestedHeat', + volume: 'base', + network: 'network', + artifact: 'artifacts', + env: 'env', + other: 'other' }); - class HeatValidationView extends Component { + static propTypes = { + attachmentsTree: PropTypes.object.isRequired, + errorList: PropTypes.array.isRequired, + currentErrors: PropTypes.array.isRequired, + currentWarnings: PropTypes.array.isRequired, + onSelectNode: PropTypes.func.isRequired, + onDeselectNode: PropTypes.func.isRequired, + toggleExpanded: PropTypes.func.isRequired, + selectedNode: PropTypes.string + }; - static propTypes = { - attachmentsTree: PropTypes.object.isRequired, - errorList: PropTypes.array.isRequired, - currentErrors: PropTypes.array.isRequired, - currentWarnings: PropTypes.array.isRequired, - onSelectNode: PropTypes.func.isRequired, - onDeselectNode: PropTypes.func.isRequired, - toggleExpanded: PropTypes.func.isRequired, - selectedNode: PropTypes.string - }; - - render() { - return (
    - - -
    ); - } + render() { + return ( +
    + + +
    + ); + } } function HeatFileTreeRow(props) { - let {node, path, toggleExpanded, selectedNode, selectNode} = props; - let isFolder = node.children && node.children.length > 0; - return ( -
    toggleExpanded(path)} className={classNames({ - 'tree-node-row': true, - 'tree-node-clicked': node.name === props.selectedNode - })} data-test-id='validation-tree-node'> -
    - { - isFolder && -
    toggleExpanded(path)} - className='tree-node-expander'> - -
    - } - { - - - - - } - { - - selectNode(node.name)} data-test-id='validation-tree-node-name'> - {node.name ? node.name : 'UNKNOWN'} - - } -
    - selectNode(node.name)} /> -
    ); + let { node, path, toggleExpanded, selectedNode, selectNode } = props; + let isFolder = node.children && node.children.length > 0; + return ( +
    toggleExpanded(path)} + className={classNames({ + 'tree-node-row': true, + 'tree-node-clicked': node.name === props.selectedNode + })} + data-test-id="validation-tree-node"> +
    + {isFolder && ( +
    toggleExpanded(path)} + className="tree-node-expander"> + +
    + )} + { + + + + } + { + selectNode(node.name)} + data-test-id="validation-tree-node-name"> + {node.name ? node.name : 'UNKNOWN'} + + } +
    + selectNode(node.name)} + /> +
    + ); } function HeatFileTreeHeader(props) { - let hasErrors = props.errorList.filter(error => error.level === errorLevels.ERROR).length > 0; - return ( -
    props.selectNode(nodeFilters.ALL)} className={classNames({'attachments-tree-header': true, - 'header-selected' : props.selectedNode === nodeFilters.ALL})} data-test-id='validation-tree-header'> -
    - {/**/} - {i18n('{title} {hasErrors}', {title: props.headerTitle, hasErrors: hasErrors ? '(Draft)' : ''})} -
    - -
    ); + let hasErrors = + props.errorList.filter(error => error.level === errorLevels.ERROR) + .length > 0; + return ( +
    props.selectNode(nodeFilters.ALL)} + className={classNames({ + 'attachments-tree-header': true, + 'header-selected': props.selectedNode === nodeFilters.ALL + })} + data-test-id="validation-tree-header"> +
    + {/**/} + + {i18n('{title} {hasErrors}', { + title: props.headerTitle, + hasErrors: hasErrors ? '(Draft)' : '' + })} + +
    + +
    + ); } -class HeatFileTree extends React.Component { - static propTypes = { - attachmentsTree: PropTypes.object.isRequired, - errorList: PropTypes.array.isRequired, - onSelectNode: PropTypes.func.isRequired, - onDeselectNode: PropTypes.func.isRequired, - toggleExpanded: PropTypes.func.isRequired, - selectedNode: PropTypes.string - }; - state = { - treeWidth: '400' - }; - render() { - let {attachmentsTree} = this.props; - return ( -
    -
    -
    - {attachmentsTree && attachmentsTree.children && attachmentsTree.children.map((child, ind) => this.renderNode(child, [ind]))} -
    -
    -
    this.onChangeTreeWidth(e)} - className='vsp-attachments-heat-validation-separator' data-test-id='validation-tree-separator'>
    -
    ); - } - renderNode(node, path) { - let rand = Math.random() * (3000 - 1) + 1; - let isFolder = node.children && node.children.length > 0; - let {selectedNode} = this.props; - return ( -
    - { - node.header ? - this.selectNode(nodeName)} /> : - this.selectNode(node.name)} /> - } - { - isFolder && - -
    - { - node.children.map((child, ind) => this.renderNode(child, [...path, ind])) - } -
    -
    - } -
    - ); - } - - - - - - selectNode(currentSelectedNode) { - let {onDeselectNode, onSelectNode, selectedNode} = this.props; - if (currentSelectedNode !== selectedNode) { - onSelectNode(currentSelectedNode); - } else { - onDeselectNode(); - } - - +class HeatFileTree extends React.Component { + static propTypes = { + attachmentsTree: PropTypes.object.isRequired, + errorList: PropTypes.array.isRequired, + onSelectNode: PropTypes.func.isRequired, + onDeselectNode: PropTypes.func.isRequired, + toggleExpanded: PropTypes.func.isRequired, + selectedNode: PropTypes.string + }; + state = { + treeWidth: '400' + }; + render() { + let { attachmentsTree } = this.props; + return ( +
    +
    +
    + {attachmentsTree && + attachmentsTree.children && + attachmentsTree.children.map((child, ind) => + this.renderNode(child, [ind]) + )} +
    +
    +
    this.onChangeTreeWidth(e)} + className="vsp-attachments-heat-validation-separator" + data-test-id="validation-tree-separator" + /> +
    + ); + } + renderNode(node, path) { + let rand = Math.random() * (3000 - 1) + 1; + let isFolder = node.children && node.children.length > 0; + let { selectedNode } = this.props; + return ( +
    + {node.header ? ( + this.selectNode(nodeName)} + /> + ) : ( + this.selectNode(node.name)} + /> + )} + {isFolder && ( + +
    + {node.children.map((child, ind) => + this.renderNode(child, [...path, ind]) + )} +
    +
    + )} +
    + ); + } - } + selectNode(currentSelectedNode) { + let { onDeselectNode, onSelectNode, selectedNode } = this.props; + if (currentSelectedNode !== selectedNode) { + onSelectNode(currentSelectedNode); + } else { + onDeselectNode(); + } + } - onChangeTreeWidth(e) { - if (e.button === mouseActions.MOUSE_BUTTON_CLICK) { - let onMouseMove = (e) => { - this.setState({treeWidth: e.clientX - leftPanelWidth}); - }; - let onMouseUp = () => { - document.removeEventListener('mousemove', onMouseMove); - document.removeEventListener('mouseup', onMouseUp); - }; - document.addEventListener('mousemove', onMouseMove); - document.addEventListener('mouseup', onMouseUp); - } - } + onChangeTreeWidth(e) { + if (e.button === mouseActions.MOUSE_BUTTON_CLICK) { + let onMouseMove = e => { + this.setState({ treeWidth: e.clientX - leftPanelWidth }); + }; + let onMouseUp = () => { + document.removeEventListener('mousemove', onMouseMove); + document.removeEventListener('mouseup', onMouseUp); + }; + document.addEventListener('mousemove', onMouseMove); + document.addEventListener('mouseup', onMouseUp); + } + } } class HeatMessageBoard extends Component { - static propTypes = { - currentErrors: PropTypes.array, - currentWarnings: PropTypes.array, - selectedNode: PropTypes.string - }; - render() { - let {errors, warnings} = this.props; - let allItems = [...errors, ...warnings]; - return ( -
    - { allItems.map(error => this.renderError(error)) } -
    - ); - } - renderError(error) { - let rand = Math.random() * (3000 - 1) + 1; - return ( -
    - {error.level === errorLevels.WARNING ? - : } - - { - (this.props.selectedNode === nodeFilters.ALL) ? - - - {error.name} - - - {error.errorMessage} - - : - error.errorMessage - } - -
    - ); - } + static propTypes = { + currentErrors: PropTypes.array, + currentWarnings: PropTypes.array, + selectedNode: PropTypes.string + }; + render() { + let { errors, warnings } = this.props; + let allItems = [...errors, ...warnings]; + return ( +
    + {allItems.map(error => this.renderError(error))} +
    + ); + } + renderError(error) { + let rand = Math.random() * (3000 - 1) + 1; + return ( +
    + {error.level === errorLevels.WARNING ? ( + + ) : ( + + )} + + {this.props.selectedNode === nodeFilters.ALL ? ( + + + {error.name} + + {error.errorMessage} + + ) : ( + error.errorMessage + )} + +
    + ); + } } class ErrorsAndWarningsCount extends Component { - static propTypes = { - errorList: PropTypes.array, - size: PropTypes.string - }; - render() { - let errors = this.getErrorsAndWarningsCount(this.props.errorList); - if (!errors) { - return null; - } - let {size} = this.props; - return (
    - {(errors.errorCount > 0) &&
    - -
    {errors.errorCount}
    -
    } - {(errors.warningCount > 0) &&
    - -
    {errors.warningCount}
    -
    } -
    ); - } - getErrorsAndWarningsCount(errorList) { - let errorCount = 0, warningCount = 0; - if (errorList && errorList.length > 0) { - for (let i = 0; i < errorList.length; i++) { - if (errorList[i].level === errorLevels.ERROR) { - errorCount++; - } else if (errorList[i].level === errorLevels.WARNING) { - warningCount++; - } - } - } - if (errorCount === 0 && warningCount === 0) { - return null; - } - return {errorCount, warningCount}; - } + static propTypes = { + errorList: PropTypes.array, + size: PropTypes.string + }; + render() { + let errors = this.getErrorsAndWarningsCount(this.props.errorList); + if (!errors) { + return null; + } + let { size } = this.props; + return ( +
    + {errors.errorCount > 0 && ( +
    + +
    + {errors.errorCount} +
    +
    + )} + {errors.warningCount > 0 && ( +
    + +
    + {errors.warningCount} +
    +
    + )} +
    + ); + } + getErrorsAndWarningsCount(errorList) { + let errorCount = 0, + warningCount = 0; + if (errorList && errorList.length > 0) { + for (let i = 0; i < errorList.length; i++) { + if (errorList[i].level === errorLevels.ERROR) { + errorCount++; + } else if (errorList[i].level === errorLevels.WARNING) { + warningCount++; + } + } + } + if (errorCount === 0 && warningCount === 0) { + return null; + } + return { errorCount, warningCount }; + } } export default HeatValidationView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentEditorReducer.js index b13bde03c8..e59337c122 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentEditorReducer.js @@ -13,79 +13,83 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, forms} from './SoftwareProductComponentsConstants.js'; +import { actionTypes, forms } from './SoftwareProductComponentsConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.COMPONENT_CREATE_OPEN: - return { - ...state, - formName: forms.CREATE_FORM, - formReady: null, - genericFieldInfo: { - 'displayName' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'validateName', data: true}, {type: 'maxLength', data: 25}] - }, - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}] - } - } - }; - case actionTypes.COMPONENT_LOAD: - return { - ...state, - data: action.component, - formReady: null, - formName: forms.ALL_SPC_FORMS, - genericFieldInfo: { - 'displayName' : { - isValid: true, - errorText: '', - validations: [] - }, - 'vfcCode' : { - isValid: true, - errorText: '', - validations: [] - }, - 'nfcFunction' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 30}] - }, - 'description' : { - isValid: true, - errorText: '', - validations: [] - } - } - }; - case actionTypes.COMPONENT_UPDATE: - return { - ...state, - data: action.component - }; - case actionTypes.COMPONENT_QUESTIONNAIRE_UPDATE: - return { - ...state, - qdata: action.payload.qdata || state.qdata, - qschema: action.payload.qschema || state.qschema - }; - case actionTypes.COMPONENT_DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData - } - }; - case actionTypes.COMPONENT_DATA_CLEAR: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.COMPONENT_CREATE_OPEN: + return { + ...state, + formName: forms.CREATE_FORM, + formReady: null, + genericFieldInfo: { + displayName: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'validateName', data: true }, + { type: 'maxLength', data: 25 } + ] + }, + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }] + } + } + }; + case actionTypes.COMPONENT_LOAD: + return { + ...state, + data: action.component, + formReady: null, + formName: forms.ALL_SPC_FORMS, + genericFieldInfo: { + displayName: { + isValid: true, + errorText: '', + validations: [] + }, + vfcCode: { + isValid: true, + errorText: '', + validations: [] + }, + nfcFunction: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 30 }] + }, + description: { + isValid: true, + errorText: '', + validations: [] + } + } + }; + case actionTypes.COMPONENT_UPDATE: + return { + ...state, + data: action.component + }; + case actionTypes.COMPONENT_QUESTIONNAIRE_UPDATE: + return { + ...state, + qdata: action.payload.qdata || state.qdata, + qschema: action.payload.qschema || state.qschema + }; + case actionTypes.COMPONENT_DATA_CHANGED: + return { + ...state, + data: { + ...state.data, + ...action.deltaData + } + }; + case actionTypes.COMPONENT_DATA_CLEAR: + return {}; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponents.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponents.js index f74b2fe2fb..bffa9f7d25 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponents.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponents.js @@ -1,50 +1,71 @@ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SoftwareProductComponentsActionHelper from '../components/SoftwareProductComponentsActionHelper.js'; -import {onboardingMethod as onboardingMethodTypes} from '../SoftwareProductConstants.js'; +import { onboardingMethod as onboardingMethodTypes } from '../SoftwareProductConstants.js'; import ConfirmationModalConstants from 'nfvo-components/modal/GlobalModalConstants.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import { screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import SoftwareProductComponentsView from './SoftwareProductComponentsListView.jsx'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; -const generateMessage = (name) => { - return i18n('Are you sure you want to delete {name}?', {name: name}); +const generateMessage = name => { + return i18n('Are you sure you want to delete {name}?', { name: name }); }; -const mapStateToProps = ({softwareProduct, currentScreen: {props: {version}}}) => { - let {softwareProductEditor: {data: currentSoftwareProduct = {}}, softwareProductComponents} = softwareProduct; - let {componentsList} = softwareProductComponents; - let {onboardingMethod = onboardingMethodTypes.HEAT} = currentSoftwareProduct; - return { - currentSoftwareProduct, - componentsList, - isManual: onboardingMethod === onboardingMethodTypes.MANUAL, - version - }; +const mapStateToProps = ({ + softwareProduct, + currentScreen: { props: { version } } +}) => { + let { + softwareProductEditor: { data: currentSoftwareProduct = {} }, + softwareProductComponents + } = softwareProduct; + let { componentsList } = softwareProductComponents; + let { + onboardingMethod = onboardingMethodTypes.HEAT + } = currentSoftwareProduct; + return { + currentSoftwareProduct, + componentsList, + isManual: onboardingMethod === onboardingMethodTypes.MANUAL, + version + }; }; -const mapActionToProps = (dispatch) => { - return { - onComponentSelect: ({id: softwareProductId, componentId, version}) => - ScreensHelper.loadScreen(dispatch, { - screen: screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version, componentId} - }), - onAddComponent: (softwareProductId, version) => SoftwareProductActionHelper.addComponent(dispatch, {softwareProductId, version, modalClassName: 'create-vfc-modal'}), - onDeleteComponent: (component, softwareProductId, version) => dispatch({ - type: ConfirmationModalConstants.GLOBAL_MODAL_WARNING, - data:{ - msg: generateMessage(component.displayName), - onConfirmed: ()=>SoftwareProductComponentsActionHelper.deleteComponent(dispatch, { - softwareProductId, - componentId: component.id, - version - }) - } - }) - }; +const mapActionToProps = dispatch => { + return { + onComponentSelect: ({ id: softwareProductId, componentId, version }) => + ScreensHelper.loadScreen(dispatch, { + screen: screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId, version, componentId } + }), + onAddComponent: (softwareProductId, version) => + SoftwareProductActionHelper.addComponent(dispatch, { + softwareProductId, + version, + modalClassName: 'create-vfc-modal' + }), + onDeleteComponent: (component, softwareProductId, version) => + dispatch({ + type: ConfirmationModalConstants.GLOBAL_MODAL_WARNING, + data: { + msg: generateMessage(component.displayName), + onConfirmed: () => + SoftwareProductComponentsActionHelper.deleteComponent( + dispatch, + { + softwareProductId, + componentId: component.id, + version + } + ) + } + }) + }; }; -export default connect(mapStateToProps, mapActionToProps, null, {withRef: true})(SoftwareProductComponentsView); +export default connect(mapStateToProps, mapActionToProps, null, { + withRef: true +})(SoftwareProductComponentsView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js index cf63ad79d0..73a971ccbb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js @@ -16,157 +16,265 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes, COMPONENTS_QUESTIONNAIRE} from './SoftwareProductComponentsConstants.js'; +import { + actionTypes, + COMPONENTS_QUESTIONNAIRE +} from './SoftwareProductComponentsConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; function baseUrl(softwareProductId, version) { - const versionId = version.id; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components`; + const versionId = version.id; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components`; } function fetchSoftwareProductComponents(softwareProductId, version) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); } -function putSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId, vspComponent) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${vspComponentId}/questionnaire`, vspComponent); +function putSoftwareProductComponentQuestionnaire( + softwareProductId, + version, + vspComponentId, + vspComponent +) { + return RestAPIUtil.put( + `${baseUrl( + softwareProductId, + version + )}/${vspComponentId}/questionnaire`, + vspComponent + ); } -function fetchSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId){ - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}/${vspComponentId}/questionnaire`); +function fetchSoftwareProductComponentQuestionnaire( + softwareProductId, + version, + vspComponentId +) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, version)}/${vspComponentId}/questionnaire` + ); } -function fetchSoftwareProductComponent(softwareProductId, version, vspComponentId){ - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}/${vspComponentId}`); +function fetchSoftwareProductComponent( + softwareProductId, + version, + vspComponentId +) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, version)}/${vspComponentId}` + ); } -function putSoftwareProductComponent(softwareProductId, version, vspComponentId, vspComponent) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${vspComponentId}`, { - name: vspComponent.name, - displayName: vspComponent.displayName, - vfcCode: vspComponent.vfcCode, - nfcFunction: vspComponent.nfcFunction, - description: vspComponent.description - }); +function putSoftwareProductComponent( + softwareProductId, + version, + vspComponentId, + vspComponent +) { + return RestAPIUtil.put( + `${baseUrl(softwareProductId, version)}/${vspComponentId}`, + { + name: vspComponent.name, + displayName: vspComponent.displayName, + vfcCode: vspComponent.vfcCode, + nfcFunction: vspComponent.nfcFunction, + description: vspComponent.description + } + ); } -function deleteSoftwareProductComponent(softwareProductId, componentId, version) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version)}/${componentId}`,); +function deleteSoftwareProductComponent( + softwareProductId, + componentId, + version +) { + return RestAPIUtil.destroy( + `${baseUrl(softwareProductId, version)}/${componentId}` + ); } +function postSoftwareProductComponent( + softwareProductId, + vspComponent, + version +) { + return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, { + name: vspComponent.displayName, + displayName: vspComponent.displayName, + description: vspComponent.description + }); +} -function postSoftwareProductComponent(softwareProductId, vspComponent, version) { +const SoftwareProductComponentsActionHelper = { + fetchSoftwareProductComponents(dispatch, { softwareProductId, version }) { + return fetchSoftwareProductComponents(softwareProductId, version).then( + response => { + dispatch({ + type: actionTypes.COMPONENTS_LIST_UPDATE, + componentsList: response.results + }); + return response; + } + ); + }, - return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, { - name: vspComponent.displayName, - displayName: vspComponent.displayName, - description: vspComponent.description - }); -} + updateSoftwareProductComponent( + dispatch, + { softwareProductId, version, vspComponentId, componentData, qdata } + ) { + return Promise.all([ + SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire( + dispatch, + { softwareProductId, version, vspComponentId, qdata } + ), + SoftwareProductComponentsActionHelper.updateSoftwareProductComponentData( + dispatch, + { softwareProductId, version, vspComponentId, componentData } + ) + ]); + }, + updateSoftwareProductComponentQuestionnaire( + dispatch, + { softwareProductId, version, vspComponentId, qdata } + ) { + return putSoftwareProductComponentQuestionnaire( + softwareProductId, + version, + vspComponentId, + qdata + ); + }, -const SoftwareProductComponentsActionHelper = { - fetchSoftwareProductComponents(dispatch, {softwareProductId, version}) { - return fetchSoftwareProductComponents(softwareProductId, version).then(response => { - dispatch({ - type: actionTypes.COMPONENTS_LIST_UPDATE, - componentsList: response.results - }); - return response; - }); - }, - - updateSoftwareProductComponent(dispatch, {softwareProductId, version, vspComponentId, componentData, qdata}) { - return Promise.all([ - SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId, qdata}), - SoftwareProductComponentsActionHelper.updateSoftwareProductComponentData(dispatch, {softwareProductId, version, vspComponentId, componentData}) - ]); - }, - - updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId, qdata}) { - return putSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId, qdata); - }, - - updateSoftwareProductComponentData(dispatch, {softwareProductId, version, vspComponentId, componentData}) { - return putSoftwareProductComponent(softwareProductId, version, vspComponentId, componentData).then(() => dispatch({ - type: actionTypes.COMPONENTS_LIST_EDIT, - component: { - id: vspComponentId, - ...componentData - } - })); - }, - - fetchSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId}) { - return fetchSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId).then(response => { - ValidationHelper.qDataLoaded(dispatch, {qName: COMPONENTS_QUESTIONNAIRE, response: {qdata: response.data ? JSON.parse(response.data) : {}, - qschema: JSON.parse(response.schema)}}); - }); - }, - - fetchSoftwareProductComponent(dispatch, {softwareProductId, version, vspComponentId}) { - return Promise.all([ - fetchSoftwareProductComponent(softwareProductId, version, vspComponentId).then(response => { - dispatch({ - type: actionTypes.COMPONENT_LOAD, - component: response.data - }); - return response; - }), - fetchSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId).then(response => { - ValidationHelper.qDataLoaded(dispatch, {qName: COMPONENTS_QUESTIONNAIRE, response: {qdata: response.data ? JSON.parse(response.data) : {}, - qschema: JSON.parse(response.schema)}}); - }) - ]); - }, - - - clearComponentsStore(dispatch) { - dispatch({ - type: actionTypes.COMPONENTS_LIST_UPDATE, - componentsList: [] - }); - }, - - createSoftwareProductComponent(dispatch,{softwareProductId, componentData, version}) { - SoftwareProductComponentsActionHelper.closeComponentCreationModal(dispatch); - /* for mock only */ - - dispatch({ - type: actionTypes.COMPONENTS_LIST_UPDATE, - componentsList: [{id: '123', ...componentData}] - }); - - postSoftwareProductComponent(softwareProductId, componentData, version).then(() => { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); - }); - }, - - clearComponentCreationData(dispatch) { - dispatch({ - type: actionTypes.COMPONENT_DATA_CLEAR - }); - }, - - closeComponentCreationModal(dispatch) { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - SoftwareProductComponentsActionHelper.clearComponentCreationData(dispatch); - }, - - deleteComponent(dispatch, {softwareProductId, componentId, version}) { - deleteSoftwareProductComponent(softwareProductId, componentId, version); - dispatch({ - type: actionTypes.COMPONENT_DELETE, - componentId: componentId - }); - }, + updateSoftwareProductComponentData( + dispatch, + { softwareProductId, version, vspComponentId, componentData } + ) { + return putSoftwareProductComponent( + softwareProductId, + version, + vspComponentId, + componentData + ).then(() => + dispatch({ + type: actionTypes.COMPONENTS_LIST_EDIT, + component: { + id: vspComponentId, + ...componentData + } + }) + ); + }, + + fetchSoftwareProductComponentQuestionnaire( + dispatch, + { softwareProductId, version, vspComponentId } + ) { + return fetchSoftwareProductComponentQuestionnaire( + softwareProductId, + version, + vspComponentId + ).then(response => { + ValidationHelper.qDataLoaded(dispatch, { + qName: COMPONENTS_QUESTIONNAIRE, + response: { + qdata: response.data ? JSON.parse(response.data) : {}, + qschema: JSON.parse(response.schema) + } + }); + }); + }, + + fetchSoftwareProductComponent( + dispatch, + { softwareProductId, version, vspComponentId } + ) { + return Promise.all([ + fetchSoftwareProductComponent( + softwareProductId, + version, + vspComponentId + ).then(response => { + dispatch({ + type: actionTypes.COMPONENT_LOAD, + component: response.data + }); + return response; + }), + fetchSoftwareProductComponentQuestionnaire( + softwareProductId, + version, + vspComponentId + ).then(response => { + ValidationHelper.qDataLoaded(dispatch, { + qName: COMPONENTS_QUESTIONNAIRE, + response: { + qdata: response.data ? JSON.parse(response.data) : {}, + qschema: JSON.parse(response.schema) + } + }); + }) + ]); + }, + + clearComponentsStore(dispatch) { + dispatch({ + type: actionTypes.COMPONENTS_LIST_UPDATE, + componentsList: [] + }); + }, + + createSoftwareProductComponent( + dispatch, + { softwareProductId, componentData, version } + ) { + SoftwareProductComponentsActionHelper.closeComponentCreationModal( + dispatch + ); + /* for mock only */ + + dispatch({ + type: actionTypes.COMPONENTS_LIST_UPDATE, + componentsList: [{ id: '123', ...componentData }] + }); + + postSoftwareProductComponent( + softwareProductId, + componentData, + version + ).then(() => { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents( + dispatch, + { softwareProductId, version } + ); + }); + }, + clearComponentCreationData(dispatch) { + dispatch({ + type: actionTypes.COMPONENT_DATA_CLEAR + }); + }, + closeComponentCreationModal(dispatch) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + SoftwareProductComponentsActionHelper.clearComponentCreationData( + dispatch + ); + }, + deleteComponent(dispatch, { softwareProductId, componentId, version }) { + deleteSoftwareProductComponent(softwareProductId, componentId, version); + dispatch({ + type: actionTypes.COMPONENT_DELETE, + componentId: componentId + }); + } }; export default SoftwareProductComponentsActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js index 35633b65cf..cc120d359a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js @@ -16,40 +16,40 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - COMPONENTS_LIST_UPDATE: null, - COMPONENTS_LIST_EDIT: null, - COMPONENT_UPDATE: null, - COMPONENT_DATA_CHANGED: null, - COMPONENT_DATA_CLEAR: null, - COMPONENT_QUESTIONNAIRE_UPDATE: null, - COMPONENT_DELETE: null, - COMPONENT_LOAD: null, - COMPONENT_CREATE_OPEN: null + COMPONENTS_LIST_UPDATE: null, + COMPONENTS_LIST_EDIT: null, + COMPONENT_UPDATE: null, + COMPONENT_DATA_CHANGED: null, + COMPONENT_DATA_CLEAR: null, + COMPONENT_QUESTIONNAIRE_UPDATE: null, + COMPONENT_DELETE: null, + COMPONENT_LOAD: null, + COMPONENT_CREATE_OPEN: null }); -export const storageConstants = keyMirror({ - backupType: { - ON_SITE: 'OnSite', - OFF_SITE: 'OffSite' - } +export const storageConstants = keyMirror({ + backupType: { + ON_SITE: 'OnSite', + OFF_SITE: 'OffSite' + } }); export const forms = keyMirror({ - ALL_SPC_FORMS: null, - NIC_EDIT_FORM: null, - CREATE_FORM: null, - IMAGE_EDIT_FORM: null + ALL_SPC_FORMS: null, + NIC_EDIT_FORM: null, + CREATE_FORM: null, + IMAGE_EDIT_FORM: null }); export const COMPONENTS_QUESTIONNAIRE = 'component'; export const COMPONENTS_COMPUTE_QUESTIONNAIRE = 'compute'; export const navigationItems = keyMirror({ - STORAGE: 'Storage', - PROCESS_DETAILS: 'Process Details', - MONITORING: 'Monitoring', - NETWORK: 'Network', - IMAGES: 'Images', - COMPUTE: 'Compute', - LOAD_BALANCING: 'High Availability & Load Balancing' + STORAGE: 'Storage', + PROCESS_DETAILS: 'Process Details', + MONITORING: 'Monitoring', + NETWORK: 'Network', + IMAGES: 'Images', + COMPUTE: 'Compute', + LOAD_BALANCING: 'High Availability & Load Balancing' }); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListReducer.js index 92211e0fd2..e1cf5f4fc3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListReducer.js @@ -13,18 +13,26 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductComponentsConstants.js'; +import { actionTypes } from './SoftwareProductComponentsConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.COMPONENTS_LIST_UPDATE: - return [...action.componentsList]; - case actionTypes.COMPONENTS_LIST_EDIT: - const indexForEdit = state.findIndex(component => component.id === action.component.id); - return [...state.slice(0, indexForEdit), action.component, ...state.slice(indexForEdit + 1)]; - case actionTypes.COMPONENT_DELETE: - return state.filter(component => component.id !== action.componentId); - default: - return state; - } + switch (action.type) { + case actionTypes.COMPONENTS_LIST_UPDATE: + return [...action.componentsList]; + case actionTypes.COMPONENTS_LIST_EDIT: + const indexForEdit = state.findIndex( + component => component.id === action.component.id + ); + return [ + ...state.slice(0, indexForEdit), + action.component, + ...state.slice(indexForEdit + 1) + ]; + case actionTypes.COMPONENT_DELETE: + return state.filter( + component => component.id !== action.componentId + ); + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListView.jsx index 0bf32df1a3..fc8abf6ff6 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListView.jsx @@ -22,85 +22,113 @@ import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.js import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; const ComponentPropType = PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - displayName: PropTypes.string, - description: PropTypes.string + id: PropTypes.string, + name: PropTypes.string, + displayName: PropTypes.string, + description: PropTypes.string }); class SoftwareProductComponentsListView extends React.Component { + state = { + localFilter: '' + }; - state = { - localFilter: '' - }; + static propTypes = { + isReadOnlyMode: PropTypes.bool, + componentsList: PropTypes.arrayOf(ComponentPropType), + onComponentSelect: PropTypes.func + }; - static propTypes = { - isReadOnlyMode: PropTypes.bool, - componentsList: PropTypes.arrayOf(ComponentPropType), - onComponentSelect: PropTypes.func - }; + render() { + let { componentsList = [], isManual } = this.props; + return ( +
    + {(componentsList.length > 0 || isManual) && + this.renderComponents()} +
    + ); + } - render() { - let {componentsList = [], isManual} = this.props; - return ( -
    - { - (componentsList.length > 0 || isManual) && this.renderComponents() - } -
    - ); - } + renderComponents() { + const { localFilter } = this.state; + const { + isManual, + onAddComponent, + isReadOnlyMode, + version, + currentSoftwareProduct: { id: softwareProductId }, + componentsList + } = this.props; + return ( + this.setState({ localFilter: value })} + isReadOnlyMode={isReadOnlyMode || !!this.filterList().length} + plusButtonTitle={i18n('Add Component')} + onAdd={ + isManual && componentsList.length === 0 + ? () => onAddComponent(softwareProductId, version) + : false + } + twoColumns> + {this.filterList().map(component => + this.renderComponentsListItem(component) + )} + + ); + } - renderComponents() { - const {localFilter} = this.state; - const {isManual, onAddComponent, isReadOnlyMode, version, currentSoftwareProduct: {id: softwareProductId}, componentsList } = this.props; - return ( - this.setState({localFilter: value})} - isReadOnlyMode={isReadOnlyMode || !!this.filterList().length} - plusButtonTitle={i18n('Add Component')} - onAdd={isManual && componentsList.length === 0 ? () => onAddComponent(softwareProductId, version) : false} - twoColumns> - {this.filterList().map(component => this.renderComponentsListItem(component))} - - ); - } + renderComponentsListItem(component) { + let { + id: componentId, + name, + displayName, + description = '' + } = component; + let { + currentSoftwareProduct: { id }, + onComponentSelect, + version + } = this.props; + return ( + + onComponentSelect({ id, componentId, version }) + }> + +
    {displayName}
    +
    + +
    {description}
    +
    +
    + ); + } - renderComponentsListItem(component) { - let {id: componentId, name, displayName, description = ''} = component; - let {currentSoftwareProduct: {id}, onComponentSelect, version} = this.props; - return ( - onComponentSelect({id, componentId, version})}> - -
    {displayName}
    -
    - -
    {description}
    -
    -
    - ); - } + filterList() { + let { componentsList = [] } = this.props; - filterList() { - let {componentsList = []} = this.props; - - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return componentsList.filter(({displayName = '', description = ''}) => { - return escape(displayName).match(filter) || escape(description).match(filter); - }); - } - else { - return componentsList; - } - } + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return componentsList.filter( + ({ displayName = '', description = '' }) => { + return ( + escape(displayName).match(filter) || + escape(description).match(filter) + ); + } + ); + } else { + return componentsList; + } + } } export default SoftwareProductComponentsListView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/ComputeFlavorActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/ComputeFlavorActionHelper.js index 02c09fbdf8..cd37c317af 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/ComputeFlavorActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/ComputeFlavorActionHelper.js @@ -16,154 +16,270 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes} from './computeComponents/computeFlavor/ComputeFlavorConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes as globalModalActionTypes, modalSizes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes } from './computeComponents/computeFlavor/ComputeFlavorConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { + actionTypes as globalModalActionTypes, + modalSizes +} from 'nfvo-components/modal/GlobalModalConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {COMPONENTS_COMPUTE_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { COMPONENTS_COMPUTE_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; function baseUrl(softwareProductId, componentId, version) { - const versionId = version.id; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/compute-flavors`; + const versionId = version.id; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/compute-flavors`; } -function baseUrlVSPLevel(softwareProductId, version){ - const versionId = version.id; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/compute-flavors`; +function baseUrlVSPLevel(softwareProductId, version) { + const versionId = version.id; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/compute-flavors`; } -function fetchComputesList(softwareProductId, componentId, version){ - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, componentId, version)}`); +function fetchComputesList(softwareProductId, componentId, version) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, componentId, version)}` + ); } -function fetchComputesListForVSP(softwareProductId, version){ - return RestAPIUtil.fetch(`${baseUrlVSPLevel(softwareProductId, version)}`); +function fetchComputesListForVSP(softwareProductId, version) { + return RestAPIUtil.fetch(`${baseUrlVSPLevel(softwareProductId, version)}`); } function fetchCompute(softwareProductId, componentId, computeId, version) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, componentId, version)}/${computeId}`); + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, componentId, version)}/${computeId}` + ); } -function fetchComputeQuestionnaire({softwareProductId, componentId, computeId, version}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, componentId, version)}/${computeId}/questionnaire`); +function fetchComputeQuestionnaire({ + softwareProductId, + componentId, + computeId, + version +}) { + return RestAPIUtil.fetch( + `${baseUrl( + softwareProductId, + componentId, + version + )}/${computeId}/questionnaire` + ); } -function postCompute({softwareProductId, componentId, compute, version}) { - return RestAPIUtil.post(baseUrl(softwareProductId, componentId, version), compute); +function postCompute({ softwareProductId, componentId, compute, version }) { + return RestAPIUtil.post( + baseUrl(softwareProductId, componentId, version), + compute + ); } -function putCompute({softwareProductId, componentId, compute, version}) { - const computeData = { - name: compute.name, - description: compute.description - }; - return RestAPIUtil.put(`${baseUrl(softwareProductId, componentId, version)}/${compute.id}`, computeData); +function putCompute({ softwareProductId, componentId, compute, version }) { + const computeData = { + name: compute.name, + description: compute.description + }; + return RestAPIUtil.put( + `${baseUrl(softwareProductId, componentId, version)}/${compute.id}`, + computeData + ); } -function putComputeQuestionnaire({softwareProductId, componentId, computeId, qdata, version}) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, componentId, version)}/${computeId}/questionnaire`, qdata); +function putComputeQuestionnaire({ + softwareProductId, + componentId, + computeId, + qdata, + version +}) { + return RestAPIUtil.put( + `${baseUrl( + softwareProductId, + componentId, + version + )}/${computeId}/questionnaire`, + qdata + ); } -function deleteCompute({softwareProductId, componentId, computeId, version}) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, componentId, version)}/${computeId}`); +function deleteCompute({ softwareProductId, componentId, computeId, version }) { + return RestAPIUtil.destroy( + `${baseUrl(softwareProductId, componentId, version)}/${computeId}` + ); } - const ComputeFlavorActionHelper = { - openComputeEditor(dispatch, {props}) { - dispatch({ - type: actionTypes.computeEditor.LOAD_EDITOR_DATA, - compute: props.compute || {} - }); - dispatch({ - type: globalModalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.COMPONENT_COMPUTE_FLAVOR_EDITOR, - modalClassName: `compute-flavor-editor-modal-${props.compute ? 'edit' : 'create'}`, - modalComponentProps: {...props, size: props.compute ? modalSizes.LARGE : undefined, dialogClassName:'compute-flavor-editor-modal'}, - title: `${props.compute ? i18n('Edit Compute Flavor') : i18n('Create New Compute Flavor')}` - } - }); - }, - - closeComputeEditor(dispatch){ - dispatch({ - type: globalModalActionTypes.GLOBAL_MODAL_CLOSE - }); - dispatch({ - type: actionTypes.computeEditor.CLEAR_DATA - }); - }, - - fetchComputesList(dispatch, {softwareProductId, componentId, version}) { - return fetchComputesList(softwareProductId, componentId, version).then(response => dispatch({ - type: actionTypes.COMPUTE_FLAVORS_LIST_LOADED, - response - })); - }, - - fetchComputesListForVSP(dispatch, {softwareProductId, version}) { - return fetchComputesListForVSP(softwareProductId, version).then(response => dispatch({ - type: actionTypes.COMPUTE_FLAVORS_LIST_LOADED, - response - })); - }, - - loadComputeData({softwareProductId, componentId, computeId, version}) { - return fetchCompute(softwareProductId, componentId, computeId, version); - }, - - loadComputeQuestionnaire(dispatch, {softwareProductId, componentId, computeId, version}) { - return fetchComputeQuestionnaire({softwareProductId, componentId, computeId, version}).then(response => - ValidationHelper.qDataLoaded(dispatch, {qName: COMPONENTS_COMPUTE_QUESTIONNAIRE ,response: { - qdata: response.data ? JSON.parse(response.data) : {}, - qschema: JSON.parse(response.schema) - }}) - ); - }, - - loadCompute(dispatch, {softwareProductId, componentId, version, computeId, isReadOnlyMode}){ - return ComputeFlavorActionHelper.loadComputeData({softwareProductId, componentId, computeId, version}).then(({data}) => - ComputeFlavorActionHelper.loadComputeQuestionnaire(dispatch, {softwareProductId, componentId, computeId, version}).then(() => - ComputeFlavorActionHelper.openComputeEditor(dispatch, {props: {softwareProductId, componentId, version, isReadOnlyMode, compute: {id: computeId, ...data}}}) - )); - }, - - saveComputeDataAndQuestionnaire(dispatch, {softwareProductId, componentId, data: compute, qdata, version}) { - ComputeFlavorActionHelper.closeComputeEditor(dispatch); - if(compute.id) { - return Promise.all([ - putComputeQuestionnaire({softwareProductId, componentId, computeId: compute.id, qdata, version}), - putCompute({softwareProductId, componentId, compute, version}).then(() => { - dispatch({ - type: actionTypes.COMPUTE_LIST_EDIT, - compute - }); - }) - ]); - } - else { - return postCompute({softwareProductId, componentId, compute, version}).then(response => - dispatch({ - type: actionTypes.ADD_COMPUTE, - compute: { - ...compute, - id: response.id, - componentId - } - }) - ); - } - }, - - deleteCompute(dispatch, {softwareProductId, componentId, computeId, version}) { - return deleteCompute({softwareProductId, componentId, computeId, version}).then(() => dispatch({ - type: actionTypes.DELETE_COMPUTE, - computeId - })); - } + openComputeEditor(dispatch, { props }) { + dispatch({ + type: actionTypes.computeEditor.LOAD_EDITOR_DATA, + compute: props.compute || {} + }); + dispatch({ + type: globalModalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: + modalContentMapper.COMPONENT_COMPUTE_FLAVOR_EDITOR, + modalClassName: `compute-flavor-editor-modal-${ + props.compute ? 'edit' : 'create' + }`, + modalComponentProps: { + ...props, + size: props.compute ? modalSizes.LARGE : undefined, + dialogClassName: 'compute-flavor-editor-modal' + }, + title: `${ + props.compute + ? i18n('Edit Compute Flavor') + : i18n('Create New Compute Flavor') + }` + } + }); + }, + + closeComputeEditor(dispatch) { + dispatch({ + type: globalModalActionTypes.GLOBAL_MODAL_CLOSE + }); + dispatch({ + type: actionTypes.computeEditor.CLEAR_DATA + }); + }, + + fetchComputesList(dispatch, { softwareProductId, componentId, version }) { + return fetchComputesList(softwareProductId, componentId, version).then( + response => + dispatch({ + type: actionTypes.COMPUTE_FLAVORS_LIST_LOADED, + response + }) + ); + }, + + fetchComputesListForVSP(dispatch, { softwareProductId, version }) { + return fetchComputesListForVSP(softwareProductId, version).then( + response => + dispatch({ + type: actionTypes.COMPUTE_FLAVORS_LIST_LOADED, + response + }) + ); + }, + + loadComputeData({ softwareProductId, componentId, computeId, version }) { + return fetchCompute(softwareProductId, componentId, computeId, version); + }, + + loadComputeQuestionnaire( + dispatch, + { softwareProductId, componentId, computeId, version } + ) { + return fetchComputeQuestionnaire({ + softwareProductId, + componentId, + computeId, + version + }).then(response => + ValidationHelper.qDataLoaded(dispatch, { + qName: COMPONENTS_COMPUTE_QUESTIONNAIRE, + response: { + qdata: response.data ? JSON.parse(response.data) : {}, + qschema: JSON.parse(response.schema) + } + }) + ); + }, + + loadCompute( + dispatch, + { softwareProductId, componentId, version, computeId, isReadOnlyMode } + ) { + return ComputeFlavorActionHelper.loadComputeData({ + softwareProductId, + componentId, + computeId, + version + }).then(({ data }) => + ComputeFlavorActionHelper.loadComputeQuestionnaire(dispatch, { + softwareProductId, + componentId, + computeId, + version + }).then(() => + ComputeFlavorActionHelper.openComputeEditor(dispatch, { + props: { + softwareProductId, + componentId, + version, + isReadOnlyMode, + compute: { id: computeId, ...data } + } + }) + ) + ); + }, + + saveComputeDataAndQuestionnaire( + dispatch, + { softwareProductId, componentId, data: compute, qdata, version } + ) { + ComputeFlavorActionHelper.closeComputeEditor(dispatch); + if (compute.id) { + return Promise.all([ + putComputeQuestionnaire({ + softwareProductId, + componentId, + computeId: compute.id, + qdata, + version + }), + putCompute({ + softwareProductId, + componentId, + compute, + version + }).then(() => { + dispatch({ + type: actionTypes.COMPUTE_LIST_EDIT, + compute + }); + }) + ]); + } else { + return postCompute({ + softwareProductId, + componentId, + compute, + version + }).then(response => + dispatch({ + type: actionTypes.ADD_COMPUTE, + compute: { + ...compute, + id: response.id, + componentId + } + }) + ); + } + }, + + deleteCompute( + dispatch, + { softwareProductId, componentId, computeId, version } + ) { + return deleteCompute({ + softwareProductId, + componentId, + computeId, + version + }).then(() => + dispatch({ + type: actionTypes.DELETE_COMPUTE, + computeId + }) + ); + } }; export default ComputeFlavorActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/SoftwareProductComponentCompute.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/SoftwareProductComponentCompute.js index 574828c9ef..d595a82e11 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/SoftwareProductComponentCompute.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/SoftwareProductComponentCompute.js @@ -13,35 +13,63 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductComponentComputeView from './SoftwareProductComponentComputeView.jsx'; import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; -import {COMPONENTS_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { COMPONENTS_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {onboardingMethod} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { onboardingMethod } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductEditor: { data: currentVSP }, + softwareProductComponents + } = softwareProduct; + let { + componentEditor: { qdata, dataMap, qgenericFieldInfo }, + computeFlavor: { computesList: computeFlavorsList } + } = softwareProductComponents; -const mapStateToProps = ({softwareProduct}) => { - let {softwareProductEditor: {data: currentVSP}, softwareProductComponents} = softwareProduct; - let {componentEditor: {qdata, dataMap, qgenericFieldInfo}, computeFlavor: {computesList: computeFlavorsList}} = softwareProductComponents; - - return { - qdata, - dataMap, - qgenericFieldInfo, - computeFlavorsList, - isManual: currentVSP.onboardingMethod === onboardingMethod.MANUAL - }; + return { + qdata, + dataMap, + qgenericFieldInfo, + computeFlavorsList, + isManual: currentVSP.onboardingMethod === onboardingMethod.MANUAL + }; }; -const mapActionToProps = (dispatch, {softwareProductId, version, componentId}) => { - return { - onQDataChanged: (deltaData, customValidations) => ValidationHelper.qDataChanged(dispatch, {deltaData, customValidations: customValidations, - qName: COMPONENTS_QUESTIONNAIRE}), - onSubmit: ({qdata}) =>{ return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId: componentId, qdata});}, - qValidateData: (data, customValidations) => ValidationHelper.qValidateData(dispatch, {data, customValidations: customValidations, - qName: COMPONENTS_QUESTIONNAIRE}) - }; +const mapActionToProps = ( + dispatch, + { softwareProductId, version, componentId } +) => { + return { + onQDataChanged: (deltaData, customValidations) => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + customValidations: customValidations, + qName: COMPONENTS_QUESTIONNAIRE + }), + onSubmit: ({ qdata }) => { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire( + dispatch, + { + softwareProductId, + version, + vspComponentId: componentId, + qdata + } + ); + }, + qValidateData: (data, customValidations) => + ValidationHelper.qValidateData(dispatch, { + data, + customValidations: customValidations, + qName: COMPONENTS_QUESTIONNAIRE + }) + }; }; -export default connect(mapStateToProps, mapActionToProps, null, {withRef: true}) (SoftwareProductComponentComputeView); +export default connect(mapStateToProps, mapActionToProps, null, { + withRef: true +})(SoftwareProductComponentComputeView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/SoftwareProductComponentComputeView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/SoftwareProductComponentComputeView.jsx index 55e5e2b30b..e6ce96666e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/SoftwareProductComponentComputeView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/SoftwareProductComponentComputeView.jsx @@ -22,67 +22,99 @@ import ComputeFlavors from './computeComponents/ComputeFlavors.js'; import Validator from 'nfvo-utils/Validator.js'; class SoftwareProductComponentComputeView extends React.Component { + static propTypes = { + dataMap: PropTypes.object, + qgenericFieldInfo: PropTypes.object, + isReadOnlyMode: PropTypes.bool, + isManual: PropTypes.bool, + onQDataChanged: PropTypes.func.isRequired, + qValidateData: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired + }; - static propTypes = { - dataMap: PropTypes.object, - qgenericFieldInfo: PropTypes.object, - isReadOnlyMode: PropTypes.bool, - isManual: PropTypes.bool, - onQDataChanged: PropTypes.func.isRequired, - qValidateData: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired - }; + render() { + let { + softwareProductId, + componentId, + version, + qdata, + dataMap, + qgenericFieldInfo, + isReadOnlyMode, + onQDataChanged, + qValidateData, + onSubmit, + computeFlavorsList, + isManual + } = this.props; - render() { - let {softwareProductId, componentId, version, qdata, dataMap, qgenericFieldInfo, isReadOnlyMode, onQDataChanged, qValidateData, - onSubmit, computeFlavorsList, isManual} = this.props; + return ( +
    + {qgenericFieldInfo && ( +
    { + this.form = form; + }} + formReady={null} + isValid={true} + hasButtons={false} + onSubmit={() => onSubmit({ qdata })} + className="component-questionnaire-validation-form" + isReadOnlyMode={isReadOnlyMode}> + + + + + )} +
    + ); + } - return ( -
    - { qgenericFieldInfo &&
    { this.form = form; }} - formReady={null} - isValid={true} - hasButtons={false} - onSubmit={() => onSubmit({qdata})} - className='component-questionnaire-validation-form' - isReadOnlyMode={isReadOnlyMode} > - - - - } -
    - ); - } + save() { + return this.form.handleFormSubmit(new Event('dummy')); + } - save(){ - return this.form.handleFormSubmit(new Event('dummy')); - } + validateMin(value, state) { + let maxVal = state.dataMap['compute/numOfVMs/maximum']; + // we are allowed to have an empty maxval, that will allow all minvals. + // if we do not have a minval than there is no point to check it either. + if (value === undefined || maxVal === undefined) { + return { isValid: true, errorText: '' }; + } else { + return Validator.validateItem(value, maxVal, 'maximum'); + } + } - validateMin(value, state) { - let maxVal = state.dataMap['compute/numOfVMs/maximum']; - // we are allowed to have an empty maxval, that will allow all minvals. - // if we do not have a minval than there is no point to check it either. - if (value === undefined || maxVal === undefined) { - return { isValid: true, errorText: '' }; - } else { - return Validator.validateItem(value, maxVal,'maximum'); - } - } - - validateMax(value, state) { - let minVal = state.dataMap['compute/numOfVMs/minimum']; - if (minVal === undefined ) { - // having no minimum is the same as 0, maximum value doesn't need to be checked - // against it. - return { isValid: true, errorText: '' }; - } else { - return Validator.validateItem(value,minVal,'minimum'); - } - } + validateMax(value, state) { + let minVal = state.dataMap['compute/numOfVMs/minimum']; + if (minVal === undefined) { + // having no minimum is the same as 0, maximum value doesn't need to be checked + // against it. + return { isValid: true, errorText: '' }; + } else { + return Validator.validateItem(value, minVal, 'minimum'); + } + } } export default SoftwareProductComponentComputeView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/ComputeFlavors.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/ComputeFlavors.js index 2b6d84f381..2004c94137 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/ComputeFlavors.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/ComputeFlavors.js @@ -15,103 +15,159 @@ */ import React from 'react'; import PropTypes from 'prop-types'; -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import ComputeFlavorActionHelper from 'sdc-app/onboarding/softwareProduct/components/compute/ComputeFlavorActionHelper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; -const mapActionsToProps = (dispatch, {softwareProductId, componentId, version}) => { - return { - onAddComputeClick: (isReadOnlyMode) => ComputeFlavorActionHelper.openComputeEditor(dispatch, {props: {softwareProductId, componentId, isReadOnlyMode, version}}), - onEditCompute: ({computeId, isReadOnlyMode}) => ComputeFlavorActionHelper.loadCompute(dispatch, {softwareProductId, componentId, version, computeId, isReadOnlyMode}), - onDeleteCompute: ({id, name}) => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data:{ - msg: i18n('Are you sure you want to delete "{name}"?', {name: name}), - onConfirmed: () => ComputeFlavorActionHelper.deleteCompute(dispatch, {softwareProductId, componentId, computeId: id, version}) - } - }) - }; +const mapActionsToProps = ( + dispatch, + { softwareProductId, componentId, version } +) => { + return { + onAddComputeClick: isReadOnlyMode => + ComputeFlavorActionHelper.openComputeEditor(dispatch, { + props: { + softwareProductId, + componentId, + isReadOnlyMode, + version + } + }), + onEditCompute: ({ computeId, isReadOnlyMode }) => + ComputeFlavorActionHelper.loadCompute(dispatch, { + softwareProductId, + componentId, + version, + computeId, + isReadOnlyMode + }), + onDeleteCompute: ({ id, name }) => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + msg: i18n('Are you sure you want to delete "{name}"?', { + name: name + }), + onConfirmed: () => + ComputeFlavorActionHelper.deleteCompute(dispatch, { + softwareProductId, + componentId, + computeId: id, + version + }) + } + }) + }; }; const computeItemPropType = PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - description: PropTypes.string + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string }); class ComputeFlavors extends React.Component { + static propTypes = { + isReadOnlyMode: PropTypes.bool, + isManual: PropTypes.bool, + onAddComputeClick: PropTypes.func, + computeFlavorsList: PropTypes.arrayOf(computeItemPropType) + }; - static propTypes = { - isReadOnlyMode: PropTypes.bool, - isManual: PropTypes.bool, - onAddComputeClick: PropTypes.func, - computeFlavorsList: PropTypes.arrayOf(computeItemPropType) - }; + state = { + localFilter: '' + }; - state = { - localFilter: '' - }; + render() { + const { localFilter } = this.state; + const { + isReadOnlyMode, + isManual, + onAddComputeClick, + onEditCompute, + onDeleteCompute + } = this.props; + return ( +
    + onAddComputeClick(isReadOnlyMode) + : null + } + isReadOnlyMode={isReadOnlyMode} + onFilter={ + isManual + ? value => this.setState({ localFilter: value }) + : null + } + filterValue={localFilter} + twoColumns> + {this.filterList().map(computeItem => ( + + ))} + +
    + ); + } - render() { - const {localFilter} = this.state; - const {isReadOnlyMode, isManual, onAddComputeClick, onEditCompute, onDeleteCompute} = this.props; - return ( -
    - onAddComputeClick(isReadOnlyMode) : null} - isReadOnlyMode={isReadOnlyMode} - onFilter={isManual ? value => this.setState({localFilter: value}) : null} - filterValue={localFilter} - twoColumns> - {this.filterList().map(computeItem => - ) - } - -
    - ); - } + filterList() { + const { computeFlavorsList = [] } = this.props; - filterList() { - const {computeFlavorsList = []} = this.props; - - const {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return computeFlavorsList.filter(({name = '', description = ''}) => { - return escape(name).match(filter) || escape(description).match(filter); - }); - } - else { - return computeFlavorsList; - } - } + const { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return computeFlavorsList.filter( + ({ name = '', description = '' }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) + ); + } + ); + } else { + return computeFlavorsList; + } + } } -const ComputeItem = ({computeItem, isReadOnlyMode, isManual, onEditCompute, onDeleteCompute}) => { - const {id, name, description} = computeItem; - return ( - onEditCompute({computeId: id, isReadOnlyMode})} - onDelete={isManual ? () => onDeleteCompute({id, name}) : null}> - -
    -
    {name}
    -
    -
    -
    {description}
    -
    -
    - ); +const ComputeItem = ({ + computeItem, + isReadOnlyMode, + isManual, + onEditCompute, + onDeleteCompute +}) => { + const { id, name, description } = computeItem; + return ( + onEditCompute({ computeId: id, isReadOnlyMode })} + onDelete={isManual ? () => onDeleteCompute({ id, name }) : null}> +
    +
    {name}
    +
    +
    +
    {description}
    +
    +
    + ); }; -export default connect(null, mapActionsToProps, null, {withRef: true})(ComputeFlavors); +export default connect(null, mapActionsToProps, null, { withRef: true })( + ComputeFlavors +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/GuestOs.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/GuestOs.jsx index 8ae9961859..c16ab5cdfe 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/GuestOs.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/GuestOs.jsx @@ -19,57 +19,91 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; - -const GuestOs = ({qgenericFieldInfo, dataMap, onQDataChanged}) => { - return( -
    - - -
    - -
    - {qgenericFieldInfo['compute/guestOS/bitSize'].enum.map(bitSize => ( - onQDataChanged({'compute/guestOS/bitSize' : Number(bit)})} - isValid={qgenericFieldInfo['compute/guestOS/bitSize'].isValid} - errorText={qgenericFieldInfo['compute/guestOS/bitSize'].errorText} - checked={dataMap['compute/guestOS/bitSize'] === bitSize.enum} /> )) } -
    -
    -
    - - - onQDataChanged({'compute/guestOS/name' : tools})} - isValid={qgenericFieldInfo['compute/guestOS/name'].isValid} - errorText={qgenericFieldInfo['compute/guestOS/name'].errorText} - value={dataMap['compute/guestOS/name']} /> - - - onQDataChanged({'compute/guestOS/tools' : tools})} - isValid={qgenericFieldInfo['compute/guestOS/tools'].isValid} - errorText={qgenericFieldInfo['compute/guestOS/tools'].errorText} - value={dataMap['compute/guestOS/tools']} /> - -
    - - -
    - ); +const GuestOs = ({ qgenericFieldInfo, dataMap, onQDataChanged }) => { + return ( +
    + + +
    + +
    + {qgenericFieldInfo[ + 'compute/guestOS/bitSize' + ].enum.map(bitSize => ( + + onQDataChanged({ + 'compute/guestOS/bitSize': Number( + bit + ) + }) + } + isValid={ + qgenericFieldInfo[ + 'compute/guestOS/bitSize' + ].isValid + } + errorText={ + qgenericFieldInfo[ + 'compute/guestOS/bitSize' + ].errorText + } + checked={ + dataMap['compute/guestOS/bitSize'] === + bitSize.enum + } + /> + ))} +
    +
    +
    + + + + onQDataChanged({ 'compute/guestOS/name': tools }) + } + isValid={ + qgenericFieldInfo['compute/guestOS/name'].isValid + } + errorText={ + qgenericFieldInfo['compute/guestOS/name'].errorText + } + value={dataMap['compute/guestOS/name']} + /> + + + + onQDataChanged({ 'compute/guestOS/tools': tools }) + } + isValid={ + qgenericFieldInfo['compute/guestOS/tools'].isValid + } + errorText={ + qgenericFieldInfo['compute/guestOS/tools'].errorText + } + value={dataMap['compute/guestOS/tools']} + /> + +
    +
    + ); }; export default GuestOs; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/NumberOfVms.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/NumberOfVms.jsx index 967c6f7aef..5451354502 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/NumberOfVms.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/NumberOfVms.jsx @@ -20,38 +20,77 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; - -const NumberOfVms = ({qgenericFieldInfo, dataMap, onQDataChanged, qValidateData, customValidations}) => { - return( - - - { onQDataChanged({'compute/numOfVMs/minimum' : tools}, customValidations); - qValidateData({'compute/numOfVMs/maximum' : dataMap['compute/numOfVMs/maximum']}, customValidations); } } - isValid={qgenericFieldInfo['compute/numOfVMs/minimum'].isValid} - errorText={qgenericFieldInfo['compute/numOfVMs/minimum'].errorText} - value={dataMap['compute/numOfVMs/minimum']} /> - - - { onQDataChanged({'compute/numOfVMs/maximum' : tools}, customValidations); - qValidateData({'compute/numOfVMs/minimum' : dataMap['compute/numOfVMs/minimum']}, customValidations); } } - isValid={qgenericFieldInfo['compute/numOfVMs/maximum'].isValid} - errorText={qgenericFieldInfo['compute/numOfVMs/maximum'].errorText} - value={dataMap['compute/numOfVMs/maximum']} /> - - - ); +const NumberOfVms = ({ + qgenericFieldInfo, + dataMap, + onQDataChanged, + qValidateData, + customValidations +}) => { + return ( + + + { + onQDataChanged( + { 'compute/numOfVMs/minimum': tools }, + customValidations + ); + qValidateData( + { + 'compute/numOfVMs/maximum': + dataMap['compute/numOfVMs/maximum'] + }, + customValidations + ); + }} + isValid={ + qgenericFieldInfo['compute/numOfVMs/minimum'].isValid + } + errorText={ + qgenericFieldInfo['compute/numOfVMs/minimum'].errorText + } + value={dataMap['compute/numOfVMs/minimum']} + /> + + + { + onQDataChanged( + { 'compute/numOfVMs/maximum': tools }, + customValidations + ); + qValidateData( + { + 'compute/numOfVMs/minimum': + dataMap['compute/numOfVMs/minimum'] + }, + customValidations + ); + }} + isValid={ + qgenericFieldInfo['compute/numOfVMs/maximum'].isValid + } + errorText={ + qgenericFieldInfo['compute/numOfVMs/maximum'].errorText + } + value={dataMap['compute/numOfVMs/maximum']} + /> + + + ); }; NumberOfVms.propTypes = { - minNumberOfVMsSelectedByUser: PropTypes.number + minNumberOfVMsSelectedByUser: PropTypes.number }; export default NumberOfVms; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorConstants.js index 41728eefb0..58c27c6bba 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorConstants.js @@ -19,14 +19,14 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const COMPUTE_FLAVOR_FORM = 'COMPUTE_FLAVOR_FORM'; export const actionTypes = keyMirror({ - ADD_COMPUTE: null, - COMPUTE_FLAVORS_LIST_LOADED: null, - COMPUTE_LIST_EDIT: null, - EDIT_COMPUTE_FLAVOR: null, - DELETE_COMPUTE: null, - CONFIRM_DELETE_COMPUTE: null, - computeEditor: { - LOAD_EDITOR_DATA: null, - CLEAR_DATA: null - } + ADD_COMPUTE: null, + COMPUTE_FLAVORS_LIST_LOADED: null, + COMPUTE_LIST_EDIT: null, + EDIT_COMPUTE_FLAVOR: null, + DELETE_COMPUTE: null, + CONFIRM_DELETE_COMPUTE: null, + computeEditor: { + LOAD_EDITOR_DATA: null, + CLEAR_DATA: null + } }); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditor.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditor.js index a3ba5fbc4a..06f9e8fd19 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditor.js @@ -13,49 +13,78 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import ComputeFlavorEditorView from './ComputeFlavorEditorView.jsx'; -import {COMPUTE_FLAVOR_FORM} from './ComputeFlavorConstants.js'; +import { COMPUTE_FLAVOR_FORM } from './ComputeFlavorConstants.js'; import ComputeFlavorActionHelper from 'sdc-app/onboarding/softwareProduct/components/compute/ComputeFlavorActionHelper.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {COMPONENTS_COMPUTE_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; -import {onboardingMethod} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { COMPONENTS_COMPUTE_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { onboardingMethod } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; export const mapStateToProps = ({ - softwareProduct: { - softwareProductEditor, - softwareProductComponents: {computeFlavor: {computeEditor = {}}} - }, - currentScreen: { - props: {isReadOnlyMode} - } + softwareProduct: { + softwareProductEditor, + softwareProductComponents: { computeFlavor: { computeEditor = {} } } + }, + currentScreen: { props: { isReadOnlyMode } } }) => { - const {data: currentSoftwareProduct = {}} = softwareProductEditor; - let {data , qdata, qgenericFieldInfo, dataMap, genericFieldInfo, formReady} = computeEditor; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + const { data: currentSoftwareProduct = {} } = softwareProductEditor; + let { + data, + qdata, + qgenericFieldInfo, + dataMap, + genericFieldInfo, + formReady + } = computeEditor; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - return { - data, - qdata, - qgenericFieldInfo, - dataMap, - genericFieldInfo, - isReadOnlyMode, - isFormValid, - formReady, - isManual: currentSoftwareProduct.onboardingMethod === onboardingMethod.MANUAL - }; + return { + data, + qdata, + qgenericFieldInfo, + dataMap, + genericFieldInfo, + isReadOnlyMode, + isFormValid, + formReady, + isManual: + currentSoftwareProduct.onboardingMethod === onboardingMethod.MANUAL + }; }; - -const mapActionsToProps = (dispatch, {softwareProductId, componentId, version}) => { - return { - onDataChanged: deltaData => ValidationHelper.dataChanged(dispatch, {deltaData, formName: COMPUTE_FLAVOR_FORM}), - onQDataChanged: deltaData => ValidationHelper.qDataChanged(dispatch, {deltaData, qName: COMPONENTS_COMPUTE_QUESTIONNAIRE}), - onCancel: () => ComputeFlavorActionHelper.closeComputeEditor(dispatch), - onSubmit: ({data, qdata}) => ComputeFlavorActionHelper.saveComputeDataAndQuestionnaire(dispatch, {softwareProductId, componentId, data, qdata, version}), - onValidateForm: () => ValidationHelper.validateForm(dispatch, COMPUTE_FLAVOR_FORM) - }; +const mapActionsToProps = ( + dispatch, + { softwareProductId, componentId, version } +) => { + return { + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: COMPUTE_FLAVOR_FORM + }), + onQDataChanged: deltaData => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + qName: COMPONENTS_COMPUTE_QUESTIONNAIRE + }), + onCancel: () => ComputeFlavorActionHelper.closeComputeEditor(dispatch), + onSubmit: ({ data, qdata }) => + ComputeFlavorActionHelper.saveComputeDataAndQuestionnaire( + dispatch, + { + softwareProductId, + componentId, + data, + qdata, + version + } + ), + onValidateForm: () => + ValidationHelper.validateForm(dispatch, COMPUTE_FLAVOR_FORM) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(ComputeFlavorEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + ComputeFlavorEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditorView.jsx index e542ce1fd1..840f722bb2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditorView.jsx @@ -23,75 +23,112 @@ import VmSizing from './VmSizing.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; class ComputeEditorView extends React.Component { + static propTypes = { + data: PropTypes.object, + qdata: PropTypes.object, + qschema: PropTypes.object, + isReadOnlyMode: PropTypes.bool, + isManual: PropTypes.bool, + onDataChanged: PropTypes.func.isRequired, + onQDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired + }; - static propTypes = { - data: PropTypes.object, - qdata: PropTypes.object, - qschema: PropTypes.object, - isReadOnlyMode: PropTypes.bool, - isManual: PropTypes.bool, - onDataChanged: PropTypes.func.isRequired, - onQDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired - }; + render() { + let { + data = {}, + qdata = {}, + qgenericFieldInfo, + dataMap, + genericFieldInfo, + isReadOnlyMode, + isManual, + isFormValid, + formReady, + onDataChanged, + onQDataChanged, + onSubmit, + onCancel, + onValidateForm + } = this.props; + const { id, name, description } = data; + const edittingComputeMode = Boolean(id); - render() { - let {data = {}, qdata = {}, qgenericFieldInfo, dataMap, genericFieldInfo, isReadOnlyMode, isManual, isFormValid, formReady, - onDataChanged, onQDataChanged, onSubmit, onCancel, onValidateForm} = this.props; - const {id, name, description} = data; - const edittingComputeMode = Boolean(id); + return ( +
    + {genericFieldInfo && ( +
    { + this.form = form; + }} + hasButtons={true} + onSubmit={() => onSubmit({ data, qdata })} + onReset={() => onCancel()} + labledButtons={true} + isReadOnlyMode={isReadOnlyMode} + isValid={isFormValid} + formReady={formReady} + onValidateForm={() => onValidateForm()} + className="component-questionnaire-validation-form" + submitButtonText={ + edittingComputeMode ? i18n('Save') : i18n('Create') + }> + + + onDataChanged({ name })} + isValid={genericFieldInfo['name'].isValid} + errorText={ + genericFieldInfo['name'].errorText + } + isRequired + /> + + + + onDataChanged({ description }) + } + isValid={ + genericFieldInfo['description'].isValid + } + errorText={ + genericFieldInfo['description'] + .errorText + } + /> + + + {edittingComputeMode && ( + + )} + + )} +
    + ); + } - return ( -
    - {genericFieldInfo &&
    { - this.form = form; - }} - hasButtons={true} - onSubmit={ () => onSubmit({data, qdata}) } - onReset={ () => onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - isValid={isFormValid} - formReady={formReady} - onValidateForm={() => onValidateForm() } - className='component-questionnaire-validation-form' - submitButtonText={edittingComputeMode ? i18n('Save') : i18n('Create')}> - - - onDataChanged({name})} - isValid={genericFieldInfo['name'].isValid} - errorText={genericFieldInfo['name'].errorText} - isRequired/> - - - onDataChanged({description})} - isValid={genericFieldInfo['description'].isValid} - errorText={genericFieldInfo['description'].errorText}/> - - - {edittingComputeMode && } - - } -
    - ); - } - - save(){ - return this.form.handleFormSubmit(new Event('dummy')); - } + save() { + return this.form.handleFormSubmit(new Event('dummy')); + } } export default ComputeEditorView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorListReducer.js index 6c02f36c90..b691084cc3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorListReducer.js @@ -14,20 +14,26 @@ * permissions and limitations under the License. */ -import {actionTypes} from './ComputeFlavorConstants.js'; +import { actionTypes } from './ComputeFlavorConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.COMPUTE_FLAVORS_LIST_LOADED: - return [...action.response.results]; - case actionTypes.ADD_COMPUTE: - return [...state, action.compute]; - case actionTypes.COMPUTE_LIST_EDIT: - const indexForEdit = state.findIndex(({id}) => id === action.compute.id); - return [...state.slice(0, indexForEdit), action.compute, ...state.slice(indexForEdit + 1)]; - case actionTypes.DELETE_COMPUTE: - return state.filter(({id}) => id !== action.computeId); - default: - return state; - } -}; \ No newline at end of file + switch (action.type) { + case actionTypes.COMPUTE_FLAVORS_LIST_LOADED: + return [...action.response.results]; + case actionTypes.ADD_COMPUTE: + return [...state, action.compute]; + case actionTypes.COMPUTE_LIST_EDIT: + const indexForEdit = state.findIndex( + ({ id }) => id === action.compute.id + ); + return [ + ...state.slice(0, indexForEdit), + action.compute, + ...state.slice(indexForEdit + 1) + ]; + case actionTypes.DELETE_COMPUTE: + return state.filter(({ id }) => id !== action.computeId); + default: + return state; + } +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorReducer.js index a476f85a19..00d76eff23 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorReducer.js @@ -13,33 +13,32 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, COMPUTE_FLAVOR_FORM} from './ComputeFlavorConstants.js'; +import { actionTypes, COMPUTE_FLAVOR_FORM } from './ComputeFlavorConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.computeEditor.LOAD_EDITOR_DATA: - return { - ...state, - formName: COMPUTE_FLAVOR_FORM, - data: action.compute, - formReady: null, - genericFieldInfo: { - name: { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true }] - }, - description: { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 300}] - } - } - }; - case actionTypes.computeEditor.CLEAR_DATA: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.computeEditor.LOAD_EDITOR_DATA: + return { + ...state, + formName: COMPUTE_FLAVOR_FORM, + data: action.compute, + formReady: null, + genericFieldInfo: { + name: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + }, + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 300 }] + } + } + }; + case actionTypes.computeEditor.CLEAR_DATA: + return {}; + default: + return state; + } }; - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/VmSizing.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/VmSizing.jsx index 54f22e0760..2f40706736 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/VmSizing.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/VmSizing.jsx @@ -18,89 +18,146 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -const VmSizing = ({qgenericFieldInfo, dataMap, onQDataChanged}) => { - return( - - - onQDataChanged({'vmSizing/numOfCPUs' : tools})} - isValid={qgenericFieldInfo['vmSizing/numOfCPUs'].isValid} - errorText={qgenericFieldInfo['vmSizing/numOfCPUs'].errorText} - value={dataMap['vmSizing/numOfCPUs']} /> - - - onQDataChanged({'vmSizing/fileSystemSizeGB' : tools})} - isValid={qgenericFieldInfo['vmSizing/fileSystemSizeGB'].isValid} - errorText={qgenericFieldInfo['vmSizing/fileSystemSizeGB'].errorText} - value={dataMap['vmSizing/fileSystemSizeGB']} /> - - - onQDataChanged({'vmSizing/persistentStorageVolumeSize' : tools})} - isValid={qgenericFieldInfo['vmSizing/persistentStorageVolumeSize'].isValid} - errorText={qgenericFieldInfo['vmSizing/persistentStorageVolumeSize'].errorText} - value={dataMap['vmSizing/persistentStorageVolumeSize']} /> - - - onQDataChanged({'vmSizing/ioOperationsPerSec' : tools})} - isValid={qgenericFieldInfo['vmSizing/ioOperationsPerSec'].isValid} - errorText={qgenericFieldInfo['vmSizing/ioOperationsPerSec'].errorText} - value={dataMap['vmSizing/ioOperationsPerSec']} /> - - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({'vmSizing/cpuOverSubscriptionRatio' : val});} - }> - - {qgenericFieldInfo['vmSizing/cpuOverSubscriptionRatio'].enum.map(cpuOSR => )} - - - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({'vmSizing/memoryRAM' : val});} - }> - - {qgenericFieldInfo['vmSizing/memoryRAM'].enum.map(mRAM => )} - - - - ); +const VmSizing = ({ qgenericFieldInfo, dataMap, onQDataChanged }) => { + return ( + + + + onQDataChanged({ 'vmSizing/numOfCPUs': tools }) + } + isValid={qgenericFieldInfo['vmSizing/numOfCPUs'].isValid} + errorText={ + qgenericFieldInfo['vmSizing/numOfCPUs'].errorText + } + value={dataMap['vmSizing/numOfCPUs']} + /> + + + + onQDataChanged({ 'vmSizing/fileSystemSizeGB': tools }) + } + isValid={ + qgenericFieldInfo['vmSizing/fileSystemSizeGB'].isValid + } + errorText={ + qgenericFieldInfo['vmSizing/fileSystemSizeGB'].errorText + } + value={dataMap['vmSizing/fileSystemSizeGB']} + /> + + + + onQDataChanged({ + 'vmSizing/persistentStorageVolumeSize': tools + }) + } + isValid={ + qgenericFieldInfo[ + 'vmSizing/persistentStorageVolumeSize' + ].isValid + } + errorText={ + qgenericFieldInfo[ + 'vmSizing/persistentStorageVolumeSize' + ].errorText + } + value={dataMap['vmSizing/persistentStorageVolumeSize']} + /> + + + + onQDataChanged({ 'vmSizing/ioOperationsPerSec': tools }) + } + isValid={ + qgenericFieldInfo['vmSizing/ioOperationsPerSec'].isValid + } + errorText={ + qgenericFieldInfo['vmSizing/ioOperationsPerSec'] + .errorText + } + value={dataMap['vmSizing/ioOperationsPerSec']} + /> + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({ + 'vmSizing/cpuOverSubscriptionRatio': val + }); + }}> + + {qgenericFieldInfo[ + 'vmSizing/cpuOverSubscriptionRatio' + ].enum.map(cpuOSR => ( + + ))} + + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({ 'vmSizing/memoryRAM': val }); + }}> + + {qgenericFieldInfo['vmSizing/memoryRAM'].enum.map(mRAM => ( + + ))} + + + + ); }; export default VmSizing; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/creation/SoftwareProductComponentCreation.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/creation/SoftwareProductComponentCreation.js index 9f59cd5b27..d831765674 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/creation/SoftwareProductComponentCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/creation/SoftwareProductComponentCreation.js @@ -14,36 +14,50 @@ * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductComponentCreationView from './SoftwareProductComponentCreationView.jsx'; import SoftwareProductComponentsActionHelper from '../SoftwareProductComponentsActionHelper.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {forms} from '../SoftwareProductComponentsConstants.js'; +import { forms } from '../SoftwareProductComponentsConstants.js'; -export const mapStateToProps = ({softwareProduct}) => { - let {softwareProductComponents: {componentEditor: {data, genericFieldInfo, formReady}}} = softwareProduct; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - return { - data, - genericFieldInfo, - formReady, - isFormValid - }; +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductComponents: { + componentEditor: { data, genericFieldInfo, formReady } + } + } = softwareProduct; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + return { + data, + genericFieldInfo, + formReady, + isFormValid + }; }; - -const mapActionsToProps = (dispatch, {softwareProductId, version}) => { - return { - onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: forms.CREATE_FORM}), - //onDataChanged: deltaData => SoftwareProductComponentsActionHelper.componentDataChanged(dispatch, {deltaData}), - onSubmit: (componentData) => { - return SoftwareProductComponentsActionHelper.createSoftwareProductComponent(dispatch, - {softwareProductId, componentData, version}); - }, - onCancel: () => SoftwareProductComponentsActionHelper.closeComponentCreationModal(dispatch), - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) - }; - +const mapActionsToProps = (dispatch, { softwareProductId, version }) => { + return { + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: forms.CREATE_FORM + }), + //onDataChanged: deltaData => SoftwareProductComponentsActionHelper.componentDataChanged(dispatch, {deltaData}), + onSubmit: componentData => { + return SoftwareProductComponentsActionHelper.createSoftwareProductComponent( + dispatch, + { softwareProductId, componentData, version } + ); + }, + onCancel: () => + SoftwareProductComponentsActionHelper.closeComponentCreationModal( + dispatch + ), + onValidateForm: formName => + ValidationHelper.validateForm(dispatch, formName) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(SoftwareProductComponentCreationView); +export default connect(mapStateToProps, mapActionsToProps)( + SoftwareProductComponentCreationView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/creation/SoftwareProductComponentCreationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/creation/SoftwareProductComponentCreationView.jsx index 42804ce5a6..0b33b4017f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/creation/SoftwareProductComponentCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/creation/SoftwareProductComponentCreationView.jsx @@ -21,59 +21,80 @@ import Form from 'nfvo-components/input/validation/Form.jsx'; import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {forms} from '../SoftwareProductComponentsConstants.js'; +import { forms } from '../SoftwareProductComponentsConstants.js'; class ComponentCreationView extends React.Component { - render() { - let {data = {}, onDataChanged, onCancel, genericFieldInfo} = this.props; - let {displayName, description} = data; - return( -
    - { - genericFieldInfo &&
    this.submit() } - onReset={ () => onCancel() } - submitButtonText={i18n('Create')} - labledButtons={true} - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.props.onValidateForm(forms.CREATE_FORM) } - className='entitlement-pools-form'> - - - onDataChanged({displayName})} - label={i18n('Name')} - isRequired={true} - isValid={genericFieldInfo.displayName.isValid} - errorText={genericFieldInfo.displayName.errorText} - value={displayName} - type='text'/> - - - onDataChanged({description})} - value={description} - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} - data-test-id='description' - type='textarea'/> - - -
    - } -
    - ); - } + render() { + let { + data = {}, + onDataChanged, + onCancel, + genericFieldInfo + } = this.props; + let { displayName, description } = data; + return ( +
    + {genericFieldInfo && ( +
    this.submit()} + onReset={() => onCancel()} + submitButtonText={i18n('Create')} + labledButtons={true} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => + this.props.onValidateForm(forms.CREATE_FORM) + } + className="entitlement-pools-form"> + + + + onDataChanged({ displayName }) + } + label={i18n('Name')} + isRequired={true} + isValid={ + genericFieldInfo.displayName.isValid + } + errorText={ + genericFieldInfo.displayName.errorText + } + value={displayName} + type="text" + /> + + + + onDataChanged({ description }) + } + value={description} + isValid={ + genericFieldInfo.description.isValid + } + errorText={ + genericFieldInfo.description.errorText + } + data-test-id="description" + type="textarea" + /> + + +
    + )} +
    + ); + } - submit() { - const {onSubmit, data} = this.props; - onSubmit(data); - } + submit() { + const { onSubmit, data } = this.props; + onSubmit(data); + } } export default ComponentCreationView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneral.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneral.js index 8c06fd0ab8..f3f64e4b20 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneral.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneral.js @@ -13,41 +13,79 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductComponentsGeneralView from './SoftwareProductComponentsGeneralView.jsx'; import SoftwareProductComponentsActionHelper from '../SoftwareProductComponentsActionHelper.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; -import {forms, COMPONENTS_QUESTIONNAIRE} from '../SoftwareProductComponentsConstants.js'; -import {onboardingMethod} from '../../SoftwareProductConstants.js'; +import { + forms, + COMPONENTS_QUESTIONNAIRE +} from '../SoftwareProductComponentsConstants.js'; +import { onboardingMethod } from '../../SoftwareProductConstants.js'; -export const mapStateToProps = ({softwareProduct}) => { - let {softwareProductEditor: {data: currentVSP}, softwareProductComponents} = softwareProduct; - let {componentEditor: {data: componentData = {} , qdata, qgenericFieldInfo : qGenericFieldInfo, dataMap, genericFieldInfo}} = softwareProductComponents; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductEditor: { data: currentVSP }, + softwareProductComponents + } = softwareProduct; + let { + componentEditor: { + data: componentData = {}, + qdata, + qgenericFieldInfo: qGenericFieldInfo, + dataMap, + genericFieldInfo + } + } = softwareProductComponents; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - return { - componentData, - qdata, - isManual: currentVSP.onboardingMethod === onboardingMethod.MANUAL, - genericFieldInfo, - qGenericFieldInfo, - dataMap, - isFormValid - }; + return { + componentData, + qdata, + isManual: currentVSP.onboardingMethod === onboardingMethod.MANUAL, + genericFieldInfo, + qGenericFieldInfo, + dataMap, + isFormValid + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, version, componentId}) => { - return { - onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: forms.ALL_SPC_FORMS}), - onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, qName: COMPONENTS_QUESTIONNAIRE}), - onSubmit: ({componentData, qdata}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, - {softwareProductId, version, vspComponentId: componentId, componentData, qdata}); - }, - onValidityChanged: isValidityData => SoftwareProductActionHelper.setIsValidityData(dispatch, {isValidityData}) - }; - +const mapActionsToProps = ( + dispatch, + { softwareProductId, version, componentId } +) => { + return { + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: forms.ALL_SPC_FORMS + }), + onQDataChanged: deltaData => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + qName: COMPONENTS_QUESTIONNAIRE + }), + onSubmit: ({ componentData, qdata }) => { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent( + dispatch, + { + softwareProductId, + version, + vspComponentId: componentId, + componentData, + qdata + } + ); + }, + onValidityChanged: isValidityData => + SoftwareProductActionHelper.setIsValidityData(dispatch, { + isValidityData + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductComponentsGeneralView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductComponentsGeneralView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx index 6aa51d1609..ad1fcaacff 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx @@ -21,9 +21,18 @@ import Form from 'nfvo-components/input/validation/Form.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -const GeneralSection = ({onDataChanged, displayName, vfcCode, nfcFunction, description, isReadOnlyMode, genericFieldInfo, isManual}) => ( - - {/* disabled until backend will be ready to implement it +const GeneralSection = ({ + onDataChanged, + displayName, + vfcCode, + nfcFunction, + description, + isReadOnlyMode, + genericFieldInfo, + isManual +}) => ( + + {/* disabled until backend will be ready to implement it
    @@ -32,156 +41,248 @@ const GeneralSection = ({onDataChanged, displayName, vfcCode, nfcFunction, descr
    */} - - - {!isManual && onDataChanged({vfcCode})} - disabled={isReadOnlyMode} - type='text'/> } - onDataChanged({nfcFunction})} - disabled={isReadOnlyMode} - type='text'/> - - - onDataChanged({description})} - disabled={isReadOnlyMode} - value={description} - groupClassName='multi-line-textarea' - data-test-id='description' - type='textarea'/> - - - + + + {!isManual && ( + onDataChanged({ vfcCode })} + disabled={isReadOnlyMode} + type="text" + /> + )} + onDataChanged({ nfcFunction })} + disabled={isReadOnlyMode} + type="text" + /> + + + onDataChanged({ description })} + disabled={isReadOnlyMode} + value={description} + groupClassName="multi-line-textarea" + data-test-id="description" + type="textarea" + /> + + + ); -const HypervisorSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => ( - - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({'general/hypervisor/hypervisor' : val});} - }> - - {qgenericFieldInfo['general/hypervisor/hypervisor'].enum.map(hv => )} - - - - onQDataChanged({'general/hypervisor/drivers' : driver})} - label={i18n('Hypervisor Drivers')} - type='text' - isValid={qgenericFieldInfo['general/hypervisor/drivers'].isValid} - errorText={qgenericFieldInfo['general/hypervisor/drivers'].errorText} - value={dataMap['general/hypervisor/drivers']}/> - - - onQDataChanged({'general/hypervisor/containerFeaturesDescription' : containerFeaturesDescription})} - isValid={qgenericFieldInfo['general/hypervisor/containerFeaturesDescription'].isValid} - errorText={qgenericFieldInfo['general/hypervisor/containerFeaturesDescription'].errorText} - value={dataMap['general/hypervisor/containerFeaturesDescription']}/> - - +const HypervisorSection = ({ dataMap, onQDataChanged, qgenericFieldInfo }) => ( + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({ 'general/hypervisor/hypervisor': val }); + }}> + + {qgenericFieldInfo['general/hypervisor/hypervisor'].enum.map( + hv => ( + + ) + )} + + + + + onQDataChanged({ 'general/hypervisor/drivers': driver }) + } + label={i18n('Hypervisor Drivers')} + type="text" + isValid={ + qgenericFieldInfo['general/hypervisor/drivers'].isValid + } + errorText={ + qgenericFieldInfo['general/hypervisor/drivers'].errorText + } + value={dataMap['general/hypervisor/drivers']} + /> + + + + onQDataChanged({ + 'general/hypervisor/containerFeaturesDescription': containerFeaturesDescription + }) + } + isValid={ + qgenericFieldInfo[ + 'general/hypervisor/containerFeaturesDescription' + ].isValid + } + errorText={ + qgenericFieldInfo[ + 'general/hypervisor/containerFeaturesDescription' + ].errorText + } + value={ + dataMap['general/hypervisor/containerFeaturesDescription'] + } + /> + + ); -const ImageSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => ( - - - onQDataChanged({'general/disk/bootDiskSizePerVM' : bootDiskSizePerVM})} - label={i18n('Size of boot disk per VM (GB)')} - type='number' - isValid={qgenericFieldInfo['general/disk/bootDiskSizePerVM'].isValid} - errorText={qgenericFieldInfo['general/disk/bootDiskSizePerVM'].errorText} - value={dataMap['general/disk/bootDiskSizePerVM']}/> - - - onQDataChanged({'general/disk/ephemeralDiskSizePerVM' : ephemeralDiskSizePerVM})} - label={i18n('Size of ephemeral disk per VM (GB)')} - type='number' - isValid={qgenericFieldInfo['general/disk/ephemeralDiskSizePerVM'].isValid} - errorText={qgenericFieldInfo['general/disk/ephemeralDiskSizePerVM'].errorText} - value={dataMap['general/disk/ephemeralDiskSizePerVM']}/> - - +const ImageSection = ({ dataMap, onQDataChanged, qgenericFieldInfo }) => ( + + + + onQDataChanged({ + 'general/disk/bootDiskSizePerVM': bootDiskSizePerVM + }) + } + label={i18n('Size of boot disk per VM (GB)')} + type="number" + isValid={ + qgenericFieldInfo['general/disk/bootDiskSizePerVM'].isValid + } + errorText={ + qgenericFieldInfo['general/disk/bootDiskSizePerVM'] + .errorText + } + value={dataMap['general/disk/bootDiskSizePerVM']} + /> + + + + onQDataChanged({ + 'general/disk/ephemeralDiskSizePerVM': ephemeralDiskSizePerVM + }) + } + label={i18n('Size of ephemeral disk per VM (GB)')} + type="number" + isValid={ + qgenericFieldInfo['general/disk/ephemeralDiskSizePerVM'] + .isValid + } + errorText={ + qgenericFieldInfo['general/disk/ephemeralDiskSizePerVM'] + .errorText + } + value={dataMap['general/disk/ephemeralDiskSizePerVM']} + /> + + ); -const RecoverySection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => ( - - - onQDataChanged({'general/recovery/pointObjective' : pointObjective})} - isValid={qgenericFieldInfo['general/recovery/pointObjective'].isValid} - errorText={qgenericFieldInfo['general/recovery/pointObjective'].errorText} - value={dataMap['general/recovery/pointObjective']}/> - - - onQDataChanged({'general/recovery/timeObjective' : timeObjective})} - isValid={qgenericFieldInfo['general/recovery/timeObjective'].isValid} - errorText={qgenericFieldInfo['general/recovery/timeObjective'].errorText} - value={dataMap['general/recovery/timeObjective']}/> -
    - - - - onQDataChanged({'general/recovery/vmProcessFailuresHandling' : vmProcessFailuresHandling})} - isValid={qgenericFieldInfo['general/recovery/vmProcessFailuresHandling'].isValid} - errorText={qgenericFieldInfo['general/recovery/vmProcessFailuresHandling'].errorText} - value={dataMap['general/recovery/vmProcessFailuresHandling']}/> -
    - - - { - /** disabled until backend will be ready to implement it +const RecoverySection = ({ dataMap, onQDataChanged, qgenericFieldInfo }) => ( + + + + onQDataChanged({ + 'general/recovery/pointObjective': pointObjective + }) + } + isValid={ + qgenericFieldInfo['general/recovery/pointObjective'].isValid + } + errorText={ + qgenericFieldInfo['general/recovery/pointObjective'] + .errorText + } + value={dataMap['general/recovery/pointObjective']} + /> + + + + onQDataChanged({ + 'general/recovery/timeObjective': timeObjective + }) + } + isValid={ + qgenericFieldInfo['general/recovery/timeObjective'].isValid + } + errorText={ + qgenericFieldInfo['general/recovery/timeObjective'] + .errorText + } + value={dataMap['general/recovery/timeObjective']} + /> +
    + + + + + onQDataChanged({ + 'general/recovery/vmProcessFailuresHandling': vmProcessFailuresHandling + }) + } + isValid={ + qgenericFieldInfo[ + 'general/recovery/vmProcessFailuresHandling' + ].isValid + } + errorText={ + qgenericFieldInfo[ + 'general/recovery/vmProcessFailuresHandling' + ].errorText + } + value={dataMap['general/recovery/vmProcessFailuresHandling']} + /> +
    + + {/** disabled until backend will be ready to implement it
    ( pointer='/general/recovery/VMRecoveryDocument'/>
    - */ - } - + */} + ); -const DNSConfigurationSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => ( - - - onQDataChanged({'general/dnsConfiguration' : dnsConfiguration})} - isValid={qgenericFieldInfo['general/dnsConfiguration'].isValid} - errorText={qgenericFieldInfo['general/dnsConfiguration'].errorText} - value={dataMap['general/dnsConfiguration']}/> - - +const DNSConfigurationSection = ({ + dataMap, + onQDataChanged, + qgenericFieldInfo +}) => ( + + + + onQDataChanged({ + 'general/dnsConfiguration': dnsConfiguration + }) + } + isValid={qgenericFieldInfo['general/dnsConfiguration'].isValid} + errorText={ + qgenericFieldInfo['general/dnsConfiguration'].errorText + } + value={dataMap['general/dnsConfiguration']} + /> + + ); -const CloneSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => ( - - - onQDataChanged({'general/vmCloneUsage' : vmCloneUsage})} - isValid={qgenericFieldInfo['general/vmCloneUsage'].isValid} - errorText={qgenericFieldInfo['general/vmCloneUsage'].errorText} - value={dataMap['general/vmCloneUsage']}/> - - +const CloneSection = ({ dataMap, onQDataChanged, qgenericFieldInfo }) => ( + + + + onQDataChanged({ 'general/vmCloneUsage': vmCloneUsage }) + } + isValid={qgenericFieldInfo['general/vmCloneUsage'].isValid} + errorText={qgenericFieldInfo['general/vmCloneUsage'].errorText} + value={dataMap['general/vmCloneUsage']} + /> + + ); class SoftwareProductComponentsGeneralView extends React.Component { + render() { + let { + isManual, + onQDataChanged, + onDataChanged, + genericFieldInfo, + dataMap, + qGenericFieldInfo, + componentData: { displayName, vfcCode, nfcFunction, description }, + isReadOnlyMode + } = this.props; + return ( +
    +
    + {genericFieldInfo && + qGenericFieldInfo && ( +
    + this.props.onValidityChanged(isValidityData) + } + hasButtons={false}> + + + + + + + + )} +
    +
    + ); + } - render() { - let {isManual, onQDataChanged, onDataChanged, genericFieldInfo, dataMap, qGenericFieldInfo, componentData: {displayName, vfcCode, nfcFunction, description}, isReadOnlyMode} = this.props; - return( -
    -
    - {genericFieldInfo && qGenericFieldInfo &&
    this.props.onValidityChanged(isValidityData)} - hasButtons={false}> - - - - - - - } -
    -
    - ); - } - - save() { - let {onSubmit, componentData, qdata} = this.props; - return onSubmit({componentData, qdata}); - } + save() { + let { onSubmit, componentData, qdata } = this.props; + return onSubmit({ componentData, qdata }); + } } export default SoftwareProductComponentsGeneralView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/ImageValidations.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/ImageValidations.js index 2483d0aaa2..900a9a1c46 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/ImageValidations.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/ImageValidations.js @@ -1,6 +1,6 @@ - import Validator from 'nfvo-utils/Validator.js'; -export const imageCustomValidations = { - 'version': value => Validator.validate('version', value, [{type: 'required', data: true}]) +export const imageCustomValidations = { + version: value => + Validator.validate('version', value, [{ type: 'required', data: true }]) }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageActionHelper.js index 8d70d6f14c..3f661b76fe 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageActionHelper.js @@ -17,157 +17,268 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {IMAGE_QUESTIONNAIRE} from './SoftwareProductComponentsImageConstants.js'; -import {actionTypes} from './SoftwareProductComponentsImageConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { IMAGE_QUESTIONNAIRE } from './SoftwareProductComponentsImageConstants.js'; +import { actionTypes } from './SoftwareProductComponentsImageConstants.js'; function baseUrl(softwareProductId, version, componentId) { - const versionId = version.id; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/images`; + const versionId = version.id; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/images`; } -function fetchImagesList({softwareProductId, componentId, version}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}`); +function fetchImagesList({ softwareProductId, componentId, version }) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, version, componentId)}` + ); } -function fetchImage({softwareProductId, componentId, imageId, version}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}/${imageId}`); +function fetchImage({ softwareProductId, componentId, imageId, version }) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, version, componentId)}/${imageId}` + ); } -function destroyImage({softwareProductId, componentId, version, imageId}) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version, componentId)}/${imageId}`); +function destroyImage({ softwareProductId, componentId, version, imageId }) { + return RestAPIUtil.destroy( + `${baseUrl(softwareProductId, version, componentId)}/${imageId}` + ); } -function createImage({softwareProductId, componentId, version, data}) { - return RestAPIUtil.post(baseUrl(softwareProductId, version, componentId), { - fileName: data.fileName - }); +function createImage({ softwareProductId, componentId, version, data }) { + return RestAPIUtil.post(baseUrl(softwareProductId, version, componentId), { + fileName: data.fileName + }); } -function fetchImageQuestionnaire({softwareProductId, componentId, imageId, version}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}/${imageId}/questionnaire`); +function fetchImageQuestionnaire({ + softwareProductId, + componentId, + imageId, + version +}) { + return RestAPIUtil.fetch( + `${baseUrl( + softwareProductId, + version, + componentId + )}/${imageId}/questionnaire` + ); } -function saveImage({softwareProductId, version, componentId, image: {id, fileName}}) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version, componentId)}/${id}`,{ - fileName - }); - +function saveImage({ + softwareProductId, + version, + componentId, + image: { id, fileName } +}) { + return RestAPIUtil.put( + `${baseUrl(softwareProductId, version, componentId)}/${id}`, + { + fileName + } + ); } -function saveImageQuestionnaire({softwareProductId, componentId, version, imageId, qdata}) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version, componentId)}/${imageId}/questionnaire`, qdata); +function saveImageQuestionnaire({ + softwareProductId, + componentId, + version, + imageId, + qdata +}) { + return RestAPIUtil.put( + `${baseUrl( + softwareProductId, + version, + componentId + )}/${imageId}/questionnaire`, + qdata + ); } const SoftwareProductComponentImagesActionHelper = { - fetchImagesList(dispatch, {softwareProductId, componentId, version}) { - dispatch({ - type: actionTypes.IMAGES_LIST_UPDATE, - response: [] - }); - - return fetchImagesList({softwareProductId, componentId, version}).then((response) => { - dispatch({ - type: actionTypes.IMAGES_LIST_UPDATE, - response: response.results, - componentId : componentId - }); - }); - }, - - deleteImage(dispatch, {softwareProductId, componentId, version, imageId}) { - return destroyImage({softwareProductId, componentId, version, imageId}).then(() => { - return SoftwareProductComponentImagesActionHelper.fetchImagesList(dispatch, {softwareProductId, componentId, version}); - }); - }, - - loadImageData({softwareProductId, componentId, imageId, version}) { - return fetchImage({softwareProductId, componentId, imageId, version}); - }, - - openEditImageEditor(dispatch, {image, softwareProductId, componentId, version, isReadOnlyMode}) { - return SoftwareProductComponentImagesActionHelper.loadImageData({softwareProductId, componentId, imageId: image.id, version}).then(({data}) => { - SoftwareProductComponentImagesActionHelper.loadImageQuestionnaire(dispatch, { - softwareProductId, - componentId, - imageId: image.id, - version - }).then(() => { - SoftwareProductComponentImagesActionHelper.openImageEditor(dispatch, { - softwareProductId, - componentId, - version, - isReadOnlyMode, - image, - data - }); - }); - }); - }, - - openImageEditor(dispatch, {image = {}, data = {}, softwareProductId, componentId, version, isReadOnlyMode}) { - - let {id} = image; - let title = id ? i18n('Edit Image') : i18n('Create New Image'); - let className = id ? 'image-modal-edit' : 'image-modal-new'; - - dispatch({ - type: actionTypes.ImageEditor.OPEN, - image: {...data, id} - }); - - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.SOFTWARE_PRODUCT_COMPONENT_IMAGE_EDITOR, - title: title, - modalClassName: className, - modalComponentProps: {softwareProductId, componentId, version, isReadOnlyMode} - } - }); - - }, - - closeImageEditor(dispatch) { - - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - - dispatch({ - type: actionTypes.ImageEditor.CLOSE - }); - - }, - - loadImageQuestionnaire(dispatch, {softwareProductId, componentId, imageId, version}) { - return fetchImageQuestionnaire({softwareProductId, componentId, imageId, version}).then((response) => { - ValidationHelper.qDataLoaded(dispatch, {qName: IMAGE_QUESTIONNAIRE ,response: { - qdata: response.data ? JSON.parse(response.data) : {}, - qschema: JSON.parse(response.schema) - }}); - }); - }, - - saveImageDataAndQuestionnaire(dispatch, {softwareProductId, componentId, version, data, qdata}) { - SoftwareProductComponentImagesActionHelper.closeImageEditor(dispatch); - if (data !== null && data.id) { - // editor in edit mode - return Promise.all([ - saveImageQuestionnaire({softwareProductId, version, componentId, imageId: data.id, qdata}), - saveImage({softwareProductId, version, componentId, image: data}).then(() => { - return SoftwareProductComponentImagesActionHelper.fetchImagesList(dispatch, {softwareProductId, componentId, version}); - }) - ]); - } else { - // editor in create mode - createImage({softwareProductId, componentId, version, data}).then(() => { - return SoftwareProductComponentImagesActionHelper.fetchImagesList(dispatch, {softwareProductId, componentId, version}); - }); - } - } + fetchImagesList(dispatch, { softwareProductId, componentId, version }) { + dispatch({ + type: actionTypes.IMAGES_LIST_UPDATE, + response: [] + }); + + return fetchImagesList({ + softwareProductId, + componentId, + version + }).then(response => { + dispatch({ + type: actionTypes.IMAGES_LIST_UPDATE, + response: response.results, + componentId: componentId + }); + }); + }, + + deleteImage( + dispatch, + { softwareProductId, componentId, version, imageId } + ) { + return destroyImage({ + softwareProductId, + componentId, + version, + imageId + }).then(() => { + return SoftwareProductComponentImagesActionHelper.fetchImagesList( + dispatch, + { softwareProductId, componentId, version } + ); + }); + }, + + loadImageData({ softwareProductId, componentId, imageId, version }) { + return fetchImage({ softwareProductId, componentId, imageId, version }); + }, + + openEditImageEditor( + dispatch, + { image, softwareProductId, componentId, version, isReadOnlyMode } + ) { + return SoftwareProductComponentImagesActionHelper.loadImageData({ + softwareProductId, + componentId, + imageId: image.id, + version + }).then(({ data }) => { + SoftwareProductComponentImagesActionHelper.loadImageQuestionnaire( + dispatch, + { + softwareProductId, + componentId, + imageId: image.id, + version + } + ).then(() => { + SoftwareProductComponentImagesActionHelper.openImageEditor( + dispatch, + { + softwareProductId, + componentId, + version, + isReadOnlyMode, + image, + data + } + ); + }); + }); + }, + + openImageEditor( + dispatch, + { + image = {}, + data = {}, + softwareProductId, + componentId, + version, + isReadOnlyMode + } + ) { + let { id } = image; + let title = id ? i18n('Edit Image') : i18n('Create New Image'); + let className = id ? 'image-modal-edit' : 'image-modal-new'; + + dispatch({ + type: actionTypes.ImageEditor.OPEN, + image: { ...data, id } + }); + + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: + modalContentMapper.SOFTWARE_PRODUCT_COMPONENT_IMAGE_EDITOR, + title: title, + modalClassName: className, + modalComponentProps: { + softwareProductId, + componentId, + version, + isReadOnlyMode + } + } + }); + }, + + closeImageEditor(dispatch) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + + dispatch({ + type: actionTypes.ImageEditor.CLOSE + }); + }, + + loadImageQuestionnaire( + dispatch, + { softwareProductId, componentId, imageId, version } + ) { + return fetchImageQuestionnaire({ + softwareProductId, + componentId, + imageId, + version + }).then(response => { + ValidationHelper.qDataLoaded(dispatch, { + qName: IMAGE_QUESTIONNAIRE, + response: { + qdata: response.data ? JSON.parse(response.data) : {}, + qschema: JSON.parse(response.schema) + } + }); + }); + }, + + saveImageDataAndQuestionnaire( + dispatch, + { softwareProductId, componentId, version, data, qdata } + ) { + SoftwareProductComponentImagesActionHelper.closeImageEditor(dispatch); + if (data !== null && data.id) { + // editor in edit mode + return Promise.all([ + saveImageQuestionnaire({ + softwareProductId, + version, + componentId, + imageId: data.id, + qdata + }), + saveImage({ + softwareProductId, + version, + componentId, + image: data + }).then(() => { + return SoftwareProductComponentImagesActionHelper.fetchImagesList( + dispatch, + { softwareProductId, componentId, version } + ); + }) + ]); + } else { + // editor in create mode + createImage({ softwareProductId, componentId, version, data }).then( + () => { + return SoftwareProductComponentImagesActionHelper.fetchImagesList( + dispatch, + { softwareProductId, componentId, version } + ); + } + ); + } + } }; export default SoftwareProductComponentImagesActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageConstants.js index 6b6c9a30e5..300b2898e1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageConstants.js @@ -16,12 +16,12 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - IMAGES_LIST_UPDATE: null, + IMAGES_LIST_UPDATE: null, - ImageEditor: { - CLOSE: null, - OPEN: null - } + ImageEditor: { + CLOSE: null, + OPEN: null + } }); export const IMAGE_QUESTIONNAIRE = 'image'; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditor.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditor.js index c5f23e7681..0243a38f1b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditor.js @@ -13,56 +13,93 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import SoftwareProductComponentsImageActionHelper from './SoftwareProductComponentsImageActionHelper.js'; import SoftwareProductComponentsImageEditorView from './SoftwareProductComponentsImageEditorView.jsx'; -import {onboardingMethod as onboardingMethodTypes} from '../../SoftwareProductConstants.js'; -import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; -import {IMAGE_QUESTIONNAIRE} from './SoftwareProductComponentsImageConstants.js'; +import { onboardingMethod as onboardingMethodTypes } from '../../SoftwareProductConstants.js'; +import { forms } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { IMAGE_QUESTIONNAIRE } from './SoftwareProductComponentsImageConstants.js'; export const mapStateToProps = ({ - softwareProduct, - currentScreen: {props: {isReadOnlyMode}} + softwareProduct, + currentScreen: { props: { isReadOnlyMode } } }) => { + let { + softwareProductEditor: { + data: currentSoftwareProduct = {}, + isValidityData = true + }, + softwareProductComponents + } = softwareProduct; - let {softwareProductEditor: {data:currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents} = softwareProduct; - - let {images: {imageEditor = {}}} = softwareProductComponents; - let {data, qdata, genericFieldInfo, qgenericFieldInfo, dataMap, formReady} = imageEditor; - let {version, onboardingMethod} = currentSoftwareProduct; - let isManual = onboardingMethod === onboardingMethodTypes.MANUAL; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo) && ValidationHelper.checkFormValid(qgenericFieldInfo); - - return { - version, - currentSoftwareProduct, - isValidityData, - data, - qdata, - dataMap, - isFormValid, - formReady, - genericFieldInfo, - qgenericFieldInfo, - isReadOnlyMode, - isManual: isManual - }; + let { images: { imageEditor = {} } } = softwareProductComponents; + let { + data, + qdata, + genericFieldInfo, + qgenericFieldInfo, + dataMap, + formReady + } = imageEditor; + let { version, onboardingMethod } = currentSoftwareProduct; + let isManual = onboardingMethod === onboardingMethodTypes.MANUAL; + let isFormValid = + ValidationHelper.checkFormValid(genericFieldInfo) && + ValidationHelper.checkFormValid(qgenericFieldInfo); + return { + version, + currentSoftwareProduct, + isValidityData, + data, + qdata, + dataMap, + isFormValid, + formReady, + genericFieldInfo, + qgenericFieldInfo, + isReadOnlyMode, + isManual: isManual + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, componentId, version}) => { - return { - onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: forms.IMAGE_EDIT_FORM}), - onSubmit: ({data, qdata}) => SoftwareProductComponentsImageActionHelper.saveImageDataAndQuestionnaire(dispatch, {softwareProductId, componentId, version, data, qdata}), - onCancel: () => SoftwareProductComponentsImageActionHelper.closeImageEditor(dispatch), - onValidateForm: customValidations => { - ValidationHelper.validateForm(dispatch, forms.IMAGE_EDIT_FORM); - ValidationHelper.qValidateForm(dispatch, IMAGE_QUESTIONNAIRE, customValidations); - }, - onQDataChanged: (deltaData, customValidations) => ValidationHelper.qDataChanged(dispatch, {deltaData, - qName: IMAGE_QUESTIONNAIRE, customValidations}), - }; +const mapActionsToProps = ( + dispatch, + { softwareProductId, componentId, version } +) => { + return { + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: forms.IMAGE_EDIT_FORM + }), + onSubmit: ({ data, qdata }) => + SoftwareProductComponentsImageActionHelper.saveImageDataAndQuestionnaire( + dispatch, + { softwareProductId, componentId, version, data, qdata } + ), + onCancel: () => + SoftwareProductComponentsImageActionHelper.closeImageEditor( + dispatch + ), + onValidateForm: customValidations => { + ValidationHelper.validateForm(dispatch, forms.IMAGE_EDIT_FORM); + ValidationHelper.qValidateForm( + dispatch, + IMAGE_QUESTIONNAIRE, + customValidations + ); + }, + onQDataChanged: (deltaData, customValidations) => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + qName: IMAGE_QUESTIONNAIRE, + customValidations + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(SoftwareProductComponentsImageEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + SoftwareProductComponentsImageEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditorReducer.js index 7c357429e5..3846d45772 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditorReducer.js @@ -13,30 +13,29 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductComponentsImageConstants.js'; -import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { actionTypes } from './SoftwareProductComponentsImageConstants.js'; +import { forms } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.ImageEditor.CLOSE: - return {}; - case actionTypes.ImageEditor.OPEN: - return { - ...state, - data: { - ...action.image - }, - genericFieldInfo: { - 'fileName' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - } - }, - formName: forms.IMAGE_EDIT_FORM - }; - default: - return state; - } + switch (action.type) { + case actionTypes.ImageEditor.CLOSE: + return {}; + case actionTypes.ImageEditor.OPEN: + return { + ...state, + data: { + ...action.image + }, + genericFieldInfo: { + fileName: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + } + }, + formName: forms.IMAGE_EDIT_FORM + }; + default: + return state; + } }; - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditorView.jsx index a5ef152e01..3670ab910d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageEditorView.jsx @@ -21,53 +21,81 @@ import Form from 'nfvo-components/input/validation/Form.jsx'; import FileDetails from './imagesEditorComponents/FileDetails.jsx'; import ImageDetails from './imagesEditorComponents/ImageDetails.jsx'; -import {imageCustomValidations} from './ImageValidations.js'; +import { imageCustomValidations } from './ImageValidations.js'; class SoftwareProductComponentsImageEditorView extends React.Component { - static propTypes = { - onDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired - }; + static propTypes = { + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired + }; - render() { - let {onCancel, onValidateForm, isReadOnlyMode, isFormValid, formReady, data = {}, genericFieldInfo, qgenericFieldInfo, dataMap, onDataChanged, isManual, onQDataChanged} = this.props; - let {id, fileName} = data; - let editingMode = Boolean(id); - return ( -
    - {genericFieldInfo &&
    { this.form = form; }} - hasButtons={true} - onSubmit={ () => this.submit() } - onReset={ () => onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - isValid={isFormValid} - formReady={formReady} - submitButtonText={editingMode ? i18n('Save') : i18n('Create')} - onValidateForm={() => onValidateForm(imageCustomValidations) } - className='vsp-components-image-editor'> -
    - - {editingMode && } -
    -
    } -
    - ); - } - submit() { - let {data, qdata, onSubmit, version} = this.props; - onSubmit({data, qdata, version}); - } + render() { + let { + onCancel, + onValidateForm, + isReadOnlyMode, + isFormValid, + formReady, + data = {}, + genericFieldInfo, + qgenericFieldInfo, + dataMap, + onDataChanged, + isManual, + onQDataChanged + } = this.props; + let { id, fileName } = data; + let editingMode = Boolean(id); + return ( +
    + {genericFieldInfo && ( +
    { + this.form = form; + }} + hasButtons={true} + onSubmit={() => this.submit()} + onReset={() => onCancel()} + labledButtons={true} + isReadOnlyMode={isReadOnlyMode} + isValid={isFormValid} + formReady={formReady} + submitButtonText={ + editingMode ? i18n('Save') : i18n('Create') + } + onValidateForm={() => + onValidateForm(imageCustomValidations) + } + className="vsp-components-image-editor"> +
    + + {editingMode && ( + + )} +
    +
    + )} +
    + ); + } + submit() { + let { data, qdata, onSubmit, version } = this.props; + onSubmit({ data, qdata, version }); + } } export default SoftwareProductComponentsImageEditorView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageList.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageList.js index d071647058..f3c39c3048 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageList.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageList.js @@ -13,73 +13,122 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import SoftwareProductComponentsImageListView from './SoftwareProductComponentsImageListView.jsx'; import ImageHelper from './SoftwareProductComponentsImageActionHelper.js'; import SoftwareProductComponentsImagesActionHelper from './SoftwareProductComponentsImageActionHelper.js'; import SoftwareProductComponentsActionHelper from '../SoftwareProductComponentsActionHelper.js'; -import {COMPONENTS_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { COMPONENTS_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {onboardingMethod as onboardingMethodTypes} from '../../SoftwareProductConstants.js'; +import { onboardingMethod as onboardingMethodTypes } from '../../SoftwareProductConstants.js'; -export const mapStateToProps = ({softwareProduct}) => { +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductEditor: { + data: currentSoftwareProduct = {}, + isValidityData = true + }, + softwareProductComponents + } = softwareProduct; + let { + images: { imagesList = [] }, + componentEditor: { + data: componentData, + qdata, + dataMap, + qgenericFieldInfo + } + } = softwareProductComponents; + let { onboardingMethod } = currentSoftwareProduct; + let isManual = onboardingMethod === onboardingMethodTypes.MANUAL; - let {softwareProductEditor: {data: currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents} = softwareProduct; - let {images: {imagesList = []}, componentEditor: {data: componentData, qdata, dataMap, qgenericFieldInfo}} = softwareProductComponents; - let {onboardingMethod} = currentSoftwareProduct; - let isManual = onboardingMethod === onboardingMethodTypes.MANUAL; - - return { - componentData, - qdata, - dataMap, - qgenericFieldInfo, - isValidityData, - imagesList, - isManual : isManual - }; + return { + componentData, + qdata, + dataMap, + qgenericFieldInfo, + isValidityData, + imagesList, + isManual: isManual + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, componentId, version}) => { - return { - onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, - qName: COMPONENTS_QUESTIONNAIRE}), - onAddImage: (isReadOnlyMode) => { - SoftwareProductComponentsImagesActionHelper.openImageEditor(dispatch, - {isReadOnlyMode, softwareProductId, - componentId, version} - );}, - onDeleteImage: (image) => { - let shortenedFileName = (image.fileName.length > 40) ? image.fileName.substr(0,40) + '...' : image.fileName; - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data: { - msg: i18n('Are you sure you want to delete "{shortenedFileName}"?', {shortenedFileName: shortenedFileName}), - onConfirmed: () => ImageHelper.deleteImage(dispatch, { - softwareProductId, - componentId, - version, - imageId: image.id - }) - } - }); - }, - onEditImageClick: (image, isReadOnlyMode) => { - SoftwareProductComponentsImagesActionHelper.openEditImageEditor(dispatch, { - image, isReadOnlyMode, softwareProductId, componentId, version, modalClassName: 'image-modal-edit'} - ); - }, - onSubmit: (qdata) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, - {softwareProductId, - vspComponentId: componentId, - version, - qdata}); - } - }; +const mapActionsToProps = ( + dispatch, + { softwareProductId, componentId, version } +) => { + return { + onQDataChanged: deltaData => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + qName: COMPONENTS_QUESTIONNAIRE + }), + onAddImage: isReadOnlyMode => { + SoftwareProductComponentsImagesActionHelper.openImageEditor( + dispatch, + { + isReadOnlyMode, + softwareProductId, + componentId, + version + } + ); + }, + onDeleteImage: image => { + let shortenedFileName = + image.fileName.length > 40 + ? image.fileName.substr(0, 40) + '...' + : image.fileName; + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + msg: i18n( + 'Are you sure you want to delete "{shortenedFileName}"?', + { + shortenedFileName: shortenedFileName + } + ), + onConfirmed: () => + ImageHelper.deleteImage(dispatch, { + softwareProductId, + componentId, + version, + imageId: image.id + }) + } + }); + }, + onEditImageClick: (image, isReadOnlyMode) => { + SoftwareProductComponentsImagesActionHelper.openEditImageEditor( + dispatch, + { + image, + isReadOnlyMode, + softwareProductId, + componentId, + version, + modalClassName: 'image-modal-edit' + } + ); + }, + onSubmit: qdata => { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire( + dispatch, + { + softwareProductId, + vspComponentId: componentId, + version, + qdata + } + ); + } + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductComponentsImageListView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductComponentsImageListView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListReducer.js index 5dd2fb623b..a7c1bfafbe 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListReducer.js @@ -13,14 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductComponentsImageConstants.js'; +import { actionTypes } from './SoftwareProductComponentsImageConstants.js'; export default (state = [], action) => { - switch (action.type) { - - case actionTypes.IMAGES_LIST_UPDATE: - return [...action.response]; - default: - return state; - } + switch (action.type) { + case actionTypes.IMAGES_LIST_UPDATE: + return [...action.response]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListView.jsx index 004cbebe5d..cb67856caa 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/SoftwareProductComponentsImageListView.jsx @@ -20,113 +20,152 @@ import Form from 'nfvo-components/input/validation/Form.jsx'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; -import Input from'nfvo-components/input/validation/Input.jsx'; +import Input from 'nfvo-components/input/validation/Input.jsx'; class SoftwareProductComponentsImageListView extends React.Component { - state = { - localFilter: '' - }; + state = { + localFilter: '' + }; - render() { - let {dataMap, onQDataChanged, isReadOnlyMode, qgenericFieldInfo} = this.props; - return( -
    -
    -
    - { qgenericFieldInfo &&
    this.save()} - isReadOnlyMode={isReadOnlyMode} - hasButtons={false}> - -

    {i18n('Image')}

    -
    -
    -
    - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({'general/image/providedBy' : val});} - }> - - { qgenericFieldInfo['general/image/providedBy'].enum.map(proto => - ) } - -
    -
    -
    -
    - - } -
    -
    - {this.renderImagesList()} + render() { + let { + dataMap, + onQDataChanged, + isReadOnlyMode, + qgenericFieldInfo + } = this.props; + return ( +
    +
    +
    + {qgenericFieldInfo && ( +
    this.save()} + isReadOnlyMode={isReadOnlyMode} + hasButtons={false}> +

    + {i18n('Image')} +

    +
    +
    +
    + { + const selectedIndex = + e.target.selectedIndex; + const val = + e.target.options[ + selectedIndex + ].value; + onQDataChanged({ + 'general/image/providedBy': val + }); + }}> + + {qgenericFieldInfo[ + 'general/image/providedBy' + ].enum.map(proto => ( + + ))} + +
    +
    +
    +
    + + )} +
    +
    + {this.renderImagesList()}
    - ); - }; - - renderImagesList() { - const {localFilter} = this.state; - let {isReadOnlyMode, onAddImage, isManual} = this.props; - - return ( - this.setState({localFilter: value})} - onAdd={isManual ? () => onAddImage(isReadOnlyMode) : null} - plusButtonTitle={i18n('Add Image')} - twoColumns> - {this.filterList().map(image => this.renderImagesListItem(image, isReadOnlyMode))} - - ); - }; + ); + } + renderImagesList() { + const { localFilter } = this.state; + let { isReadOnlyMode, onAddImage, isManual } = this.props; - renderImagesListItem(image, isReadOnlyMode) { - let {id, fileName} = image; - let {onEditImageClick, isManual, onDeleteImage} = this.props; - return ( - onEditImageClick(image, isReadOnlyMode)} - onDelete={isManual ? () => onDeleteImage(image) : null}> + return ( + this.setState({ localFilter: value })} + onAdd={isManual ? () => onAddImage(isReadOnlyMode) : null} + plusButtonTitle={i18n('Add Image')} + twoColumns> + {this.filterList().map(image => + this.renderImagesListItem(image, isReadOnlyMode) + )} + + ); + } - -
    {fileName}
    -
    -
    - ); - } + renderImagesListItem(image, isReadOnlyMode) { + let { id, fileName } = image; + let { onEditImageClick, isManual, onDeleteImage } = this.props; + return ( + onEditImageClick(image, isReadOnlyMode)} + onDelete={isManual ? () => onDeleteImage(image) : null}> + +
    + {fileName} +
    +
    +
    + ); + } - filterList() { - let {imagesList} = this.props; - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return imagesList.filter(({fileName = ''}) => { - return escape(fileName).match(filter); - }); - } - else { - return imagesList; - } - } + filterList() { + let { imagesList } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return imagesList.filter(({ fileName = '' }) => { + return escape(fileName).match(filter); + }); + } else { + return imagesList; + } + } - save() { - let {onSubmit, qdata} = this.props; - return onSubmit(qdata); - } + save() { + let { onSubmit, qdata } = this.props; + return onSubmit(qdata); + } } export default SoftwareProductComponentsImageListView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/FileDetails.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/FileDetails.jsx index 64367c00f2..ec173cd988 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/FileDetails.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/FileDetails.jsx @@ -18,32 +18,64 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { forms } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; import Format from './Format.jsx'; import Version from './Version.jsx'; -const FileDetails = ({editingMode, fileName, onDataChanged, isManual, dataMap, onQDataChanged, genericFieldInfo, qgenericFieldInfo}) => { - let fileNameCols = (editingMode) ? 3 : 4; - return( - - - onDataChanged({fileName}, forms.IMAGE_EDIT_FORM)} - label={i18n('Image Name')} - data-test-id='image-filename' - value={fileName} - isValid={genericFieldInfo.fileName.isValid} - errorText={genericFieldInfo.fileName.errorText} - isRequired={true} - type='text' - className='image-filename'/> - - {!editingMode &&
    {i18n('After image creation you must go to Edit Image and add File Version')}
    } - {editingMode && } - {editingMode && } -
    - ); +const FileDetails = ({ + editingMode, + fileName, + onDataChanged, + isManual, + dataMap, + onQDataChanged, + genericFieldInfo, + qgenericFieldInfo +}) => { + let fileNameCols = editingMode ? 3 : 4; + return ( + + + + onDataChanged({ fileName }, forms.IMAGE_EDIT_FORM) + } + label={i18n('Image Name')} + data-test-id="image-filename" + value={fileName} + isValid={genericFieldInfo.fileName.isValid} + errorText={genericFieldInfo.fileName.errorText} + isRequired={true} + type="text" + className="image-filename" + /> + + {!editingMode && ( +
    + {i18n( + 'After image creation you must go to Edit Image and add File Version' + )} +
    + )} + {editingMode && ( + + )} + {editingMode && ( + + )} +
    + ); }; export default FileDetails; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/Format.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/Format.jsx index 1f71c6b277..0ee8fb76d0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/Format.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/Format.jsx @@ -18,30 +18,34 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; - -const Format = ({isManual, dataMap, qgenericFieldInfo, onQDataChanged}) => { - return( - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({'format' : val});} - }> - - {qgenericFieldInfo['format'].enum.map(hv => )} - - - ); +const Format = ({ isManual, dataMap, qgenericFieldInfo, onQDataChanged }) => { + return ( + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({ format: val }); + }}> + + {qgenericFieldInfo['format'].enum.map(hv => ( + + ))} + + + ); }; export default Format; - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/ImageDetails.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/ImageDetails.jsx index 24e54bbbcb..ccf94bc860 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/ImageDetails.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/ImageDetails.jsx @@ -19,21 +19,22 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -const ImageDetails = ({dataMap, qgenericFieldInfo, onQDataChanged}) => { - return( - - - onQDataChanged({'md5' : md5})} - isValid={qgenericFieldInfo['md5'].isValid} - errorText={qgenericFieldInfo['md5'].errorText} - value={dataMap['md5']}/> - - - ); +const ImageDetails = ({ dataMap, qgenericFieldInfo, onQDataChanged }) => { + return ( + + + onQDataChanged({ md5: md5 })} + isValid={qgenericFieldInfo['md5'].isValid} + errorText={qgenericFieldInfo['md5'].errorText} + value={dataMap['md5']} + /> + + + ); }; export default ImageDetails; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/Version.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/Version.jsx index bd55c5ba91..60454c52e7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/Version.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/images/imagesEditorComponents/Version.jsx @@ -17,25 +17,29 @@ import React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Input from 'nfvo-components/input/validation/Input.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {imageCustomValidations} from '../ImageValidations.js'; +import { imageCustomValidations } from '../ImageValidations.js'; - -const Version = ({isManual, dataMap, qgenericFieldInfo, onQDataChanged}) => { - return( - - onQDataChanged({'version' : version}, {'version' : imageCustomValidations['version']})} - isValid={qgenericFieldInfo['version'].isValid} - errorText={qgenericFieldInfo['version'].errorText} - value={dataMap['version']}/> - - ); +const Version = ({ isManual, dataMap, qgenericFieldInfo, onQDataChanged }) => { + return ( + + + onQDataChanged( + { version: version }, + { version: imageCustomValidations['version'] } + ) + } + isValid={qgenericFieldInfo['version'].isValid} + errorText={qgenericFieldInfo['version'].errorText} + value={dataMap['version']} + /> + + ); }; export default Version; - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js index 350e80c0f8..da8b73fbe0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js @@ -13,29 +13,50 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductComponentLoadBalancingView from './SoftwareProductComponentLoadBalancingRefView.jsx'; import SoftwareProductComponentsActionHelper from '../SoftwareProductComponentsActionHelper.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {COMPONENTS_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { COMPONENTS_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; -export const mapStateToProps = ({softwareProduct: {softwareProductComponents}}) => { - - let {componentEditor: {qdata, qgenericFieldInfo: genericFieldInfo, dataMap}} = softwareProductComponents; - - return { - qdata, - genericFieldInfo, - dataMap - }; +export const mapStateToProps = ({ + softwareProduct: { softwareProductComponents } +}) => { + let { + componentEditor: { qdata, qgenericFieldInfo: genericFieldInfo, dataMap } + } = softwareProductComponents; + return { + qdata, + genericFieldInfo, + dataMap + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, version, componentId}) => { - return { - onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, qName: COMPONENTS_QUESTIONNAIRE}), - onSubmit: ({qdata}) =>{ return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId: componentId, qdata});} - }; +const mapActionsToProps = ( + dispatch, + { softwareProductId, version, componentId } +) => { + return { + onQDataChanged: deltaData => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + qName: COMPONENTS_QUESTIONNAIRE + }), + onSubmit: ({ qdata }) => { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire( + dispatch, + { + softwareProductId, + version, + vspComponentId: componentId, + qdata + } + ); + } + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductComponentLoadBalancingView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductComponentLoadBalancingView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancingRefView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancingRefView.jsx index 1cbb9afc5d..4c90fc0be2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancingRefView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancingRefView.jsx @@ -19,7 +19,7 @@ import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; 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'; +import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; @@ -27,145 +27,244 @@ import GridItem from 'nfvo-components/grid/GridItem.jsx'; const prefix = 'highAvailabilityAndLoadBalancing/'; const pointers = [ - { - key: 'failureLoadDistribution', - description: 'How is load distributed across live vms in the event of a vm/host failure? please describe' - }, - { - key: 'nkModelImplementation', - description: 'Does each VM implement the N+K model for redundancy and failure protection? Please describe.' - }, - { - key: 'architectureChoice', - description: 'What architecture is being implemented: ACTIVE-ACTIVE and/or ACTIVE-PASSIVE. ', - added: 'Will the arrangement be 1-1 or N-M? Please describe.' - }, - {key: 'slaRequirements', description: 'Specify application SLA requirements on Cloud platform.'}, - { - key: 'horizontalScaling', - description: 'Is horizontal scaling the preferred solution for HA and resiliency? Please describe.' - }, - { - key: 'loadDistributionMechanism', - description: 'Can load be distributed across VMs? If so, are special mechanisms needed to re-balance data across VMs?', - added: 'Please describe.' - } + { + key: 'failureLoadDistribution', + description: + 'How is load distributed across live vms in the event of a vm/host failure? please describe' + }, + { + key: 'nkModelImplementation', + description: + 'Does each VM implement the N+K model for redundancy and failure protection? Please describe.' + }, + { + key: 'architectureChoice', + description: + 'What architecture is being implemented: ACTIVE-ACTIVE and/or ACTIVE-PASSIVE. ', + added: 'Will the arrangement be 1-1 or N-M? Please describe.' + }, + { + key: 'slaRequirements', + description: 'Specify application SLA requirements on Cloud platform.' + }, + { + key: 'horizontalScaling', + description: + 'Is horizontal scaling the preferred solution for HA and resiliency? Please describe.' + }, + { + key: 'loadDistributionMechanism', + description: + 'Can load be distributed across VMs? If so, are special mechanisms needed to re-balance data across VMs?', + added: 'Please describe.' + } ]; //TODO check for buttons -const TextAreaItem = ({item, toggle, expanded, genericFieldInfo, dataMap, onQDataChanged}) => ( - -
    toggle(item.key)}> - - {i18n(item.description)} - {item.added &&
    {i18n(item.added)}
    } -
    -
    -
    -
    - onQDataChanged({[`${prefix}${item.key}`] : val})} /> -
    -
    -
    -
    +const TextAreaItem = ({ + item, + toggle, + expanded, + genericFieldInfo, + dataMap, + onQDataChanged +}) => ( + +
    toggle(item.key)}> + + {i18n(item.description)} + {item.added &&
    {i18n(item.added)}
    } +
    +
    +
    +
    + + onQDataChanged({ [`${prefix}${item.key}`]: val }) + } + /> +
    +
    +
    +
    ); class SoftwareProductComponentLoadBalancingView extends React.Component { - static propTypes = { - componentId: PropTypes.string.isRequired, - softwareProductId: PropTypes.string.isRequired, - qdata: PropTypes.object, - qschema: PropTypes.object, - currentSoftwareProduct: PropTypes.object - }; + static propTypes = { + componentId: PropTypes.string.isRequired, + softwareProductId: PropTypes.string.isRequired, + qdata: PropTypes.object, + qschema: PropTypes.object, + currentSoftwareProduct: PropTypes.object + }; - state = { - expanded: {} - }; + state = { + expanded: {} + }; - render() { - let {dataMap, genericFieldInfo, onQDataChanged, isReadOnlyMode} = this.props; - return ( -
    -
    - { genericFieldInfo &&
    this.save()} - isReadOnlyMode={isReadOnlyMode} - hasButtons={false}> - - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({[`${prefix}isComponentMandatory`] : val});} - }> - - { genericFieldInfo[`${prefix}isComponentMandatory`].enum.map(isMan => ) } - - - - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({[`${prefix}highAvailabilityMode`] : val});} - }> - - {genericFieldInfo[`${prefix}highAvailabilityMode`].enum.map(hmode => )} - - - - - - {pointers.map(pointer => {this.toggle(name);}} />)} - -
    } -
    -
    - ); - } + render() { + let { + dataMap, + genericFieldInfo, + onQDataChanged, + isReadOnlyMode + } = this.props; + return ( +
    +
    + {genericFieldInfo && ( +
    this.save()} + isReadOnlyMode={isReadOnlyMode} + hasButtons={false}> + + + { + const selectedIndex = + e.target.selectedIndex; + const val = + e.target.options[selectedIndex] + .value; + onQDataChanged({ + [`${prefix}isComponentMandatory`]: val + }); + }}> + + {genericFieldInfo[ + `${prefix}isComponentMandatory` + ].enum.map(isMan => ( + + ))} + + + + + { + const selectedIndex = + e.target.selectedIndex; + const val = + e.target.options[selectedIndex] + .value; + onQDataChanged({ + [`${prefix}highAvailabilityMode`]: val + }); + }}> + + {genericFieldInfo[ + `${prefix}highAvailabilityMode` + ].enum.map(hmode => ( + + ))} + + + + + + {pointers.map(pointer => ( + { + this.toggle(name); + }} + /> + ))} + +
    + )} +
    +
    + ); + } - toggle(name) { - let st = this.state.expanded[name] ? true : false; - let newState = {...this.state}; - newState.expanded[name] = !st; - this.setState(newState); - } + toggle(name) { + let st = this.state.expanded[name] ? true : false; + let newState = { ...this.state }; + newState.expanded[name] = !st; + this.setState(newState); + } - save() { - let {onSubmit, qdata} = this.props; - return onSubmit({qdata}); - } + save() { + let { onSubmit, qdata } = this.props; + return onSubmit({ qdata }); + } } export default SoftwareProductComponentLoadBalancingView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js index 8871aabbb5..0b0b9ae2d9 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js @@ -13,51 +13,54 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductComponentsMonitoringView from './SoftwareProductComponentsMonitoringView.jsx'; import SoftwareProductComponentsMonitoringAction from './SoftwareProductComponentsMonitoringActionHelper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; - - -export const mapStateToProps = ({softwareProduct}) => { - - let {softwareProductComponents: {monitoring}} = softwareProduct; - return { - filenames: monitoring - }; - +export const mapStateToProps = ({ softwareProduct }) => { + let { softwareProductComponents: { monitoring } } = softwareProduct; + return { + filenames: monitoring + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, version, componentId}) => { - - return { - onDropMibFileToUpload: (formData, type) => - SoftwareProductComponentsMonitoringAction.uploadFile(dispatch, { - softwareProductId, - version, - componentId, - formData, - type - }), - - onDeleteFile: type => SoftwareProductComponentsMonitoringAction.deleteFile(dispatch, { - softwareProductId, - version, - componentId, - type - }), +const mapActionsToProps = ( + dispatch, + { softwareProductId, version, componentId } +) => { + return { + onDropMibFileToUpload: (formData, type) => + SoftwareProductComponentsMonitoringAction.uploadFile(dispatch, { + softwareProductId, + version, + componentId, + formData, + type + }), - onFileUploadError: () => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - title: i18n('Upload Failed'), - msg: i18n('Expected "zip" file. Please check the provided file type.') - } - }) - }; + onDeleteFile: type => + SoftwareProductComponentsMonitoringAction.deleteFile(dispatch, { + softwareProductId, + version, + componentId, + type + }), + onFileUploadError: () => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('Upload Failed'), + msg: i18n( + 'Expected "zip" file. Please check the provided file type.' + ) + } + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductComponentsMonitoringView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductComponentsMonitoringView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js index 3db708bc92..c60bc5f1be 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js @@ -16,61 +16,90 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from './SoftwareProductComponentsMonitoringConstants.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes } from './SoftwareProductComponentsMonitoringConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; function baseUrl(vspId, version, componentId) { - const versionId = version.id; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/components/${componentId}/uploads`; + const versionId = version.id; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/components/${componentId}/uploads`; } -let onInvalidFileSizeUpload = (dispatch) => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - title: i18n('Upload Failed'), - msg: i18n('no zip file was uploaded or zip file doesn\'t exist') - } -}); +let onInvalidFileSizeUpload = dispatch => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('Upload Failed'), + msg: i18n("no zip file was uploaded or zip file doesn't exist") + } + }); -let uploadFile = (dispatch, {softwareProductId, version, componentId, formData, type}) => { - return RestAPIUtil.post(`${baseUrl(softwareProductId, version, componentId)}/types/${type}`, formData).then(()=> dispatch({ - type: actionTypes.MONITOR_UPLOADED, data: {filename: formData.get('upload').name, type : type} - })); +let uploadFile = ( + dispatch, + { softwareProductId, version, componentId, formData, type } +) => { + return RestAPIUtil.post( + `${baseUrl(softwareProductId, version, componentId)}/types/${type}`, + formData + ).then(() => + dispatch({ + type: actionTypes.MONITOR_UPLOADED, + data: { filename: formData.get('upload').name, type: type } + }) + ); }; -let deleteFile = (dispatch, {softwareProductId, version, componentId, type}) => { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version, componentId)}/types/${type}`).then(()=> dispatch({ - type: actionTypes.MONITOR_DELETED, - data : { type: type} - })); +let deleteFile = ( + dispatch, + { softwareProductId, version, componentId, type } +) => { + return RestAPIUtil.destroy( + `${baseUrl(softwareProductId, version, componentId)}/types/${type}` + ).then(() => + dispatch({ + type: actionTypes.MONITOR_DELETED, + data: { type: type } + }) + ); }; - const SoftwareProductComponentsMonitoringAction = { + fetchExistingFiles(dispatch, { softwareProductId, version, componentId }) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, version, componentId)}` + ).then(response => + dispatch({ + type: actionTypes.MONITOR_FILES_DATA_CHANGE, + data: response + }) + ); + }, - fetchExistingFiles(dispatch, {softwareProductId, version, componentId}){ - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}`).then(response => - dispatch({ - type: actionTypes.MONITOR_FILES_DATA_CHANGE, - data: response - }) - ); - }, - - uploadFile(dispatch, {softwareProductId, version, componentId, formData, type}){ - if (formData.get('upload').size) { - return uploadFile(dispatch, {softwareProductId, version, componentId, formData, type}); - } - else { - onInvalidFileSizeUpload(dispatch); - } - }, - - deleteFile(dispatch, {softwareProductId, version, componentId, type}){ - return deleteFile(dispatch, {softwareProductId, version, componentId, type}); - } + uploadFile( + dispatch, + { softwareProductId, version, componentId, formData, type } + ) { + if (formData.get('upload').size) { + return uploadFile(dispatch, { + softwareProductId, + version, + componentId, + formData, + type + }); + } else { + onInvalidFileSizeUpload(dispatch); + } + }, + deleteFile(dispatch, { softwareProductId, version, componentId, type }) { + return deleteFile(dispatch, { + softwareProductId, + version, + componentId, + type + }); + } }; export default SoftwareProductComponentsMonitoringAction; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js index bf2cbd2a3f..10049d6b57 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js @@ -16,29 +16,26 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; - export const actionTypes = keyMirror({ - MONITOR_FILES_DATA_CHANGE: null, - MONITOR_UPLOADED: null, - MONITOR_DELETED: null + MONITOR_FILES_DATA_CHANGE: null, + MONITOR_UPLOADED: null, + MONITOR_DELETED: null }); export const fileTypes = { - SNMP_TRAP: 'SNMP_TRAP', - SNMP_POLL: 'SNMP_POLL', - VES_EVENT: 'VES_EVENTS' + SNMP_TRAP: 'SNMP_TRAP', + SNMP_POLL: 'SNMP_POLL', + VES_EVENT: 'VES_EVENTS' }; export const type2Name = { - SNMP_TRAP: 'snmpTrap', - SNMP_POLL: 'snmpPoll', - VES_EVENTS: 'vesEvent' + SNMP_TRAP: 'snmpTrap', + SNMP_POLL: 'snmpPoll', + VES_EVENTS: 'vesEvent' }; - export const type2Title = { - SNMP_TRAP : i18n('SNMP Trap'), - SNMP_POLL : i18n('SNMP Poll'), - VES_EVENTS: i18n('VES') + SNMP_TRAP: i18n('SNMP Trap'), + SNMP_POLL: i18n('SNMP Poll'), + VES_EVENTS: i18n('VES') }; - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringReducer.js index f5cfe6f06d..61ad4ec2d9 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringReducer.js @@ -13,23 +13,26 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, type2Name} from './SoftwareProductComponentsMonitoringConstants.js'; +import { + actionTypes, + type2Name +} from './SoftwareProductComponentsMonitoringConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.MONITOR_FILES_DATA_CHANGE: - return action.data; - case actionTypes.MONITOR_UPLOADED: - return { - ...state, - [type2Name[action.data.type]]: action.data.filename - }; - case actionTypes.MONITOR_DELETED: - return { - ...state, - [type2Name[action.data.type]]: undefined - }; - default: - return state; - } + switch (action.type) { + case actionTypes.MONITOR_FILES_DATA_CHANGE: + return action.data; + case actionTypes.MONITOR_UPLOADED: + return { + ...state, + [type2Name[action.data.type]]: action.data.filename + }; + case actionTypes.MONITOR_DELETED: + return { + ...state, + [type2Name[action.data.type]]: undefined + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx index 95d1e4e283..771bca161a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx @@ -13,123 +13,133 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import Dropzone from 'react-dropzone'; import Button from 'sdc-ui/lib/react/Button.js'; import DraggableUploadFileBox from 'nfvo-components/fileupload/DraggableUploadFileBox.jsx'; -import {fileTypes, type2Title, type2Name} from './SoftwareProductComponentsMonitoringConstants.js'; - - +import { + fileTypes, + type2Title, + type2Name +} from './SoftwareProductComponentsMonitoringConstants.js'; class SoftwareProductComponentsMonitoringView extends Component { - - static propTypes = { - isReadOnlyMode: PropTypes.bool, - filenames: PropTypes.object, - softwareProductId: PropTypes.string, - - onDropMibFileToUpload: PropTypes.func, - onDeleteSnmpFile: PropTypes.func - }; - - state = { - dragging: false - }; - - - - - render() { - return ( -
    - {this.renderDropzoneWithType(fileTypes.VES_EVENT)} - {this.renderDropzoneWithType(fileTypes.SNMP_TRAP)} - {this.renderDropzoneWithType(fileTypes.SNMP_POLL)} -
    - ); - } - - renderDropzoneWithType(type) { - let {isReadOnlyMode, filenames} = this.props; - let fileByType = type2Name[type]; - let fileName = (filenames) ? filenames[fileByType] : undefined; - let refAndName = `fileInput${type.toString()}`; - let typeDisplayName = type2Title[type]; - return ( - this.handleImport(acceptedFiles, rejectedFiles, {isReadOnlyMode, type, refAndName})} - onDragEnter={() => this.handleOnDragEnter(isReadOnlyMode)} - onDragLeave={() => this.setState({dragging:false})} - multiple={false} - disableClick={true} - ref={refAndName} - name={refAndName} - accept='.zip'> -
    -
    {typeDisplayName}
    - {fileName ? this.renderUploadedFileName(fileName, type, isReadOnlyMode) : this.renderUploadButton(refAndName)} -
    -
    - ); - } - - renderUploadButton(refAndName) { - let {isReadOnlyMode} = this.props; - return ( - this.refs[refAndName].open()}/> - ); - } - - renderUploadedFileName(filename, type, isReadOnlyMode) { - return ( -
    - - -
    - ); - } - - - handleOnDragEnter(isReadOnlyMode) { - if (!isReadOnlyMode) { - this.setState({dragging: true}); - } - } - - handleImport(files, rejectedFiles, {isReadOnlyMode, type, refAndName}) { - if (isReadOnlyMode) { - return; - } - if (files.length > 0) { - this.setState({dragging: false}); - let file = files[0]; - let formData = new FormData(); - formData.append('upload', file); - this.refs[refAndName].value = ''; - this.props.onDropMibFileToUpload(formData, type); - } else if (rejectedFiles.length > 0) { - this.setState({dragging: false}); - this.props.onFileUploadError(); - } - } + static propTypes = { + isReadOnlyMode: PropTypes.bool, + filenames: PropTypes.object, + softwareProductId: PropTypes.string, + + onDropMibFileToUpload: PropTypes.func, + onDeleteSnmpFile: PropTypes.func + }; + + state = { + dragging: false + }; + + render() { + return ( +
    + {this.renderDropzoneWithType(fileTypes.VES_EVENT)} + {this.renderDropzoneWithType(fileTypes.SNMP_TRAP)} + {this.renderDropzoneWithType(fileTypes.SNMP_POLL)} +
    + ); + } + + renderDropzoneWithType(type) { + let { isReadOnlyMode, filenames } = this.props; + let fileByType = type2Name[type]; + let fileName = filenames ? filenames[fileByType] : undefined; + let refAndName = `fileInput${type.toString()}`; + let typeDisplayName = type2Title[type]; + return ( + + this.handleImport(acceptedFiles, rejectedFiles, { + isReadOnlyMode, + type, + refAndName + }) + } + onDragEnter={() => this.handleOnDragEnter(isReadOnlyMode)} + onDragLeave={() => this.setState({ dragging: false })} + multiple={false} + disableClick={true} + ref={refAndName} + name={refAndName} + accept=".zip"> +
    +
    {typeDisplayName}
    + {fileName + ? this.renderUploadedFileName( + fileName, + type, + isReadOnlyMode + ) + : this.renderUploadButton(refAndName)} +
    +
    + ); + } + + renderUploadButton(refAndName) { + let { isReadOnlyMode } = this.props; + return ( + this.refs[refAndName].open()} + /> + ); + } + + renderUploadedFileName(filename, type, isReadOnlyMode) { + return ( +
    + + +
    + ); + } + + handleOnDragEnter(isReadOnlyMode) { + if (!isReadOnlyMode) { + this.setState({ dragging: true }); + } + } + + handleImport(files, rejectedFiles, { isReadOnlyMode, type, refAndName }) { + if (isReadOnlyMode) { + return; + } + if (files.length > 0) { + this.setState({ dragging: false }); + let file = files[0]; + let formData = new FormData(); + formData.append('upload', file); + this.refs[refAndName].value = ''; + this.props.onDropMibFileToUpload(formData, type); + } else if (rejectedFiles.length > 0) { + this.setState({ dragging: false }); + this.props.onFileUploadError(); + } + } } export default SoftwareProductComponentsMonitoringView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreation.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreation.js index d4aaf7cc7e..e705618a65 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreation.js @@ -13,39 +13,55 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import NICCreationActionHelper from './NICCreationActionHelper.js'; import NICCreationView from './NICCreationView.jsx'; import SoftwareProductComponentsNetworkActionHelper from '../SoftwareProductComponentsNetworkActionHelper.js'; -import {networkTypes, NIC_CREATION_FORM_NAME} from '../SoftwareProductComponentsNetworkConstants.js'; +import { + networkTypes, + NIC_CREATION_FORM_NAME +} from '../SoftwareProductComponentsNetworkConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -export const mapStateToProps = ({softwareProduct}) => { - let {softwareProductEditor: {data:currentSoftwareProduct = {}}, softwareProductComponents} = softwareProduct; - let {network: {nicCreation = {}}} = softwareProductComponents; - let {data, genericFieldInfo, formReady} = nicCreation; - data = {...data, networkType: networkTypes.EXTERNAL}; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductEditor: { data: currentSoftwareProduct = {} }, + softwareProductComponents + } = softwareProduct; + let { network: { nicCreation = {} } } = softwareProductComponents; + let { data, genericFieldInfo, formReady } = nicCreation; + data = { ...data, networkType: networkTypes.EXTERNAL }; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - return { - currentSoftwareProduct, - data, - genericFieldInfo, - isFormValid, - formReady - }; + return { + currentSoftwareProduct, + data, + genericFieldInfo, + isFormValid, + formReady + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, version}) => { - return { - onDataChanged: deltaData => ValidationHelper.dataChanged(dispatch, {deltaData, formName: NIC_CREATION_FORM_NAME}), - onCancel: () => NICCreationActionHelper.close(dispatch), - onSubmit: ({nic, componentId}) => { - SoftwareProductComponentsNetworkActionHelper.createNIC(dispatch, {nic, softwareProductId, componentId, version}); - NICCreationActionHelper.close(dispatch); - }, - onValidateForm: () => ValidationHelper.validateForm(dispatch, NIC_CREATION_FORM_NAME) - }; +const mapActionsToProps = (dispatch, { softwareProductId, version }) => { + return { + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: NIC_CREATION_FORM_NAME + }), + onCancel: () => NICCreationActionHelper.close(dispatch), + onSubmit: ({ nic, componentId }) => { + SoftwareProductComponentsNetworkActionHelper.createNIC(dispatch, { + nic, + softwareProductId, + componentId, + version + }); + NICCreationActionHelper.close(dispatch); + }, + onValidateForm: () => + ValidationHelper.validateForm(dispatch, NIC_CREATION_FORM_NAME) + }; }; export default connect(mapStateToProps, mapActionsToProps)(NICCreationView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationActionHelper.js index a40b32d51a..4f200ce33f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationActionHelper.js @@ -13,35 +13,37 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from '../SoftwareProductComponentsNetworkConstants'; +import { actionTypes } from '../SoftwareProductComponentsNetworkConstants'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; export default { + open( + dispatch, + { softwareProductId, componentId, modalClassName, version } + ) { + dispatch({ + type: actionTypes.NICCreation.OPEN + }); - open(dispatch, {softwareProductId, componentId, modalClassName, version}) { - dispatch({ - type: actionTypes.NICCreation.OPEN - }); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.NIC_CREATION, + title: i18n('Create NEW NIC'), + modalClassName, + modalComponentProps: { softwareProductId, componentId, version } + } + }); + }, - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.NIC_CREATION, - title: i18n('Create NEW NIC'), - modalClassName, - modalComponentProps: {softwareProductId, componentId, version} - } - }); - }, - - close(dispatch){ - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - dispatch({ - type: actionTypes.NICCreation.CLEAR_DATA - }); - } + close(dispatch) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + dispatch({ + type: actionTypes.NICCreation.CLEAR_DATA + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationReducer.js index c7e2495b3d..8309c40451 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationReducer.js @@ -13,37 +13,40 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, NIC_CREATION_FORM_NAME} from '../SoftwareProductComponentsNetworkConstants.js'; +import { + actionTypes, + NIC_CREATION_FORM_NAME +} from '../SoftwareProductComponentsNetworkConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.NICCreation.OPEN: - return { - ...state, - data: {}, - formName: NIC_CREATION_FORM_NAME, - formReady: null, - genericFieldInfo: { - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}] - }, - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data : true}] - }, - 'networkDescription' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 50}] - } - } - }; - case actionTypes.NICCreation.CLEAR_DATA: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.NICCreation.OPEN: + return { + ...state, + data: {}, + formName: NIC_CREATION_FORM_NAME, + formReady: null, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }] + }, + name: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + }, + networkDescription: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 50 }] + } + } + }; + case actionTypes.NICCreation.CLEAR_DATA: + return {}; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationView.jsx index 258876844a..88525c051d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/NICCreation/NICCreationView.jsx @@ -22,103 +22,136 @@ import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; const NICPropType = PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - description: PropTypes.string, - networkId: PropTypes.string + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + networkId: PropTypes.string }); class NICCreationView extends React.Component { + static propTypes = { + data: NICPropType, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired + }; - static propTypes = { - data: NICPropType, - onDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired - }; + render() { + let { + data = {}, + onDataChanged, + genericFieldInfo, + isFormValid, + onValidateForm, + formReady + } = this.props; + let { name, description, networkDescription } = data; + return ( +
    + {genericFieldInfo && ( +
    (this.form = form)} + hasButtons={true} + onSubmit={() => this.submit()} + submitButtonText={ + data.id ? i18n('Save') : i18n('Create') + } + onReset={() => this.props.onCancel()} + labledButtons={true} + isValid={isFormValid} + onValidateForm={() => onValidateForm()} + formReady={formReady}> + + + onDataChanged({ name })} + isRequired={true} + type="text" + isValid={genericFieldInfo['name'].isValid} + errorText={ + genericFieldInfo['name'].errorText + } + className="field-section" + /> + + onDataChanged({ description }) + } + isValid={ + genericFieldInfo['description'].isValid + } + errorText={ + genericFieldInfo['description'] + .errorText + } + type="textarea" + className="field-section" + /> + + + + +
    + +
    + + +
    +
    +
    + + + onDataChanged({ networkDescription }) + } + isValid={ + genericFieldInfo['networkDescription'] + .isValid + } + errorText={ + genericFieldInfo['networkDescription'] + .errorText + } + type="text" + className="field-section" + /> + +
    +
    + )} +
    + ); + } - render() { - let {data = {}, onDataChanged, genericFieldInfo, isFormValid, onValidateForm, formReady} = this.props; - let {name, description, networkDescription} = data; - return ( -
    - {genericFieldInfo &&
    this.form = form} - hasButtons={true} - onSubmit={ () => this.submit() } - submitButtonText={data.id ? i18n('Save') : i18n('Create')} - onReset={ () => this.props.onCancel() } - labledButtons={true} - isValid={isFormValid} - onValidateForm={() => onValidateForm()} - formReady={formReady} > - - - onDataChanged({name})} - isRequired={true} - type='text' - isValid={genericFieldInfo['name'].isValid} - errorText={genericFieldInfo['name'].errorText} - className='field-section'/> - onDataChanged({description})} - isValid={genericFieldInfo['description'].isValid} - errorText={genericFieldInfo['description'].errorText} - type='textarea' - className='field-section'/> - - - - -
    - -
    - - -
    -
    -
    - - onDataChanged({networkDescription})} - isValid={genericFieldInfo['networkDescription'].isValid} - errorText={genericFieldInfo['networkDescription'].errorText} - type='text' - className='field-section'/> - -
    -
    } -
    - ); - } - - - submit() { - const {data: nic, componentId} = this.props; - this.props.onSubmit({nic, componentId}); - } + submit() { + const { data: nic, componentId } = this.props; + this.props.onSubmit({ nic, componentId }); + } } export default NICCreationView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditor.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditor.js index 93bd0bd67e..d7205b46ed 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditor.js @@ -13,56 +13,93 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductComponentsNetworkActionHelper from './SoftwareProductComponentsNetworkActionHelper.js'; import SoftwareProductComponentsNICEditorView from './SoftwareProductComponentsNICEditorView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; -import {NIC_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js'; -import {onboardingMethod as onboardingMethodTypes} from '../../SoftwareProductConstants.js'; +import { forms } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { NIC_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js'; +import { onboardingMethod as onboardingMethodTypes } from '../../SoftwareProductConstants.js'; -export const mapStateToProps = ({softwareProduct, currentScreen}) => { - - let {softwareProductEditor: {data:currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents} = softwareProduct; - let {network: {nicEditor = {}}} = softwareProductComponents; - let {data, qdata, genericFieldInfo, qgenericFieldInfo, dataMap, formReady} = nicEditor; - let {props: {isReadOnlyMode}} = currentScreen; - let {onboardingMethod} = currentSoftwareProduct; - let protocols = []; - if(qdata && qdata.protocols && qdata.protocols.protocols && qdata.protocols.protocols.length){ - protocols = qdata.protocols.protocols; - } - let {version} = currentSoftwareProduct; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo) && ValidationHelper.checkFormValid(qgenericFieldInfo); - - return { - currentSoftwareProduct, - isValidityData, - version, - data, - qdata, - dataMap, - isFormValid, - formReady, - genericFieldInfo, - qgenericFieldInfo, - isReadOnlyMode, - protocols, - isManual: onboardingMethod === onboardingMethodTypes.MANUAL - }; +export const mapStateToProps = ({ softwareProduct, currentScreen }) => { + let { + softwareProductEditor: { + data: currentSoftwareProduct = {}, + isValidityData = true + }, + softwareProductComponents + } = softwareProduct; + let { network: { nicEditor = {} } } = softwareProductComponents; + let { + data, + qdata, + genericFieldInfo, + qgenericFieldInfo, + dataMap, + formReady + } = nicEditor; + let { props: { isReadOnlyMode } } = currentScreen; + let { onboardingMethod } = currentSoftwareProduct; + let protocols = []; + if ( + qdata && + qdata.protocols && + qdata.protocols.protocols && + qdata.protocols.protocols.length + ) { + protocols = qdata.protocols.protocols; + } + let { version } = currentSoftwareProduct; + let isFormValid = + ValidationHelper.checkFormValid(genericFieldInfo) && + ValidationHelper.checkFormValid(qgenericFieldInfo); + return { + currentSoftwareProduct, + isValidityData, + version, + data, + qdata, + dataMap, + isFormValid, + formReady, + genericFieldInfo, + qgenericFieldInfo, + isReadOnlyMode, + protocols, + isManual: onboardingMethod === onboardingMethodTypes.MANUAL + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, componentId, version}) => { - return { - onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, - formName: forms.NIC_EDIT_FORM}), - onSubmit: ({data, qdata}) => SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(dispatch, {softwareProductId, version, componentId, data, qdata}), - onCancel: () => SoftwareProductComponentsNetworkActionHelper.closeNICEditor(dispatch), - onValidateForm: () => ValidationHelper.validateForm(dispatch, forms.NIC_EDIT_FORM), - onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, - qName: NIC_QUESTIONNAIRE}), - }; +const mapActionsToProps = ( + dispatch, + { softwareProductId, componentId, version } +) => { + return { + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: forms.NIC_EDIT_FORM + }), + onSubmit: ({ data, qdata }) => + SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire( + dispatch, + { softwareProductId, version, componentId, data, qdata } + ), + onCancel: () => + SoftwareProductComponentsNetworkActionHelper.closeNICEditor( + dispatch + ), + onValidateForm: () => + ValidationHelper.validateForm(dispatch, forms.NIC_EDIT_FORM), + onQDataChanged: deltaData => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + qName: NIC_QUESTIONNAIRE + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(SoftwareProductComponentsNICEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + SoftwareProductComponentsNICEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorReducer.js index dd37135d77..2da9b4b76b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorReducer.js @@ -13,37 +13,37 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductComponentsNetworkConstants.js'; -import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { actionTypes } from './SoftwareProductComponentsNetworkConstants.js'; +import { forms } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.NICEditor.FILL_DATA: - return { - ...state, - data: action.nic, - genericFieldInfo: { - 'description' : { - isValid: true, - errorText: '', - validations: [] - }, - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data : true}] - }, - 'networkDescription' : { - isValid: true, - errorText: '', - validations: [] - } - }, - formName: forms.NIC_EDIT_FORM - }; - case actionTypes.NICEditor.CLEAR_DATA: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.NICEditor.FILL_DATA: + return { + ...state, + data: action.nic, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [] + }, + name: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + }, + networkDescription: { + isValid: true, + errorText: '', + validations: [] + } + }, + formName: forms.NIC_EDIT_FORM + }; + case actionTypes.NICEditor.CLEAR_DATA: + return {}; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorView.jsx index fbb3d53033..df2efbe39e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorView.jsx @@ -26,48 +26,113 @@ import Protocols from './nicEditorComponents/Protocols.jsx'; import NameAndPurpose from './nicEditorComponents/NameAndPurpose.jsx'; class SoftwareProductComponentsNetworkEditorView extends React.Component { + render() { + let { + onCancel, + onValidateForm, + isReadOnlyMode, + isFormValid, + formReady, + data = {}, + qgenericFieldInfo, + dataMap, + onDataChanged, + protocols, + onQDataChanged, + isManual, + genericFieldInfo + } = this.props; + let { + name, + description, + networkName, + networkType, + networkDescription + } = data; + let netWorkValues = [ + { + enum: networkName, + title: networkName + } + ]; + return ( +
    + {qgenericFieldInfo && ( +
    { + this.form = form; + }} + hasButtons={true} + onSubmit={() => this.submit()} + onReset={() => onCancel()} + labledButtons={true} + isReadOnlyMode={isReadOnlyMode} + isValid={isFormValid} + formReady={formReady} + onValidateForm={() => onValidateForm()} + className="vsp-components-network-editor"> +
    + + + + + + + + + +
    +
    + )} +
    + ); + } - render() { - let {onCancel, onValidateForm, isReadOnlyMode, isFormValid, formReady, data = {}, qgenericFieldInfo, - dataMap, onDataChanged, protocols, onQDataChanged, isManual, genericFieldInfo} = this.props; - let {name, description, networkName, networkType, networkDescription} = data; - let netWorkValues = [{ - enum: networkName, - title: networkName - }]; - return ( -
    - {qgenericFieldInfo &&
    { this.form = form; }} - hasButtons={true} - onSubmit={ () => this.submit() } - onReset={ () => onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - isValid={isFormValid} - formReady={formReady} - onValidateForm={() => onValidateForm() } - className='vsp-components-network-editor'> -
    - - - - - - - - - -
    -
    } -
    - ); - } - - submit() { - let {data, qdata, onSubmit} = this.props; - onSubmit({data, qdata}); - } + submit() { + let { data, qdata, onSubmit } = this.props; + onSubmit({ data, qdata }); + } } export default SoftwareProductComponentsNetworkEditorView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICListReducer.js index 5cfc88bdc9..a2e65142a2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICListReducer.js @@ -13,16 +13,22 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductComponentsNetworkConstants.js'; +import { actionTypes } from './SoftwareProductComponentsNetworkConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.NIC_LIST_UPDATE: - return [...action.response]; - case actionTypes.NIC_LIST_EDIT: - const indexForEdit = state.findIndex(nic => nic.id === action.nic.id); - return [...state.slice(0, indexForEdit), action.nic, ...state.slice(indexForEdit + 1)]; - default: - return state; - } + switch (action.type) { + case actionTypes.NIC_LIST_UPDATE: + return [...action.response]; + case actionTypes.NIC_LIST_EDIT: + const indexForEdit = state.findIndex( + nic => nic.id === action.nic.id + ); + return [ + ...state.slice(0, indexForEdit), + action.nic, + ...state.slice(indexForEdit + 1) + ]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js index 1ffbc5919f..58c816134b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js @@ -17,127 +17,223 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes} from './SoftwareProductComponentsNetworkConstants.js'; -import {actionTypes as GlobalModalActions} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {modalContentMapper as modalPagesMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes } from './SoftwareProductComponentsNetworkConstants.js'; +import { actionTypes as GlobalModalActions } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { modalContentMapper as modalPagesMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {NIC_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js'; +import { NIC_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js'; function baseUrl(softwareProductId, version, componentId) { - const versionId = version.id; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/nics`; + const versionId = version.id; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/nics`; } -function createNIC({nic, vspId, componentId, version}) { - return RestAPIUtil.post(baseUrl(vspId, version, componentId), { - name: nic.name, - description: nic.description, - networkDescription: nic.networkDescription, - networkType: nic.networkType - }); +function createNIC({ nic, vspId, componentId, version }) { + return RestAPIUtil.post(baseUrl(vspId, version, componentId), { + name: nic.name, + description: nic.description, + networkDescription: nic.networkDescription, + networkType: nic.networkType + }); } -function fetchNICQuestionnaire({softwareProductId, version, componentId, nicId}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}/${nicId}/questionnaire`); +function fetchNICQuestionnaire({ + softwareProductId, + version, + componentId, + nicId +}) { + return RestAPIUtil.fetch( + `${baseUrl( + softwareProductId, + version, + componentId + )}/${nicId}/questionnaire` + ); } -function fetchNIC({softwareProductId, version, componentId, nicId}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}/${nicId}`); +function fetchNIC({ softwareProductId, version, componentId, nicId }) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, version, componentId)}/${nicId}` + ); } -function fetchNICsList({softwareProductId, version, componentId}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}`); +function fetchNICsList({ softwareProductId, version, componentId }) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, version, componentId)}` + ); } -function deleteNIC({softwareProductId, componentId, nicId, version}) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version, componentId)}/${nicId}`); +function deleteNIC({ softwareProductId, componentId, nicId, version }) { + return RestAPIUtil.destroy( + `${baseUrl(softwareProductId, version, componentId)}/${nicId}` + ); } -function saveNIC({softwareProductId, version, componentId, nic: {id, name, description, networkId, networkType, networkDescription}}) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version, componentId)}/${id}`,{ - name, - description, - networkId, - networkDescription, - networkType - }); +function saveNIC({ + softwareProductId, + version, + componentId, + nic: { id, name, description, networkId, networkType, networkDescription } +}) { + return RestAPIUtil.put( + `${baseUrl(softwareProductId, version, componentId)}/${id}`, + { + name, + description, + networkId, + networkDescription, + networkType + } + ); } -function saveNICQuestionnaire({softwareProductId, version, componentId, nicId, qdata}) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version, componentId)}/${nicId}/questionnaire`, qdata); +function saveNICQuestionnaire({ + softwareProductId, + version, + componentId, + nicId, + qdata +}) { + return RestAPIUtil.put( + `${baseUrl( + softwareProductId, + version, + componentId + )}/${nicId}/questionnaire`, + qdata + ); } const SoftwareProductComponentNetworkActionHelper = { - - fetchNICsList(dispatch, {softwareProductId, version, componentId}) { - return fetchNICsList({softwareProductId, version, componentId}).then((response) => { - dispatch({ - type: actionTypes.NIC_LIST_UPDATE, - response: response.results - }); - }); - }, - - openNICEditor(dispatch, {nic = {}, data = {}, softwareProductId, componentId, isReadOnlyMode, modalClassName, version}) { - dispatch({ - type: actionTypes.NICEditor.FILL_DATA, - nic: {...data, id: nic.id} - }); - dispatch({ - type: GlobalModalActions.GLOBAL_MODAL_SHOW, - data: { - modalClassName, - modalComponentProps: {softwareProductId, componentId, isReadOnlyMode, version}, - modalComponentName: modalPagesMapper.NIC_EDITOR, - title: i18n('Edit NIC') - } - }); - }, - - closeNICEditor(dispatch) { - dispatch({ - type: GlobalModalActions.GLOBAL_MODAL_CLOSE - }); - dispatch({ - type: actionTypes.NICEditor.CLEAR_DATA - }); - }, - - createNIC(dispatch, {nic, softwareProductId, componentId, version}){ - return createNIC({nic, vspId: softwareProductId, componentId, version}).then(() => { - return SoftwareProductComponentNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version}); - }); - }, - loadNICData({softwareProductId, version, componentId, nicId}) { - return fetchNIC({softwareProductId, version, componentId, nicId}); - }, - - deleteNIC(dispatch, {softwareProductId, componentId, nicId, version}) { - return deleteNIC({softwareProductId, componentId, nicId, version}).then(() => { - return SoftwareProductComponentNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version}); - }); - }, - loadNICQuestionnaire(dispatch, {softwareProductId, version, componentId, nicId}) { - return fetchNICQuestionnaire({softwareProductId, version, componentId, nicId}).then((response) => { - ValidationHelper.qDataLoaded(dispatch, {qName: NIC_QUESTIONNAIRE ,response: { - qdata: response.data ? JSON.parse(response.data) : {}, - qschema: JSON.parse(response.schema) - }}); - }); - }, - - saveNICDataAndQuestionnaire(dispatch, {softwareProductId, version, componentId, data, qdata}) { - SoftwareProductComponentNetworkActionHelper.closeNICEditor(dispatch); - return Promise.all([ - saveNICQuestionnaire({softwareProductId, version, componentId, nicId: data.id, qdata}), - saveNIC({softwareProductId, version, componentId, nic: data}).then(() => { - dispatch({ - type: actionTypes.NIC_LIST_EDIT, - nic: data - }); - }) - ]); - } + fetchNICsList(dispatch, { softwareProductId, version, componentId }) { + return fetchNICsList({ softwareProductId, version, componentId }).then( + response => { + dispatch({ + type: actionTypes.NIC_LIST_UPDATE, + response: response.results + }); + } + ); + }, + + openNICEditor( + dispatch, + { + nic = {}, + data = {}, + softwareProductId, + componentId, + isReadOnlyMode, + modalClassName, + version + } + ) { + dispatch({ + type: actionTypes.NICEditor.FILL_DATA, + nic: { ...data, id: nic.id } + }); + dispatch({ + type: GlobalModalActions.GLOBAL_MODAL_SHOW, + data: { + modalClassName, + modalComponentProps: { + softwareProductId, + componentId, + isReadOnlyMode, + version + }, + modalComponentName: modalPagesMapper.NIC_EDITOR, + title: i18n('Edit NIC') + } + }); + }, + + closeNICEditor(dispatch) { + dispatch({ + type: GlobalModalActions.GLOBAL_MODAL_CLOSE + }); + dispatch({ + type: actionTypes.NICEditor.CLEAR_DATA + }); + }, + + createNIC(dispatch, { nic, softwareProductId, componentId, version }) { + return createNIC({ + nic, + vspId: softwareProductId, + componentId, + version + }).then(() => { + return SoftwareProductComponentNetworkActionHelper.fetchNICsList( + dispatch, + { softwareProductId, componentId, version } + ); + }); + }, + loadNICData({ softwareProductId, version, componentId, nicId }) { + return fetchNIC({ softwareProductId, version, componentId, nicId }); + }, + + deleteNIC(dispatch, { softwareProductId, componentId, nicId, version }) { + return deleteNIC({ + softwareProductId, + componentId, + nicId, + version + }).then(() => { + return SoftwareProductComponentNetworkActionHelper.fetchNICsList( + dispatch, + { softwareProductId, componentId, version } + ); + }); + }, + loadNICQuestionnaire( + dispatch, + { softwareProductId, version, componentId, nicId } + ) { + return fetchNICQuestionnaire({ + softwareProductId, + version, + componentId, + nicId + }).then(response => { + ValidationHelper.qDataLoaded(dispatch, { + qName: NIC_QUESTIONNAIRE, + response: { + qdata: response.data ? JSON.parse(response.data) : {}, + qschema: JSON.parse(response.schema) + } + }); + }); + }, + + saveNICDataAndQuestionnaire( + dispatch, + { softwareProductId, version, componentId, data, qdata } + ) { + SoftwareProductComponentNetworkActionHelper.closeNICEditor(dispatch); + return Promise.all([ + saveNICQuestionnaire({ + softwareProductId, + version, + componentId, + nicId: data.id, + qdata + }), + saveNIC({ + softwareProductId, + version, + componentId, + nic: data + }).then(() => { + dispatch({ + type: actionTypes.NIC_LIST_EDIT, + nic: data + }); + }) + ]); + } }; export default SoftwareProductComponentNetworkActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js index 8ef8fe8c18..4e361bb1a9 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js @@ -16,23 +16,23 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - NIC_LIST_EDIT: null, - NIC_LIST_UPDATE: null, + NIC_LIST_EDIT: null, + NIC_LIST_UPDATE: null, - NICEditor: { - FILL_DATA: null, - CLEAR_DATA: null, - }, - NICCreation: { - OPEN: null, - CLEAR_DATA: null, - DATA_CHANGED: null - }, + NICEditor: { + FILL_DATA: null, + CLEAR_DATA: null + }, + NICCreation: { + OPEN: null, + CLEAR_DATA: null, + DATA_CHANGED: null + } }); export const networkTypes = { - EXTERNAL: 'External', - INTERNAL: 'Internal' + EXTERNAL: 'External', + INTERNAL: 'Internal' }; export const NIC_QUESTIONNAIRE = 'nic'; export const NIC_CREATION_FORM_NAME = 'nicCreation'; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkList.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkList.js index bb256d5d41..ac708524cf 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkList.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkList.js @@ -13,79 +13,132 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; import SoftwareProductComponentsNetworkListView from './SoftwareProductComponentsNetworkListView.jsx'; import SoftwareProductComponentsNetworkActionHelper from './SoftwareProductComponentsNetworkActionHelper.js'; -import {COMPONENTS_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import { COMPONENTS_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {actionTypes as GlobalModalActions} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as GlobalModalActions } from 'nfvo-components/modal/GlobalModalConstants.js'; import NICCreationActionHelper from './NICCreation/NICCreationActionHelper.js'; -import {onboardingMethod as onboardingMethodTypes} from '../../SoftwareProductConstants.js'; +import { onboardingMethod as onboardingMethodTypes } from '../../SoftwareProductConstants.js'; +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductEditor: { + data: currentSoftwareProduct = {}, + isValidityData = true + }, + softwareProductComponents + } = softwareProduct; + let { + network: { nicList = [] }, + componentEditor: { + data: componentData, + qdata, + dataMap, + qgenericFieldInfo + } + } = softwareProductComponents; + let { version, onboardingMethod } = currentSoftwareProduct; + let isManual = onboardingMethod === onboardingMethodTypes.MANUAL; -export const mapStateToProps = ({softwareProduct}) => { - - let {softwareProductEditor: {data: currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents} = softwareProduct; - let {network: {nicList = []}, componentEditor: {data: componentData, qdata, dataMap, qgenericFieldInfo}} = softwareProductComponents; - let {version, onboardingMethod} = currentSoftwareProduct; - let isManual = onboardingMethod === onboardingMethodTypes.MANUAL; - - return { - version, - componentData, - qdata, - dataMap, - qgenericFieldInfo, - isValidityData, - nicList, - isManual - }; - + return { + version, + componentData, + qdata, + dataMap, + qgenericFieldInfo, + isValidityData, + nicList, + isManual + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, componentId, version}) => { - return { - onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, - qName: COMPONENTS_QUESTIONNAIRE}), - onAddNic: () => NICCreationActionHelper.open(dispatch, {softwareProductId, componentId, modalClassName: 'network-nic-modal-create', version}), - onDeleteNic: (nic) => dispatch({ - type: GlobalModalActions.GLOBAL_MODAL_WARNING, - data:{ - msg: i18n('Are you sure you want to delete "{name}"?', {name: nic.name}), - onConfirmed: () => SoftwareProductComponentsNetworkActionHelper.deleteNIC(dispatch, {softwareProductId, - componentId, nicId: nic.id, version}) - } - }), - onEditNicClick: (nic, isReadOnlyMode) => { - Promise.all([ - SoftwareProductComponentsNetworkActionHelper.loadNICData({ - softwareProductId, - version, - componentId, - nicId: nic.id - }), - SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(dispatch, { - softwareProductId, - version, - componentId, - nicId: nic.id - }) - ]).then( - ([{data}]) => SoftwareProductComponentsNetworkActionHelper.openNICEditor(dispatch, {nic, data, - isReadOnlyMode, softwareProductId, componentId, modalClassName: 'network-nic-modal-edit', version}) - ); - }, - onSubmit: ({qdata}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, - {softwareProductId, version, - vspComponentId: componentId, - qdata}); - } - - - }; +const mapActionsToProps = ( + dispatch, + { softwareProductId, componentId, version } +) => { + return { + onQDataChanged: deltaData => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + qName: COMPONENTS_QUESTIONNAIRE + }), + onAddNic: () => + NICCreationActionHelper.open(dispatch, { + softwareProductId, + componentId, + modalClassName: 'network-nic-modal-create', + version + }), + onDeleteNic: nic => + dispatch({ + type: GlobalModalActions.GLOBAL_MODAL_WARNING, + data: { + msg: i18n('Are you sure you want to delete "{name}"?', { + name: nic.name + }), + onConfirmed: () => + SoftwareProductComponentsNetworkActionHelper.deleteNIC( + dispatch, + { + softwareProductId, + componentId, + nicId: nic.id, + version + } + ) + } + }), + onEditNicClick: (nic, isReadOnlyMode) => { + Promise.all([ + SoftwareProductComponentsNetworkActionHelper.loadNICData({ + softwareProductId, + version, + componentId, + nicId: nic.id + }), + SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire( + dispatch, + { + softwareProductId, + version, + componentId, + nicId: nic.id + } + ) + ]).then(([{ data }]) => + SoftwareProductComponentsNetworkActionHelper.openNICEditor( + dispatch, + { + nic, + data, + isReadOnlyMode, + softwareProductId, + componentId, + modalClassName: 'network-nic-modal-edit', + version + } + ) + ); + }, + onSubmit: ({ qdata }) => { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire( + dispatch, + { + softwareProductId, + version, + vspComponentId: componentId, + qdata + } + ); + } + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductComponentsNetworkListView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductComponentsNetworkListView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx index 4d460c722d..c631fb24c3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx @@ -20,138 +20,203 @@ import Form from 'nfvo-components/input/validation/Form.jsx'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; -import Input from'nfvo-components/input/validation/Input.jsx'; - +import Input from 'nfvo-components/input/validation/Input.jsx'; class SoftwareProductComponentsNetworkView extends React.Component { + state = { + localFilter: '' + }; - state = { - localFilter: '' - }; - - render() { - let {dataMap, qgenericFieldInfo, onQDataChanged, isReadOnlyMode} = this.props; - - return( -
    -
    -
    -{ qgenericFieldInfo &&
    this.save()} - isReadOnlyMode={isReadOnlyMode} - hasButtons={false}> -

    {i18n('Network Capacity')}

    -
    -
    -
    - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({'network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs' : val});} - }> - - { qgenericFieldInfo['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs'].enum.map(proto => - ) } - -
    -
    - onQDataChanged({'network/networkCapacity/networkTransactionsPerSecond' : ntps})} - isValid={qgenericFieldInfo['network/networkCapacity/networkTransactionsPerSecond'].isValid} - errorText={qgenericFieldInfo['network/networkCapacity/networkTransactionsPerSecond'].errorText} - value={dataMap['network/networkCapacity/networkTransactionsPerSecond']} /> -
    -
    -
    -
    - - } -
    - {this.renderNicList()} -
    - -
    - ); - } - - renderNicList() { - const {localFilter} = this.state; - let {isReadOnlyMode, onAddNic, isManual} = this.props; - return ( - this.setState({localFilter: value})} - onAdd={isManual ? onAddNic : null} - plusButtonTitle={i18n('Add NIC')} - twoColumns> - {this.filterList().map(nic => this.renderNicListItem(nic, isReadOnlyMode))} - - ); - } + render() { + let { + dataMap, + qgenericFieldInfo, + onQDataChanged, + isReadOnlyMode + } = this.props; - renderNicListItem(nic, isReadOnlyMode) { - let {id, name, description, networkName = ''} = nic; - let {onEditNicClick, version, isManual, onDeleteNic} = this.props; - return ( - onEditNicClick(nic, version, isReadOnlyMode)} - onDelete={isManual ? () => onDeleteNic(nic, version) : null}> + return ( +
    +
    +
    + {qgenericFieldInfo && ( +
    this.save()} + isReadOnlyMode={isReadOnlyMode} + hasButtons={false}> +

    + {i18n('Network Capacity')} +

    +
    +
    +
    + { + const selectedIndex = + e.target.selectedIndex; + const val = + e.target.options[ + selectedIndex + ].value; + onQDataChanged({ + 'network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs': val + }); + }}> + + {qgenericFieldInfo[ + 'network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs' + ].enum.map(proto => ( + + ))} + +
    +
    + + onQDataChanged({ + 'network/networkCapacity/networkTransactionsPerSecond': ntps + }) + } + isValid={ + qgenericFieldInfo[ + 'network/networkCapacity/networkTransactionsPerSecond' + ].isValid + } + errorText={ + qgenericFieldInfo[ + 'network/networkCapacity/networkTransactionsPerSecond' + ].errorText + } + value={ + dataMap[ + 'network/networkCapacity/networkTransactionsPerSecond' + ] + } + /> +
    +
    +
    +
    + + )} +
    + {this.renderNicList()} +
    +
    + ); + } - -
    {name}
    -
    - -
    -
    {i18n('Purpose of NIC')}
    - {description &&
    {description}
    } -
    - {!isManual &&
    -
    {i18n('Network')}
    -
    {networkName}
    -
    } -
    + renderNicList() { + const { localFilter } = this.state; + let { isReadOnlyMode, onAddNic, isManual } = this.props; + return ( + this.setState({ localFilter: value })} + onAdd={isManual ? onAddNic : null} + plusButtonTitle={i18n('Add NIC')} + twoColumns> + {this.filterList().map(nic => + this.renderNicListItem(nic, isReadOnlyMode) + )} + + ); + } - - ); - } + renderNicListItem(nic, isReadOnlyMode) { + let { id, name, description, networkName = '' } = nic; + let { onEditNicClick, version, isManual, onDeleteNic } = this.props; + return ( + onEditNicClick(nic, version, isReadOnlyMode)} + onDelete={isManual ? () => onDeleteNic(nic, version) : null}> + +
    {name}
    +
    + +
    +
    + {i18n('Purpose of NIC')} +
    + {description && ( +
    + {description} +
    + )} +
    + {!isManual && ( +
    +
    {i18n('Network')}
    +
    {networkName}
    +
    + )} +
    +
    + ); + } - filterList() { - let {nicList} = this.props; - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return nicList.filter(({name = '', description = ''}) => { - return escape(name).match(filter) || escape(description).match(filter); - }); - } - else { - return nicList; - } - } + filterList() { + let { nicList } = this.props; + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return nicList.filter(({ name = '', description = '' }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) + ); + }); + } else { + return nicList; + } + } - save() { - let {onSubmit, qdata, version} = this.props; - return onSubmit({qdata, version}); - } + save() { + let { onSubmit, qdata, version } = this.props; + return onSubmit({ qdata, version }); + } } export default SoftwareProductComponentsNetworkView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Acceptable.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Acceptable.jsx index 0fc7404c56..0b2783ebe7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Acceptable.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Acceptable.jsx @@ -19,57 +19,97 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -const Acceptable = ({qgenericFieldInfo, dataMap, onQDataChanged}) => { - return( - - -
    {i18n('Acceptable Jitter')}
    -
    - -
    {i18n('Allow Packet Loss')}
    -
    - - onQDataChanged({'sizing/acceptableJitter/mean' : val})} /> - - - onQDataChanged({'sizing/acceptableJitter/max' : val})} /> - - - onQDataChanged({'sizing/acceptableJitter/variable' : val})} /> - - - onQDataChanged({'sizing/acceptablePacketLoss' : val})} /> - -
    - ); +const Acceptable = ({ qgenericFieldInfo, dataMap, onQDataChanged }) => { + return ( + + +
    + {i18n('Acceptable Jitter')} +
    +
    + +
    + {i18n('Allow Packet Loss')} +
    +
    + + + onQDataChanged({ 'sizing/acceptableJitter/mean': val }) + } + /> + + + + onQDataChanged({ 'sizing/acceptableJitter/max': val }) + } + /> + + + + onQDataChanged({ + 'sizing/acceptableJitter/variable': val + }) + } + /> + + + + onQDataChanged({ 'sizing/acceptablePacketLoss': val }) + } + /> + +
    + ); }; export default Acceptable; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/FlowLength.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/FlowLength.jsx index 3745fc7c2e..32a5516eb4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/FlowLength.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/FlowLength.jsx @@ -18,18 +18,20 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import PacketsBytes from './PacketsBytes.jsx'; const pointers = [ - {label: 'Peak', value: 'sizing/flowLength/packets/peak'}, - {label: 'Avg', value: 'sizing/flowLength/packets/avg'}, - {label: 'Peak', value: 'sizing/flowLength/bytes/peak'}, - {label: 'Avg', value: 'sizing/flowLength/bytes/avg'}, + { label: 'Peak', value: 'sizing/flowLength/packets/peak' }, + { label: 'Avg', value: 'sizing/flowLength/packets/avg' }, + { label: 'Peak', value: 'sizing/flowLength/bytes/peak' }, + { label: 'Avg', value: 'sizing/flowLength/bytes/avg' } ]; -const FlowLength = (props) => { - return( - - ); +const FlowLength = props => { + return ( + + ); }; export default FlowLength; - - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/InFlowTraffic.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/InFlowTraffic.jsx index 5476ed90e6..150e58af52 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/InFlowTraffic.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/InFlowTraffic.jsx @@ -18,18 +18,20 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import PacketsBytes from './PacketsBytes.jsx'; const pointers = [ - {label: 'Peak', value: 'sizing/inflowTrafficPerSecond/packets/peak'}, - {label: 'Avg', value: 'sizing/inflowTrafficPerSecond/packets/avg'}, - {label: 'Peak', value: 'sizing/inflowTrafficPerSecond/bytes/peak'}, - {label: 'Avg', value: 'sizing/inflowTrafficPerSecond/bytes/avg'}, + { label: 'Peak', value: 'sizing/inflowTrafficPerSecond/packets/peak' }, + { label: 'Avg', value: 'sizing/inflowTrafficPerSecond/packets/avg' }, + { label: 'Peak', value: 'sizing/inflowTrafficPerSecond/bytes/peak' }, + { label: 'Avg', value: 'sizing/inflowTrafficPerSecond/bytes/avg' } ]; -const InFlowTraffic = (props) => { - return( - - ); +const InFlowTraffic = props => { + return ( + + ); }; export default InFlowTraffic; - - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/IpConfig.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/IpConfig.jsx index b3a5d21625..695835606b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/IpConfig.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/IpConfig.jsx @@ -19,27 +19,37 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -const IpConfig = ({dataMap, onQDataChanged}) => { - return ( - - - onQDataChanged({'ipConfiguration/ipv4Required' : value})} - data-test-id='ipConfiguration-ipv4Required' - value={dataMap['ipConfiguration/ipv4Required']} /> - - - onQDataChanged({'ipConfiguration/ipv6Required' : value})} - value={dataMap['ipConfiguration/ipv6Required']} /> - - - ); +const IpConfig = ({ dataMap, onQDataChanged }) => { + return ( + + + + onQDataChanged({ + 'ipConfiguration/ipv4Required': value + }) + } + data-test-id="ipConfiguration-ipv4Required" + value={dataMap['ipConfiguration/ipv4Required']} + /> + + + + onQDataChanged({ + 'ipConfiguration/ipv6Required': value + }) + } + value={dataMap['ipConfiguration/ipv6Required']} + /> + + + ); }; export default IpConfig; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/NameAndPurpose.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/NameAndPurpose.jsx index 06a2bb445c..5a89239dc6 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/NameAndPurpose.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/NameAndPurpose.jsx @@ -20,40 +20,48 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -const NameAndPurpose = ({onDataChanged, genericFieldInfo, isReadOnlyMode, name, description, isManual}) => { - - return ( - - - onDataChanged({name})} - isValid={genericFieldInfo['name'].isValid} - errorText={genericFieldInfo['name'].errorText} - type='text' /> - - - onDataChanged({description})} - disabled={isReadOnlyMode} - type='textarea' /> - - - ); +const NameAndPurpose = ({ + onDataChanged, + genericFieldInfo, + isReadOnlyMode, + name, + description, + isManual +}) => { + return ( + + + onDataChanged({ name })} + isValid={genericFieldInfo['name'].isValid} + errorText={genericFieldInfo['name'].errorText} + type="text" + /> + + + onDataChanged({ description })} + disabled={isReadOnlyMode} + type="textarea" + /> + + + ); }; NameAndPurpose.PropTypes = { - name: PropTypes.string, - description: PropTypes.array, - onDataChanged: PropTypes.func, - isReadOnlyMode: PropTypes.bool, + name: PropTypes.string, + description: PropTypes.array, + onDataChanged: PropTypes.func, + isReadOnlyMode: PropTypes.bool }; export default NameAndPurpose; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Network.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Network.jsx index 7e6712cb5e..c440d2fbd3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Network.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Network.jsx @@ -21,56 +21,70 @@ import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; import { networkTypes } from '../SoftwareProductComponentsNetworkConstants.js'; -const Network = ({networkValues, networkType, networkDescription, onDataChanged, isReadOnlyMode}) => { - const isExternal = networkType === networkTypes.EXTERNAL; - return ( - - - - - - - - - { - isExternal ? - onDataChanged({networkDescription})} - disabled={isReadOnlyMode} - type='text' /> - : - - {networkValues.map(val => )} - - } - - - ); +const Network = ({ + networkValues, + networkType, + networkDescription, + onDataChanged, + isReadOnlyMode +}) => { + const isExternal = networkType === networkTypes.EXTERNAL; + return ( + + + + + + + + + {isExternal ? ( + + onDataChanged({ networkDescription }) + } + disabled={isReadOnlyMode} + type="text" + /> + ) : ( + + {networkValues.map(val => ( + + ))} + + )} + + + ); }; Network.PropTypes = { - networkValues: PropTypes.array + networkValues: PropTypes.array }; -export default Network; +export default Network; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/OutFlowTraffic.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/OutFlowTraffic.jsx index 80a3d1579b..7173294536 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/OutFlowTraffic.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/OutFlowTraffic.jsx @@ -18,18 +18,20 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import PacketsBytes from './PacketsBytes.jsx'; const pointers = [ - {label: 'Peak', value: 'sizing/outflowTrafficPerSecond/packets/peak'}, - {label: 'Avg', value: 'sizing/outflowTrafficPerSecond/packets/avg'}, - {label: 'Peak', value: 'sizing/outflowTrafficPerSecond/bytes/peak'}, - {label: 'Avg', value: 'sizing/outflowTrafficPerSecond/bytes/avg'}, + { label: 'Peak', value: 'sizing/outflowTrafficPerSecond/packets/peak' }, + { label: 'Avg', value: 'sizing/outflowTrafficPerSecond/packets/avg' }, + { label: 'Peak', value: 'sizing/outflowTrafficPerSecond/bytes/peak' }, + { label: 'Avg', value: 'sizing/outflowTrafficPerSecond/bytes/avg' } ]; -const OutFlowTraffic = (props) => { - return( - - ); +const OutFlowTraffic = props => { + return ( + + ); }; export default OutFlowTraffic; - - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/PacketsBytes.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/PacketsBytes.jsx index f5f28aea59..070ac816ad 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/PacketsBytes.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/PacketsBytes.jsx @@ -20,47 +20,74 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -const PointerInput = ({label, value, onQDataChanged, qgenericFieldInfo, dataMap, lastColInRow}) => { - return ( - - onQDataChanged({[value]: val})} /> - - ); +const PointerInput = ({ + label, + value, + onQDataChanged, + qgenericFieldInfo, + dataMap, + lastColInRow +}) => { + return ( + + onQDataChanged({ [value]: val })} + /> + + ); }; PointerInput.PropTypes = { - label: PropTypes.string, - value: PropTypes.string + label: PropTypes.string, + value: PropTypes.string }; -const PacketsBytes = ({title, pointers = [], qgenericFieldInfo, dataMap, onQDataChanged}) => { - return( - - -
    {i18n('Packets')}
    -
    - -
    {i18n('Bytes')}
    -
    - {pointers.map((pointer, i) => {return ();})} -
    - ); +const PacketsBytes = ({ + title, + pointers = [], + qgenericFieldInfo, + dataMap, + onQDataChanged +}) => { + return ( + + +
    + {i18n('Packets')} +
    +
    + +
    {i18n('Bytes')}
    +
    + {pointers.map((pointer, i) => { + return ( + + ); + })} +
    + ); }; PacketsBytes.PropTypes = { - title: PropTypes.string, - pointers: PropTypes.array, - onQDataChanged: PropTypes.function, - dataMap: PropTypes.object, - qgenericFieldInfo: PropTypes.object + title: PropTypes.string, + pointers: PropTypes.array, + onQDataChanged: PropTypes.function, + dataMap: PropTypes.object, + qgenericFieldInfo: PropTypes.object }; export default PacketsBytes; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Protocols.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Protocols.jsx index be4093da59..eb762b11b2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Protocols.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Protocols.jsx @@ -21,55 +21,83 @@ import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -const Protocols = ({protocols, qgenericFieldInfo, dataMap, onQDataChanged}) => { - return ( - - - {}} - onEnumChange={protocols => { - onQDataChanged({'protocols/protocols' : protocols});} - } - multiSelectedEnum={dataMap['protocols/protocols']} - clearable={false} - values={qgenericFieldInfo['protocols/protocols'].enum}/> - - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({'protocols/protocolWithHighestTrafficProfile' : val});} - }> - {(protocols.length === 0) && - - } - {protocols.map(protocol => )} - - - - ); +const Protocols = ({ + protocols, + qgenericFieldInfo, + dataMap, + onQDataChanged +}) => { + return ( + + + {}} + onEnumChange={protocols => { + onQDataChanged({ 'protocols/protocols': protocols }); + }} + multiSelectedEnum={dataMap['protocols/protocols']} + clearable={false} + values={qgenericFieldInfo['protocols/protocols'].enum} + /> + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({ + 'protocols/protocolWithHighestTrafficProfile': val + }); + }}> + {protocols.length === 0 && ( + + )} + {protocols.map(protocol => ( + + ))} + + + + ); }; Protocols.PropTypes = { - protocols: PropTypes.array, - onQDataChanged: PropTypes.function, - dataMap: PropTypes.object, - qgenericFieldInfo: PropTypes.object + protocols: PropTypes.array, + onQDataChanged: PropTypes.function, + dataMap: PropTypes.object, + qgenericFieldInfo: PropTypes.object }; export default Protocols; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Sizing.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Sizing.jsx index 202d458f25..f9ec7261ac 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Sizing.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Sizing.jsx @@ -19,21 +19,32 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -const Sizing = ({qgenericFieldInfo, dataMap, onQDataChanged}) => { - return( - - - onQDataChanged({'sizing/describeQualityOfService' : val}) }/> - - - ); +const Sizing = ({ qgenericFieldInfo, dataMap, onQDataChanged }) => { + return ( + + + + onQDataChanged({ + 'sizing/describeQualityOfService': val + }) + } + /> + + + ); }; export default Sizing; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js index b2133ad5d8..52c5cdde3d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js @@ -15,121 +15,184 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from './SoftwareProductComponentProcessesConstants.js'; +import { actionTypes } from './SoftwareProductComponentProcessesConstants.js'; function baseUrl(softwareProductId, version, componentId) { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/processes`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${ + version.id + }/components/${componentId}/processes`; } -function fetchProcessesList({softwareProductId, version, componentId}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}`); +function fetchProcessesList({ softwareProductId, version, componentId }) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, version, componentId)}` + ); } -function deleteProcess({softwareProductId, version, componentId, processId}) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version, componentId)}/${processId}`); +function deleteProcess({ softwareProductId, version, componentId, processId }) { + return RestAPIUtil.destroy( + `${baseUrl(softwareProductId, version, componentId)}/${processId}` + ); } -function putProcess({softwareProductId, version, componentId, process}) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version, componentId)}/${process.id}`, { - name: process.name, - description: process.description, - type: process.type === '' ? null : process.type - }); +function putProcess({ softwareProductId, version, componentId, process }) { + return RestAPIUtil.put( + `${baseUrl(softwareProductId, version, componentId)}/${process.id}`, + { + name: process.name, + description: process.description, + type: process.type === '' ? null : process.type + } + ); } -function postProcess({softwareProductId, version, componentId, process}) { - return RestAPIUtil.post(`${baseUrl(softwareProductId, version, componentId)}`, { - name: process.name, - description: process.description, - type: process.type === '' ? null : process.type - }); +function postProcess({ softwareProductId, version, componentId, process }) { + return RestAPIUtil.post( + `${baseUrl(softwareProductId, version, componentId)}`, + { + name: process.name, + description: process.description, + type: process.type === '' ? null : process.type + } + ); } -function uploadFileToProcess({softwareProductId, version, processId, componentId, formData}) { - return RestAPIUtil.post(`${baseUrl(softwareProductId, version, componentId)}/${processId}/upload`, formData); +function uploadFileToProcess({ + softwareProductId, + version, + processId, + componentId, + formData +}) { + return RestAPIUtil.post( + `${baseUrl( + softwareProductId, + version, + componentId + )}/${processId}/upload`, + formData + ); } - - const SoftwareProductComponentProcessesActionHelper = { - fetchProcessesList(dispatch, {softwareProductId, version, componentId}) { - dispatch({ - type: actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES, - processesList: [] - }); - - return fetchProcessesList({softwareProductId, version, componentId}).then(response => { - dispatch({ - type: actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES, - processesList: response.results - }); - }); - }, - - deleteProcess(dispatch, {process, softwareProductId, version, componentId}) { - return deleteProcess({softwareProductId, version, processId:process.id, componentId}).then(() => { - dispatch({ - type: actionTypes.DELETE_SOFTWARE_PRODUCT_COMPONENTS_PROCESS, - processId: process.id - }); - }); - - }, - - saveProcess(dispatch, {softwareProductId, version, componentId, previousProcess, process}) { - if (previousProcess) { - return putProcess({softwareProductId, version, componentId, process}).then(() => { - if (process.formData && process.formData.name !== previousProcess.artifactName){ - uploadFileToProcess({softwareProductId, version, processId: process.id, formData: process.formData, componentId}); - } - dispatch({ - type: actionTypes.EDIT_SOFTWARE_PRODUCT_COMPONENTS_PROCESS, - process - }); - }); - } - else { - return postProcess({softwareProductId, version, componentId, process}).then(response => { - if (process.formData) { - uploadFileToProcess({softwareProductId, version, processId: response.value, formData: process.formData, componentId}); - } - dispatch({ - type: actionTypes.ADD_SOFTWARE_PRODUCT_COMPONENTS_PROCESS, - process: { - ...process, - id: response.value - } - }); - }); - } - }, - - hideDeleteConfirm(dispatch) { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM, - processToDelete: false - }); - }, - - openDeleteProcessesConfirm(dispatch, {process} ) { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM, - processToDelete: process - }); - }, - - openEditor(dispatch, process = {}) { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_OPEN, - process - }); - }, - closeEditor(dispatch) { - dispatch({ - type:actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_CLOSE - }); - } + fetchProcessesList(dispatch, { softwareProductId, version, componentId }) { + dispatch({ + type: actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES, + processesList: [] + }); + + return fetchProcessesList({ + softwareProductId, + version, + componentId + }).then(response => { + dispatch({ + type: actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES, + processesList: response.results + }); + }); + }, + + deleteProcess( + dispatch, + { process, softwareProductId, version, componentId } + ) { + return deleteProcess({ + softwareProductId, + version, + processId: process.id, + componentId + }).then(() => { + dispatch({ + type: actionTypes.DELETE_SOFTWARE_PRODUCT_COMPONENTS_PROCESS, + processId: process.id + }); + }); + }, + + saveProcess( + dispatch, + { softwareProductId, version, componentId, previousProcess, process } + ) { + if (previousProcess) { + return putProcess({ + softwareProductId, + version, + componentId, + process + }).then(() => { + if ( + process.formData && + process.formData.name !== previousProcess.artifactName + ) { + uploadFileToProcess({ + softwareProductId, + version, + processId: process.id, + formData: process.formData, + componentId + }); + } + dispatch({ + type: actionTypes.EDIT_SOFTWARE_PRODUCT_COMPONENTS_PROCESS, + process + }); + }); + } else { + return postProcess({ + softwareProductId, + version, + componentId, + process + }).then(response => { + if (process.formData) { + uploadFileToProcess({ + softwareProductId, + version, + processId: response.value, + formData: process.formData, + componentId + }); + } + dispatch({ + type: actionTypes.ADD_SOFTWARE_PRODUCT_COMPONENTS_PROCESS, + process: { + ...process, + id: response.value + } + }); + }); + } + }, + + hideDeleteConfirm(dispatch) { + dispatch({ + type: + actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM, + processToDelete: false + }); + }, + + openDeleteProcessesConfirm(dispatch, { process }) { + dispatch({ + type: + actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM, + processToDelete: process + }); + }, + + openEditor(dispatch, process = {}) { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_OPEN, + process + }); + }, + closeEditor(dispatch) { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_CLOSE + }); + } }; export default SoftwareProductComponentProcessesActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesConstants.js index d15432b3fb..e3ce4f8007 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesConstants.js @@ -16,21 +16,22 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - ADD_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: null, - EDIT_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: null, - DELETE_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: null, - SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_OPEN: null, - SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_CLOSE: null, - FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES: null, - SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM: null + ADD_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: null, + EDIT_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: null, + DELETE_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: null, + SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_OPEN: null, + SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_CLOSE: null, + FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES: null, + SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM: null }); export const optionsInputValues = { - PROCESS_TYPE: [ - {title: 'Select...', enum: ''}, - {title: 'Lifecycle Operations', enum: 'Lifecycle_Operations'}, - {title: 'Other', enum: 'Other'} - ] + PROCESS_TYPE: [ + { title: 'Select...', enum: '' }, + { title: 'Lifecycle Operations', enum: 'Lifecycle_Operations' }, + { title: 'Other', enum: 'Other' } + ] }; -export const SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM = 'SOFTWAREPRODUCTPROCESSCOMPONENTSEDITORFORM'; +export const SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM = + 'SOFTWAREPRODUCTPROCESSCOMPONENTSEDITORFORM'; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditor.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditor.js index 9502e24b1a..9d2bf34b78 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditor.js @@ -13,44 +13,68 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import SoftwareProductComponentProcessesActionHelper from './SoftwareProductComponentProcessesActionHelper'; import SoftwareProductComponentProcessesEditorView from './SoftwareProductComponentProcessesEditorView.jsx'; -import {SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM} from './SoftwareProductComponentProcessesConstants.js'; +import { SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM } from './SoftwareProductComponentProcessesConstants.js'; -export const mapStateToProps = ({softwareProduct}) => { - let {softwareProductComponents: {componentProcesses = {}}} = softwareProduct; - let {processesList = [], processesEditor = {}} = componentProcesses; - let {data, genericFieldInfo, formReady} = processesEditor; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductComponents: { componentProcesses = {} } + } = softwareProduct; + let { processesList = [], processesEditor = {} } = componentProcesses; + let { data, genericFieldInfo, formReady } = processesEditor; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - let previousData; - const processId = data ? data.id : null; - if(processId) { - previousData = processesList.find(process => process.id === processId); - } + let previousData; + const processId = data ? data.id : null; + if (processId) { + previousData = processesList.find(process => process.id === processId); + } - return { - data, - genericFieldInfo, - previousData, - isFormValid, - formReady - }; + return { + data, + genericFieldInfo, + previousData, + isFormValid, + formReady + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, version, componentId}) => { - - return { - onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM}), - onCancel: () => SoftwareProductComponentProcessesActionHelper.closeEditor(dispatch), - onSubmit: ({previousProcess, process}) => { - SoftwareProductComponentProcessesActionHelper.closeEditor(dispatch); - SoftwareProductComponentProcessesActionHelper.saveProcess(dispatch, {softwareProductId, version, previousProcess, componentId, process}); - }, - onValidateForm: () => ValidationHelper.validateForm(dispatch, SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM) - }; +const mapActionsToProps = ( + dispatch, + { softwareProductId, version, componentId } +) => { + return { + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM + }), + onCancel: () => + SoftwareProductComponentProcessesActionHelper.closeEditor(dispatch), + onSubmit: ({ previousProcess, process }) => { + SoftwareProductComponentProcessesActionHelper.closeEditor(dispatch); + SoftwareProductComponentProcessesActionHelper.saveProcess( + dispatch, + { + softwareProductId, + version, + previousProcess, + componentId, + process + } + ); + }, + onValidateForm: () => + ValidationHelper.validateForm( + dispatch, + SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM + ) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(SoftwareProductComponentProcessesEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + SoftwareProductComponentProcessesEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorReducer.js index 9afaa6d5fd..fd211734df 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorReducer.js @@ -13,42 +13,48 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM} from './SoftwareProductComponentProcessesConstants.js'; +import { + actionTypes, + SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM +} from './SoftwareProductComponentProcessesConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_OPEN: - return { - ...state, - formReady: null, - formName: SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM, - genericFieldInfo: { - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}] - }, - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}] - }, - 'artifactName' : { - isValid: true, - errorText: '', - validations: [] - }, - 'type' : { - isValid: true, - errorText: '', - validations: [] - } - }, - data: action.process - }; - case actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_CLOSE: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_OPEN: + return { + ...state, + formReady: null, + formName: SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM, + genericFieldInfo: { + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 120 } + ] + }, + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }] + }, + artifactName: { + isValid: true, + errorText: '', + validations: [] + }, + type: { + isValid: true, + errorText: '', + validations: [] + } + }, + data: action.process + }; + case actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_CLOSE: + return {}; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorView.jsx index 9841ecbae7..132ebe86fb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorView.jsx @@ -14,17 +14,18 @@ * permissions and limitations under the License. */ import React from 'react'; -import {optionsInputValues as ComponentProcessesOptionsInputValues} from './SoftwareProductComponentProcessesConstants.js'; +import { optionsInputValues as ComponentProcessesOptionsInputValues } from './SoftwareProductComponentProcessesConstants.js'; import SoftwareProductProcessesEditorForm from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorForm.jsx'; - class SoftwareProductProcessesEditorView extends React.Component { - - render() { - return ( - - ); - } + render() { + return ( + + ); + } } export default SoftwareProductProcessesEditorView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesList.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesList.js index 2a7152ef8b..cb6d25a6ac 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesList.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesList.js @@ -13,45 +13,64 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import SoftwareProductComponentProcessesActionHelper from './SoftwareProductComponentProcessesActionHelper.js'; import SoftwareProductComponentsProcessesListView from './SoftwareProductComponentsProcessesListView.jsx'; -export const mapStateToProps = ({softwareProduct}) => { - - let {softwareProductEditor: {data:currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents: {componentProcesses = {}}} = softwareProduct; - let{processesList = [], processesEditor = {}} = componentProcesses; - let {data} = processesEditor; - - return { - currentSoftwareProduct, - isValidityData, - processesList, - isDisplayModal: Boolean(data), - isModalInEditMode: Boolean(data && data.id) - }; +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductEditor: { + data: currentSoftwareProduct = {}, + isValidityData = true + }, + softwareProductComponents: { componentProcesses = {} } + } = softwareProduct; + let { processesList = [], processesEditor = {} } = componentProcesses; + let { data } = processesEditor; + return { + currentSoftwareProduct, + isValidityData, + processesList, + isDisplayModal: Boolean(data), + isModalInEditMode: Boolean(data && data.id) + }; }; -const mapActionsToProps = (dispatch, {componentId, softwareProductId, version}) => { - - return { - onAddProcess: () => SoftwareProductComponentProcessesActionHelper.openEditor(dispatch), - onEditProcess: (process) => SoftwareProductComponentProcessesActionHelper.openEditor(dispatch, process), - onDeleteProcess: (process) => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data:{ - msg: i18n('Are you sure you want to delete "{name}"?', {name: process.name}), - confirmationButtonText: i18n('Delete'), - title: i18n('Delete'), - onConfirmed: ()=> SoftwareProductComponentProcessesActionHelper.deleteProcess(dispatch, - {process, softwareProductId, version, componentId}) - } - }) - }; +const mapActionsToProps = ( + dispatch, + { componentId, softwareProductId, version } +) => { + return { + onAddProcess: () => + SoftwareProductComponentProcessesActionHelper.openEditor(dispatch), + onEditProcess: process => + SoftwareProductComponentProcessesActionHelper.openEditor( + dispatch, + process + ), + onDeleteProcess: process => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + msg: i18n('Are you sure you want to delete "{name}"?', { + name: process.name + }), + confirmationButtonText: i18n('Delete'), + title: i18n('Delete'), + onConfirmed: () => + SoftwareProductComponentProcessesActionHelper.deleteProcess( + dispatch, + { process, softwareProductId, version, componentId } + ) + } + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductComponentsProcessesListView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductComponentsProcessesListView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesListReducer.js index 98e24a9c21..d406f02c19 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesListReducer.js @@ -13,20 +13,26 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductComponentProcessesConstants.js'; +import { actionTypes } from './SoftwareProductComponentProcessesConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES: - return [...action.processesList]; - case actionTypes.EDIT_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: - const indexForEdit = state.findIndex(process => process.id === action.process.id); - return [...state.slice(0, indexForEdit), action.process, ...state.slice(indexForEdit + 1)]; - case actionTypes.ADD_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: - return [...state, action.process]; - case actionTypes.DELETE_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: - return state.filter(process => process.id !== action.processId); - default: - return state; - } + switch (action.type) { + case actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES: + return [...action.processesList]; + case actionTypes.EDIT_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: + const indexForEdit = state.findIndex( + process => process.id === action.process.id + ); + return [ + ...state.slice(0, indexForEdit), + action.process, + ...state.slice(indexForEdit + 1) + ]; + case actionTypes.ADD_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: + return [...state, action.process]; + case actionTypes.DELETE_SOFTWARE_PRODUCT_COMPONENTS_PROCESS: + return state.filter(process => process.id !== action.processId); + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesListView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesListView.jsx index 27c4b9f429..8fa2bffb27 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesListView.jsx @@ -21,55 +21,73 @@ import SoftwareProductProcessesEditor from './SoftwareProductComponentProcessesE import SoftwareProductProcessListView from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessListView.jsx'; class SoftwareProductProcessesView extends React.Component { + state = { + localFilter: '' + }; - state = { - localFilter: '' - }; + static propTypes = { + onAddProcess: PropTypes.func, + onEditProcess: PropTypes.func, + onDeleteProcess: PropTypes.func, + isDisplayModal: PropTypes.bool, + isModalInEditMode: PropTypes.bool, + onStorageSelect: PropTypes.func, + componentId: PropTypes.string, + softwareProductId: PropTypes.string, + currentSoftwareProduct: PropTypes.object + }; - static propTypes = { - onAddProcess: PropTypes.func, - onEditProcess: PropTypes.func, - onDeleteProcess: PropTypes.func, - isDisplayModal: PropTypes.bool, - isModalInEditMode: PropTypes.bool, - onStorageSelect: PropTypes.func, - componentId: PropTypes.string, - softwareProductId: PropTypes.string, - currentSoftwareProduct: PropTypes.object - }; - - render() { - return ( -
    -
    -
    - {this.renderEditor()} - -
    -
    -
    - ); - } - - renderEditor() { - let {softwareProductId, version, componentId, isReadOnlyMode, isDisplayModal, isModalInEditMode} = this.props; - return ( - - - {isModalInEditMode ? i18n('Edit Process Details') : i18n('Create New Process Details')} - - - - - - - ); - } + render() { + return ( +
    +
    +
    + {this.renderEditor()} + +
    +
    +
    + ); + } + renderEditor() { + let { + softwareProductId, + version, + componentId, + isReadOnlyMode, + isDisplayModal, + isModalInEditMode + } = this.props; + return ( + + + + {isModalInEditMode + ? i18n('Edit Process Details') + : i18n('Create New Process Details')} + + + + + + + ); + } } export default SoftwareProductProcessesView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorage.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorage.js index ca27a76a18..8da9b99a33 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorage.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorage.js @@ -13,32 +13,57 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; import SoftwareProductComponentStorageView from './SoftwareProductComponentStorageView.jsx'; -import {COMPONENTS_QUESTIONNAIRE} from '../SoftwareProductComponentsConstants.js'; +import { COMPONENTS_QUESTIONNAIRE } from '../SoftwareProductComponentsConstants.js'; -const mapStateToProps = ({softwareProduct: {softwareProductComponents}}) => { - let {componentEditor: {qdata, qgenericFieldInfo : qGenericFieldInfo, dataMap}} = softwareProductComponents; +const mapStateToProps = ({ + softwareProduct: { softwareProductComponents } +}) => { + let { + componentEditor: { + qdata, + qgenericFieldInfo: qGenericFieldInfo, + dataMap + } + } = softwareProductComponents; - return { - qdata, - qGenericFieldInfo, - dataMap - }; + return { + qdata, + qGenericFieldInfo, + dataMap + }; }; -const mapActionToProps = (dispatch, {softwareProductId, version, componentId}) => { - return { - onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, qName: COMPONENTS_QUESTIONNAIRE}), - onSubmit: ({qdata}) => { - return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId: componentId, qdata}); - } - }; +const mapActionToProps = ( + dispatch, + { softwareProductId, version, componentId } +) => { + return { + onQDataChanged: deltaData => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + qName: COMPONENTS_QUESTIONNAIRE + }), + onSubmit: ({ qdata }) => { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire( + dispatch, + { + softwareProductId, + version, + vspComponentId: componentId, + qdata + } + ); + } + }; }; -export default connect(mapStateToProps, mapActionToProps, null, {withRef: true}) (SoftwareProductComponentStorageView); +export default connect(mapStateToProps, mapActionToProps, null, { + withRef: true +})(SoftwareProductComponentStorageView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorageView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorageView.jsx index 8538dab6bc..ac7e4a8053 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorageView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/storage/SoftwareProductComponentStorageView.jsx @@ -22,171 +22,311 @@ import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; import classnames from 'classnames'; -const BackupSection = ({isReadOnlyMode,dataMap, onQDataChanged, qgenericFieldInfo}) => ( - - -
    - -
    - {qgenericFieldInfo['storage/backup/backupType'].enum.map(onSite => ( - onQDataChanged({'storage/backup/backupType' : site})} - isValid={qgenericFieldInfo['storage/backup/backupType'].isValid} - errorText={qgenericFieldInfo['storage/backup/backupType'].errorText} - checked={dataMap['storage/backup/backupType'] === onSite.enum} /> )) } -
    -
    -
    - - onQDataChanged({'storage/backup/backupSolution' : backupSolution})} - label={i18n('Backup Solution')} - type='text' - isValid={qgenericFieldInfo['storage/backup/backupSolution'].isValid} - errorText={qgenericFieldInfo['storage/backup/backupSolution'].errorText} - value={dataMap['storage/backup/backupSolution']}/> - - - onQDataChanged({'storage/backup/backupStorageSize' : backupStorageSize})} - label={i18n('Backup Storage Size (GB)')} - type='number' - isValid={qgenericFieldInfo['storage/backup/backupStorageSize'].isValid} - errorText={qgenericFieldInfo['storage/backup/backupStorageSize'].errorText} - value={dataMap['storage/backup/backupStorageSize']}/> - - - { - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onQDataChanged({'storage/backup/backupNIC' : val});} - }> - - {qgenericFieldInfo['storage/backup/backupNIC'].enum.map(hv => )} - - -
    +const BackupSection = ({ + isReadOnlyMode, + dataMap, + onQDataChanged, + qgenericFieldInfo +}) => ( + + +
    + +
    + {qgenericFieldInfo['storage/backup/backupType'].enum.map( + onSite => ( + + onQDataChanged({ + 'storage/backup/backupType': site + }) + } + isValid={ + qgenericFieldInfo[ + 'storage/backup/backupType' + ].isValid + } + errorText={ + qgenericFieldInfo[ + 'storage/backup/backupType' + ].errorText + } + checked={ + dataMap['storage/backup/backupType'] === + onSite.enum + } + /> + ) + )} +
    +
    +
    + + + onQDataChanged({ + 'storage/backup/backupSolution': backupSolution + }) + } + label={i18n('Backup Solution')} + type="text" + isValid={ + qgenericFieldInfo['storage/backup/backupSolution'].isValid + } + errorText={ + qgenericFieldInfo['storage/backup/backupSolution'].errorText + } + value={dataMap['storage/backup/backupSolution']} + /> + + + + onQDataChanged({ + 'storage/backup/backupStorageSize': backupStorageSize + }) + } + label={i18n('Backup Storage Size (GB)')} + type="number" + isValid={ + qgenericFieldInfo['storage/backup/backupStorageSize'] + .isValid + } + errorText={ + qgenericFieldInfo['storage/backup/backupStorageSize'] + .errorText + } + value={dataMap['storage/backup/backupStorageSize']} + /> + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({ 'storage/backup/backupNIC': val }); + }}> + + {qgenericFieldInfo['storage/backup/backupNIC'].enum.map(hv => ( + + ))} + + +
    ); -const SnapshotBackupSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => ( - - - onQDataChanged({'storage/snapshotBackup/snapshotFrequency' : snapshotFrequency})} - label={i18n('Backup Storage Size (GB)')} - type='number' - isValid={qgenericFieldInfo['storage/snapshotBackup/snapshotFrequency'].isValid} - errorText={qgenericFieldInfo['storage/snapshotBackup/snapshotFrequency'].errorText} - value={dataMap['storage/snapshotBackup/snapshotFrequency']}/> - - +const SnapshotBackupSection = ({ + dataMap, + onQDataChanged, + qgenericFieldInfo +}) => ( + + + + onQDataChanged({ + 'storage/snapshotBackup/snapshotFrequency': snapshotFrequency + }) + } + label={i18n('Backup Storage Size (GB)')} + type="number" + isValid={ + qgenericFieldInfo[ + 'storage/snapshotBackup/snapshotFrequency' + ].isValid + } + errorText={ + qgenericFieldInfo[ + 'storage/snapshotBackup/snapshotFrequency' + ].errorText + } + value={dataMap['storage/snapshotBackup/snapshotFrequency']} + /> + + ); -const LogBackupSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => ( - - - onQDataChanged({'storage/logBackup/sizeOfLogFiles' : sizeOfLogFiles})} - label={i18n('Backup Storage Size (GB)')} - type='number' - isValid={qgenericFieldInfo['storage/logBackup/sizeOfLogFiles'].isValid} - errorText={qgenericFieldInfo['storage/logBackup/sizeOfLogFiles'].errorText} - value={dataMap['storage/logBackup/sizeOfLogFiles']}/> - - - onQDataChanged({'storage/logBackup/logRetentionPeriod' : logRetentionPeriod})} - type='number' - isValid={qgenericFieldInfo['storage/logBackup/logRetentionPeriod'].isValid} - errorText={qgenericFieldInfo['storage/logBackup/logRetentionPeriod'].errorText} - value={dataMap['storage/logBackup/logRetentionPeriod']}/> - - - onQDataChanged({'storage/logBackup/logBackupFrequency' : logBackupFrequency})} - type='number' - isValid={qgenericFieldInfo['storage/logBackup/logBackupFrequency'].isValid} - errorText={qgenericFieldInfo['storage/logBackup/logBackupFrequency'].errorText} - value={dataMap['storage/logBackup/logBackupFrequency']}/> - - - onQDataChanged({'storage/logBackup/logFileLocation' : logFileLocation})} - type='text' - isValid={qgenericFieldInfo['storage/logBackup/logFileLocation'].isValid} - errorText={qgenericFieldInfo['storage/logBackup/logFileLocation'].errorText} - value={dataMap['storage/logBackup/logFileLocation']}/> - - +const LogBackupSection = ({ dataMap, onQDataChanged, qgenericFieldInfo }) => ( + + + + onQDataChanged({ + 'storage/logBackup/sizeOfLogFiles': sizeOfLogFiles + }) + } + label={i18n('Backup Storage Size (GB)')} + type="number" + isValid={ + qgenericFieldInfo['storage/logBackup/sizeOfLogFiles'] + .isValid + } + errorText={ + qgenericFieldInfo['storage/logBackup/sizeOfLogFiles'] + .errorText + } + value={dataMap['storage/logBackup/sizeOfLogFiles']} + /> + + + + onQDataChanged({ + 'storage/logBackup/logRetentionPeriod': logRetentionPeriod + }) + } + type="number" + isValid={ + qgenericFieldInfo['storage/logBackup/logRetentionPeriod'] + .isValid + } + errorText={ + qgenericFieldInfo['storage/logBackup/logRetentionPeriod'] + .errorText + } + value={dataMap['storage/logBackup/logRetentionPeriod']} + /> + + + + onQDataChanged({ + 'storage/logBackup/logBackupFrequency': logBackupFrequency + }) + } + type="number" + isValid={ + qgenericFieldInfo['storage/logBackup/logBackupFrequency'] + .isValid + } + errorText={ + qgenericFieldInfo['storage/logBackup/logBackupFrequency'] + .errorText + } + value={dataMap['storage/logBackup/logBackupFrequency']} + /> + + + + onQDataChanged({ + 'storage/logBackup/logFileLocation': logFileLocation + }) + } + type="text" + isValid={ + qgenericFieldInfo['storage/logBackup/logFileLocation'] + .isValid + } + errorText={ + qgenericFieldInfo['storage/logBackup/logFileLocation'] + .errorText + } + value={dataMap['storage/logBackup/logFileLocation']} + /> + + ); class SoftwareProductComponentStorageView extends React.Component { + static propTypes = { + componentId: PropTypes.string, + onQDataChanged: PropTypes.func, + onSubmit: PropTypes.func, + isReadOnlyMode: PropTypes.bool + }; - static propTypes = { - componentId: PropTypes.string, - onQDataChanged: PropTypes.func, - onSubmit: PropTypes.func, - isReadOnlyMode: PropTypes.bool - }; + render() { + let { + onQDataChanged, + dataMap, + qGenericFieldInfo, + isReadOnlyMode, + onSubmit, + qdata + } = this.props; - render() { - let {onQDataChanged, dataMap, qGenericFieldInfo, isReadOnlyMode, onSubmit, qdata} = this.props; + return ( +
    + {qGenericFieldInfo && ( +
    (this.form = form)} + isValid={true} + formReady={null} + onSubmit={() => onSubmit({ qdata })} + className="component-questionnaire-validation-form" + isReadOnlyMode={isReadOnlyMode} + hasButtons={false}> + + + + + )} +
    + ); + } - return( -
    - {qGenericFieldInfo &&
    this.form = form } - isValid={true} - formReady={null} - onSubmit={() => onSubmit({qdata})} - className='component-questionnaire-validation-form' - isReadOnlyMode={isReadOnlyMode} - hasButtons={false}> - - - - } -
    - ); - } - - save(){ - const {qdata, onSubmit} = this.props; - return onSubmit({qdata}); - } + save() { + const { qdata, onSubmit } = this.props; + return onSubmit({ qdata }); + } } export default SoftwareProductComponentStorageView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js index 569b33f999..41584d94e2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js @@ -13,64 +13,96 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductCreationActionHelper from './SoftwareProductCreationActionHelper.js'; import SoftwareProductCreationView from './SoftwareProductCreationView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import SoftwareProductActionHelper from '../SoftwareProductActionHelper.js'; +import SoftwareProductActionHelper from '../SoftwareProductActionHelper.js'; import VersionsPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js'; -import {itemTypes as versionItemTypes} from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.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 { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; import PermissionsActionHelper from 'sdc-app/onboarding/permissions/PermissionsActionHelper.js'; -export const mapStateToProps = ({finalizedLicenseModelList, users: {usersList}, archivedSoftwareProductList, - softwareProductList, finalizedSoftwareProductList, softwareProduct: {softwareProductCreation, softwareProductCategories} }) => { - let {genericFieldInfo} = softwareProductCreation; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); +export const mapStateToProps = ({ + finalizedLicenseModelList, + users: { usersList }, + archivedSoftwareProductList, + softwareProductList, + finalizedSoftwareProductList, + softwareProduct: { softwareProductCreation, softwareProductCategories } +}) => { + let { genericFieldInfo } = softwareProductCreation; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - let VSPNames = {}; - const allVspList = [...softwareProductList, ...finalizedSoftwareProductList, ...archivedSoftwareProductList]; - allVspList.map(item => { - VSPNames[item.name.toLowerCase()] = item.id; - }); - + let VSPNames = {}; + const allVspList = [ + ...softwareProductList, + ...finalizedSoftwareProductList, + ...archivedSoftwareProductList + ]; + allVspList.map(item => { + VSPNames[item.name.toLowerCase()] = item.id; + }); - return { - data: softwareProductCreation.data, - selectedVendorId: softwareProductCreation.selectedVendorId, - disableVendor: softwareProductCreation.disableVendor, - softwareProductCategories, - finalizedLicenseModelList, - isFormValid, - formReady: softwareProductCreation.formReady, - genericFieldInfo, - VSPNames, - usersList - }; + return { + data: softwareProductCreation.data, + selectedVendorId: softwareProductCreation.selectedVendorId, + disableVendor: softwareProductCreation.disableVendor, + softwareProductCategories, + finalizedLicenseModelList, + isFormValid, + formReady: softwareProductCreation.formReady, + genericFieldInfo, + VSPNames, + usersList + }; }; -export const mapActionsToProps = (dispatch) => { - return { - onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), - onCancel: () => SoftwareProductCreationActionHelper.resetData(dispatch), - onSubmit: (softwareProduct, usersList) => { - SoftwareProductCreationActionHelper.resetData(dispatch); - SoftwareProductCreationActionHelper.createSoftwareProduct(dispatch, {softwareProduct}).then(response => { - let {itemId, version} = response; - SoftwareProductActionHelper.fetchSoftwareProductList(dispatch).then(() => - PermissionsActionHelper.fetchItemUsers(dispatch, {itemId, allUsers: usersList}).then(() => - VersionsPageActionHelper.fetchVersions(dispatch, {itemType: versionItemTypes.SOFTWARE_PRODUCT, itemId}).then(() => - ScreensHelper.loadScreen(dispatch, {screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId: itemId, version}}) - ) - ) - ); - }); - }, - onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) - }; +export const mapActionsToProps = dispatch => { + return { + onDataChanged: (deltaData, formName, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName, + customValidations + }), + onCancel: () => SoftwareProductCreationActionHelper.resetData(dispatch), + onSubmit: (softwareProduct, usersList) => { + SoftwareProductCreationActionHelper.resetData(dispatch); + SoftwareProductCreationActionHelper.createSoftwareProduct( + dispatch, + { softwareProduct } + ).then(response => { + let { itemId, version } = response; + SoftwareProductActionHelper.fetchSoftwareProductList( + dispatch + ).then(() => + PermissionsActionHelper.fetchItemUsers(dispatch, { + itemId, + allUsers: usersList + }).then(() => + VersionsPageActionHelper.fetchVersions(dispatch, { + itemType: versionItemTypes.SOFTWARE_PRODUCT, + itemId + }).then(() => + ScreensHelper.loadScreen(dispatch, { + screen: + enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId: itemId, version } + }) + ) + ) + ); + }); + }, + onValidateForm: formName => + ValidationHelper.validateForm(dispatch, formName) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductCreationView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductCreationView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js index b19e460497..1b1fd71fef 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js @@ -17,68 +17,68 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; -import {actionTypes as modalActionTypes, modalSizes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes} from './SoftwareProductCreationConstants.js'; +import { + actionTypes as modalActionTypes, + modalSizes +} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes } from './SoftwareProductCreationConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; function baseUrl() { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/`; } function createSoftwareProduct(softwareProduct) { - return RestAPIUtil.post(baseUrl(), { - ...softwareProduct, - icon: 'icon', - licensingData: {} - }); + return RestAPIUtil.post(baseUrl(), { + ...softwareProduct, + icon: 'icon', + licensingData: {} + }); } const SoftwareProductCreationActionHelper = { + open(dispatch, vendorId) { + SoftwareProductActionHelper.loadSoftwareProductAssociatedData(dispatch); + dispatch({ + type: actionTypes.OPEN, + selectedVendorId: vendorId + }); - open(dispatch, vendorId) { - SoftwareProductActionHelper.loadSoftwareProductAssociatedData(dispatch); - dispatch({ - type: actionTypes.OPEN, - selectedVendorId: vendorId - }); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: + modalContentMapper.SOFTWARE_PRODUCT_CREATION, + title: i18n('New Software Product'), + modalComponentProps: { + vendorId, + size: modalSizes.LARGE + } + } + }); + }, - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.SOFTWARE_PRODUCT_CREATION, - title: i18n('New Software Product'), - modalComponentProps: { - vendorId, - size: modalSizes.LARGE - } - } - }); + resetData(dispatch) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); - }, - - resetData(dispatch) { - - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - - dispatch({ - type: actionTypes.RESET_DATA - }); - }, - - createSoftwareProduct(dispatch, {softwareProduct}) { - return createSoftwareProduct(softwareProduct).then(result => { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_CREATED, - result - }); - return result; - }); - } + dispatch({ + type: actionTypes.RESET_DATA + }); + }, + createSoftwareProduct(dispatch, { softwareProduct }) { + return createSoftwareProduct(softwareProduct).then(result => { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_CREATED, + result + }); + return result; + }); + } }; export default SoftwareProductCreationActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationConstants.js index b941c849cb..ad1034602a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationConstants.js @@ -16,9 +16,9 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - OPEN: null, - RESET_DATA: null, - SOFTWARE_PRODUCT_CREATED: null + OPEN: null, + RESET_DATA: null, + SOFTWARE_PRODUCT_CREATED: null }); export const SP_CREATION_FORM_NAME = 'SPCREATIONFORM'; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js index a7db2b2357..5f70f18f75 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js @@ -13,56 +13,70 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, SP_CREATION_FORM_NAME} from './SoftwareProductCreationConstants.js'; - +import { + actionTypes, + SP_CREATION_FORM_NAME +} from './SoftwareProductCreationConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.OPEN: - return { - ...state, - formName: SP_CREATION_FORM_NAME, - disableVendor: action.selectedVendorId ? true : false, - data: { - vendorId: action.selectedVendorId ? action.selectedVendorId : undefined - }, - genericFieldInfo: { - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'freeEnglishText', data: true}, {type: 'maxLength', data: 1000}, {type: 'required', data: true}] - }, - 'vendorId' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - }, - 'subCategory' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - }, - 'category' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - }, - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 25}, {type: 'validateName', data: true}] - }, - 'onboardingMethod' : { - isValid: true, - errorText: '', - validations: [{type: 'requiredChooseOption', data: true}] - } - }, - showModal: true - }; - case actionTypes.RESET_DATA: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.OPEN: + return { + ...state, + formName: SP_CREATION_FORM_NAME, + disableVendor: action.selectedVendorId ? true : false, + data: { + vendorId: action.selectedVendorId + ? action.selectedVendorId + : undefined + }, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [ + { type: 'freeEnglishText', data: true }, + { type: 'maxLength', data: 1000 }, + { type: 'required', data: true } + ] + }, + vendorId: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + }, + subCategory: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + }, + category: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + }, + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 25 }, + { type: 'validateName', data: true } + ] + }, + onboardingMethod: { + isValid: true, + errorText: '', + validations: [ + { type: 'requiredChooseOption', data: true } + ] + } + }, + showModal: true + }; + case actionTypes.RESET_DATA: + return {}; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx index e491491f4d..e94087cc80 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx @@ -22,194 +22,308 @@ import Form from 'nfvo-components/input/validation/Form.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; -import {SP_CREATION_FORM_NAME} from './SoftwareProductCreationConstants.js'; +import { SP_CREATION_FORM_NAME } from './SoftwareProductCreationConstants.js'; import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js'; import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js'; -import {onboardingMethod as onboardingMethodConst} from '../SoftwareProductConstants.js'; +import { onboardingMethod as onboardingMethodConst } from '../SoftwareProductConstants.js'; const SoftwareProductPropType = PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - description: PropTypes.string, - category: PropTypes.string, - subCategory: PropTypes.string, - vendorId: PropTypes.string + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + category: PropTypes.string, + subCategory: PropTypes.string, + vendorId: PropTypes.string }); class SoftwareProductCreationView extends React.Component { + static propTypes = { + data: SoftwareProductPropType, + finalizedLicenseModelList: PropTypes.array, + softwareProductCategories: PropTypes.array, + VSPNames: PropTypes.object, + usersList: PropTypes.array, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired + }; - static propTypes = { - data: SoftwareProductPropType, - finalizedLicenseModelList: PropTypes.array, - softwareProductCategories: PropTypes.array, - VSPNames: PropTypes.object, - usersList: PropTypes.array, - onDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired - }; - - render() { - let {softwareProductCategories, data = {}, onDataChanged, onCancel, genericFieldInfo, disableVendor} = this.props; - let {name, description, vendorId, subCategory, onboardingMethod} = data; - - const vendorList = this.getVendorList(); - return ( -
    - { genericFieldInfo &&
    this.validationForm = validationForm} - hasButtons={true} - onSubmit={() => this.submit() } - onReset={() => onCancel() } - labledButtons={true} - isValid={this.props.isFormValid} - submitButtonText={i18n('Create')} - formReady={this.props.formReady} - onValidateForm={() => this.validate() }> - - - onDataChanged({name},SP_CREATION_FORM_NAME, {name: name => this.validateName(name)})} - isValid={genericFieldInfo.name.isValid} - errorText={genericFieldInfo.name.errorText} - type='text' - className='field-section' - data-test-id='new-vsp-name' /> - this.onSelectVendor(e)} - isValid={genericFieldInfo.vendorId.isValid} - errorText={genericFieldInfo.vendorId.errorText} - className='input-options-select' - groupClassName='bootstrap-input-options' - data-test-id='new-vsp-vendor' > - {vendorList.map(vendor => - )} - - this.onSelectSubCategory(e)} - isValid={genericFieldInfo.subCategory.isValid} - errorText={genericFieldInfo.subCategory.errorText} - className='input-options-select' - groupClassName='bootstrap-input-options' - data-test-id='new-vsp-category' > - - {softwareProductCategories.map(category => - category.subcategories && - {category.subcategories.map(sub => - )} - ) - } - - - - onDataChanged({description},SP_CREATION_FORM_NAME)} - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} - type='textarea' - className='field-section' - data-test-id='new-vsp-description'/> - - - - } -
    - ); - } - - getVendorList() { - let {finalizedLicenseModelList} = this.props; - - return [{enum: '', title: i18n('please select...')}].concat( - sortByStringProperty(finalizedLicenseModelList, 'name').map(vendor => { - return { - enum: vendor.id, - title: vendor.name - }; - }) - ); - } - - onSelectVendor(e) { - const selectedIndex = e.target.selectedIndex; - const vendorId = e.target.options[selectedIndex].value; - this.props.onDataChanged({vendorId},SP_CREATION_FORM_NAME); - } - - onSelectSubCategory(e) { - const selectedIndex = e.target.selectedIndex; - const subCategory = e.target.options[selectedIndex].value; - let {softwareProductCategories, onDataChanged} = this.props; - let category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory(subCategory, softwareProductCategories); - onDataChanged({category, subCategory},SP_CREATION_FORM_NAME); - } - - submit() { - let {data:softwareProduct, finalizedLicenseModelList, usersList} = this.props; - softwareProduct.vendorName = finalizedLicenseModelList.find(vendor => vendor.id === softwareProduct.vendorId).name; - this.props.onSubmit(softwareProduct, usersList); - } - - validateName(value) { - const {data: {id}, VSPNames} = this.props; - const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: VSPNames}); - - return !isExists ? {isValid: true, errorText: ''} : - {isValid: false, errorText: i18n('Software product by the name \'' + value + '\' already exists. Software product name must be unique')}; - } - - validate() { - this.props.onValidateForm(SP_CREATION_FORM_NAME); - } + render() { + let { + softwareProductCategories, + data = {}, + onDataChanged, + onCancel, + genericFieldInfo, + disableVendor + } = this.props; + let { + name, + description, + vendorId, + subCategory, + onboardingMethod + } = data; + + const vendorList = this.getVendorList(); + return ( +
    + {genericFieldInfo && ( +
    + (this.validationForm = validationForm) + } + hasButtons={true} + onSubmit={() => this.submit()} + onReset={() => onCancel()} + labledButtons={true} + isValid={this.props.isFormValid} + submitButtonText={i18n('Create')} + formReady={this.props.formReady} + onValidateForm={() => this.validate()}> + + + + onDataChanged( + { name }, + SP_CREATION_FORM_NAME, + { + name: name => + this.validateName(name) + } + ) + } + isValid={genericFieldInfo.name.isValid} + errorText={genericFieldInfo.name.errorText} + type="text" + className="field-section" + data-test-id="new-vsp-name" + /> + this.onSelectVendor(e)} + isValid={genericFieldInfo.vendorId.isValid} + errorText={ + genericFieldInfo.vendorId.errorText + } + className="input-options-select" + groupClassName="bootstrap-input-options" + data-test-id="new-vsp-vendor"> + {vendorList.map(vendor => ( + + ))} + + this.onSelectSubCategory(e)} + isValid={ + genericFieldInfo.subCategory.isValid + } + errorText={ + genericFieldInfo.subCategory.errorText + } + className="input-options-select" + groupClassName="bootstrap-input-options" + data-test-id="new-vsp-category"> + + {softwareProductCategories.map( + category => + category.subcategories && ( + + {category.subcategories.map( + sub => ( + + ) + )} + + ) + )} + + + + + onDataChanged( + { description }, + SP_CREATION_FORM_NAME + ) + } + isValid={ + genericFieldInfo.description.isValid + } + errorText={ + genericFieldInfo.description.errorText + } + type="textarea" + className="field-section" + data-test-id="new-vsp-description" + /> + + + + + )} +
    + ); + } + + getVendorList() { + let { finalizedLicenseModelList } = this.props; + + return [{ enum: '', title: i18n('please select...') }].concat( + sortByStringProperty(finalizedLicenseModelList, 'name').map( + vendor => { + return { + enum: vendor.id, + title: vendor.name + }; + } + ) + ); + } + + onSelectVendor(e) { + const selectedIndex = e.target.selectedIndex; + const vendorId = e.target.options[selectedIndex].value; + this.props.onDataChanged({ vendorId }, SP_CREATION_FORM_NAME); + } + + onSelectSubCategory(e) { + const selectedIndex = e.target.selectedIndex; + const subCategory = e.target.options[selectedIndex].value; + let { softwareProductCategories, onDataChanged } = this.props; + let category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory( + subCategory, + softwareProductCategories + ); + onDataChanged({ category, subCategory }, SP_CREATION_FORM_NAME); + } + + submit() { + let { + data: softwareProduct, + finalizedLicenseModelList, + usersList + } = this.props; + softwareProduct.vendorName = finalizedLicenseModelList.find( + vendor => vendor.id === softwareProduct.vendorId + ).name; + this.props.onSubmit(softwareProduct, usersList); + } + + validateName(value) { + const { data: { id }, VSPNames } = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({ + itemId: id, + itemName: value, + list: VSPNames + }); + + return !isExists + ? { isValid: true, errorText: '' } + : { + isValid: false, + errorText: i18n( + "Software product by the name '" + + value + + "' already exists. Software product name must be unique" + ) + }; + } + + validate() { + this.props.onValidateForm(SP_CREATION_FORM_NAME); + } } -const OnboardingProcedure = ({onboardingMethod, onDataChanged, genericFieldInfo}) => { - return( - - - onDataChanged({onboardingMethod: onboardingMethodConst.NETWORK_PACKAGE},SP_CREATION_FORM_NAME)} - type='radio' - data-test-id='new-vsp-creation-procedure-heat' /> - - - onDataChanged({onboardingMethod: onboardingMethodConst.MANUAL},SP_CREATION_FORM_NAME)} - type='radio' - data-test-id='new-vsp-creation-procedure-manual' /> - - - ); +const OnboardingProcedure = ({ + onboardingMethod, + onDataChanged, + genericFieldInfo +}) => { + return ( + + + + onDataChanged( + { + onboardingMethod: + onboardingMethodConst.NETWORK_PACKAGE + }, + SP_CREATION_FORM_NAME + ) + } + type="radio" + data-test-id="new-vsp-creation-procedure-heat" + /> + + + + onDataChanged( + { onboardingMethod: onboardingMethodConst.MANUAL }, + SP_CREATION_FORM_NAME + ) + } + type="radio" + data-test-id="new-vsp-creation-procedure-manual" + /> + + + ); }; export default SoftwareProductCreationView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js index 9888087800..1a0c66d70e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js @@ -13,25 +13,48 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductDependenciesView from './SoftwareProductDependenciesView.jsx'; import SoftwareProductDependenciesActionHelper from './SoftwareProductDependenciesActionHelper.js'; -export const mapStateToProps = ({softwareProduct}) => { - let {softwareProductDependencies, softwareProductComponents: {componentsList}} = softwareProduct; - return { - softwareProductDependencies: softwareProductDependencies, - componentsOptions: componentsList.map(component => ({value: component.id, label: component.displayName})) - }; +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductDependencies, + softwareProductComponents: { componentsList } + } = softwareProduct; + return { + softwareProductDependencies: softwareProductDependencies, + componentsOptions: componentsList.map(component => ({ + value: component.id, + label: component.displayName + })) + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, version}) => { - return { - onDataChanged: (item) => SoftwareProductDependenciesActionHelper.updateDependency(dispatch, {softwareProductId, version, item}), - onDeleteDependency: (item) => SoftwareProductDependenciesActionHelper.removeDependency(dispatch, {softwareProductId, version, item}), - onAddDependency: (item) => SoftwareProductDependenciesActionHelper.createDependency(dispatch, {softwareProductId, version, item}) - }; +const mapActionsToProps = (dispatch, { softwareProductId, version }) => { + return { + onDataChanged: item => + SoftwareProductDependenciesActionHelper.updateDependency(dispatch, { + softwareProductId, + version, + item + }), + onDeleteDependency: item => + SoftwareProductDependenciesActionHelper.removeDependency(dispatch, { + softwareProductId, + version, + item + }), + onAddDependency: item => + SoftwareProductDependenciesActionHelper.createDependency(dispatch, { + softwareProductId, + version, + item + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductDependenciesView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductDependenciesView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js index f04f8faf56..4bbcaa13d5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js @@ -15,83 +15,99 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes, NEW_RULE_TEMP_ID} from './SoftwareProductDependenciesConstants.js'; +import { + actionTypes, + NEW_RULE_TEMP_ID +} from './SoftwareProductDependenciesConstants.js'; function baseUrl(softwareProductId, version) { - const versionId = version.id; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/component-dependencies`; + const versionId = version.id; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/component-dependencies`; } function fetchDependencies(softwareProductId, version) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); } function addDepencency(softwareProductId, version, item) { - return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, { - sourceId: item.sourceId, - targetId: item.targetId, - relationType: item.relationType - }); + return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, { + sourceId: item.sourceId, + targetId: item.targetId, + relationType: item.relationType + }); } - function updateDepencency(softwareProductId, version, item) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${item.id}`, - { - sourceId: item.sourceId, - targetId: item.targetId, - relationType: item.relationType - }); + return RestAPIUtil.put( + `${baseUrl(softwareProductId, version)}/${item.id}`, + { + sourceId: item.sourceId, + targetId: item.targetId, + relationType: item.relationType + } + ); } function removeDependency(softwareProductId, version, item) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version)}/${item.id}`); + return RestAPIUtil.destroy( + `${baseUrl(softwareProductId, version)}/${item.id}` + ); } - const SoftwareProductDependenciesActionHelper = { - updateDependency(dispatch, {softwareProductId, version, item}) { - // if change was made on existing item - we will update the server and refresh the list - // if change was made on the 'new' row - we will only fire the event - if (item.id !== NEW_RULE_TEMP_ID) { - return updateDepencency(softwareProductId, version, item).then(() => { - return this.fetchDependencies(dispatch, {softwareProductId, version}); - }); - } else { - dispatch({ - type: actionTypes.UPDATE_NEW_SOFTWARE_PRODUCT_DEPENDENCY, - item: item - }); - } - }, + updateDependency(dispatch, { softwareProductId, version, item }) { + // if change was made on existing item - we will update the server and refresh the list + // if change was made on the 'new' row - we will only fire the event + if (item.id !== NEW_RULE_TEMP_ID) { + return updateDepencency(softwareProductId, version, item).then( + () => { + return this.fetchDependencies(dispatch, { + softwareProductId, + version + }); + } + ); + } else { + dispatch({ + type: actionTypes.UPDATE_NEW_SOFTWARE_PRODUCT_DEPENDENCY, + item: item + }); + } + }, - createDependency(dispatch, {softwareProductId, version, item}) { - // removing the temp id - delete item.id; - // creating the new dependency - return addDepencency(softwareProductId, version, item).then(() => { - dispatch({ - type: actionTypes.ADD_SOFTWARE_PRODUCT_DEPENDENCY - }); - return this.fetchDependencies(dispatch, {softwareProductId, version}); - }); - }, + createDependency(dispatch, { softwareProductId, version, item }) { + // removing the temp id + delete item.id; + // creating the new dependency + return addDepencency(softwareProductId, version, item).then(() => { + dispatch({ + type: actionTypes.ADD_SOFTWARE_PRODUCT_DEPENDENCY + }); + return this.fetchDependencies(dispatch, { + softwareProductId, + version + }); + }); + }, - removeDependency(dispatch, {softwareProductId, version, item}) { - return removeDependency(softwareProductId, version, item).then( () => { - return this.fetchDependencies(dispatch, {softwareProductId, version}); - }); - }, + removeDependency(dispatch, { softwareProductId, version, item }) { + return removeDependency(softwareProductId, version, item).then(() => { + return this.fetchDependencies(dispatch, { + softwareProductId, + version + }); + }); + }, - fetchDependencies(dispatch, {softwareProductId, version}) { - return fetchDependencies(softwareProductId, version).then( response => { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE, - dependenciesList : response.results - }); - }); - } + fetchDependencies(dispatch, { softwareProductId, version }) { + return fetchDependencies(softwareProductId, version).then(response => { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE, + dependenciesList: response.results + }); + }); + } }; export default SoftwareProductDependenciesActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesConstants.js index c25561da17..32c7387ca2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesConstants.js @@ -16,17 +16,17 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE: null, - ADD_SOFTWARE_PRODUCT_DEPENDENCY: null, - UPDATE_NEW_SOFTWARE_PRODUCT_DEPENDENCY: null + SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE: null, + ADD_SOFTWARE_PRODUCT_DEPENDENCY: null, + UPDATE_NEW_SOFTWARE_PRODUCT_DEPENDENCY: null }); export const relationTypes = { - DEPENDS_ON: 'dependsOn' + DEPENDS_ON: 'dependsOn' }; export const relationTypesOptions = [ - {value: relationTypes.DEPENDS_ON, label: 'Depends On'} + { value: relationTypes.DEPENDS_ON, label: 'Depends On' } ]; -export const NEW_RULE_TEMP_ID = 'newRuleTempId'; \ No newline at end of file +export const NEW_RULE_TEMP_ID = 'newRuleTempId'; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesReducer.js index 3edd3b899a..6e028b1ff2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesReducer.js @@ -1,4 +1,3 @@ - /*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * @@ -15,32 +14,47 @@ * permissions and limitations under the License. */ -import {actionTypes, relationTypes, NEW_RULE_TEMP_ID} from './SoftwareProductDependenciesConstants.js'; -import {checkCyclesAndMarkDependencies} from './SoftwareProductDependenciesUtils.js'; +import { + actionTypes, + relationTypes, + NEW_RULE_TEMP_ID +} from './SoftwareProductDependenciesConstants.js'; +import { checkCyclesAndMarkDependencies } from './SoftwareProductDependenciesUtils.js'; -let newRowObject = {id: NEW_RULE_TEMP_ID, targetId: null, sourceId: null, relationType: relationTypes.DEPENDS_ON}; +let newRowObject = { + id: NEW_RULE_TEMP_ID, + targetId: null, + sourceId: null, + relationType: relationTypes.DEPENDS_ON +}; -export default (state = [Object.assign({}, newRowObject) ], action) => { - switch (action.type) { - case actionTypes.SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE: - // copying the entity with the data for the row that is in the 'add' mode - let newDependency = state.find(dependency => dependency.id === NEW_RULE_TEMP_ID); - action.dependenciesList.push(newDependency); - // returning list from the server with our 'new entity' row - return checkCyclesAndMarkDependencies(action.dependenciesList); - case actionTypes.ADD_SOFTWARE_PRODUCT_DEPENDENCY : - // resetting the entity with the data for the 'add' mode for a new entity - let newArray = state.filter(dependency => dependency.id !== NEW_RULE_TEMP_ID); - newArray.push(Object.assign({}, newRowObject)); - return newArray; - case actionTypes.UPDATE_NEW_SOFTWARE_PRODUCT_DEPENDENCY : - // we really only need this for the 'new' row since we need to change the state to get - // everything updated - let updateArrayIndex = state.findIndex(dependency => dependency.id === NEW_RULE_TEMP_ID); - let updateArray = state.slice(); - updateArray.splice(updateArrayIndex, 1, action.item); - return checkCyclesAndMarkDependencies(updateArray); - default: - return state; - } +export default (state = [Object.assign({}, newRowObject)], action) => { + switch (action.type) { + case actionTypes.SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE: + // copying the entity with the data for the row that is in the 'add' mode + let newDependency = state.find( + dependency => dependency.id === NEW_RULE_TEMP_ID + ); + action.dependenciesList.push(newDependency); + // returning list from the server with our 'new entity' row + return checkCyclesAndMarkDependencies(action.dependenciesList); + case actionTypes.ADD_SOFTWARE_PRODUCT_DEPENDENCY: + // resetting the entity with the data for the 'add' mode for a new entity + let newArray = state.filter( + dependency => dependency.id !== NEW_RULE_TEMP_ID + ); + newArray.push(Object.assign({}, newRowObject)); + return newArray; + case actionTypes.UPDATE_NEW_SOFTWARE_PRODUCT_DEPENDENCY: + // we really only need this for the 'new' row since we need to change the state to get + // everything updated + let updateArrayIndex = state.findIndex( + dependency => dependency.id === NEW_RULE_TEMP_ID + ); + let updateArray = state.slice(); + updateArray.splice(updateArrayIndex, 1, action.item); + return checkCyclesAndMarkDependencies(updateArray); + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesUtils.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesUtils.js index 94d21bd49d..8d5aaf864e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesUtils.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesUtils.js @@ -16,49 +16,77 @@ import DirectedGraph from 'nfvo-utils/DirectedGraph.js'; -function findCycles(graph, node, id, visited = {}, visitedConnections = {}, recursionStack = {}, connectionsWithCycle = {}) { - visited[node] = true; - recursionStack[node] = true; - if (id) { - visitedConnections[id] = true; - } - for (let edge of graph.getEdges(node)) { - if (!visited[edge.target]) { - findCycles(graph, edge.target, edge.id, visited, visitedConnections, recursionStack, connectionsWithCycle); - } else if (recursionStack[edge.target]) { - visitedConnections[edge.id] = true; - for (let connection in visitedConnections) { - connectionsWithCycle[connection] = true; - } - } - } - recursionStack[node] = false; - return {visitedNodes: visited, connectionsWithCycle: connectionsWithCycle}; +function findCycles( + graph, + node, + id, + visited = {}, + visitedConnections = {}, + recursionStack = {}, + connectionsWithCycle = {} +) { + visited[node] = true; + recursionStack[node] = true; + if (id) { + visitedConnections[id] = true; + } + for (let edge of graph.getEdges(node)) { + if (!visited[edge.target]) { + findCycles( + graph, + edge.target, + edge.id, + visited, + visitedConnections, + recursionStack, + connectionsWithCycle + ); + } else if (recursionStack[edge.target]) { + visitedConnections[edge.id] = true; + for (let connection in visitedConnections) { + connectionsWithCycle[connection] = true; + } + } + } + recursionStack[node] = false; + return { + visitedNodes: visited, + connectionsWithCycle: connectionsWithCycle + }; } export function checkCyclesAndMarkDependencies(dependenciesList) { - let overallVisitedNodes = {}; - let overallConnectionsWithCycles = {}; + let overallVisitedNodes = {}; + let overallConnectionsWithCycles = {}; - let g = new DirectedGraph(); - for (let dependency of dependenciesList) { - if (dependency.sourceId !== null && dependency.targetId !== null) { - g.addEdge(dependency.sourceId, dependency.targetId, {id: dependency.id}); - } - } + let g = new DirectedGraph(); + for (let dependency of dependenciesList) { + if (dependency.sourceId !== null && dependency.targetId !== null) { + g.addEdge(dependency.sourceId, dependency.targetId, { + id: dependency.id + }); + } + } - for (let node in g.nodes) { - if (!overallVisitedNodes.node) { - let {visitedNodes, connectionsWithCycle} = findCycles(g, node, undefined); - overallVisitedNodes = {...overallVisitedNodes, ...visitedNodes}; - overallConnectionsWithCycles = {...overallConnectionsWithCycles, ...connectionsWithCycle}; - } - } - return dependenciesList.map(dependency => ( - { - ...dependency, - hasCycle: dependency.sourceId && dependency.targetId ? - overallConnectionsWithCycles.hasOwnProperty(dependency.id) - : undefined - })); + for (let node in g.nodes) { + if (!overallVisitedNodes.node) { + let { visitedNodes, connectionsWithCycle } = findCycles( + g, + node, + undefined + ); + overallVisitedNodes = { ...overallVisitedNodes, ...visitedNodes }; + overallConnectionsWithCycles = { + ...overallConnectionsWithCycles, + ...connectionsWithCycle + }; + } + } + return dependenciesList.map(dependency => ({ + ...dependency, + hasCycle: + dependency.sourceId && dependency.targetId + ? overallConnectionsWithCycles.hasOwnProperty(dependency.id) + : undefined + })); } diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx index ed92de7bb1..3ea1f2d5cc 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx @@ -20,111 +20,201 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import SelectActionTable from 'nfvo-components/table/SelectActionTable.jsx'; import SelectActionTableRow from 'nfvo-components/table/SelectActionTableRow.jsx'; import SelectActionTableCell from 'nfvo-components/table/SelectActionTableCell.jsx'; -import {relationTypesOptions, NEW_RULE_TEMP_ID} from './SoftwareProductDependenciesConstants.js'; +import { + relationTypesOptions, + NEW_RULE_TEMP_ID +} from './SoftwareProductDependenciesConstants.js'; - -const TableActionRow = ({onAction, actionIcon, showAction, dependency, sourceOptions, targetOptions, onDataChanged}) => { - return ( - - { - dependency.sourceId = newVal; - onDataChanged(dependency); - }} /> - - { - dependency.targetId = newVal; - onDataChanged(dependency); - }} /> - - ); +const TableActionRow = ({ + onAction, + actionIcon, + showAction, + dependency, + sourceOptions, + targetOptions, + onDataChanged +}) => { + return ( + + { + dependency.sourceId = newVal; + onDataChanged(dependency); + }} + /> + + { + dependency.targetId = newVal; + onDataChanged(dependency); + }} + /> + + ); }; - export default class SoftwareProductDependenciesView extends React.Component { - filterTargets({componentsOptions, sourceToTargetMapping, selectedSourceId, selectedTargetId}) { - let isInMap = sourceToTargetMapping.hasOwnProperty(selectedSourceId); - return componentsOptions.filter(component => { - if (component.value === selectedTargetId) { - return true; - } else { - return component.value !== selectedSourceId && (isInMap ? sourceToTargetMapping[selectedSourceId].indexOf(component.value) < 0 : true); - } - }); - } - - filterSources({componentsOptions, sourceToTargetMapping, selectedSourceId, selectedTargetId}) { - return componentsOptions.filter(component => { - if (component.value === selectedSourceId) { - return true; - } else { - let isInMap = sourceToTargetMapping.hasOwnProperty(component.value); - return component.value !== selectedTargetId && (isInMap ? sourceToTargetMapping[component.value].indexOf(selectedTargetId) < 0 : true); - } - }); - } + filterTargets({ + componentsOptions, + sourceToTargetMapping, + selectedSourceId, + selectedTargetId + }) { + let isInMap = sourceToTargetMapping.hasOwnProperty(selectedSourceId); + return componentsOptions.filter(component => { + if (component.value === selectedTargetId) { + return true; + } else { + return ( + component.value !== selectedSourceId && + (isInMap + ? sourceToTargetMapping[selectedSourceId].indexOf( + component.value + ) < 0 + : true) + ); + } + }); + } - render() { - let {componentsOptions, softwareProductDependencies, onDataChanged, onAddDependency, onDeleteDependency, isReadOnlyMode} = this.props; - let sourceToTargetMapping = {}; - softwareProductDependencies.map(dependency => { - let isInMap = sourceToTargetMapping.hasOwnProperty(dependency.sourceId); - if (dependency.targetId) { - sourceToTargetMapping[dependency.sourceId] = isInMap ? [...sourceToTargetMapping[dependency.sourceId], dependency.targetId] : [dependency.targetId]; - } - }); - let depList = softwareProductDependencies.filter(dependency => dependency.id !== NEW_RULE_TEMP_ID); - let newDependency = softwareProductDependencies.find(dependency => dependency.id === NEW_RULE_TEMP_ID); - return ( -
    -
    {i18n('Dependencies')}
    - - {!isReadOnlyMode && onAddDependency(newDependency)} - dependency={newDependency} - componentsOptions={componentsOptions} - sourceToTargetMapping={sourceToTargetMapping} - onDataChanged={onDataChanged} - sourceOptions={this.filterSources({componentsOptions, sourceToTargetMapping, selectedSourceId: newDependency.sourceId, selectedTargetId: newDependency.targetId})} - targetOptions={this.filterTargets({componentsOptions, sourceToTargetMapping, selectedSourceId: newDependency.sourceId, selectedTargetId: newDependency.targetId})} - showAction={newDependency.targetId !== null && newDependency.relationType !== null && newDependency.sourceId !== null}/> } - {depList.map(dependency => ( - onDeleteDependency(dependency)} - dependency={dependency} - componentsOptions={componentsOptions} - sourceToTargetMapping={sourceToTargetMapping} - sourceOptions={this.filterSources({componentsOptions, sourceToTargetMapping, selectedSourceId: dependency.sourceId, selectedTargetId: dependency.targetId})} - targetOptions={this.filterTargets({componentsOptions, sourceToTargetMapping, selectedSourceId: dependency.sourceId, selectedTargetId: dependency.targetId})} - onDataChanged={onDataChanged} - showAction={true}/> - ))} - -
    - ); - } + filterSources({ + componentsOptions, + sourceToTargetMapping, + selectedSourceId, + selectedTargetId + }) { + return componentsOptions.filter(component => { + if (component.value === selectedSourceId) { + return true; + } else { + let isInMap = sourceToTargetMapping.hasOwnProperty( + component.value + ); + return ( + component.value !== selectedTargetId && + (isInMap + ? sourceToTargetMapping[component.value].indexOf( + selectedTargetId + ) < 0 + : true) + ); + } + }); + } + render() { + let { + componentsOptions, + softwareProductDependencies, + onDataChanged, + onAddDependency, + onDeleteDependency, + isReadOnlyMode + } = this.props; + let sourceToTargetMapping = {}; + softwareProductDependencies.map(dependency => { + let isInMap = sourceToTargetMapping.hasOwnProperty( + dependency.sourceId + ); + if (dependency.targetId) { + sourceToTargetMapping[dependency.sourceId] = isInMap + ? [ + ...sourceToTargetMapping[dependency.sourceId], + dependency.targetId + ] + : [dependency.targetId]; + } + }); + let depList = softwareProductDependencies.filter( + dependency => dependency.id !== NEW_RULE_TEMP_ID + ); + let newDependency = softwareProductDependencies.find( + dependency => dependency.id === NEW_RULE_TEMP_ID + ); + return ( +
    +
    {i18n('Dependencies')}
    + + {!isReadOnlyMode && ( + onAddDependency(newDependency)} + dependency={newDependency} + componentsOptions={componentsOptions} + sourceToTargetMapping={sourceToTargetMapping} + onDataChanged={onDataChanged} + sourceOptions={this.filterSources({ + componentsOptions, + sourceToTargetMapping, + selectedSourceId: newDependency.sourceId, + selectedTargetId: newDependency.targetId + })} + targetOptions={this.filterTargets({ + componentsOptions, + sourceToTargetMapping, + selectedSourceId: newDependency.sourceId, + selectedTargetId: newDependency.targetId + })} + showAction={ + newDependency.targetId !== null && + newDependency.relationType !== null && + newDependency.sourceId !== null + } + /> + )} + {depList.map(dependency => ( + onDeleteDependency(dependency)} + dependency={dependency} + componentsOptions={componentsOptions} + sourceToTargetMapping={sourceToTargetMapping} + sourceOptions={this.filterSources({ + componentsOptions, + sourceToTargetMapping, + selectedSourceId: dependency.sourceId, + selectedTargetId: dependency.targetId + })} + targetOptions={this.filterTargets({ + componentsOptions, + sourceToTargetMapping, + selectedSourceId: dependency.sourceId, + selectedTargetId: dependency.targetId + })} + onDataChanged={onDataChanged} + showAction={true} + /> + ))} + +
    + ); + } } diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeployment.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeployment.js index a5c70068b0..4e03926ac5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeployment.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeployment.js @@ -13,37 +13,70 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductDeploymentView from './SoftwareProductDeploymentView.jsx'; import SoftwareProductDeploymentActionHelper from './SoftwareProductDeploymentActionHelper.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; -export function mapStateToProps({softwareProduct}) { - let {softwareProductComponents: {componentsList}, softwareProductDeployment: {deploymentFlavors}} = softwareProduct; - return { - deploymentFlavors, - componentsList - }; +export function mapStateToProps({ softwareProduct }) { + let { + softwareProductComponents: { componentsList }, + softwareProductDeployment: { deploymentFlavors } + } = softwareProduct; + return { + deploymentFlavors, + componentsList + }; } -function mapActionToProps(dispatch, {softwareProductId, version}) { - let modalClassName = 'deployment-flavor-editor'; - return { - onAddDeployment: componentsList => SoftwareProductDeploymentActionHelper.openDeploymentFlavorEditor(dispatch, {softwareProductId, modalClassName, componentsList, version}), - onDeleteDeployment: ({id, model}) => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data:{ - msg: i18n('Are you sure you want to delete "{model}"?', {model: model}), - onConfirmed: () => SoftwareProductDeploymentActionHelper.deleteDeploymentFlavor(dispatch, {softwareProductId, deploymentFlavorId: id, version}) - } - }), - onEditDeployment: (deploymentFlavor, componentsList) => - SoftwareProductDeploymentActionHelper.fetchDeploymentFlavor({softwareProductId, deploymentFlavorId: deploymentFlavor.id, version}).then(response => - SoftwareProductDeploymentActionHelper - .openDeploymentFlavorEditor(dispatch, {softwareProductId, componentsList, modalClassName, deploymentFlavor: {...response.data, id: response.id}, isEdit: true, version}), - ) - }; +function mapActionToProps(dispatch, { softwareProductId, version }) { + let modalClassName = 'deployment-flavor-editor'; + return { + onAddDeployment: componentsList => + SoftwareProductDeploymentActionHelper.openDeploymentFlavorEditor( + dispatch, + { softwareProductId, modalClassName, componentsList, version } + ), + onDeleteDeployment: ({ id, model }) => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + msg: i18n('Are you sure you want to delete "{model}"?', { + model: model + }), + onConfirmed: () => + SoftwareProductDeploymentActionHelper.deleteDeploymentFlavor( + dispatch, + { + softwareProductId, + deploymentFlavorId: id, + version + } + ) + } + }), + onEditDeployment: (deploymentFlavor, componentsList) => + SoftwareProductDeploymentActionHelper.fetchDeploymentFlavor({ + softwareProductId, + deploymentFlavorId: deploymentFlavor.id, + version + }).then(response => + SoftwareProductDeploymentActionHelper.openDeploymentFlavorEditor( + dispatch, + { + softwareProductId, + componentsList, + modalClassName, + deploymentFlavor: { ...response.data, id: response.id }, + isEdit: true, + version + } + ) + ) + }; } -export default connect(mapStateToProps, mapActionToProps, null, {withRef: true})(SoftwareProductDeploymentView); +export default connect(mapStateToProps, mapActionToProps, null, { + withRef: true +})(SoftwareProductDeploymentView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentActionHelper.js index bd802b38f4..44b25311e0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentActionHelper.js @@ -1,101 +1,183 @@ -import {actionTypes} from './SoftwareProductDeploymentConstants.js'; -import {actionTypes as GlobalModalActions} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes } from './SoftwareProductDeploymentConstants.js'; +import { actionTypes as GlobalModalActions } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import pickBy from 'lodash/pickBy'; function baseUrl(vspId, version) { - const versionId = version.id; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/deployment-flavors`; + const versionId = version.id; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/deployment-flavors`; } -function fetchDeploymentFlavorsList({softwareProductId, version}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); +function fetchDeploymentFlavorsList({ softwareProductId, version }) { + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); } -function fetchDeploymentFlavor({softwareProductId, deploymentFlavorId, version}) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}/${deploymentFlavorId}`); +function fetchDeploymentFlavor({ + softwareProductId, + deploymentFlavorId, + version +}) { + return RestAPIUtil.fetch( + `${baseUrl(softwareProductId, version)}/${deploymentFlavorId}` + ); } -function deleteDeploymentFlavor({softwareProductId, deploymentFlavorId, version}) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version)}/${deploymentFlavorId}`); +function deleteDeploymentFlavor({ + softwareProductId, + deploymentFlavorId, + version +}) { + return RestAPIUtil.destroy( + `${baseUrl(softwareProductId, version)}/${deploymentFlavorId}` + ); } -function createDeploymentFlavor({softwareProductId, data, version}) { - return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, data); +function createDeploymentFlavor({ softwareProductId, data, version }) { + return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, data); } -function editDeploymentFlavor({softwareProductId, deploymentFlavorId, data, version}) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${deploymentFlavorId}`, data); +function editDeploymentFlavor({ + softwareProductId, + deploymentFlavorId, + data, + version +}) { + return RestAPIUtil.put( + `${baseUrl(softwareProductId, version)}/${deploymentFlavorId}`, + data + ); } const SoftwareProductDeploymentActionHelper = { - fetchDeploymentFlavorsList(dispatch, {softwareProductId, version}) { - return fetchDeploymentFlavorsList({softwareProductId, version}).then(response => { - dispatch({ - type: actionTypes.FETCH_SOFTWARE_PRODUCT_DEPLOYMENT_FLAVORS, - deploymentFlavors: response.results - }); - }); - }, + fetchDeploymentFlavorsList(dispatch, { softwareProductId, version }) { + return fetchDeploymentFlavorsList({ softwareProductId, version }).then( + response => { + dispatch({ + type: actionTypes.FETCH_SOFTWARE_PRODUCT_DEPLOYMENT_FLAVORS, + deploymentFlavors: response.results + }); + } + ); + }, - fetchDeploymentFlavor({softwareProductId, deploymentFlavorId, version}) { - return fetchDeploymentFlavor({softwareProductId, deploymentFlavorId, version}); - }, + fetchDeploymentFlavor({ softwareProductId, deploymentFlavorId, version }) { + return fetchDeploymentFlavor({ + softwareProductId, + deploymentFlavorId, + version + }); + }, - deleteDeploymentFlavor(dispatch, {softwareProductId, deploymentFlavorId, version}) { - return deleteDeploymentFlavor({softwareProductId, deploymentFlavorId, version}).then(() => { - return SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList(dispatch, {softwareProductId, version}); - }); - }, + deleteDeploymentFlavor( + dispatch, + { softwareProductId, deploymentFlavorId, version } + ) { + return deleteDeploymentFlavor({ + softwareProductId, + deploymentFlavorId, + version + }).then(() => { + return SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList( + dispatch, + { softwareProductId, version } + ); + }); + }, - createDeploymentFlavor(dispatch, {softwareProductId, data, version}) { - return createDeploymentFlavor({softwareProductId, data, version}).then(() => { - return SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList(dispatch, {softwareProductId, version}); - }); - }, + createDeploymentFlavor(dispatch, { softwareProductId, data, version }) { + return createDeploymentFlavor({ + softwareProductId, + data, + version + }).then(() => { + return SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList( + dispatch, + { softwareProductId, version } + ); + }); + }, - editDeploymentFlavor(dispatch, {softwareProductId, deploymentFlavorId, data, version}) { - let dataWithoutId = pickBy(data, (val, key) => key !== 'id'); - return editDeploymentFlavor({softwareProductId, deploymentFlavorId, data: dataWithoutId, version}).then(() => { - return SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList(dispatch, {softwareProductId, version}); - }); - }, + editDeploymentFlavor( + dispatch, + { softwareProductId, deploymentFlavorId, data, version } + ) { + let dataWithoutId = pickBy(data, (val, key) => key !== 'id'); + return editDeploymentFlavor({ + softwareProductId, + deploymentFlavorId, + data: dataWithoutId, + version + }).then(() => { + return SoftwareProductDeploymentActionHelper.fetchDeploymentFlavorsList( + dispatch, + { softwareProductId, version } + ); + }); + }, - closeDeploymentFlavorEditor(dispatch) { - dispatch({ - type: actionTypes.deploymentFlavorEditor.SOFTWARE_PRODUCT_DEPLOYMENT_CLEAR_DATA - }); - dispatch({ - type: GlobalModalActions.GLOBAL_MODAL_CLOSE - }); - }, + closeDeploymentFlavorEditor(dispatch) { + dispatch({ + type: + actionTypes.deploymentFlavorEditor + .SOFTWARE_PRODUCT_DEPLOYMENT_CLEAR_DATA + }); + dispatch({ + type: GlobalModalActions.GLOBAL_MODAL_CLOSE + }); + }, - openDeploymentFlavorEditor(dispatch, {softwareProductId, modalClassName, deploymentFlavor = {}, componentsList, isEdit = false, version}) { - let alteredDeploymentFlavor = {...deploymentFlavor}; - if (componentsList.length) { - alteredDeploymentFlavor = {...alteredDeploymentFlavor, componentComputeAssociations: deploymentFlavor.componentComputeAssociations ? - [{...deploymentFlavor.componentComputeAssociations[0], componentId: componentsList[0].id}] - : - [{componentId: componentsList[0].id, computeFlavorId: null}] - }; - } - dispatch({ - type: actionTypes.deploymentFlavorEditor.SOFTWARE_PRODUCT_DEPLOYMENT_FILL_DATA, - deploymentFlavor: alteredDeploymentFlavor - }); - dispatch({ - type: GlobalModalActions.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.DEPLOYMENT_FLAVOR_EDITOR, - modalComponentProps: {softwareProductId, version}, - modalClassName, - title: isEdit ? 'Edit Deployment Flavor' : 'Create a New Deployment Flavor' - } - }); - }, + openDeploymentFlavorEditor( + dispatch, + { + softwareProductId, + modalClassName, + deploymentFlavor = {}, + componentsList, + isEdit = false, + version + } + ) { + let alteredDeploymentFlavor = { ...deploymentFlavor }; + if (componentsList.length) { + alteredDeploymentFlavor = { + ...alteredDeploymentFlavor, + componentComputeAssociations: deploymentFlavor.componentComputeAssociations + ? [ + { + ...deploymentFlavor + .componentComputeAssociations[0], + componentId: componentsList[0].id + } + ] + : [ + { + componentId: componentsList[0].id, + computeFlavorId: null + } + ] + }; + } + dispatch({ + type: + actionTypes.deploymentFlavorEditor + .SOFTWARE_PRODUCT_DEPLOYMENT_FILL_DATA, + deploymentFlavor: alteredDeploymentFlavor + }); + dispatch({ + type: GlobalModalActions.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.DEPLOYMENT_FLAVOR_EDITOR, + modalComponentProps: { softwareProductId, version }, + modalClassName, + title: isEdit + ? 'Edit Deployment Flavor' + : 'Create a New Deployment Flavor' + } + }); + } }; -export default SoftwareProductDeploymentActionHelper; +export default SoftwareProductDeploymentActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentConstants.js index 51469b461c..6c0d3efe38 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentConstants.js @@ -16,13 +16,13 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - FETCH_SOFTWARE_PRODUCT_DEPLOYMENT_FLAVORS: null, + FETCH_SOFTWARE_PRODUCT_DEPLOYMENT_FLAVORS: null, - deploymentFlavorEditor: { - DATA_CHANGED: null, - SOFTWARE_PRODUCT_DEPLOYMENT_FILL_DATA: null, - SOFTWARE_PRODUCT_DEPLOYMENT_CLEAR_DATA: null - } + deploymentFlavorEditor: { + DATA_CHANGED: null, + SOFTWARE_PRODUCT_DEPLOYMENT_FILL_DATA: null, + SOFTWARE_PRODUCT_DEPLOYMENT_CLEAR_DATA: null + } }); export const DEPLOYMENT_FLAVORS_FORM_NAME = 'DEPLOYMENT_FLAVORS_FORM_NAME'; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentListReducer.js index 8eb91e8fcb..31bf09e945 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentListReducer.js @@ -13,13 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductDeploymentConstants.js'; +import { actionTypes } from './SoftwareProductDeploymentConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.FETCH_SOFTWARE_PRODUCT_DEPLOYMENT_FLAVORS: - return [...action.deploymentFlavors]; - default: - return state; - } + switch (action.type) { + case actionTypes.FETCH_SOFTWARE_PRODUCT_DEPLOYMENT_FLAVORS: + return [...action.deploymentFlavors]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentView.jsx index 860d02c343..e1bdd553a6 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentView.jsx @@ -22,74 +22,82 @@ import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.js import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; export default class SoftwareProductDeployment extends React.Component { - state = { - localFilter: '' - }; + state = { + localFilter: '' + }; - static propTypes = { - onAddDeployment: PropTypes.func.isRequired, - onDeleteDeployment: PropTypes.func.isRequired, - onEditDeployment: PropTypes.func.isRequired, - isReadOnlyMode: PropTypes.bool.isRequired - }; + static propTypes = { + onAddDeployment: PropTypes.func.isRequired, + onDeleteDeployment: PropTypes.func.isRequired, + onEditDeployment: PropTypes.func.isRequired, + isReadOnlyMode: PropTypes.bool.isRequired + }; - render() { - return ( -
    - {this.renderList()} -
    - ); - } + render() { + return
    {this.renderList()}
    ; + } - renderList() { - let {onAddDeployment, isReadOnlyMode, componentsList} = this.props; - return ( - onAddDeployment(componentsList)} - isReadOnlyMode={isReadOnlyMode} - title={i18n('Deployment Flavors')} - onFilter={value => this.setState({localFilter: value})} - twoColumns> - {this.filterList().map(deploymentFlavor => this.renderListItem(deploymentFlavor, isReadOnlyMode))} - - ); - } + renderList() { + let { onAddDeployment, isReadOnlyMode, componentsList } = this.props; + return ( + onAddDeployment(componentsList)} + isReadOnlyMode={isReadOnlyMode} + title={i18n('Deployment Flavors')} + onFilter={value => this.setState({ localFilter: value })} + twoColumns> + {this.filterList().map(deploymentFlavor => + this.renderListItem(deploymentFlavor, isReadOnlyMode) + )} + + ); + } - renderListItem(deploymentFlavor, isReadOnlyMode) { - let {id, model, description} = deploymentFlavor; - let {onEditDeployment, onDeleteDeployment, componentsList} = this.props; - return ( - onEditDeployment(deploymentFlavor, componentsList)} - onDelete={() => onDeleteDeployment(deploymentFlavor)}> - -
    {model}
    -
    - -
    {description}
    -
    -
    - ); - } + renderListItem(deploymentFlavor, isReadOnlyMode) { + let { id, model, description } = deploymentFlavor; + let { + onEditDeployment, + onDeleteDeployment, + componentsList + } = this.props; + return ( + + onEditDeployment(deploymentFlavor, componentsList) + } + onDelete={() => onDeleteDeployment(deploymentFlavor)}> + +
    {model}
    +
    + +
    {description}
    +
    +
    + ); + } - filterList() { - let {deploymentFlavors} = this.props; - let {localFilter} = this.state; + filterList() { + let { deploymentFlavors } = this.props; + let { localFilter } = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return deploymentFlavors.filter(({model = '', description = ''}) => { - return escape(model).match(filter) || escape(description).match(filter); - }); - } - else { - return deploymentFlavors; - } - } + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return deploymentFlavors.filter( + ({ model = '', description = '' }) => { + return ( + escape(model).match(filter) || + escape(description).match(filter) + ); + } + ); + } else { + return deploymentFlavors; + } + } } diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditor.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditor.js index c24548b7b9..9392317692 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditor.js @@ -13,77 +13,103 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductDeploymentEditorView from './SoftwareProductDeploymentEditorView.jsx'; import SoftwareProdcutDeploymentActionHelper from '../SoftwareProductDeploymentActionHelper.js'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {DEPLOYMENT_FLAVORS_FORM_NAME} from '../SoftwareProductDeploymentConstants.js'; +import { DEPLOYMENT_FLAVORS_FORM_NAME } from '../SoftwareProductDeploymentConstants.js'; export function mapStateToProps({ - licenseModel, - softwareProduct, - currentScreen: {props: {isReadOnlyMode}} + licenseModel, + softwareProduct, + currentScreen: { props: { isReadOnlyMode } } }) { - let { - softwareProductEditor: { - data: currentSoftwareProduct = {} - }, - softwareProductComponents: { - componentsList, - computeFlavor: { - computesList - } - }, - softwareProductDeployment: { - deploymentFlavors, - deploymentFlavorEditor: { - data = {}, - genericFieldInfo, - formReady - } - } - } = softwareProduct; + let { + softwareProductEditor: { data: currentSoftwareProduct = {} }, + softwareProductComponents: { + componentsList, + computeFlavor: { computesList } + }, + softwareProductDeployment: { + deploymentFlavors, + deploymentFlavorEditor: { data = {}, genericFieldInfo, formReady } + } + } = softwareProduct; - let { - featureGroup: { - featureGroupsList - } - } = licenseModel; + let { featureGroup: { featureGroupsList } } = licenseModel; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - let selectedFeatureGroupsIds = currentSoftwareProduct.licensingData ? currentSoftwareProduct.licensingData.featureGroups || [] : []; - let selectedFeatureGroupsList = featureGroupsList - .filter(featureGroup => selectedFeatureGroupsIds.includes(featureGroup.id)) - .map(featureGroup => ({value: featureGroup.id, label: featureGroup.name})); + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + let selectedFeatureGroupsIds = currentSoftwareProduct.licensingData + ? currentSoftwareProduct.licensingData.featureGroups || [] + : []; + let selectedFeatureGroupsList = featureGroupsList + .filter(featureGroup => + selectedFeatureGroupsIds.includes(featureGroup.id) + ) + .map(featureGroup => ({ + value: featureGroup.id, + label: featureGroup.name + })); - let DFNames = {}; + let DFNames = {}; - deploymentFlavors.map(deployment => { - DFNames[deployment.model.toLowerCase()] = deployment.id; - }); + deploymentFlavors.map(deployment => { + DFNames[deployment.model.toLowerCase()] = deployment.id; + }); - return { - data, - selectedFeatureGroupsList, - genericFieldInfo, - DFNames, - isFormValid, - formReady, - isReadOnlyMode, - componentsList, - computesList, - isEdit: Boolean(data.id) - }; + return { + data, + selectedFeatureGroupsList, + genericFieldInfo, + DFNames, + isFormValid, + formReady, + isReadOnlyMode, + componentsList, + computesList, + isEdit: Boolean(data.id) + }; } -function mapActionsToProps(dispatch, {softwareProductId, version}) { - return { - onDataChanged: (deltaData, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: DEPLOYMENT_FLAVORS_FORM_NAME, customValidations}), - onClose: () => SoftwareProdcutDeploymentActionHelper.closeDeploymentFlavorEditor(dispatch), - onCreate: data => SoftwareProdcutDeploymentActionHelper.createDeploymentFlavor(dispatch, {softwareProductId, data, version}), - onEdit: data => SoftwareProdcutDeploymentActionHelper.editDeploymentFlavor(dispatch, {softwareProductId, deploymentFlavorId: data.id, data, version}), - onValidateForm: () => ValidationHelper.validateForm(dispatch, DEPLOYMENT_FLAVORS_FORM_NAME) - }; +function mapActionsToProps(dispatch, { softwareProductId, version }) { + return { + onDataChanged: (deltaData, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: DEPLOYMENT_FLAVORS_FORM_NAME, + customValidations + }), + onClose: () => + SoftwareProdcutDeploymentActionHelper.closeDeploymentFlavorEditor( + dispatch + ), + onCreate: data => + SoftwareProdcutDeploymentActionHelper.createDeploymentFlavor( + dispatch, + { + softwareProductId, + data, + version + } + ), + onEdit: data => + SoftwareProdcutDeploymentActionHelper.editDeploymentFlavor( + dispatch, + { + softwareProductId, + deploymentFlavorId: data.id, + data, + version + } + ), + onValidateForm: () => + ValidationHelper.validateForm( + dispatch, + DEPLOYMENT_FLAVORS_FORM_NAME + ) + }; } -export default connect(mapStateToProps, mapActionsToProps)(SoftwareProductDeploymentEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + SoftwareProductDeploymentEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorReducer.js index 70836e8ff9..16e73d2162 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorReducer.js @@ -13,32 +13,37 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, DEPLOYMENT_FLAVORS_FORM_NAME} from '../SoftwareProductDeploymentConstants.js';; +import { + actionTypes, + DEPLOYMENT_FLAVORS_FORM_NAME +} from '../SoftwareProductDeploymentConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.deploymentFlavorEditor.SOFTWARE_PRODUCT_DEPLOYMENT_FILL_DATA: - return { - ...state, - data: action.deploymentFlavor, - formReady: null, - formName: DEPLOYMENT_FLAVORS_FORM_NAME, - genericFieldInfo: { - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 500}] - }, - 'model' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - } - } - }; - case actionTypes.deploymentFlavorEditor.SOFTWARE_PRODUCT_DEPLOYMENT_CLEAR_DATA: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.deploymentFlavorEditor + .SOFTWARE_PRODUCT_DEPLOYMENT_FILL_DATA: + return { + ...state, + data: action.deploymentFlavor, + formReady: null, + formName: DEPLOYMENT_FLAVORS_FORM_NAME, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 500 }] + }, + model: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + } + } + }; + case actionTypes.deploymentFlavorEditor + .SOFTWARE_PRODUCT_DEPLOYMENT_CLEAR_DATA: + return {}; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorView.jsx index 7c9ae438d9..e44d2bd966 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorView.jsx @@ -11,127 +11,240 @@ import SelectActionTableCell from 'nfvo-components/table/SelectActionTableCell.j import Validator from 'nfvo-utils/Validator.js'; export default class SoftwareProductDeploymentEditorView extends React.Component { - render() { - let {data, isEdit, onClose, onDataChanged, isReadOnlyMode, selectedFeatureGroupsList, componentsList, computesList, genericFieldInfo} = this.props; - let {model, description, featureGroupId, componentComputeAssociations = []} = data; - let featureGroupsExist = selectedFeatureGroupsList.length > 0; - return ( -
    - {genericFieldInfo &&
    this.submit() } - submitButtonText={isEdit ? i18n('Save') : i18n('Create')} - onReset={ () => onClose() } - onValidateForm={() => this.validate() } - isValid={this.props.isFormValid} - formReady={this.props.formReady} - className='vsp-deployment-editor'> - - - onDataChanged({model}, {model: model => this.validateName(model)})} - label={i18n('Model')} - value={model} - data-test-id='deployment-model' - isValid={genericFieldInfo.model.isValid} - errorText={genericFieldInfo.model.errorText} - isRequired={true} - type='text'/> - - - onDataChanged({description})} - label={i18n('Description')} - value={description} - data-test-id='deployment-description' - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} - type='text'/> - - - - - onDataChanged({featureGroupId: featureGroup ? featureGroup.value : null})} - type='select' - clearable={true} - disabled={isReadOnlyMode || !featureGroupsExist} - className='field-section' - options={selectedFeatureGroupsList}/> - - - {!featureGroupsExist && - - {i18n('Please assign Feature Groups in VSP General')} - - } - - - - {componentComputeAssociations.map( (association, index) => - - ({value: component.id, label: component.displayName}) ) - } - selected={association.componentId} - onChange={componentId => { - let newAssociations = [...componentComputeAssociations]; - newAssociations[index] = {...newAssociations[index], componentId}; - onDataChanged({componentComputeAssociations: newAssociations}); - }} - disabled={true}/> - compute.componentId === association.componentId) - .map(compute => ({value: compute.computeFlavorId, label: compute.name}) ) - } - selected={association.computeFlavorId} - onChange={computeFlavorId => { - let newAssociations = [...componentComputeAssociations]; - newAssociations[index] = {...newAssociations[index], computeFlavorId}; - onDataChanged({componentComputeAssociations: newAssociations}); - }} - disabled={isReadOnlyMode}/> - - )} - - - -
    } -
    - ); - } + render() { + let { + data, + isEdit, + onClose, + onDataChanged, + isReadOnlyMode, + selectedFeatureGroupsList, + componentsList, + computesList, + genericFieldInfo + } = this.props; + let { + model, + description, + featureGroupId, + componentComputeAssociations = [] + } = data; + let featureGroupsExist = selectedFeatureGroupsList.length > 0; + return ( +
    + {genericFieldInfo && ( +
    this.submit()} + submitButtonText={ + isEdit ? i18n('Save') : i18n('Create') + } + onReset={() => onClose()} + onValidateForm={() => this.validate()} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + className="vsp-deployment-editor"> + + + + onDataChanged( + { model }, + { + model: model => + this.validateName(model) + } + ) + } + label={i18n('Model')} + value={model} + data-test-id="deployment-model" + isValid={genericFieldInfo.model.isValid} + errorText={genericFieldInfo.model.errorText} + isRequired={true} + type="text" + /> + + + + onDataChanged({ description }) + } + label={i18n('Description')} + value={description} + data-test-id="deployment-description" + isValid={ + genericFieldInfo.description.isValid + } + errorText={ + genericFieldInfo.description.errorText + } + type="text" + /> + + + + + + onDataChanged({ + featureGroupId: featureGroup + ? featureGroup.value + : null + }) + } + type="select" + clearable={true} + disabled={ + isReadOnlyMode || !featureGroupsExist + } + className="field-section" + options={selectedFeatureGroupsList} + /> + + + {!featureGroupsExist && ( + + + + {i18n( + 'Please assign Feature Groups in VSP General' + )} + + + + )} + + + + {componentComputeAssociations.map( + (association, index) => ( + + ({ + value: component.id, + label: + component.displayName + }) + )} + selected={ + association.componentId + } + onChange={componentId => { + let newAssociations = [ + ...componentComputeAssociations + ]; + newAssociations[ + index + ] = { + ...newAssociations[ + index + ], + componentId + }; + onDataChanged({ + componentComputeAssociations: newAssociations + }); + }} + disabled={true} + /> + + compute.componentId === + association.componentId + ) + .map(compute => ({ + value: + compute.computeFlavorId, + label: compute.name + }))} + selected={ + association.computeFlavorId + } + onChange={computeFlavorId => { + let newAssociations = [ + ...componentComputeAssociations + ]; + newAssociations[ + index + ] = { + ...newAssociations[ + index + ], + computeFlavorId + }; + onDataChanged({ + componentComputeAssociations: newAssociations + }); + }} + disabled={isReadOnlyMode} + /> + + ) + )} + + + +
    + )} +
    + ); + } - validateName(value) { - const {data: {id = ''}, DFNames} = this.props; - const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: DFNames}); + validateName(value) { + const { data: { id = '' }, DFNames } = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({ + itemId: id, + itemName: value, + list: DFNames + }); - return !isExists ? {isValid: true, errorText: ''} : - {isValid: false, errorText: i18n('Deployment flavor by the name \'' + value + '\' already exists. Deployment flavor name must be unique')}; - } + return !isExists + ? { isValid: true, errorText: '' } + : { + isValid: false, + errorText: i18n( + "Deployment flavor by the name '" + + value + + "' already exists. Deployment flavor name must be unique" + ) + }; + } - submit(){ - let {isEdit, onCreate, onEdit, onClose, data} = this.props; - if (isEdit) { - onEdit(data); - } else { - onCreate(data); - } - onClose(); - } + submit() { + let { isEdit, onCreate, onEdit, onClose, data } = this.props; + if (isEdit) { + onEdit(data); + } else { + onCreate(data); + } + onClose(); + } - validate() { - this.props.onValidateForm(); - } + validate() { + this.props.onValidateForm(); + } } diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js index 0973537d43..8a3279a02c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js @@ -13,80 +13,140 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; import SoftwareProductDetailsView from './SoftwareProductDetailsView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {PRODUCT_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; -import {actionTypes as modalActionTypes, modalSizes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { PRODUCT_QUESTIONNAIRE } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { + actionTypes as modalActionTypes, + modalSizes +} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { forms } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; export const mapStateToProps = ({ - finalizedLicenseModelList, - archivedLicenseModelList, - softwareProduct, - licenseModel: {licenseAgreement, featureGroup} + finalizedLicenseModelList, + archivedLicenseModelList, + softwareProduct, + licenseModel: { licenseAgreement, featureGroup } }) => { + let { + softwareProductEditor: { + data: currentSoftwareProduct, + licensingVersionsList = [], + genericFieldInfo + }, + softwareProductCategories, + softwareProductQuestionnaire + } = softwareProduct; + let { licensingData = {}, licensingVersion } = currentSoftwareProduct; + let licenseAgreementList = [], + filteredFeatureGroupsList = []; + licenseAgreementList = licensingVersion + ? licenseAgreement.licenseAgreementList + : []; + if (licensingVersion && licensingData && licensingData.licenseAgreement) { + let selectedLicenseAgreement = licenseAgreementList.find( + la => la.id === licensingData.licenseAgreement + ); + if (selectedLicenseAgreement) { + let featureGroupsList = featureGroup.featureGroupsList.filter( + ({ referencingLicenseAgreements }) => + referencingLicenseAgreements.includes( + selectedLicenseAgreement.id + ) + ); + if (featureGroupsList.length) { + filteredFeatureGroupsList = featureGroupsList.map( + featureGroup => ({ + enum: featureGroup.id, + title: featureGroup.name + }) + ); + } + } + } + let { + qdata, + qgenericFieldInfo: qGenericFieldInfo, + dataMap + } = softwareProductQuestionnaire; - let {softwareProductEditor: {data: currentSoftwareProduct, licensingVersionsList = [], genericFieldInfo}, softwareProductCategories, softwareProductQuestionnaire} = softwareProduct; - let {licensingData = {}, licensingVersion} = currentSoftwareProduct; - let licenseAgreementList = [], filteredFeatureGroupsList = []; - licenseAgreementList = licensingVersion ? - licenseAgreement.licenseAgreementList : []; - if(licensingVersion && licensingData && licensingData.licenseAgreement) { - let selectedLicenseAgreement = licenseAgreementList.find(la => la.id === licensingData.licenseAgreement); - if (selectedLicenseAgreement) { - let featureGroupsList = featureGroup.featureGroupsList.filter(({referencingLicenseAgreements}) => referencingLicenseAgreements.includes(selectedLicenseAgreement.id)); - if (featureGroupsList.length) { - filteredFeatureGroupsList = featureGroupsList.map(featureGroup => ({enum: featureGroup.id, title: featureGroup.name})); - } - } - } - let {qdata, qgenericFieldInfo : qGenericFieldInfo, dataMap} = softwareProductQuestionnaire; - - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - const isVendorArchived = archivedLicenseModelList.find(item => item.id === currentSoftwareProduct.vendorId); - return { - currentSoftwareProduct, - softwareProductCategories, - licenseAgreementList, - licensingVersionsList, - featureGroupsList: filteredFeatureGroupsList, - finalizedLicenseModelList, - qdata, - isFormValid, - genericFieldInfo, - qGenericFieldInfo, - dataMap, - isVendorArchived: !!isVendorArchived - }; - + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + const isVendorArchived = archivedLicenseModelList.find( + item => item.id === currentSoftwareProduct.vendorId + ); + return { + currentSoftwareProduct, + softwareProductCategories, + licenseAgreementList, + licensingVersionsList, + featureGroupsList: filteredFeatureGroupsList, + finalizedLicenseModelList, + qdata, + isFormValid, + genericFieldInfo, + qGenericFieldInfo, + dataMap, + isVendorArchived: !!isVendorArchived + }; }; -export const mapActionsToProps = (dispatch, {version}) => { - return { - onDataChanged: (deltaData, formName) => ValidationHelper.dataChanged(dispatch, {deltaData, formName}), - onVendorParamChanged: (deltaData, formName) => SoftwareProductActionHelper.softwareProductEditorVendorChanged(dispatch, {deltaData, formName}), - onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, qName: PRODUCT_QUESTIONNAIRE}), - onValidityChanged: isValidityData => SoftwareProductActionHelper.setIsValidityData(dispatch, {isValidityData}), - onSubmit: (softwareProduct, qdata) => SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {softwareProduct, qdata, version}), - onArchivedVendorRemove: ({onVendorParamChanged, finalizedLicenseModelList, vendorName}) => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data:{ - title: i18n('Change Archived VLM'), - modalComponentName: modalContentMapper.VENDOR_SELECTOR, - modalComponentProps: { - size: modalSizes.MEDIUM, - finalizedLicenseModelList, - vendorName, - onClose: () => dispatch({type: modalActionTypes.GLOBAL_MODAL_CLOSE}), - onConfirm: (vendorId) => onVendorParamChanged({vendorId}, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS) - } - } - }) - }; +export const mapActionsToProps = (dispatch, { version }) => { + return { + onDataChanged: (deltaData, formName) => + ValidationHelper.dataChanged(dispatch, { deltaData, formName }), + onVendorParamChanged: (deltaData, formName) => + SoftwareProductActionHelper.softwareProductEditorVendorChanged( + dispatch, + { deltaData, formName } + ), + onQDataChanged: deltaData => + ValidationHelper.qDataChanged(dispatch, { + deltaData, + qName: PRODUCT_QUESTIONNAIRE + }), + onValidityChanged: isValidityData => + SoftwareProductActionHelper.setIsValidityData(dispatch, { + isValidityData + }), + onSubmit: (softwareProduct, qdata) => + SoftwareProductActionHelper.updateSoftwareProduct(dispatch, { + softwareProduct, + qdata, + version + }), + onArchivedVendorRemove: ({ + onVendorParamChanged, + finalizedLicenseModelList, + vendorName + }) => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + title: i18n('Change Archived VLM'), + modalComponentName: modalContentMapper.VENDOR_SELECTOR, + modalComponentProps: { + size: modalSizes.MEDIUM, + finalizedLicenseModelList, + vendorName, + onClose: () => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }), + onConfirm: vendorId => + onVendorParamChanged( + { vendorId }, + forms.VENDOR_SOFTWARE_PRODUCT_DETAILS + ) + } + } + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductDetailsView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductDetailsView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsReducer.js index 1a293264c3..1e4a0df787 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsReducer.js @@ -13,49 +13,56 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { + actionTypes, + forms +} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.softwareProductEditor.IS_VALIDITY_DATA_CHANGED: - return { - ...state, - isValidityData: action.isValidityData - }; - case actionTypes.SOFTWARE_PRODUCT_LOADED: - return { - ...state, - formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS, - genericFieldInfo: { - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'validateName', data: true}, {type: 'maxLength', data: 25}, {type: 'required', data: true}] - }, - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - } - }, - data: action.response - }; - case actionTypes.TOGGLE_NAVIGATION_ITEM: - return { - ...state, - mapOfExpandedIds: action.mapOfExpandedIds - }; - case actionTypes.LOAD_LICENSING_VERSIONS_LIST: - return { - ...state, - licensingVersionsList: action.licensingVersionsList - }; - case actionTypes.CANDIDATE_IN_PROCESS: - return { - ...state, - data: {...state.data, candidateOnboardingOrigin: true} - }; - default: - return state; - } + switch (action.type) { + case actionTypes.softwareProductEditor.IS_VALIDITY_DATA_CHANGED: + return { + ...state, + isValidityData: action.isValidityData + }; + case actionTypes.SOFTWARE_PRODUCT_LOADED: + return { + ...state, + formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS, + genericFieldInfo: { + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'validateName', data: true }, + { type: 'maxLength', data: 25 }, + { type: 'required', data: true } + ] + }, + description: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + } + }, + data: action.response + }; + case actionTypes.TOGGLE_NAVIGATION_ITEM: + return { + ...state, + mapOfExpandedIds: action.mapOfExpandedIds + }; + case actionTypes.LOAD_LICENSING_VERSIONS_LIST: + return { + ...state, + licensingVersionsList: action.licensingVersionsList + }; + case actionTypes.CANDIDATE_IN_PROCESS: + return { + ...state, + data: { ...state.data, candidateOnboardingOrigin: true } + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsVendorSelector.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsVendorSelector.jsx index c2a3e0bd02..9c20723689 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsVendorSelector.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsVendorSelector.jsx @@ -22,57 +22,77 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js'; class VendorSelector extends React.Component { - static propTypes = { - finalizedLicenseModelList: PropTypes.array, - vendorName: PropTypes.string, - onClose: PropTypes.func.isRequired, - onConfirm: PropTypes.func.isRequired - } - constructor(props){ - super(props); - const selectedValue = props.finalizedLicenseModelList.length ? props.finalizedLicenseModelList[0].id : ''; - this.state = { - selectedValue - }; - } - submit() { - const vendor = this.props.finalizedLicenseModelList.find(item => item.id === this.state.selectedValue); - this.props.onConfirm(vendor.id); - this.props.onClose(); - } - render() { - const {finalizedLicenseModelList, vendorName, onClose} = this.props; - const {selectedValue} = this.state; - return ( -
    -
    this.submit()} - onReset={() => onClose()} - isValid = {!!selectedValue} - submitButtonText={i18n('Save')} - hasButtons={true}> -
    {`${i18n('The VLM')} '${vendorName}' ${i18n('assigned to this VSP is archived')}.`}
    -
    {i18n('If you select a different VLM you will not be able to reselect the archived VLM.')}
    - {this.setState({ - selectedValue: e.target.options[e.target.selectedIndex].value - });}} - value={selectedValue}> - - {sortByStringProperty( - finalizedLicenseModelList, - 'name' - ).map(lm => ) - } - -
    -
    - ); - } + static propTypes = { + finalizedLicenseModelList: PropTypes.array, + vendorName: PropTypes.string, + onClose: PropTypes.func.isRequired, + onConfirm: PropTypes.func.isRequired + }; + constructor(props) { + super(props); + const selectedValue = props.finalizedLicenseModelList.length + ? props.finalizedLicenseModelList[0].id + : ''; + this.state = { + selectedValue + }; + } + submit() { + const vendor = this.props.finalizedLicenseModelList.find( + item => item.id === this.state.selectedValue + ); + this.props.onConfirm(vendor.id); + this.props.onClose(); + } + render() { + const { finalizedLicenseModelList, vendorName, onClose } = this.props; + const { selectedValue } = this.state; + return ( +
    +
    this.submit()} + onReset={() => onClose()} + isValid={!!selectedValue} + submitButtonText={i18n('Save')} + hasButtons={true}> +
    {`${i18n( + 'The VLM' + )} '${vendorName}' ${i18n( + 'assigned to this VSP is archived' + )}.`}
    +
    + {i18n( + 'If you select a different VLM you will not be able to reselect the archived VLM.' + )} +
    + { + this.setState({ + selectedValue: + e.target.options[e.target.selectedIndex] + .value + }); + }} + value={selectedValue}> + + {sortByStringProperty( + finalizedLicenseModelList, + 'name' + ).map(lm => ( + + ))} + +
    +
    + ); + } } export default VendorSelector; - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx index 24aa319c24..12b1eadc86 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx @@ -13,7 +13,7 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; import i18n from 'nfvo-utils/i18n/i18n.js'; @@ -24,427 +24,642 @@ import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js'; -import {forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { forms } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; -const DeprecatedVlmInfo = ({vendorName, onVendorRemove}) => { - return ( -
    - onVendorRemove()} - label={i18n('Vendor')} - type='select' - value={`${vendorName} (Archived)`}> - - -
    - ); +const DeprecatedVlmInfo = ({ vendorName, onVendorRemove }) => { + return ( +
    + onVendorRemove()} + label={i18n('Vendor')} + type="select" + value={`${vendorName} (Archived)`}> + + +
    + ); }; class GeneralSection extends React.Component { - static propTypes = { - vendorId: PropTypes.string, - name: PropTypes.string, - description: PropTypes.string, - subCategory: PropTypes.string, - softwareProductCategories: PropTypes.array, - finalizedLicenseModelList: PropTypes.array, - onDataChanged: PropTypes.func.isRequired, - onVendorParamChanged: PropTypes.func.isRequired, - onSelectSubCategory: PropTypes.func.isRequired, - isVendorArchived: PropTypes.bool, - onArchivedVendorRemove: PropTypes.func - }; + static propTypes = { + vendorId: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + subCategory: PropTypes.string, + softwareProductCategories: PropTypes.array, + finalizedLicenseModelList: PropTypes.array, + onDataChanged: PropTypes.func.isRequired, + onVendorParamChanged: PropTypes.func.isRequired, + onSelectSubCategory: PropTypes.func.isRequired, + isVendorArchived: PropTypes.bool, + onArchivedVendorRemove: PropTypes.func + }; - onVendorParamChanged(e) { - const selectedIndex = e.target.selectedIndex; - const vendorId = e.target.options[selectedIndex].value; - this.props.onVendorParamChanged({vendorId}, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS); + onVendorParamChanged(e) { + const selectedIndex = e.target.selectedIndex; + const vendorId = e.target.options[selectedIndex].value; + this.props.onVendorParamChanged( + { vendorId }, + forms.VENDOR_SOFTWARE_PRODUCT_DETAILS + ); + } - } + onSelectSubCategory(e) { + const selectedIndex = e.target.selectedIndex; + const subCategory = e.target.options[selectedIndex].value; + this.props.onSelectSubCategory(subCategory); + } + onVendorRemove() { + const { + finalizedLicenseModelList, + vendorName, + onVendorParamChanged + } = this.props; + this.props.onArchivedVendorRemove({ + finalizedLicenseModelList, + onVendorParamChanged, + vendorName + }); + } - onSelectSubCategory(e) { - const selectedIndex = e.target.selectedIndex; - const subCategory = e.target.options[selectedIndex].value; - this.props.onSelectSubCategory(subCategory); - } - onVendorRemove() { - const {finalizedLicenseModelList, vendorName, onVendorParamChanged} = this.props; - this.props.onArchivedVendorRemove({finalizedLicenseModelList, onVendorParamChanged, vendorName}); - } - - render (){ - let {genericFieldInfo} = this.props; - return ( -
    - {genericFieldInfo && - - name.length <= 25 && this.props.onDataChanged({name}, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS)}/> - {this.props.isVendorArchived ? - this.onVendorRemove()} vendorName={this.props.vendorName} /> : - this.onVendorParamChanged(e)}> - {sortByStringProperty( - this.props.finalizedLicenseModelList, - 'name' - ).map(lm => ) - } - - } - this.onSelectSubCategory(e)}> - { - this.props.softwareProductCategories.map(category => - category.subcategories && - {category.subcategories.map(sub => - )} - - ) - } - - - - this.props.onDataChanged({description}, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS)}/> - - } -
    ); - } + render() { + let { genericFieldInfo } = this.props; + return ( +
    + {genericFieldInfo && ( + + + + name.length <= 25 && + this.props.onDataChanged( + { name }, + forms.VENDOR_SOFTWARE_PRODUCT_DETAILS + ) + } + /> + {this.props.isVendorArchived ? ( + this.onVendorRemove()} + vendorName={this.props.vendorName} + /> + ) : ( + + this.onVendorParamChanged(e) + }> + {sortByStringProperty( + this.props.finalizedLicenseModelList, + 'name' + ).map(lm => ( + + ))} + + )} + this.onSelectSubCategory(e)}> + {this.props.softwareProductCategories.map( + category => + category.subcategories && ( + + {category.subcategories.map( + sub => ( + + ) + )} + + ) + )} + + + + + this.props.onDataChanged( + { description }, + forms.VENDOR_SOFTWARE_PRODUCT_DETAILS + ) + } + /> + + + )} +
    + ); + } } class LicensesSection extends React.Component { - static propTypes = { - onVendorParamChanged: PropTypes.func.isRequired, - vendorId: PropTypes.string, - licensingVersion: PropTypes.string, - licensingVersionsList: PropTypes.array, - licensingData: PropTypes.shape({ - licenceAgreement: PropTypes.string, - featureGroups: PropTypes.array - }), - onFeatureGroupsChanged: PropTypes.func.isRequired, - onLicensingDataChanged: PropTypes.func.isRequired, - featureGroupsList: PropTypes.array, - licenseAgreementList: PropTypes.array, - isVendorArchived: PropTypes.bool - }; + static propTypes = { + onVendorParamChanged: PropTypes.func.isRequired, + vendorId: PropTypes.string, + licensingVersion: PropTypes.string, + licensingVersionsList: PropTypes.array, + licensingData: PropTypes.shape({ + licenceAgreement: PropTypes.string, + featureGroups: PropTypes.array + }), + onFeatureGroupsChanged: PropTypes.func.isRequired, + onLicensingDataChanged: PropTypes.func.isRequired, + featureGroupsList: PropTypes.array, + licenseAgreementList: PropTypes.array, + isVendorArchived: PropTypes.bool + }; - onVendorParamChanged(e) { - const selectedIndex = e.target.selectedIndex; - const licensingVersion = e.target.options[selectedIndex].value; - this.props.onVendorParamChanged({vendorId: this.props.vendorId, licensingVersion}, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS); - } + onVendorParamChanged(e) { + const selectedIndex = e.target.selectedIndex; + const licensingVersion = e.target.options[selectedIndex].value; + this.props.onVendorParamChanged( + { vendorId: this.props.vendorId, licensingVersion }, + forms.VENDOR_SOFTWARE_PRODUCT_DETAILS + ); + } - onLicensingDataChanged(e) { - const selectedIndex = e.target.selectedIndex; - const licenseAgreement = e.target.options[selectedIndex].value; - this.props.onLicensingDataChanged({licenseAgreement, featureGroups: []}); - } + onLicensingDataChanged(e) { + const selectedIndex = e.target.selectedIndex; + const licenseAgreement = e.target.options[selectedIndex].value; + this.props.onLicensingDataChanged({ + licenseAgreement, + featureGroups: [] + }); + } - render(){ - return ( - - - this.onVendorParamChanged(e)} - value={this.props.licensingVersion || ''} - label={i18n('Licensing Version')} - disabled={this.props.isVendorArchived} - type='select'> - {this.props.licensingVersionsList.map(version => - - )} - - - - this.onLicensingDataChanged(e)}> - - {this.props.licenseAgreementList.map(la => )} - - - - {this.props.licensingData.licenseAgreement && ( - {}} - disabled={this.props.isVendorArchived} - onEnumChange={featureGroups => this.props.onFeatureGroupsChanged({featureGroups})} - multiSelectedEnum={this.props.licensingData.featureGroups} - name='feature-groups' - label={i18n('Feature Groups')} - clearable={false} - values={this.props.featureGroupsList}/>) - } - - - ); - } + render() { + return ( + + + this.onVendorParamChanged(e)} + value={this.props.licensingVersion || ''} + label={i18n('Licensing Version')} + disabled={this.props.isVendorArchived} + type="select"> + {this.props.licensingVersionsList.map(version => ( + + ))} + + + + this.onLicensingDataChanged(e)}> + + {this.props.licenseAgreementList.map(la => ( + + ))} + + + + {this.props.licensingData.licenseAgreement && ( + {}} + disabled={this.props.isVendorArchived} + onEnumChange={featureGroups => + this.props.onFeatureGroupsChanged({ + featureGroups + }) + } + multiSelectedEnum={ + this.props.licensingData.featureGroups + } + name="feature-groups" + label={i18n('Feature Groups')} + clearable={false} + values={this.props.featureGroupsList} + /> + )} + + + ); + } } -const AvailabilitySection = (props) => ( - - - props.onQDataChanged({'general/availability/useAvailabilityZonesForHighAvailability' : aZone})} /> - - +const AvailabilitySection = props => ( + + + + props.onQDataChanged({ + 'general/availability/useAvailabilityZonesForHighAvailability': aZone + }) + } + /> + + ); -const RegionsSection = (props) => ( - - - {}} - onEnumChange={(regions) => props.onQDataChanged({'general/regionsData/regions' : regions})} - multiSelectedEnum={props.dataMap['general/regionsData/regions']} - name='vsp-regions' - clearable={false} - values={props.genericFieldInfo['general/regionsData/regions'].enum} /> - - +const RegionsSection = props => ( + + + {}} + onEnumChange={regions => + props.onQDataChanged({ + 'general/regionsData/regions': regions + }) + } + multiSelectedEnum={props.dataMap['general/regionsData/regions']} + name="vsp-regions" + clearable={false} + values={ + props.genericFieldInfo['general/regionsData/regions'].enum + } + /> + + ); -const StorageDataReplicationSection = (props) => ( - - - props.onQDataChanged({'general/storageDataReplication/storageReplicationSize' : sRep})} /> - - - props.onQDataChanged({'general/storageDataReplication/storageReplicationSource' : sRepSource})} /> - - - props.onQDataChanged({'general/storageDataReplication/storageReplicationFrequency' : sRepFreq})} /> - - - props.onQDataChanged({'general/storageDataReplication/storageReplicationDestination' : sRepDest})} /> - - +const StorageDataReplicationSection = props => ( + + + + props.onQDataChanged({ + 'general/storageDataReplication/storageReplicationSize': sRep + }) + } + /> + + + + props.onQDataChanged({ + 'general/storageDataReplication/storageReplicationSource': sRepSource + }) + } + /> + + + + props.onQDataChanged({ + 'general/storageDataReplication/storageReplicationFrequency': sRepFreq + }) + } + /> + + + + props.onQDataChanged({ + 'general/storageDataReplication/storageReplicationDestination': sRepDest + }) + } + /> + + ); class SoftwareProductDetails extends Component { + static propTypes = { + vendorName: PropTypes.string, + currentSoftwareProduct: PropTypes.shape({ + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + category: PropTypes.string, + subCategory: PropTypes.string, + vendorId: PropTypes.string, + vendorName: PropTypes.string, + licensingVersion: PropTypes.string, + licensingData: PropTypes.shape({ + licenceAgreement: PropTypes.string, + featureGroups: PropTypes.array + }) + }), + softwareProductCategories: PropTypes.array, + finalizedLicenseModelList: PropTypes.array, + licenseAgreementList: PropTypes.array, + featureGroupsList: PropTypes.array, + onSubmit: PropTypes.func.isRequired, + onDataChanged: PropTypes.func.isRequired, + onValidityChanged: PropTypes.func.isRequired, + qdata: PropTypes.object.isRequired, + onQDataChanged: PropTypes.func.isRequired, + onVendorParamChanged: PropTypes.func.isRequired + }; - static propTypes = { - vendorName: PropTypes.string, - currentSoftwareProduct: PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - description: PropTypes.string, - category: PropTypes.string, - subCategory: PropTypes.string, - vendorId: PropTypes.string, - vendorName: PropTypes.string, - licensingVersion: PropTypes.string, - licensingData: PropTypes.shape({ - licenceAgreement: PropTypes.string, - featureGroups: PropTypes.array - }) - }), - softwareProductCategories: PropTypes.array, - finalizedLicenseModelList: PropTypes.array, - licenseAgreementList: PropTypes.array, - featureGroupsList: PropTypes.array, - onSubmit: PropTypes.func.isRequired, - onDataChanged: PropTypes.func.isRequired, - onValidityChanged: PropTypes.func.isRequired, - qdata: PropTypes.object.isRequired, - onQDataChanged: PropTypes.func.isRequired, - onVendorParamChanged: PropTypes.func.isRequired - }; - - prepareDataForGeneralSection(){ - let {softwareProductCategories, finalizedLicenseModelList, onDataChanged, currentSoftwareProduct, genericFieldInfo, isVendorArchived, onArchivedVendorRemove} = this.props; - let {name, description, vendorId, subCategory, vendorName} = currentSoftwareProduct; - return { - name, - description, - vendorId, - subCategory, - softwareProductCategories, - finalizedLicenseModelList, - onDataChanged, - onVendorParamChanged: args => this.onVendorParamChanged(args), - onSelectSubCategory: args => this.onSelectSubCategory(args), - genericFieldInfo, - vendorName, - isVendorArchived, - onArchivedVendorRemove - }; - - } + prepareDataForGeneralSection() { + let { + softwareProductCategories, + finalizedLicenseModelList, + onDataChanged, + currentSoftwareProduct, + genericFieldInfo, + isVendorArchived, + onArchivedVendorRemove + } = this.props; + let { + name, + description, + vendorId, + subCategory, + vendorName + } = currentSoftwareProduct; + return { + name, + description, + vendorId, + subCategory, + softwareProductCategories, + finalizedLicenseModelList, + onDataChanged, + onVendorParamChanged: args => this.onVendorParamChanged(args), + onSelectSubCategory: args => this.onSelectSubCategory(args), + genericFieldInfo, + vendorName, + isVendorArchived, + onArchivedVendorRemove + }; + } - prepareDataForLicensesSection(){ - let { featureGroupsList, licenseAgreementList, currentSoftwareProduct, isVendorArchived} = this.props; - let {vendorId, licensingVersion, licensingData = {}} = currentSoftwareProduct; - return { - onVendorParamChanged: args => this.onVendorParamChanged(args), - vendorId, - licensingVersion, - licensingVersionsList: this.buildLicensingVersionsListItems(), - licensingData, - onFeatureGroupsChanged: args => this.onFeatureGroupsChanged(args), - onLicensingDataChanged: args => this.onLicensingDataChanged(args), - featureGroupsList, - licenseAgreementList, - isVendorArchived - }; + prepareDataForLicensesSection() { + let { + featureGroupsList, + licenseAgreementList, + currentSoftwareProduct, + isVendorArchived + } = this.props; + let { + vendorId, + licensingVersion, + licensingData = {} + } = currentSoftwareProduct; + return { + onVendorParamChanged: args => this.onVendorParamChanged(args), + vendorId, + licensingVersion, + licensingVersionsList: this.buildLicensingVersionsListItems(), + licensingData, + onFeatureGroupsChanged: args => this.onFeatureGroupsChanged(args), + onLicensingDataChanged: args => this.onLicensingDataChanged(args), + featureGroupsList, + licenseAgreementList, + isVendorArchived + }; + } - } + render() { + let { currentSoftwareProduct } = this.props; + let { qdata, onQDataChanged, dataMap, qGenericFieldInfo } = this.props; + let { isReadOnlyMode } = this.props; - render() { - let {currentSoftwareProduct} = this.props; - let {qdata, onQDataChanged, dataMap, qGenericFieldInfo} = this.props; - let {isReadOnlyMode} = this.props; + return ( +
    +
    + (this.validationForm = validationForm) + } + className="vsp-general-tab" + hasButtons={false} + formReady={null} + isValid={this.props.isFormValid} + onSubmit={() => + this.props.onSubmit(currentSoftwareProduct, qdata) + } + onValidityChanged={isValidityData => + this.props.onValidityChanged(isValidityData) + } + isReadOnlyMode={isReadOnlyMode}> + + + + + + +
    + ); + } - return ( -
    -
    this.validationForm = validationForm} - className='vsp-general-tab' - hasButtons={false} - formReady={null} - isValid={this.props.isFormValid} - onSubmit={() => this.props.onSubmit(currentSoftwareProduct, qdata)} - onValidityChanged={(isValidityData) => this.props.onValidityChanged(isValidityData)} - isReadOnlyMode={isReadOnlyMode}> - - - - - - -
    - ); - } + onVendorParamChanged({ vendorId, licensingVersion }) { + let { finalizedLicenseModelList, onVendorParamChanged } = this.props; + if (!licensingVersion) { + const licensingVersionsList = this.buildLicensingVersionsListItems(); + licensingVersion = licensingVersionsList[0].enum; + } - onVendorParamChanged({vendorId, licensingVersion}) { - - let {finalizedLicenseModelList, onVendorParamChanged} = this.props; - if(!licensingVersion) { - const licensingVersionsList = this.buildLicensingVersionsListItems(); - licensingVersion = licensingVersionsList[0].enum; - } - - if (!vendorId) { - vendorId = finalizedLicenseModelList[0].id; - } - - let vendorName = finalizedLicenseModelList.find(licenseModelItem => licenseModelItem.id === vendorId).name || ''; - let deltaData = { - vendorId, - vendorName, - licensingVersion, - licensingData: {} - }; + if (!vendorId) { + vendorId = finalizedLicenseModelList[0].id; + } - onVendorParamChanged(deltaData, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS); + let vendorName = + finalizedLicenseModelList.find( + licenseModelItem => licenseModelItem.id === vendorId + ).name || ''; + let deltaData = { + vendorId, + vendorName, + licensingVersion, + licensingData: {} + }; - } + onVendorParamChanged(deltaData, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS); + } - buildLicensingVersionsListItems() { - let {licensingVersionsList} = this.props; + buildLicensingVersionsListItems() { + let { licensingVersionsList } = this.props; - let licensingVersionsListItems = [{ - enum: '', - title: i18n('Select...') - }]; + let licensingVersionsListItems = [ + { + enum: '', + title: i18n('Select...') + } + ]; - return licensingVersionsListItems.concat(licensingVersionsList.map(version => ({enum: version.id, title: version.name}))); - } + return licensingVersionsListItems.concat( + licensingVersionsList.map(version => ({ + enum: version.id, + title: version.name + })) + ); + } - onFeatureGroupsChanged({featureGroups}) { - this.onLicensingDataChanged({featureGroups}); - } + onFeatureGroupsChanged({ featureGroups }) { + this.onLicensingDataChanged({ featureGroups }); + } - onLicensingDataChanged(deltaData) { - this.props.onDataChanged({ - licensingData: { - ...this.props.currentSoftwareProduct.licensingData, - ...deltaData - } - }, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS); - } + onLicensingDataChanged(deltaData) { + this.props.onDataChanged( + { + licensingData: { + ...this.props.currentSoftwareProduct.licensingData, + ...deltaData + } + }, + forms.VENDOR_SOFTWARE_PRODUCT_DETAILS + ); + } - onSelectSubCategory(subCategory) { - let {softwareProductCategories, onDataChanged} = this.props; - let category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory(subCategory, softwareProductCategories); - onDataChanged({category, subCategory}, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS); - } + onSelectSubCategory(subCategory) { + let { softwareProductCategories, onDataChanged } = this.props; + let category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory( + subCategory, + softwareProductCategories + ); + onDataChanged( + { category, subCategory }, + forms.VENDOR_SOFTWARE_PRODUCT_DETAILS + ); + } - save(){ - return this.validationForm.handleFormSubmit(new Event('dummy')); - } + save() { + return this.validationForm.handleFormSubmit(new Event('dummy')); + } } export default SoftwareProductDetails; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js index 64e0d562ce..34bfceec24 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js @@ -13,106 +13,134 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; import LandingPageView from './SoftwareProductLandingPageView.jsx'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {onboardingMethod} from '../SoftwareProductConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { onboardingMethod } from '../SoftwareProductConstants.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; - +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; export const mapStateToProps = ({ - softwareProduct, - licenseModel: {licenseAgreement}, + softwareProduct, + licenseModel: { licenseAgreement } }) => { - let {softwareProductEditor: {data:currentSoftwareProduct = {}}, softwareProductComponents, softwareProductCategories = [], } = softwareProduct; - let {licensingData = {}} = currentSoftwareProduct; - let {licenseAgreementList} = licenseAgreement; - let {componentsList} = softwareProductComponents; - let licenseAgreementName = licenseAgreementList.find(la => la.id === licensingData.licenseAgreement); - if (licenseAgreementName) { - licenseAgreementName = licenseAgreementName.name; - } else if (licenseAgreementList.length === 0) { // otherwise the state of traingle svgicon will be updated post unmounting - licenseAgreementName = null; - } - - let categoryName = '', subCategoryName = '', fullCategoryDisplayName = ''; - const category = softwareProductCategories.find(ca => ca.uniqueId === currentSoftwareProduct.category); - if (category) { - categoryName = category.name; - const subcategories = category.subcategories || []; - const subcat = subcategories.find(sc => sc.uniqueId === currentSoftwareProduct.subCategory); - subCategoryName = subcat && subcat.name ? subcat.name : ''; - } - fullCategoryDisplayName = `${subCategoryName} (${categoryName})`; + let { + softwareProductEditor: { data: currentSoftwareProduct = {} }, + softwareProductComponents, + softwareProductCategories = [] + } = softwareProduct; + let { licensingData = {} } = currentSoftwareProduct; + let { licenseAgreementList } = licenseAgreement; + let { componentsList } = softwareProductComponents; + let licenseAgreementName = licenseAgreementList.find( + la => la.id === licensingData.licenseAgreement + ); + if (licenseAgreementName) { + licenseAgreementName = licenseAgreementName.name; + } else if (licenseAgreementList.length === 0) { + // otherwise the state of traingle svgicon will be updated post unmounting + licenseAgreementName = null; + } + let categoryName = '', + subCategoryName = '', + fullCategoryDisplayName = ''; + const category = softwareProductCategories.find( + ca => ca.uniqueId === currentSoftwareProduct.category + ); + if (category) { + categoryName = category.name; + const subcategories = category.subcategories || []; + const subcat = subcategories.find( + sc => sc.uniqueId === currentSoftwareProduct.subCategory + ); + subCategoryName = subcat && subcat.name ? subcat.name : ''; + } + fullCategoryDisplayName = `${subCategoryName} (${categoryName})`; - return { - currentSoftwareProduct: { - ...currentSoftwareProduct, - licenseAgreementName, - fullCategoryDisplayName - }, - componentsList, - isManual: currentSoftwareProduct.onboardingMethod === onboardingMethod.MANUAL - }; + return { + currentSoftwareProduct: { + ...currentSoftwareProduct, + licenseAgreementName, + fullCategoryDisplayName + }, + componentsList, + isManual: + currentSoftwareProduct.onboardingMethod === onboardingMethod.MANUAL + }; }; -const mapActionsToProps = (dispatch, {version}) => { - return { - onDetailsSelect: ({id: softwareProductId}) => - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version} - }), - onCandidateInProcess: (softwareProductId) => ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version} - }), - onUpload: (softwareProductId, formData) => - SoftwareProductActionHelper.uploadFile(dispatch, { - softwareProductId, - formData, - failedNotificationTitle: i18n('Upload validation failed'), - version - }), +const mapActionsToProps = (dispatch, { version }) => { + return { + onDetailsSelect: ({ id: softwareProductId }) => + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId, version } + }), + onCandidateInProcess: softwareProductId => + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS_SETUP, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId, version } + }), + onUpload: (softwareProductId, formData) => + SoftwareProductActionHelper.uploadFile(dispatch, { + softwareProductId, + formData, + failedNotificationTitle: i18n('Upload validation failed'), + version + }), - onUploadConfirmation: (softwareProductId, formData) => - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data:{ - msg: i18n('Upload will erase existing data. Do you want to continue?'), - confirmationButtonText: i18n('Continue'), - title: i18n('Warning'), - onConfirmed: ()=>SoftwareProductActionHelper.uploadFile(dispatch, { - softwareProductId, - formData, - failedNotificationTitle: i18n('Upload validation failed'), - version - }), - onDeclined: () => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }) - } - }), + onUploadConfirmation: (softwareProductId, formData) => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + msg: i18n( + 'Upload will erase existing data. Do you want to continue?' + ), + confirmationButtonText: i18n('Continue'), + title: i18n('Warning'), + onConfirmed: () => + SoftwareProductActionHelper.uploadFile(dispatch, { + softwareProductId, + formData, + failedNotificationTitle: i18n( + 'Upload validation failed' + ), + version + }), + onDeclined: () => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }) + } + }), - onInvalidFileSizeUpload: () => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_ERROR, - data: { - title: i18n('Upload Failed'), - confirmationButtonText: i18n('Continue'), - msg: i18n('no zip or csar file was uploaded or expected file doesn\'t exist') - } - }), - onComponentSelect: ({id: softwareProductId, componentId}) => ScreensHelper.loadScreen(dispatch, { - screen: screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, version, componentId} - }), - /** for the next version */ - onAddComponent: () => SoftwareProductActionHelper.addComponent(dispatch) - }; + onInvalidFileSizeUpload: () => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('Upload Failed'), + confirmationButtonText: i18n('Continue'), + msg: i18n( + "no zip or csar file was uploaded or expected file doesn't exist" + ) + } + }), + onComponentSelect: ({ id: softwareProductId, componentId }) => + ScreensHelper.loadScreen(dispatch, { + screen: screenTypes.SOFTWARE_PRODUCT_COMPONENT_DEFAULT_GENERAL, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId, version, componentId } + }), + /** for the next version */ + onAddComponent: () => SoftwareProductActionHelper.addComponent(dispatch) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(LandingPageView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(LandingPageView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx index a73a849a08..bc8a2be646 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx @@ -18,7 +18,6 @@ import PropTypes from 'prop-types'; import classnames from 'classnames'; import Dropzone from 'react-dropzone'; - import i18n from 'nfvo-utils/i18n/i18n.js'; import DraggableUploadFileBox from 'nfvo-components/fileupload/DraggableUploadFileBox.jsx'; @@ -26,192 +25,237 @@ import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import SoftwareProductComponentsList from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponents.js'; const SoftwareProductPropType = PropTypes.shape({ - name: PropTypes.string, - description: PropTypes.string, - version: PropTypes.string, - id: PropTypes.string, - categoryId: PropTypes.string, - vendorId: PropTypes.string, - status: PropTypes.string, - licensingData: PropTypes.object, - validationData: PropTypes.object + name: PropTypes.string, + description: PropTypes.string, + version: PropTypes.string, + id: PropTypes.string, + categoryId: PropTypes.string, + vendorId: PropTypes.string, + status: PropTypes.string, + licensingData: PropTypes.object, + validationData: PropTypes.object }); const ComponentPropType = PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - displayName: PropTypes.string, - description: PropTypes.string + id: PropTypes.string, + name: PropTypes.string, + displayName: PropTypes.string, + description: PropTypes.string }); class SoftwareProductLandingPageView extends React.Component { + state = { + fileName: '', + dragging: false, + files: [] + }; + + static propTypes = { + currentSoftwareProduct: SoftwareProductPropType, + isReadOnlyMode: PropTypes.bool, + componentsList: PropTypes.arrayOf(ComponentPropType), + version: PropTypes.object, + onDetailsSelect: PropTypes.func, + onUpload: PropTypes.func, + onUploadConfirmation: PropTypes.func, + onInvalidFileSizeUpload: PropTypes.func, + onComponentSelect: PropTypes.func, + onAddComponent: PropTypes.func + }; + componentDidMount() { + const { onCandidateInProcess, currentSoftwareProduct } = this.props; + if (currentSoftwareProduct.candidateOnboardingOrigin) { + onCandidateInProcess(currentSoftwareProduct.id); + } + } + render() { + let { + currentSoftwareProduct, + isReadOnlyMode, + isManual, + onDetailsSelect + } = this.props; + return ( +
    + + this.handleImportSubmit(files, isReadOnlyMode, isManual) + } + onDragEnter={() => + this.handleOnDragEnter(isReadOnlyMode, isManual) + } + onDragLeave={() => this.setState({ dragging: false })} + multiple={false} + disableClick={true} + ref="fileInput" + name="fileInput" + accept=".zip, .csar"> +
    +
    +
    + + {this.renderProductDetails( + isManual, + isReadOnlyMode + )} +
    +
    +
    +
    + +
    + ); + } + + handleOnDragEnter(isReadOnlyMode, isManual) { + if (!isReadOnlyMode && !isManual) { + this.setState({ dragging: true }); + } + } + + renderProductDetails(isManual, isReadOnlyMode) { + return ( +
    + {!isManual && ( +
    +
    + {i18n('Software Product Attachments')} +
    + this.refs.fileInput.open()} + /> +
    + )} +
    + ); + } + + handleImportSubmit(files, isReadOnlyMode, isManual) { + if (isReadOnlyMode || isManual) { + return; + } + if (files[0] && files[0].size) { + this.setState({ + fileName: files[0].name, + dragging: false, + complete: '0' + }); + this.startUploading(files); + } else { + this.setState({ + dragging: false + }); + this.props.onInvalidFileSizeUpload(); + } + } - state = { - - fileName: '', - dragging: false, - files: [] - }; - - static propTypes = { - currentSoftwareProduct: SoftwareProductPropType, - isReadOnlyMode: PropTypes.bool, - componentsList: PropTypes.arrayOf(ComponentPropType), - version: PropTypes.object, - onDetailsSelect: PropTypes.func, - onUpload: PropTypes.func, - onUploadConfirmation: PropTypes.func, - onInvalidFileSizeUpload: PropTypes.func, - onComponentSelect: PropTypes.func, - onAddComponent: PropTypes.func - }; - componentDidMount() { - const {onCandidateInProcess, currentSoftwareProduct} = this.props; - if (currentSoftwareProduct.candidateOnboardingOrigin) { - onCandidateInProcess(currentSoftwareProduct.id); - } - } - render() { - let {currentSoftwareProduct, isReadOnlyMode, isManual, onDetailsSelect} = this.props; - return ( -
    - this.handleImportSubmit(files, isReadOnlyMode, isManual)} - onDragEnter={() => this.handleOnDragEnter(isReadOnlyMode, isManual)} - onDragLeave={() => this.setState({dragging:false})} - multiple={false} - disableClick={true} - ref='fileInput' - name='fileInput' - accept='.zip, .csar'> -
    -
    -
    - - {this.renderProductDetails(isManual, isReadOnlyMode)} -
    -
    -
    -
    - -
    - ); - } - - handleOnDragEnter(isReadOnlyMode, isManual) { - if (!isReadOnlyMode && !isManual) { - this.setState({dragging: true}); - } - } - - renderProductDetails(isManual, isReadOnlyMode) { - return ( -
    - { !isManual &&
    -
    {i18n('Software Product Attachments')}
    - this.refs.fileInput.open()}/> -
    - } -
    - ); - } - - handleImportSubmit(files, isReadOnlyMode, isManual) { - if (isReadOnlyMode || isManual) { - return; - } - if (files[0] && files[0].size) { - this.setState({ - fileName: files[0].name, - dragging: false, - complete: '0', - }); - this.startUploading(files); - } - else { - this.setState({ - dragging: false - }); - this.props.onInvalidFileSizeUpload(); - } - - } - - startUploading(files) { - let {onUpload, currentSoftwareProduct, onUploadConfirmation} = this.props; - - let {validationData} = currentSoftwareProduct; - - if (!(files && files.length)) { - return; - } - let file = files[0]; - let formData = new FormData(); - formData.append('upload', file); - this.refs.fileInput.value = ''; - - if (validationData) { - onUploadConfirmation(currentSoftwareProduct.id, formData); - }else { - onUpload(currentSoftwareProduct.id, formData); - } - - } + startUploading(files) { + let { + onUpload, + currentSoftwareProduct, + onUploadConfirmation + } = this.props; + + let { validationData } = currentSoftwareProduct; + + if (!(files && files.length)) { + return; + } + let file = files[0]; + let formData = new FormData(); + formData.append('upload', file); + this.refs.fileInput.value = ''; + + if (validationData) { + onUploadConfirmation(currentSoftwareProduct.id, formData); + } else { + onUpload(currentSoftwareProduct.id, formData); + } + } } -const ProductSummary = ({currentSoftwareProduct, onDetailsSelect}) => { - let {name = '', description = '', vendorName = '', fullCategoryDisplayName = '', licenseAgreementName = ''} = currentSoftwareProduct; - return ( -
    -
    {i18n('Software Product Details')}
    -
    onDetailsSelect(currentSoftwareProduct)}> -
    -
    -
    - {name} -
    -
    -
    -
    -
    -
    {i18n('Vendor')}
    -
    {vendorName}
    -
    -
    -
    {i18n('Category')}
    -
    {fullCategoryDisplayName}
    -
    -
    -
    {i18n('License Agreement')}
    -
    - -
    -
    -
    -
    -
    {i18n('Description')}
    -
    {description}
    -
    -
    -
    -
    -
    - ); +const ProductSummary = ({ currentSoftwareProduct, onDetailsSelect }) => { + let { + name = '', + description = '', + vendorName = '', + fullCategoryDisplayName = '', + licenseAgreementName = '' + } = currentSoftwareProduct; + return ( +
    +
    + {i18n('Software Product Details')} +
    +
    onDetailsSelect(currentSoftwareProduct)}> +
    +
    +
    + {name} +
    +
    +
    +
    +
    +
    {i18n('Vendor')}
    +
    {vendorName}
    +
    +
    +
    {i18n('Category')}
    +
    + {fullCategoryDisplayName} +
    +
    +
    +
    + {i18n('License Agreement')} +
    +
    + +
    +
    +
    +
    +
    {i18n('Description')}
    +
    {description}
    +
    +
    +
    +
    +
    + ); }; - -const LicenseAgreement = ({licenseAgreementName}) => { - if (!licenseAgreementName) { - return (
    {i18n('Missing')}
    ); - } - return
    {licenseAgreementName}
    ; +const LicenseAgreement = ({ licenseAgreementName }) => { + if (!licenseAgreementName) { + return ( +
    + +
    {i18n('Missing')}
    +
    + ); + } + return
    {licenseAgreementName}
    ; }; export default SoftwareProductLandingPageView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworks.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworks.js index 6161eadba9..27dd471a00 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworks.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworks.js @@ -13,13 +13,14 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SoftwareProductNetworksView from './SoftwareProductNetworksView.jsx'; -export const mapStateToProps = ({softwareProduct}) => { - let {softwareProductNetworks: {networksList = []}} = softwareProduct; - return {networksList}; +export const mapStateToProps = ({ softwareProduct }) => { + let { softwareProductNetworks: { networksList = [] } } = softwareProduct; + return { networksList }; }; -export default connect(mapStateToProps, null, null, {withRef: true})(SoftwareProductNetworksView); - +export default connect(mapStateToProps, null, null, { withRef: true })( + SoftwareProductNetworksView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js index 4cb460ecc6..388c641b46 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js @@ -13,30 +13,29 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductNetworksConstants.js'; +import { actionTypes } from './SoftwareProductNetworksConstants.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; function baseUrl(vspId, version) { - let {id: versionId} = version; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/networks`; + let { id: versionId } = version; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/networks`; } - function fetchNetworksList(softwareProductId, version) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); } const SoftwareProductNetworksActionHelper = { - fetchNetworksList(dispatch, {softwareProductId, version}) { - return fetchNetworksList(softwareProductId, version).then(response => { - dispatch({ - type: actionTypes.FETCH_SOFTWARE_PRODUCT_NETWORKS, - networksList: response.results - }); - }); - } + fetchNetworksList(dispatch, { softwareProductId, version }) { + return fetchNetworksList(softwareProductId, version).then(response => { + dispatch({ + type: actionTypes.FETCH_SOFTWARE_PRODUCT_NETWORKS, + networksList: response.results + }); + }); + } }; -export default SoftwareProductNetworksActionHelper; +export default SoftwareProductNetworksActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksConstants.js index a3d5578dc4..17e4bdfe8d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksConstants.js @@ -16,5 +16,5 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - FETCH_SOFTWARE_PRODUCT_NETWORKS: null, + FETCH_SOFTWARE_PRODUCT_NETWORKS: null }); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksListReducer.js index e7c2fcb045..796de822df 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksListReducer.js @@ -13,13 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductNetworksConstants.js'; +import { actionTypes } from './SoftwareProductNetworksConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.FETCH_SOFTWARE_PRODUCT_NETWORKS: - return [...action.networksList]; - default: - return state; - } + switch (action.type) { + case actionTypes.FETCH_SOFTWARE_PRODUCT_NETWORKS: + return [...action.networksList]; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx index e8c365f124..458f3192f4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx @@ -22,73 +22,76 @@ import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.js import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; class SoftwareProductNetworksView extends React.Component { + static propTypes = { + networksList: PropTypes.arrayOf( + PropTypes.shape({ + id: PropTypes.string.isRequired, + name: PropTypes.string.isRequired, + dhcp: PropTypes.bool.isRequired + }) + ).isRequired, + isReadOnlyMode: PropTypes.bool.isRequired + }; - static propTypes = { - networksList: PropTypes.arrayOf(PropTypes.shape({ - id: PropTypes.string.isRequired, - name: PropTypes.string.isRequired, - dhcp: PropTypes.bool.isRequired - })).isRequired, - isReadOnlyMode: PropTypes.bool.isRequired - }; + state = { + localFilter: '' + }; - state = { - localFilter: '' - }; + render() { + const { localFilter } = this.state; + const { isReadOnlyMode } = this.props; - render() { - const {localFilter} = this.state; - const {isReadOnlyMode} = this.props; + return ( +
    + this.setState({ localFilter: value })} + twoColumns> + {this.filterList().map(network => + this.renderNetworksListItem({ network, isReadOnlyMode }) + )} + +
    + ); + } - return ( -
    - this.setState({localFilter: value})} - twoColumns> - {this.filterList().map(network => this.renderNetworksListItem({network, isReadOnlyMode}))} - -
    - ); - } + renderNetworksListItem({ network, isReadOnlyMode }) { + let { id, name, dhcp } = network; + return ( + + +
    {name}
    +
    + +
    +
    {i18n('DHCP')}
    +
    + {dhcp ? i18n('YES') : i18n('NO')} +
    +
    +
    +
    + ); + } - renderNetworksListItem({network, isReadOnlyMode}) { - let {id, name, dhcp} = network; - return ( - + filterList() { + let { networksList } = this.props; - -
    {name}
    -
    - -
    -
    {i18n('DHCP')}
    -
    {dhcp ? i18n('YES') : i18n('NO')}
    -
    -
    -
    - ); - } - - filterList() { - let {networksList} = this.props; - - let {localFilter} = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return networksList.filter(({name = ''}) => { - return escape(name).match(filter); - }); - } - else { - return networksList; - } - } + let { localFilter } = this.state; + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return networksList.filter(({ name = '' }) => { + return escape(name).match(filter); + }); + } else { + return networksList; + } + } } export default SoftwareProductNetworksView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessListView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessListView.jsx index aa39c87dd0..cee46abc69 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessListView.jsx @@ -20,80 +20,86 @@ import i18n from 'nfvo-utils/i18n/i18n.js'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; - class SoftwareProductProcessesListView extends React.Component { + state = { + localFilter: '' + }; - state = { - localFilter: '' - }; - - static propTypes = { - onAddProcess: PropTypes.func.isRequired, - onEditProcess: PropTypes.func.isRequired, - onDeleteProcess: PropTypes.func.isRequired, - isReadOnlyMode: PropTypes.bool.isRequired, - currentSoftwareProduct:PropTypes.object, - addButtonTitle: PropTypes.string - }; - - render() { - const {localFilter} = this.state; - let {onAddProcess, isReadOnlyMode, addButtonTitle} = this.props; + static propTypes = { + onAddProcess: PropTypes.func.isRequired, + onEditProcess: PropTypes.func.isRequired, + onDeleteProcess: PropTypes.func.isRequired, + isReadOnlyMode: PropTypes.bool.isRequired, + currentSoftwareProduct: PropTypes.object, + addButtonTitle: PropTypes.string + }; - return ( - this.setState({localFilter: value})}> - {this.filterList().map(processes => this.renderProcessListItem(processes, isReadOnlyMode))} - ); - } + render() { + const { localFilter } = this.state; + let { onAddProcess, isReadOnlyMode, addButtonTitle } = this.props; - renderProcessListItem(process, isReadOnlyMode) { - let {id, name, description, artifactName = ''} = process; - let {currentSoftwareProduct: {version}, onEditProcess, onDeleteProcess} = this.props; - return ( - onEditProcess(process)} - onDelete={() => onDeleteProcess(process, version)}> + return ( + this.setState({ localFilter: value })}> + {this.filterList().map(processes => + this.renderProcessListItem(processes, isReadOnlyMode) + )} + + ); + } -
    -
    {i18n('Name')}
    -
    {name}
    -
    -
    -
    {i18n('Artifact name')}
    -
    {artifactName}
    -
    -
    -
    {i18n('Notes')}
    -
    {description}
    -
    -
    - ); - } + renderProcessListItem(process, isReadOnlyMode) { + let { id, name, description, artifactName = '' } = process; + let { + currentSoftwareProduct: { version }, + onEditProcess, + onDeleteProcess + } = this.props; + return ( + onEditProcess(process)} + onDelete={() => onDeleteProcess(process, version)}> +
    +
    {i18n('Name')}
    +
    {name}
    +
    +
    +
    {i18n('Artifact name')}
    +
    {artifactName}
    +
    +
    +
    {i18n('Notes')}
    +
    {description}
    +
    +
    + ); + } - filterList() { - let {processesList} = this.props; - let {localFilter} = this.state; + filterList() { + let { processesList } = this.props; + let { localFilter } = this.state; - if (localFilter.trim()) { - const filter = new RegExp(escape(localFilter), 'i'); - return processesList.filter(({name = '', description = ''}) => { - return escape(name).match(filter) || escape(description).match(filter); - }); - } - else { - return processesList; - } - } + if (localFilter.trim()) { + const filter = new RegExp(escape(localFilter), 'i'); + return processesList.filter(({ name = '', description = '' }) => { + return ( + escape(name).match(filter) || + escape(description).match(filter) + ); + }); + } else { + return processesList; + } + } } export default SoftwareProductProcessesListView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcesses.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcesses.js index b0403abde5..fb44530dae 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcesses.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcesses.js @@ -13,40 +13,57 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import SoftwareProductProcessesActionHelper from './SoftwareProductProcessesActionHelper.js'; import SoftwareProductProcessesView from './SoftwareProductProcessesView.jsx'; -export const mapStateToProps = ({softwareProduct}) => { - let {softwareProductEditor: {data: currentSoftwareProduct = {}}, softwareProductProcesses: {processesList, processesEditor}} = softwareProduct; - let {data} = processesEditor; +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductEditor: { data: currentSoftwareProduct = {} }, + softwareProductProcesses: { processesList, processesEditor } + } = softwareProduct; + let { data } = processesEditor; - return { - currentSoftwareProduct, - processesList, - isDisplayEditor: Boolean(data), - isModalInEditMode: Boolean(data && data.id) - }; + return { + currentSoftwareProduct, + processesList, + isDisplayEditor: Boolean(data), + isModalInEditMode: Boolean(data && data.id) + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, version}) => { - return { - onAddProcess: () => SoftwareProductProcessesActionHelper.openEditor(dispatch), - onEditProcess: (process) => SoftwareProductProcessesActionHelper.openEditor(dispatch, process), - onDeleteProcess: (process) => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data:{ - msg: i18n('Are you sure you want to delete "{name}"?', {name: process.name}), - confirmationButtonText: i18n('Delete'), - title: i18n('Delete'), - onConfirmed: ()=> SoftwareProductProcessesActionHelper.deleteProcess(dispatch, - {process, softwareProductId, version}) - } - }) - }; +const mapActionsToProps = (dispatch, { softwareProductId, version }) => { + return { + onAddProcess: () => + SoftwareProductProcessesActionHelper.openEditor(dispatch), + onEditProcess: process => + SoftwareProductProcessesActionHelper.openEditor(dispatch, process), + onDeleteProcess: process => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + msg: i18n('Are you sure you want to delete "{name}"?', { + name: process.name + }), + confirmationButtonText: i18n('Delete'), + title: i18n('Delete'), + onConfirmed: () => + SoftwareProductProcessesActionHelper.deleteProcess( + dispatch, + { + process, + softwareProductId, + version + } + ) + } + }) + }; }; -export default connect(mapStateToProps, mapActionsToProps, null, {withRef: true})(SoftwareProductProcessesView); +export default connect(mapStateToProps, mapActionsToProps, null, { + withRef: true +})(SoftwareProductProcessesView); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js index 8fd370b6cc..7c72c5b892 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js @@ -13,127 +13,145 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductProcessesConstants.js'; +import { actionTypes } from './SoftwareProductProcessesConstants.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; function baseUrl(vspId, version) { - let {id: versionId} = version; - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/processes`; + let { id: versionId } = version; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/processes`; } function putProcess(softwareProductId, version, process) { - return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${process.id}`, { - name: process.name, - description: process.description, - type: process.type === '' ? null : process.type - }); + return RestAPIUtil.put( + `${baseUrl(softwareProductId, version)}/${process.id}`, + { + name: process.name, + description: process.description, + type: process.type === '' ? null : process.type + } + ); } function postProcess(softwareProductId, version, process) { - return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, { - name: process.name, - description: process.description, - type: process.type === '' ? null : process.type - }); + return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, { + name: process.name, + description: process.description, + type: process.type === '' ? null : process.type + }); } function deleteProcess(softwareProductId, version, processId) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version)}/${processId}`); + return RestAPIUtil.destroy( + `${baseUrl(softwareProductId, version)}/${processId}` + ); } -function uploadFileToProcess(softwareProductId, version, processId, formData) -{ - return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}/${processId}/upload`, formData); +function uploadFileToProcess(softwareProductId, version, processId, formData) { + return RestAPIUtil.post( + `${baseUrl(softwareProductId, version)}/${processId}/upload`, + formData + ); } function fetchProcesses(softwareProductId, version) { - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); } const SoftwareProductActionHelper = { - - fetchProcessesList(dispatch, {softwareProductId, version}) { - - dispatch({ - type: actionTypes.FETCH_SOFTWARE_PRODUCT_PROCESSES, - processesList: [] - }); - - return fetchProcesses(softwareProductId, version).then(response => { - dispatch({ - type: actionTypes.FETCH_SOFTWARE_PRODUCT_PROCESSES, - processesList: response.results - }); - }); - }, - openEditor(dispatch, process = {}) { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_PROCESS_EDITOR_OPEN, - process - }); - }, - - deleteProcess(dispatch, {process, softwareProductId, version}) { - return deleteProcess(softwareProductId, version, process.id).then(() => { - dispatch({ - type: actionTypes.DELETE_SOFTWARE_PRODUCT_PROCESS, - processId: process.id - }); - }); - - }, - - closeEditor(dispatch) { - dispatch({ - type:actionTypes.SOFTWARE_PRODUCT_PROCESS_EDITOR_CLOSE - }); - }, - - saveProcess(dispatch, {softwareProductId, version, previousProcess, process}) { - if (previousProcess) { - return putProcess(softwareProductId, version, process).then(() => { - if (process.formData){ - uploadFileToProcess(softwareProductId, version, process.id, process.formData); - } - dispatch({ - type: actionTypes.EDIT_SOFTWARE_PRODUCT_PROCESS, - process - }); - }); - } - else { - return postProcess(softwareProductId, version, process).then(response => { - if (process.formData) { - uploadFileToProcess(softwareProductId, version, response.value, process.formData); - } - dispatch({ - type: actionTypes.ADD_SOFTWARE_PRODUCT_PROCESS, - process: { - ...process, - id: response.value - } - }); - }); - } - }, - - hideDeleteConfirm(dispatch) { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM, - processToDelete: false - }); - }, - - openDeleteProcessesConfirm(dispatch, {process} ) { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM, - processToDelete: process - }); - } - + fetchProcessesList(dispatch, { softwareProductId, version }) { + dispatch({ + type: actionTypes.FETCH_SOFTWARE_PRODUCT_PROCESSES, + processesList: [] + }); + + return fetchProcesses(softwareProductId, version).then(response => { + dispatch({ + type: actionTypes.FETCH_SOFTWARE_PRODUCT_PROCESSES, + processesList: response.results + }); + }); + }, + openEditor(dispatch, process = {}) { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_PROCESS_EDITOR_OPEN, + process + }); + }, + + deleteProcess(dispatch, { process, softwareProductId, version }) { + return deleteProcess(softwareProductId, version, process.id).then( + () => { + dispatch({ + type: actionTypes.DELETE_SOFTWARE_PRODUCT_PROCESS, + processId: process.id + }); + } + ); + }, + + closeEditor(dispatch) { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_PROCESS_EDITOR_CLOSE + }); + }, + + saveProcess( + dispatch, + { softwareProductId, version, previousProcess, process } + ) { + if (previousProcess) { + return putProcess(softwareProductId, version, process).then(() => { + if (process.formData) { + uploadFileToProcess( + softwareProductId, + version, + process.id, + process.formData + ); + } + dispatch({ + type: actionTypes.EDIT_SOFTWARE_PRODUCT_PROCESS, + process + }); + }); + } else { + return postProcess(softwareProductId, version, process).then( + response => { + if (process.formData) { + uploadFileToProcess( + softwareProductId, + version, + response.value, + process.formData + ); + } + dispatch({ + type: actionTypes.ADD_SOFTWARE_PRODUCT_PROCESS, + process: { + ...process, + id: response.value + } + }); + } + ); + } + }, + + hideDeleteConfirm(dispatch) { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM, + processToDelete: false + }); + }, + + openDeleteProcessesConfirm(dispatch, { process }) { + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM, + processToDelete: process + }); + } }; export default SoftwareProductActionHelper; - diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConstants.js index 6eee24cdde..7f09ea8e73 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConstants.js @@ -16,20 +16,20 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - ADD_SOFTWARE_PRODUCT_PROCESS: null, - EDIT_SOFTWARE_PRODUCT_PROCESS: null, - DELETE_SOFTWARE_PRODUCT_PROCESS: null, - SOFTWARE_PRODUCT_PROCESS_EDITOR_OPEN: null, - SOFTWARE_PRODUCT_PROCESS_EDITOR_CLOSE: null, - FETCH_SOFTWARE_PRODUCT_PROCESSES: null, - SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM: null + ADD_SOFTWARE_PRODUCT_PROCESS: null, + EDIT_SOFTWARE_PRODUCT_PROCESS: null, + DELETE_SOFTWARE_PRODUCT_PROCESS: null, + SOFTWARE_PRODUCT_PROCESS_EDITOR_OPEN: null, + SOFTWARE_PRODUCT_PROCESS_EDITOR_CLOSE: null, + FETCH_SOFTWARE_PRODUCT_PROCESSES: null, + SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM: null }); export const optionsInputValues = { - PROCESS_TYPE: [ - {title: 'Select...', enum: ''}, - {title: 'Other', enum: 'Other'} - ] + PROCESS_TYPE: [ + { title: 'Select...', enum: '' }, + { title: 'Other', enum: 'Other' } + ] }; export const VSP_PROCESS_FORM = 'VSPPROCESSFORM'; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditor.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditor.js index fc194fac13..58cc894a21 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditor.js @@ -13,41 +13,56 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import SoftwareProductProcessesActionHelper from './SoftwareProductProcessesActionHelper'; import SoftwareProductProcessesEditorView from './SoftwareProductProcessesEditorView.jsx'; -import {VSP_PROCESS_FORM} from './SoftwareProductProcessesConstants.js'; +import { VSP_PROCESS_FORM } from './SoftwareProductProcessesConstants.js'; -export const mapStateToProps = ({softwareProduct}) => { - let {softwareProductProcesses: {processesList, processesEditor}} = softwareProduct; - let {data, genericFieldInfo, formReady} = processesEditor; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - let previousData; - const processId = data ? data.id : null; - if(processId) { - previousData = processesList.find(process => process.id === processId); - } +export const mapStateToProps = ({ softwareProduct }) => { + let { + softwareProductProcesses: { processesList, processesEditor } + } = softwareProduct; + let { data, genericFieldInfo, formReady } = processesEditor; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + let previousData; + const processId = data ? data.id : null; + if (processId) { + previousData = processesList.find(process => process.id === processId); + } - return { - data, - genericFieldInfo, - previousData, - isFormValid, - formReady - }; + return { + data, + genericFieldInfo, + previousData, + isFormValid, + formReady + }; }; -const mapActionsToProps = (dispatch, {softwareProductId, version}) => { - return { - onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: VSP_PROCESS_FORM}), - onSubmit: ({previousProcess, process}) => { - SoftwareProductProcessesActionHelper.closeEditor(dispatch); - SoftwareProductProcessesActionHelper.saveProcess(dispatch, {softwareProductId, version, previousProcess, process}); - }, - onCancel: () => SoftwareProductProcessesActionHelper.closeEditor(dispatch), - onValidateForm: () => ValidationHelper.validateForm(dispatch, VSP_PROCESS_FORM) - }; +const mapActionsToProps = (dispatch, { softwareProductId, version }) => { + return { + onDataChanged: deltaData => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: VSP_PROCESS_FORM + }), + onSubmit: ({ previousProcess, process }) => { + SoftwareProductProcessesActionHelper.closeEditor(dispatch); + SoftwareProductProcessesActionHelper.saveProcess(dispatch, { + softwareProductId, + version, + previousProcess, + process + }); + }, + onCancel: () => + SoftwareProductProcessesActionHelper.closeEditor(dispatch), + onValidateForm: () => + ValidationHelper.validateForm(dispatch, VSP_PROCESS_FORM) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(SoftwareProductProcessesEditorView); +export default connect(mapStateToProps, mapActionsToProps)( + SoftwareProductProcessesEditorView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorForm.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorForm.jsx index d1bd602683..6e8254f65b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorForm.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorForm.jsx @@ -25,157 +25,212 @@ import GridSection from 'nfvo-components/grid/GridSection.jsx'; import GridItem from 'nfvo-components/grid/GridItem.jsx'; const SoftwareProductProcessEditorPropType = PropTypes.shape({ - id: PropTypes.string, - name: PropTypes.string, - description: PropTypes.string, - artifactName: PropTypes.string, - type: PropTypes.string + id: PropTypes.string, + name: PropTypes.string, + description: PropTypes.string, + artifactName: PropTypes.string, + type: PropTypes.string }); - - class SoftwareProductProcessesEditorForm extends React.Component { + static propTypes = { + data: SoftwareProductProcessEditorPropType, + previousData: SoftwareProductProcessEditorPropType, + isReadOnlyMode: PropTypes.bool, + onDataChanged: PropTypes.func, + onSubmit: PropTypes.func, + onCancel: PropTypes.func + }; + state = { + dragging: false, + files: [] + }; + render() { + let { + data = {}, + isReadOnlyMode, + onDataChanged, + onCancel, + genericFieldInfo, + optionsInputValues + } = this.props; + let { name, description, artifactName, type } = data; - static propTypes = { - data: SoftwareProductProcessEditorPropType, - previousData: SoftwareProductProcessEditorPropType, - isReadOnlyMode: PropTypes.bool, - onDataChanged: PropTypes.func, - onSubmit: PropTypes.func, - onCancel: PropTypes.func - }; - state = { - dragging: false, - files: [] - }; - - render() { - let {data = {}, isReadOnlyMode, onDataChanged, onCancel, genericFieldInfo, optionsInputValues} = this.props; - let {name, description, artifactName, type} = data; - - return ( -
    - {genericFieldInfo &&
    this.submit() } - onReset={ () => onCancel() } - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.props.onValidateForm() } - className='vsp-processes-editor'> -
    - this.handleImportSubmit(acceptedFiles, rejectedFiles)} - onDragEnter={() => this.setState({dragging: true})} - onDragLeave={() => this.setState({dragging: false})} - multiple={false} - disableClick={true} - ref='processEditorFileInput' - name='processEditorFileInput'> - - - onDataChanged({name})} - isValid={genericFieldInfo.name.isValid} - isRequired={true} - data-test-id='name' - errorText={genericFieldInfo.name.errorText} - label={i18n('Name')} - value={name} - type='text'/> - - - - this.refs.processEditorFileInput.open()}/> - - - - - onDataChanged({description})} - isValid={genericFieldInfo.description.isValid} - errorText={genericFieldInfo.description.errorText} - label={i18n('Notes')} - value={description} - data-test-id='vsp-process-description' - type='textarea'/> - - - - { - // setting the unit to the correct value - const selectedIndex = e.target.selectedIndex; - const val = e.target.options[selectedIndex].value; - onDataChanged({type: val});} - } - value={type} - label={i18n('Process Type')} - className='process-type' - data-test-id='process-type' - isValid={genericFieldInfo.type.isValid} - errorText={genericFieldInfo.type.errorText} - type='select'> - {optionsInputValues.PROCESS_TYPE.map(mtype => - )} - - - - -
    -
    } -
    - ); - } - - submit() { - const {data: process, previousData: previousProcess} = this.props; - let {files} = this.state; - let formData = false; - if (files.length) { - let file = files[0]; - formData = new FormData(); - formData.append('upload', file); - } + return ( +
    + {genericFieldInfo && ( +
    this.submit()} + onReset={() => onCancel()} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => this.props.onValidateForm()} + className="vsp-processes-editor"> +
    + + this.handleImportSubmit( + acceptedFiles, + rejectedFiles + ) + } + onDragEnter={() => + this.setState({ dragging: true }) + } + onDragLeave={() => + this.setState({ dragging: false }) + } + multiple={false} + disableClick={true} + ref="processEditorFileInput" + name="processEditorFileInput"> + + + + onDataChanged({ name }) + } + isValid={ + genericFieldInfo.name.isValid + } + isRequired={true} + data-test-id="name" + errorText={ + genericFieldInfo.name.errorText + } + label={i18n('Name')} + value={name} + type="text" + /> + + + + + this.refs.processEditorFileInput.open() + } + /> + + + + + + onDataChanged({ description }) + } + isValid={ + genericFieldInfo.description + .isValid + } + errorText={ + genericFieldInfo.description + .errorText + } + label={i18n('Notes')} + value={description} + data-test-id="vsp-process-description" + type="textarea" + /> + + + + { + // setting the unit to the correct value + const selectedIndex = + e.target.selectedIndex; + const val = + e.target.options[ + selectedIndex + ].value; + onDataChanged({ type: val }); + }} + value={type} + label={i18n('Process Type')} + className="process-type" + data-test-id="process-type" + isValid={ + genericFieldInfo.type.isValid + } + errorText={ + genericFieldInfo.type.errorText + } + type="select"> + {optionsInputValues.PROCESS_TYPE.map( + mtype => ( + + ) + )} + + + + +
    +
    + )} +
    + ); + } - let updatedProcess = { - ...process, - formData - }; - this.props.onSubmit({process: updatedProcess, previousProcess}); - } + submit() { + const { data: process, previousData: previousProcess } = this.props; + let { files } = this.state; + let formData = false; + if (files.length) { + let file = files[0]; + formData = new FormData(); + formData.append('upload', file); + } + let updatedProcess = { + ...process, + formData + }; + this.props.onSubmit({ process: updatedProcess, previousProcess }); + } - handleImportSubmit(files, rejectedFiles) { - if (files.length > 0) { - let {onDataChanged} = this.props; - this.setState({ - dragging: false, - complete: '0', - files - }); - onDataChanged({artifactName: files[0].name}); - } - else if (rejectedFiles.length > 0) { - this.setState({ - dragging: false - }); - if (DEBUG) { - console.log('file was rejected.' + rejectedFiles[0].name); - } - } - } + handleImportSubmit(files, rejectedFiles) { + if (files.length > 0) { + let { onDataChanged } = this.props; + this.setState({ + dragging: false, + complete: '0', + files + }); + onDataChanged({ artifactName: files[0].name }); + } else if (rejectedFiles.length > 0) { + this.setState({ + dragging: false + }); + if (DEBUG) { + console.log('file was rejected.' + rejectedFiles[0].name); + } + } + } } export default SoftwareProductProcessesEditorForm; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorReducer.js index 11b89b17c2..a8731fd163 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorReducer.js @@ -13,43 +13,49 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, VSP_PROCESS_FORM} from './SoftwareProductProcessesConstants.js'; +import { + actionTypes, + VSP_PROCESS_FORM +} from './SoftwareProductProcessesConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.SOFTWARE_PRODUCT_PROCESS_EDITOR_OPEN: - return { - ...state, - formReady: null, - formName: VSP_PROCESS_FORM, - genericFieldInfo: { - 'name' : { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}] - }, - 'description' : { - isValid: true, - errorText: '', - validations: [{type: 'maxLength', data: 1000}] - }, - 'artifactName' : { - isValid: true, - errorText: '', - validations: [] - }, - 'type' : { - isValid: true, - errorText: '', - validations: [] - } - }, - data: action.process - }; - case actionTypes.SOFTWARE_PRODUCT_PROCESS_EDITOR_CLOSE: - return {}; + switch (action.type) { + case actionTypes.SOFTWARE_PRODUCT_PROCESS_EDITOR_OPEN: + return { + ...state, + formReady: null, + formName: VSP_PROCESS_FORM, + genericFieldInfo: { + name: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 120 } + ] + }, + description: { + isValid: true, + errorText: '', + validations: [{ type: 'maxLength', data: 1000 }] + }, + artifactName: { + isValid: true, + errorText: '', + validations: [] + }, + type: { + isValid: true, + errorText: '', + validations: [] + } + }, + data: action.process + }; + case actionTypes.SOFTWARE_PRODUCT_PROCESS_EDITOR_CLOSE: + return {}; - default: - return state; - } + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorView.jsx index 9ce690a1ca..867090bb31 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorView.jsx @@ -15,16 +15,18 @@ */ import React from 'react'; -import {optionsInputValues as ProcessesOptionsInputValues} from './SoftwareProductProcessesConstants.js'; +import { optionsInputValues as ProcessesOptionsInputValues } from './SoftwareProductProcessesConstants.js'; import SoftwareProductProcessesEditorForm from './SoftwareProductProcessesEditorForm.jsx'; - class SoftwareProductProcessesEditorView extends React.Component { - render() { - return ( - - ); - } + render() { + return ( + + ); + } } export default SoftwareProductProcessesEditorView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesListReducer.js index 20390d1f60..0e4d94650e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesListReducer.js @@ -13,20 +13,26 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './SoftwareProductProcessesConstants.js'; +import { actionTypes } from './SoftwareProductProcessesConstants.js'; export default (state = [], action) => { - switch (action.type) { - case actionTypes.FETCH_SOFTWARE_PRODUCT_PROCESSES: - return [...action.processesList]; - case actionTypes.EDIT_SOFTWARE_PRODUCT_PROCESS: - const indexForEdit = state.findIndex(process => process.id === action.process.id); - return [...state.slice(0, indexForEdit), action.process, ...state.slice(indexForEdit + 1)]; - case actionTypes.ADD_SOFTWARE_PRODUCT_PROCESS: - return [...state, action.process]; - case actionTypes.DELETE_SOFTWARE_PRODUCT_PROCESS: - return state.filter(process => process.id !== action.processId); - default: - return state; - } + switch (action.type) { + case actionTypes.FETCH_SOFTWARE_PRODUCT_PROCESSES: + return [...action.processesList]; + case actionTypes.EDIT_SOFTWARE_PRODUCT_PROCESS: + const indexForEdit = state.findIndex( + process => process.id === action.process.id + ); + return [ + ...state.slice(0, indexForEdit), + action.process, + ...state.slice(indexForEdit + 1) + ]; + case actionTypes.ADD_SOFTWARE_PRODUCT_PROCESS: + return [...state, action.process]; + case actionTypes.DELETE_SOFTWARE_PRODUCT_PROCESS: + return state.filter(process => process.id !== action.processId); + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesView.jsx index b0da767a2b..1357c31e12 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesView.jsx @@ -20,45 +20,63 @@ import Modal from 'nfvo-components/modal/Modal.jsx'; import SoftwareProductProcessesEditor from './SoftwareProductProcessesEditor.js'; import SoftwareProductProcessListView from './SoftwareProductProcessListView.jsx'; - class SoftwareProductProcessesView extends React.Component { + state = { + localFilter: '' + }; - state = { - localFilter: '' - }; - - static propTypes = { - onAddProcess: PropTypes.func.isRequired, - onEditProcess: PropTypes.func.isRequired, - onDeleteProcess: PropTypes.func.isRequired, - isDisplayEditor: PropTypes.bool.isRequired, - isReadOnlyMode: PropTypes.bool.isRequired, - currentSoftwareProduct:PropTypes.object - }; - - render() { - return ( -
    - {this.renderEditor()} - -
    - ); - } + static propTypes = { + onAddProcess: PropTypes.func.isRequired, + onEditProcess: PropTypes.func.isRequired, + onDeleteProcess: PropTypes.func.isRequired, + isDisplayEditor: PropTypes.bool.isRequired, + isReadOnlyMode: PropTypes.bool.isRequired, + currentSoftwareProduct: PropTypes.object + }; - renderEditor() { - let {currentSoftwareProduct: {id}, version, isModalInEditMode, isReadOnlyMode, isDisplayEditor} = this.props; - return ( + render() { + return ( +
    + {this.renderEditor()} + +
    + ); + } - - - {isModalInEditMode ? i18n('Edit Process Details') : i18n('Create New Process Details')} - - - - - - ); - } + renderEditor() { + let { + currentSoftwareProduct: { id }, + version, + isModalInEditMode, + isReadOnlyMode, + isDisplayEditor + } = this.props; + return ( + + + + {isModalInEditMode + ? i18n('Edit Process Details') + : i18n('Create New Process Details')} + + + + + + + ); + } } export default SoftwareProductProcessesView; diff --git a/openecomp-ui/src/sdc-app/onboarding/userNotifications/NotificationsReducer.js b/openecomp-ui/src/sdc-app/onboarding/userNotifications/NotificationsReducer.js index 2c3442ee68..a3004995d7 100644 --- a/openecomp-ui/src/sdc-app/onboarding/userNotifications/NotificationsReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/userNotifications/NotificationsReducer.js @@ -14,59 +14,66 @@ * permissions and limitations under the License. */ -import {actionTypes} from './UserNotificationsConstants.js'; +import { actionTypes } from './UserNotificationsConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.NOTIFICATION: - let list = (state.notificationsList) ? state.notificationsList : []; - const {notifications, lastScanned} = action.data; - return { - ...state, - lastScanned, - notificationsList: [...notifications, ...list], - numOfNotSeenNotifications: state.numOfNotSeenNotifications + notifications.length - }; - case actionTypes.LOAD_NOTIFICATIONS: - return { - ...state, - ...action.result, - notificationsList: action.result.notifications, - notifications: undefined - }; - case actionTypes.LOAD_PREV_NOTIFICATIONS: - const {notifications: prevNotifications, endOfPage: newEndOfPage} = action.result; - return { - ...state, - notificationsList: [ - ...state.notificationsList, - ...prevNotifications - ], - endOfPage: newEndOfPage - }; - case actionTypes.UPDATE_READ_NOTIFICATION: - let {notificationForUpdate} = action; - notificationForUpdate = {...notificationForUpdate, read: true}; - const indexForEdit = state.notificationsList.findIndex(notification => notification.eventId === notificationForUpdate.eventId); - return { - ...state, - notificationsList: [ - ...state.notificationsList.slice(0, indexForEdit), - notificationForUpdate, - ...state.notificationsList.slice(indexForEdit + 1) - ] - }; - case actionTypes.RESET_NEW_NOTIFICATIONS: - return { - ...state, - numOfNotSeenNotifications: 0 - }; - case actionTypes.TOGGLE_OVERLAY: - return { - ...state, - showNotificationsOverlay: action.showNotificationsOverlay - }; - default: - return state; - } + switch (action.type) { + case actionTypes.NOTIFICATION: + let list = state.notificationsList ? state.notificationsList : []; + const { notifications, lastScanned } = action.data; + return { + ...state, + lastScanned, + notificationsList: [...notifications, ...list], + numOfNotSeenNotifications: + state.numOfNotSeenNotifications + notifications.length + }; + case actionTypes.LOAD_NOTIFICATIONS: + return { + ...state, + ...action.result, + notificationsList: action.result.notifications, + notifications: undefined + }; + case actionTypes.LOAD_PREV_NOTIFICATIONS: + const { + notifications: prevNotifications, + endOfPage: newEndOfPage + } = action.result; + return { + ...state, + notificationsList: [ + ...state.notificationsList, + ...prevNotifications + ], + endOfPage: newEndOfPage + }; + case actionTypes.UPDATE_READ_NOTIFICATION: + let { notificationForUpdate } = action; + notificationForUpdate = { ...notificationForUpdate, read: true }; + const indexForEdit = state.notificationsList.findIndex( + notification => + notification.eventId === notificationForUpdate.eventId + ); + return { + ...state, + notificationsList: [ + ...state.notificationsList.slice(0, indexForEdit), + notificationForUpdate, + ...state.notificationsList.slice(indexForEdit + 1) + ] + }; + case actionTypes.RESET_NEW_NOTIFICATIONS: + return { + ...state, + numOfNotSeenNotifications: 0 + }; + case actionTypes.TOGGLE_OVERLAY: + return { + ...state, + showNotificationsOverlay: action.showNotificationsOverlay + }; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/userNotifications/NotificationsView.jsx b/openecomp-ui/src/sdc-app/onboarding/userNotifications/NotificationsView.jsx index de105d23a7..7f5b334586 100644 --- a/openecomp-ui/src/sdc-app/onboarding/userNotifications/NotificationsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/userNotifications/NotificationsView.jsx @@ -18,89 +18,155 @@ import React from 'react'; import PropTypes from 'prop-types'; import enhanceWithClickOutside from 'react-click-outside'; import classnames from 'classnames'; -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; import Overlay from 'nfvo-components/overlay/Overlay.jsx'; import UserNotifications from 'sdc-app/onboarding/userNotifications/UserNotifications.jsx'; import UserNotificationsActionHelper from 'sdc-app/onboarding/userNotifications/UserNotificationsActionHelper.js'; -import {actionTypes} from './UserNotificationsConstants.js'; +import { actionTypes } from './UserNotificationsConstants.js'; import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; -const mapStateToProps = ({currentScreen, notifications, users: {usersList}}) => { - return {currentScreen, notifications, usersList}; +const mapStateToProps = ({ + currentScreen, + notifications, + users: { usersList } +}) => { + return { currentScreen, notifications, usersList }; }; -const mapActionToProps = (dispatch) => { - return { - resetNewNotifications: notificationId => UserNotificationsActionHelper.updateLastSeenNotification(dispatch, {notificationId}), - toggleOverlay: ({showNotificationsOverlay}) => dispatch({type: actionTypes.TOGGLE_OVERLAY, showNotificationsOverlay}), - onLoadPrevNotifications: (lastScanned, endOfPage) => UserNotificationsActionHelper.loadPreviousNotifications(dispatch, {lastScanned, endOfPage}), - onSync: ({itemId, itemName, versionId, versionName, currentScreen}) => UserNotificationsActionHelper.syncItem(dispatch, {itemId, itemName, versionId, versionName, currentScreen}), - updateNotification: notificationForUpdate => UserNotificationsActionHelper.updateNotification(dispatch, {notificationForUpdate}), - onLoadItemsLists: () => OnboardingActionHelper.loadItemsLists(dispatch) - }; +const mapActionToProps = dispatch => { + return { + resetNewNotifications: notificationId => + UserNotificationsActionHelper.updateLastSeenNotification(dispatch, { + notificationId + }), + toggleOverlay: ({ showNotificationsOverlay }) => + dispatch({ + type: actionTypes.TOGGLE_OVERLAY, + showNotificationsOverlay + }), + onLoadPrevNotifications: (lastScanned, endOfPage) => + UserNotificationsActionHelper.loadPreviousNotifications(dispatch, { + lastScanned, + endOfPage + }), + onSync: ({ itemId, itemName, versionId, versionName, currentScreen }) => + UserNotificationsActionHelper.syncItem(dispatch, { + itemId, + itemName, + versionId, + versionName, + currentScreen + }), + updateNotification: notificationForUpdate => + UserNotificationsActionHelper.updateNotification(dispatch, { + notificationForUpdate + }), + onLoadItemsLists: () => OnboardingActionHelper.loadItemsLists(dispatch) + }; }; - class NotificationsView extends React.Component { + static propTypes = { + currentScreen: PropTypes.object, + notifications: PropTypes.object, + resetNewNotifications: PropTypes.func, + toggleOverlay: PropTypes.func, + onLoadPrevNotifications: PropTypes.func, + onSync: PropTypes.func, + updateNotification: PropTypes.func, + onLoadItemsLists: PropTypes.func + }; - static propTypes = { - currentScreen: PropTypes.object, - notifications: PropTypes.object, - resetNewNotifications: PropTypes.func, - toggleOverlay: PropTypes.func, - onLoadPrevNotifications: PropTypes.func, - onSync: PropTypes.func, - updateNotification: PropTypes.func, - onLoadItemsLists: PropTypes.func - }; - - render() { - const {usersList, notifications, onLoadPrevNotifications, onSync, updateNotification, onLoadItemsLists, currentScreen} = this.props; - const {notificationsList, numOfNotSeenNotifications, showNotificationsOverlay, lastScanned, endOfPage} = notifications; + render() { + const { + usersList, + notifications, + onLoadPrevNotifications, + onSync, + updateNotification, + onLoadItemsLists, + currentScreen + } = this.props; + const { + notificationsList, + numOfNotSeenNotifications, + showNotificationsOverlay, + lastScanned, + endOfPage + } = notifications; - return ( -
    -
    this.onNotificationIconClick()}> - 0 ? 'notificationFullBell' : 'notificationBell'} color={numOfNotSeenNotifications > 0 ? 'primary' : ''}/> -
    - {numOfNotSeenNotifications} -
    -
    - {showNotificationsOverlay && - - - - } -
    - ); - } + return ( +
    +
    this.onNotificationIconClick()}> + 0 + ? 'notificationFullBell' + : 'notificationBell' + } + color={numOfNotSeenNotifications > 0 ? 'primary' : ''} + /> +
    + {numOfNotSeenNotifications} +
    +
    + {showNotificationsOverlay && ( + + + + )} +
    + ); + } - handleClickOutside() { - const {notifications: {showNotificationsOverlay}} = this.props; - if(showNotificationsOverlay) { - this.onCloseOverlay(); - } - } + handleClickOutside() { + const { notifications: { showNotificationsOverlay } } = this.props; + if (showNotificationsOverlay) { + this.onCloseOverlay(); + } + } - onNotificationIconClick() { - const {notifications: {showNotificationsOverlay}, toggleOverlay} = this.props; - if (showNotificationsOverlay) { - this.onCloseOverlay(); - } else { - toggleOverlay({showNotificationsOverlay: true}); - } - } + onNotificationIconClick() { + const { + notifications: { showNotificationsOverlay }, + toggleOverlay + } = this.props; + if (showNotificationsOverlay) { + this.onCloseOverlay(); + } else { + toggleOverlay({ showNotificationsOverlay: true }); + } + } - onCloseOverlay() { - const {notifications: {numOfNotSeenNotifications, lastScanned}, resetNewNotifications, toggleOverlay} = this.props; - if (numOfNotSeenNotifications) { - resetNewNotifications(lastScanned); - } - toggleOverlay({showNotificationsOverlay: false}); - } + onCloseOverlay() { + const { + notifications: { numOfNotSeenNotifications, lastScanned }, + resetNewNotifications, + toggleOverlay + } = this.props; + if (numOfNotSeenNotifications) { + resetNewNotifications(lastScanned); + } + toggleOverlay({ showNotificationsOverlay: false }); + } } -export default connect(mapStateToProps, mapActionToProps)(enhanceWithClickOutside(NotificationsView)); +export default connect(mapStateToProps, mapActionToProps)( + enhanceWithClickOutside(NotificationsView) +); diff --git a/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotifications.jsx b/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotifications.jsx index fd5c04db92..01ca50cd4f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotifications.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotifications.jsx @@ -19,126 +19,193 @@ import PropTypes from 'prop-types'; import ReactDOM from 'react-dom'; import classnames from 'classnames'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {notificationType} from './UserNotificationsConstants.js'; +import { notificationType } from './UserNotificationsConstants.js'; import ShowMore from 'react-show-more'; -const Notification = ({notification, users, onActionClicked, getNotificationTypeDesc}) => { - const {eventType, read, eventAttributes, dateTime} = notification; - const {itemName, userId, description, versionName, permission, granted} = eventAttributes; - const {fullName: userName} = users.find(user => user.userId === userId); - return ( -
    -
    -
    - {itemName} - {versionName &&    v{versionName}} - {!read &&
    } -
    -
    -
    {getNotificationTypeDesc(eventType, permission, granted)}
    -
    -
    {`${i18n('By')} ${userName}`}
    -
    - {(description || versionName) &&
    - {description && - {description} - } - {eventType === notificationType.ITEM_CHANGED.SUBMIT && -
    -
    {i18n('Version {versionName} was submitted.', {versionName: versionName})}
    -
    - } -
    - } -
    {dateTime}
    -
    -
    -
    onActionClicked(notification)}> - {eventType === notificationType.PERMISSION_CHANGED - || eventType === notificationType.ITEM_DELETED - || eventType === notificationType.ITEM_ARCHIVED - || eventType === notificationType.ITEM_RESTORED ? i18n('OK') : i18n('Sync')} -
    -
    -
    - ); +const Notification = ({ + notification, + users, + onActionClicked, + getNotificationTypeDesc +}) => { + const { eventType, read, eventAttributes, dateTime } = notification; + const { + itemName, + userId, + description, + versionName, + permission, + granted + } = eventAttributes; + const { fullName: userName } = users.find(user => user.userId === userId); + return ( +
    +
    +
    + {itemName} + {versionName && ( +    v{versionName} + )} + {!read &&
    } +
    +
    +
    + {getNotificationTypeDesc( + eventType, + permission, + granted + )} +
    +
    +
    {`${i18n( + 'By' + )} ${userName}`}
    +
    + {(description || versionName) && ( +
    + {description && ( + + {description} + + )} + {eventType === notificationType.ITEM_CHANGED.SUBMIT && ( +
    +
    + {i18n( + 'Version {versionName} was submitted.', + { versionName: versionName } + )} +
    +
    + )} +
    + )} +
    {dateTime}
    +
    +
    +
    onActionClicked(notification)}> + {eventType === notificationType.PERMISSION_CHANGED || + eventType === notificationType.ITEM_DELETED || + eventType === notificationType.ITEM_ARCHIVED || + eventType === notificationType.ITEM_RESTORED + ? i18n('OK') + : i18n('Sync')} +
    +
    +
    + ); }; function getNotificationTypeDesc(eventType, permission, granted) { - switch (eventType) { - case notificationType.PERMISSION_CHANGED: - const grantedStr = granted ? i18n('Granted') : i18n('Taken'); - return `${i18n('Permission')} ${grantedStr}: ${permission}`; - case notificationType.ITEM_CHANGED.COMMIT: - return i18n('Your Copy Is Out Of Sync'); - case notificationType.ITEM_CHANGED.SUBMIT: - return i18n('Version Submitted'); - case notificationType.ITEM_DELETED: - return i18n('Item was deleted'); - case notificationType.ITEM_ARCHIVED: - return i18n('Item was archived'); - case notificationType.ITEM_RESTORED: - return i18n('Item was restored from archive'); - } + switch (eventType) { + case notificationType.PERMISSION_CHANGED: + const grantedStr = granted ? i18n('Granted') : i18n('Taken'); + return `${i18n('Permission')} ${grantedStr}: ${permission}`; + case notificationType.ITEM_CHANGED.COMMIT: + return i18n('Your Copy Is Out Of Sync'); + case notificationType.ITEM_CHANGED.SUBMIT: + return i18n('Version Submitted'); + case notificationType.ITEM_DELETED: + return i18n('Item was deleted'); + case notificationType.ITEM_ARCHIVED: + return i18n('Item was archived'); + case notificationType.ITEM_RESTORED: + return i18n('Item was restored from archive'); + } } class UserNotifications extends React.Component { + static propTypes = { + currentScreen: PropTypes.object, + notificationsList: PropTypes.array, + usersList: PropTypes.array, + lastScanned: PropTypes.string, + endOfPage: PropTypes.string, + onLoadPrevNotifications: PropTypes.func, + onSync: PropTypes.func, + updateNotification: PropTypes.func, + onLoadItemsLists: PropTypes.func + }; - static propTypes = { - currentScreen: PropTypes.object, - notificationsList: PropTypes.array, - usersList: PropTypes.array, - lastScanned: PropTypes.string, - endOfPage:PropTypes.string, - onLoadPrevNotifications: PropTypes.func, - onSync: PropTypes.func, - updateNotification: PropTypes.func, - onLoadItemsLists: PropTypes.func - }; + render() { + const { + notificationsList = [], + usersList, + lastScanned, + endOfPage + } = this.props; - render() { - const {notificationsList = [], usersList, lastScanned, endOfPage} = this.props; + return ( +
    +
    + {i18n('Notifications')} +
    +
    + this.loadPrevNotifications(lastScanned, endOfPage) + }> + {notificationsList.map(notification => ( + + this.onActionClicked(notification) + } + getNotificationTypeDesc={getNotificationTypeDesc} + /> + ))} +
    +
    + ); + } - return ( -
    -
    {i18n('Notifications')}
    -
    this.loadPrevNotifications(lastScanned, endOfPage)}> - { - notificationsList.map(notification => ( - this.onActionClicked(notification)} - getNotificationTypeDesc={getNotificationTypeDesc}/>)) - } -
    -
    - ); - } + onActionClicked(notification) { + const { + onSync, + updateNotification, + currentScreen, + onLoadItemsLists + } = this.props; + const { + eventType, + eventAttributes: { itemId, itemName, versionId, versionName } + } = notification; + if ( + eventType !== notificationType.PERMISSION_CHANGED && + eventType !== notificationType.ITEM_DELETED && + eventType !== notificationType.ITEM_ARCHIVED && + eventType !== notificationType.ITEM_RESTORED + ) { + onSync({ itemId, itemName, versionId, versionName, currentScreen }); + } else { + onLoadItemsLists(); + } + updateNotification(notification); + } - onActionClicked(notification) { - const {onSync, updateNotification, currentScreen, onLoadItemsLists} = this.props; - const {eventType, eventAttributes: {itemId, itemName, versionId, versionName}} = notification; - if(eventType !== notificationType.PERMISSION_CHANGED && - eventType !== notificationType.ITEM_DELETED && - eventType !== notificationType.ITEM_ARCHIVED && - eventType !== notificationType.ITEM_RESTORED) { - onSync({itemId, itemName, versionId, versionName, currentScreen}); - } - else { - onLoadItemsLists(); - } - updateNotification(notification); - } + loadPrevNotifications(lastScanned, endOfPage) { + if (endOfPage && lastScanned) { + let element = ReactDOM.findDOMNode(this.refs['notificationList']); + const { onLoadPrevNotifications } = this.props; - loadPrevNotifications(lastScanned, endOfPage) { - if(endOfPage && lastScanned) { - let element = ReactDOM.findDOMNode(this.refs['notificationList']); - const {onLoadPrevNotifications} = this.props; - - if (element && element.clientHeight + element.scrollTop === element.scrollHeight) { - onLoadPrevNotifications(lastScanned, endOfPage); - } - } - } + if ( + element && + element.clientHeight + element.scrollTop === + element.scrollHeight + ) { + onLoadPrevNotifications(lastScanned, endOfPage); + } + } + } } -export default UserNotifications; \ No newline at end of file +export default UserNotifications; diff --git a/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotificationsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotificationsActionHelper.js index 574aa0f3fc..f8693e15be 100644 --- a/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotificationsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotificationsActionHelper.js @@ -1,123 +1,175 @@ -import {actionTypes} from './UserNotificationsConstants.js'; +import { actionTypes } from './UserNotificationsConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Configuration from 'sdc-app/config/Configuration.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; -import WebSocketUtil, {websocketUrl} from 'nfvo-utils/WebSocketUtil.js'; -import {actionsEnum as VersionControllerActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import WebSocketUtil, { websocketUrl } from 'nfvo-utils/WebSocketUtil.js'; +import { actionsEnum as VersionControllerActionsEnum } from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; import MergeEditorActionHelper from 'sdc-app/common/merge/MergeEditorActionHelper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; -import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; +import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js'; function baseUrl() { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/notifications`; + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/notifications`; } function fetch() { - return RestAPIUtil.fetch(baseUrl()); + return RestAPIUtil.fetch(baseUrl()); } function updateNotification(notificationId) { - return RestAPIUtil.put(`${baseUrl()}/${notificationId}`); + return RestAPIUtil.put(`${baseUrl()}/${notificationId}`); } function updateLastSeenNotification(notificationId) { - return RestAPIUtil.put(`${baseUrl()}/last-seen/${notificationId}`); + return RestAPIUtil.put(`${baseUrl()}/last-seen/${notificationId}`); } function loadPrevNotifications(lastScanned, endOfPage) { - return RestAPIUtil.fetch(`${baseUrl()}?LAST_DELIVERED_EVENT_ID=${lastScanned}&END_OF_PAGE_EVENT_ID=${endOfPage}`); + return RestAPIUtil.fetch( + `${baseUrl()}?LAST_DELIVERED_EVENT_ID=${lastScanned}&END_OF_PAGE_EVENT_ID=${endOfPage}` + ); } const INITIAL_LAST_SCANNED = '00000000-0000-1000-8080-808080808080'; const UserNotificationsActionHelper = { - notificationsFirstHandling(dispatch) { - console.log('Websocket Url: ', websocketUrl); - UserNotificationsActionHelper.fetchUserNotificationsList(dispatch).then(({lastScanned}) => { - WebSocketUtil.open(websocketUrl, {lastScanned: lastScanned || INITIAL_LAST_SCANNED}); - }); - }, + notificationsFirstHandling(dispatch) { + console.log('Websocket Url: ', websocketUrl); + UserNotificationsActionHelper.fetchUserNotificationsList(dispatch).then( + ({ lastScanned }) => { + WebSocketUtil.open(websocketUrl, { + lastScanned: lastScanned || INITIAL_LAST_SCANNED + }); + } + ); + }, - fetchUserNotificationsList(dispatch) { - return fetch().then(result => { - dispatch({ - type: actionTypes.LOAD_NOTIFICATIONS, - result - }); - return Promise.resolve({lastScanned: result.lastScanned}); - }); - }, + fetchUserNotificationsList(dispatch) { + return fetch().then(result => { + dispatch({ + type: actionTypes.LOAD_NOTIFICATIONS, + result + }); + return Promise.resolve({ lastScanned: result.lastScanned }); + }); + }, - loadPreviousNotifications(dispatch, {lastScanned, endOfPage}) { - loadPrevNotifications(lastScanned, endOfPage).then(result => dispatch({ - type: actionTypes.LOAD_PREV_NOTIFICATIONS, - result - })); - }, + loadPreviousNotifications(dispatch, { lastScanned, endOfPage }) { + loadPrevNotifications(lastScanned, endOfPage).then(result => + dispatch({ + type: actionTypes.LOAD_PREV_NOTIFICATIONS, + result + }) + ); + }, - notifyAboutConflicts(dispatch, {itemId, itemName, version, currentScreen}) { - let {props} = currentScreen; - let currentItemId = props.softwareProductId || props.licenseModelId; - let currentVersion = props.version; - if(currentItemId === itemId && currentVersion.id === version.id) { - MergeEditorActionHelper.analyzeSyncResult(dispatch, {itemId, version}).then(() => ScreensHelper.loadScreen(dispatch, currentScreen)); - } - else { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_WARNING, - data: { - title: i18n('Conflicts'), - msg: i18n('There are conflicts in {itemName} version {versionName} that you have to resolve', {itemName: itemName.toUpperCase(), versionName: version.versionName}), - cancelButtonText: i18n('OK') - } - }); - } - }, + notifyAboutConflicts( + dispatch, + { itemId, itemName, version, currentScreen } + ) { + let { props } = currentScreen; + let currentItemId = props.softwareProductId || props.licenseModelId; + let currentVersion = props.version; + if (currentItemId === itemId && currentVersion.id === version.id) { + MergeEditorActionHelper.analyzeSyncResult(dispatch, { + itemId, + version + }).then(() => ScreensHelper.loadScreen(dispatch, currentScreen)); + } else { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: i18n('Conflicts'), + msg: i18n( + 'There are conflicts in {itemName} version {versionName} that you have to resolve', + { + itemName: itemName.toUpperCase(), + versionName: version.versionName + } + ), + cancelButtonText: i18n('OK') + } + }); + } + }, - syncItem(dispatch, {itemId, itemName, versionId, versionName, currentScreen}) { - let version = {id: versionId, versionName}; - ItemsHelper.fetchVersion({itemId, versionId}).then(response => { - let inMerge = response && response.state && response.state.synchronizationState === SyncStates.MERGE; - if (!inMerge) { - ItemsHelper.performVCAction({itemId, version, action: VersionControllerActionsEnum.SYNC}).then(() => { - return ItemsHelper.fetchVersion({itemId, versionId}).then(response => { - let inMerge = response && response.state && response.state.synchronizationState === SyncStates.MERGE; - if (!inMerge) { - return ScreensHelper.loadScreen(dispatch, currentScreen); - } - else { - return this.notifyAboutConflicts(dispatch, {itemId, itemName, version, currentScreen}); - } - }); - }); - } - else { - this.notifyAboutConflicts(dispatch, {itemId, itemName, version, currentScreen}); - } - }); - }, + syncItem( + dispatch, + { itemId, itemName, versionId, versionName, currentScreen } + ) { + let version = { id: versionId, versionName }; + ItemsHelper.fetchVersion({ itemId, versionId }).then(response => { + let inMerge = + response && + response.state && + response.state.synchronizationState === SyncStates.MERGE; + if (!inMerge) { + ItemsHelper.performVCAction({ + itemId, + version, + action: VersionControllerActionsEnum.SYNC + }).then(() => { + return ItemsHelper.fetchVersion({ itemId, versionId }).then( + response => { + let inMerge = + response && + response.state && + response.state.synchronizationState === + SyncStates.MERGE; + if (!inMerge) { + return ScreensHelper.loadScreen( + dispatch, + currentScreen + ); + } else { + return this.notifyAboutConflicts(dispatch, { + itemId, + itemName, + version, + currentScreen + }); + } + } + ); + }); + } else { + this.notifyAboutConflicts(dispatch, { + itemId, + itemName, + version, + currentScreen + }); + } + }); + }, - updateNotification(dispatch, {notificationForUpdate}) { - updateNotification(notificationForUpdate.eventId).then(response => { - if(response.status === 'Success' && Object.keys(response.errors).length === 0) { - dispatch({ - type: actionTypes.UPDATE_READ_NOTIFICATION, - notificationForUpdate - }); - } - }); - }, + updateNotification(dispatch, { notificationForUpdate }) { + updateNotification(notificationForUpdate.eventId).then(response => { + if ( + response.status === 'Success' && + Object.keys(response.errors).length === 0 + ) { + dispatch({ + type: actionTypes.UPDATE_READ_NOTIFICATION, + notificationForUpdate + }); + } + }); + }, - updateLastSeenNotification(dispatch, {notificationId}) { - updateLastSeenNotification(notificationId).then(response => { - if (response.status === 'Success' && Object.keys(response.errors).length === 0) { - dispatch({type: actionTypes.RESET_NEW_NOTIFICATIONS}); - } - }); - } + updateLastSeenNotification(dispatch, { notificationId }) { + updateLastSeenNotification(notificationId).then(response => { + if ( + response.status === 'Success' && + Object.keys(response.errors).length === 0 + ) { + dispatch({ type: actionTypes.RESET_NEW_NOTIFICATIONS }); + } + }); + } }; export default UserNotificationsActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotificationsConstants.js b/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotificationsConstants.js index a8e92e29fd..b2466f19af 100644 --- a/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotificationsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotificationsConstants.js @@ -1,22 +1,21 @@ - import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - NOTIFICATION: null, - LOAD_NOTIFICATIONS: null, - LOAD_PREV_NOTIFICATIONS: null, - UPDATE_READ_NOTIFICATION: null, - RESET_NEW_NOTIFICATIONS: null, - TOGGLE_OVERLAY: null + NOTIFICATION: null, + LOAD_NOTIFICATIONS: null, + LOAD_PREV_NOTIFICATIONS: null, + UPDATE_READ_NOTIFICATION: null, + RESET_NEW_NOTIFICATIONS: null, + TOGGLE_OVERLAY: null }); export const notificationType = keyMirror({ - PERMISSION_CHANGED: 'PermissionChanged', - ITEM_CHANGED: { - COMMIT: 'commit', - SUBMIT: 'submit' - }, - ITEM_DELETED: 'delete', - ITEM_ARCHIVED: 'archive', - ITEM_RESTORED: 'restore' -}); \ No newline at end of file + PERMISSION_CHANGED: 'PermissionChanged', + ITEM_CHANGED: { + COMMIT: 'commit', + SUBMIT: 'submit' + }, + ITEM_DELETED: 'delete', + ITEM_ARCHIVED: 'archive', + ITEM_RESTORED: 'restore' +}); diff --git a/openecomp-ui/src/sdc-app/onboarding/users/UsersActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/users/UsersActionHelper.js index a2e92fe0bc..98bce1ce56 100644 --- a/openecomp-ui/src/sdc-app/onboarding/users/UsersActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/users/UsersActionHelper.js @@ -16,46 +16,41 @@ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from './UsersConstants.js'; +import { actionTypes } from './UsersConstants.js'; function getUserId() { - let catalogApiHeaders = Configuration.get('CatalogApiHeaders'); - let User = catalogApiHeaders && catalogApiHeaders.userId; - let userId = User && User.value ? User.value : ''; - return userId; + let catalogApiHeaders = Configuration.get('CatalogApiHeaders'); + let User = catalogApiHeaders && catalogApiHeaders.userId; + let userId = User && User.value ? User.value : ''; + return userId; } function baseUrl() { - const restCatalogPrefix = Configuration.get('restCatalogPrefix'); - return `${restCatalogPrefix}`; + const restCatalogPrefix = Configuration.get('restCatalogPrefix'); + return `${restCatalogPrefix}`; } - function fetchUsersList() { - const url = '/v1/user/users'; - return RestAPIUtil.fetch(`${baseUrl()}${url}`); + const url = '/v1/user/users'; + return RestAPIUtil.fetch(`${baseUrl()}${url}`); } - - const UsersActionHelper = { - fetchUsersList(dispatch) { - fetchUsersList().then(response => { - dispatch({ - type: actionTypes.USERS_LIST_LOADED, - usersList: response - }); - - let userId = getUserId(); - let userInfo = response.find(user => user.userId === userId); - dispatch({ - type: actionTypes.GOT_USER_INFO, - userInfo - }); - - }); - - } + fetchUsersList(dispatch) { + fetchUsersList().then(response => { + dispatch({ + type: actionTypes.USERS_LIST_LOADED, + usersList: response + }); + + let userId = getUserId(); + let userInfo = response.find(user => user.userId === userId); + dispatch({ + type: actionTypes.GOT_USER_INFO, + userInfo + }); + }); + } }; export default UsersActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/users/UsersConstants.js b/openecomp-ui/src/sdc-app/onboarding/users/UsersConstants.js index fdcf4b179b..216d28ad47 100644 --- a/openecomp-ui/src/sdc-app/onboarding/users/UsersConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/users/UsersConstants.js @@ -17,6 +17,6 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - USERS_LIST_LOADED: null, - GOT_USER_INFO: null + USERS_LIST_LOADED: null, + GOT_USER_INFO: null }); diff --git a/openecomp-ui/src/sdc-app/onboarding/users/UsersReducers.js b/openecomp-ui/src/sdc-app/onboarding/users/UsersReducers.js index 6bd72e3b3c..89a04d2a8b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/users/UsersReducers.js +++ b/openecomp-ui/src/sdc-app/onboarding/users/UsersReducers.js @@ -14,29 +14,28 @@ * permissions and limitations under the License. */ -import {actionTypes} from './UsersConstants.js'; -import {combineReducers} from 'redux'; +import { actionTypes } from './UsersConstants.js'; +import { combineReducers } from 'redux'; -function usersList (state = [], action) { - switch (action.type) { - case (actionTypes.USERS_LIST_LOADED): - return [...action.usersList]; - default: - return state; - } -}; - -function userInfo (state = {}, action) { - switch (action.type) { - case (actionTypes.GOT_USER_INFO): - return action.userInfo; - default: - return state; - } +function usersList(state = [], action) { + switch (action.type) { + case actionTypes.USERS_LIST_LOADED: + return [...action.usersList]; + default: + return state; + } } +function userInfo(state = {}, action) { + switch (action.type) { + case actionTypes.GOT_USER_INFO: + return action.userInfo; + default: + return state; + } +} export default combineReducers({ - usersList: usersList, - userInfo: userInfo -}); \ No newline at end of file + usersList: usersList, + userInfo: userInfo +}); diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js index 0fd0eabd86..457d096219 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js @@ -14,76 +14,100 @@ * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import VersionsPageActionHelper from './VersionsPageActionHelper.js'; import VersionsPageCreationActionHelper from './creation/VersionsPageCreationActionHelper.js'; import PermissionsActionHelper from '../permissions/PermissionsActionHelper.js'; -import {onboardingMethod as onboardingMethodType} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import { onboardingMethod as onboardingMethodType } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; import VersionsPageView from './VersionsPage.jsx'; export const mapStateToProps = ({ - users: {userInfo}, - versionsPage: {permissions, versionsList}, - currentScreen: {itemPermission: {isCollaborator, isArchived}, props: {itemId}}, - softwareProductList = [] + users: { userInfo }, + versionsPage: { permissions, versionsList }, + currentScreen: { + itemPermission: { isCollaborator, isArchived }, + props: { itemId } + }, + softwareProductList = [] }) => { + let { versions = [], selectedVersion } = versionsList; + let { owner, contributors, viewers } = permissions; - let {versions = [], selectedVersion} = versionsList; - let {owner, contributors, viewers} = permissions; - - // sorting the version list - versions.sort((a,b) => { - let statusCompare = b.status.localeCompare(a.status); - if (statusCompare === 0) { - return b.modificationTime - a.modificationTime; - } else { - return statusCompare; - } - - }); - const curentSoftwareProduct = softwareProductList.find(item => item.id === itemId); - return { - versions, - contributors, - viewers, - owner, - currentUser: userInfo, - selectedVersion, - isCollaborator, - isManual: curentSoftwareProduct && curentSoftwareProduct.onboardingMethod === onboardingMethodType.MANUAL, - isArchived - }; - + // sorting the version list + versions.sort((a, b) => { + let statusCompare = b.status.localeCompare(a.status); + if (statusCompare === 0) { + return b.modificationTime - a.modificationTime; + } else { + return statusCompare; + } + }); + const curentSoftwareProduct = softwareProductList.find( + item => item.id === itemId + ); + return { + versions, + contributors, + viewers, + owner, + currentUser: userInfo, + selectedVersion, + isCollaborator, + isManual: + curentSoftwareProduct && + curentSoftwareProduct.onboardingMethod === + onboardingMethodType.MANUAL, + isArchived + }; }; -export const mapActionsToProps = (dispatch, {itemType, itemId, additionalProps}) => { - return { - onNavigateToVersion({version}) { - VersionsPageActionHelper.onNavigateToVersion(dispatch, {version, itemId, itemType, additionalProps}); - }, +export const mapActionsToProps = ( + dispatch, + { itemType, itemId, additionalProps } +) => { + return { + onNavigateToVersion({ version }) { + VersionsPageActionHelper.onNavigateToVersion(dispatch, { + version, + itemId, + itemType, + additionalProps + }); + }, - onSelectVersion({version}) { - VersionsPageActionHelper.selectVersion(dispatch, {version}); - }, + onSelectVersion({ version }) { + VersionsPageActionHelper.selectVersion(dispatch, { version }); + }, - onCreateVersion({version}) { - VersionsPageCreationActionHelper.open(dispatch, {baseVersion: version, itemId, itemType, additionalProps}); - }, + onCreateVersion({ version }) { + VersionsPageCreationActionHelper.open(dispatch, { + baseVersion: version, + itemId, + itemType, + additionalProps + }); + }, - onManagePermissions() { - PermissionsActionHelper.openPermissonsManager(dispatch, {itemId, askForRights: false}); - }, + onManagePermissions() { + PermissionsActionHelper.openPermissonsManager(dispatch, { + itemId, + askForRights: false + }); + }, - onTreeFullScreen(treeProps) { - VersionsPageActionHelper.openTree(dispatch, treeProps); - }, + onTreeFullScreen(treeProps) { + VersionsPageActionHelper.openTree(dispatch, treeProps); + }, - onModalNodeClick({version}) { - VersionsPageActionHelper.selectVersionFromModal(dispatch, {version}); - }, - onArchive: () => VersionsPageActionHelper.archiveItem(dispatch, itemId), - onRestore: () => VersionsPageActionHelper.restoreItemFromArchive(dispatch, itemId) - }; + onModalNodeClick({ version }) { + VersionsPageActionHelper.selectVersionFromModal(dispatch, { + version + }); + }, + onArchive: () => VersionsPageActionHelper.archiveItem(dispatch, itemId), + onRestore: () => + VersionsPageActionHelper.restoreItemFromArchive(dispatch, itemId) + }; }; export default connect(mapStateToProps, mapActionsToProps)(VersionsPageView); diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx index f8417fafbf..7f7af8130f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx @@ -22,81 +22,144 @@ import Button from 'sdc-ui/lib/react/Button.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import featureToggle from 'sdc-app/features/featureToggle.js'; -const DepricateButton = ({depricateAction, title}) => ( -
    - -
    +const DepricateButton = ({ depricateAction, title }) => ( +
    + +
    ); -const FeatureDepricatedButton = featureToggle('ARCHIVE_ITEM')(DepricateButton); +const FeatureDepricatedButton = featureToggle('ARCHIVE_ITEM')(DepricateButton); -const VersionPageTitle = ({itemName, depricatedTitle, isArchived, onRestore, onArchive}) => { - return ( -
    -
    {`${i18n('Available Versions')} - ${itemName} ${depricatedTitle}`}
    - onRestore() : () => onArchive() } title={i18n(isArchived ? 'RESTORE' : 'ARCHIVE')}/> -
    - ); +const VersionPageTitle = ({ + itemName, + depricatedTitle, + isArchived, + onRestore, + onArchive +}) => { + return ( +
    +
    {`${i18n( + 'Available Versions' + )} - ${itemName} ${depricatedTitle}`}
    + onRestore() : () => onArchive() + } + title={i18n(isArchived ? 'RESTORE' : 'ARCHIVE')} + /> +
    + ); }; class VersionsPage extends React.Component { - state = { - showExpanded : false - } - render() { - let { versions, owner, contributors, currentUser, isCollaborator, itemName = '', viewers, onSelectVersion, onNavigateToVersion, - onTreeFullScreen, onManagePermissions, onCreateVersion, selectedVersion, onModalNodeClick, isManual, isArchived, onArchive, onRestore} = this.props; - const depricatedTitle = isArchived ? i18n('(Archived)') : ''; - return ( -
    - - -
    -
    -
    -
    {i18n('Version Tree')}
    - {this.state.showExpanded && onTreeFullScreen({ - name: 'versions-tree-popup', - width: 798, - height: 500, - nodes: versions.map(version => ({id: version.id, name: version.name, parent: version.baseId || ''})), - onNodeClick: (version) => onModalNodeClick({version}), - selectedNodeId: selectedVersion, - scrollable: true, - toWiden: true - })} />} -
    - ({id: version.id, name: version.name, parent: version.baseId || ''}))} - onNodeClick={version => onSelectVersion({version})} - onRenderedBeyondWidth={() => {this.setState({showExpanded : true});}} - selectedNodeId={selectedVersion}/> -
    - -
    -
    - ); - } + state = { + showExpanded: false + }; + render() { + let { + versions, + owner, + contributors, + currentUser, + isCollaborator, + itemName = '', + viewers, + onSelectVersion, + onNavigateToVersion, + onTreeFullScreen, + onManagePermissions, + onCreateVersion, + selectedVersion, + onModalNodeClick, + isManual, + isArchived, + onArchive, + onRestore + } = this.props; + const depricatedTitle = isArchived ? i18n('(Archived)') : ''; + return ( +
    + + +
    +
    +
    +
    + {i18n('Version Tree')} +
    + {this.state.showExpanded && ( + + onTreeFullScreen({ + name: 'versions-tree-popup', + width: 798, + height: 500, + nodes: versions.map(version => ({ + id: version.id, + name: version.name, + parent: version.baseId || '' + })), + onNodeClick: version => + onModalNodeClick({ version }), + selectedNodeId: selectedVersion, + scrollable: true, + toWiden: true + }) + } + /> + )} +
    + ({ + id: version.id, + name: version.name, + parent: version.baseId || '' + }))} + onNodeClick={version => + onSelectVersion({ version }) + } + onRenderedBeyondWidth={() => { + this.setState({ showExpanded: true }); + }} + selectedNodeId={selectedVersion} + /> +
    + +
    +
    + ); + } } export default VersionsPage; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js index d475c03c31..606b17b897 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js @@ -14,94 +14,96 @@ * permissions and limitations under the License. */ import ItemsHelper from '../../common/helpers/ItemsHelper.js'; -import {actionTypes} from './VersionsPageConstants.js'; -import {itemTypes} from './VersionsPageConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes } from './VersionsPageConstants.js'; +import { itemTypes } from './VersionsPageConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; - +import { enums, screenTypes } from 'sdc-app/onboarding/OnboardingConstants.js'; const VersionsPageActionHelper = { - fetchVersions(dispatch, {itemType, itemId}) { - return ItemsHelper.fetchVersions({itemId}).then(response => { - dispatch({ - type: actionTypes.VERSIONS_LOADED, - versions: response.results, - itemType, - itemId - }); - return Promise.resolve(response); - }); - }, + fetchVersions(dispatch, { itemType, itemId }) { + return ItemsHelper.fetchVersions({ itemId }).then(response => { + dispatch({ + type: actionTypes.VERSIONS_LOADED, + versions: response.results, + itemType, + itemId + }); + return Promise.resolve(response); + }); + }, - selectVersion(dispatch, {version}) { - dispatch({ - type: actionTypes.SELECT_VERSION, - versionId: version.id - }); - }, + selectVersion(dispatch, { version }) { + dispatch({ + type: actionTypes.SELECT_VERSION, + versionId: version.id + }); + }, - selectNone(dispatch) { - dispatch({ type: actionTypes.SELECT_NONE }); - }, + selectNone(dispatch) { + dispatch({ type: actionTypes.SELECT_NONE }); + }, - onNavigateToVersion(dispatch, {version, itemId, itemType}) { - switch (itemType) { - case itemTypes.LICENSE_MODEL: - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.LICENSE_MODEL_OVERVIEW, screenType: screenTypes.LICENSE_MODEL, - props: {licenseModelId: itemId, version} - }); - break; - case itemTypes.SOFTWARE_PRODUCT: - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId: itemId, version} - }); - break; - } - }, + onNavigateToVersion(dispatch, { version, itemId, itemType }) { + switch (itemType) { + case itemTypes.LICENSE_MODEL: + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.LICENSE_MODEL_OVERVIEW, + screenType: screenTypes.LICENSE_MODEL, + props: { licenseModelId: itemId, version } + }); + break; + case itemTypes.SOFTWARE_PRODUCT: + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, + screenType: screenTypes.SOFTWARE_PRODUCT, + props: { softwareProductId: itemId, version } + }); + break; + } + }, - openTree(dispatch, treeProps) { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.VERSION_TREE, - modalComponentProps: treeProps, - onDeclined: () => dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }), - modalClassName: 'versions-tree-modal', - cancelButtonText: i18n('Close'), - title: i18n('Version Tree') - } - }); - }, + openTree(dispatch, treeProps) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.VERSION_TREE, + modalComponentProps: treeProps, + onDeclined: () => + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }), + modalClassName: 'versions-tree-modal', + cancelButtonText: i18n('Close'), + title: i18n('Version Tree') + } + }); + }, - selectVersionFromModal(dispatch, {version}) { - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - this.selectVersion(dispatch, {version}); - }, + selectVersionFromModal(dispatch, { version }) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + this.selectVersion(dispatch, { version }); + }, - archiveItem(dispatch, itemId) { - ItemsHelper.archiveItem(itemId).then(() => { - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.ONBOARDING_CATALOG - }); - }); - }, + archiveItem(dispatch, itemId) { + ItemsHelper.archiveItem(itemId).then(() => { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.ONBOARDING_CATALOG + }); + }); + }, - restoreItemFromArchive(dispatch, itemId) { - ItemsHelper.restoreItem(itemId).then(() => { - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.ONBOARDING_CATALOG - }); - }); - } + restoreItemFromArchive(dispatch, itemId) { + ItemsHelper.restoreItem(itemId).then(() => { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.ONBOARDING_CATALOG + }); + }); + } }; export default VersionsPageActionHelper; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageConstants.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageConstants.js index 983ab79a14..3a3879ddb3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageConstants.js @@ -16,12 +16,12 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - VERSIONS_LOADED: null, - SELECT_VERSION: null, - SELECT_NONE: null + VERSIONS_LOADED: null, + SELECT_VERSION: null, + SELECT_NONE: null }); export const itemTypes = { - LICENSE_MODEL: 'vendor-license-models', - SOFTWARE_PRODUCT: 'vendor-software-products' + LICENSE_MODEL: 'vendor-license-models', + SOFTWARE_PRODUCT: 'vendor-software-products' }; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageReducer.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageReducer.js index 9b6fa9f803..c270278f21 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageReducer.js @@ -13,30 +13,34 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './VersionsPageConstants.js'; -import {combineReducers} from 'redux'; +import { actionTypes } from './VersionsPageConstants.js'; +import { combineReducers } from 'redux'; import VersionsPageCreationReducer from './creation/VersionsPageCreationReducer.js'; import PermissionsReducer from '../permissions/PermissionsReducer.js'; -import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js'; +import { createPlainDataReducer } from 'sdc-app/common/reducers/PlainDataReducer.js'; function VersionsListReducer(state = {}, action) { - switch (action.type) { - case actionTypes.VERSIONS_LOADED: - let {versions, itemType = state.itemType, itemId} = action; - return {...state, versions, itemType, itemId}; - case actionTypes.SELECT_VERSION: - return {...state, selectedVersion: action.versionId === state.selectedVersion ? null : action.versionId}; - case actionTypes.SELECT_NONE: - return {...state, selectedVersion: null}; - default: - return state; - } -}; - - + switch (action.type) { + case actionTypes.VERSIONS_LOADED: + let { versions, itemType = state.itemType, itemId } = action; + return { ...state, versions, itemType, itemId }; + case actionTypes.SELECT_VERSION: + return { + ...state, + selectedVersion: + action.versionId === state.selectedVersion + ? null + : action.versionId + }; + case actionTypes.SELECT_NONE: + return { ...state, selectedVersion: null }; + default: + return state; + } +} export default combineReducers({ - versionCreation: createPlainDataReducer(VersionsPageCreationReducer), - versionsList: VersionsListReducer, - permissions: PermissionsReducer + versionCreation: createPlainDataReducer(VersionsPageCreationReducer), + versionsList: VersionsListReducer, + permissions: PermissionsReducer }); diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/PermissionsView.jsx b/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/PermissionsView.jsx index 26f8450f4c..74d88f0b52 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/PermissionsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/PermissionsView.jsx @@ -22,61 +22,108 @@ import Tooltip from 'react-bootstrap/lib/Tooltip.js'; const maxContributors = 6; -function extraUsersTooltip (extraUsers) { - return ( - - {extraUsers.map(extraUser =>
    {extraUser.fullName}
    )} -
    - ); +function extraUsersTooltip(extraUsers) { + return ( + + {extraUsers.map(extraUser => ( +
    + {extraUser.fullName} +
    + ))} +
    + ); } -const User = ({user, isCurrentUser, dataTestId}) => ( - +const User = ({ user, isCurrentUser, dataTestId }) => ( + ); -const Owner = ({owner, isCurrentUser}) => ( -
    -
    {i18n('Owner')}
    - -
    +const Owner = ({ owner, isCurrentUser }) => ( +
    +
    {i18n('Owner')}
    + +
    ); -const Contributors = ({contributors, owner, currentUser, onManagePermissions, isManual}) => { - let extraUsers = contributors.length - maxContributors; - return ( -
    -
    {i18n('Contributors')}
    - {contributors.slice(0, maxContributors).map(contributor => - - )} - {extraUsers > 0 && - -
    {`+${extraUsers}`}
    -
    - } - {currentUser.userId === owner.userId && !isManual && - - {i18n('Manage Permissions')} - - } -
    - ); +const Contributors = ({ + contributors, + owner, + currentUser, + onManagePermissions, + isManual +}) => { + let extraUsers = contributors.length - maxContributors; + return ( +
    +
    {i18n('Contributors')}
    + {contributors + .slice(0, maxContributors) + .map(contributor => ( + + ))} + {extraUsers > 0 && ( + +
    {`+${extraUsers}`}
    +
    + )} + {currentUser.userId === owner.userId && + !isManual && ( + + {i18n('Manage Permissions')} + + )} +
    + ); }; -const PermissionsView = ({owner, contributors, currentUser = {}, onManagePermissions, isManual}) => ( -
    -
    {i18n('Permissions')}
    -
    -
    - - -
    -
    -
    +const PermissionsView = ({ + owner, + contributors, + currentUser = {}, + onManagePermissions, + isManual +}) => ( +
    +
    + {i18n('Permissions')} +
    +
    +
    + + +
    +
    +
    ); export default PermissionsView; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/VersionList.jsx b/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/VersionList.jsx index 47255eb9dc..d74805eccc 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/VersionList.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/components/VersionList.jsx @@ -20,108 +20,177 @@ import Tooltip from 'react-bootstrap/lib/Tooltip.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import SVGIcon from 'sdc-ui/lib/react/SVGIcon.js'; -const formatTime = (time) => { - if (!time) { return ''; } +const formatTime = time => { + if (!time) { + return ''; + } - const date = new Date(time); - const options = { - year: 'numeric', - month: 'short', - day: 'numeric', - hour: '2-digit', - minute: '2-digit' - }; - const newDate = date.toLocaleTimeString('en-US', options); + const date = new Date(time); + const options = { + year: 'numeric', + month: 'short', + day: 'numeric', + hour: '2-digit', + minute: '2-digit' + }; + const newDate = date.toLocaleTimeString('en-US', options); - return newDate; + return newDate; }; const DescriptionField = ({ className, text, useTooltip }) => { - if (useTooltip) { - return ( -
    - {text}}> -
    {text}
    -
    -
    - ); - } - return
    {text}
    ; + if (useTooltip) { + return ( +
    + + {text} + + }> +
    {text}
    +
    +
    + ); + } + return
    {text}
    ; }; -const VersionListItem = ({ data, onSelectVersion, onNavigateToVersion, onCreateVersion, isHeader, isSelected, isCollaborator }) => { +const VersionListItem = ({ + data, + onSelectVersion, + onNavigateToVersion, + onCreateVersion, + isHeader, + isSelected, + isCollaborator +}) => { + let { modificationTime, name, status, description, additionalInfo } = data; + const modificationText = !isHeader + ? formatTime(modificationTime) + : i18n('Last Edited On'); - let {modificationTime, name, status, description, additionalInfo} = data; - const modificationText = !isHeader ? formatTime(modificationTime) : i18n('Last Edited On'); - - return ( -
    { - e.stopPropagation(); - onSelectVersion(); - onNavigateToVersion(); - }}> -
    {name}
    -
    {status}
    -
    {modificationText}
    - - - { - isHeader ? -
    {i18n('Actions')}
    - : -
    -
    - {e.stopPropagation(); onNavigateToVersion();}} - label={i18n('Go to this Version')} - labelPosition='right' /> -
    -
    - {!isHeader && isCollaborator && additionalInfo.OptionalCreationMethods.length > 0 && onCreateVersion && - { e.stopPropagation(); onCreateVersion(); }} - label={i18n('Create New Version')} - labelPosition='right' - disabled={!isCollaborator || !onCreateVersion} /> - } -
    -
    - } -
    - ); + return ( +
    { + e.stopPropagation(); + onSelectVersion(); + onNavigateToVersion(); + }}> +
    + {name} +
    +
    + {status} +
    +
    + {modificationText} +
    + + {isHeader ? ( +
    + {i18n('Actions')} +
    + ) : ( +
    +
    + { + e.stopPropagation(); + onNavigateToVersion(); + }} + label={i18n('Go to this Version')} + labelPosition="right" + /> +
    +
    + {!isHeader && + isCollaborator && + additionalInfo.OptionalCreationMethods.length > 0 && + onCreateVersion && ( + { + e.stopPropagation(); + onCreateVersion(); + }} + label={i18n('Create New Version')} + labelPosition="right" + disabled={ + !isCollaborator || !onCreateVersion + } + /> + )} +
    +
    + )} +
    + ); }; -const VersionList = ({ versions, onSelectVersion, onNavigateToVersion, onCreateVersion, selectedVersion, isCollaborator }) => ( -
    - -
    - {versions.map(version => - onSelectVersion({version})} - onNavigateToVersion={() => onNavigateToVersion({version})} - onCreateVersion={onCreateVersion ? () => onCreateVersion({version}) : false} - isSelected={selectedVersion === version.id} - isCollaborator={isCollaborator} /> - )} -
    -
    +const VersionList = ({ + versions, + onSelectVersion, + onNavigateToVersion, + onCreateVersion, + selectedVersion, + isCollaborator +}) => ( +
    + +
    + {versions.map(version => ( + onSelectVersion({ version })} + onNavigateToVersion={() => onNavigateToVersion({ version })} + onCreateVersion={ + onCreateVersion + ? () => onCreateVersion({ version }) + : false + } + isSelected={selectedVersion === version.id} + isCollaborator={isCollaborator} + /> + ))} +
    +
    ); export default VersionList; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreation.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreation.js index 66c1c79be5..e0cb925df4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreation.js @@ -13,32 +13,52 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {connect} from 'react-redux'; +import { connect } from 'react-redux'; import VersionsPageCreationActionHelper from './VersionsPageCreationActionHelper.js'; import VersionsPageActionHelper from '../VersionsPageActionHelper.js'; import VersionsPageCreationView from './VersionsPageCreationView.jsx'; import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -import {VERSION_CREATION_FORM_NAME} from './VersionsPageCreationConstants.js'; +import { VERSION_CREATION_FORM_NAME } from './VersionsPageCreationConstants.js'; -export const mapStateToProps = ({versionsPage: {versionCreation}}) => { - let {genericFieldInfo} = versionCreation; - let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); +export const mapStateToProps = ({ versionsPage: { versionCreation } }) => { + let { genericFieldInfo } = versionCreation; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); - return {...versionCreation, isFormValid}; + return { ...versionCreation, isFormValid }; }; -export const mapActionsToProps = (dispatch, {itemId, itemType, additionalProps}) => { - return { - onDataChanged: (deltaData, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: VERSION_CREATION_FORM_NAME, customValidations}), - onCancel: () => VersionsPageCreationActionHelper.close(dispatch), - onSubmit: ({baseVersion, payload}) => { - VersionsPageCreationActionHelper.close(dispatch); - VersionsPageCreationActionHelper.createVersion(dispatch, {baseVersion, itemId, payload}).then(response => { - VersionsPageActionHelper.onNavigateToVersion(dispatch, {version: response, itemId, itemType, additionalProps}); - }); - }, - onValidateForm: () => ValidationHelper.validateForm(dispatch, VERSION_CREATION_FORM_NAME) - }; +export const mapActionsToProps = ( + dispatch, + { itemId, itemType, additionalProps } +) => { + return { + onDataChanged: (deltaData, customValidations) => + ValidationHelper.dataChanged(dispatch, { + deltaData, + formName: VERSION_CREATION_FORM_NAME, + customValidations + }), + onCancel: () => VersionsPageCreationActionHelper.close(dispatch), + onSubmit: ({ baseVersion, payload }) => { + VersionsPageCreationActionHelper.close(dispatch); + VersionsPageCreationActionHelper.createVersion(dispatch, { + baseVersion, + itemId, + payload + }).then(response => { + VersionsPageActionHelper.onNavigateToVersion(dispatch, { + version: response, + itemId, + itemType, + additionalProps + }); + }); + }, + onValidateForm: () => + ValidationHelper.validateForm(dispatch, VERSION_CREATION_FORM_NAME) + }; }; -export default connect(mapStateToProps, mapActionsToProps)(VersionsPageCreationView); +export default connect(mapStateToProps, mapActionsToProps)( + VersionsPageCreationView +); diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationActionHelper.js index bc038689a4..6e3be705c0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationActionHelper.js @@ -15,65 +15,76 @@ */ import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from './VersionsPageCreationConstants.js'; -import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; -import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import { actionTypes } from './VersionsPageCreationConstants.js'; +import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js'; +import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import ItemsHelper from 'sdc-app/common/helpers/ItemsHelper.js'; -import {actionTypes as VersionsPageActionTypes} from '../VersionsPageConstants.js'; +import { actionTypes as VersionsPageActionTypes } from '../VersionsPageConstants.js'; -function baseUrl({itemId, baseVersion}) { - const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/items/${itemId}/versions/${baseVersion.id}/`; +function baseUrl({ itemId, baseVersion }) { + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/items/${itemId}/versions/${baseVersion.id}/`; } -function createVersion({itemId, baseVersion, payload: {description, creationMethod} }) { - return RestAPIUtil.post(baseUrl({itemId, baseVersion}), {description, creationMethod}); +function createVersion({ + itemId, + baseVersion, + payload: { description, creationMethod } +}) { + return RestAPIUtil.post(baseUrl({ itemId, baseVersion }), { + description, + creationMethod + }); } - export default { + open(dispatch, { itemType, itemId, additionalProps, baseVersion }) { + dispatch({ + type: actionTypes.OPEN + }); - open(dispatch, {itemType, itemId, additionalProps, baseVersion}) { - dispatch({ - type: actionTypes.OPEN - }); - - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_SHOW, - data: { - modalComponentName: modalContentMapper.VERSION_CREATION, - modalComponentProps: {itemType, itemId, additionalProps, baseVersion}, - title: i18n('New Version - From {name}', {name: baseVersion.name}) - } - }); - }, - - close(dispatch){ - dispatch({ - type: actionTypes.CLOSE - }); + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.VERSION_CREATION, + modalComponentProps: { + itemType, + itemId, + additionalProps, + baseVersion + }, + title: i18n('New Version - From {name}', { + name: baseVersion.name + }) + } + }); + }, - dispatch({ - type: modalActionTypes.GLOBAL_MODAL_CLOSE - }); - }, + close(dispatch) { + dispatch({ + type: actionTypes.CLOSE + }); - createVersion(dispatch, {itemId, baseVersion, payload}){ - return createVersion({itemId, baseVersion, payload}).then(result => { - return ItemsHelper.fetchVersions({itemId}).then(response => { - dispatch({ - type: VersionsPageActionTypes.VERSIONS_LOADED, - versions: response.results, - itemId - }); - dispatch({ - type: actionTypes.VERSION_CREATED, - result - }); - return result; - }); - }); - } + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_CLOSE + }); + }, + createVersion(dispatch, { itemId, baseVersion, payload }) { + return createVersion({ itemId, baseVersion, payload }).then(result => { + return ItemsHelper.fetchVersions({ itemId }).then(response => { + dispatch({ + type: VersionsPageActionTypes.VERSIONS_LOADED, + versions: response.results, + itemId + }); + dispatch({ + type: actionTypes.VERSION_CREATED, + result + }); + return result; + }); + }); + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationConstants.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationConstants.js index 4ce381d4de..e761232443 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationConstants.js @@ -16,13 +16,13 @@ import keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ - OPEN: null, - CLOSE: null, - VERSION_CREATED: null + OPEN: null, + CLOSE: null, + VERSION_CREATED: null }); export const VERSION_CREATION_FORM_NAME = 'VCREATIONFORM'; export const defaultState = { - creationMethod: 'major' -}; \ No newline at end of file + creationMethod: 'major' +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationReducer.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationReducer.js index 620cf4717f..a762e4d338 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationReducer.js @@ -13,32 +13,39 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes, VERSION_CREATION_FORM_NAME, defaultState} from './VersionsPageCreationConstants.js'; +import { + actionTypes, + VERSION_CREATION_FORM_NAME, + defaultState +} from './VersionsPageCreationConstants.js'; export default (state = {}, action) => { - switch (action.type) { - case actionTypes.OPEN: - return { - ...state, - formReady: null, - formName: VERSION_CREATION_FORM_NAME, - data: {...defaultState}, - genericFieldInfo: { - description: { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}] - }, - creationMethod: { - isValid: true, - errorText: '', - validations: [{type: 'required', data: true}] - } - } - }; - case actionTypes.CLOSE: - return {}; - default: - return state; - } + switch (action.type) { + case actionTypes.OPEN: + return { + ...state, + formReady: null, + formName: VERSION_CREATION_FORM_NAME, + data: { ...defaultState }, + genericFieldInfo: { + description: { + isValid: true, + errorText: '', + validations: [ + { type: 'required', data: true }, + { type: 'maxLength', data: 120 } + ] + }, + creationMethod: { + isValid: true, + errorText: '', + validations: [{ type: 'required', data: true }] + } + } + }; + case actionTypes.CLOSE: + return {}; + default: + return state; + } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationView.jsx b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationView.jsx index caa85fe107..ba92d26067 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/creation/VersionsPageCreationView.jsx @@ -20,125 +20,116 @@ import Input from 'nfvo-components/input/validation/Input.jsx'; import Form from 'nfvo-components/input/validation/Form.jsx'; const VersionPropType = PropTypes.shape({ - name: PropTypes.string, - description: PropTypes.string, - creationMethod: PropTypes.string + name: PropTypes.string, + description: PropTypes.string, + creationMethod: PropTypes.string }); class VersionsPageCreationView extends React.Component { - - static propTypes = { - data: VersionPropType, - availableMethods: PropTypes.array, - onDataChanged: PropTypes.func.isRequired, - onSubmit: PropTypes.func.isRequired, - onCancel: PropTypes.func.isRequired - }; - - render() { - let {data = {}, genericFieldInfo, baseVersion, onDataChanged, onCancel} = this.props; - let {additionalInfo: {OptionalCreationMethods}} = baseVersion; - let {description, creationMethod} = data; - - return ( -
    - { genericFieldInfo &&
    this.validationForm = validationForm} - hasButtons={true} - onSubmit={() => this.submit()} - submitButtonText={i18n('Create')} - onReset={() => onCancel()} - labledButtons={true} - isValid={this.props.isFormValid} - formReady={this.props.formReady} - onValidateForm={() => this.validate()}> - -
    - this.onSelectMethod(e)} - type='select' - overlayPos='bottom' - data-test-id='new-version-category' - isValid={genericFieldInfo.creationMethod.isValid} - errorText={genericFieldInfo.creationMethod.errorText} - isRequired> - - {OptionalCreationMethods.map(method => )} - -
    - -
    - onDataChanged({description})} - isRequired /> -
    - -
    } -
    - ); - } - - onSelectMethod(e) { - const selectedIndex = e.target.selectedIndex; - const creationMethod = e.target.options[selectedIndex].value; - this.props.onDataChanged({creationMethod}); - } - - submit() { - let {baseVersion, data: {description, creationMethod}} = this.props; - this.props.onSubmit({baseVersion, payload: {description, creationMethod}}); - } - - validate() { - this.props.onValidateForm(); - } - + static propTypes = { + data: VersionPropType, + availableMethods: PropTypes.array, + onDataChanged: PropTypes.func.isRequired, + onSubmit: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired + }; + + render() { + let { + data = {}, + genericFieldInfo, + baseVersion, + onDataChanged, + onCancel + } = this.props; + let { additionalInfo: { OptionalCreationMethods } } = baseVersion; + let { description, creationMethod } = data; + + return ( +
    + {genericFieldInfo && ( +
    + (this.validationForm = validationForm) + } + hasButtons={true} + onSubmit={() => this.submit()} + submitButtonText={i18n('Create')} + onReset={() => onCancel()} + labledButtons={true} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => this.validate()}> +
    + this.onSelectMethod(e)} + type="select" + overlayPos="bottom" + data-test-id="new-version-category" + isValid={ + genericFieldInfo.creationMethod.isValid + } + errorText={ + genericFieldInfo.creationMethod.errorText + } + isRequired> + + {OptionalCreationMethods.map(method => ( + + ))} + +
    + +
    + + onDataChanged({ description }) + } + isRequired + /> +
    +
    + )} +
    + ); + } + + onSelectMethod(e) { + const selectedIndex = e.target.selectedIndex; + const creationMethod = e.target.options[selectedIndex].value; + this.props.onDataChanged({ creationMethod }); + } + + submit() { + let { baseVersion, data: { description, creationMethod } } = this.props; + this.props.onSubmit({ + baseVersion, + payload: { description, creationMethod } + }); + } + + validate() { + this.props.onValidateForm(); + } } export default VersionsPageCreationView; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*
    https://github.com/cpettitt/dagre-d3/issues/202 --> http://jointjs.com/blog/get-transform-to-element-polyfill.html -SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function(toElement) { - return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM()); -}; - -ReactDOM.render(, document.getElementById('sdc-app')); +SVGElement.prototype.getTransformToElement = + SVGElement.prototype.getTransformToElement || + function(toElement) { + return toElement + .getScreenCTM() + .inverse() + .multiply(this.getScreenCTM()); + }; +ReactDOM.render( + + + , + document.getElementById('sdc-app') +); diff --git a/openecomp-ui/webpack.common.js b/openecomp-ui/webpack.common.js index d1038b6655..5506670e54 100644 --- a/openecomp-ui/webpack.common.js +++ b/openecomp-ui/webpack.common.js @@ -4,41 +4,77 @@ let path = require('path'); let localDevConfig = {}; try { - localDevConfig = require('./devConfig'); + localDevConfig = require('./devConfig'); } catch (e) { - console.log('Could not find local dev config.'); + console.log('Could not find local dev config.'); } -let devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig); +let devConfig = Object.assign( + {}, + require('./devConfig.defaults'), + localDevConfig +); module.exports = { - entry: devConfig.bundles, - resolve: { - modules: [path.resolve('.'), path.join(__dirname, 'node_modules')], - alias: { - i18nJson: 'nfvo-utils/i18n/en.json', // only for default build, not through gulp - 'nfvo-utils': 'src/nfvo-utils', - 'nfvo-components': 'src/nfvo-components', - 'sdc-app': 'src/sdc-app', - 'react-select/dist/' : 'node_modules/react-select/dist/', - 'jquery' : 'node_modules/restful-js/node_modules/jquery' - } - }, - module: { - rules: [ - {test: /\.(js|jsx)$/, loader: 'source-map-loader', exclude: [/node_modules/, path.resolve(__dirname, '../dox-sequence-diagram/')], enforce: 'pre'}, - {test: /\.(js|jsx)$/, use: [ - {loader : 'babel-loader'}, - {loader : 'eslint-loader'}], exclude: [/node_modules/, path.resolve(__dirname, '../dox-sequence-diagram/')]}, - {test: /\.(css|scss)$/, use: [ - {loader: 'style-loader'}, - {loader: 'css-loader?sourceMap'}, - {loader: 'sass-loader?sourceMap', options: { output: { path: path.join(__dirname, 'dist') } }}]}, + entry: devConfig.bundles, + resolve: { + modules: [path.resolve('.'), path.join(__dirname, 'node_modules')], + alias: { + i18nJson: 'nfvo-utils/i18n/en.json', // only for default build, not through gulp + 'nfvo-utils': 'src/nfvo-utils', + 'nfvo-components': 'src/nfvo-components', + 'sdc-app': 'src/sdc-app', + 'react-select/dist/': 'node_modules/react-select/dist/', + jquery: 'node_modules/restful-js/node_modules/jquery' + } + }, + module: { + rules: [ + { + test: /\.(js|jsx)$/, + loader: 'source-map-loader', + exclude: [ + /node_modules/, + path.resolve(__dirname, '../dox-sequence-diagram/') + ], + enforce: 'pre' + }, + { + test: /\.(js|jsx)$/, + use: [ + { loader: 'babel-loader' }, + { loader: 'eslint-loader', options: { fix: false } } + ], + exclude: [ + /node_modules/, + path.resolve(__dirname, '../dox-sequence-diagram/') + ] + }, + { + test: /\.(css|scss)$/, + use: [ + { loader: 'style-loader' }, + { loader: 'css-loader?sourceMap' }, + { + loader: 'sass-loader?sourceMap', + options: { + output: { path: path.join(__dirname, 'dist') } + } + } + ] + }, - // required for font icons - {test: /\.(woff|woff2)(\?.*)?$/, loader: 'url-loader?limit=16384&mimetype=application/font-woff'}, - {test: /\.(ttf|eot|otf)(\?.*)?$/, loader: 'file-loader'}, - {test: /\.(png|jpg|svg)(\?.*)?$/, loader: 'url-loader?limit=16384', exclude: path.join(__dirname, 'resources/images/svg') }, - {test: /\.html$/, use: [ {loader: 'html-loader'}]} - ] - }, - plugins: [] + // required for font icons + { + test: /\.(woff|woff2)(\?.*)?$/, + loader: 'url-loader?limit=16384&mimetype=application/font-woff' + }, + { test: /\.(ttf|eot|otf)(\?.*)?$/, loader: 'file-loader' }, + { + test: /\.(png|jpg|svg)(\?.*)?$/, + loader: 'url-loader?limit=16384', + exclude: path.join(__dirname, 'resources/images/svg') + }, + { test: /\.html$/, use: [{ loader: 'html-loader' }] } + ] + }, + plugins: [] }; diff --git a/openecomp-ui/webpack.production.js b/openecomp-ui/webpack.production.js index 2dea2170ae..22da77e6ed 100644 --- a/openecomp-ui/webpack.production.js +++ b/openecomp-ui/webpack.production.js @@ -10,48 +10,57 @@ let webpackCommon = require('./webpack.common'); // copying the common config let webpackProdConfig = cloneDeep(webpackCommon); // setting production settings -assign( webpackProdConfig, { - devtool: undefined, - cache: true, - output: { - path: path.join(__dirname, 'dist'), - publicPath: '/onboarding/', - filename: '[name].js' - }, - resolveLoader: { - modules: [path.join(__dirname, 'node_modules'), path.resolve('.')], - alias: { - 'config-json-loader': 'tools/webpack/config-json-loader/index.js' - } - }, - plugins: [ - new webpack.DefinePlugin({ - 'process.env': { - // This has effect on the react lib size - 'NODE_ENV': JSON.stringify('production') - }, - DEBUG: false, - DEV: false - }), - new webpack.optimize.UglifyJsPlugin(), - new webpack.LoaderOptionsPlugin({ - options: { - eslint: { - configFile: './.eslintrc', - emitError: true, - emitWarning: true, - failOnError: true - } - } - }) - ] +assign(webpackProdConfig, { + devtool: undefined, + cache: true, + output: { + path: path.join(__dirname, 'dist'), + publicPath: '/onboarding/', + filename: '[name].js' + }, + resolveLoader: { + modules: [path.join(__dirname, 'node_modules'), path.resolve('.')], + alias: { + 'config-json-loader': 'tools/webpack/config-json-loader/index.js' + } + }, + plugins: [ + new webpack.DefinePlugin({ + 'process.env': { + // This has effect on the react lib size + NODE_ENV: JSON.stringify('production') + }, + DEBUG: false, + DEV: false + }), + new webpack.optimize.UglifyJsPlugin(), + new webpack.LoaderOptionsPlugin({ + options: { + eslint: { + configFile: './.eslintrc', + emitError: true, + emitWarning: true, + failOnError: true + } + } + }) + ] }); -webpackProdConfig.module.rules = webpackProdConfig.module.rules.filter(rule => ((rule.enforce !== 'pre') || (rule.enforce === 'pre' && rule.loader !== 'source-map-loader'))); +webpackProdConfig.module.rules = webpackProdConfig.module.rules.filter( + rule => + rule.enforce !== 'pre' || + (rule.enforce === 'pre' && rule.loader !== 'source-map-loader') +); webpackProdConfig.module.rules.forEach(loader => { - if (loader.use && loader.use[0].loader === 'style-loader') { - loader.use = loader.use.map(loaderObj => loaderObj.loader.replace('?sourceMap', '')); - } + if (loader.use && loader.use[0].loader === 'style-loader') { + loader.use = loader.use.map(loaderObj => + loaderObj.loader.replace('?sourceMap', '') + ); + } +}); +webpackProdConfig.module.rules.push({ + test: /config.json$/, + use: [{ loader: 'config-json-loader' }] }); -webpackProdConfig.module.rules.push({test: /config.json$/, use: [{loader:'config-json-loader'}]}); module.exports = webpackProdConfig; diff --git a/openecomp-ui/yarn.lock b/openecomp-ui/yarn.lock index fe991f31be..e7b68d1f36 100644 --- a/openecomp-ui/yarn.lock +++ b/openecomp-ui/yarn.lock @@ -2,26 +2,107 @@ # yarn lockfile v1 -"@angular/common@2.3.1": - version "2.3.1" - resolved "https://registry.yarnpkg.com/@angular/common/-/common-2.3.1.tgz#146c2ed44e02b0f291dd9d4b2e5e2a693057e9bc" +"@angular/common@~2.4.8": + version "2.4.10" + resolved "https://registry.yarnpkg.com/@angular/common/-/common-2.4.10.tgz#a3a682d2228fa30ec23dd0eb57c8e887fba26997" -"@angular/core@2.3.1": - version "2.3.1" - resolved "https://registry.yarnpkg.com/@angular/core/-/core-2.3.1.tgz#be6e91fdfdd7498506604263e051797cf67a47be" +"@angular/core@~2.4.8": + version "2.4.10" + resolved "https://registry.yarnpkg.com/@angular/core/-/core-2.4.10.tgz#0b8320a65065965d998645b1f5cd3cf769b441ea" -"@angular/platform-browser-dynamic@2.3.1": - version "2.3.1" - resolved "https://registry.yarnpkg.com/@angular/platform-browser-dynamic/-/platform-browser-dynamic-2.3.1.tgz#d01f3c0c25c628be83c308e83d53128222f558fa" +"@angular/forms@~2.4.8": + version "2.4.10" + resolved "https://registry.yarnpkg.com/@angular/forms/-/forms-2.4.10.tgz#062133aaade1f3b3c962f1593208c541b622fd06" -"@angular/platform-browser@2.3.1": - version "2.3.1" - resolved "https://registry.yarnpkg.com/@angular/platform-browser/-/platform-browser-2.3.1.tgz#114309150876188e0df8841b20ca2359fd5e7cad" +"@angular/http@^2.4.8": + version "2.4.10" + resolved "https://registry.yarnpkg.com/@angular/http/-/http-2.4.10.tgz#ff6beade5b39c989ebf2393c49b34eebd43e9555" + +"@angular/platform-browser-dynamic@~2.4.8": + version "2.4.10" + resolved "https://registry.yarnpkg.com/@angular/platform-browser-dynamic/-/platform-browser-dynamic-2.4.10.tgz#8df25dec2b06adc690cc9bc26448deccaebcd8ec" + +"@angular/platform-browser@~2.4.8": + version "2.4.10" + resolved "https://registry.yarnpkg.com/@angular/platform-browser/-/platform-browser-2.4.10.tgz#cbf25608148fb4ffef96cc5005ba5d7b3e093906" "@angular/router@~3.2.1": version "3.2.4" resolved "https://registry.yarnpkg.com/@angular/router/-/router-3.2.4.tgz#dfec71ad072ec031364ba5d08bd6fe03fd5beadc" +"@angular/upgrade@^2.4.8": + version "2.4.10" + resolved "https://registry.yarnpkg.com/@angular/upgrade/-/upgrade-2.4.10.tgz#b69a3ee324d4450eb1696ddc9bded1a6ec06ca52" + +"@babel/code-frame@7.0.0-beta.40", "@babel/code-frame@^7.0.0-beta.40": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.40.tgz#37e2b0cf7c56026b4b21d3927cadf81adec32ac6" + dependencies: + "@babel/highlight" "7.0.0-beta.40" + +"@babel/generator@7.0.0-beta.40": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.0.0-beta.40.tgz#ab61f9556f4f71dbd1138949c795bb9a21e302ea" + dependencies: + "@babel/types" "7.0.0-beta.40" + jsesc "^2.5.1" + lodash "^4.2.0" + source-map "^0.5.0" + trim-right "^1.0.1" + +"@babel/helper-function-name@7.0.0-beta.40": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.40.tgz#9d033341ab16517f40d43a73f2d81fc431ccd7b6" + dependencies: + "@babel/helper-get-function-arity" "7.0.0-beta.40" + "@babel/template" "7.0.0-beta.40" + "@babel/types" "7.0.0-beta.40" + +"@babel/helper-get-function-arity@7.0.0-beta.40": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.40.tgz#ac0419cf067b0ec16453e1274f03878195791c6e" + dependencies: + "@babel/types" "7.0.0-beta.40" + +"@babel/highlight@7.0.0-beta.40": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.40.tgz#b43d67d76bf46e1d10d227f68cddcd263786b255" + dependencies: + chalk "^2.0.0" + esutils "^2.0.2" + js-tokens "^3.0.0" + +"@babel/template@7.0.0-beta.40": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.40.tgz#034988c6424eb5c3268fe6a608626de1f4410fc8" + dependencies: + "@babel/code-frame" "7.0.0-beta.40" + "@babel/types" "7.0.0-beta.40" + babylon "7.0.0-beta.40" + lodash "^4.2.0" + +"@babel/traverse@^7.0.0-beta.40": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.40.tgz#d140e449b2e093ef9fe1a2eecc28421ffb4e521e" + dependencies: + "@babel/code-frame" "7.0.0-beta.40" + "@babel/generator" "7.0.0-beta.40" + "@babel/helper-function-name" "7.0.0-beta.40" + "@babel/types" "7.0.0-beta.40" + babylon "7.0.0-beta.40" + debug "^3.0.1" + globals "^11.1.0" + invariant "^2.2.0" + lodash "^4.2.0" + +"@babel/types@7.0.0-beta.40", "@babel/types@^7.0.0-beta.40": + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.40.tgz#25c3d7aae14126abe05fcb098c65a66b6d6b8c14" + dependencies: + esutils "^2.0.2" + lodash "^4.2.0" + to-fast-properties "^2.0.0" + "@kadira/react-split-pane@^1.4.0": version "1.4.7" resolved "https://registry.yarnpkg.com/@kadira/react-split-pane/-/react-split-pane-1.4.7.tgz#6d753d4a9fe62fe82056e323a6bcef7f026972b5" @@ -365,6 +446,10 @@ acorn@^5.0.0, acorn@^5.2.1: version "5.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822" +acorn@^5.4.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.5.0.tgz#1abb587fbf051f94e3de20e6b26ef910b1828298" + airbnb-js-shims@^1.0.1, airbnb-js-shims@^1.4.0: version "1.4.1" resolved "https://registry.yarnpkg.com/airbnb-js-shims/-/airbnb-js-shims-1.4.1.tgz#cc3e8eb8d35877f9d0fdc6583e26b0ee75b98ad0" @@ -382,7 +467,7 @@ airbnb-js-shims@^1.0.1, airbnb-js-shims@^1.4.0: string.prototype.padend "^3.0.0" string.prototype.padstart "^3.0.0" -ajv-keywords@^1.0.0, ajv-keywords@^1.1.1: +ajv-keywords@^1.1.1: version "1.5.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-1.5.1.tgz#314dd0a4b3368fad3dfcdc54ede6171b886daf3c" @@ -390,6 +475,10 @@ ajv-keywords@^2.0.0, ajv-keywords@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" +ajv-keywords@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.1.0.tgz#ac2b27939c543e95d2c06e7f7f5c27be4aa543be" + ajv@^4.7.0, ajv@^4.9.1: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" @@ -397,7 +486,7 @@ ajv@^4.7.0, ajv@^4.9.1: co "^4.6.0" json-stable-stringify "^1.0.1" -ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5: +ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5, ajv@^5.3.0: version "5.5.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" dependencies: @@ -406,6 +495,14 @@ ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5: fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.3.0" +ajv@^6.0.1: + version "6.2.0" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.2.0.tgz#afac295bbaa0152449e522742e4547c1ae9328d2" + dependencies: + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -434,10 +531,6 @@ ansi-cyan@^0.1.1: dependencies: ansi-wrap "0.1.0" -ansi-escapes@^1.1.0: - version "1.4.0" - resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" - ansi-escapes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.0.0.tgz#ec3e8b4e9f8064fc02c3ac9b65f1c275bda8ef92" @@ -804,14 +897,16 @@ babel-core@^6.0.0, babel-core@^6.11.4, babel-core@^6.24.0, babel-core@^6.26.0: slash "^1.0.0" source-map "^0.5.6" -babel-eslint@^7.2.1: - version "7.2.3" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-7.2.3.tgz#b2fe2d80126470f5c19442dc757253a897710827" +babel-eslint@^8.2.1: + version "8.2.2" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.2.2.tgz#1102273354c6f0b29b4ea28a65f97d122296b68b" dependencies: - babel-code-frame "^6.22.0" - babel-traverse "^6.23.1" - babel-types "^6.23.0" - babylon "^6.17.0" + "@babel/code-frame" "^7.0.0-beta.40" + "@babel/traverse" "^7.0.0-beta.40" + "@babel/types" "^7.0.0-beta.40" + babylon "^7.0.0-beta.40" + eslint-scope "~3.7.1" + eslint-visitor-keys "^1.0.0" babel-generator@^6.18.0, babel-generator@^6.26.0: version "6.26.0" @@ -1877,12 +1972,6 @@ babel-register@^6.26.0: mkdirp "^0.5.1" source-map-support "^0.4.15" -babel-runtime@5.8.19: - version "5.8.19" - resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-5.8.19.tgz#05ee3aaf67e6d4a39f1bc0f07598b26b9ceb4d3e" - dependencies: - core-js "^0.9.0" - babel-runtime@6.11.6: version "6.11.6" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.11.6.tgz#6db707fef2d49c49bfa3cb64efdb436b518b8222" @@ -1907,7 +1996,7 @@ babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0, babel-te babylon "^6.18.0" lodash "^4.17.4" -babel-traverse@^6.16.0, babel-traverse@^6.18.0, babel-traverse@^6.23.1, babel-traverse@^6.24.1, babel-traverse@^6.26.0, babel-traverse@^6.4.5: +babel-traverse@^6.16.0, babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0, babel-traverse@^6.4.5: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" dependencies: @@ -1921,7 +2010,7 @@ babel-traverse@^6.16.0, babel-traverse@^6.18.0, babel-traverse@^6.23.1, babel-tr invariant "^2.2.2" lodash "^4.17.4" -babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24.1, babel-types@^6.26.0: +babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" dependencies: @@ -1930,7 +2019,11 @@ babel-types@^6.16.0, babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.23 lodash "^4.17.4" to-fast-properties "^1.0.3" -babylon@^6.17.0, babylon@^6.18.0, babylon@^6.4.5: +babylon@7.0.0-beta.40, babylon@^7.0.0-beta.40: + version "7.0.0-beta.40" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.40.tgz#91fc8cd56d5eb98b28e6fde41045f2957779940a" + +babylon@^6.18.0, babylon@^6.4.5: version "6.18.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" @@ -2207,7 +2300,7 @@ buffer@^4.3.0, buffer@^4.9.0: ieee754 "^1.1.4" isarray "^1.0.0" -builtin-modules@^1.0.0: +builtin-modules@^1.0.0, builtin-modules@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f" @@ -2359,6 +2452,14 @@ chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" +chalk@^2.0.0, chalk@^2.1.0: + version "2.3.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.1.tgz#523fe2678aec7b04e8041909292fe8b17059b796" + dependencies: + ansi-styles "^3.2.0" + escape-string-regexp "^1.0.5" + supports-color "^5.2.0" + chalk@^2.0.1, chalk@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" @@ -2367,6 +2468,10 @@ chalk@^2.0.1, chalk@^2.3.0: escape-string-regexp "^1.0.5" supports-color "^4.0.0" +chardet@^0.4.0: + version "0.4.2" + resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" + charenc@~0.0.1: version "0.0.2" resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" @@ -2478,11 +2583,11 @@ clean-css@4.1.x: dependencies: source-map "0.5.x" -cli-cursor@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" +cli-cursor@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" dependencies: - restore-cursor "^1.0.1" + restore-cursor "^2.0.0" cli-width@^2.0.0: version "2.2.0" @@ -2681,7 +2786,7 @@ concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" -concat-stream@^1.4.6, concat-stream@^1.5.0: +concat-stream@^1.5.0, concat-stream@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7" dependencies: @@ -2732,6 +2837,10 @@ constants-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" +contains-path@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" + content-disposition@0.5.2: version "0.5.2" resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.2.tgz#0cf68bb9ddf5f2be7961c3a85178cb85dba78cb4" @@ -2771,10 +2880,6 @@ copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" -core-js@^0.9.0: - version "0.9.18" - resolved "https://registry.yarnpkg.com/core-js/-/core-js-0.9.18.tgz#13f458e430232b0f4ec1f480da7c2f5288e9d095" - core-js@^1.0.0: version "1.2.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" @@ -2841,7 +2946,7 @@ cross-spawn@^3.0.0: lru-cache "^4.0.1" which "^1.2.9" -cross-spawn@^5.0.1: +cross-spawn@^5.0.1, cross-spawn@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" dependencies: @@ -3315,13 +3420,13 @@ dateformat@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.2.0.tgz#4065e2013cf9fb916ddfd82efb506ad4c6769062" -debug@2.6.9, debug@^2.1.1, debug@^2.2.0, debug@^2.3.3, debug@^2.6.6, debug@^2.6.8: +debug@2.6.9, debug@^2.2.0, debug@^2.3.3, debug@^2.6.6, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: ms "2.0.0" -debug@^3.1.0: +debug@^3.0.1, debug@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: @@ -3511,14 +3616,14 @@ dns-txt@^2.0.2: dependencies: buffer-indexof "^1.0.0" -doctrine@^1.2.2: +doctrine@1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-1.5.0.tgz#379dce730f6166f76cefa4e6707a159b02c5a6fa" dependencies: esutils "^2.0.2" isarray "^1.0.0" -doctrine@^2.0.0: +doctrine@^2.0.0, doctrine@^2.0.2, doctrine@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" dependencies: @@ -3879,9 +3984,22 @@ escope@^3.6.0: esrecurse "^4.1.0" estraverse "^4.1.1" -eslint-loader@^1.3.0: - version "1.9.0" - resolved "https://registry.yarnpkg.com/eslint-loader/-/eslint-loader-1.9.0.tgz#7e1be9feddca328d3dcfaef1ad49d5beffe83a13" +eslint-config-prettier@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-2.9.0.tgz#5ecd65174d486c22dff389fe036febf502d468a3" + dependencies: + get-stdin "^5.0.1" + +eslint-import-resolver-node@^0.3.1: + version "0.3.2" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a" + dependencies: + debug "^2.6.9" + resolve "^1.5.0" + +eslint-loader@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/eslint-loader/-/eslint-loader-2.0.0.tgz#d136619b5c684e36531ffc28c60a56e404608f5d" dependencies: loader-fs-cache "^1.0.0" loader-utils "^1.0.2" @@ -3889,65 +4007,102 @@ eslint-loader@^1.3.0: object-hash "^1.1.4" rimraf "^2.6.1" -eslint-plugin-import@^0.8.1: - version "0.8.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-0.8.1.tgz#c1e076097d913cbdfd58f1d14f49205d8a33a735" +eslint-module-utils@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.1.1.tgz#abaec824177613b8a95b299639e1b6facf473449" dependencies: - babel-runtime "5.8.19" - espree "^2.0.1" - resolve "^1.1.6" + debug "^2.6.8" + pkg-dir "^1.0.0" -eslint-plugin-react@^3.14.0: - version "3.16.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-3.16.1.tgz#262d96b77d7c4a42af809a73c0e527a58612293c" +eslint-plugin-import@^2.9.0: + version "2.9.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.9.0.tgz#26002efbfca5989b7288ac047508bd24f217b169" + dependencies: + builtin-modules "^1.1.1" + contains-path "^0.1.0" + debug "^2.6.8" + doctrine "1.5.0" + eslint-import-resolver-node "^0.3.1" + eslint-module-utils "^2.1.1" + has "^1.0.1" + lodash "^4.17.4" + minimatch "^3.0.3" + read-pkg-up "^2.0.0" -eslint@^2.13.1: - version "2.13.1" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-2.13.1.tgz#e4cc8fa0f009fb829aaae23855a29360be1f6c11" +eslint-plugin-prettier@^2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-2.6.0.tgz#33e4e228bdb06142d03c560ce04ec23f6c767dd7" dependencies: - chalk "^1.1.3" - concat-stream "^1.4.6" - debug "^2.1.1" - doctrine "^1.2.2" - es6-map "^0.1.3" - escope "^3.6.0" - espree "^3.1.6" - estraverse "^4.2.0" + fast-diff "^1.1.1" + jest-docblock "^21.0.0" + +eslint-plugin-react@^7.7.0: + version "7.7.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.7.0.tgz#f606c719dbd8a1a2b3d25c16299813878cca0160" + dependencies: + doctrine "^2.0.2" + has "^1.0.1" + jsx-ast-utils "^2.0.1" + prop-types "^15.6.0" + +eslint-scope@^3.7.1, eslint-scope@~3.7.1: + version "3.7.1" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8" + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + +eslint-visitor-keys@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" + +eslint@^4.18.1: + version "4.18.1" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.18.1.tgz#b9138440cb1e98b2f44a0d578c6ecf8eae6150b0" + dependencies: + ajv "^5.3.0" + babel-code-frame "^6.22.0" + chalk "^2.1.0" + concat-stream "^1.6.0" + cross-spawn "^5.1.0" + debug "^3.1.0" + doctrine "^2.1.0" + eslint-scope "^3.7.1" + eslint-visitor-keys "^1.0.0" + espree "^3.5.2" + esquery "^1.0.0" esutils "^2.0.2" - file-entry-cache "^1.1.1" - glob "^7.0.3" - globals "^9.2.0" - ignore "^3.1.2" + file-entry-cache "^2.0.0" + functional-red-black-tree "^1.0.1" + glob "^7.1.2" + globals "^11.0.1" + ignore "^3.3.3" imurmurhash "^0.1.4" - inquirer "^0.12.0" - is-my-json-valid "^2.10.0" + inquirer "^3.0.6" is-resolvable "^1.0.0" - js-yaml "^3.5.1" - json-stable-stringify "^1.0.0" + js-yaml "^3.9.1" + json-stable-stringify-without-jsonify "^1.0.1" levn "^0.3.0" - lodash "^4.0.0" - mkdirp "^0.5.0" - optionator "^0.8.1" - path-is-absolute "^1.0.0" - path-is-inside "^1.0.1" - pluralize "^1.2.1" - progress "^1.1.8" - require-uncached "^1.0.2" - shelljs "^0.6.0" - strip-json-comments "~1.0.1" - table "^3.7.8" + lodash "^4.17.4" + minimatch "^3.0.2" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + optionator "^0.8.2" + path-is-inside "^1.0.2" + pluralize "^7.0.0" + progress "^2.0.0" + require-uncached "^1.0.3" + semver "^5.3.0" + strip-ansi "^4.0.0" + strip-json-comments "~2.0.1" + table "^4.0.1" text-table "~0.2.0" - user-home "^2.0.0" - -espree@^2.0.1: - version "2.2.5" - resolved "https://registry.yarnpkg.com/espree/-/espree-2.2.5.tgz#df691b9310889402aeb29cc066708c56690b854b" -espree@^3.1.6: - version "3.5.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" +espree@^3.5.2: + version "3.5.3" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.3.tgz#931e0af64e7fbbed26b050a29daad1fc64799fa6" dependencies: - acorn "^5.2.1" + acorn "^5.4.0" acorn-jsx "^3.0.0" esprima-fb@^15001.1.0-dev-harmony-fb: @@ -3966,6 +4121,12 @@ esprima@^4.0.0, esprima@~4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804" +esquery@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.0.tgz#cfba8b57d7fba93f17298a8a006a04cda13d80fa" + dependencies: + estraverse "^4.0.0" + esrecurse@^4.1.0: version "4.2.0" resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.0.tgz#fa9568d98d3823f9a41d91e902dcab9ea6e5b163" @@ -3973,7 +4134,7 @@ esrecurse@^4.1.0: estraverse "^4.1.0" object-assign "^4.0.1" -estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -4039,10 +4200,6 @@ exenv@^1.2.0, exenv@^1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/exenv/-/exenv-1.2.2.tgz#2ae78e85d9894158670b03d47bec1f03bd91bb9d" -exit-hook@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/exit-hook/-/exit-hook-1.1.1.tgz#f05ca233b48c05d54fff07765df8507e95c02ff8" - exit@0.1.2, exit@0.1.x: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" @@ -4146,6 +4303,14 @@ extend@^3.0.0, extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" +external-editor@^2.0.4: + version "2.1.0" + resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48" + dependencies: + chardet "^0.4.0" + iconv-lite "^0.4.17" + tmp "^0.0.33" + extglob@^0.3.1: version "0.3.2" resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1" @@ -4189,6 +4354,10 @@ fast-deep-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz#96256a3bc975595eb36d82e9929d060d893439ff" +fast-diff@^1.1.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/fast-diff/-/fast-diff-1.1.2.tgz#4b62c42b8e03de3f848460b639079920695d0154" + fast-json-stable-stringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" @@ -4235,16 +4404,15 @@ fbjs@^0.8.12, fbjs@^0.8.16, fbjs@^0.8.9: setimmediate "^1.0.5" ua-parser-js "^0.7.9" -figures@^1.3.5: - version "1.7.0" - resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" +figures@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" dependencies: escape-string-regexp "^1.0.5" - object-assign "^4.1.0" -file-entry-cache@^1.1.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-1.3.1.tgz#44c61ea607ae4be9c1402f41f44270cbfe334ff8" +file-entry-cache@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361" dependencies: flat-cache "^1.2.1" object-assign "^4.0.1" @@ -4510,6 +4678,10 @@ function.prototype.name@^1.0.0, function.prototype.name@^1.1.0: function-bind "^1.1.1" is-callable "^1.1.3" +functional-red-black-tree@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" + fuse.js@^2.2.0: version "2.7.4" resolved "https://registry.yarnpkg.com/fuse.js/-/fuse.js-2.7.4.tgz#96e420fde7ef011ac49c258a621314fe576536f9" @@ -4565,6 +4737,10 @@ get-stdin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-4.0.1.tgz#b968c6b0a04384324902e8bf1a5df32579a450fe" +get-stdin@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-5.0.1.tgz#122e161591e21ff4c52530305693f20e6393a398" + get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" @@ -4717,7 +4893,11 @@ global@^4.3.0, global@^4.3.2: min-document "^2.19.0" process "~0.5.1" -globals@^9.18.0, globals@^9.2.0: +globals@^11.0.1, globals@^11.1.0: + version "11.3.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.3.0.tgz#e04fdb7b9796d8adac9c8f64c14837b2313378b0" + +globals@^9.18.0: version "9.18.0" resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" @@ -4967,6 +5147,10 @@ has-flag@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + has-gulplog@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/has-gulplog/-/has-gulplog-0.1.0.tgz#6414c82913697da51590397dafb12f22967811ce" @@ -5215,6 +5399,10 @@ http-errors@1.6.2, http-errors@~1.6.2: setprototypeof "1.0.3" statuses ">= 1.3.1 < 2" +http-loader@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/http-loader/-/http-loader-0.0.1.tgz#b04f8c2d8e872ae079572606eff0f4b8ef55d07c" + http-parser-js@>=0.4.0: version "0.4.9" resolved "https://registry.yarnpkg.com/http-parser-js/-/http-parser-js-0.4.9.tgz#ea1a04fb64adff0242e9974f297dd4c3cad271e1" @@ -5267,7 +5455,7 @@ i@0.3.x: version "0.3.6" resolved "https://registry.yarnpkg.com/i/-/i-0.3.6.tgz#d96c92732076f072711b6b10fd7d4f65ad8ee23d" -iconv-lite@0.4, iconv-lite@0.4.19, iconv-lite@^0.4.5, iconv-lite@~0.4.13: +iconv-lite@0.4, iconv-lite@0.4.19, iconv-lite@^0.4.17, iconv-lite@^0.4.5, iconv-lite@~0.4.13: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" @@ -5293,7 +5481,7 @@ ignore-loader@^0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/ignore-loader/-/ignore-loader-0.1.2.tgz#d81f240376d0ba4f0d778972c3ad25874117a463" -ignore@^3.1.2: +ignore@^3.3.3: version "3.3.7" resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021" @@ -5371,22 +5559,23 @@ inline-style-prefixer@^3.0.6: bowser "^1.7.3" css-in-js-utils "^2.0.0" -inquirer@^0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-0.12.0.tgz#1ef2bfd63504df0bc75785fff8c2c41df12f077e" +inquirer@^3.0.6: + version "3.3.0" + resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9" dependencies: - ansi-escapes "^1.1.0" - ansi-regex "^2.0.0" - chalk "^1.0.0" - cli-cursor "^1.0.1" + ansi-escapes "^3.0.0" + chalk "^2.0.0" + cli-cursor "^2.1.0" cli-width "^2.0.0" - figures "^1.3.5" + external-editor "^2.0.4" + figures "^2.0.0" lodash "^4.3.0" - readline2 "^1.0.1" - run-async "^0.1.0" - rx-lite "^3.1.2" - string-width "^1.0.1" - strip-ansi "^3.0.0" + mute-stream "0.0.7" + run-async "^2.2.0" + rx-lite "^4.0.8" + rx-lite-aggregates "^4.0.8" + string-width "^2.1.0" + strip-ansi "^4.0.0" through "^2.3.6" insert-css@^1.0.0: @@ -5437,6 +5626,12 @@ invariant@2.x.x, invariant@^2.0.0, invariant@^2.1.0, invariant@^2.2.1, invariant dependencies: loose-envify "^1.0.0" +invariant@^2.2.0: + version "2.2.3" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.3.tgz#1a827dfde7dcbd7c323f0ca826be8fa7c5e9d688" + dependencies: + loose-envify "^1.0.0" + invert-kv@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-1.0.0.tgz#104a8e4aaca6d3d8cd157a8ef8bfab2d7a3ffdb6" @@ -5608,7 +5803,7 @@ is-glob@^4.0.0: dependencies: is-extglob "^2.1.1" -is-my-json-valid@^2.10.0, is-my-json-valid@^2.12.4: +is-my-json-valid@^2.12.4: version "2.17.1" resolved "https://registry.yarnpkg.com/is-my-json-valid/-/is-my-json-valid-2.17.1.tgz#3da98914a70a22f0a8563ef1511a246c6fc55471" dependencies: @@ -5673,6 +5868,10 @@ is-primitive@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" +is-promise@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" + is-property@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" @@ -5905,7 +6104,7 @@ jest-diff@^21.2.1: jest-get-type "^21.2.0" pretty-format "^21.2.1" -jest-docblock@^21.2.0: +jest-docblock@^21.0.0, jest-docblock@^21.2.0: version "21.2.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" @@ -6073,7 +6272,7 @@ js-tokens@^3.0.0, js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" -js-yaml@^3.4.3, js-yaml@^3.5.1, js-yaml@^3.7.0: +js-yaml@^3.4.3, js-yaml@^3.7.0, js-yaml@^3.9.1: version "3.10.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" dependencies: @@ -6119,6 +6318,10 @@ jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" +jsesc@^2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.1.tgz#e421a2a8e20d6b0819df28908f782526b96dd1fe" + jsesc@~0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" @@ -6148,7 +6351,11 @@ json-schema@0.2.3: version "0.2.3" resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13" -json-stable-stringify@^1.0.0, json-stable-stringify@^1.0.1: +json-stable-stringify-without-jsonify@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" + +json-stable-stringify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af" dependencies: @@ -6193,6 +6400,12 @@ jstransform@11: object-assign "^2.0.0" source-map "^0.4.2" +jsx-ast-utils@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-2.0.1.tgz#e801b1b39985e20fffc87b40e3748080e2dcac7f" + dependencies: + array-includes "^3.0.3" + jsx-loader@^0.13.2: version "0.13.2" resolved "https://registry.yarnpkg.com/jsx-loader/-/jsx-loader-0.13.2.tgz#9767f643975c78f5e5abeba9bc57885297e732d4" @@ -7019,11 +7232,7 @@ multipipe@^0.1.0, multipipe@^0.1.2: dependencies: duplexer2 "0.0.2" -mute-stream@0.0.5: - version "0.0.5" - resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.5.tgz#8fbfabb0a98a253d3184331f9e8deb7372fac6c0" - -mute-stream@~0.0.4: +mute-stream@0.0.7, mute-stream@~0.0.4: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" @@ -7432,9 +7641,11 @@ once@~1.3.0: dependencies: wrappy "1" -onetime@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" +onetime@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4" + dependencies: + mimic-fn "^1.0.0" opn@^5.1.0: version "5.2.0" @@ -7449,7 +7660,7 @@ optimist@^0.6.1, optimist@~0.6.0: minimist "~0.0.1" wordwrap "~0.0.2" -optionator@^0.8.1: +optionator@^0.8.1, optionator@^0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" dependencies: @@ -7504,7 +7715,7 @@ os-locale@^2.0.0: lcid "^1.0.0" mem "^1.1.0" -os-tmpdir@^1.0.0, os-tmpdir@^1.0.1: +os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" @@ -7636,7 +7847,7 @@ path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" -path-is-inside@^1.0.1: +path-is-inside@^1.0.1, path-is-inside@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" @@ -7755,9 +7966,9 @@ plugin-error@^1.0.0: arr-union "^3.1.0" extend-shallow "^3.0.2" -pluralize@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-1.2.1.tgz#d1a21483fd22bb41e58a12fa3421823140897c45" +pluralize@^7.0.0: + version "7.0.0" + resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777" podda@^1.2.1, podda@^1.2.2: version "1.2.2" @@ -8089,6 +8300,10 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +prettier@^1.10.2: + version "1.10.2" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.10.2.tgz#1af8356d1842276a99a5b5529c82dd9e9ad3cc93" + pretty-error@^2.0.2: version "2.1.1" resolved "https://registry.yarnpkg.com/pretty-error/-/pretty-error-2.1.1.tgz#5f4f87c8f91e5ae3f3ba87ab4cf5e03b1a17f1a3" @@ -8123,9 +8338,9 @@ process@~0.5.1: version "0.5.2" resolved "https://registry.yarnpkg.com/process/-/process-0.5.2.tgz#1638d8a8e34c2f440a91db95ab9aeb677fc185cf" -progress@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be" +progress@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" promise-inflight@^1.0.1: version "1.0.1" @@ -8417,6 +8632,15 @@ react-dom-factories@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/react-dom-factories/-/react-dom-factories-1.0.2.tgz#eb7705c4db36fb501b3aa38ff759616aa0ff96e0" +react-dom@15.6.2, react-dom@^15.6.2: + version "15.6.2" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.2.tgz#41cfadf693b757faf2708443a1d1fd5a02bef730" + dependencies: + fbjs "^0.8.9" + loose-envify "^1.1.0" + object-assign "^4.1.0" + prop-types "^15.5.10" + react-dom@16.x.x: version "16.2.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.2.0.tgz#69003178601c0ca19b709b33a83369fe6124c044" @@ -8426,15 +8650,6 @@ react-dom@16.x.x: object-assign "^4.1.1" prop-types "^15.6.0" -react-dom@^15.5.4, react-dom@^15.6.2: - version "15.6.2" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.2.tgz#41cfadf693b757faf2708443a1d1fd5a02bef730" - dependencies: - fbjs "^0.8.9" - loose-envify "^1.1.0" - object-assign "^4.1.0" - prop-types "^15.5.10" - react-dropzone@4.2.3: version "4.2.3" resolved "https://registry.yarnpkg.com/react-dropzone/-/react-dropzone-4.2.3.tgz#f7bc92aa5fe4253fdb1fd3792114d2d29b47119a" @@ -8681,16 +8896,7 @@ react-truncate@^2.0.5: version "2.3.0" resolved "https://registry.yarnpkg.com/react-truncate/-/react-truncate-2.3.0.tgz#d469b355aff1f83ae9e0f2fed0d47dfd061e5d2e" -react@16.x.x: - version "16.2.0" - resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba" - dependencies: - fbjs "^0.8.16" - loose-envify "^1.1.0" - object-assign "^4.1.1" - prop-types "^15.6.0" - -react@^15.4.1, react@^15.5.4, react@^15.6.2: +react@15.6.2, react@^15.4.1, react@^15.6.2: version "15.6.2" resolved "https://registry.yarnpkg.com/react/-/react-15.6.2.tgz#dba0434ab439cfe82f108f0f511663908179aa72" dependencies: @@ -8700,6 +8906,15 @@ react@^15.4.1, react@^15.5.4, react@^15.6.2: object-assign "^4.1.0" prop-types "^15.5.10" +react@16.x.x: + version "16.2.0" + resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba" + dependencies: + fbjs "^0.8.16" + loose-envify "^1.1.0" + object-assign "^4.1.1" + prop-types "^15.6.0" + reactcss@^1.2.0: version "1.2.3" resolved "https://registry.yarnpkg.com/reactcss/-/reactcss-1.2.3.tgz#c00013875e557b1cf0dfd9a368a1c3dab3b548dd" @@ -8790,14 +9005,6 @@ readdirp@^2.0.0: readable-stream "^2.0.2" set-immediate-shim "^1.0.1" -readline2@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/readline2/-/readline2-1.0.1.tgz#41059608ffc154757b715d9989d199ffbf372e35" - dependencies: - code-point-at "^1.0.0" - is-fullwidth-code-point "^1.0.0" - mute-stream "0.0.5" - recast@^0.11.17, recast@~0.11.12: version "0.11.23" resolved "https://registry.yarnpkg.com/recast/-/recast-0.11.23.tgz#451fd3004ab1e4df9b4e4b66376b2a21912462d3" @@ -9063,7 +9270,7 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" -require-uncached@^1.0.2: +require-uncached@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3" dependencies: @@ -9103,18 +9310,18 @@ resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" -resolve@^1.1.6, resolve@^1.1.7: +resolve@^1.1.6, resolve@^1.1.7, resolve@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" dependencies: path-parse "^1.0.5" -restore-cursor@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541" +restore-cursor@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf" dependencies: - exit-hook "^1.0.0" - onetime "^1.0.0" + onetime "^2.0.0" + signal-exit "^3.0.2" revalidator@0.1.x: version "0.1.8" @@ -9147,11 +9354,11 @@ rosie@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/rosie/-/rosie-1.6.0.tgz#bc0ef64cd401d00794450d5792c0276e226b6ab0" -run-async@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/run-async/-/run-async-0.1.0.tgz#c8ad4a5e110661e402a7d21b530e009f25f8e389" +run-async@^2.2.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0" dependencies: - once "^1.3.0" + is-promise "^2.1.0" run-queue@^1.0.0, run-queue@^1.0.3: version "1.0.3" @@ -9171,17 +9378,23 @@ rw@1: version "1.3.3" resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4" -rx-lite@^3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" +rx-lite-aggregates@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be" + dependencies: + rx-lite "*" + +rx-lite@*, rx-lite@^4.0.8: + version "4.0.8" + resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444" rx@4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" -rxjs@5.0.0-beta.12: - version "5.0.0-beta.12" - resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.0.0-beta.12.tgz#cdfde2d8c4639d20ae7794bff8fddf32da7ad337" +rxjs@5.4.2: + version "5.4.2" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.2.tgz#2a3236fcbf03df57bae06fd6972fd99e5c08fcf7" dependencies: symbol-observable "^1.0.1" @@ -9246,22 +9459,27 @@ scss-tokenizer@^0.2.3: js-base64 "^2.1.8" source-map "^0.4.2" -sdc-ui@1.6.9: - version "1.6.9" - resolved "https://registry.yarnpkg.com/sdc-ui/-/sdc-ui-1.6.9.tgz#cfb85152b1ff4890e869b0903527462d562a8e68" +sdc-ui@1.6.24: + version "1.6.24" + resolved "https://registry.yarnpkg.com/sdc-ui/-/sdc-ui-1.6.24.tgz#059b0fe6fdc36c962b65853a8012885aa38e78a7" dependencies: - "@angular/common" "2.3.1" - "@angular/core" "2.3.1" - "@angular/platform-browser" "2.3.1" - "@angular/platform-browser-dynamic" "2.3.1" + "@angular/common" "~2.4.8" + "@angular/core" "~2.4.8" + "@angular/forms" "~2.4.8" + "@angular/http" "^2.4.8" + "@angular/platform-browser" "~2.4.8" + "@angular/platform-browser-dynamic" "~2.4.8" "@angular/router" "~3.2.1" + "@angular/upgrade" "^2.4.8" "@storybook/react" "^3.1.5" - react "^15.5.4" - react-dom "^15.5.4" + http-loader "0.0.1" + prop-types "^15.6.0" + react "15.6.2" + react-dom "15.6.2" reflect-metadata "^0.1.3" - rxjs "5.0.0-beta.12" + rxjs "5.4.2" svg-react-loader "^0.4.4" - zone.js "~0.6.26" + zone.js "^0.8.18" select-hose@^2.0.0: version "2.0.0" @@ -9426,10 +9644,6 @@ shelljs@0.3.x: version "0.3.0" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.3.0.tgz#3596e6307a781544f591f37da618360f31db57b1" -shelljs@^0.6.0: - version "0.6.1" - resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.6.1.tgz#ec6211bed1920442088fe0f70b2837232ed2c8a8" - shelljs@^0.7.4, shelljs@^0.7.8: version "0.7.8" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.8.tgz#decbcf874b0d1e5fb72e14b164a9683048e9acb3" @@ -9454,9 +9668,11 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" -slice-ansi@0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-0.0.4.tgz#edbf8903f66f7ce2f8eafd6ceed65e264c831b35" +slice-ansi@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d" + dependencies: + is-fullwidth-code-point "^2.0.0" slide@^1.1.5: version "1.1.6" @@ -9582,7 +9798,7 @@ source-map@0.5.6: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" -source-map@0.5.x, source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1, source-map@~0.5.6: +source-map@0.5.x, source-map@^0.5.0, source-map@^0.5.1, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1, source-map@~0.5.6: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -9768,7 +9984,7 @@ string-width@^1.0.1, string-width@^1.0.2: is-fullwidth-code-point "^1.0.0" strip-ansi "^3.0.0" -string-width@^2.0.0: +string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e" dependencies: @@ -9850,7 +10066,7 @@ strip-indent@^1.0.1: dependencies: get-stdin "^4.0.1" -strip-json-comments@1.0.x, strip-json-comments@~1.0.1: +strip-json-comments@1.0.x: version "1.0.4" resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-1.0.4.tgz#1e15fbcac97d3ee99bf2d73b4c656b082bbafb91" @@ -9903,6 +10119,12 @@ supports-color@^5.1.0: dependencies: has-flag "^2.0.0" +supports-color@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.2.0.tgz#b0d5333b1184dd3666cbe5aa0b45c5ac7ac17a4a" + dependencies: + has-flag "^3.0.0" + svg-react-loader@^0.4.4: version "0.4.5" resolved "https://registry.yarnpkg.com/svg-react-loader/-/svg-react-loader-0.4.5.tgz#1f324c9c7b858f5c89fac752bbe9ca3f6214f850" @@ -9948,16 +10170,16 @@ symbol-tree@^3.2.1: version "3.2.2" resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6" -table@^3.7.8: - version "3.8.3" - resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" +table@^4.0.1: + version "4.0.3" + resolved "https://registry.yarnpkg.com/table/-/table-4.0.3.tgz#00b5e2b602f1794b9acaf9ca908a76386a7813bc" dependencies: - ajv "^4.7.0" - ajv-keywords "^1.0.0" - chalk "^1.1.1" - lodash "^4.0.0" - slice-ansi "0.0.4" - string-width "^2.0.0" + ajv "^6.0.1" + ajv-keywords "^3.0.0" + chalk "^2.1.0" + lodash "^4.17.4" + slice-ansi "1.0.0" + string-width "^2.1.1" tapable@^0.1.8, tapable@~0.1.8: version "0.1.10" @@ -10074,6 +10296,12 @@ tinycolor2@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/tinycolor2/-/tinycolor2-1.4.1.tgz#f4fad333447bc0b07d4dc8e9209d8f39a8ac77e8" +tmp@^0.0.33: + version "0.0.33" + resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9" + dependencies: + os-tmpdir "~1.0.2" + tmpl@1.0.x: version "1.0.4" resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1" @@ -10086,6 +10314,10 @@ to-fast-properties@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" +to-fast-properties@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" + to-object-path@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" @@ -10361,12 +10593,6 @@ user-home@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" -user-home@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/user-home/-/user-home-2.0.0.tgz#9c70bfd8169bc1dcbf48604e0f04b8b49cde9e9f" - dependencies: - os-homedir "^1.0.0" - util-deprecate@^1.0.2, util-deprecate@~1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" @@ -10986,6 +11212,6 @@ yazl@^2.1.0: dependencies: buffer-crc32 "~0.2.3" -zone.js@~0.6.26: - version "0.6.26" - resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.6.26.tgz#067c13b8b80223a89b62e9dc82680f09762c4636" +zone.js@^0.8.18: + version "0.8.20" + resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.8.20.tgz#a218c48db09464b19ff6fc8f0d4bb5b1046e185d" -- cgit 1.2.3-korg