From 280f8015d06af1f41a3ef12e8300801c7a5e0d54 Mon Sep 17 00:00:00 2001 From: AviZi Date: Fri, 9 Jun 2017 02:39:56 +0300 Subject: [SDC-29] Amdocs OnBoard 1707 initial commit. Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi --- openecomp-ui/.babelrc | 8 +- openecomp-ui/.editorconfig | 1 + openecomp-ui/.eslintrc | 2 +- openecomp-ui/.gitignore | 9 +- openecomp-ui/.storybook/addons.js | 3 + openecomp-ui/.storybook/config.js | 27 + openecomp-ui/.storybook/fonts/omnes-att-bold.otf | Bin 0 -> 153056 bytes openecomp-ui/.storybook/fonts/omnes-att-light.ttf | Bin 0 -> 73968 bytes openecomp-ui/.storybook/fonts/omnes-att-medium.ttf | Bin 0 -> 65152 bytes .../.storybook/fonts/omnes-att-regular.ttf | Bin 0 -> 71692 bytes openecomp-ui/.storybook/storybook.scss | 32 + openecomp-ui/.storybook/webpack.config.js | 17 + openecomp-ui/LICENSE | 2 +- openecomp-ui/README.md | 34 + openecomp-ui/devConfig.defaults.json | 6 +- openecomp-ui/fixture/data/entitlementPools.json | 36 -- openecomp-ui/fixture/data/featureGroup.json | 59 -- openecomp-ui/fixture/data/featureGroups.json | 28 - .../fixture/data/licenseAgreementList.json | 33 - openecomp-ui/fixture/data/licenseKeyGroups.json | 20 - openecomp-ui/fixture/data/licenseModels.json | 16 - openecomp-ui/fixture/data/softwareProduct.json | 96 --- openecomp-ui/fixture/data/softwareProductList.json | 34 - openecomp-ui/fixture/express.js | 231 ------- openecomp-ui/fixture/fixture.js | 93 --- openecomp-ui/fixture/middleware.js | 24 - openecomp-ui/gulpfile.js | 349 +++-------- openecomp-ui/index.js | 0 openecomp-ui/karma.conf.js | 102 --- openecomp-ui/package.json | 113 ++-- openecomp-ui/pom.xml | 245 +++++--- openecomp-ui/proxy-server.js | 92 +++ openecomp-ui/readMe.txt | 25 - openecomp-ui/resources/css/font-awesome.min.css | 4 - .../resources/fonts/fontawesome-webfont.eot | Bin 60767 -> 0 bytes .../resources/fonts/fontawesome-webfont.svg | 565 ----------------- .../resources/fonts/fontawesome-webfont.ttf | Bin 122092 -> 0 bytes .../resources/fonts/fontawesome-webfont.woff | Bin 71508 -> 0 bytes .../resources/fonts/fontawesome-webfont.woff2 | Bin 56780 -> 0 bytes .../resources/fonts/omnes-att-bold-italic.otf | Bin 138100 -> 0 bytes openecomp-ui/resources/fonts/omnes-att-bold.otf | Bin 153056 -> 0 bytes openecomp-ui/resources/fonts/omnes-att-italic.otf | Bin 138748 -> 0 bytes .../resources/fonts/omnes-att-light-Italic.otf | Bin 139760 -> 0 bytes openecomp-ui/resources/fonts/omnes-att-light.otf | Bin 145516 -> 0 bytes .../resources/fonts/omnes-att-medium-italic.otf | Bin 141340 -> 0 bytes openecomp-ui/resources/fonts/omnes-att-medium.otf | Bin 131984 -> 0 bytes openecomp-ui/resources/fonts/omnes-att-regular.otf | Bin 144548 -> 0 bytes openecomp-ui/resources/images/artifacts_icon.png | Bin 0 -> 1052 bytes openecomp-ui/resources/images/base_icon.png | Bin 0 -> 1534 bytes openecomp-ui/resources/images/download_icon.png | Bin 0 -> 286 bytes .../resources/images/ecomp/ASDC_Sprite.png | Bin 3416772 -> 0 bytes .../images/ecomp/sprite-services-icons.png | Bin 124154 -> 0 bytes .../resources/images/icons/ZIP_blue_icon.png | Bin 0 -> 371 bytes openecomp-ui/resources/images/icons/ZIP_icon.png | Bin 0 -> 340 bytes .../resources/images/icons/artifacts_blue_icon.png | Bin 0 -> 119 bytes .../resources/images/icons/artifacts_grey_icon.png | Bin 0 -> 112 bytes openecomp-ui/resources/images/icons/back_icon.png | Bin 0 -> 289 bytes openecomp-ui/resources/images/icons/checked_in.png | Bin 0 -> 1236 bytes .../resources/images/icons/checked_out.png | Bin 0 -> 1237 bytes .../resources/images/icons/down_chevron.png | Bin 0 -> 184 bytes openecomp-ui/resources/images/icons/env_icon.png | Bin 0 -> 145 bytes .../resources/images/icons/env_icon_blue.png | Bin 0 -> 145 bytes .../resources/images/icons/error_icon_big.png | Bin 0 -> 435 bytes .../resources/images/icons/error_icon_small.png | Bin 0 -> 363 bytes .../images/icons/go_to_overview_disable_icon.png | Bin 0 -> 121 bytes .../resources/images/icons/go_to_overview_icon.png | Bin 0 -> 121 bytes .../images/icons/nested_HEAT_icon_blue.png | Bin 0 -> 174 bytes .../resources/images/icons/nested_heat_icon.png | Bin 0 -> 180 bytes .../resources/images/icons/network_blue_icon.png | Bin 0 -> 285 bytes .../resources/images/icons/network_icon.png | Bin 0 -> 306 bytes .../resources/images/icons/orphans_blue_icon-n.png | Bin 0 -> 683 bytes .../resources/images/icons/orphans_grey_icon.png | Bin 0 -> 321 bytes .../resources/images/icons/others_blue_icon.png | Bin 0 -> 121 bytes .../resources/images/icons/others_icon.png | Bin 0 -> 114 bytes .../resources/images/icons/pencil_icon-01.svg | 17 + .../icons/plus_vlm_summary_disabled_icon.png | Bin 0 -> 1012 bytes .../images/icons/plus_vlm_summary_icon.png | Bin 0 -> 690 bytes .../images/icons/plus_vlm_summary_icon_blue.png | Bin 0 -> 1013 bytes .../images/icons/revert_icon_disabled.png | Bin 0 -> 443 bytes openecomp-ui/resources/images/icons/reverticon.png | Bin 0 -> 1305 bytes .../resources/images/icons/save_icon_disable.png | Bin 0 -> 186 bytes openecomp-ui/resources/images/icons/saveicon.png | Bin 0 -> 15002 bytes .../resources/images/icons/submit_icon_disable.png | Bin 0 -> 479 bytes .../resources/images/icons/submiticonactive.png | Bin 0 -> 1334 bytes .../images/icons/vlm_list_view_blue_icon.png | Bin 0 -> 367 bytes .../images/icons/vlm_list_view_grey_icon.png | Bin 0 -> 347 bytes .../resources/images/icons/volume_blue_icon.png | Bin 0 -> 479 bytes .../resources/images/icons/volume_icon.png | Bin 0 -> 453 bytes .../resources/images/icons/warning_icon_big.png | Bin 0 -> 380 bytes .../resources/images/icons/warning_icon_small.png | Bin 0 -> 287 bytes openecomp-ui/resources/images/module_icon.png | Bin 0 -> 1204 bytes .../images/onboarding/vendor-license-model.svg | 1 - .../images/onboarding/vendor-software-product.svg | 1 - openecomp-ui/resources/images/pencil_icon-01.svg | 17 + .../resources/images/svg/angle-double-left.svg | 15 + .../resources/images/svg/angle-double-right.svg | 11 + openecomp-ui/resources/images/svg/angle-left.svg | 9 + openecomp-ui/resources/images/svg/angle-right.svg | 9 + openecomp-ui/resources/images/svg/back.svg | 6 + openecomp-ui/resources/images/svg/caret-down.svg | 6 + openecomp-ui/resources/images/svg/check-circle.svg | 1 + openecomp-ui/resources/images/svg/check.svg | 9 + openecomp-ui/resources/images/svg/chevron-down.svg | 9 + openecomp-ui/resources/images/svg/chevron-up.svg | 9 + openecomp-ui/resources/images/svg/close.svg | 10 + openecomp-ui/resources/images/svg/error-circle.svg | 1 + .../images/svg/exclamation-triangle-full.svg | 9 + .../images/svg/exclamation-triangle-line.svg | 25 + .../resources/images/svg/exclamation-triangle.svg | 11 + openecomp-ui/resources/images/svg/filter.svg | 9 + openecomp-ui/resources/images/svg/locked.svg | 39 ++ openecomp-ui/resources/images/svg/pencil.svg | 17 + openecomp-ui/resources/images/svg/plus-circle.svg | 15 + openecomp-ui/resources/images/svg/plus.svg | 9 + openecomp-ui/resources/images/svg/search.svg | 8 + openecomp-ui/resources/images/svg/sliders.svg | 19 + openecomp-ui/resources/images/svg/trash-o.svg | 17 + openecomp-ui/resources/images/svg/unlocked.svg | 39 ++ openecomp-ui/resources/images/svg/vendor.svg | 1 + .../images/svg/version-controller-lock-closed.svg | 17 + .../images/svg/version-controller-lock-open.svg | 17 + .../images/svg/version-controller-revert.svg | 14 + .../images/svg/version-controller-save.svg | 10 + .../images/svg/version-controller-submit.svg | 10 + openecomp-ui/resources/images/svg/vlm.svg | 1 + openecomp-ui/resources/images/svg/vsp.svg | 1 + openecomp-ui/resources/images/trash_icon.png | Bin 0 -> 173 bytes openecomp-ui/resources/images/upload_icon.png | Bin 0 -> 268 bytes openecomp-ui/resources/images/v_icon.png | Bin 0 -> 832 bytes openecomp-ui/resources/scss/_components.scss | 34 +- openecomp-ui/resources/scss/_modules.scss | 10 +- .../resources/scss/bootstrap-cust/_forms.scss | 3 +- .../resources/scss/bootstrap-cust/_modals.scss | 7 +- .../resources/scss/bootstrap-cust/_variables.scss | 5 + openecomp-ui/resources/scss/common/_base.scss | 8 + openecomp-ui/resources/scss/common/_layout.scss | 7 + .../resources/scss/common/_typography.scss | 84 ++- openecomp-ui/resources/scss/common/_utils.scss | 189 +++--- openecomp-ui/resources/scss/common/_variables.scss | 66 +- .../resources/scss/components/_activityLog.scss | 104 ++++ .../resources/scss/components/_buttons.scss | 15 - .../resources/scss/components/_dualListBox.scss | 10 +- .../scss/components/_expandableInput.scss | 108 ++-- openecomp-ui/resources/scss/components/_forms.scss | 49 +- openecomp-ui/resources/scss/components/_grid.scss | 64 ++ openecomp-ui/resources/scss/components/_icon.scss | 164 +++++ .../resources/scss/components/_inputOptions.scss | 48 +- .../resources/scss/components/_listEditorView.scss | 145 +++-- .../scss/components/_navigationSideBar.scss | 6 +- .../scss/components/_selectActionTable.scss | 152 +++++ .../resources/scss/components/_slidePanel.scss | 35 -- .../scss/components/_submitErrorResponse.scss | 37 ++ .../resources/scss/components/_svgIcon.scss | 51 ++ .../resources/scss/components/_validationForm.scss | 24 +- .../scss/components/_versionController.scss | 196 +++--- .../resources/scss/modules/_entitlementPools.scss | 30 +- .../resources/scss/modules/_featureGroup.scss | 15 - .../resources/scss/modules/_licenseAgreement.scss | 30 - .../resources/scss/modules/_licenseKeyGroup.scss | 16 - .../scss/modules/_licenseModelOverview.scss | 491 +++++++++++++++ .../resources/scss/modules/_onboardingCatalog.scss | 180 +----- .../modules/_softwareProductAttachmentPage.scss | 284 ++++++--- .../modules/_softwareProductComponentCompute.scss | 3 + .../modules/_softwareProductComponentGeneral.scss | 3 + .../modules/_softwareProductComponentNetwork.scss | 49 +- .../_softwareProductComponentProcessesPage.scss | 8 + .../scss/modules/_softwareProductDependencies.scss | 25 + .../scss/modules/_softwareProductLandingPage.scss | 95 +-- .../scss/modules/_softwareProductNetworksPage.scss | 24 - .../modules/_softwareProductProcessesPage.scss | 11 +- .../_softwareproductComponentLoadBalancing.scss | 22 +- .../scss/modules/_vspComponentQuestionnaire.scss | 7 +- .../resources/scss/modules/_vspHeatSetup.scss | 316 ++++++++++ .../modules/onboardingCatalog/_catalogHeader.scss | 33 + .../modules/onboardingCatalog/_catalogList.scss | 31 + .../modules/onboardingCatalog/_catalogTile.scss | 139 +++++ .../modules/onboardingCatalog/_createItemTile.scss | 71 +++ .../modules/onboardingCatalog/_onboardHeader.scss | 31 + .../scss/modules/onboardingCatalog/_tile.scss | 14 + .../onboardingCatalog/_vendorPageHeader.scss | 21 + .../modules/onboardingCatalog/_vendorTile.scss | 88 +++ .../scss/modules/onboardingCatalog/_vlmTile.scss | 8 + .../modules/onboardingCatalog/_vspOverlay.scss | 74 +++ openecomp-ui/resources/scss/onboarding.scss | 70 ++- .../src/nfvo-components/SubmitErrorResponse.jsx | 175 +++--- .../nfvo-components/activity-log/ActivityLog.js | 27 + .../activity-log/ActivityLogActionHelper.js | 31 + .../activity-log/ActivityLogConstants.js | 23 + .../activity-log/ActivityLogReducer.js | 25 + .../activity-log/ActivityLogView.jsx | 124 ++++ .../confirmations/ConfirmationModalView.jsx | 53 -- .../src/nfvo-components/editor/TabulatedEditor.jsx | 31 +- openecomp-ui/src/nfvo-components/grid/GridItem.jsx | 26 + .../src/nfvo-components/grid/GridSection.jsx | 33 + openecomp-ui/src/nfvo-components/icon/Icon.jsx | 45 ++ openecomp-ui/src/nfvo-components/icon/SVGIcon.jsx | 54 ++ .../src/nfvo-components/icon/SVGIcon.stories.js | 50 ++ .../src/nfvo-components/input/ExpandableInput.jsx | 140 +++-- .../src/nfvo-components/input/SelectInput.jsx | 18 +- .../src/nfvo-components/input/ToggleInput.jsx | 15 + .../input/dualListbox/DualListboxView.jsx | 67 +- .../input/inputOptions/InputOptions.jsx | 55 +- .../src/nfvo-components/input/validation/Form.jsx | 114 ++++ .../src/nfvo-components/input/validation/Input.jsx | 180 ++++++ .../input/validation/InputOptions.jsx | 279 +++++++++ .../input/validation/InputWrapper.jsx | 134 ++++ .../src/nfvo-components/input/validation/Tabs.jsx | 79 +++ .../input/validation/ValidationButtons.jsx | 21 +- .../input/validation/ValidationForm.jsx | 200 ------ .../input/validation/ValidationInput.jsx | 509 --------------- .../input/validation/ValidationTab.jsx | 107 ---- .../input/validation/ValidationTabs.jsx | 72 --- .../listEditor/ListEditorItemView.jsx | 38 +- .../listEditor/ListEditorItemViewField.jsx | 24 + .../nfvo-components/listEditor/ListEditorView.jsx | 99 +-- .../listEditor/listEditor.stories.js | 60 ++ openecomp-ui/src/nfvo-components/loader/Loader.jsx | 15 + .../src/nfvo-components/loader/LoaderConstants.js | 21 +- .../src/nfvo-components/loader/LoaderReducer.js | 21 +- .../src/nfvo-components/modal/GlobalModal.js | 120 ++++ .../nfvo-components/modal/GlobalModalConstants.js | 33 + .../nfvo-components/modal/GlobalModalReducer.js | 50 ++ openecomp-ui/src/nfvo-components/modal/Modal.jsx | 15 + .../notifications/NotificationConstants.js | 29 - .../notifications/NotificationModal.jsx | 100 --- .../notifications/NotificationReducer.js | 51 -- .../nfvo-components/panel/NavigationSideBar.jsx | 125 ++-- .../src/nfvo-components/panel/SlidePanel.jsx | 109 ---- .../panel/versionController/VersionController.jsx | 245 ++++---- .../VersionControllerConstants.js | 29 +- .../versionController/VersionControllerUtils.js | 39 +- .../nfvo-components/progressBar/ProgressBar.jsx | 15 + .../nfvo-components/table/SelectActionTable.jsx | 29 + .../table/SelectActionTableCell.jsx | 20 + .../nfvo-components/table/SelectActionTableRow.jsx | 30 + openecomp-ui/src/nfvo-utils/DirectedGraph.js | 45 ++ .../src/nfvo-utils/ErrorResponseHandler.js | 38 +- openecomp-ui/src/nfvo-utils/KeyMirror.js | 23 +- openecomp-ui/src/nfvo-utils/RestAPIUtil.js | 304 +++------ openecomp-ui/src/nfvo-utils/UUID.js | 21 +- openecomp-ui/src/nfvo-utils/Validator.js | 110 ++++ openecomp-ui/src/nfvo-utils/i18n/i18n.js | 21 +- openecomp-ui/src/nfvo-utils/json/JSONPointer.js | 23 +- openecomp-ui/src/nfvo-utils/json/JSONSchema.js | 127 +++- .../src/nfvo-utils/sortByStringProperty.js | 18 + openecomp-ui/src/sdc-app/AppStore.js | 43 +- openecomp-ui/src/sdc-app/Application.jsx | 19 +- openecomp-ui/src/sdc-app/ModulesOptions.jsx | 21 +- openecomp-ui/src/sdc-app/Test.jsx | 122 ---- .../src/sdc-app/common/helpers/ValidationHelper.js | 91 +++ .../src/sdc-app/common/modal/ModalContentMapper.js | 31 + .../sdc-app/common/reducers/JSONSchemaReducer.js | 145 +++++ .../common/reducers/JSONSchemaReducerConstants.js | 23 + .../sdc-app/common/reducers/PlainDataReducer.js | 94 +++ .../common/reducers/PlainDataReducerConstants.js | 22 + openecomp-ui/src/sdc-app/config/Configuration.js | 25 +- openecomp-ui/src/sdc-app/config/config.json | 2 +- openecomp-ui/src/sdc-app/flows/FlowsActions.js | 46 +- openecomp-ui/src/sdc-app/flows/FlowsConstants.js | 23 +- openecomp-ui/src/sdc-app/flows/FlowsEditorModal.js | 46 +- .../src/sdc-app/flows/FlowsEditorModalView.jsx | 38 +- openecomp-ui/src/sdc-app/flows/FlowsListEditor.js | 31 +- .../src/sdc-app/flows/FlowsListEditorView.jsx | 20 +- openecomp-ui/src/sdc-app/flows/FlowsListReducer.js | 56 +- openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx | 15 + openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js | 23 +- openecomp-ui/src/sdc-app/flows/ImportantLogic.jsx | 15 + openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx | 17 +- .../sdc-app/flows/SequenceDiagramModelHelper.js | 21 +- openecomp-ui/src/sdc-app/heatValidation.app.jsx | 16 +- .../src/sdc-app/heatvalidation/Attachments.js | 44 ++ .../src/sdc-app/heatvalidation/HeatSetup.js | 28 + .../src/sdc-app/heatvalidation/UploadScreen.jsx | 186 +----- .../heatvalidation/UploadScreenActionHelper.js | 200 +++++- .../heatvalidation/UploadScreenConstants.js | 28 - .../sdc-app/heatvalidation/UploadScreenReducer.js | 33 - .../heatvalidation/attachments/Attachments.js | 46 -- .../attachments/AttachmentsActionHelper.js | 44 -- .../attachments/AttachmentsConstants.js | 55 -- .../attachments/AttachmentsReducer.js | 199 ------ .../heatvalidation/attachments/AttachmentsView.jsx | 190 ------ .../sdc-app/onboarding/OnboardingActionHelper.js | 158 +++-- .../src/sdc-app/onboarding/OnboardingCatalog.js | 59 -- .../sdc-app/onboarding/OnboardingCatalogView.jsx | 147 ----- .../src/sdc-app/onboarding/OnboardingConstants.js | 30 +- .../src/sdc-app/onboarding/OnboardingPunchOut.jsx | 387 ++++++++---- .../src/sdc-app/onboarding/OnboardingReducers.js | 23 +- .../sdc-app/onboarding/OnboardingReducersMap.js | 28 +- .../FinalizedLicenseModelListReducer.js | 21 +- .../onboarding/licenseModel/LicenseModel.js | 78 ++- .../licenseModel/LicenseModelActionHelper.js | 124 +++- .../licenseModel/LicenseModelConstants.js | 31 +- .../licenseModel/LicenseModelEditorReducer.js | 23 +- .../licenseModel/LicenseModelListReducer.js | 21 +- .../onboarding/licenseModel/LicenseModelReducer.js | 79 ++- .../licenseModel/creation/LicenseModelCreation.js | 48 +- .../creation/LicenseModelCreationActionHelper.js | 51 +- .../creation/LicenseModelCreationConstants.js | 26 +- .../creation/LicenseModelCreationReducer.js | 47 +- .../creation/LicenseModelCreationView.jsx | 67 +- .../EntitlementPoolsActionHelper.js | 54 +- .../EntitlementPoolsConfirmationModal.jsx | 51 -- .../entitlementPools/EntitlementPoolsConstants.js | 33 +- .../entitlementPools/EntitlementPoolsEditor.js | 50 +- .../EntitlementPoolsEditorReducer.js | 77 ++- .../EntitlementPoolsEditorView.jsx | 363 +++++++---- .../entitlementPools/EntitlementPoolsListEditor.js | 41 +- .../EntitlementPoolsListEditorView.jsx | 67 +- .../EntitlementPoolsListReducer.js | 21 +- .../featureGroups/FeatureGroupEditor.js | 74 ++- .../featureGroups/FeatureGroupEditorView.jsx | 413 +++++-------- .../featureGroups/FeatureGroupListEditor.js | 50 +- .../featureGroups/FeatureGroupListEditorView.jsx | 86 ++- .../featureGroups/FeatureGroupsActionHelper.js | 118 ++-- .../FeatureGroupsConfirmationModal.jsx | 48 -- .../featureGroups/FeatureGroupsConstants.js | 44 +- .../featureGroups/FeatureGroupsEditorReducer.js | 52 +- .../featureGroups/FeatureGroupsListReducer.js | 21 +- .../LicenseAgreementActionHelper.js | 84 +-- .../LicenseAgreementConfirmationModal.jsx | 43 -- .../licenseAgreement/LicenseAgreementConstants.js | 41 +- .../licenseAgreement/LicenseAgreementEditor.js | 60 +- .../LicenseAgreementEditorReducer.js | 64 +- .../LicenseAgreementEditorView.jsx | 326 +++++----- .../licenseAgreement/LicenseAgreementListEditor.js | 48 +- .../LicenseAgreementListEditorView.jsx | 66 +- .../LicenseAgreementListReducer.js | 21 +- .../LicenseKeyGroupsActionHelper.js | 59 +- .../LicenseKeyGroupsConfirmationModal.jsx | 49 -- .../licenseKeyGroups/LicenseKeyGroupsConstants.js | 41 +- .../licenseKeyGroups/LicenseKeyGroupsEditor.js | 48 +- .../LicenseKeyGroupsEditorReducer.js | 57 +- .../LicenseKeyGroupsEditorView.jsx | 183 ++++-- .../licenseKeyGroups/LicenseKeyGroupsListEditor.js | 36 +- .../LicenseKeyGroupsListEditorView.jsx | 45 +- .../LicenseKeyGroupsListReducer.js | 21 +- .../licenseModel/overview/LicenseModelOverview.js | 163 +++++ .../overview/LicenseModelOverviewConstants.js | 42 ++ .../overview/LicenseModelOverviewView.jsx | 105 ++++ .../licenseModel/overview/SummaryView.jsx | 33 + .../licenseModel/overview/VLMListView.jsx | 123 ++++ .../overview/licenseModelOverviewActionHelper.js | 39 ++ .../overview/listItems/EntitlementPool.jsx | 53 ++ .../overview/listItems/FeatureGroup.jsx | 50 ++ .../overview/listItems/LicenseAgreement.jsx | 53 ++ .../overview/listItems/LicenseKeyGroup.jsx | 48 ++ .../listItemsComponents/AdditionalDataCol.jsx | 51 ++ .../listItems/listItemsComponents/ArrowCol.jsx | 35 ++ .../listItems/listItemsComponents/IconCol.jsx | 26 + .../listItems/listItemsComponents/ItemInfo.jsx | 39 ++ .../summary/LicenseModelDescriptionEdit.jsx | 56 ++ .../licenseModel/overview/summary/ListButtons.jsx | 39 ++ .../overview/summary/SummaryCountItem.jsx | 31 + .../overview/summary/SummaryCountList.js | 126 ++++ .../overview/summary/VendorDataView.js | 86 +++ .../onboarding/onboard/CatalogItemDetails.jsx | 134 ++++ .../onboard/CatalogItemDetails.stories.js | 36 ++ .../src/sdc-app/onboarding/onboard/CatalogList.jsx | 51 ++ .../sdc-app/onboarding/onboard/CatalogModal.jsx | 62 ++ .../src/sdc-app/onboarding/onboard/CatalogTile.jsx | 31 + .../onboarding/onboard/DetailsCatalogView.jsx | 56 ++ .../src/sdc-app/onboarding/onboard/Onboard.js | 90 +++ .../onboarding/onboard/OnboardActionHelper.js | 45 ++ .../sdc-app/onboarding/onboard/OnboardConstants.js | 28 + .../sdc-app/onboarding/onboard/OnboardReducer.js | 31 + .../src/sdc-app/onboarding/onboard/OnboardView.jsx | 95 +++ .../OnboardingCatalogActionHelper.js | 85 +++ .../OnboardingCatalogConstants.js | 50 ++ .../onboardingCatalog/OnboardingCatalogReducer.js | 30 + .../onboardingCatalog/OnboardingCatalogUtils.js | 21 + .../onboardingCatalog/OnboardingCatalogView.jsx | 98 +++ .../onboard/onboardingCatalog/Tooltip.jsx | 24 + .../onboard/onboardingCatalog/VSPOverlay.jsx | 50 ++ .../onboardingCatalog/VendorCatalogReducer.js | 38 ++ .../onboardingCatalog/VendorCatalogView.jsx | 74 +++ .../onboard/onboardingCatalog/VendorItem.jsx | 96 +++ .../onboarding/onboard/workspace/WorkspaceView.jsx | 57 ++ .../FinalizedSoftwareProductReducer.js | 25 + .../onboarding/softwareProduct/SoftwareProduct.js | 182 +++--- .../softwareProduct/SoftwareProductActionHelper.js | 340 +++++++--- .../SoftwareProductCategoriesHelper.js | 21 +- .../softwareProduct/SoftwareProductConstants.js | 72 ++- .../softwareProduct/SoftwareProductListReducer.js | 21 +- .../softwareProduct/SoftwareProductReducer.js | 61 +- .../attachments/SoftwareProductAttachments.js | 95 ++- .../SoftwareProductAttachmentsActionHelper.js | 44 -- .../SoftwareProductAttachmentsConstants.js | 60 +- .../SoftwareProductAttachmentsReducer.js | 199 ------ .../attachments/SoftwareProductAttachmentsUtils.js | 25 + .../attachments/SoftwareProductAttachmentsView.jsx | 253 +++----- .../softwareProduct/attachments/setup/HeatSetup.js | 62 ++ .../attachments/setup/HeatSetupActionHelper.js | 77 +++ .../attachments/setup/HeatSetupConstants.js | 42 ++ .../attachments/setup/HeatSetupReducer.js | 124 ++++ .../attachments/setup/HeatSetupView.jsx | 328 ++++++++++ .../attachments/validation/HeatValidation.js | 51 ++ .../validation/HeatValidationActionHelper.js | 39 ++ .../validation/HeatValidationConstants.js | 57 ++ .../validation/HeatValidationReducer.js | 196 ++++++ .../attachments/validation/HeatValidationView.jsx | 274 ++++++++ .../SoftwareProductComponentEditorReducer.js | 57 +- .../SoftwareProductComponentsActionHelper.js | 117 ++-- .../SoftwareProductComponentsConstants.js | 33 +- .../components/SoftwareProductComponentsList.js | 25 +- .../SoftwareProductComponentsListReducer.js | 21 +- .../SoftwareProductComponentsListView.jsx | 35 +- .../compute/SoftwareProductComponentCompute.js | 45 +- .../SoftwareProductComponentComputeView.jsx | 149 ++--- .../compute/computeComponents/GuestOs.jsx | 76 +++ .../compute/computeComponents/NumberOfVms.jsx | 94 +++ .../compute/computeComponents/VmSizing.jsx | 68 ++ .../general/SoftwareProductComponentsGeneral.js | 49 +- .../SoftwareProductComponentsGeneralView.jsx | 430 ++++++++----- .../SoftwareProductComponentLoadBalancing.js | 34 +- ...oftwareProductComponentLoadBalancingRefView.jsx | 134 +++- .../SoftwareProductComponentsMonitoring.js | 38 +- ...twareProductComponentsMonitoringActionHelper.js | 70 +-- ...SoftwareProductComponentsMonitoringConstants.js | 21 +- .../SoftwareProductComponentsMonitoringReducer.js | 21 +- .../SoftwareProductComponentsMonitoringView.jsx | 39 +- .../network/SoftwareProductComponentsNICEditor.js | 51 +- .../SoftwareProductComponentsNICEditorReducer.js | 51 +- .../SoftwareProductComponentsNICEditorView.jsx | 356 ++--------- .../SoftwareProductComponentsNICListReducer.js | 21 +- ...SoftwareProductComponentsNetworkActionHelper.js | 96 ++- .../SoftwareProductComponentsNetworkConstants.js | 27 +- .../SoftwareProductComponentsNetworkList.js | 46 +- .../SoftwareProductComponentsNetworkListView.jsx | 104 ++-- .../network/nicEditorComponents/Acceptable.jsx | 75 +++ .../network/nicEditorComponents/FlowLength.jsx | 35 ++ .../network/nicEditorComponents/InFlowTraffic.jsx | 35 ++ .../network/nicEditorComponents/IpConfig.jsx | 45 ++ .../network/nicEditorComponents/NameAndPurpose.jsx | 54 ++ .../network/nicEditorComponents/Network.jsx | 62 ++ .../network/nicEditorComponents/OutFlowTraffic.jsx | 35 ++ .../network/nicEditorComponents/PacketsBytes.jsx | 65 ++ .../network/nicEditorComponents/Protocols.jsx | 74 +++ .../network/nicEditorComponents/Sizing.jsx | 39 ++ ...oftwareProductComponentProcessesActionHelper.js | 76 +-- .../SoftwareProductComponentProcessesConstants.js | 36 +- .../SoftwareProductComponentProcessesEditor.js | 42 +- ...ftwareProductComponentProcessesEditorReducer.js | 56 +- ...SoftwareProductComponentProcessesEditorView.jsx | 189 ++++-- .../SoftwareProductComponentProcessesList.js | 36 +- ...SoftwareProductComponentProcessesListReducer.js | 21 +- ...ProductComponentsProcessesConfirmationModal.jsx | 45 -- .../SoftwareProductComponentsProcessesListView.jsx | 36 +- .../storage/SoftwareProductComponentStorage.js | 39 +- .../SoftwareProductComponentStorageView.jsx | 256 +++++--- .../creation/SoftwareProductCreation.js | 56 +- .../SoftwareProductCreationActionHelper.js | 62 +- .../creation/SoftwareProductCreationConstants.js | 26 +- .../creation/SoftwareProductCreationReducer.js | 64 +- .../creation/SoftwareProductCreationView.jsx | 140 +++-- .../dependencies/SoftwareProductDependencies.js | 40 ++ .../SoftwareProductDependenciesActionHelper.js | 58 ++ .../SoftwareProductDependenciesConstants.js | 29 + .../SoftwareProductDependenciesReducer.js | 36 ++ .../SoftwareProductDependenciesUtils.js | 64 ++ .../SoftwareProductDependenciesView.jsx | 98 +++ .../details/SoftwareProductDetails.js | 47 +- .../details/SoftwareProductDetailsReducer.js | 56 +- .../details/SoftwareProductDetailsView.jsx | 480 +++++++++----- .../landingPage/SoftwareProductLandingPage.js | 63 +- ...reProductLandingPageUploadConfirmationModal.jsx | 38 -- .../landingPage/SoftwareProductLandingPageView.jsx | 91 +-- .../networks/SoftwareProductNetworks.js | 21 +- .../SoftwareProductNetworksActionHelper.js | 29 +- .../networks/SoftwareProductNetworksConstants.js | 21 +- .../networks/SoftwareProductNetworksListReducer.js | 21 +- .../networks/SoftwareProductNetworksView.jsx | 34 +- .../processes/SoftwareProductProcesses.js | 34 +- .../SoftwareProductProcessesActionHelper.js | 74 +-- .../SoftwareProductProcessesConfirmationModal.jsx | 45 -- .../processes/SoftwareProductProcessesConstants.js | 35 +- .../processes/SoftwareProductProcessesEditor.js | 43 +- .../SoftwareProductProcessesEditorReducer.js | 55 +- .../SoftwareProductProcessesEditorView.jsx | 202 ++++-- .../SoftwareProductProcessesListReducer.js | 21 +- .../processes/SoftwareProductProcessesView.jsx | 35 +- openecomp-ui/src/sdc-app/punch-outs.js | 21 +- openecomp-ui/src/sdc-app/sdc.app.jsx | 16 +- openecomp-ui/test-utils/MockRest.js | 49 +- openecomp-ui/test-utils/Util.js | 52 +- .../factories/SubnitErrorMessageFactorie.js | 56 ++ .../factories/activity-log/ActivityLogFactories.js | 30 + .../test-utils/factories/flows/FlowsFactories.js | 118 ++++ .../factories/flows/ParticipantFactory.js | 20 + .../factories/flows/SequenceDiagramFactory.js | 50 ++ .../licenseModel/EntitlementPoolFactories.js | 61 ++ .../licenseModel/FeatureGroupFactories.js | 82 +++ .../licenseModel/LicenseAgreementFactories.js | 77 +++ .../licenseModel/LicenseKeyGroupFactories.js | 52 ++ .../licenseModel/LicenseModelFactories.js | 77 +++ .../test-utils/factories/mixins/IdMixin.js | 20 + .../test-utils/factories/mixins/RandomNameMixin.js | 20 + .../factories/onboard/OnboardFactories.js | 23 + .../onboard/OnboardingCatalogFactories.js | 26 + .../SoftwareProductAttachmentsFactories.js | 106 ++++ .../SoftwareProductComponentsComputeFactory.js | 35 ++ .../SoftwareProductComponentsFactories.js | 34 + ...SoftwareProductComponentsMonitoringFactories.js | 32 + .../SoftwareProductComponentsNetworkFactories.js | 260 ++++++++ .../SoftwareProductComponentsStorageFactory.js | 34 + .../SoftwareProductCreationFactories.js | 33 + .../SoftwareProductDependenciesFactories.js | 34 + .../SoftwareProductEditorFactories.js | 63 ++ .../softwareProduct/SoftwareProductFactory.js | 47 ++ .../SoftwareProductNetworkFactory.js | 25 + .../SoftwareProductProcessFactories.js | 73 +++ .../SoftwareProductQSchemaFactory.js | 131 ++++ .../softwareProduct/VSPCategoriesFactory.js | 40 ++ .../VersionControllerUtilsFactory.js | 30 + .../factories/softwareProduct/VspQdataFactory.js | 55 ++ openecomp-ui/test-utils/failedTestReport.js | 34 + openecomp-ui/test-utils/fileMock.js | 1 + openecomp-ui/test-utils/styleMock.js | 1 + openecomp-ui/test-utils/test-env-setup.js | 16 + openecomp-ui/test-utils/test-setup.js | 2 + openecomp-ui/test/flows/FlowsListEditor.test.js | 255 ++------ openecomp-ui/test/flows/flowsEditorModal.test.js | 50 +- openecomp-ui/test/flows/test.js | 442 ++----------- .../creation/LicenseModelCreation.test.js | 75 +++ .../test/licenseModel/entitlementPools/test.js | 177 ++---- .../LicenseModelFeatureGroupEditor.test.js | 74 +++ .../LicenseModelFeatureGroupListEditor.test.js | 90 +++ .../test/licenseModel/featureGroups/test.js | 212 ++++--- .../test/licenseModel/licenseAgreement/test.js | 172 ++---- .../test/licenseModel/licenseKeyGroups/test.js | 169 ++--- .../overview/listItems/EntitlementPool.test.js | 31 + .../overview/listItems/FeatureGroup.test.js | 58 ++ .../overview/listItems/LicenseAgreement.test.js | 54 ++ .../overview/listItems/LicenseKeyGroup.test.js | 31 + .../overview/summary/SummaryCountList.test.js | 87 +++ .../overview/summary/VendorDataView.test.js | 48 ++ openecomp-ui/test/licenseModel/overview/test.js | 355 +++++++++++ .../test/licenseModel/overview/views.test.js | 159 +++++ openecomp-ui/test/licenseModel/test.js | 55 +- .../nfvo-components/SubmitErrorResponse.test.js | 33 + .../__snapshots__/storyshots.test.js.snap | 686 +++++++++++++++++++++ .../activity-log/ActivityLog.test.js | 89 +++ .../nfvo-components/editor/TabulatedEditor.test.js | 52 ++ .../input/dualListBox/dualListbox.test.js | 85 +-- .../nfvo-components/input/validation/input.test.js | 141 +++++ .../nfvo-components/listEditor/listEditor.test.js | 60 +- .../test/nfvo-components/modal/globalModal.test.js | 92 +++ .../notifications/notificationsModal.test.js | 144 ----- .../VersionController/versionController.test.js | 145 ++++- .../versionControllerUtils.test.js | 132 ++-- .../test/nfvo-components/storyshots.test.js | 2 + .../test/onboard/onboardingCatalog/test.js | 63 ++ .../test/onboard/onboardingCatalog/views.test.js | 143 +++++ openecomp-ui/test/onboard/test.js | 62 ++ openecomp-ui/test/setup.test.js | 25 - .../SoftwareProductAttachmentsView.test.js | 214 ++----- .../SoftwareproductAttachmentsHelper.test.js | 153 ----- .../attachments/setup/heatSetup.test.js | 49 ++ .../setup/heatSetupActionHelper.test.js | 142 +++++ .../validation/HeatValidationActionHelper.test.js | 144 +++++ .../validation/HeatValidationView.test.js | 184 ++++++ .../softwareProduct/components/compute/test.js | 85 +-- .../SoftwareProductComponentsGeneral.test.js | 90 +-- .../softwareProductComponentLoadbalancing.test.js | 87 +-- .../SoftwareProductComponentsMonitoring.test.js | 53 +- .../softwareProduct/components/monitoring/test.js | 73 +-- .../SoftwareProductComponentsNICEditor.test.js | 83 ++- .../SoftwareProductComponentsNetwork.test.js | 91 +-- ...areProductComponentsNetworkActionHelper.test.js | 233 ++----- ...oftwareProductComponentsProcessesEditor.test.js | 57 ++ .../SoftwareProductComponentsProcessesView.test.js | 77 +++ .../softwareProduct/components/processes/test.js | 191 +++--- .../softwareProduct/components/storage/test.js | 85 +-- .../test/softwareProduct/components/test.js | 65 +- .../creation/SoftwareProductCreation.test.js | 105 ++++ .../SoftwareProductDependencies.test.js | 210 +++++++ .../softwareProduct/details/detailsView.test.js | 415 +++++-------- openecomp-ui/test/softwareProduct/details/test.js | 494 ++++++++------- .../test/softwareProduct/details/vspQschema.js | 20 +- .../landingPage/landingPage.test.js | 177 ++++++ .../networks/SoftwareProductNetworksView.test.js | 94 +-- .../softwareProductNetworksActionHelper.test.js | 49 +- .../processes/SoftwareProductEditor.test.js | 62 ++ .../processes/SoftwareProductProcessesView.test.js | 75 +++ .../test/softwareProduct/processes/test.js | 338 +++++----- .../test/utils/errorResponseHandler.test.js | 76 ++- openecomp-ui/test/utils/restApiUtil.test.js | 149 ----- openecomp-ui/test/utils/uuid.test.js | 33 +- openecomp-ui/test/utils/validator.test.js | 69 +++ openecomp-ui/tests.webpack.js | 35 -- openecomp-ui/tools/gulp/deployment/gulpfile.js | 21 +- openecomp-ui/tools/gulp/deployment/package.json | 2 +- .../gulp/deployment/tools/gulp/tasks/i18nUpdate.js | 23 +- openecomp-ui/tools/gulp/tasks/i18n.js | 34 +- openecomp-ui/tools/gulp/tasks/prod.js | 48 +- .../tools/webpack/config-json-loader/index.js | 24 +- .../webapp-onboarding/WEB-INF/jetty-web.xml | 2 +- openecomp-ui/webpack.common.js | 44 ++ openecomp-ui/webpack.config.js | 130 ++-- openecomp-ui/webpack.production.js | 45 ++ 599 files changed, 25510 insertions(+), 14539 deletions(-) create mode 100644 openecomp-ui/.storybook/addons.js create mode 100644 openecomp-ui/.storybook/config.js create mode 100644 openecomp-ui/.storybook/fonts/omnes-att-bold.otf create mode 100644 openecomp-ui/.storybook/fonts/omnes-att-light.ttf create mode 100644 openecomp-ui/.storybook/fonts/omnes-att-medium.ttf create mode 100644 openecomp-ui/.storybook/fonts/omnes-att-regular.ttf create mode 100644 openecomp-ui/.storybook/storybook.scss create mode 100644 openecomp-ui/.storybook/webpack.config.js create mode 100644 openecomp-ui/README.md delete mode 100644 openecomp-ui/fixture/data/entitlementPools.json delete mode 100644 openecomp-ui/fixture/data/featureGroup.json delete mode 100644 openecomp-ui/fixture/data/featureGroups.json delete mode 100644 openecomp-ui/fixture/data/licenseAgreementList.json delete mode 100644 openecomp-ui/fixture/data/licenseKeyGroups.json delete mode 100644 openecomp-ui/fixture/data/licenseModels.json delete mode 100644 openecomp-ui/fixture/data/softwareProduct.json delete mode 100644 openecomp-ui/fixture/data/softwareProductList.json delete mode 100644 openecomp-ui/fixture/express.js delete mode 100644 openecomp-ui/fixture/fixture.js delete mode 100644 openecomp-ui/fixture/middleware.js create mode 100644 openecomp-ui/index.js delete mode 100644 openecomp-ui/karma.conf.js create mode 100644 openecomp-ui/proxy-server.js delete mode 100644 openecomp-ui/readMe.txt delete mode 100644 openecomp-ui/resources/css/font-awesome.min.css delete mode 100644 openecomp-ui/resources/fonts/fontawesome-webfont.eot delete mode 100644 openecomp-ui/resources/fonts/fontawesome-webfont.svg delete mode 100644 openecomp-ui/resources/fonts/fontawesome-webfont.ttf delete mode 100644 openecomp-ui/resources/fonts/fontawesome-webfont.woff delete mode 100644 openecomp-ui/resources/fonts/fontawesome-webfont.woff2 delete mode 100644 openecomp-ui/resources/fonts/omnes-att-bold-italic.otf delete mode 100644 openecomp-ui/resources/fonts/omnes-att-bold.otf delete mode 100644 openecomp-ui/resources/fonts/omnes-att-italic.otf delete mode 100644 openecomp-ui/resources/fonts/omnes-att-light-Italic.otf delete mode 100644 openecomp-ui/resources/fonts/omnes-att-light.otf delete mode 100644 openecomp-ui/resources/fonts/omnes-att-medium-italic.otf delete mode 100644 openecomp-ui/resources/fonts/omnes-att-medium.otf delete mode 100644 openecomp-ui/resources/fonts/omnes-att-regular.otf create mode 100644 openecomp-ui/resources/images/artifacts_icon.png create mode 100644 openecomp-ui/resources/images/base_icon.png create mode 100644 openecomp-ui/resources/images/download_icon.png delete mode 100644 openecomp-ui/resources/images/ecomp/ASDC_Sprite.png delete mode 100644 openecomp-ui/resources/images/ecomp/sprite-services-icons.png create mode 100644 openecomp-ui/resources/images/icons/ZIP_blue_icon.png create mode 100644 openecomp-ui/resources/images/icons/ZIP_icon.png create mode 100644 openecomp-ui/resources/images/icons/artifacts_blue_icon.png create mode 100644 openecomp-ui/resources/images/icons/artifacts_grey_icon.png create mode 100644 openecomp-ui/resources/images/icons/back_icon.png create mode 100644 openecomp-ui/resources/images/icons/checked_in.png create mode 100644 openecomp-ui/resources/images/icons/checked_out.png create mode 100644 openecomp-ui/resources/images/icons/down_chevron.png create mode 100644 openecomp-ui/resources/images/icons/env_icon.png create mode 100644 openecomp-ui/resources/images/icons/env_icon_blue.png create mode 100644 openecomp-ui/resources/images/icons/error_icon_big.png create mode 100644 openecomp-ui/resources/images/icons/error_icon_small.png create mode 100644 openecomp-ui/resources/images/icons/go_to_overview_disable_icon.png create mode 100644 openecomp-ui/resources/images/icons/go_to_overview_icon.png create mode 100644 openecomp-ui/resources/images/icons/nested_HEAT_icon_blue.png create mode 100644 openecomp-ui/resources/images/icons/nested_heat_icon.png create mode 100644 openecomp-ui/resources/images/icons/network_blue_icon.png create mode 100644 openecomp-ui/resources/images/icons/network_icon.png create mode 100644 openecomp-ui/resources/images/icons/orphans_blue_icon-n.png create mode 100644 openecomp-ui/resources/images/icons/orphans_grey_icon.png create mode 100644 openecomp-ui/resources/images/icons/others_blue_icon.png create mode 100644 openecomp-ui/resources/images/icons/others_icon.png create mode 100644 openecomp-ui/resources/images/icons/pencil_icon-01.svg create mode 100644 openecomp-ui/resources/images/icons/plus_vlm_summary_disabled_icon.png create mode 100644 openecomp-ui/resources/images/icons/plus_vlm_summary_icon.png create mode 100644 openecomp-ui/resources/images/icons/plus_vlm_summary_icon_blue.png create mode 100644 openecomp-ui/resources/images/icons/revert_icon_disabled.png create mode 100644 openecomp-ui/resources/images/icons/reverticon.png create mode 100644 openecomp-ui/resources/images/icons/save_icon_disable.png create mode 100644 openecomp-ui/resources/images/icons/saveicon.png create mode 100644 openecomp-ui/resources/images/icons/submit_icon_disable.png create mode 100644 openecomp-ui/resources/images/icons/submiticonactive.png create mode 100644 openecomp-ui/resources/images/icons/vlm_list_view_blue_icon.png create mode 100644 openecomp-ui/resources/images/icons/vlm_list_view_grey_icon.png create mode 100644 openecomp-ui/resources/images/icons/volume_blue_icon.png create mode 100644 openecomp-ui/resources/images/icons/volume_icon.png create mode 100644 openecomp-ui/resources/images/icons/warning_icon_big.png create mode 100644 openecomp-ui/resources/images/icons/warning_icon_small.png create mode 100644 openecomp-ui/resources/images/module_icon.png delete mode 100644 openecomp-ui/resources/images/onboarding/vendor-license-model.svg delete mode 100644 openecomp-ui/resources/images/onboarding/vendor-software-product.svg create mode 100644 openecomp-ui/resources/images/pencil_icon-01.svg create mode 100644 openecomp-ui/resources/images/svg/angle-double-left.svg create mode 100644 openecomp-ui/resources/images/svg/angle-double-right.svg create mode 100644 openecomp-ui/resources/images/svg/angle-left.svg create mode 100644 openecomp-ui/resources/images/svg/angle-right.svg create mode 100644 openecomp-ui/resources/images/svg/back.svg create mode 100644 openecomp-ui/resources/images/svg/caret-down.svg create mode 100644 openecomp-ui/resources/images/svg/check-circle.svg create mode 100644 openecomp-ui/resources/images/svg/check.svg create mode 100644 openecomp-ui/resources/images/svg/chevron-down.svg create mode 100644 openecomp-ui/resources/images/svg/chevron-up.svg create mode 100644 openecomp-ui/resources/images/svg/close.svg create mode 100644 openecomp-ui/resources/images/svg/error-circle.svg create mode 100644 openecomp-ui/resources/images/svg/exclamation-triangle-full.svg create mode 100644 openecomp-ui/resources/images/svg/exclamation-triangle-line.svg create mode 100644 openecomp-ui/resources/images/svg/exclamation-triangle.svg create mode 100644 openecomp-ui/resources/images/svg/filter.svg create mode 100644 openecomp-ui/resources/images/svg/locked.svg create mode 100644 openecomp-ui/resources/images/svg/pencil.svg create mode 100644 openecomp-ui/resources/images/svg/plus-circle.svg create mode 100644 openecomp-ui/resources/images/svg/plus.svg create mode 100644 openecomp-ui/resources/images/svg/search.svg create mode 100644 openecomp-ui/resources/images/svg/sliders.svg create mode 100644 openecomp-ui/resources/images/svg/trash-o.svg create mode 100644 openecomp-ui/resources/images/svg/unlocked.svg create mode 100644 openecomp-ui/resources/images/svg/vendor.svg create mode 100644 openecomp-ui/resources/images/svg/version-controller-lock-closed.svg create mode 100644 openecomp-ui/resources/images/svg/version-controller-lock-open.svg create mode 100644 openecomp-ui/resources/images/svg/version-controller-revert.svg create mode 100644 openecomp-ui/resources/images/svg/version-controller-save.svg create mode 100644 openecomp-ui/resources/images/svg/version-controller-submit.svg create mode 100644 openecomp-ui/resources/images/svg/vlm.svg create mode 100644 openecomp-ui/resources/images/svg/vsp.svg create mode 100644 openecomp-ui/resources/images/trash_icon.png create mode 100644 openecomp-ui/resources/images/upload_icon.png create mode 100644 openecomp-ui/resources/images/v_icon.png create mode 100644 openecomp-ui/resources/scss/components/_activityLog.scss create mode 100644 openecomp-ui/resources/scss/components/_grid.scss create mode 100644 openecomp-ui/resources/scss/components/_icon.scss create mode 100644 openecomp-ui/resources/scss/components/_selectActionTable.scss delete mode 100644 openecomp-ui/resources/scss/components/_slidePanel.scss create mode 100644 openecomp-ui/resources/scss/components/_svgIcon.scss create mode 100644 openecomp-ui/resources/scss/modules/_licenseModelOverview.scss create mode 100644 openecomp-ui/resources/scss/modules/_softwareProductComponentCompute.scss create mode 100644 openecomp-ui/resources/scss/modules/_softwareProductComponentProcessesPage.scss create mode 100644 openecomp-ui/resources/scss/modules/_softwareProductDependencies.scss delete mode 100644 openecomp-ui/resources/scss/modules/_softwareProductNetworksPage.scss create mode 100644 openecomp-ui/resources/scss/modules/_vspHeatSetup.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogHeader.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogList.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogTile.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_createItemTile.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_onboardHeader.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_tile.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_vendorPageHeader.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_vendorTile.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_vlmTile.scss create mode 100644 openecomp-ui/resources/scss/modules/onboardingCatalog/_vspOverlay.scss create mode 100644 openecomp-ui/src/nfvo-components/activity-log/ActivityLog.js create mode 100644 openecomp-ui/src/nfvo-components/activity-log/ActivityLogActionHelper.js create mode 100644 openecomp-ui/src/nfvo-components/activity-log/ActivityLogConstants.js create mode 100644 openecomp-ui/src/nfvo-components/activity-log/ActivityLogReducer.js create mode 100644 openecomp-ui/src/nfvo-components/activity-log/ActivityLogView.jsx delete mode 100644 openecomp-ui/src/nfvo-components/confirmations/ConfirmationModalView.jsx create mode 100644 openecomp-ui/src/nfvo-components/grid/GridItem.jsx create mode 100644 openecomp-ui/src/nfvo-components/grid/GridSection.jsx create mode 100644 openecomp-ui/src/nfvo-components/icon/Icon.jsx create mode 100644 openecomp-ui/src/nfvo-components/icon/SVGIcon.jsx create mode 100644 openecomp-ui/src/nfvo-components/icon/SVGIcon.stories.js create mode 100644 openecomp-ui/src/nfvo-components/input/validation/Form.jsx create mode 100644 openecomp-ui/src/nfvo-components/input/validation/Input.jsx create mode 100644 openecomp-ui/src/nfvo-components/input/validation/InputOptions.jsx create mode 100644 openecomp-ui/src/nfvo-components/input/validation/InputWrapper.jsx create mode 100644 openecomp-ui/src/nfvo-components/input/validation/Tabs.jsx delete mode 100644 openecomp-ui/src/nfvo-components/input/validation/ValidationForm.jsx delete mode 100644 openecomp-ui/src/nfvo-components/input/validation/ValidationInput.jsx delete mode 100644 openecomp-ui/src/nfvo-components/input/validation/ValidationTab.jsx delete mode 100644 openecomp-ui/src/nfvo-components/input/validation/ValidationTabs.jsx create mode 100644 openecomp-ui/src/nfvo-components/listEditor/ListEditorItemViewField.jsx create mode 100644 openecomp-ui/src/nfvo-components/listEditor/listEditor.stories.js create mode 100644 openecomp-ui/src/nfvo-components/modal/GlobalModal.js create mode 100644 openecomp-ui/src/nfvo-components/modal/GlobalModalConstants.js create mode 100644 openecomp-ui/src/nfvo-components/modal/GlobalModalReducer.js delete mode 100644 openecomp-ui/src/nfvo-components/notifications/NotificationConstants.js delete mode 100644 openecomp-ui/src/nfvo-components/notifications/NotificationModal.jsx delete mode 100644 openecomp-ui/src/nfvo-components/notifications/NotificationReducer.js delete mode 100644 openecomp-ui/src/nfvo-components/panel/SlidePanel.jsx create mode 100644 openecomp-ui/src/nfvo-components/table/SelectActionTable.jsx create mode 100644 openecomp-ui/src/nfvo-components/table/SelectActionTableCell.jsx create mode 100644 openecomp-ui/src/nfvo-components/table/SelectActionTableRow.jsx create mode 100644 openecomp-ui/src/nfvo-utils/DirectedGraph.js create mode 100644 openecomp-ui/src/nfvo-utils/Validator.js create mode 100644 openecomp-ui/src/nfvo-utils/sortByStringProperty.js delete mode 100644 openecomp-ui/src/sdc-app/Test.jsx create mode 100644 openecomp-ui/src/sdc-app/common/helpers/ValidationHelper.js create mode 100644 openecomp-ui/src/sdc-app/common/modal/ModalContentMapper.js create mode 100644 openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js create mode 100644 openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js create mode 100644 openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js create mode 100644 openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js create mode 100644 openecomp-ui/src/sdc-app/heatvalidation/Attachments.js create mode 100644 openecomp-ui/src/sdc-app/heatvalidation/HeatSetup.js delete mode 100644 openecomp-ui/src/sdc-app/heatvalidation/UploadScreenConstants.js delete mode 100644 openecomp-ui/src/sdc-app/heatvalidation/UploadScreenReducer.js delete mode 100644 openecomp-ui/src/sdc-app/heatvalidation/attachments/Attachments.js delete mode 100644 openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsActionHelper.js delete mode 100644 openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsConstants.js delete mode 100644 openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsReducer.js delete mode 100644 openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsView.jsx delete mode 100644 openecomp-ui/src/sdc-app/onboarding/OnboardingCatalog.js delete mode 100644 openecomp-ui/src/sdc-app/onboarding/OnboardingCatalogView.jsx delete mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConfirmationModal.jsx delete mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConfirmationModal.jsx delete mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConfirmationModal.jsx delete mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConfirmationModal.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/licenseModelOverviewActionHelper.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/AdditionalDataCol.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ArrowCol.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/IconCol.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ItemInfo.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/LicenseModelDescriptionEdit.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountItem.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountList.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.stories.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/CatalogList.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/CatalogModal.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/CatalogTile.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/DetailsCatalogView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/OnboardConstants.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/OnboardReducer.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/OnboardView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogReducer.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogUtils.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/Tooltip.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogReducer.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/FinalizedSoftwareProductReducer.js delete mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js delete mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsUtils.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetup.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupReducer.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidation.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/GuestOs.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/NumberOfVms.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/VmSizing.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Acceptable.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/FlowLength.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/InFlowTraffic.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/IpConfig.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/NameAndPurpose.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Network.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/OutFlowTraffic.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/PacketsBytes.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Protocols.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Sizing.jsx delete mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesConfirmationModal.jsx create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesConstants.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesReducer.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesUtils.js create mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx delete mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageUploadConfirmationModal.jsx delete mode 100644 openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConfirmationModal.jsx create mode 100644 openecomp-ui/test-utils/factories/SubnitErrorMessageFactorie.js create mode 100644 openecomp-ui/test-utils/factories/activity-log/ActivityLogFactories.js create mode 100644 openecomp-ui/test-utils/factories/flows/FlowsFactories.js create mode 100644 openecomp-ui/test-utils/factories/flows/ParticipantFactory.js create mode 100644 openecomp-ui/test-utils/factories/flows/SequenceDiagramFactory.js create mode 100644 openecomp-ui/test-utils/factories/licenseModel/EntitlementPoolFactories.js create mode 100644 openecomp-ui/test-utils/factories/licenseModel/FeatureGroupFactories.js create mode 100644 openecomp-ui/test-utils/factories/licenseModel/LicenseAgreementFactories.js create mode 100644 openecomp-ui/test-utils/factories/licenseModel/LicenseKeyGroupFactories.js create mode 100644 openecomp-ui/test-utils/factories/licenseModel/LicenseModelFactories.js create mode 100644 openecomp-ui/test-utils/factories/mixins/IdMixin.js create mode 100644 openecomp-ui/test-utils/factories/mixins/RandomNameMixin.js create mode 100644 openecomp-ui/test-utils/factories/onboard/OnboardFactories.js create mode 100644 openecomp-ui/test-utils/factories/onboard/OnboardingCatalogFactories.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsStorageFactory.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductCreationFactories.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductDependenciesFactories.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductFactory.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/VSPCategoriesFactory.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js create mode 100644 openecomp-ui/test-utils/factories/softwareProduct/VspQdataFactory.js create mode 100644 openecomp-ui/test-utils/failedTestReport.js create mode 100644 openecomp-ui/test-utils/fileMock.js create mode 100644 openecomp-ui/test-utils/styleMock.js create mode 100644 openecomp-ui/test-utils/test-env-setup.js create mode 100644 openecomp-ui/test-utils/test-setup.js create mode 100644 openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js create mode 100644 openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js create mode 100644 openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js create mode 100644 openecomp-ui/test/licenseModel/overview/listItems/EntitlementPool.test.js create mode 100644 openecomp-ui/test/licenseModel/overview/listItems/FeatureGroup.test.js create mode 100644 openecomp-ui/test/licenseModel/overview/listItems/LicenseAgreement.test.js create mode 100644 openecomp-ui/test/licenseModel/overview/listItems/LicenseKeyGroup.test.js create mode 100644 openecomp-ui/test/licenseModel/overview/summary/SummaryCountList.test.js create mode 100644 openecomp-ui/test/licenseModel/overview/summary/VendorDataView.test.js create mode 100644 openecomp-ui/test/licenseModel/overview/test.js create mode 100644 openecomp-ui/test/licenseModel/overview/views.test.js create mode 100644 openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js create mode 100644 openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap create mode 100644 openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js create mode 100644 openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js create mode 100644 openecomp-ui/test/nfvo-components/input/validation/input.test.js create mode 100644 openecomp-ui/test/nfvo-components/modal/globalModal.test.js delete mode 100644 openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js create mode 100644 openecomp-ui/test/nfvo-components/storyshots.test.js create mode 100644 openecomp-ui/test/onboard/onboardingCatalog/test.js create mode 100644 openecomp-ui/test/onboard/onboardingCatalog/views.test.js create mode 100644 openecomp-ui/test/onboard/test.js delete mode 100644 openecomp-ui/test/setup.test.js delete mode 100644 openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js create mode 100644 openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js create mode 100644 openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js create mode 100644 openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js create mode 100644 openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js create mode 100644 openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js create mode 100644 openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js create mode 100644 openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js create mode 100644 openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js create mode 100644 openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js create mode 100644 openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js create mode 100644 openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js delete mode 100644 openecomp-ui/test/utils/restApiUtil.test.js create mode 100644 openecomp-ui/test/utils/validator.test.js delete mode 100644 openecomp-ui/tests.webpack.js create mode 100644 openecomp-ui/webpack.common.js create mode 100644 openecomp-ui/webpack.production.js (limited to 'openecomp-ui') diff --git a/openecomp-ui/.babelrc b/openecomp-ui/.babelrc index 635081d464..76f4b82867 100644 --- a/openecomp-ui/.babelrc +++ b/openecomp-ui/.babelrc @@ -1,10 +1,12 @@ { - "presets": ["stage-0", "react"], + "presets": [["es2015", { "modules": false }],"stage-0", "react"], "plugins": [ "transform-es2015-modules-commonjs", "transform-es2015-destructuring", "transform-es2015-spread", "transform-object-rest-spread", - "transform-class-properties" - ] + "transform-class-properties", + "transform-runtime" + ], + "sourceMap": "inline" } diff --git a/openecomp-ui/.editorconfig b/openecomp-ui/.editorconfig index fcdada6db0..12b7eb2b05 100644 --- a/openecomp-ui/.editorconfig +++ b/openecomp-ui/.editorconfig @@ -13,6 +13,7 @@ insert_final_newline = true # tab indentation [src/**.js] [src/**.jsx] +[resources/scss] indent_style = tab diff --git a/openecomp-ui/.eslintrc b/openecomp-ui/.eslintrc index da8a422df3..63da329372 100644 --- a/openecomp-ui/.eslintrc +++ b/openecomp-ui/.eslintrc @@ -4,7 +4,7 @@ "es6": true, "jquery": true, "node": true, - "mocha": true + "jest": true }, "plugins": [ "react", diff --git a/openecomp-ui/.gitignore b/openecomp-ui/.gitignore index cce0a545f7..7704a027fe 100644 --- a/openecomp-ui/.gitignore +++ b/openecomp-ui/.gitignore @@ -1,7 +1,14 @@ .idea - +.vscode +debug.log dist node_modules devConfig.json .npmrc +test/coverage +npm-debug.log +**/.DS_Store +coverage +.storybook-dist +.storybook/resources diff --git a/openecomp-ui/.storybook/addons.js b/openecomp-ui/.storybook/addons.js new file mode 100644 index 0000000000..c7ad1fdfc2 --- /dev/null +++ b/openecomp-ui/.storybook/addons.js @@ -0,0 +1,3 @@ +import '@kadira/storybook/addons'; +import '@kadira/storybook-addon-knobs/register'; +import '@kadira/storybook-addon-options/register'; \ No newline at end of file diff --git a/openecomp-ui/.storybook/config.js b/openecomp-ui/.storybook/config.js new file mode 100644 index 0000000000..94e9855fa2 --- /dev/null +++ b/openecomp-ui/.storybook/config.js @@ -0,0 +1,27 @@ +import React from 'react'; +import {configure, addDecorator} from '@kadira/storybook'; +import {withKnobs} from '@kadira/storybook-addon-knobs'; +import { setOptions } from '@kadira/storybook-addon-options'; +import './storybook.scss'; +import '../resources/scss/onboarding.scss'; + + +const req = require.context('../src', true, /.stories.js$/) +const namespaceDecorator = (story) => ( +
+ {story()} +
+); + +addDecorator(namespaceDecorator); + +setOptions({ + name: 'custom', + downPanelInRight: true +}); + +function loadStories() { + req.keys().forEach((filename) => req(filename)) +} + +configure(loadStories, module); \ No newline at end of file diff --git a/openecomp-ui/.storybook/fonts/omnes-att-bold.otf b/openecomp-ui/.storybook/fonts/omnes-att-bold.otf new file mode 100644 index 0000000000..136afca84c Binary files /dev/null and b/openecomp-ui/.storybook/fonts/omnes-att-bold.otf differ diff --git a/openecomp-ui/.storybook/fonts/omnes-att-light.ttf b/openecomp-ui/.storybook/fonts/omnes-att-light.ttf new file mode 100644 index 0000000000..273761ab3d Binary files /dev/null and b/openecomp-ui/.storybook/fonts/omnes-att-light.ttf differ diff --git a/openecomp-ui/.storybook/fonts/omnes-att-medium.ttf b/openecomp-ui/.storybook/fonts/omnes-att-medium.ttf new file mode 100644 index 0000000000..2740425412 Binary files /dev/null and b/openecomp-ui/.storybook/fonts/omnes-att-medium.ttf differ diff --git a/openecomp-ui/.storybook/fonts/omnes-att-regular.ttf b/openecomp-ui/.storybook/fonts/omnes-att-regular.ttf new file mode 100644 index 0000000000..2342be4be5 Binary files /dev/null and b/openecomp-ui/.storybook/fonts/omnes-att-regular.ttf differ diff --git a/openecomp-ui/.storybook/storybook.scss b/openecomp-ui/.storybook/storybook.scss new file mode 100644 index 0000000000..ed63bb9ab5 --- /dev/null +++ b/openecomp-ui/.storybook/storybook.scss @@ -0,0 +1,32 @@ +$PORT: '9090'; +$PROD_MACHINE: '10.147.92.78'; + +@font-face { + font-family: omnes-light; + src: url('http://localhost:#{$PORT}/omnes-att-light.ttf'), + url('http://#{$PROD_MACHINE}:#{$PORT}/omnes-att-light.ttf'); +} + +@font-face { + font-family: omnes-regular; + src: url('http://localhost:#{$PORT}/omnes-att-regular.ttf'), + url('http://#{$PROD_MACHINE}:#{$PORT}/omnes-att-regular.ttf'); +} + +@font-face { + font-family: omnes-medium; + src: url('http://localhost:#{$PORT}/omnes-att-medium.ttf'), + url('http://#{$PROD_MACHINE}:#{$PORT}/omnes-att-medium.ttf'); +} + +@font-face { + font-family: omnes-bold; + src: url('http://localhost:#{$PORT}/omnes-att-bold.otf'), + url('http://#{$PROD_MACHINE}:#{$PORT}/omnes-att-bold.otf'); +} + +body { + @import '../resources/scss/bootstrap.scss'; + font-family: omnes-medium,sans-serif; + font-size: 14px; +} \ No newline at end of file diff --git a/openecomp-ui/.storybook/webpack.config.js b/openecomp-ui/.storybook/webpack.config.js new file mode 100644 index 0000000000..aeb97c1b5a --- /dev/null +++ b/openecomp-ui/.storybook/webpack.config.js @@ -0,0 +1,17 @@ +var ASDCConfig = require('../webpack.common.js'); + +module.exports = function(baseConfig, configType) { + baseConfig.module.loaders = baseConfig.module.loaders.concat([ + {test: /\.(css|scss)$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap']}, + + // 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'}, + + {test: /\.json$/, loaders: ['json']}, + {test: /\.html$/, loaders: ['html']} + ]); + baseConfig.resolve = { root: ASDCConfig.resolve.modules, alias: ASDCConfig.resolve.alias }; + return baseConfig; +} diff --git a/openecomp-ui/LICENSE b/openecomp-ui/LICENSE index 2507db8a57..5628b9ace4 100644 --- a/openecomp-ui/LICENSE +++ b/openecomp-ui/LICENSE @@ -1 +1 @@ -(c) Copyright 2016 ECOMP, all rights reserved. +(c) Copyright 2016 OPENECOMP, all rights reserved. diff --git a/openecomp-ui/README.md b/openecomp-ui/README.md new file mode 100644 index 0000000000..cb103ce889 --- /dev/null +++ b/openecomp-ui/README.md @@ -0,0 +1,34 @@ +# ASDC - Amdocs Onboard UI App + +## Setup + +##### Install `nodejs`: + +download nodejs from here: https://nodejs.org/en/ (take the "current" version with latest features) & install it. +##### Install `gulp` + +install gulp by running the following command `npm install --global gulp-cli` + +##### Install DOX-UI +* pull for latest changes +* go to folder `dox-sequence-diagram-ui` +* run `npm install` +* wait for it... +* go to folder `openecomp-ui` +* run `npm install` +* create a copy of `devConfig.defaults.json` file and name it `devConfig.json` (we already configured git to ignore it so it will not be pushed) +in that file. + + populate the fields of the IP addresses of your BE machine you'd like to connect (**pay attention, it is a JSON file**): + + For example *http://\:\* +* run `npm start` +* your favorite UI will wait for you at: `http://localhost:9000/sdc1/proxy-designer1#/onboardVendor` + + + +#### Troubleshooting +Problem | Why is this happening | Solution +------- | --------------------- | -------- +npm cannot reach destination | proxy | When within managed network, you should set your proxy to NPM as the following:
`npm config set proxy http://:`
`npm config set https-proxy http://:` +git protocol is blocked and cannot connect | managed network rules for protocols | When within managed network, you should set globally that when git protocol is used, then it will be replaced with "https"
`git config --global url."https://".insteadOf git://` diff --git a/openecomp-ui/devConfig.defaults.json b/openecomp-ui/devConfig.defaults.json index bfcf9aae8f..46f0d189e8 100644 --- a/openecomp-ui/devConfig.defaults.json +++ b/openecomp-ui/devConfig.defaults.json @@ -2,5 +2,9 @@ "port": 9000, "proxyATTTarget": null, "proxyTarget": null, - "useFixture": false + "bundles": { + "bundle": ["sdc-app/sdc.app.jsx"], + "punch-outs": ["sdc-app/punch-outs.js"], + "heat-validation": ["sdc-app/heatValidation.app.jsx"] + } } diff --git a/openecomp-ui/fixture/data/entitlementPools.json b/openecomp-ui/fixture/data/entitlementPools.json deleted file mode 100644 index 22750cbb6d..0000000000 --- a/openecomp-ui/fixture/data/entitlementPools.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "results":[ - { - "name": "ep1", - "description": "string", - "thresholdValue": 75, - "thresholdUnits": "%", - "entitlementMetric": {"choice": "User", "other":""}, - "increments": "string", - "aggregationFunction": {"choice": "Average", "other": ""}, - "operationalScope": {"choices": ["VM"], "other": ""}, - "time": {"choice": "Hour", "other": ""}, - "sku": "DEF2-385A-4521-AAAA", - "id": "1", - "referencingFeatureGroups": ["1","2"], - "partNumber": "51529" - }, - { - "name": "ep2", - "description": "string", - "thresholdValue": 99, - "thresholdUnits": "%", - "entitlementMetric": {"choice": "User", "other":""}, - "increments": "string", - "aggregationFunction": {"choice": "Average", "other": ""}, - "operationalScope": {"choices": ["Other"], "other": "blabla"}, - "time": {"choice": "Hour", "other": ""}, - "sku": "DEF2-385A-4521-AAAA", - "id": "2", - "refCount": 0, - "partNumber": "51529", - "referencingFeatureGroups": [] - } - ] -} - diff --git a/openecomp-ui/fixture/data/featureGroup.json b/openecomp-ui/fixture/data/featureGroup.json deleted file mode 100644 index 278baecb36..0000000000 --- a/openecomp-ui/fixture/data/featureGroup.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "name": "fssss", - "description": "gdfgdfgdsfg", - "id": "1", - "licenseKeyGroupsIds": [ - "1,2" - ], - "entitlementPoolsIds": [ - "1,2" - ], - "licenseKeyGroups": [ - { - "name": "ls1", - "description": "string", - "type": "string", - "operationalScope": "string", - "id": "1", - "refCount": 0 - }, - { - "name": "ls2", - "description": "string", - "type": "string", - "operationalScope": "string", - "id": "1", - "refCount": 0 - } - ], - "entitlementPools": [ - { - "name": "ep1", - "description": "string", - "thresholdValue": 0, - "thresholdUnits": "string", - "entitlementMetric": "string", - "increments": "string", - "aggregationFunction": "string", - "operationalScope": "string", - "time": "string", - "sku": "string", - "id": "string", - "refCount": 0 - }, - { - "name": "ep2", - "description": "string", - "thresholdValue": 0, - "thresholdUnits": "string", - "entitlementMetric": "string", - "increments": "string", - "aggregationFunction": "string", - "operationalScope": "string", - "time": "string", - "sku": "string", - "id": "string", - "refCount": 0 - } - ] -} diff --git a/openecomp-ui/fixture/data/featureGroups.json b/openecomp-ui/fixture/data/featureGroups.json deleted file mode 100644 index eea4967ca8..0000000000 --- a/openecomp-ui/fixture/data/featureGroups.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "results": [ - { - "name": "fs1", - "id": "0", - "description": "fs1-description", - "licenseKeyGroupsIds": [ - "1" - ], - "entitlementPoolsIds": [ - "1" - ], - "referencingLicenseAgreements": ["1","2"] - }, - { - "name": "fs2", - "id": "1", - "description": "fs2-description", - "licenseKeyGroupsIds": [ - "2" - ], - "entitlementPoolsIds": [ - "2" - ], - "referencingLicenseAgreements": [] - } - ] -} diff --git a/openecomp-ui/fixture/data/licenseAgreementList.json b/openecomp-ui/fixture/data/licenseAgreementList.json deleted file mode 100644 index b113295fcb..0000000000 --- a/openecomp-ui/fixture/data/licenseAgreementList.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "results": [ - { - "name": "name0", - "description": "description0", - "licenseTerm": {"choice": "Other", "other": "blabla"}, - "requirementsAndConstrains": "requirementsAndConstrains0", - "featureGroupsIds": [], - "id": "0" - }, - { - "name": "name1", - "description": "description1", - "licenseTerm": {"choice": "Fixed_Term", "other": ""}, - "requirementsAndConstrains": "requirementsAndConstrains1", - "featureGroupsIds": [ - "1" - ], - "id": "1" - }, - { - "name": "name2", - "description": "description2", - "licenseTerm": {"choice": "Unlimited", "other": ""}, - "requirementsAndConstrains": "requirementsAndConstrains2", - "featureGroupsIds": [ - "2" - ], - "id": "2" - } - ], - "listCount": 3 -} diff --git a/openecomp-ui/fixture/data/licenseKeyGroups.json b/openecomp-ui/fixture/data/licenseKeyGroups.json deleted file mode 100644 index 74050ab033..0000000000 --- a/openecomp-ui/fixture/data/licenseKeyGroups.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "results":[ - { - "name": "lsk1", - "description": "string", - "type": "Unique", - "operationalScope": {"choices": ["Network_Wide","VM"], "other": ""}, - "id": "1", - "referencingFeatureGroups":["1","2"] - }, - { - "name": "lsk2", - "description": "string", - "type": "One_Time", - "operationalScope": {"choices": ["Other"], "other": "blabla"}, - "id": "2", - "referencingFeatureGroups": 0 - } - ] -} diff --git a/openecomp-ui/fixture/data/licenseModels.json b/openecomp-ui/fixture/data/licenseModels.json deleted file mode 100644 index 5239c4fafc..0000000000 --- a/openecomp-ui/fixture/data/licenseModels.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "results":[ - { - "vendorName": "Omer Corp.", - "description": "", - "iconRef": "string", - "id": "1" - }, - { - "vendorName": "Robotricks", - "description": "Optimus Prime", - "iconRef": "string", - "id": "2" - } - ] -} diff --git a/openecomp-ui/fixture/data/softwareProduct.json b/openecomp-ui/fixture/data/softwareProduct.json deleted file mode 100644 index 5b60587614..0000000000 --- a/openecomp-ui/fixture/data/softwareProduct.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "name": "VSP5", - "version": "0.1", - "id": "4730033D16C64E3CA556AB0AC4478218", - "description": "A software model for Fortigate. Nam hendrerit sollicitudin semper. Aenean consectetur nisi sit amet ante sodales consectetur. Nullam rutrum massa in pellentesque ' +elementum. Aliquam efficitur tellus lacus, eget iaculis justo iaculis eu. ", - "categoryId": "category", - "vendorId": "1", - "checkinStatus": "CHECK_OUT", - "licensingData": "test data", - "validationData": { - "logicalStructure": [ - { - "type": "PPD", - "catalogInstances": [ - { - "name": "PPD1", - "artifacts": [ - { - "name": "chopstick.py" - }, - { - "name": "bread.py" - } - ] - } - ] - } - ], - "importStructure": { - "HEAT": [ - { - "fileName": "sushi.yml", - "env": "soy.env", - "nested": [ - { - "fileName": "salmon.yml", - "env": "skin.env", - "artifacts": [ - { - "name": "rice.py", - "status": "OK" - }, - { - "name": "tuna.py", - "status": "Missing" - } - ] - } - ], - "artifacts": [ - { - "name": "chopstick.py", - "status": "OK" - }, - { - "name": "bread.py", - "status": "Missing" - } - ], - "volume": [ - { - "fileName": "fishtank.yml", - "env": "middletown.env" - } - ], - "network": [ - { - "fileName": "fishnet.yml", - "env": "ship.env" - } - ] - } - ], - "volume": [ - { - "fileName": "vol1.yml", - "env": "e1.env" - }, - { - "fileName": "vol2.yml", - "env": "e2.env" - } - ], - "network": [ - { - "fileName": "net1.yml", - "env": "env1.env" - }, - { - "fileName": "net2.yml", - "env": "env2.env" - } - ] - } - } -} diff --git a/openecomp-ui/fixture/data/softwareProductList.json b/openecomp-ui/fixture/data/softwareProductList.json deleted file mode 100644 index 4554abc95f..0000000000 --- a/openecomp-ui/fixture/data/softwareProductList.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "results": [ - { - "name": "Software Product 1", - "version": "1.0", - "id": "1", - "category": "Category1", - "subCategory": "Sub Category1", - "vendor": "1", - "status": "string", - "checkinStatus": "string" - }, - { - "name": "Software Product 2", - "version": "1.0", - "id": "2", - "category": "Category2", - "subCategory": "Sub Category2", - "vendor": "2", - "status": "string", - "checkinStatus": "string" - }, - { - "name": "Software Product 3", - "version": "1.0", - "id": "3", - "category": "Category3", - "subCategory": "Sub Category3", - "vendor": "3", - "status": "string", - "checkinStatus": "string" - } - ] -} diff --git a/openecomp-ui/fixture/express.js b/openecomp-ui/fixture/express.js deleted file mode 100644 index ed8bf956f9..0000000000 --- a/openecomp-ui/fixture/express.js +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -var args = process.argv.slice(2); - -function defineRoutes(router) { - - //LICENSE-MODELS - router.get('/v1.0/vendor-license-models', licenseModelsList); - - //FEATURE-GROUP - router.get('/v1.0/vendor-license-models/:licenseModelId/feature-groups', featureGroupList); - router.get('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', featureGroup); - router.post('/v1.0/vendor-license-models/:licenseModelId/feature-groups', addFeatureGroup); - router.delete('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', deletefeatureGroup); - router.put('/v1.0/vendor-license-models/:licenseModelId/feature-groups/:featureGroupId', updatefeatureGroup); - - - - //LICENSE-AGREEMENT - router.get('/v1.0/vendor-license-models/:licenseModelId/license-agreements', licenseAgreementList); - router.post('/v1.0/vendor-license-models/:licenseModelId/license-agreements/', addLicenseAgreement); - router.delete('/v1.0/vendor-license-models/:licenseModelId/license-agreements/:licenseAgreementId', deleteLicenseAgreement); - router.put('/v1.0/vendor-license-models/:licenseModelId/license-agreements/:licenseAgreementId', updateLicenseAgreement); - - //ENTITLEMENT POOLS - router.get('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools', entitlementPoolsList); - router.post('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools', addEntitlementPool); - router.put('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools/:entitlementPoolId', updateEntitlementPool); - router.delete('/v1.0/vendor-license-models/:licenseModelId/entitlement-pools/:entitlementPoolId', deleteEntitlementPool); - - //LICENSE KEY GROUPS - router.get('/v1.0/vendor-license-models/:licenseModelId/license-key-groups', licenseKeyGroupsList); - router.post('/v1.0/vendor-license-models/:licenseModelId/license-key-groups', addLicenseKeyGroup); - router.delete('/v1.0/vendor-license-models/:licenseModelId/license-key-groups/:licenseKeyGroupId', deleteLicenseKeyGroup); - router.put('/v1.0/vendor-license-models/:licenseModelId/license-key-groups/:licenseKeyGroupId', updateLicenseKeyGroup); - - //VENDOR SOFTWARE PRODUCT - - router.post('/v1.0/vendor-software-products/:vspId/upload', softwareProductUpload); - router.get('/v1.0/vendor-software-products/:vspId', getSoftwareProduct); - router.get('/v1.0/vendor-software-products', softwareProductList); - - router.put('/v1.0/vendor-software-products/:vspId/processes/:prcId', putSoftwareProductProcess); - router.post('/v1.0/vendor-software-products/:vspId/processes', postSoftwareProductProcess); -} - - -function licenseModelsList(req, res) { - res.json(require('./data/licenseModels')); -} - -function featureGroupList(req, res) { - res.json(require('./data/featureGroups')); -} - -function featureGroup(req, res) { - res.json(require('./data/featureGroup')); -} - -function deletefeatureGroup(req, res) { - res.json({ - returnCode: 'OK' - }); -} - - -function updatefeatureGroup(req, res) { - res.json({ - returnCode: 'OK' - }); -} - -function addFeatureGroup(req,res) { - var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); - res.json({ - returnCode: 'OK', - value: id - }) -} - -/** ENTITLEMENT POOLS **/ -function entitlementPoolsList(req, res) { - res.json(require('./data/entitlementPools')); -} - -function updateEntitlementPool(req, res) { - res.json({ - returnCode: 'OK' - }); -} - -function addEntitlementPool(req,res) { - var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); - res.json({ - returnCode: 'OK', - value: id - }) -} - -function deleteEntitlementPool(req, res) { - res.json({ - returnCode: 'OK' - }); -} - -/** LICENSE KEY GROUPS */ - -function licenseKeyGroupsList(req, res) { - res.json(require('./data/licenseKeyGroups')); -} - -function addLicenseKeyGroup(req,res) { - var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); - res.json({ - returnCode: 'OK', - value: id - }) -} - -function deleteLicenseKeyGroup(req, res) { - res.json({ - returnCode: 'OK' - }); -} - -function updateLicenseKeyGroup(req, res) { - res.json({ - returnCode: 'OK' - }); -} - -function licenseAgreementList(req, res) { - res.json(require('./data/licenseAgreementList')); -} - - -function addLicenseAgreement(req,res) { - var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); - res.json({ - returnCode: 'OK', - value: id - }) -} -function deleteLicenseAgreement(req, res) { - res.json({ - returnCode: 'OK' - }); -} -function updateLicenseAgreement(req, res) { - res.json({ - returnCode: 'OK' - }); -} - -/** VENDOR SOFTWARE PRODUCT */ - -function softwareProductUpload(req, res) { - res.json({ - status: 'SUCCESS' - }); -} - -function getSoftwareProduct(req, res) { - res.json(require('./data/softwareProduct')); -} - - -function putSoftwareProductProcess(req, res) { - res.json({ - status: 'SUCCESS' - }); -} - -function postSoftwareProductProcess(req, res) { - var id = Math.floor(Math.random() * (100 - 1) + 1).toString(); - res.json({ - returnCode: 'OK', - value: id - }); -} - - - - -function createFixtureServer(port) { - var express = require('express'); - var app = express(); - var bodyParser = require('body-parser'); - app.use(bodyParser.urlencoded({extended: true})); - app.use(bodyParser.json()); - - var router = express.Router(); - - defineRoutes(router); - - app.use('/api', router); - app.use('/onboarding-api', router); - app.use('/sdc1/feProxy/onboarding-api', router); - - app.listen(port); - - console.log('Fixture server is up. port->', port); - //console.log(router.stack); - return app; -} - -/** SOFTWARE PRODUCT LIST **/ -function softwareProductList(req, res) { - res.json(require('./data/softwareProductList')); -} - - -createFixtureServer(args[0]); diff --git a/openecomp-ui/fixture/fixture.js b/openecomp-ui/fixture/fixture.js deleted file mode 100644 index 7e5b263c5c..0000000000 --- a/openecomp-ui/fixture/fixture.js +++ /dev/null @@ -1,93 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -'use strict'; - -const PORT = 4000; - -function startFixtureServer() { - return require('child_process').fork('fixture/express', [PORT]); -} - -function buildProxyMiddleware() { - return require('./middleware')(PORT); -} - -function getProxyData(fixtureServerOptions, req, res, next) { - if (!fixtureServerOptions.serverProcess) { - fixtureServerOptions.serverProcess = startFixtureServer(); - } - - return fixtureServerOptions.proxy(req, res, next); -} - -function wrapFixture(fixtureServerOptions, req, res, next) { - if (fixtureServerOptions.proxy) { - return getProxyData(fixtureServerOptions, req, res, next); - } else { - next(); - } -} - - -module.exports = function fixture(options) { - - let proxy; - if(options.enabled) { - proxy = buildProxyMiddleware(); - } - - let fixtureServerOptions = { - proxy, - serverProcess: null - }; - - (function startWatch() { - var nodeWatch = require('node-watch'); - - nodeWatch(['fixture/data', 'fixture/express.js'], function () { - if (fixtureServerOptions.proxy && fixtureServerOptions.serverProcess) { - fixtureServerOptions.serverProcess.kill(); - fixtureServerOptions.serverProcess = startFixtureServer(); - } - }); - - nodeWatch(['devConfig.json'], function () { - let devConfigDefaults = require('../devConfig.defaults'); - require('fs').readFile('devConfig.json', (err, data) => { - if (err) throw err; - const config = Object.assign({}, devConfigDefaults, JSON.parse(data)); - if (config.useFixture) { - fixtureServerOptions.proxy = proxy || buildProxyMiddleware(); - } - else { - fixtureServerOptions.proxy = null; - if (fixtureServerOptions.serverProcess) { - fixtureServerOptions.serverProcess.kill(); - fixtureServerOptions.serverProcess = null; - } - } - }); - }); - - })(); - - return (req, res, next) => wrapFixture(fixtureServerOptions, req, res, next); -}; diff --git a/openecomp-ui/fixture/middleware.js b/openecomp-ui/fixture/middleware.js deleted file mode 100644 index 915bb81cab..0000000000 --- a/openecomp-ui/fixture/middleware.js +++ /dev/null @@ -1,24 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -module.exports = function createProxyMiddleware(port) { - var proxy = require('http-proxy-middleware'); - return proxy(['/api', '/onboarding-api'], {target: 'http://localhost:' + port}); -}; diff --git a/openecomp-ui/gulpfile.js b/openecomp-ui/gulpfile.js index 57885ec6ca..2cad6d8520 100644 --- a/openecomp-ui/gulpfile.js +++ b/openecomp-ui/gulpfile.js @@ -1,292 +1,101 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - 'use strict'; -var path = require('path'); -var gulp = require('gulp'); -var gulpHelpers = require('gulp-helpers'); -var taskMaker = gulpHelpers.taskMaker(gulp); -var _ = gulpHelpers.framework('_'); -var runSequence = gulpHelpers.framework('run-sequence'); -var i18nTask = require('./tools/gulp/tasks/i18n'); -var prodTask = require('./tools/gulp/tasks/prod'); -var gulpCssUsage = require('gulp-css-usage').default; -var webpack = require('webpack'); -var WebpackDevServer = require('webpack-dev-server'); +let gulp = require('gulp'); +let gulpHelpers = require('gulp-helpers'); +let replace = require('gulp-replace'); +let taskMaker = gulpHelpers.taskMaker(gulp); +let runSequence = gulpHelpers.framework('run-sequence'); +let i18nTask = require('./tools/gulp/tasks/i18n'); +let prodTask = require('./tools/gulp/tasks/prod'); +let gulpCssUsage = require('gulp-css-usage').default; +let jsonConfig = { + "appContextPath" : "/onboarding" +}; -var localDevConfig = {}; try { - localDevConfig = require('./devConfig'); + jsonConfig = require('./src/sdc-app/config/config.json'); } catch (e) { + console.log('could not load config. using deault value instead'); } -var devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig); -var webpackConfig = require('./webpack.config'); - -function defineTasks(mode) { - let appName = 'onboarding'; - let dist = 'dist/' + mode + '/'; - - let path = { - locales: 'i18n/', - jssource: 'src/**/*.js', - jsxsource: 'src/**/*.jsx', - html: '**/*.html', - output: dist, - assets: './resources/**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', - json: './src/**/*.json', - index: './src/index.html', - heat: './src/heat.html', - watch: ['./src/**'], - scss: './resources/scss/**/*.scss', - css: dist + '/css', - war: [dist + 'index.html', dist + 'punch-outs_en.js', dist + '**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', dist + '**/*(config.json|locale.json)', 'tools/gulp/deployment/**', 'webapp-onboarding/**'], - heatWar: [dist + 'heat.html', dist + 'heat-validation_en.js', dist + '**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', dist + '**/*(config.json|locale.json)', 'webapp-heat-validation/**'], - wardest: 'dist/' - }; - - taskMaker.defineTask('clean', {taskName: 'clean', src: path.output}); - taskMaker.defineTask('copy', {taskName: 'copy-assets', src: path.assets, dest: path.output}); - taskMaker.defineTask('copy', { - taskName: 'copy-json', - src: path.json, - dest: path.output, - changed: {extension: '.json'} - }); - taskMaker.defineTask('copy', { - taskName: 'copy-index.html', - src: path.index, - dest: path.output, - rename: 'index.html' - }); - taskMaker.defineTask('copy', { - taskName: 'copy-heat.html', - src: path.heat, - dest: path.output, - rename: 'heat.html' - }); - taskMaker.defineTask('sass', { - taskName: 'sass', - src: path.scss, - dest: path.css, - config: {outputStyle: 'compressed'} - }); - taskMaker.defineTask('compress', { - taskName: 'compress-war', - src: path.war, - filename: appName + '.war', - dest: path.wardest - }); - taskMaker.defineTask('compress', { - taskName: 'compress-heat-war', - src: path.heatWar, - filename: 'heat-validation.war', - dest: path.wardest - }); - taskMaker.defineTask('watch', { - taskName: 'watch-stuff', - src: [path.assets, path.json, path.index, path.heat], - tasks: ['copy-stuff'] - }); - taskMaker.defineTask('watch', {taskName: 'watch-sass', src: path.scss, tasks: ['sass']}); - - gulp.task('copy-stuff', callback => { - return runSequence(['copy-assets', 'copy-json', 'copy-index.html', 'copy-heat.html'], callback); - }); - - gulp.task('i18n', () => { - return i18nTask({ - outputPath: path.output, - localesPath: path.locales, - lang: 'en' - }).catch(err => { - console.log('i18n Task : Error! ', err); - throw err; - }); - }); - - - gulp.task('dependencies', () => { - //TODO: - }); - -} - -gulp.task('dev', callback => { - defineTasks('dev'); - return runSequence('clean', ['i18n', 'copy-stuff'], 'webpack-dev-server', ['watch-stuff'], callback); -}); - -// Production build -gulp.task('build', callback => { - defineTasks('prod'); - return runSequence('clean', ['copy-stuff', 'i18n'], 'prod', ['compress-war', 'compress-heat-war'], callback); -}); - -gulp.task('default', ['dev']); -gulp.task('prod', () => { - - // configure webpack for production - let webpackProductionConfig = Object.create(webpackConfig); - - for (let name in webpackProductionConfig.entry) { - webpackProductionConfig.entry[name] = webpackProductionConfig.entry[name].filter(path => !path.startsWith('webpack')); - } - - webpackProductionConfig.cache = true; - webpackProductionConfig.output = { - path: path.join(__dirname, 'dist/prod'), - publicPath: '/onboarding/', - filename: '[name].js' - }; - webpackProductionConfig.resolveLoader = { - root: [path.resolve('.')], - alias: { - 'config-json-loader': 'tools/webpack/config-json-loader/index.js' - } - }; - - // remove source maps - webpackProductionConfig.devtool = undefined; - webpackProductionConfig.module.preLoaders = webpackProductionConfig.module.preLoaders.filter(preLoader => preLoader.loader != 'source-map-loader'); - webpackProductionConfig.module.loaders.forEach(loader => { - if (loader.loaders && loader.loaders[0] === 'style') { - loader.loaders = loader.loaders.map(loaderName => loaderName.replace('?sourceMap', '')); - } - }); - - webpackProductionConfig.module.loaders.push({test: /config.json$/, loaders: ['config-json-loader']}); - webpackProductionConfig.eslint = { - configFile: './.eslintrc', - failOnError: true - }; - webpackProductionConfig.babel = {//TODO: remove this when UglifyJS will support user or - // Webpack 2.0 - presets: ['es2015', 'stage-0', 'react'] - } - webpackProductionConfig.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.DedupePlugin(), - new webpack.optimize.UglifyJsPlugin() - ]; - - // run production build - return prodTask({ - webpackProductionConfig, - outDir: 'dist/prod' - }) - .then(() => { +const appName = 'onboarding'; +const dist = 'dist'; + +const path = { + jetty: './webapp-onboarding/WEB-INF/jetty-web.xml', + appinf: './webapp-onboarding/**/*.*', + appinf_output: dist + '/webapp-onboarding', + locales: dist + '/i18n/', + output: dist, + json: './src/**/*.json', + index: './src/index.html', + heat: './src/heat.html', + scss: './resources/scss/**/*.scss', + css: dist + '/css', + svgSrc: './resources/images/svg/*.svg', + svg: dist + '/resources/images/svg', + war: [dist + '/index.html', dist + '/punch-outs_en.js', dist + '/**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', dist + '/**/*(config.json|locale.json)', 'tools/gulp/deployment/**', dist + '/webapp-onboarding/**'], + heatWar: [dist + '/heat.html', dist + '/heat-validation_en.js', dist + '/**/*.{css,png,svg,eot,ttf,woff,woff2,otf}', dist + '/**/*(config.json|locale.json)', 'webapp-heat-validation/**'], + wardest: dist, + storybookFonts: './.storybook/fonts/*', + storybookDist: './.storybook-dist', + storybookResources: './.storybook/resources/onboarding/resources/images/svg', + storybookDistResources: './.storybook-dist/onboarding/resources/images/svg' +}; + +taskMaker.defineTask('clean', {taskName: 'clean', src: path.output}); +taskMaker.defineTask('copy', {taskName: 'copy-json', src: path.json, dest: path.output, changed: {extension: '.json'}}); +taskMaker.defineTask('copy', {taskName: 'copy-index.html', src: path.index, dest: path.output, rename: 'index.html'}); +taskMaker.defineTask('copy', {taskName: 'copy-heat.html', src: path.heat, dest: path.output, rename: 'heat.html'}); +taskMaker.defineTask('copy', {taskName: 'copy-svg', src: path.svgSrc, dest: path.svg}); +//TODO: delete this task after gulp-css-usage support for SCSS files +taskMaker.defineTask('sass', {taskName: 'sass', src: path.scss, dest: path.css, config: {outputStyle: 'compressed'}}); +taskMaker.defineTask('compress', {taskName: 'compress-war', src: path.war, filename: appName + '.war', dest: path.wardest}); +taskMaker.defineTask('compress', {taskName: 'compress-heat-war', src: path.heatWar, filename: 'heat-validation.war', dest: path.wardest}); +taskMaker.defineTask('watch', {taskName: 'watch-stuff', src: [path.json, path.index, path.heat], tasks: ['copy-stuff']}); +taskMaker.defineTask('copy', {taskName: 'copy-storybook-fonts', src: path.storybookFonts, dest: path.storybookDist}); +taskMaker.defineTask('copy', {taskName: 'copy-storybook-resources', src: path.svgSrc, dest: path.storybookResources}); +taskMaker.defineTask('copy', {taskName: 'copy-storybook-resources-prod', src: path.svgSrc, dest: path.storybookDistResources}); + +gulp.task('app-context', function(){ + gulp.src([path.appinf]) + .pipe(gulp.dest(path.appinf_output)) + .on('end', function () { + gulp.src([path.jetty]) + .pipe(replace(/.*<\/Set>/g, ''+jsonConfig.appContextPath+'')) + .pipe(gulp.dest(path.appinf_output + '/WEB-INF')); }) - .catch(err => { - if (err && err.stack) { - console.error(err, err.stack); - } - throw new Error('Webpack build FAILED'); - }); }); -gulp.task('webpack-dev-server', () => { - // modify some webpack config options for development - let myConfig = Object.create(webpackConfig); - - myConfig.devServer.setup = server => { - let fixture = require('./fixture/fixture'); - let proxy = require('http-proxy-middleware'); - let proxyConfigDefaults = { - changeOrigin: true, - secure: false, - onProxyRes: (proxyRes, req, res) => { - let setCookie = proxyRes.headers['set-cookie']; - if (setCookie) { - setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, ''); - } - } - }; +gulp.task('copy-stuff', callback => runSequence(['copy-json', 'copy-index.html', 'copy-heat.html', 'copy-svg', 'app-context'], callback)); - let middlewares = [ - (req, res, next) => { - let match = req.url.match(/^(.*)_en.js$/); - let newUrl = match && match[1] + '.js'; - if (newUrl) { - console.log(`REWRITING URL: ${req.url} -> ${newUrl}`); - req.url = newUrl; - } - next(); - }, - fixture({ - enabled: devConfig.useFixture - }) - ]; +gulp.task('i18n', () => + i18nTask({outputPath: path.output, localesPath: path.locales, lang: 'en'}).catch(err => { + console.log('i18n Task : Error! ', err); + throw err; + }) +); - // standalon back-end (proxyTarget) has higher priority, so it should be first - if (devConfig.proxyTarget) { - middlewares.push( - proxy(['/api', '/onboarding-api', '/sdc1/feProxy/onboarding-api'], Object.assign({}, proxyConfigDefaults, { - target: devConfig.proxyTarget, - pathRewrite: { - '/sdc1/feProxy/onboarding-api': '/onboarding-api' - } - })) - ) - } +gulp.task('dev', callback => runSequence('clean', ['i18n', 'copy-stuff'], callback)); +gulp.task('build', callback => runSequence('clean', ['copy-stuff', 'i18n'], 'prod', ['compress-war', 'compress-heat-war'], callback)); - // Ecorp environment (proxyATTTarget) has lower priority, so it should be second - if (devConfig.proxyATTTarget) { - middlewares.push( - proxy(['/sdc1', '/onboarding-api'], Object.assign({}, proxyConfigDefaults, { - target: devConfig.proxyATTTarget, - pathRewrite: { - // Workaround for some weird proxy issue - '/sdc1/feProxy/onboarding-api': '/sdc1/feProxy/onboarding-api', - '/onboarding-api': '/sdc1/feProxy/onboarding-api' - } - })) - ) - } - server.use(middlewares); - }; +gulp.task('default', ['dev']); - // Start a webpack-dev-server - let server = new WebpackDevServer(webpack(myConfig), myConfig.devServer); - server.listen(myConfig.devServer.port, '0.0.0.0', err => { - if (err) { - throw new Error('webpack-dev-server' + err); +gulp.task('prod', () => prodTask({outDir: path.output}) + .catch(err => { + if (err && err.stack) { + console.error(err, err.stack); } - }); -}); + throw new Error('Webpack build FAILED'); + }) +); -gulp.task('gulp-css-usage', callback => { - return gulp.src('src/**/*.jsx').pipe(gulpCssUsage({css: 'dist/dev/css/style.css', babylon: ['objectRestSpread']})); +gulp.task('gulp-css-usage', () => { + return gulp.src('src/**/*.jsx').pipe(gulpCssUsage({css: path.css + '/style.css', babylon: ['objectRestSpread']})); }); -gulp.task('css-usage', callback => { - defineTasks('dev'); +gulp.task('css-usage', () => { runSequence('sass', 'gulp-css-usage'); }); diff --git a/openecomp-ui/index.js b/openecomp-ui/index.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/openecomp-ui/karma.conf.js b/openecomp-ui/karma.conf.js deleted file mode 100644 index 91c5040942..0000000000 --- a/openecomp-ui/karma.conf.js +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -var path = require('path'); -var isparta = require('isparta'); - -module.exports = function (config) { - config.set({ - - browsers: [process.env.JENKINS_HOME ? 'Firefox' : 'Chrome'], - - singleRun: true, - - autoWatchBatchDelay: 50, - - frameworks: ['mocha'], - - files: [ - 'tests.webpack.js' - ], - - preprocessors: { - 'tests.webpack.js': ['webpack', 'sourcemap'], - 'src/**/*.jsx': ['coverage'] - }, - - reporters: ['progress', 'coverage'], - - coverageReporter: { - dir: 'dist/coverage/', - reporters: [ - {type: 'html'}, - {type: 'text-summary'} - ], - includeAllSources: true, - instrumenters: {isparta: isparta}, - instrumenter: { - '**/*.js': 'isparta', - '**/*.jsx': 'isparta' - }, - instrumenterOptions: { - isparta: { - embedSource: true, - noAutoWrap: true, - } - } - }, - - webpack: { - devtool: 'inline-source-map', - resolve: { - root: [path.resolve('.')], - alias: { - i18nJson: 'nfvo-utils/i18n/locale.json', - 'nfvo-utils/RestAPIUtil.js': 'test-utils/MockRest.js', - 'nfvo-utils': 'src/nfvo-utils', - 'nfvo-components': 'src/nfvo-components', - 'sdc-app': 'src/sdc-app' - } - }, - module: { - preLoaders: [ - {test: /\.js$/, exclude: /(src|node_modules)/, loader: 'eslint-loader'}, - {test: /\.(js|jsx)$/, exclude: /(test|test\.js|node_modules)/, loader: 'isparta'} - ], - loaders: [ - {test: /\.(js|jsx)$/, exclude: /node_modules/, loader: 'babel-loader'}, - {test: /\.json$/, loaders: ['json']}, - {test: /\.(css|scss|png|jpg|svg|ttf|eot|otf|woff|woff2)(\?.*)?$/, loader: 'ignore-loader'}, - ] - }, - eslint: { - configFile: './.eslintrc', - emitError: true, - emitWarning: true, - failOnError: true - }, - }, - - webpackServer: { - noInfo: true - } - - }); -}; diff --git a/openecomp-ui/package.json b/openecomp-ui/package.json index 1d9a479e43..8157be8141 100644 --- a/openecomp-ui/package.json +++ b/openecomp-ui/package.json @@ -2,101 +2,130 @@ "name": "dox-ui", "version": "1.0.0", "description": "", - "author": "ECOMP", + "author": "OPENECOMP", "license": "SEE LICENSE IN LICENSE", "scripts": { - "start": "gulp dev", + "start": "gulp dev && webpack-dev-server --progress", "build": "gulp build", - "test": "karma start", - "test-dev": "karma start --auto-watch --no-single-run" + "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", + "storybook": "gulp copy-storybook-resources && start-storybook -p 9090 -c .storybook -s .storybook/resources,.storybook/fonts", + "storyshots": "jest storyshots.test.js", + "build-storybook": "build-storybook -c .storybook -o .storybook-dist && gulp copy-storybook-fonts && gulp copy-storybook-resources-prod" }, "dependencies": { "classnames": "^2.2.5", "core-js": "^2.4.0", "dox-sequence-diagram-ui": "file:../dox-sequence-diagram-ui", - "history": "^1.13.1", - "immutable": "^3.7.5", "intl": "^1.0.1", "intl-format-cache": "^2.0.5", "intl-messageformat": "^1.2.0", "intl-relativeformat": "^1.2.0", - "jquery": "^2.2.2", + "jquery": "^2.1.4", "lodash": "^4.13.1", "md5": "^2.1.0", - "react": "~15.3.0", - "react-bootstrap": "^0.28.1", - "react-dom": "~15.3.0", - "react-dropzone": "3.4.0", - "react-fontawesome": "^0.3.3", + "randomstring": "^1.1.5", + "react": "~15.3.2", + "react-bootstrap": "^0.30.1", + "react-dom": "~15.3.2", + "react-dropzone": "3.7.3", "react-redux": "^4.4.1", "react-select": "^1.0.0-beta13", + "react-sortable": "^1.2.0", "redux": "^3.3.1", + "restful-js": "^0.7.0", "uuid-js": "^0.7.5", "validator": "^4.3.0" }, "devDependencies": { - "babel-core": "^6.9.1", - "babel-eslint": "^6.0.2", - "babel-loader": "^6.2.4", + "@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": "^19.0.0", + "babel-loader": "^7.0.0-beta.1", "babel-plugin-transform-class-properties": "^6.10.2", "babel-plugin-transform-es2015-destructuring": "^6.9.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.10.3", "babel-plugin-transform-es2015-spread": "^6.8.0", "babel-plugin-transform-object-rest-spread": "^6.8.0", - "babel-preset-es2015": "^6.9.0", - "babel-preset-react": "^6.5.0", - "babel-preset-stage-0": "^6.5.0", - "chai": "^3.5.0", + "babel-plugin-transform-runtime": "^6.22.0", + "babel-preset-es2015": "^6.24.0", + "babel-preset-react": "^6.23.0", + "babel-preset-stage-0": "^6.22.0", "css-loader": "^0.23.1", "deep-freeze": "0.0.1", + "enzyme": "^2.7.1", "eslint-loader": "^1.3.0", "eslint-plugin-import": "^0.8.1", "eslint-plugin-react": "^3.14.0", - "expect": "^1.20.1", "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-helpers": "^5.0.0", - "gulp-jsx-coverage": "^0.3.8", "gulp-rename": "^1.2.2", "gulp-replace": "^0.5.4", + "gulp-util": "^3.0.8", "html-loader": "^0.4.3", "http-proxy-middleware": "^0.8.2", "ignore-loader": "^0.1.1", - "isparta": "^4.0.0", - "isparta-loader": "^2.0.0", - "istanbul": "^1.0.0-alpha.2", - "istanbul-instrumenter-loader": "^0.2.0", - "jsdom": "^8.3.0", + "jasmine-core": "^2.5.2", + "jest": "^19.0.2", + "jshint": "^2.9.4", "json-loader": "^0.5.4", "jsx-loader": "^0.13.2", - "karma": "^0.13.22", - "karma-chai": "^0.1.0", - "karma-chrome-launcher": "^1.0.1", - "karma-cli": "^1.0.0", - "karma-coverage": "^1.0.0", - "karma-firefox-launcher": "^1.0.0", - "karma-mocha": "^1.0.1", - "karma-sourcemap-loader": "^0.3.7", - "karma-webpack": "^1.7.0", "mkdirp": "^0.5.1", - "mocha": "^2.4.5", "node-watch": "^0.3.5", "prompt": "^0.2.14", - "react-addons-test-utils": "~15.3.0", - "react-hot-loader": "^1.3.0", - "sass-loader": "^3.1.2", - "sinon": "^1.17.3", + "react-addons-test-utils": "~15.3.2", + "react-hot-loader": "^1.3.1", + "rosie": "^1.6.0", + "sass-loader": "^3.2.3", "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": "^1.13.1", - "webpack-dev-server": "^1.14.1" + "webpack": "^2.2.1", + "webpack-dev-server": "^2.4.2" }, "engines": { "node": ">=5.1", "npm": ">=3.3" + }, + "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", + "^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/locale.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}" + ], + "coverageReporters": [ + "lcov" + ] } } diff --git a/openecomp-ui/pom.xml b/openecomp-ui/pom.xml index 0c37c11bea..78eb97c57b 100644 --- a/openecomp-ui/pom.xml +++ b/openecomp-ui/pom.xml @@ -1,109 +1,156 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - - org.openecomp.sdc - sdc-main - 1.1.0-SNAPSHOT - + org.openecomp.sdc + onboarding-fe + onboarding-ui-war + war - org.openecomp.sdc.onboarding - onboarding-fe - onboarding-ui-war - pom + + org.openecomp.sdc + sdc-onboarding + 1.1.0-SNAPSHOT + ../onboarding + - - true - + + + + + + + maven-clean-plugin + 2.6.1 + + + clean.dist.folder + clean + + clean + + + + + ${basedir}/dist + + + ${basedir}/node_modules + + + ${basedir}/../dox-sequence-diagram-ui/dist + + + ${basedir}/../dox-sequence-diagram-ui/node_modules + + + + + + - - + + + + + com.github.eirslett + frontend-maven-plugin + 1.4 + + + + + install node and npm in dox-sequence-diagram-ui + + install-node-and-npm + + + ${project.basedir}/../dox-sequence-diagram-ui + v6.9.5 + 3.10.10 + + + + install node and npm + + install-node-and-npm + + + v6.9.5 + 3.10.10 + + + + + npm install in dox-sequence-diagram-ui + + npm + + + ${project.basedir}/../dox-sequence-diagram-ui + install + + + + + npm install + + npm + + + install + + + + + npm run build + + npm + + + run build + + + + - - io.wcm.maven.plugins - nodejs-maven-plugin - - - compile - - run - - - - - - - ${session.executionRootDirectory}/dox-sequence-diagram-ui - - - ${session.executionRootDirectory}/dox-sequence-diagram-ui - webpack - - - ${project.basedir} - - - ${project.basedir} - gulp - - build - - - - - + + maven-antrun-plugin + + + repack war + prepare-package + + + + + + + + + + + + run + + + + - - com.coderplus.maven.plugins - copy-rename-maven-plugin - 1.0 - - - copy-file - compile - - copy - - - ${project.basedir}/dist/onboarding.war - ${project.basedir}/target/onboarding-fe-${project.version}.war - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - attach-artifacts - compile - - attach-artifact - - - - - ${project.basedir}/target/onboarding-fe-${project.version}.war - war - - - - - - - - - - + + org.apache.maven.plugins + maven-war-plugin + 3.0.0 + + + + ${basedir}/target/dist + + + + + + diff --git a/openecomp-ui/proxy-server.js b/openecomp-ui/proxy-server.js new file mode 100644 index 0000000000..4733d38a89 --- /dev/null +++ b/openecomp-ui/proxy-server.js @@ -0,0 +1,92 @@ +'use strict'; + +const proxy = require('http-proxy-middleware'); + +let localDevConfig = {}; +try { + localDevConfig = require('./devConfig'); +} catch (e) {} +const devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig); +let devPort = process.env.PORT || devConfig.port; + +let jsonConfig = { + "appContextPath" : "/onboarding" +}; + +try { + jsonConfig = require('./src/sdc-app/config/config.json'); +} catch (e) { + console.log('could not load config. using deault value instead'); +} + +module.exports = function (server) { + let proxyConfigDefaults = { + changeOrigin: true, + secure: false, + onProxyRes: (proxyRes, req, res) => { + let setCookie = proxyRes.headers['set-cookie']; + if (setCookie) { + setCookie[0] = setCookie[0].replace(/\bSecure\b(; )?/, ''); + } + if (proxyRes.statusCode === 302 && proxyRes.headers.location.indexOf('login') > -1) { + proxyRes.headers.location = `http://localhost:${devPort}/sdc1#/onboardVendor`; + res.setHeader('Set-Cookie', [ + 'HTTP_CSP_EMAIL=csantana@sdc.com', + 'HTTP_CSP_FIRSTNAME=Carlos', + 'HTTP_CSP_LASTNAME=Santana', + 'HTTP_CSP_WSTYPE=Intranet', + 'HTTP_IV_REMOTE_ADDRESS=0.0.0.0', + 'HTTP_IV_USER=cs0008', + 'USER_ID=cs0008' + ]); + } + } + }; + + let middlewares = [ + (req, res, next) => { + if (req.url.indexOf('/proxy-designer1') > -1) { + req.url = req.url.replace('/proxy-designer1', ''); + } + + if (req.url.indexOf(jsonConfig.appContextPath + '/resources') > -1) { + req.url = req.url.replace(jsonConfig.appContextPath, ''); + } + + let match = req.url.match(/^(.*)_en.js$/); + let newUrl = match && match[1] + '.js'; + if (newUrl) { + console.log(`REWRITING URL: ${req.url} -> ${newUrl}`); + req.url = newUrl; + } + next(); + } + ]; + + // standalon back-end (proxyTarget) has higher priority, so it should be first + if (devConfig.proxyTarget) { + middlewares.push( + proxy(['/api', '/onboarding-api', '/sdc1/feProxy/onboarding-api'], Object.assign({}, proxyConfigDefaults, { + target: devConfig.proxyTarget, + pathRewrite: { + '/sdc1/feProxy/onboarding-api': '/onboarding-api' + } + })) + ); + } + + // ATT environment (proxyATTTarget) has lower priority, so it should be second + if (devConfig.proxyATTTarget) { + middlewares.push( + proxy(['/sdc1', '/onboarding-api', '/scripts', '/styles'], Object.assign({}, proxyConfigDefaults, { + target: devConfig.proxyATTTarget, + pathRewrite: { + // Workaround for some weird proxy issue + '/sdc1/feProxy/onboarding-api': '/sdc1/feProxy/onboarding-api', + '/onboarding-api': '/sdc1/feProxy/onboarding-api' + } + })) + ); + } + server.use(middlewares); +}; diff --git a/openecomp-ui/readMe.txt b/openecomp-ui/readMe.txt deleted file mode 100644 index 6b70dfc5bb..0000000000 --- a/openecomp-ui/readMe.txt +++ /dev/null @@ -1,25 +0,0 @@ -# OpenECOMP SDC(UI) - ---- ---- - -# Steps - -### Install nodejs & gulp - -#### Download nodejs from here : https://nodejs.org/en/ (take the "current" version with latest features) & install it. -#### Install gulp by running the following command : npm install --global gulp-cli - -### Install DOX-UI a - -#### Pull for latest changes. -#### Go to folder dox-sequence-diagram-ui -#### Give the following command : run npm install -#### Wait for it.. -#### Go to folder dox-ui -#### run npm install -#### Create a copy of devConfig.defaults.json file and name it devConfig.json (we already configured git to ignore it so it will not be pushed). -#### In that file, populate the fields of the IP addresses of your BE machine you'd like to connect (pay attention, it is a JSON file): For example, http://: -#### After everything was successful, run gulp. -#### After server was up, your favourite UI will wait for you at : http://localhost:9000/sdc1/proxy-designer1#/onboardVendor - diff --git a/openecomp-ui/resources/css/font-awesome.min.css b/openecomp-ui/resources/css/font-awesome.min.css deleted file mode 100644 index 24fcc04c4e..0000000000 --- a/openecomp-ui/resources/css/font-awesome.min.css +++ /dev/null @@ -1,4 +0,0 @@ -/*! - * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome - * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) - */@font-face{font-family:'FontAwesome';src:url('../fonts/fontawesome-webfont.eot?v=4.3.0');src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.3.0') format('embedded-opentype'),url('../fonts/fontawesome-webfont.woff2?v=4.3.0') format('woff2'),url('../fonts/fontawesome-webfont.woff?v=4.3.0') format('woff'),url('../fonts/fontawesome-webfont.ttf?v=4.3.0') format('truetype'),url('../fonts/fontawesome-webfont.svg?v=4.3.0#fontawesomeregular') format('svg');font-weight:normal;font-style:normal}.fa{display:inline-block;font:normal normal normal 14px/1 FontAwesome;font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0, 0)}.fa-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.fa-2x{font-size:2em}.fa-3x{font-size:3em}.fa-4x{font-size:4em}.fa-5x{font-size:5em}.fa-fw{width:1.28571429em;text-align:center}.fa-ul{padding-left:0;margin-left:2.14285714em;list-style-type:none}.fa-ul>li{position:relative}.fa-li{position:absolute;left:-2.14285714em;width:2.14285714em;top:.14285714em;text-align:center}.fa-li.fa-lg{left:-1.85714286em}.fa-border{padding:.2em .25em .15em;border:solid .08em #eee;border-radius:.1em}.pull-right{float:right}.pull-left{float:left}.fa.pull-left{margin-right:.3em}.fa.pull-right{margin-left:.3em}.fa-spin{-webkit-animation:fa-spin 2s infinite linear;animation:fa-spin 2s infinite linear}.fa-pulse{-webkit-animation:fa-spin 1s infinite steps(8);animation:fa-spin 1s infinite steps(8)}@-webkit-keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}@keyframes fa-spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}100%{-webkit-transform:rotate(359deg);transform:rotate(359deg)}}.fa-rotate-90{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=1);-webkit-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg)}.fa-rotate-180{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2);-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.fa-rotate-270{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=3);-webkit-transform:rotate(270deg);-ms-transform:rotate(270deg);transform:rotate(270deg)}.fa-flip-horizontal{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1);-webkit-transform:scale(-1, 1);-ms-transform:scale(-1, 1);transform:scale(-1, 1)}.fa-flip-vertical{filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1);-webkit-transform:scale(1, -1);-ms-transform:scale(1, -1);transform:scale(1, -1)}:root .fa-rotate-90,:root .fa-rotate-180,:root .fa-rotate-270,:root .fa-flip-horizontal,:root .fa-flip-vertical{filter:none}.fa-stack{position:relative;display:inline-block;width:2em;height:2em;line-height:2em;vertical-align:middle}.fa-stack-1x,.fa-stack-2x{position:absolute;left:0;width:100%;text-align:center}.fa-stack-1x{line-height:inherit}.fa-stack-2x{font-size:2em}.fa-inverse{color:#fff}.fa-glass:before{content:"\f000"}.fa-music:before{content:"\f001"}.fa-search:before{content:"\f002"}.fa-envelope-o:before{content:"\f003"}.fa-heart:before{content:"\f004"}.fa-star:before{content:"\f005"}.fa-star-o:before{content:"\f006"}.fa-user:before{content:"\f007"}.fa-film:before{content:"\f008"}.fa-th-large:before{content:"\f009"}.fa-th:before{content:"\f00a"}.fa-th-list:before{content:"\f00b"}.fa-check:before{content:"\f00c"}.fa-remove:before,.fa-close:before,.fa-times:before{content:"\f00d"}.fa-search-plus:before{content:"\f00e"}.fa-search-minus:before{content:"\f010"}.fa-power-off:before{content:"\f011"}.fa-signal:before{content:"\f012"}.fa-gear:before,.fa-cog:before{content:"\f013"}.fa-trash-o:before{content:"\f014"}.fa-home:before{content:"\f015"}.fa-file-o:before{content:"\f016"}.fa-clock-o:before{content:"\f017"}.fa-road:before{content:"\f018"}.fa-download:before{content:"\f019"}.fa-arrow-circle-o-down:before{content:"\f01a"}.fa-arrow-circle-o-up:before{content:"\f01b"}.fa-inbox:before{content:"\f01c"}.fa-play-circle-o:before{content:"\f01d"}.fa-rotate-right:before,.fa-repeat:before{content:"\f01e"}.fa-refresh:before{content:"\f021"}.fa-list-alt:before{content:"\f022"}.fa-lock:before{content:"\f023"}.fa-flag:before{content:"\f024"}.fa-headphones:before{content:"\f025"}.fa-volume-off:before{content:"\f026"}.fa-volume-down:before{content:"\f027"}.fa-volume-up:before{content:"\f028"}.fa-qrcode:before{content:"\f029"}.fa-barcode:before{content:"\f02a"}.fa-tag:before{content:"\f02b"}.fa-tags:before{content:"\f02c"}.fa-book:before{content:"\f02d"}.fa-bookmark:before{content:"\f02e"}.fa-print:before{content:"\f02f"}.fa-camera:before{content:"\f030"}.fa-font:before{content:"\f031"}.fa-bold:before{content:"\f032"}.fa-italic:before{content:"\f033"}.fa-text-height:before{content:"\f034"}.fa-text-width:before{content:"\f035"}.fa-align-left:before{content:"\f036"}.fa-align-center:before{content:"\f037"}.fa-align-right:before{content:"\f038"}.fa-align-justify:before{content:"\f039"}.fa-list:before{content:"\f03a"}.fa-dedent:before,.fa-outdent:before{content:"\f03b"}.fa-indent:before{content:"\f03c"}.fa-video-camera:before{content:"\f03d"}.fa-photo:before,.fa-image:before,.fa-picture-o:before{content:"\f03e"}.fa-pencil:before{content:"\f040"}.fa-map-marker:before{content:"\f041"}.fa-adjust:before{content:"\f042"}.fa-tint:before{content:"\f043"}.fa-edit:before,.fa-pencil-square-o:before{content:"\f044"}.fa-share-square-o:before{content:"\f045"}.fa-check-square-o:before{content:"\f046"}.fa-arrows:before{content:"\f047"}.fa-step-backward:before{content:"\f048"}.fa-fast-backward:before{content:"\f049"}.fa-backward:before{content:"\f04a"}.fa-play:before{content:"\f04b"}.fa-pause:before{content:"\f04c"}.fa-stop:before{content:"\f04d"}.fa-forward:before{content:"\f04e"}.fa-fast-forward:before{content:"\f050"}.fa-step-forward:before{content:"\f051"}.fa-eject:before{content:"\f052"}.fa-chevron-left:before{content:"\f053"}.fa-chevron-right:before{content:"\f054"}.fa-plus-circle:before{content:"\f055"}.fa-minus-circle:before{content:"\f056"}.fa-times-circle:before{content:"\f057"}.fa-check-circle:before{content:"\f058"}.fa-question-circle:before{content:"\f059"}.fa-info-circle:before{content:"\f05a"}.fa-crosshairs:before{content:"\f05b"}.fa-times-circle-o:before{content:"\f05c"}.fa-check-circle-o:before{content:"\f05d"}.fa-ban:before{content:"\f05e"}.fa-arrow-left:before{content:"\f060"}.fa-arrow-right:before{content:"\f061"}.fa-arrow-up:before{content:"\f062"}.fa-arrow-down:before{content:"\f063"}.fa-mail-forward:before,.fa-share:before{content:"\f064"}.fa-expand:before{content:"\f065"}.fa-compress:before{content:"\f066"}.fa-plus:before{content:"\f067"}.fa-minus:before{content:"\f068"}.fa-asterisk:before{content:"\f069"}.fa-exclamation-circle:before{content:"\f06a"}.fa-gift:before{content:"\f06b"}.fa-leaf:before{content:"\f06c"}.fa-fire:before{content:"\f06d"}.fa-eye:before{content:"\f06e"}.fa-eye-slash:before{content:"\f070"}.fa-warning:before,.fa-exclamation-triangle:before{content:"\f071"}.fa-plane:before{content:"\f072"}.fa-calendar:before{content:"\f073"}.fa-random:before{content:"\f074"}.fa-comment:before{content:"\f075"}.fa-magnet:before{content:"\f076"}.fa-chevron-up:before{content:"\f077"}.fa-chevron-down:before{content:"\f078"}.fa-retweet:before{content:"\f079"}.fa-shopping-cart:before{content:"\f07a"}.fa-folder:before{content:"\f07b"}.fa-folder-open:before{content:"\f07c"}.fa-arrows-v:before{content:"\f07d"}.fa-arrows-h:before{content:"\f07e"}.fa-bar-chart-o:before,.fa-bar-chart:before{content:"\f080"}.fa-twitter-square:before{content:"\f081"}.fa-facebook-square:before{content:"\f082"}.fa-camera-retro:before{content:"\f083"}.fa-key:before{content:"\f084"}.fa-gears:before,.fa-cogs:before{content:"\f085"}.fa-comments:before{content:"\f086"}.fa-thumbs-o-up:before{content:"\f087"}.fa-thumbs-o-down:before{content:"\f088"}.fa-star-half:before{content:"\f089"}.fa-heart-o:before{content:"\f08a"}.fa-sign-out:before{content:"\f08b"}.fa-linkedin-square:before{content:"\f08c"}.fa-thumb-tack:before{content:"\f08d"}.fa-external-link:before{content:"\f08e"}.fa-sign-in:before{content:"\f090"}.fa-trophy:before{content:"\f091"}.fa-github-square:before{content:"\f092"}.fa-upload:before{content:"\f093"}.fa-lemon-o:before{content:"\f094"}.fa-phone:before{content:"\f095"}.fa-square-o:before{content:"\f096"}.fa-bookmark-o:before{content:"\f097"}.fa-phone-square:before{content:"\f098"}.fa-twitter:before{content:"\f099"}.fa-facebook-f:before,.fa-facebook:before{content:"\f09a"}.fa-github:before{content:"\f09b"}.fa-unlock:before{content:"\f09c"}.fa-credit-card:before{content:"\f09d"}.fa-rss:before{content:"\f09e"}.fa-hdd-o:before{content:"\f0a0"}.fa-bullhorn:before{content:"\f0a1"}.fa-bell:before{content:"\f0f3"}.fa-certificate:before{content:"\f0a3"}.fa-hand-o-right:before{content:"\f0a4"}.fa-hand-o-left:before{content:"\f0a5"}.fa-hand-o-up:before{content:"\f0a6"}.fa-hand-o-down:before{content:"\f0a7"}.fa-arrow-circle-left:before{content:"\f0a8"}.fa-arrow-circle-right:before{content:"\f0a9"}.fa-arrow-circle-up:before{content:"\f0aa"}.fa-arrow-circle-down:before{content:"\f0ab"}.fa-globe:before{content:"\f0ac"}.fa-wrench:before{content:"\f0ad"}.fa-tasks:before{content:"\f0ae"}.fa-filter:before{content:"\f0b0"}.fa-briefcase:before{content:"\f0b1"}.fa-arrows-alt:before{content:"\f0b2"}.fa-group:before,.fa-users:before{content:"\f0c0"}.fa-chain:before,.fa-link:before{content:"\f0c1"}.fa-cloud:before{content:"\f0c2"}.fa-flask:before{content:"\f0c3"}.fa-cut:before,.fa-scissors:before{content:"\f0c4"}.fa-copy:before,.fa-files-o:before{content:"\f0c5"}.fa-paperclip:before{content:"\f0c6"}.fa-save:before,.fa-floppy-o:before{content:"\f0c7"}.fa-square:before{content:"\f0c8"}.fa-navicon:before,.fa-reorder:before,.fa-bars:before{content:"\f0c9"}.fa-list-ul:before{content:"\f0ca"}.fa-list-ol:before{content:"\f0cb"}.fa-strikethrough:before{content:"\f0cc"}.fa-underline:before{content:"\f0cd"}.fa-table:before{content:"\f0ce"}.fa-magic:before{content:"\f0d0"}.fa-truck:before{content:"\f0d1"}.fa-pinterest:before{content:"\f0d2"}.fa-pinterest-square:before{content:"\f0d3"}.fa-google-plus-square:before{content:"\f0d4"}.fa-google-plus:before{content:"\f0d5"}.fa-money:before{content:"\f0d6"}.fa-caret-down:before{content:"\f0d7"}.fa-caret-up:before{content:"\f0d8"}.fa-caret-left:before{content:"\f0d9"}.fa-caret-right:before{content:"\f0da"}.fa-columns:before{content:"\f0db"}.fa-unsorted:before,.fa-sort:before{content:"\f0dc"}.fa-sort-down:before,.fa-sort-desc:before{content:"\f0dd"}.fa-sort-up:before,.fa-sort-asc:before{content:"\f0de"}.fa-envelope:before{content:"\f0e0"}.fa-linkedin:before{content:"\f0e1"}.fa-rotate-left:before,.fa-undo:before{content:"\f0e2"}.fa-legal:before,.fa-gavel:before{content:"\f0e3"}.fa-dashboard:before,.fa-tachometer:before{content:"\f0e4"}.fa-comment-o:before{content:"\f0e5"}.fa-comments-o:before{content:"\f0e6"}.fa-flash:before,.fa-bolt:before{content:"\f0e7"}.fa-sitemap:before{content:"\f0e8"}.fa-umbrella:before{content:"\f0e9"}.fa-paste:before,.fa-clipboard:before{content:"\f0ea"}.fa-lightbulb-o:before{content:"\f0eb"}.fa-exchange:before{content:"\f0ec"}.fa-cloud-download:before{content:"\f0ed"}.fa-cloud-upload:before{content:"\f0ee"}.fa-user-md:before{content:"\f0f0"}.fa-stethoscope:before{content:"\f0f1"}.fa-suitcase:before{content:"\f0f2"}.fa-bell-o:before{content:"\f0a2"}.fa-coffee:before{content:"\f0f4"}.fa-cutlery:before{content:"\f0f5"}.fa-file-text-o:before{content:"\f0f6"}.fa-building-o:before{content:"\f0f7"}.fa-hospital-o:before{content:"\f0f8"}.fa-ambulance:before{content:"\f0f9"}.fa-medkit:before{content:"\f0fa"}.fa-fighter-jet:before{content:"\f0fb"}.fa-beer:before{content:"\f0fc"}.fa-h-square:before{content:"\f0fd"}.fa-plus-square:before{content:"\f0fe"}.fa-angle-double-left:before{content:"\f100"}.fa-angle-double-right:before{content:"\f101"}.fa-angle-double-up:before{content:"\f102"}.fa-angle-double-down:before{content:"\f103"}.fa-angle-left:before{content:"\f104"}.fa-angle-right:before{content:"\f105"}.fa-angle-up:before{content:"\f106"}.fa-angle-down:before{content:"\f107"}.fa-desktop:before{content:"\f108"}.fa-laptop:before{content:"\f109"}.fa-tablet:before{content:"\f10a"}.fa-mobile-phone:before,.fa-mobile:before{content:"\f10b"}.fa-circle-o:before{content:"\f10c"}.fa-quote-left:before{content:"\f10d"}.fa-quote-right:before{content:"\f10e"}.fa-spinner:before{content:"\f110"}.fa-circle:before{content:"\f111"}.fa-mail-reply:before,.fa-reply:before{content:"\f112"}.fa-github-alt:before{content:"\f113"}.fa-folder-o:before{content:"\f114"}.fa-folder-open-o:before{content:"\f115"}.fa-smile-o:before{content:"\f118"}.fa-frown-o:before{content:"\f119"}.fa-meh-o:before{content:"\f11a"}.fa-gamepad:before{content:"\f11b"}.fa-keyboard-o:before{content:"\f11c"}.fa-flag-o:before{content:"\f11d"}.fa-flag-checkered:before{content:"\f11e"}.fa-terminal:before{content:"\f120"}.fa-code:before{content:"\f121"}.fa-mail-reply-all:before,.fa-reply-all:before{content:"\f122"}.fa-star-half-empty:before,.fa-star-half-full:before,.fa-star-half-o:before{content:"\f123"}.fa-location-arrow:before{content:"\f124"}.fa-crop:before{content:"\f125"}.fa-code-fork:before{content:"\f126"}.fa-unlink:before,.fa-chain-broken:before{content:"\f127"}.fa-question:before{content:"\f128"}.fa-info:before{content:"\f129"}.fa-exclamation:before{content:"\f12a"}.fa-superscript:before{content:"\f12b"}.fa-subscript:before{content:"\f12c"}.fa-eraser:before{content:"\f12d"}.fa-puzzle-piece:before{content:"\f12e"}.fa-microphone:before{content:"\f130"}.fa-microphone-slash:before{content:"\f131"}.fa-shield:before{content:"\f132"}.fa-calendar-o:before{content:"\f133"}.fa-fire-extinguisher:before{content:"\f134"}.fa-rocket:before{content:"\f135"}.fa-maxcdn:before{content:"\f136"}.fa-chevron-circle-left:before{content:"\f137"}.fa-chevron-circle-right:before{content:"\f138"}.fa-chevron-circle-up:before{content:"\f139"}.fa-chevron-circle-down:before{content:"\f13a"}.fa-html5:before{content:"\f13b"}.fa-css3:before{content:"\f13c"}.fa-anchor:before{content:"\f13d"}.fa-unlock-alt:before{content:"\f13e"}.fa-bullseye:before{content:"\f140"}.fa-ellipsis-h:before{content:"\f141"}.fa-ellipsis-v:before{content:"\f142"}.fa-rss-square:before{content:"\f143"}.fa-play-circle:before{content:"\f144"}.fa-ticket:before{content:"\f145"}.fa-minus-square:before{content:"\f146"}.fa-minus-square-o:before{content:"\f147"}.fa-level-up:before{content:"\f148"}.fa-level-down:before{content:"\f149"}.fa-check-square:before{content:"\f14a"}.fa-pencil-square:before{content:"\f14b"}.fa-external-link-square:before{content:"\f14c"}.fa-share-square:before{content:"\f14d"}.fa-compass:before{content:"\f14e"}.fa-toggle-down:before,.fa-caret-square-o-down:before{content:"\f150"}.fa-toggle-up:before,.fa-caret-square-o-up:before{content:"\f151"}.fa-toggle-right:before,.fa-caret-square-o-right:before{content:"\f152"}.fa-euro:before,.fa-eur:before{content:"\f153"}.fa-gbp:before{content:"\f154"}.fa-dollar:before,.fa-usd:before{content:"\f155"}.fa-rupee:before,.fa-inr:before{content:"\f156"}.fa-cny:before,.fa-rmb:before,.fa-yen:before,.fa-jpy:before{content:"\f157"}.fa-ruble:before,.fa-rouble:before,.fa-rub:before{content:"\f158"}.fa-won:before,.fa-krw:before{content:"\f159"}.fa-bitcoin:before,.fa-btc:before{content:"\f15a"}.fa-file:before{content:"\f15b"}.fa-file-text:before{content:"\f15c"}.fa-sort-alpha-asc:before{content:"\f15d"}.fa-sort-alpha-desc:before{content:"\f15e"}.fa-sort-amount-asc:before{content:"\f160"}.fa-sort-amount-desc:before{content:"\f161"}.fa-sort-numeric-asc:before{content:"\f162"}.fa-sort-numeric-desc:before{content:"\f163"}.fa-thumbs-up:before{content:"\f164"}.fa-thumbs-down:before{content:"\f165"}.fa-youtube-square:before{content:"\f166"}.fa-youtube:before{content:"\f167"}.fa-xing:before{content:"\f168"}.fa-xing-square:before{content:"\f169"}.fa-youtube-play:before{content:"\f16a"}.fa-dropbox:before{content:"\f16b"}.fa-stack-overflow:before{content:"\f16c"}.fa-instagram:before{content:"\f16d"}.fa-flickr:before{content:"\f16e"}.fa-adn:before{content:"\f170"}.fa-bitbucket:before{content:"\f171"}.fa-bitbucket-square:before{content:"\f172"}.fa-tumblr:before{content:"\f173"}.fa-tumblr-square:before{content:"\f174"}.fa-long-arrow-down:before{content:"\f175"}.fa-long-arrow-up:before{content:"\f176"}.fa-long-arrow-left:before{content:"\f177"}.fa-long-arrow-right:before{content:"\f178"}.fa-apple:before{content:"\f179"}.fa-windows:before{content:"\f17a"}.fa-android:before{content:"\f17b"}.fa-linux:before{content:"\f17c"}.fa-dribbble:before{content:"\f17d"}.fa-skype:before{content:"\f17e"}.fa-foursquare:before{content:"\f180"}.fa-trello:before{content:"\f181"}.fa-female:before{content:"\f182"}.fa-male:before{content:"\f183"}.fa-gittip:before,.fa-gratipay:before{content:"\f184"}.fa-sun-o:before{content:"\f185"}.fa-moon-o:before{content:"\f186"}.fa-archive:before{content:"\f187"}.fa-bug:before{content:"\f188"}.fa-vk:before{content:"\f189"}.fa-weibo:before{content:"\f18a"}.fa-renren:before{content:"\f18b"}.fa-pagelines:before{content:"\f18c"}.fa-stack-exchange:before{content:"\f18d"}.fa-arrow-circle-o-right:before{content:"\f18e"}.fa-arrow-circle-o-left:before{content:"\f190"}.fa-toggle-left:before,.fa-caret-square-o-left:before{content:"\f191"}.fa-dot-circle-o:before{content:"\f192"}.fa-wheelchair:before{content:"\f193"}.fa-vimeo-square:before{content:"\f194"}.fa-turkish-lira:before,.fa-try:before{content:"\f195"}.fa-plus-square-o:before{content:"\f196"}.fa-space-shuttle:before{content:"\f197"}.fa-slack:before{content:"\f198"}.fa-envelope-square:before{content:"\f199"}.fa-wordpress:before{content:"\f19a"}.fa-openid:before{content:"\f19b"}.fa-institution:before,.fa-bank:before,.fa-university:before{content:"\f19c"}.fa-mortar-board:before,.fa-graduation-cap:before{content:"\f19d"}.fa-yahoo:before{content:"\f19e"}.fa-google:before{content:"\f1a0"}.fa-reddit:before{content:"\f1a1"}.fa-reddit-square:before{content:"\f1a2"}.fa-stumbleupon-circle:before{content:"\f1a3"}.fa-stumbleupon:before{content:"\f1a4"}.fa-delicious:before{content:"\f1a5"}.fa-digg:before{content:"\f1a6"}.fa-pied-piper:before{content:"\f1a7"}.fa-pied-piper-alt:before{content:"\f1a8"}.fa-drupal:before{content:"\f1a9"}.fa-joomla:before{content:"\f1aa"}.fa-language:before{content:"\f1ab"}.fa-fax:before{content:"\f1ac"}.fa-building:before{content:"\f1ad"}.fa-child:before{content:"\f1ae"}.fa-paw:before{content:"\f1b0"}.fa-spoon:before{content:"\f1b1"}.fa-cube:before{content:"\f1b2"}.fa-cubes:before{content:"\f1b3"}.fa-behance:before{content:"\f1b4"}.fa-behance-square:before{content:"\f1b5"}.fa-steam:before{content:"\f1b6"}.fa-steam-square:before{content:"\f1b7"}.fa-recycle:before{content:"\f1b8"}.fa-automobile:before,.fa-car:before{content:"\f1b9"}.fa-cab:before,.fa-taxi:before{content:"\f1ba"}.fa-tree:before{content:"\f1bb"}.fa-spotify:before{content:"\f1bc"}.fa-deviantart:before{content:"\f1bd"}.fa-soundcloud:before{content:"\f1be"}.fa-database:before{content:"\f1c0"}.fa-file-pdf-o:before{content:"\f1c1"}.fa-file-word-o:before{content:"\f1c2"}.fa-file-excel-o:before{content:"\f1c3"}.fa-file-powerpoint-o:before{content:"\f1c4"}.fa-file-photo-o:before,.fa-file-picture-o:before,.fa-file-image-o:before{content:"\f1c5"}.fa-file-zip-o:before,.fa-file-archive-o:before{content:"\f1c6"}.fa-file-sound-o:before,.fa-file-audio-o:before{content:"\f1c7"}.fa-file-movie-o:before,.fa-file-video-o:before{content:"\f1c8"}.fa-file-code-o:before{content:"\f1c9"}.fa-vine:before{content:"\f1ca"}.fa-codepen:before{content:"\f1cb"}.fa-jsfiddle:before{content:"\f1cc"}.fa-life-bouy:before,.fa-life-buoy:before,.fa-life-saver:before,.fa-support:before,.fa-life-ring:before{content:"\f1cd"}.fa-circle-o-notch:before{content:"\f1ce"}.fa-ra:before,.fa-rebel:before{content:"\f1d0"}.fa-ge:before,.fa-empire:before{content:"\f1d1"}.fa-git-square:before{content:"\f1d2"}.fa-git:before{content:"\f1d3"}.fa-hacker-news:before{content:"\f1d4"}.fa-tencent-weibo:before{content:"\f1d5"}.fa-qq:before{content:"\f1d6"}.fa-wechat:before,.fa-weixin:before{content:"\f1d7"}.fa-send:before,.fa-paper-plane:before{content:"\f1d8"}.fa-send-o:before,.fa-paper-plane-o:before{content:"\f1d9"}.fa-history:before{content:"\f1da"}.fa-genderless:before,.fa-circle-thin:before{content:"\f1db"}.fa-header:before{content:"\f1dc"}.fa-paragraph:before{content:"\f1dd"}.fa-sliders:before{content:"\f1de"}.fa-share-alt:before{content:"\f1e0"}.fa-share-alt-square:before{content:"\f1e1"}.fa-bomb:before{content:"\f1e2"}.fa-soccer-ball-o:before,.fa-futbol-o:before{content:"\f1e3"}.fa-tty:before{content:"\f1e4"}.fa-binoculars:before{content:"\f1e5"}.fa-plug:before{content:"\f1e6"}.fa-slideshare:before{content:"\f1e7"}.fa-twitch:before{content:"\f1e8"}.fa-yelp:before{content:"\f1e9"}.fa-newspaper-o:before{content:"\f1ea"}.fa-wifi:before{content:"\f1eb"}.fa-calculator:before{content:"\f1ec"}.fa-paypal:before{content:"\f1ed"}.fa-google-wallet:before{content:"\f1ee"}.fa-cc-visa:before{content:"\f1f0"}.fa-cc-mastercard:before{content:"\f1f1"}.fa-cc-discover:before{content:"\f1f2"}.fa-cc-amex:before{content:"\f1f3"}.fa-cc-paypal:before{content:"\f1f4"}.fa-cc-stripe:before{content:"\f1f5"}.fa-bell-slash:before{content:"\f1f6"}.fa-bell-slash-o:before{content:"\f1f7"}.fa-trash:before{content:"\f1f8"}.fa-copyright:before{content:"\f1f9"}.fa-at:before{content:"\f1fa"}.fa-eyedropper:before{content:"\f1fb"}.fa-paint-brush:before{content:"\f1fc"}.fa-birthday-cake:before{content:"\f1fd"}.fa-area-chart:before{content:"\f1fe"}.fa-pie-chart:before{content:"\f200"}.fa-line-chart:before{content:"\f201"}.fa-lastfm:before{content:"\f202"}.fa-lastfm-square:before{content:"\f203"}.fa-toggle-off:before{content:"\f204"}.fa-toggle-on:before{content:"\f205"}.fa-bicycle:before{content:"\f206"}.fa-bus:before{content:"\f207"}.fa-ioxhost:before{content:"\f208"}.fa-angellist:before{content:"\f209"}.fa-cc:before{content:"\f20a"}.fa-shekel:before,.fa-sheqel:before,.fa-ils:before{content:"\f20b"}.fa-meanpath:before{content:"\f20c"}.fa-buysellads:before{content:"\f20d"}.fa-connectdevelop:before{content:"\f20e"}.fa-dashcube:before{content:"\f210"}.fa-forumbee:before{content:"\f211"}.fa-leanpub:before{content:"\f212"}.fa-sellsy:before{content:"\f213"}.fa-shirtsinbulk:before{content:"\f214"}.fa-simplybuilt:before{content:"\f215"}.fa-skyatlas:before{content:"\f216"}.fa-cart-plus:before{content:"\f217"}.fa-cart-arrow-down:before{content:"\f218"}.fa-diamond:before{content:"\f219"}.fa-ship:before{content:"\f21a"}.fa-user-secret:before{content:"\f21b"}.fa-motorcycle:before{content:"\f21c"}.fa-street-view:before{content:"\f21d"}.fa-heartbeat:before{content:"\f21e"}.fa-venus:before{content:"\f221"}.fa-mars:before{content:"\f222"}.fa-mercury:before{content:"\f223"}.fa-transgender:before{content:"\f224"}.fa-transgender-alt:before{content:"\f225"}.fa-venus-double:before{content:"\f226"}.fa-mars-double:before{content:"\f227"}.fa-venus-mars:before{content:"\f228"}.fa-mars-stroke:before{content:"\f229"}.fa-mars-stroke-v:before{content:"\f22a"}.fa-mars-stroke-h:before{content:"\f22b"}.fa-neuter:before{content:"\f22c"}.fa-facebook-official:before{content:"\f230"}.fa-pinterest-p:before{content:"\f231"}.fa-whatsapp:before{content:"\f232"}.fa-server:before{content:"\f233"}.fa-user-plus:before{content:"\f234"}.fa-user-times:before{content:"\f235"}.fa-hotel:before,.fa-bed:before{content:"\f236"}.fa-viacoin:before{content:"\f237"}.fa-train:before{content:"\f238"}.fa-subway:before{content:"\f239"}.fa-medium:before{content:"\f23a"} \ No newline at end of file diff --git a/openecomp-ui/resources/fonts/fontawesome-webfont.eot b/openecomp-ui/resources/fonts/fontawesome-webfont.eot deleted file mode 100644 index 33b2bb8005..0000000000 Binary files a/openecomp-ui/resources/fonts/fontawesome-webfont.eot and /dev/null differ diff --git a/openecomp-ui/resources/fonts/fontawesome-webfont.svg b/openecomp-ui/resources/fonts/fontawesome-webfont.svg deleted file mode 100644 index 1ee89d4368..0000000000 --- a/openecomp-ui/resources/fonts/fontawesome-webfont.svg +++ /dev/null @@ -1,565 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/openecomp-ui/resources/fonts/fontawesome-webfont.ttf b/openecomp-ui/resources/fonts/fontawesome-webfont.ttf deleted file mode 100644 index ed9372f8ea..0000000000 Binary files a/openecomp-ui/resources/fonts/fontawesome-webfont.ttf and /dev/null differ diff --git a/openecomp-ui/resources/fonts/fontawesome-webfont.woff b/openecomp-ui/resources/fonts/fontawesome-webfont.woff deleted file mode 100644 index 8b280b98fa..0000000000 Binary files a/openecomp-ui/resources/fonts/fontawesome-webfont.woff and /dev/null differ diff --git a/openecomp-ui/resources/fonts/fontawesome-webfont.woff2 b/openecomp-ui/resources/fonts/fontawesome-webfont.woff2 deleted file mode 100644 index 3311d58514..0000000000 Binary files a/openecomp-ui/resources/fonts/fontawesome-webfont.woff2 and /dev/null differ diff --git a/openecomp-ui/resources/fonts/omnes-att-bold-italic.otf b/openecomp-ui/resources/fonts/omnes-att-bold-italic.otf deleted file mode 100644 index 77f0dbc15f..0000000000 Binary files a/openecomp-ui/resources/fonts/omnes-att-bold-italic.otf and /dev/null differ diff --git a/openecomp-ui/resources/fonts/omnes-att-bold.otf b/openecomp-ui/resources/fonts/omnes-att-bold.otf deleted file mode 100644 index 136afca84c..0000000000 Binary files a/openecomp-ui/resources/fonts/omnes-att-bold.otf and /dev/null differ diff --git a/openecomp-ui/resources/fonts/omnes-att-italic.otf b/openecomp-ui/resources/fonts/omnes-att-italic.otf deleted file mode 100644 index 5dc1da79d4..0000000000 Binary files a/openecomp-ui/resources/fonts/omnes-att-italic.otf and /dev/null differ diff --git a/openecomp-ui/resources/fonts/omnes-att-light-Italic.otf b/openecomp-ui/resources/fonts/omnes-att-light-Italic.otf deleted file mode 100644 index b13ae4fede..0000000000 Binary files a/openecomp-ui/resources/fonts/omnes-att-light-Italic.otf and /dev/null differ diff --git a/openecomp-ui/resources/fonts/omnes-att-light.otf b/openecomp-ui/resources/fonts/omnes-att-light.otf deleted file mode 100644 index 587d871e6f..0000000000 Binary files a/openecomp-ui/resources/fonts/omnes-att-light.otf and /dev/null differ diff --git a/openecomp-ui/resources/fonts/omnes-att-medium-italic.otf b/openecomp-ui/resources/fonts/omnes-att-medium-italic.otf deleted file mode 100644 index f824bc23e7..0000000000 Binary files a/openecomp-ui/resources/fonts/omnes-att-medium-italic.otf and /dev/null differ diff --git a/openecomp-ui/resources/fonts/omnes-att-medium.otf b/openecomp-ui/resources/fonts/omnes-att-medium.otf deleted file mode 100644 index 3085c1fa39..0000000000 Binary files a/openecomp-ui/resources/fonts/omnes-att-medium.otf and /dev/null differ diff --git a/openecomp-ui/resources/fonts/omnes-att-regular.otf b/openecomp-ui/resources/fonts/omnes-att-regular.otf deleted file mode 100644 index a1a78eb7ca..0000000000 Binary files a/openecomp-ui/resources/fonts/omnes-att-regular.otf and /dev/null differ diff --git a/openecomp-ui/resources/images/artifacts_icon.png b/openecomp-ui/resources/images/artifacts_icon.png new file mode 100644 index 0000000000..584f78d33a Binary files /dev/null and b/openecomp-ui/resources/images/artifacts_icon.png differ diff --git a/openecomp-ui/resources/images/base_icon.png b/openecomp-ui/resources/images/base_icon.png new file mode 100644 index 0000000000..439a517e03 Binary files /dev/null and b/openecomp-ui/resources/images/base_icon.png differ diff --git a/openecomp-ui/resources/images/download_icon.png b/openecomp-ui/resources/images/download_icon.png new file mode 100644 index 0000000000..307d0eff9e Binary files /dev/null and b/openecomp-ui/resources/images/download_icon.png differ diff --git a/openecomp-ui/resources/images/ecomp/ASDC_Sprite.png b/openecomp-ui/resources/images/ecomp/ASDC_Sprite.png deleted file mode 100644 index db4440427c..0000000000 Binary files a/openecomp-ui/resources/images/ecomp/ASDC_Sprite.png and /dev/null differ diff --git a/openecomp-ui/resources/images/ecomp/sprite-services-icons.png b/openecomp-ui/resources/images/ecomp/sprite-services-icons.png deleted file mode 100644 index afb3cbc286..0000000000 Binary files a/openecomp-ui/resources/images/ecomp/sprite-services-icons.png and /dev/null differ diff --git a/openecomp-ui/resources/images/icons/ZIP_blue_icon.png b/openecomp-ui/resources/images/icons/ZIP_blue_icon.png new file mode 100644 index 0000000000..a36d2473fc Binary files /dev/null and b/openecomp-ui/resources/images/icons/ZIP_blue_icon.png differ diff --git a/openecomp-ui/resources/images/icons/ZIP_icon.png b/openecomp-ui/resources/images/icons/ZIP_icon.png new file mode 100644 index 0000000000..82822d5727 Binary files /dev/null and b/openecomp-ui/resources/images/icons/ZIP_icon.png differ diff --git a/openecomp-ui/resources/images/icons/artifacts_blue_icon.png b/openecomp-ui/resources/images/icons/artifacts_blue_icon.png new file mode 100644 index 0000000000..46bc14884b Binary files /dev/null and b/openecomp-ui/resources/images/icons/artifacts_blue_icon.png differ diff --git a/openecomp-ui/resources/images/icons/artifacts_grey_icon.png b/openecomp-ui/resources/images/icons/artifacts_grey_icon.png new file mode 100644 index 0000000000..6f3e8a2ebf Binary files /dev/null and b/openecomp-ui/resources/images/icons/artifacts_grey_icon.png differ diff --git a/openecomp-ui/resources/images/icons/back_icon.png b/openecomp-ui/resources/images/icons/back_icon.png new file mode 100644 index 0000000000..305080a807 Binary files /dev/null and b/openecomp-ui/resources/images/icons/back_icon.png differ diff --git a/openecomp-ui/resources/images/icons/checked_in.png b/openecomp-ui/resources/images/icons/checked_in.png new file mode 100644 index 0000000000..44112ced13 Binary files /dev/null and b/openecomp-ui/resources/images/icons/checked_in.png differ diff --git a/openecomp-ui/resources/images/icons/checked_out.png b/openecomp-ui/resources/images/icons/checked_out.png new file mode 100644 index 0000000000..ac73c732bb Binary files /dev/null and b/openecomp-ui/resources/images/icons/checked_out.png differ diff --git a/openecomp-ui/resources/images/icons/down_chevron.png b/openecomp-ui/resources/images/icons/down_chevron.png new file mode 100644 index 0000000000..257f036646 Binary files /dev/null and b/openecomp-ui/resources/images/icons/down_chevron.png differ diff --git a/openecomp-ui/resources/images/icons/env_icon.png b/openecomp-ui/resources/images/icons/env_icon.png new file mode 100644 index 0000000000..83d6852a14 Binary files /dev/null and b/openecomp-ui/resources/images/icons/env_icon.png differ diff --git a/openecomp-ui/resources/images/icons/env_icon_blue.png b/openecomp-ui/resources/images/icons/env_icon_blue.png new file mode 100644 index 0000000000..bb30e26382 Binary files /dev/null and b/openecomp-ui/resources/images/icons/env_icon_blue.png differ diff --git a/openecomp-ui/resources/images/icons/error_icon_big.png b/openecomp-ui/resources/images/icons/error_icon_big.png new file mode 100644 index 0000000000..35dfeb318c Binary files /dev/null and b/openecomp-ui/resources/images/icons/error_icon_big.png differ diff --git a/openecomp-ui/resources/images/icons/error_icon_small.png b/openecomp-ui/resources/images/icons/error_icon_small.png new file mode 100644 index 0000000000..059aa9b201 Binary files /dev/null and b/openecomp-ui/resources/images/icons/error_icon_small.png differ diff --git a/openecomp-ui/resources/images/icons/go_to_overview_disable_icon.png b/openecomp-ui/resources/images/icons/go_to_overview_disable_icon.png new file mode 100644 index 0000000000..98bf1d92d8 Binary files /dev/null and b/openecomp-ui/resources/images/icons/go_to_overview_disable_icon.png differ diff --git a/openecomp-ui/resources/images/icons/go_to_overview_icon.png b/openecomp-ui/resources/images/icons/go_to_overview_icon.png new file mode 100644 index 0000000000..e996377fec Binary files /dev/null and b/openecomp-ui/resources/images/icons/go_to_overview_icon.png differ diff --git a/openecomp-ui/resources/images/icons/nested_HEAT_icon_blue.png b/openecomp-ui/resources/images/icons/nested_HEAT_icon_blue.png new file mode 100644 index 0000000000..21383bf4c1 Binary files /dev/null and b/openecomp-ui/resources/images/icons/nested_HEAT_icon_blue.png differ diff --git a/openecomp-ui/resources/images/icons/nested_heat_icon.png b/openecomp-ui/resources/images/icons/nested_heat_icon.png new file mode 100644 index 0000000000..beeaf20264 Binary files /dev/null and b/openecomp-ui/resources/images/icons/nested_heat_icon.png differ diff --git a/openecomp-ui/resources/images/icons/network_blue_icon.png b/openecomp-ui/resources/images/icons/network_blue_icon.png new file mode 100644 index 0000000000..5ed223d214 Binary files /dev/null and b/openecomp-ui/resources/images/icons/network_blue_icon.png differ diff --git a/openecomp-ui/resources/images/icons/network_icon.png b/openecomp-ui/resources/images/icons/network_icon.png new file mode 100644 index 0000000000..ec0f9208e4 Binary files /dev/null and b/openecomp-ui/resources/images/icons/network_icon.png differ diff --git a/openecomp-ui/resources/images/icons/orphans_blue_icon-n.png b/openecomp-ui/resources/images/icons/orphans_blue_icon-n.png new file mode 100644 index 0000000000..64a5949a6a Binary files /dev/null and b/openecomp-ui/resources/images/icons/orphans_blue_icon-n.png differ diff --git a/openecomp-ui/resources/images/icons/orphans_grey_icon.png b/openecomp-ui/resources/images/icons/orphans_grey_icon.png new file mode 100644 index 0000000000..f761ae71b8 Binary files /dev/null and b/openecomp-ui/resources/images/icons/orphans_grey_icon.png differ diff --git a/openecomp-ui/resources/images/icons/others_blue_icon.png b/openecomp-ui/resources/images/icons/others_blue_icon.png new file mode 100644 index 0000000000..e3953151dd Binary files /dev/null and b/openecomp-ui/resources/images/icons/others_blue_icon.png differ diff --git a/openecomp-ui/resources/images/icons/others_icon.png b/openecomp-ui/resources/images/icons/others_icon.png new file mode 100644 index 0000000000..cc498053d2 Binary files /dev/null and b/openecomp-ui/resources/images/icons/others_icon.png differ diff --git a/openecomp-ui/resources/images/icons/pencil_icon-01.svg b/openecomp-ui/resources/images/icons/pencil_icon-01.svg new file mode 100644 index 0000000000..50e38aa6a2 --- /dev/null +++ b/openecomp-ui/resources/images/icons/pencil_icon-01.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/icons/plus_vlm_summary_disabled_icon.png b/openecomp-ui/resources/images/icons/plus_vlm_summary_disabled_icon.png new file mode 100644 index 0000000000..dcd8081e74 Binary files /dev/null and b/openecomp-ui/resources/images/icons/plus_vlm_summary_disabled_icon.png differ diff --git a/openecomp-ui/resources/images/icons/plus_vlm_summary_icon.png b/openecomp-ui/resources/images/icons/plus_vlm_summary_icon.png new file mode 100644 index 0000000000..e50ce02a92 Binary files /dev/null and b/openecomp-ui/resources/images/icons/plus_vlm_summary_icon.png differ diff --git a/openecomp-ui/resources/images/icons/plus_vlm_summary_icon_blue.png b/openecomp-ui/resources/images/icons/plus_vlm_summary_icon_blue.png new file mode 100644 index 0000000000..09ecc4a2ea Binary files /dev/null and b/openecomp-ui/resources/images/icons/plus_vlm_summary_icon_blue.png differ diff --git a/openecomp-ui/resources/images/icons/revert_icon_disabled.png b/openecomp-ui/resources/images/icons/revert_icon_disabled.png new file mode 100644 index 0000000000..e0f55de1fd Binary files /dev/null and b/openecomp-ui/resources/images/icons/revert_icon_disabled.png differ diff --git a/openecomp-ui/resources/images/icons/reverticon.png b/openecomp-ui/resources/images/icons/reverticon.png new file mode 100644 index 0000000000..813f036788 Binary files /dev/null and b/openecomp-ui/resources/images/icons/reverticon.png differ diff --git a/openecomp-ui/resources/images/icons/save_icon_disable.png b/openecomp-ui/resources/images/icons/save_icon_disable.png new file mode 100644 index 0000000000..5eb6513027 Binary files /dev/null and b/openecomp-ui/resources/images/icons/save_icon_disable.png differ diff --git a/openecomp-ui/resources/images/icons/saveicon.png b/openecomp-ui/resources/images/icons/saveicon.png new file mode 100644 index 0000000000..64ada85cdb Binary files /dev/null and b/openecomp-ui/resources/images/icons/saveicon.png differ diff --git a/openecomp-ui/resources/images/icons/submit_icon_disable.png b/openecomp-ui/resources/images/icons/submit_icon_disable.png new file mode 100644 index 0000000000..ccb5775e8c Binary files /dev/null and b/openecomp-ui/resources/images/icons/submit_icon_disable.png differ diff --git a/openecomp-ui/resources/images/icons/submiticonactive.png b/openecomp-ui/resources/images/icons/submiticonactive.png new file mode 100644 index 0000000000..d0d36a1870 Binary files /dev/null and b/openecomp-ui/resources/images/icons/submiticonactive.png differ diff --git a/openecomp-ui/resources/images/icons/vlm_list_view_blue_icon.png b/openecomp-ui/resources/images/icons/vlm_list_view_blue_icon.png new file mode 100644 index 0000000000..da2b5bb027 Binary files /dev/null and b/openecomp-ui/resources/images/icons/vlm_list_view_blue_icon.png differ diff --git a/openecomp-ui/resources/images/icons/vlm_list_view_grey_icon.png b/openecomp-ui/resources/images/icons/vlm_list_view_grey_icon.png new file mode 100644 index 0000000000..582cf8eab4 Binary files /dev/null and b/openecomp-ui/resources/images/icons/vlm_list_view_grey_icon.png differ diff --git a/openecomp-ui/resources/images/icons/volume_blue_icon.png b/openecomp-ui/resources/images/icons/volume_blue_icon.png new file mode 100644 index 0000000000..34e47ac97e Binary files /dev/null and b/openecomp-ui/resources/images/icons/volume_blue_icon.png differ diff --git a/openecomp-ui/resources/images/icons/volume_icon.png b/openecomp-ui/resources/images/icons/volume_icon.png new file mode 100644 index 0000000000..ca2a2f8fcc Binary files /dev/null and b/openecomp-ui/resources/images/icons/volume_icon.png differ diff --git a/openecomp-ui/resources/images/icons/warning_icon_big.png b/openecomp-ui/resources/images/icons/warning_icon_big.png new file mode 100644 index 0000000000..c44d24021e Binary files /dev/null and b/openecomp-ui/resources/images/icons/warning_icon_big.png differ diff --git a/openecomp-ui/resources/images/icons/warning_icon_small.png b/openecomp-ui/resources/images/icons/warning_icon_small.png new file mode 100644 index 0000000000..1592ec5045 Binary files /dev/null and b/openecomp-ui/resources/images/icons/warning_icon_small.png differ diff --git a/openecomp-ui/resources/images/module_icon.png b/openecomp-ui/resources/images/module_icon.png new file mode 100644 index 0000000000..fd71a747db Binary files /dev/null and b/openecomp-ui/resources/images/module_icon.png differ diff --git a/openecomp-ui/resources/images/onboarding/vendor-license-model.svg b/openecomp-ui/resources/images/onboarding/vendor-license-model.svg deleted file mode 100644 index f23c30e05e..0000000000 --- a/openecomp-ui/resources/images/onboarding/vendor-license-model.svg +++ /dev/null @@ -1 +0,0 @@ -vendoe license model icon \ No newline at end of file diff --git a/openecomp-ui/resources/images/onboarding/vendor-software-product.svg b/openecomp-ui/resources/images/onboarding/vendor-software-product.svg deleted file mode 100644 index a547c4abdf..0000000000 --- a/openecomp-ui/resources/images/onboarding/vendor-software-product.svg +++ /dev/null @@ -1 +0,0 @@ -vendor software product \ No newline at end of file diff --git a/openecomp-ui/resources/images/pencil_icon-01.svg b/openecomp-ui/resources/images/pencil_icon-01.svg new file mode 100644 index 0000000000..50e38aa6a2 --- /dev/null +++ b/openecomp-ui/resources/images/pencil_icon-01.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/angle-double-left.svg b/openecomp-ui/resources/images/svg/angle-double-left.svg new file mode 100644 index 0000000000..9e1591a11d --- /dev/null +++ b/openecomp-ui/resources/images/svg/angle-double-left.svg @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/angle-double-right.svg b/openecomp-ui/resources/images/svg/angle-double-right.svg new file mode 100644 index 0000000000..e77031aa70 --- /dev/null +++ b/openecomp-ui/resources/images/svg/angle-double-right.svg @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/angle-left.svg b/openecomp-ui/resources/images/svg/angle-left.svg new file mode 100644 index 0000000000..b2d2f81b3d --- /dev/null +++ b/openecomp-ui/resources/images/svg/angle-left.svg @@ -0,0 +1,9 @@ + + + + + + + diff --git a/openecomp-ui/resources/images/svg/angle-right.svg b/openecomp-ui/resources/images/svg/angle-right.svg new file mode 100644 index 0000000000..f8e6efc3a6 --- /dev/null +++ b/openecomp-ui/resources/images/svg/angle-right.svg @@ -0,0 +1,9 @@ + + + + + + + diff --git a/openecomp-ui/resources/images/svg/back.svg b/openecomp-ui/resources/images/svg/back.svg new file mode 100644 index 0000000000..287355fa95 --- /dev/null +++ b/openecomp-ui/resources/images/svg/back.svg @@ -0,0 +1,6 @@ + + + + + diff --git a/openecomp-ui/resources/images/svg/caret-down.svg b/openecomp-ui/resources/images/svg/caret-down.svg new file mode 100644 index 0000000000..cfd3c57eb1 --- /dev/null +++ b/openecomp-ui/resources/images/svg/caret-down.svg @@ -0,0 +1,6 @@ + + + + + diff --git a/openecomp-ui/resources/images/svg/check-circle.svg b/openecomp-ui/resources/images/svg/check-circle.svg new file mode 100644 index 0000000000..313657e4a1 --- /dev/null +++ b/openecomp-ui/resources/images/svg/check-circle.svg @@ -0,0 +1 @@ + diff --git a/openecomp-ui/resources/images/svg/check.svg b/openecomp-ui/resources/images/svg/check.svg new file mode 100644 index 0000000000..43d18814b1 --- /dev/null +++ b/openecomp-ui/resources/images/svg/check.svg @@ -0,0 +1,9 @@ + + + + + + + diff --git a/openecomp-ui/resources/images/svg/chevron-down.svg b/openecomp-ui/resources/images/svg/chevron-down.svg new file mode 100644 index 0000000000..1ebd094459 --- /dev/null +++ b/openecomp-ui/resources/images/svg/chevron-down.svg @@ -0,0 +1,9 @@ + + + + + + + diff --git a/openecomp-ui/resources/images/svg/chevron-up.svg b/openecomp-ui/resources/images/svg/chevron-up.svg new file mode 100644 index 0000000000..7fce935e14 --- /dev/null +++ b/openecomp-ui/resources/images/svg/chevron-up.svg @@ -0,0 +1,9 @@ + + + + + + + diff --git a/openecomp-ui/resources/images/svg/close.svg b/openecomp-ui/resources/images/svg/close.svg new file mode 100644 index 0000000000..0decc7c2b6 --- /dev/null +++ b/openecomp-ui/resources/images/svg/close.svg @@ -0,0 +1,10 @@ + + + + + + + diff --git a/openecomp-ui/resources/images/svg/error-circle.svg b/openecomp-ui/resources/images/svg/error-circle.svg new file mode 100644 index 0000000000..8234753bd4 --- /dev/null +++ b/openecomp-ui/resources/images/svg/error-circle.svg @@ -0,0 +1 @@ +Asset 4 \ No newline at end of file diff --git a/openecomp-ui/resources/images/svg/exclamation-triangle-full.svg b/openecomp-ui/resources/images/svg/exclamation-triangle-full.svg new file mode 100644 index 0000000000..7cab121861 --- /dev/null +++ b/openecomp-ui/resources/images/svg/exclamation-triangle-full.svg @@ -0,0 +1,9 @@ + + + + + diff --git a/openecomp-ui/resources/images/svg/exclamation-triangle-line.svg b/openecomp-ui/resources/images/svg/exclamation-triangle-line.svg new file mode 100644 index 0000000000..eae682503d --- /dev/null +++ b/openecomp-ui/resources/images/svg/exclamation-triangle-line.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/exclamation-triangle.svg b/openecomp-ui/resources/images/svg/exclamation-triangle.svg new file mode 100644 index 0000000000..245661242a --- /dev/null +++ b/openecomp-ui/resources/images/svg/exclamation-triangle.svg @@ -0,0 +1,11 @@ + + + + + + + diff --git a/openecomp-ui/resources/images/svg/filter.svg b/openecomp-ui/resources/images/svg/filter.svg new file mode 100644 index 0000000000..1c493f4653 --- /dev/null +++ b/openecomp-ui/resources/images/svg/filter.svg @@ -0,0 +1,9 @@ + + + + + diff --git a/openecomp-ui/resources/images/svg/locked.svg b/openecomp-ui/resources/images/svg/locked.svg new file mode 100644 index 0000000000..9785f8df11 --- /dev/null +++ b/openecomp-ui/resources/images/svg/locked.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/pencil.svg b/openecomp-ui/resources/images/svg/pencil.svg new file mode 100644 index 0000000000..6701a3aba0 --- /dev/null +++ b/openecomp-ui/resources/images/svg/pencil.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/plus-circle.svg b/openecomp-ui/resources/images/svg/plus-circle.svg new file mode 100644 index 0000000000..9a0f023be7 --- /dev/null +++ b/openecomp-ui/resources/images/svg/plus-circle.svg @@ -0,0 +1,15 @@ + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/plus.svg b/openecomp-ui/resources/images/svg/plus.svg new file mode 100644 index 0000000000..36f3486717 --- /dev/null +++ b/openecomp-ui/resources/images/svg/plus.svg @@ -0,0 +1,9 @@ + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/search.svg b/openecomp-ui/resources/images/svg/search.svg new file mode 100644 index 0000000000..ce8310429a --- /dev/null +++ b/openecomp-ui/resources/images/svg/search.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/openecomp-ui/resources/images/svg/sliders.svg b/openecomp-ui/resources/images/svg/sliders.svg new file mode 100644 index 0000000000..ade9de2435 --- /dev/null +++ b/openecomp-ui/resources/images/svg/sliders.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/trash-o.svg b/openecomp-ui/resources/images/svg/trash-o.svg new file mode 100644 index 0000000000..26336f172f --- /dev/null +++ b/openecomp-ui/resources/images/svg/trash-o.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/unlocked.svg b/openecomp-ui/resources/images/svg/unlocked.svg new file mode 100644 index 0000000000..6d94a94247 --- /dev/null +++ b/openecomp-ui/resources/images/svg/unlocked.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/vendor.svg b/openecomp-ui/resources/images/svg/vendor.svg new file mode 100644 index 0000000000..a3b8f5f0a3 --- /dev/null +++ b/openecomp-ui/resources/images/svg/vendor.svg @@ -0,0 +1 @@ +vendor diff --git a/openecomp-ui/resources/images/svg/version-controller-lock-closed.svg b/openecomp-ui/resources/images/svg/version-controller-lock-closed.svg new file mode 100644 index 0000000000..73aae7dbf2 --- /dev/null +++ b/openecomp-ui/resources/images/svg/version-controller-lock-closed.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/version-controller-lock-open.svg b/openecomp-ui/resources/images/svg/version-controller-lock-open.svg new file mode 100644 index 0000000000..52e0b8bf71 --- /dev/null +++ b/openecomp-ui/resources/images/svg/version-controller-lock-open.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/version-controller-revert.svg b/openecomp-ui/resources/images/svg/version-controller-revert.svg new file mode 100644 index 0000000000..f9f02f94be --- /dev/null +++ b/openecomp-ui/resources/images/svg/version-controller-revert.svg @@ -0,0 +1,14 @@ + + + + + + + diff --git a/openecomp-ui/resources/images/svg/version-controller-save.svg b/openecomp-ui/resources/images/svg/version-controller-save.svg new file mode 100644 index 0000000000..4a05425ed7 --- /dev/null +++ b/openecomp-ui/resources/images/svg/version-controller-save.svg @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/version-controller-submit.svg b/openecomp-ui/resources/images/svg/version-controller-submit.svg new file mode 100644 index 0000000000..9909ab3c6e --- /dev/null +++ b/openecomp-ui/resources/images/svg/version-controller-submit.svg @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/openecomp-ui/resources/images/svg/vlm.svg b/openecomp-ui/resources/images/svg/vlm.svg new file mode 100644 index 0000000000..79b4625a09 --- /dev/null +++ b/openecomp-ui/resources/images/svg/vlm.svg @@ -0,0 +1 @@ +vlm_new_icon \ No newline at end of file diff --git a/openecomp-ui/resources/images/svg/vsp.svg b/openecomp-ui/resources/images/svg/vsp.svg new file mode 100644 index 0000000000..344755c2ab --- /dev/null +++ b/openecomp-ui/resources/images/svg/vsp.svg @@ -0,0 +1 @@ +vsp_new_icon diff --git a/openecomp-ui/resources/images/trash_icon.png b/openecomp-ui/resources/images/trash_icon.png new file mode 100644 index 0000000000..ebc17aef38 Binary files /dev/null and b/openecomp-ui/resources/images/trash_icon.png differ diff --git a/openecomp-ui/resources/images/upload_icon.png b/openecomp-ui/resources/images/upload_icon.png new file mode 100644 index 0000000000..55f60f654e Binary files /dev/null and b/openecomp-ui/resources/images/upload_icon.png differ diff --git a/openecomp-ui/resources/images/v_icon.png b/openecomp-ui/resources/images/v_icon.png new file mode 100644 index 0000000000..387e3037fc Binary files /dev/null and b/openecomp-ui/resources/images/v_icon.png differ diff --git a/openecomp-ui/resources/scss/_components.scss b/openecomp-ui/resources/scss/_components.scss index 884308885a..bd85f547c9 100644 --- a/openecomp-ui/resources/scss/_components.scss +++ b/openecomp-ui/resources/scss/_components.scss @@ -2,7 +2,6 @@ @import "components/buttons"; @import "components/forms"; @import "components/validationForm"; -@import "components/slidePanel"; @import "components/dualListBox"; @import "components/listEditorView"; @import "components/toggleInput"; @@ -16,6 +15,11 @@ @import "components/dropzone"; @import "components/submitErrorResponse"; @import "components/expandableInput"; +@import "components/grid"; +@import "components/icon"; +@import "components/svgIcon"; +@import "components/activityLog"; +@import "components/selectActionTable"; %noselect { -webkit-touch-callout: none; @@ -53,7 +57,7 @@ } .search-icon { position: relative; - left: -20px; + left: -23px; align-self: center; width: 0; color: $dark-gray; @@ -71,3 +75,29 @@ margin-left: 50%; color: $yellow; } + +.chevron::before { + border-style: solid; + border-width: 0.15em 0.15em 0 0; + content: ''; + display: inline-block; + height: 0.8em; + left: 0.15em; + position: relative; + top: 0.15em; + vertical-align: top; + width: 0.8em; +} +.chevron.right:before { + left: 0; + transform: rotate(45deg); +} +.chevron.down:before { + transform: rotate(135deg); +} +.chevron.left:before { + transform: rotate(-135deg); +} +.chevron.top:before { + transform: rotate(-45deg); +} diff --git a/openecomp-ui/resources/scss/_modules.scss b/openecomp-ui/resources/scss/_modules.scss index fd35bf2e0b..578895dfe0 100644 --- a/openecomp-ui/resources/scss/_modules.scss +++ b/openecomp-ui/resources/scss/_modules.scss @@ -1,3 +1,4 @@ +@import "modules/licenseModelOverview"; @import "modules/licenseAgreement"; @import "modules/featureGroup"; @import "modules/entitlementPools"; @@ -7,16 +8,15 @@ @import "modules/_softwareProductAttachmentPage"; @import "modules/_softwareProductProcessesPage"; @import "modules/_vspComponentQuestionnaire"; -@import "modules/_softwareProductNetworksPage"; @import "modules/_softwareProductComponentNetwork"; @import "modules/_softwareProductComponentGeneral"; @import "modules/_softwareproductComponentLoadBalancing"; +@import "modules/_softwareProductComponentProcessesPage"; +@import "modules/softwareProductComponentCompute"; @import "modules/vspComponentMonitoring"; @import "modules/licenseModel"; @import "modules/onboardingCatalog"; @import "modules/workflows"; @import "modules/uploadScreen"; - - - - +@import "modules/vspHeatSetup"; +@import "modules/softwareProductDependencies"; diff --git a/openecomp-ui/resources/scss/bootstrap-cust/_forms.scss b/openecomp-ui/resources/scss/bootstrap-cust/_forms.scss index 545b23ee7f..8085274cac 100644 --- a/openecomp-ui/resources/scss/bootstrap-cust/_forms.scss +++ b/openecomp-ui/resources/scss/bootstrap-cust/_forms.scss @@ -88,10 +88,11 @@ input[type=radio]:checked:before { input[type=checkbox]:checked:before { font-family: $icon-font-family; - content: "\f00c"; + content: "\2714"; font-size: $icon-font-size; color: $blue; text-align: center; + line-height: 13px; } .radio, diff --git a/openecomp-ui/resources/scss/bootstrap-cust/_modals.scss b/openecomp-ui/resources/scss/bootstrap-cust/_modals.scss index 6bc6e46b2f..6a825b811e 100644 --- a/openecomp-ui/resources/scss/bootstrap-cust/_modals.scss +++ b/openecomp-ui/resources/scss/bootstrap-cust/_modals.scss @@ -7,7 +7,12 @@ } .modal-body{ - padding: 15px; + padding: 0; + .validation-form-content { + padding: 50px; + overflow-y: auto; + max-height: 490px; + } } .modal-footer { diff --git a/openecomp-ui/resources/scss/bootstrap-cust/_variables.scss b/openecomp-ui/resources/scss/bootstrap-cust/_variables.scss index 59f0e3db7c..1af39d5b39 100644 --- a/openecomp-ui/resources/scss/bootstrap-cust/_variables.scss +++ b/openecomp-ui/resources/scss/bootstrap-cust/_variables.scss @@ -125,3 +125,8 @@ $nav-tabs-active-link-hover-border-color: transparent; // //## $popover-bg: $background-gray; + +//== Tooltips +// +//## +$tooltip-bg: $dark-gray; diff --git a/openecomp-ui/resources/scss/common/_base.scss b/openecomp-ui/resources/scss/common/_base.scss index aa3ffdeb2b..e901db000e 100644 --- a/openecomp-ui/resources/scss/common/_base.scss +++ b/openecomp-ui/resources/scss/common/_base.scss @@ -44,6 +44,10 @@ input { padding: 7px 10px; } +.disabled { + opacity: 0.7 !important; +} + fieldset { border: none; } @@ -64,3 +68,7 @@ fieldset { .box-hover { border: 1px solid $light-blue; } + + + + diff --git a/openecomp-ui/resources/scss/common/_layout.scss b/openecomp-ui/resources/scss/common/_layout.scss index 6d63a79f55..dc2a33ccc7 100644 --- a/openecomp-ui/resources/scss/common/_layout.scss +++ b/openecomp-ui/resources/scss/common/_layout.scss @@ -15,8 +15,15 @@ .content-area { padding: 30px 60px 70px 60px; overflow-y: auto; + overflow-x: hidden; height: 100%; &.no-padding-content-area { padding: 0; } } + +.onborading-modal { + .modal-title { + text-transform: uppercase; + } +} \ No newline at end of file diff --git a/openecomp-ui/resources/scss/common/_typography.scss b/openecomp-ui/resources/scss/common/_typography.scss index 46edfb03de..1543f0adcd 100644 --- a/openecomp-ui/resources/scss/common/_typography.scss +++ b/openecomp-ui/resources/scss/common/_typography.scss @@ -1,28 +1,20 @@ /* Fonts */ -@font-face { - font-family: Omnes-Light; - src: url('../fonts/omnes-att-light.otf'); -} -@font-face { - font-family: Omnes-Regular; - src: url('../fonts/omnes-att-regular.otf'); +@mixin base-font-regular() { + font-family: omnes-regular, Arial, sans-serif; } -@font-face { - font-family: Omnes-Medium; - src: url('../fonts/omnes-att-medium.otf'); +@mixin base-font-light() { + font-family: omnes-light, Arial, sans-serif; } -@font-face { - font-family: Omnes-Bold; - src: url('../fonts/omnes-att-bold.otf'); +@mixin base-font-medium() { + font-family: omnes-medium, Arial, sans-serif; } -$base-font-regular: omnes-regular, "Omnes-Regular"; -$base-font-light: omnes-light, "Omnes-Light"; -$base-font-medium: omnes-medium, "Omnes-Medium"; -$base-font-bold: omnes-bold, "Omnes-Bold"; +@mixin base-font-bold() { + font-family: omnes-bold, Arial, sans-serif; +} $heading-font-1: 36px; $heading-font-2: 24px; @@ -34,82 +26,106 @@ $body-font-1: 14px; $body-font-2: 13px; $body-font-3: 12px; -$icon-font-size: 10px; -$icon-font-family: FontAwesome; +$icon-font-size: 11px; +$icon-font-family: Arial; $radio-font-family: Arial; .heading-1 { - font-family: $base-font-light; + @include base-font-light; font-size: $heading-font-1; } .heading-2 { - font-family: $base-font-light; + @include base-font-light; font-size: $heading-font-2; } .heading-3-light { - font-family: $base-font-light; + @include base-font-light; font-size: $heading-font-3; + @extend .text-uppercase !optional; } .heading-3 { - font-family: $base-font-regular; + @include base-font-regular; font-size: $heading-font-3; + @extend .text-uppercase !optional; } .heading-3-medium { - font-family: $base-font-medium; + @include base-font-medium; font-size: $heading-font-3; + @extend .text-uppercase !optional; } .heading-4 { - font-family: $base-font-regular; + @include base-font-regular; font-size: $heading-font-4; } .heading-4-medium { - font-family: $base-font-medium; + @include base-font-medium; font-size: $heading-font-4; } .heading-5 { - font-family: $base-font-regular; + @include base-font-regular; font-size: $heading-font-5; } .heading-5-medium { - font-family: $base-font-medium; + @include base-font-medium; font-size: $heading-font-5; } .body-1 { - font-family: $base-font-regular; + @include base-font-regular; font-size: $body-font-1; } .body-1-medium { - font-family: $base-font-medium; + @include base-font-medium; + font-size: $body-font-1; +} + +.body-1-light { + @include base-font-light; font-size: $body-font-1; } .body-2 { - font-family: $base-font-regular; + @include base-font-regular; font-size: $body-font-2; } .body-2-medium { - font-family: $base-font-medium; + @include base-font-medium; font-size: $body-font-2; } .body-3 { - font-family: $base-font-regular; + @include base-font-regular; font-size: $body-font-3; } .body-3-medium { - font-family: $base-font-medium; + @include base-font-medium; font-size: $body-font-3; } +.body-3-light { + @include base-font-light; + font-size: $body-font-3; +} + +.circle-icon-text { + @include base-font-medium; + font-size: $body-font-1; +} + +.warning-text { + color: $orange; +} +.error-text { + color: $red; +} diff --git a/openecomp-ui/resources/scss/common/_utils.scss b/openecomp-ui/resources/scss/common/_utils.scss index 70f3416e4b..dce623e15d 100644 --- a/openecomp-ui/resources/scss/common/_utils.scss +++ b/openecomp-ui/resources/scss/common/_utils.scss @@ -15,27 +15,27 @@ $browserPrefixes: webkit moz o ms; @mixin prefix($property, $value, $prefixeslist: 'all') { @if $prefixeslist == all { - -webkit-#{$property}: $value; - -moz-#{$property}: $value; - -ms-#{$property}: $value; - -o-#{$property}: $value; - #{$property}: $value; + -webkit-#{$property}: $value; + -moz-#{$property}: $value; + -ms-#{$property}: $value; + -o-#{$property}: $value; + #{$property}: $value; } @else { - @each $prefix in $prefixeslist { - @if $prefix == webkit { - -webkit-#{$property}: $value; - } @else if $prefix == moz { - -moz-#{$property}: $value; - } @else if $prefix == ms { - -ms-#{$property}: $value; - } @else if $prefix == o { - -o-#{$property}: $value; - } @else if $prefix == spec { - #{$property}: $value; - } @else { - @warn "No such prefix: #{$prefix}"; - } - } + @each $prefix in $prefixeslist { + @if $prefix == webkit { + -webkit-#{$property}: $value; + } @else if $prefix == moz { + -moz-#{$property}: $value; + } @else if $prefix == ms { + -ms-#{$property}: $value; + } @else if $prefix == o { + -o-#{$property}: $value; + } @else if $prefix == spec { + #{$property}: $value; + } @else { + @warn "No such prefix: #{$prefix}"; + } + } } } @@ -43,25 +43,25 @@ $browserPrefixes: webkit moz o ms; @mixin value-suffix-with-range($property, $valuesuffix, $from, $to, $prefixeslist) { @if $prefixeslist == all { - #{property} : -webkit-#{$valuesuffix}($from, $to); - #{property} : -moz-#{$valuesuffix}($from, $to); - #{property} : -o-#{$valuesuffix}($from, $to); - #{property} : -ms-#{$valuesuffix}($from, $to); + #{property} : -webkit-#{$valuesuffix}($from, $to); + #{property} : -moz-#{$valuesuffix}($from, $to); + #{property} : -o-#{$valuesuffix}($from, $to); + #{property} : -ms-#{$valuesuffix}($from, $to); } @else { - @each $prefix in $prefixeslist { - @if $prefix == webkit { - #{property} : -webkit-#{$valuesuffix}($from, $to); - } @else if $prefix == moz { - #{property} : -moz-#{$valuesuffix}($from, $to); - } @else if $prefix == ms { - #{property} : -ms-#{$valuesuffix}($from, $to); - } @else if $prefix == o { - #{property} : -o-#{$valuesuffix}($from, $to); - } @else { - @warn "No such prefix: #{$prefix}"; - } - } + @each $prefix in $prefixeslist { + @if $prefix == webkit { + #{property} : -webkit-#{$valuesuffix}($from, $to); + } @else if $prefix == moz { + #{property} : -moz-#{$valuesuffix}($from, $to); + } @else if $prefix == ms { + #{property} : -ms-#{$valuesuffix}($from, $to); + } @else if $prefix == o { + #{property} : -o-#{$valuesuffix}($from, $to); + } @else { + @warn "No such prefix: #{$prefix}"; + } + } } } @@ -81,11 +81,11 @@ $browserPrefixes: webkit moz o ms; @mixin border-radius($value, $positions: all) { @if ($positions == all) { - @include prefix(border-radius, $value, $border-radius-prefix); + @include prefix(border-radius, $value, $border-radius-prefix); } @else { - @each $position in $positions { - @include prefix(border-#{$position}-radius, $value, $border-radius-prefix); - } + @each $position in $positions { + @include prefix(border-#{$position}-radius, $value, $border-radius-prefix); + } } } @@ -102,12 +102,39 @@ $browserPrefixes: webkit moz o ms; } /* Ellipsis */ -@mixin ellipsis() { +@mixin ellipsis($width: 100%, $display: inline-block, $max-width: none) { overflow: hidden; text-overflow: ellipsis; - width: 100%; + width: $width; white-space: nowrap; - display: inline-block; + display: $display; + max-width: $max-width; +} + +@mixin multiline-ellipsis($lineHeight: 1.3em, $lineCount: 2, $bgColor: $white){ + overflow: hidden; + position: relative; + line-height: $lineHeight; + max-height: $lineHeight * $lineCount; + text-align: justify; + word-break: break-all; + // margin-right: -1em; + padding-right: 1em; + &:before { + content: '...'; + position: absolute; + right: 3px; + bottom: 0; + } + &:after { + content: ''; + position: absolute; + right: 0; + width: 1em; + height: 1em; + margin-top: 0.2em; + background: $bgColor; + } } @mixin gradient($from, $to) { @@ -124,52 +151,13 @@ $browserPrefixes: webkit moz o ms; margin-top: -$height/2; } -@mixin multiline-ellipsis($height, $lineheight, $ellipsiswidth: 3em) { - - $ellipsiswidth: 3em !default; - - .ellipsis { - overflow: hidden; - height: $height; - line-height: $lineheight; - } - - .ellipsis:before { - content: ""; - float: left; - width: 5px; - height: $height; - } - - .ellipsis > *:first-child { - float: right; - width: 100%; - margin-left: -5px; - } - - .ellipsis:after { - content: "\02026"; - - float: right; - position: relative; - top: -25px; - left: 100%; - width: $ellipsiswidth; - margin-left: -$ellipsiswidth; - padding-right: 5px; - - text-align: right; - } - -} - @mixin text-vertical-align($align: middle) { display: table; width: 100%; & > * { - vertical-align: $align; - display: table-cell; + vertical-align: $align; + display: table-cell; } } @@ -181,7 +169,7 @@ $browserPrefixes: webkit moz o ms; @mixin center-content($width) { & > * { - @include center-element($width); + @include center-element($width); } } @@ -202,9 +190,9 @@ $browserPrefixes: webkit moz o ms; // @param // $deg - angle in degrees @mixin transform-translate($x, $y) { - transform: translate($x, $y); /* IE10 and Mozilla */ - -ms-transform: translate($x, $y); /* IE 9 */ - -webkit-transform: translate($x, $y); /* Safari and Chrome */ + transform: translate($x, $y); /* IE10 and Mozilla */ + -ms-transform: translate($x, $y); /* IE 9 */ + -webkit-transform: translate($x, $y); /* Safari and Chrome */ } /* transform-scale */ @@ -222,7 +210,22 @@ $browserPrefixes: webkit moz o ms; @mixin scrollable() { ::-webkit-scrollbar { - width: 8px; + width: 8px; + } +} + +@mixin create-circle($size, $bgcolor, $content) { + border-radius: 50%; + width: $size; + height: $size; + background: $bgcolor; + border: 3px solid $bgcolor; + &:after { + content: $content; + position: relative; + left: 9px; + top: 9px; + @extend .circle-icon-text; } } @@ -297,3 +300,9 @@ $browserPrefixes: webkit moz o ms; } } } + + +/**/ +@mixin border-shadow($xShadow: 0.545px, $yShadow: 0.839px, $blur: 4px, $spread: 0, $color: $light-gray, $opacity: 0.2) { + @include box-shadow($xShadow $yShadow $blur $spread rgba($color, $opacity)); +} diff --git a/openecomp-ui/resources/scss/common/_variables.scss b/openecomp-ui/resources/scss/common/_variables.scss index 92c20cdfdf..2162b0b1b0 100644 --- a/openecomp-ui/resources/scss/common/_variables.scss +++ b/openecomp-ui/resources/scss/common/_variables.scss @@ -19,6 +19,7 @@ $white: #ffffff; // Secondary Colors $red: #cf2a2a; +$crimson: #a94442; $background-alice-blue: #e5f5fb; $background-gray: #f2f2f2; @@ -29,10 +30,15 @@ $functional-yellow: #ffb81c; $tlv-gray: #f8f8f8; $tlv-light-gray: #eaeaea; $tlv-hover: #e6f6fb; +$highlight-gray: #eceff3; $content-background-color: $white; $scroll-bar-color: $text-black;//$light-gray; +$vc-status-text-color: #42b72a; + +// sizes +$circle-icon-size: 40px; //responsive @media params $tablet-max-width: 1024px; @@ -41,7 +47,59 @@ $desktop-min-width: 1824px; /* Textures */ $images-folder-name: "../images"; -$plus-circle-icon: $images-folder-name + "/plus-circle-icon.svg"; -$interface-icon: $images-folder-name + "/interface.svg"; -$sdc-logo: $images-folder-name + "/logo.svg"; -$warning-icon: $images-folder-name + "/warning.svg"; + +/* Icons */ +$icons-folder: "../images/icons"; +$artifacts-icon: $images-folder-name + "/artifacts_icon.png"; +$check-icon: $images-folder-name + "/v_icon.png"; +$base-module-icon: $images-folder-name + "/base_icon.png"; +$module-icon: $images-folder-name + "/module_icon.png"; +$pencil-icon: $images-folder-name + "/pencil_icon-01.svg"; +$vc-check-in-icon: $icons-folder + "/checked_in.png"; +$vc-checkout-icon: $icons-folder + "/checked_out.png"; +$vc-revert-icon: $icons-folder + "/reverticon.png"; +$vc-revert-disabled-icon: $icons-folder + "/revert_icon_disabled.png"; +$vc-save-icon: $icons-folder + "/saveicon.png"; +$vc-save-disabled-icon: $icons-folder + "/save_icon_disable.png"; +$vc-submit-icon: $icons-folder + "/submiticonactive.png"; +$vc-submit-disabled-icon: $icons-folder + "/submit_icon_disable.png"; +$trash-icon: $images-folder-name + "/trash_icon.png"; +$download-icon: $images-folder-name + "/download_icon.png"; +$upload-icon: $images-folder-name + "/upload_icon.png"; + + +/* catalog icons */ +$back-icon: $icons-folder + "/back_icon.png"; +/* validation icons */ +$artifacts-selected-icon: $icons-folder + "/artifacts_blue_icon.png"; +$artifacts-regular-icon: $icons-folder + "/artifacts_grey_icon.png"; +$chevron_down: $icons-folder + "/down_chevron.png"; +$error-icon-lg: $icons-folder + "/error_icon_big.png"; +$error-icon-sm: $icons-folder + "/error_icon_small.png"; +$go-to-overview-icon: $icons-folder + "/go_to_overview_icon.png"; +$go-to-overview-disabled-icon: $icons-folder + "/go_to_overview_disable_icon.png"; +$network-selected-icon: $icons-folder + "/network_blue_icon.png"; +$network-icon: $icons-folder + "/network_icon.png"; +$others-selected-icon: $icons-folder + "/others_blue_icon.png"; +$others-icon: $icons-folder + "/others_icon.png"; +$volume-selected-icon: $icons-folder + "/volume_blue_icon.png"; +$volume-icon: $icons-folder + "/volume_icon.png"; +$warning-icon-lg: $icons-folder + "/warning_icon_big.png"; +$warning-icon-sm: $icons-folder + "/warning_icon_small.png"; +$zip-icon: $icons-folder + "/ZIP_icon.png"; +$zip-selected-icon: $icons-folder + "/ZIP_blue_icon.png"; +$heat-icon: $icons-folder + "/nested_heat_icon.png"; +$heat-selected-icon: $icons-folder + "/nested_HEAT_icon_blue.png"; +$env-icon: $icons-folder + "/env_icon.png"; +$env-selected-icon: $icons-folder + "/env_icon_blue.png"; + +/* vlm summary icons */ + +$vlm-summary-plus-blue: $icons-folder + "/plus_vlm_summary_icon_blue.png"; +$vlm-summary-plus: $icons-folder + "/plus_vlm_summary_icon.png"; +$vlm-summary-plus-disabled: $icons-folder + "/plus_vlm_summary_disabled_icon.png"; +$vlm-summary-orphans: $icons-folder + "/orphans_grey_icon.png"; +$vlm-summary-orphans-blue: $icons-folder + "/orphans_blue_icon-n.png"; +$vlm-summary-used: $icons-folder + "/vlm_list_view_grey_icon.png"; +$vlm-summary-used-blue: $icons-folder + "/vlm_list_view_blue_icon.png"; + diff --git a/openecomp-ui/resources/scss/components/_activityLog.scss b/openecomp-ui/resources/scss/components/_activityLog.scss new file mode 100644 index 0000000000..1e31e06814 --- /dev/null +++ b/openecomp-ui/resources/scss/components/_activityLog.scss @@ -0,0 +1,104 @@ +$message-info-icon-size: 16px; + +@mixin status-icon-class { + @extend .body-1-light; + width: $message-info-icon-size; + height: $message-info-icon-size; + margin-left: 8px; + color: $white; + border-radius: $message-info-icon-size / 2; + display: inline-block; + text-align: center; +} + +.activity-log-view { + + .list-editor-view .list-editor-view-header { + border: none; + .list-editor-view-title { + @extend .heading-1; + color: $blue; + } + } + .list-editor-view-list { + border: 1px solid $light-gray; + border-bottom: none; + } + .activity-list-item { + display: flex; + height: 36px; + @extend .body-1; + &.header { + @extend .body-1-medium; + background-color: $tlv-light-gray; + color: $text-black; + } + } + + .activity-status { + .svg-icon-wrapper { + float: right; + } + .check-circle { + fill: $green; + width: 16px; + height: 16px; + } + .status-icon.false:after { + @include status-icon-class; + float: right; + background-color: $red; + content: "!"; + } + } + + .message-further-info-icon { + @include status-icon-class; + background-color: $gray; + } + + .table-cell { + border-right: 1px solid $light-gray; + border-bottom: 1px solid $light-gray; + &:last-child { + border-right: none; + } + flex-basis: 20%; + display: flex; + padding: 0 20px; + justify-content: center; + flex-direction: column; + &.activity-comment { + min-width: 0; + span { + @include ellipsis(100%); + } + } + } + + .date-header { + cursor: pointer; + display: flex; + align-items: center; + .header-sort-arrow { + width: 0; + height: 0; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + margin-left: 9px; + &.up { + border-bottom: 5px solid $black; + } + &.down { + border-top: 5px solid $black; + } + + } + } + + .date-cell { + display: flex; + justify-content: space-between; + } + +} diff --git a/openecomp-ui/resources/scss/components/_buttons.scss b/openecomp-ui/resources/scss/components/_buttons.scss index b39ea495ab..fbf2c3e728 100644 --- a/openecomp-ui/resources/scss/components/_buttons.scss +++ b/openecomp-ui/resources/scss/components/_buttons.scss @@ -1,18 +1,3 @@ - -$plus-circle-icon-size: 18px; -.plus-icon-button { - background: url($plus-circle-icon) no-repeat; - background-size: $plus-circle-icon-size; - width: $plus-circle-icon-size; - height: $plus-circle-icon-size; - cursor: pointer; - &.small { - background-size: $plus-circle-icon-size - 6; - width: $plus-circle-icon-size - 6; - height: $plus-circle-icon-size - 6; - } -} - .primary-btn{ border: 1px solid; border-color: $blue; diff --git a/openecomp-ui/resources/scss/components/_dualListBox.scss b/openecomp-ui/resources/scss/components/_dualListBox.scss index 543c1c8b92..4a1a940c34 100644 --- a/openecomp-ui/resources/scss/components/_dualListBox.scss +++ b/openecomp-ui/resources/scss/components/_dualListBox.scss @@ -1,6 +1,10 @@ .dual-list-box { display: flex; margin: 25px 0 10px 0; + .svg-icon.search { + height: 14px; + width: 14px; + } .dual-search-multi-select-section { $multi-select-box-width: 398px; @@ -32,6 +36,10 @@ .dual-list-options-bar { margin: 62px 54px 27px 54px; padding-top: 23px; + .svg-icon { + width: 14px; + height: 14px; + } .dual-list-option { text-align: center; line-height: 10px; @@ -40,7 +48,7 @@ height: 15px; cursor: pointer; margin-top: 20px; - color: $blue; + fill: $blue; } } } diff --git a/openecomp-ui/resources/scss/components/_expandableInput.scss b/openecomp-ui/resources/scss/components/_expandableInput.scss index 52f410a61b..52b72d7c91 100644 --- a/openecomp-ui/resources/scss/components/_expandableInput.scss +++ b/openecomp-ui/resources/scss/components/_expandableInput.scss @@ -1,61 +1,55 @@ -$transitionLength: 0.5s; - -@mixin expand-transition($tl){ - transition: width $tl, background-color $tl, cursor $tl; -} - -@mixin color-transition($tl){ - transition: color $tl; -} - -.expandable-input-wrapper { - display: flex; - &:hover{ - .form-control { - border-color: $gray; - } - } - .expandable-input-control { - flex: 1 1; - margin: 0; - .form-control { - border-radius: 20px; - } - align-self: center; - } - .expandable-active { - @include expand-transition($transitionLength); - width: 215px; - cursor: text; - } - .expandable-not-active { - @include expand-transition($transitionLength); - width: 28px; - cursor: pointer; - background-color: transparent; - color: transparent; +.expandable-input-top { + display: flex; + height: 22px; + .svg-icon-wrapper { + height: 17px; + width: 17px; } - - .expandable-icon { - @include color-transition($transitionLength); - position: relative; - left: -20px; - align-self: center; - width: 0; - cursor: pointer; - color: $dark-gray; - } - - .expandable-close-button{ - @extend .expandable-icon; - color: $gray; - opacity: 0.5; - &:hover { - opacity: 1; + .expandable-input-wrapper { + display: flex; + .svg-icon.search { + height: 17px; + width: 17px; + } + &.closed { + .svg-icon.search { + transition: fill 0.5s ease-in; + fill: $blue; + cursor: pointer; + &:hover { + transition: fill 0.5s ease-in; + fill: $dark-blue; + } + } + } + &.opened { + .svg-icon-wrapper { + margin-left: 3px; + } + .svg-icon.search { + fill: $dark-blue; + } + .svg-icon.close { + margin-left: 7px; + height: 10px; + width: 10px; + opacity: 0.6; + fill: $dark-gray; + &:hover { + opacity: 1; + } + } + } + .expandable-input-control { + .form-control { + border: none; + background-color: transparent; + border-radius: 0; + border-bottom: 1px solid $gray; + height: 22px; + padding: 0 5px; + } + margin: 0; } - } - .expandable-icon-active { - @include color-transition($transitionLength); - color: $blue; } } diff --git a/openecomp-ui/resources/scss/components/_forms.scss b/openecomp-ui/resources/scss/components/_forms.scss index 3c50fe694a..23c58ea4ac 100644 --- a/openecomp-ui/resources/scss/components/_forms.scss +++ b/openecomp-ui/resources/scss/components/_forms.scss @@ -5,10 +5,37 @@ padding: 0 0 30px 0; } } + +.validation-form-content { + fieldset[disabled] { + .form-group { + opacity: 0.7; + cursor: auto; + pointer-events: none; + .dropdown-multi-select { + .form-group { + opacity: 1; + } + .Select-control { + background-color: $tlv-light-gray; + } + } + } + } +} + .dropdown-multi-select { .Select { display: block; width: 100%; + .Select-menu-outer { + .Select-option { + &:hover { + background-color: $blue; + color: $white; + } + } + } .Select-control { height: 28px; border-radius: 2px; @@ -26,20 +53,24 @@ &.Select--multi { .Select-value { color: $text-black; - background-color: transparent; - border-color: $light-gray; - margin-top: 2px; - margin-left: 2px; - border-radius: 1px; + background-color: $background-gray; + border: none; + margin: 3px 0 3px 10px; + border-radius: 10px; + padding-left: 8px; + padding-right: 6px; } .Select-value-icon { - border-right-color: $light-gray; + border: none; + float: right; + &:hover { + background-color: inherit; + color: inherit; + } } .Select-arrow-zone { - padding-top: 4px; + padding-top: 4px; } } } } - - diff --git a/openecomp-ui/resources/scss/components/_grid.scss b/openecomp-ui/resources/scss/components/_grid.scss new file mode 100644 index 0000000000..d4d1fa7ccd --- /dev/null +++ b/openecomp-ui/resources/scss/components/_grid.scss @@ -0,0 +1,64 @@ +$gridItemSpace: 15%; + +.grid-section { + padding-bottom: 30px; + .grid-items { + display: flex; + flex-direction: row; + flex-wrap: wrap; + } + + %grid-col-base { + flex-shrink: 0; + display: flex; + } + + .grid-item { + flex: 1; + display: flex; + flex-direction: column; + } + + .grid-item-stretch { + @extend .grid-item; + & *:last-child { + flex: 1; + display: flex; + flex-direction: column; + } + } + + .grid-col-1 { + @extend %grid-col-base; + flex-basis: 25%; + &:after { + flex-basis: $gridItemSpace; + content: ' '; + } + } + + .grid-col-2 { + @extend %grid-col-base; + flex-basis: 50%; + &:after { + flex-basis: $gridItemSpace / 2; + content: ' '; + } + } + .grid-col-3 { + @extend %grid-col-base; + flex-basis: 75%; + &:after { + flex-basis: $gridItemSpace / 3; + content: ' '; + } + } + .grid-col-4 { + @extend %grid-col-base; + flex-basis: 100%; + &:after { + flex-basis: $gridItemSpace / 4; + content: ' '; + } + } +} diff --git a/openecomp-ui/resources/scss/components/_icon.scss b/openecomp-ui/resources/scss/components/_icon.scss new file mode 100644 index 0000000000..c80055d055 --- /dev/null +++ b/openecomp-ui/resources/scss/components/_icon.scss @@ -0,0 +1,164 @@ +$image-icon-normal-size: 20px; + +.icon-component { + display: inline-flex; + align-items: center; + + &.clickable:hover { + cursor: pointer; + } + .icon-label { + color: $blue; + } + &.disabled { + .icon-label { + color: $tlv-light-gray; + opacity: 0.7; + } + } + .icon { + width: $image-icon-normal-size; + height: $image-icon-normal-size; + margin: 0 6px; + background-repeat: no-repeat; + + &.trash { + background-image: url($trash-icon); + } + + &.artifacts { + background-image: url($artifacts-icon); + } + + &.base { + background-image: url($base-module-icon); + } + + &.module { + background-image: url($module-icon); + } + + &.pencil { + background-image: url($pencil-icon); + } + + &.check { + background-image: url($check-icon); + width: 30px; + height: 30px; + } + + &.download { + background-image: url($download-icon); + width: 16px; + height: 14px; + } + + &.upload { + background-image: url($upload-icon); + width: 16px; + height: 14px; + } + &.validation-artifacts { + width: 13px; + height: 17px; + position: relative; + top: 3px; + background-image: url($artifacts-regular-icon); + &.selected { + background-image: url($artifacts-selected-icon); + } + } + &.network { + background-image: url($network-icon); + width: 12px; + height: 12px; + &.selected { + background-image: url($network-selected-icon); + } + } + &.validation-other { + background-image: url($others-icon); + width: 12px; + height: 12px; + &.selected { + background-image: url($others-selected-icon); + } + } + &.volume { + width: 15px; + height: 16px; + background-image: url($volume-icon); + &.selected { + background-image: url($volume-selected-icon); + } + } + &.zip { + background-image: url($zip-icon); + height: 23px; + width: 29px; + &.selected { + background-image: url($zip-selected-icon); + } + } + &.heat { + background-image: url($heat-icon); + height: 14px; + width: 16px; + &.selected { + background-image: url($heat-selected-icon); + } + } + &.env { + background-image: url($env-icon); + height: 15px; + width: 16px; + &.selected { + background-image: url($env-selected-icon); + } + } + &.error { + width: 14px; + min-width: 14px; + height: 14px; + background-image: url($error-icon-sm); + } + &.warning { + height: 13px; + width: 15px; + min-width: 15px; + background-image: url($warning-icon-sm); + } + &.error-lg { + width: 17px; + min-width: 17px; + height: 17px; + background-image: url($error-icon-lg); + } + &.warning-lg { + width: 19px; + min-width: 19px; + height: 17px; + background-image: url($warning-icon-lg); + } + &.chevron-up { + background-image: url($chevron_down); + transform: rotate(180deg); + height: 7px; + width: 11px; + } + &.chevron-down { + background-image: url($chevron_down); + height: 7px; + width: 11px; + } + &.go-to-overview { + background-image: url($go-to-overview-icon); + height: 15px; + width: 18px; + &.disabled { + background-image: url($go-to-overview-disabled-icon); + } + } + } +} diff --git a/openecomp-ui/resources/scss/components/_inputOptions.scss b/openecomp-ui/resources/scss/components/_inputOptions.scss index 107751b07b..face03d64d 100644 --- a/openecomp-ui/resources/scss/components/_inputOptions.scss +++ b/openecomp-ui/resources/scss/components/_inputOptions.scss @@ -1,3 +1,12 @@ +.disabled { + .Select-control { + background-color: $tlv-light-gray; + .Select-placeholder { + color: $dark-gray; + } + } +} + .input-options { display: flex; border: 1px solid $light-gray; @@ -14,6 +23,7 @@ padding-top:0px; padding-bottom: 0px; height:28px; + } .input-options-other{ @@ -34,6 +44,42 @@ } .input-options.has-error { - border-color: #A94442; + border-color: $crimson; } +.bootstrap-input-options { + display: flex; + flex-direction: column; + .input-options-select { + border: 1px solid $light-gray; + border-radius: 2px; + height: 30px; + float: left; + transition-property: width; + transition-duration: 300ms; + padding-top: 0px; + padding-bottom: 0px; + width: 100%; + &:hover { + border-color: $gray; + } + } + .input-options-other { + float: left; + height: 30px; + border: none; + padding-top: 0px; + padding-bottom: 0px; + height: 28px; + } + .input-options-separator { + width: 1px; + height: 24px; + margin-top: 2px; + margin-bottom: 2px; + border: 1px solid $light-gray; + } + &.has-error { + border-color: $crimson; + } +} diff --git a/openecomp-ui/resources/scss/components/_listEditorView.scss b/openecomp-ui/resources/scss/components/_listEditorView.scss index 704faaf098..18d5426eb7 100644 --- a/openecomp-ui/resources/scss/components/_listEditorView.scss +++ b/openecomp-ui/resources/scss/components/_listEditorView.scss @@ -2,49 +2,42 @@ @extend .flex-column; background-color: $content-background-color; - .list-editor-view-title { - @extend .section-title; - } - - .list-editor-view-title-inline { - @extend .list-editor-view-title; - position: relative; - top: 9px; - &:first-child { - padding: 0; - } - } - - .list-editor-view-add-section { - display: inline-block; - padding: 0 10px 0 10px; + .expandble-search-wrapper { + display: flex; + justify-content: flex-end; + margin-top: 10px; } - .list-editor-view-actions { + .list-editor-view-header { display: flex; justify-content: space-between; - align-items: center; + align-items: flex-end; border-bottom: 1px solid $light-gray; - padding-bottom: 18px; + padding-bottom: 5px; + .list-editor-view-title { + @extend .heading-3-medium; + } .list-editor-view-add-controller { - @extend .body-1-medium; + @extend .heading-4-medium; color: $blue; display: table; cursor: pointer; position: relative; - top: 9px; + padding-top: 0px; + padding-bottom: 0px; + margin-left: auto; + .list-editor-view-add-title { + display: flex; + } span { display: table-cell; vertical-align: middle; + margin-top:4px; &:nth-child(2) { padding-left: 10px; } } } - - .search-wrapper { - width: 265px; - } } .list-editor-view-list-scroller { @@ -56,21 +49,17 @@ .list-editor-view-list { @extend .flex-column; - .list-editor-item-view { margin: 8px 0; border: 1px solid $light-gray; background-color: $white; - cursor: pointer; display: flex; - height: 100px; min-height: 100px; overflow: hidden; .list-editor-item-view-content { padding: 10px 28px; display: flex; - flex-basis: 95%; - width: 95%; + flex: 1 1 auto; .list-editor-item-view-field { flex: 1 1; color: $black; @@ -91,6 +80,12 @@ .text { @extend .body-1; } + .textEllipses { + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; + padding-right: 5px; + } } } .list-editor-item-view-controller { @@ -99,59 +94,79 @@ align-self: center; justify-content: center; flex-direction: column; - .fa { - transition: color .3s; - font-size: 22px; - color: $white; - &:first-child{ + .svg-icon-wrapper { + &:first-child { margin-bottom: 10px; } } + .svg-icon { + transition: fill .3s; + height: 18px; + width: 18px; + fill: $white; + } } - &:hover { + &.selectable:hover{ @extend .box-hover; + cursor: pointer; .list-editor-item-view-controller { - .fa { - color: $gray; + .svg-icon { + fill: $dark-gray; + &:hover { + fill: $black; + } } } } } - } + &.two-columns { - &.thinner-list { - background-color: $white; - padding: 0; - margin-top: 35px; + flex-direction: row; + flex-wrap: wrap; - .list-editor-view-list { - border-top: 0; - padding-top: 0; - margin-top: 23px; .list-editor-item-view { - &:hover { - border-color: $light-gray; - } - margin: 5px 0 0 0; - height: 30px; - border-top: 0; - border-left: 0; - border-right: 0; .list-editor-item-view-content { - padding: 4px; - .name { - @extend .body-2-medium; - flex-basis: 36%; + display: flex; + flex-direction: row; + align-items: center; + padding: 10px 18px 10px 0; + .list-editor-item-view-field { + flex: 0.3 1; + display: flex; + justify-content: center; + flex-direction: column; + height: 100%; + border-right : 1px solid $light-gray; + margin-left: 18px; + &:last-child{ + border: none; + flex: 1; + } + .details{ + display: flex; + flex-direction: row; + .title { + padding: 0; + margin-right: 5px; + } + } + + .description { + @extend .body-1; + @include multiline-ellipsis(1.3em, 3); + } } } - .list-editor-item-view-controller { - .fa-trash-o { - font-size: 20px; - } + + &:nth-child(odd){ + flex: 0 0 48.5%; + margin-right: 50px; + } + &:nth-child(even) { + flex: 1; + margin-right: 0; } } } } } - - diff --git a/openecomp-ui/resources/scss/components/_navigationSideBar.scss b/openecomp-ui/resources/scss/components/_navigationSideBar.scss index 404f43ca68..36c14a2785 100644 --- a/openecomp-ui/resources/scss/components/_navigationSideBar.scss +++ b/openecomp-ui/resources/scss/components/_navigationSideBar.scss @@ -3,7 +3,7 @@ height: 100%; background-color: $white; border-right: 1px solid $light-gray; - box-shadow: 1px -1px 3px 0px $tlv-light-gray; + @include box-shadow(1px -1px 3px 0px $tlv-light-gray); border-bottom: 0; .navigation-side-content { @@ -16,11 +16,11 @@ flex-direction: column; background-color: $tlv-gray; .group-name { - @extend .heading-5-medium; + @extend .heading-4-medium; @include ellipsis; min-height: 56px; display: block; - padding: 18px 12px 16px 40px; + padding: 18px 12px 13px 40px; background-color: $white; border-bottom: 1px solid $tlv-light-gray; } diff --git a/openecomp-ui/resources/scss/components/_selectActionTable.scss b/openecomp-ui/resources/scss/components/_selectActionTable.scss new file mode 100644 index 0000000000..fa17733374 --- /dev/null +++ b/openecomp-ui/resources/scss/components/_selectActionTable.scss @@ -0,0 +1,152 @@ +.select-action-table-view { + .svg-icon-wrapper { + flex-direction: row; + + &::before { + content:""; + } + .svg-icon { + margin-left: 5px; + margin-right: 5px; + width:16px; + height:16px; + } + } + .dummy-icon { + background-color: $white; + fill: $white; + .locked { + fill: $white; + } + } + + .select-action-table-controllers { + display: flex; + .svg-icon-wrapper { + &:hover { + cursor: pointer; + } + &:first-child { + margin-left: auto; + } + } + } + .select-action-table { + display: flex; + flex-direction: column; + border-color: $light-gray; + + .select-action-table-headers { + display: flex; + background-color: $tlv-light-gray; + border-color: inherit; + .select-action-table-header { + @extend .body-1-medium; + flex: 1; + border-top: 1px solid; + border-right: 1px solid; + border-color: inherit; + padding: 8px 0 7px 20px; + &:first-child { + border-left: 1px solid; + border-color: inherit; + } + } + } + .select-action-table-row-wrapper { + display: flex; + flex-direction: row; + margin-bottom: 14px; + .svg-icon.trash-o { + + fill: $dark-gray; + } + .svg-icon.error-circle { + fill: $red; + } + .svg-icon.check-circle { + fill: $green; + } + .select-action-table-row { + display: flex; + flex: 1; + border: 1px solid; + border-color: $light-gray; + &.has-error { + border-color: $red; + } + .select-action-table-cell { + flex: 1; + border-right: 1px solid; + border-color: $light-gray; + @extend .body-1; + .dropdown-multi-select { + .form-group { + .Select{ + &.is-open { + border: 1px solid $blue; + } + } + } + } + .form-group { + margin: 0; + .Select-control { + height:36px; + border: none; + .is-open { + border-left-color: $blue; + border-right-color: $blue; + } + .Select-value, .Select-placeholder, .Select-input { + padding-left: 20px; + padding-right: 50px; + padding-top: 4px; + + } + .Select-placeholder { + color: $dark-gray; + } + .Select-arrow-zone { + padding-right: 15px; + } + } + } + &:last-child { + border-right: none; + } + } + .Select-menu-outer { + border-left: 1px solid $blue; + border-right: 1px solid $blue; + border-bottom: 1px solid $blue; + overflow: auto; + .Select-menu { + display: inline-block; + .Select-option { + width: 100%; + display: inline-block; + border-bottom: 1px solid $light-gray; + &:hover { + background-color: $blue; + color: $white; + &.is-focused { + background-color: $blue; + } + &.is-focused { + background-color: $blue; + } + } + &.is-selected { + background-color: transparent; + } + &.is-focused { + background-color: transparent; + } + } + } + } + } + } + } +} diff --git a/openecomp-ui/resources/scss/components/_slidePanel.scss b/openecomp-ui/resources/scss/components/_slidePanel.scss deleted file mode 100644 index 61c9a189f0..0000000000 --- a/openecomp-ui/resources/scss/components/_slidePanel.scss +++ /dev/null @@ -1,35 +0,0 @@ - -.slide-panel { - transition: left .5s,right .5s; - - .slide-panel-header { - padding: 10px; - height: 45px; - display: table; - width: 100%; - .slide-panel-header-title, .collapse-double-icon { - display: table-cell; - vertical-align: middle; - } - .slide-panel-header-title { - @extend .body-2; - text-align: center; - width: 100%; - color: $text-black; - } - .collapse-double-icon { - color: $text-black; - cursor: pointer; - } - } - - .slide-panel-content { - opacity: 1; - transition: opacity .5s, visibility .5s; - - &.closed { - opacity: 0; - visibility: hidden; - } - } -} diff --git a/openecomp-ui/resources/scss/components/_submitErrorResponse.scss b/openecomp-ui/resources/scss/components/_submitErrorResponse.scss index fdac5ebe45..e34be01af2 100644 --- a/openecomp-ui/resources/scss/components/_submitErrorResponse.scss +++ b/openecomp-ui/resources/scss/components/_submitErrorResponse.scss @@ -20,4 +20,41 @@ } } } + .error-block { + margin: 10px 0; + .error-block-header { + background-color: $tlv-gray; + padding: 5px; + cursor: pointer; + .chevron-down { + width:10px; + height:10px; + margin-right: 10px; + &.right { + transform: rotate(270deg); + } + } + + } + .error-code-list-item { + .icon-label { + @extend .body-1; + color: $dark-gray; + } + .icon-component { + align-items: baseline; + } + } + .list-group-item { + .error-item-text { + margin-top:-2px; + //position: fixed; + } + } + .component-name-header { + margin-left: 45px; + margin-top: 10px; + @extend .heading-5-medium; + } + } } diff --git a/openecomp-ui/resources/scss/components/_svgIcon.scss b/openecomp-ui/resources/scss/components/_svgIcon.scss new file mode 100644 index 0000000000..fc02f81fd4 --- /dev/null +++ b/openecomp-ui/resources/scss/components/_svgIcon.scss @@ -0,0 +1,51 @@ +@mixin overrideBootstrapClose(){ + opacity: 1; + float: none; + &:hover { + opacity: 1; + } +} + +.svg-icon-wrapper { + display: inline-flex; + justify-content: center; + align-items: center; + &.bottom { + flex-direction: column; + .svg-icon-label { + margin-bottom: 5px; + } + } + &.right { + float: none; + .svg-icon-label { + margin-left: 5px; + } + } + &.top { + flex-direction: column-reverse;; + .svg-icon-label { + margin-top: 5px; + } + } + &.left { + flex-direction: row-reverse;; + .svg-icon-label { + margin-right: 5px; + } + } + // bootstrap override + &.close { + @include overrideBootstrapClose(); + } + .close { + @include overrideBootstrapClose(); + } + .svg-icon { + width: 20px; + height: 20px; + } + .svg-icon-label { + @extend .body-1; + } +} diff --git a/openecomp-ui/resources/scss/components/_validationForm.scss b/openecomp-ui/resources/scss/components/_validationForm.scss index 93444c2e88..9404f2841a 100644 --- a/openecomp-ui/resources/scss/components/_validationForm.scss +++ b/openecomp-ui/resources/scss/components/_validationForm.scss @@ -5,6 +5,7 @@ form { flex: 1; } .nav-tabs { + position: relative; .invalid-tab:not(.active) { a { color: $red; @@ -73,14 +74,17 @@ form { flex: 0.2; content: ' '; } - &.add-line-break { - .control-label { - &:after { - content: "\00a0"; - display: block; + @media (min-width: 1349px) { + &.add-line-break { + .control-label { + &:after { + content: "\00a0"; + display: block; + } } } } + } } } @@ -91,6 +95,16 @@ form { button:first-child { margin-right: 15px; } + .svg-icon { + height: 14px; + width: 14px; + } + .svg-icon.check { + fill: $white; + } + .svg-icon.close { + fill: $blue; + } } } diff --git a/openecomp-ui/resources/scss/components/_versionController.scss b/openecomp-ui/resources/scss/components/_versionController.scss index 3511470bfb..3c30cdcc37 100644 --- a/openecomp-ui/resources/scss/components/_versionController.scss +++ b/openecomp-ui/resources/scss/components/_versionController.scss @@ -1,109 +1,125 @@ .version-controller-bar { - .navbar-inverse { - @extend .body-1-medium; + display: flex; + min-height: 57px; + border-bottom: 1px solid $tlv-light-gray; + background-color: transparent; + .vc-container { + display: flex; + flex: 1; + align-self: center; background-color: transparent; - border-bottom: $tlv-light-gray thin solid; - padding-top: 14px; - padding-bottom: 12px; - margin-bottom: 0; - .container { - width: 100%; - padding: 0 52px; + justify-content: space-between; + padding-left: 16px; + padding-right: 40px; + .version-status-container { + display: flex; height: 30px; - .navbar-collapse { - padding-left: 0; - .items-in-left { - display: flex; - height: 30px; - .version-section { - .form-group { - margin-right: 5px; - .input-options { - border: none; - .input-options-select { - padding-top: 4px; - } - } + .version-selector { + border: none; + margin-top: 7px; + padding-right: 10px; + margin-right: 15px; + margin-left: 10px; + @extend .body-1; + } + .version-section { + .form-group { + margin-right: 20px; + .input-options { + border: none; + .input-options-select { + padding-top: 4px; } } - .vc-status { - display: flex; - padding-left: 14px; - border-left: $light-gray thin solid; - .status-text { - align-self: center; - display: flex; - padding-left: 3px; - .status-text-dash { - padding: 0 9px; - } + } + } + .vc-status { + display: flex; + padding-left: 20px; + border-left: $light-gray thin solid; + .status-text { + align-self: center; + margin-top: 2px; + @extend .heading-5; + color: $dark-gray; + } + } + } + .save-submit-cancel-container { + display: flex; + height: 30px; + .action-buttons { + display: flex; + padding: 0 13px; + .version-control-buttons { + display: flex; + } + .action-buttons-svg { + padding-top: 5px; + margin-right: 20px; + padding-bottom: 5px; + + .version-controller-lock-closed { + fill: $dark-gray; + width: 21px; + height: 23px; + margin-top: -3px; + &.disabled { + fill: $light-gray; } - .onboarding-status-icon { - width: 25px; - height: 19px; - background-image: url('../images/ecomp/ASDC_Sprite.png'); - background-position: -306px 674px; - align-self: center; + &:hover { + fill: $black; } - .checkout-status-icon { - display: flex; - & > .catalog-tile-check-in-status.sprite-new.checkout-editable-status-icon { - width: 25px; - height: 19px; - align-self: center; - margin-left: 5px; - } + } + .version-controller-lock-open { + fill: $dark-gray; + width: 24px; + height: 28px; + margin-top: -6px; + &:hover { + fill: $black; } } - } - .items-in-right { - display: flex; - height: 30px; - .action-buttons { - display: flex; - border-right: $gray thin solid; - padding: 0 13px; - .version-control-buttons { - display: flex; + .version-controller-submit { + fill: $blue; + &.disabled { + fill: $light-gray; } - .vc-nav-item-button { - border: 1px solid $light-gray; - border-radius: 5px; - cursor: pointer; - margin-right:10px; - padding: 6px 20px; - &:hover, &:focus { - background-color: lightgrey; - } - &.button-submit{ - background-color: transparent; - color: $green; - border-color: $green; - } - &.button-checkin-checkout { - background-color: $white; - @extend .body-1; - } + &:hover { + fill: $dark-blue; } - .revert-btn, .save-btn { - height: 24px; - width: 24px; - align-self: center; - cursor: pointer; - margin-right: 10px; + } + + .version-controller-revert { + fill: $dark-gray; + &.disabled { + fill: $light-gray; + } + &:hover { + fill: $black; } } - .vc-nav-item-close { - display: flex; - padding-left: 18px; - padding-top: 3px; - align-self: center; - @extend .body-1; - color: $gray; - cursor: pointer; + .version-controller-save { + fill: $dark-gray; + &.disabled { + fill: $light-gray; + } + &:hover { + fill: $black; + } } } } + .vc-nav-item-close { + display: flex; + padding-left: 18px; + padding-top: 3px; + align-self: center; + @extend .body-1; + color: $gray; + cursor: pointer; + border-left: $gray thin solid; + } } } } diff --git a/openecomp-ui/resources/scss/modules/_entitlementPools.scss b/openecomp-ui/resources/scss/modules/_entitlementPools.scss index df7cea4cd8..0e0a72a387 100644 --- a/openecomp-ui/resources/scss/modules/_entitlementPools.scss +++ b/openecomp-ui/resources/scss/modules/_entitlementPools.scss @@ -35,29 +35,13 @@ .tab-content { padding: 50px; } - .entitlement-pools-form-row { - - display: flex; - justify-content: space-between; - & > * { - flex: 0 1 47%; - } - .validation-input-wrapper { - .form-group { - textarea { - height: 184px; - } - .entitlement-pools-form-row-threshold-value { - margin-top: 23px; - margin-left: 10px; - width: 189px; - } - .dropdown-multi-select .Select { - z-index: 1080; - } - } - } - } + .threshold-section { + display: flex; + justify-content: space-between; + .validation-input-wrapper { + flex: 0 0 46%; + } + } } .validation-buttons { padding: 20px 50px; diff --git a/openecomp-ui/resources/scss/modules/_featureGroup.scss b/openecomp-ui/resources/scss/modules/_featureGroup.scss index f66a01c290..71e7cee575 100644 --- a/openecomp-ui/resources/scss/modules/_featureGroup.scss +++ b/openecomp-ui/resources/scss/modules/_featureGroup.scss @@ -28,21 +28,6 @@ padding: 0; } .feature-group-form { - .button-tab { - @extend .body-1-medium; - color: $dark-gray; - padding: 6px; - border: 0; - background-color: $white; - box-shadow: none; - &:first-child { - margin-right: 28px; - } - &.active, &:hover { - color: $text-black; - border-bottom: 2px solid $blue; - } - } .no-items-msg { margin-top: 55px; color: $dark-gray; diff --git a/openecomp-ui/resources/scss/modules/_licenseAgreement.scss b/openecomp-ui/resources/scss/modules/_licenseAgreement.scss index a7afd01cc5..7a7b87677e 100644 --- a/openecomp-ui/resources/scss/modules/_licenseAgreement.scss +++ b/openecomp-ui/resources/scss/modules/_licenseAgreement.scss @@ -37,21 +37,6 @@ padding: 0; } .license-agreement-form { - .button-tab{ - @extend .body-1-medium; - color: $dark-gray; - padding: 6px; - border: 0; - background-color: $white; - box-shadow: none; - &:first-child { - margin-right: 28px; - } - &.active, &:hover { - color: $text-black; - border-bottom: 2px solid $blue; - } - } .no-items-msg { margin-top: 55px; color: $dark-gray; @@ -70,21 +55,6 @@ } } } - .license-agreement-form-row { - display: flex; - justify-content: space-between; - .license-agreement-form-col { - flex: 0 1 45%; - } - .validation-input-wrapper { - flex: 0 1 45%; - .form-group { - textarea { - height: 100px; - } - } - } - } .validation-buttons { padding: 20px 50px; } diff --git a/openecomp-ui/resources/scss/modules/_licenseKeyGroup.scss b/openecomp-ui/resources/scss/modules/_licenseKeyGroup.scss index 19b4792949..5ea84e98c4 100644 --- a/openecomp-ui/resources/scss/modules/_licenseKeyGroup.scss +++ b/openecomp-ui/resources/scss/modules/_licenseKeyGroup.scss @@ -30,22 +30,6 @@ width: 400px; color: $black; } - .license-key-groups-form-row { - display: flex; - justify-content: space-between; - .options-input-form-row { - width: 370px; - } - .validation-input-wrapper { - flex: 0 1 45%; - .form-group { - textarea { - height: 100px; - } - - } - } - } } .validation-buttons { padding: 20px 50px; diff --git a/openecomp-ui/resources/scss/modules/_licenseModelOverview.scss b/openecomp-ui/resources/scss/modules/_licenseModelOverview.scss new file mode 100644 index 0000000000..4ec7c8d3af --- /dev/null +++ b/openecomp-ui/resources/scss/modules/_licenseModelOverview.scss @@ -0,0 +1,491 @@ +.license-model-overview { + .overview-top-section { + .overview-title{ + @extend .heading-1; + @extend .text-uppercase !optional; + margin-bottom: 20px; + color: $blue; + } + .license-model-overview-top { + display: flex; + justify-content: flex-start; + flex-direction: row; + padding-bottom: 10px; + min-height: 155px; + .separator { + width: 1px; + border-right: 1px solid $tlv-light-gray; + margin-left: 20px; + } + .vendor-data-view { + @extend .flex-column; + background-color: $tlv-gray; + padding: 20px 30px; + border: 1px solid $tlv-light-gray; + @include border-shadow(); + .vendor-title { + margin-top:5px; + } + .vendor-name { + @extend .heading-3-medium; + text-transform: none; + padding-bottom: 15px; + border-bottom: 1px solid $tlv-light-gray; + } + .vendor-description { + @extend .flex; + @extend .body-1; + justify-content: space-between; + margin-top: 10px; + overflow: hidden; + border: 1px solid transparent; + position: relative; + left: -6px; + width: 101%; + + &:hover { + border: 1px solid $tlv-light-gray; + background-position: 99% 12%; + background-size: 15px; + padding-right: 20px; + background-image: url($pencil-icon); + background-repeat: no-repeat; + cursor: pointer; + } + &.read-only { + border: none; + } + .description-data { + @include multiline-ellipsis($lineCount: 3, $bgColor: $tlv-gray); + } + } + + .vendor-description-readonly { + @extend .flex; + @extend .body-1; + justify-content: space-between; + margin-top: 10px; + overflow: hidden; + border: none; + height: 49px; + margin-bottom: 15px; + padding: 6px; + position: relative; + left:-6px; + } + + .vendor-description-edit { + @extend .flex; + flex-direction: column; + border: none; + margin-top: 10px; + position: relative; + left: -6px; + width: 101%; + textarea { + padding-left: 6px; + } + .buttons-row { + @extend .flex; + justify-content: flex-end; + flex-direction: row; + margin-top: -25px; + .buttons-wrapper { + @extend .flex; + @extend .body-3; + border: 1px solid $light-gray; + width: 95px; + height: 19px; + background-color: $tlv-light-gray; + border-radius: 2px; + position: relative; + flex: 0 1 auto; + text-align: center; + .description-button { + cursor: pointer; + flex: 1; + &:hover { + background-color: $white; + } + } + .description-save { + cursor: pointer; + flex: 1; + color:$blue; + &:hover { + background-color: $white; + } + } + } + } + .description-edit-textarea { + height:67px; + border: 1px solid $tlv-light-gray; + resize: none; + position: relative; + left: -12px; + } + } + } + .summary-count-list { + @extend .flex-column; + flex: 0.6; + margin-left: 20px; + justify-content: space-between; + border: 1px solid $tlv-light-gray; + @include border-shadow(); + background-color: $tlv-gray; + .summary-count-item { + @extend .flex; + @extend .heading-4-medium; + padding-top: 5px; + padding-left: 45px; + padding-right: 45px; + border-bottom: 1px solid $tlv-light-gray; + &:last-child { border-bottom: none; } + .item-count { + flex-grow: 2; + margin-left: 5px; + } + .add-button { + cursor: pointer; + font-size: larger; + background-image: url($vlm-summary-plus); + background-size: 20px; + background-repeat: no-repeat; + width:20px; + height:20px; + margin-top: 3px; + margin-left: auto; + &:hover { + cursor: pointer; + background-image: url($vlm-summary-plus-blue); + } + } + + .summary-name-and-count { + &:hover { + cursor: pointer; + color: $blue; + } + } + + + } + } + .plus-icon { + font-size: $icon-font-size; + border-radius: 50%; + border: 1px solid $black; + color: $black; + height: 16px; + width: 16px; + padding: 2px 2px 2px 3px; + } + } + } + .vlm-list-tab-panel + { + @extend .flex; + .section-title { + flex: 1; + } + .overview-buttons-section { + margin-top: 20px; + display: flex; + justify-content: flex-start; + .button-vlm-list-view { + height: 32px; + width: 34px; + margin-left:10px; + cursor: pointer; + } + .vlm-list-icon { + background-size: 32px; + background-repeat: no-repeat; + background-image: url($vlm-summary-used); + &.selected { + background-image: url($vlm-summary-used-blue); + } + } + .entities-list-icon { + background-size: 32px; + background-repeat: no-repeat; + background-image: url($vlm-summary-orphans); + &.selected { + background-image: url($vlm-summary-orphans-blue); + } + } + + } + } + + .overview-list-section { + @extend .flex-column; + margin-top: 35px; + .section-title { + @extend .heading-2; + padding-top: 20px; + margin-bottom: 15px; + padding-bottom: 0px; + } + &.overview-list-orphans { + .chevron::before + { + display: none; + } + .vlm-list-view { + .vlm-list { + .vlm-list-item { + @include border-shadow(); + .list-item-icon-col { + display: flex; + flex-direction: column; + justify-content: center; + margin-left: 5px; + } + &.vlm-list-item-la { + margin-left: 0; + .list-item-icon-col { + padding-left: 22px; + + } + .la-icon { + background-color: $gray; + border-color: $gray; + } + .list-item-section { + &:first-child { + background-color: gray; + } + } + } + &.vlm-list-item-fg { + cursor: default; + margin-left: 0; + border-left: 10px solid $gray; + .list-item-arrow-col { + margin-left: 0px; + } + .list-item-icon-col { + padding-left: 22px; + } + .fg-icon { + background-color: $gray; + border-color: $gray; + } + } + &.vlm-list-item-ep { + margin-left: 0; + border-left: 10px solid $gray; + .list-item-icon-col { + padding-left: 22px; + } + .ep-icon { + background-color: $gray; + border-color: $gray; + } + .list-item-section { + &:first-child { + display: flex; + color: $white; + min-width: 34px; + } + } + } + &.vlm-list-item-lkg { + margin-left: 0; + border-left: 10px solid $gray; + .list-item-icon-col { + padding-left: 22px; + } + .lkg-icon { + background-color: $gray; + border-color: $gray; + } + .list-item-section { + &:first-child { + display: flex; + color: $white; + min-width: 34px; + } + } + } + } + } + } + } + .vlm-list-view { + flex: 1; + .vlm-list { + @extend .flex; + flex-direction: column; + .vlm-list-item { + @include border-shadow(); + min-height: 90px; + height: 90px; + background-color: $tlv-gray; + @extend .flex; + border: 1px solid $tlv-light-gray; + margin-bottom: 0px; + cursor: pointer; + .list-item-icon-col { + display: flex; + flex-direction: column; + justify-content: center; + + } + .list-item-section { + padding: 10px; + .children-count { + @extend .body-1; + line-height: 20px; + color: $gray; + padding-left: 5px; + .count-value { + padding: 0 5px; + } + } + .additional-data { + padding-left: 50px; + .additional-data-name { + @extend .body-1-medium; + } + } + .additional-data-col-border { + border-left: 1px solid $tlv-light-gray; + min-height: 100%; + height: 100%; + } + } + .list-item-additional-data-col { + @extend .body-1; + @extend .flex; + align-items: center; + flex: 0.8; + } + .arrow-icon { + align-self: center; + } + .vlm-item-info { + flex: 1; + } + .vlm-list-item-title { + @extend .flex; + .item-name { + @extend .heading-5-medium; + flex: 0 1 auto; + margin-bottom: 4px; + } + } + .vlm-list-item-description { + @extend .body-1; + overflow: hidden; + max-height: 38px; + } + &.vlm-list-item-la { + margin-top: 10px; + border-left: 10px solid $dark-blue; + .la-icon { + @include create-circle($circle-icon-size,$dark-blue,'LA'); + color: $white; + } + .list-item-section { + + &:first-child { + display: flex; + color: $dark-blue; + min-width: 34px; + } + } + .list-item-arrow-col { + flex: 0.01; + margin-left: 14px; + } + .list-item-icon-col { + padding-left: 14px; + padding-right: 30px; + align-items: center; + } + + } + &.vlm-list-item-fg { + border-left: 10px solid $blue; + margin-left: 20px; + margin-top: 10px; + .fg-icon { + @include create-circle($circle-icon-size,$blue,'FG'); + color: $white; + } + .list-item-section { + &:first-child { + display: flex; + color: $blue; + min-width: 34px; + + } + } + .list-item-arrow-col { + flex: 0.01; + margin-left: 26px; + } + .list-item-icon-col { + padding-left: 22px; + padding-right: 30px; + align-items: center; + } + } + &.vlm-list-item-ep { + margin-left: 40px; + margin-top: 10px; + border-left: 10px solid $light-blue; + cursor: default; + .ep-icon { + @include create-circle($circle-icon-size,$light-blue,'EP'); + color: $white; + } + .list-item-icon-col { + padding-left: 72px; + padding-right: 30px; + align-items: center; + } + .list-item-section { + &:first-child { + display: none; + } + } + .list-item-additional-data-col { + margin-right: 20px; + } + } + &.vlm-list-item-lkg { + margin-top: 10px; + margin-left: 40px; + border-left: 10px solid $light-blue; + cursor: default; + .lkg-icon { + @include create-circle($circle-icon-size,$light-blue,'KG'); + color: $white; + } + .list-item-icon-col { + padding-left: 72px; + padding-right: 30px; + align-items: center; + } + .list-item-section { + &:first-child { + display: none; + } + + } + .list-item-additional-data-col { + margin-right: 20px; + } + } + } + + } + } + } + +} diff --git a/openecomp-ui/resources/scss/modules/_onboardingCatalog.scss b/openecomp-ui/resources/scss/modules/_onboardingCatalog.scss index 6020866d4a..6c56d11049 100644 --- a/openecomp-ui/resources/scss/modules/_onboardingCatalog.scss +++ b/openecomp-ui/resources/scss/modules/_onboardingCatalog.scss @@ -1,164 +1,24 @@ $transitionLength: 0.6s; .catalog-view { - background-color: $background-gray; - height: 100%; - overflow: hidden; - height: 100%; - .catalog-header { - padding-top: 20px; - margin: 0 48px 0 20px; - border-bottom: 1px solid $light-gray; - display: flex; - flex-direction: row; - justify-content: space-between; - .catalog-header-title { - @extend .heading-2; - margin: 0 0 10px 0; - } - .expandable-input-wrapper { - margin: 0 0 10px 0; - } - } - .catalog-list { - max-height: 100%; - overflow: auto; - display: flex; - flex-wrap: wrap; - padding: 40px 10px 0 10px; - &:after { - content: ' '; - display:block; - width: 100%; - height: 85px; - } - .tile { - background-color: $white; - margin: 10px; - width: 214px; - height: 210px; - display: flex; - flex-direction: column; - - } - .create-catalog-item { - border: 2px dashed $light-gray; - background-color: transparent; - &:hover { - .plus-section { - display: none; - } - .primary-btn { - display: inherit; - } - } - justify-content: center; - .plus-section { - align-self: center; - display: flex; - flex-direction: column; - .plus-icon-button { - align-self: center; - background-size: 23px; - width: 23px; - height: 23px; - margin-bottom: 4px; - } - } - .primary-btn { - display: none; - width: 176px; - &.new-license-model { - margin-bottom: 18px; - } - &:hover { - background-color: $background-alice-blue; - } - } - } - .catalog-tile { - cursor: pointer; - border: 1px solid $tlv-light-gray; - &:hover { - @include box-shadow(3px 3px 5px 0 rgba(24,24,25,.04)); - } - &:active { - border: 1px solid $light-blue; - } - .catalog-tile-type { - padding-top: 7px; - border-radius: 50%; - width: 40px; - height: 40px; - background: white; - border: 4px solid #F2F2F2; - position: relative; - top: -12px; - left: -7px; - &:before { - @extend .body-1; - color: $light-blue; - } - &.license-model-type { - padding-left: 13px; - &:before { - content: "L" - } - } - &.software-product-type { - padding-left: 8px; - &:before { - content: "SP" - } - } - } - .catalog-tile-icon { - text-align: center; - flex-basis: 60%; - justify-content: center; - background-size: 60px 60px; - background-repeat: no-repeat; - background-position: center; - display: flex; - .icon { - align-self: center; - height: 65px; - width: 65px; - background-repeat: no-repeat; - margin-bottom: 27px; - &.license-model-type-icon { - background-image: url('../images/onboarding/vendor-license-model.svg'); - } - &.software-product-type-icon { - background-image: url('../images/onboarding/vendor-software-product.svg'); - } - } - } - .catalog-tile-content { - border-top: 1px solid $background-gray; - flex-basis: 30%; - padding: 8px; - display: flex; - justify-content: space-between; - .catalog-tile-item-details { - overflow: hidden; - } - .catalog-tile-item-name { - @extend .body-1-medium; - @include ellipsis(); - width: 150px; - color: $dark-gray - } - .catalog-tile-item-version { - @extend .body-1; - color: $gray; - } - .catalog-tile-check-in-status { - width: 25px; - height: 19px; - align-self: center; - } - } - } - } + background-color: $background-gray; + overflow: hidden; + height: 100%; + @import "onboardingCatalog/onboardHeader"; + @import "onboardingCatalog/catalogHeader"; + @import "onboardingCatalog/vendorPageHeader"; + @import "onboardingCatalog/catalogList"; + .catalog-wrapper { + height: 100%; + overflow: auto; + .tab-separator { + content: ''; + height: 25px; + border-right: 1px solid $dark-gray; + } + .catalog-list { + overflow: hidden; + height: auto; + } + } } diff --git a/openecomp-ui/resources/scss/modules/_softwareProductAttachmentPage.scss b/openecomp-ui/resources/scss/modules/_softwareProductAttachmentPage.scss index 657bb544a7..37068975a2 100644 --- a/openecomp-ui/resources/scss/modules/_softwareProductAttachmentPage.scss +++ b/openecomp-ui/resources/scss/modules/_softwareProductAttachmentPage.scss @@ -1,153 +1,237 @@ -.software-product-attachments { + +.vsp-attachments-view { + position: relative; + #attachments-tabs { + .nav-tabs { + background-color: $tlv-gray; + box-shadow: none; + border-bottom: 1px solid $light-gray; + & > li { + & > a { + font-size: 24px; + font-weight: lighter; + padding-left: 0; + padding-right: 0; + margin-right: 40px; + }; + &.active > a {color: $blue;}; + } + } + } + .attachments-view-controllers { + position: absolute; + right: 40px; + top: 15px; + display: flex; + .icon-label { + color: $dark-gray; + } + + .go-to-overview-icon { + .icon-label { + color: $blue; + } + &.disabled { + .icon-label { + color: $gray; + } + } + } + + .icon-component { + margin-right: 30px; + + } + + input[type="file"] { + visibility: hidden; + width: 1px; + padding: 0; + margin-left: -1px; + } + } +} + +.vsp-attachments-heat-validation { @extend .body-1; - width: 100%; - height: 100%; display: flex; - - .software-product-attachments-tree { + .svg-icon.exclamation-triangle-line { + fill: $orange; + width: 15px; + height: 15px; + &.large { + width: 20px; + height: 20px; + } + } + .validation-tree-section { display: flex; - border-right: 1px solid $light-gray; - margin: 0px; - padding: 5px 3px 10px 3px; + width: 400px; + justify-content: space-between; + } + .vsp-attachments-heat-validation-tree { + @extend .flex-column; + margin: 0; overflow: auto; height: 100%; - + .attachments-tree-header { + display: flex; + justify-content: space-between; + height: 55px; + align-items: center; + &.header-selected { + background: $tlv-gray; + } + .header-icon { + top: -3px; + position: relative; + margin-left: 20px; + } + .tree-header-title-text { + @extend .heading-4-medium; + padding-left: 32px; + cursor: pointer; + &.tree-header-title-selected{ + color: $blue; + } + } + .tree-header-title { + display: flex; + } + } + .counters { + display: flex; + justify-content: space-between; + z-index: 1; + padding-right: 20px; + .counter { + display: flex; + &:first-child { + margin-right: 20px; + } + &:only-child { + margin-right: 0; + } + .svg-icon-wrapper { + margin-right: 5px; + } + .counter-icon { + margin-right: 5px; + } + .error-text, .warning-text { + @extend .body-3; + &.large { + @extend .heading-4-medium; + } + } + } + } .tree-wrapper { flex: 1 1; position: relative; padding-bottom: 10px; + @-moz-document url-prefix() { + .tree-block-inside { + top: 0; + position: relative; + } + } .tree-block-inside { - padding-left: 17px; - padding-top: 8px; - padding-bottom: 1px; + padding-left: 20px; .tree-node-row { cursor: default; white-space: nowrap; - &.tree-node-selected::before { + display: flex; + justify-content: space-between; + height: 40px; + align-items: center; + .svg-icon.chevron-down, .svg-icon.chevron-up { + height: 10px; + width: 10px; + } + + &:after { + border-top: 1px solid $tlv-gray; + height: 40px; position: absolute; left: 0; right: 0; - height: 20px; - display: inline-block; content: ' '; - background-color: $light-gray; } - - &.tree-node-clicked::before { + @-moz-document url-prefix() { + &:after { + top: 0; + } + } + &.tree-node-selected::before { position: absolute; - left: 4px; - right: 4px; + left: 0; + right: 0; height: 20px; display: inline-block; content: ' '; - font-weight: bold; - background-color: $white; + background-color: $tlv-gray; + color: $blue; } + &.tree-node-clicked { + color: $blue; + &:after { + background: $tlv-gray; + height: 40px; + position: absolute; + left: 0; + right: 0; + content: ' '; + } + } + .tree-node-name { + cursor: pointer; + } + .name-section { + z-index: 1; + flex: 1; + @include ellipsis(auto); + } .tree-node-expander { position: relative; display: inline-block; cursor: pointer; - .fa { - position: absolute; - left: -7px; - top: -11px; - @include transition(transform 0.3s); - } - &.tree-node-expander-collapsed .fa { - @include transform-rotate(-90); - } } - .tree-node-icon { margin: 0 7px; - color: $text-black; - opacity: .5; - .tree-node-validation-error::after { - content: "!"; - font-weight: bold; - position: absolute; - color: $red; - font-size: large; - left: -7px; - bottom: -5px; - } - } - - .error-status { - color: $red; - &.error-status-selected { - font-weight: bold; - } - &.error-status-hovered { - font-weight: bold; - background-color: $blue; - } - } - - .tree-element-text { - @extend %noselect; - position: relative; - padding-right: 5px; - &.error-status-selected { - font-weight: bold; - } } } - } } } - .software-product-attachments-separator { - border: 1px solid $tlv-light-gray; + .vsp-attachments-heat-validation-separator { + border-left: 1px solid $tlv-light-gray; height: 100%; width: 5px; cursor: e-resize; } - .software-product-attachments-error-list { - text-align: center; - margin-top: 12px; - display: flex; - align-content: flex-start; - flex-direction: column; - padding-left: 70px; - padding-right: 50px; + .message-board-section { + @extend .flex-column; + padding-left: 25px; + padding-top: 10px; + padding-right: 60px; overflow: auto; margin-bottom: 70px; .error-item { - &.selected { - background-color: $light-gray; - } - &.clicked { - color: $blue; - } - &.shifted { - margin-top: 20px; - } - text-align: left; - .error-item-file-name { - font-weight: bold; - } + display: flex; + margin: 10px 0; .error-item-file-type { + margin-left: 15px; + } + .error-file-name { + @extend .body-1-medium; margin-right: 5px; - &.strong { - font-weight: bold; - } - &.ERROR { - color: $red; - } - &.WARNING { - color: $yellow; - } } } - .error-item:hover { - cursor: default; - background-color: $tlv-hover; - } } } diff --git a/openecomp-ui/resources/scss/modules/_softwareProductComponentCompute.scss b/openecomp-ui/resources/scss/modules/_softwareProductComponentCompute.scss new file mode 100644 index 0000000000..164e3bc261 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/_softwareProductComponentCompute.scss @@ -0,0 +1,3 @@ +.section-title.software-product-compute-number-of-vms{ + text-transform: initial; +} \ No newline at end of file diff --git a/openecomp-ui/resources/scss/modules/_softwareProductComponentGeneral.scss b/openecomp-ui/resources/scss/modules/_softwareProductComponentGeneral.scss index 4ff2d2c14a..67d76f5454 100644 --- a/openecomp-ui/resources/scss/modules/_softwareProductComponentGeneral.scss +++ b/openecomp-ui/resources/scss/modules/_softwareProductComponentGeneral.scss @@ -3,6 +3,9 @@ .one-line-textarea { height: 30px; } + .multi-line-textarea > textarea { + height: 113px; + } } .additional-validation-form { margin-top: 50px; diff --git a/openecomp-ui/resources/scss/modules/_softwareProductComponentNetwork.scss b/openecomp-ui/resources/scss/modules/_softwareProductComponentNetwork.scss index 6097f3ef52..e14ab02fcd 100644 --- a/openecomp-ui/resources/scss/modules/_softwareProductComponentNetwork.scss +++ b/openecomp-ui/resources/scss/modules/_softwareProductComponentNetwork.scss @@ -1,10 +1,5 @@ .vsp-components-network { .network-data { - .network-data-title { - @extend .body-2-medium; - padding-bottom: 20px; - padding-left: 15px; - } .single-col { .validation-input-wrapper { label { @@ -27,7 +22,14 @@ padding-right: 50px; padding-top: 20px; height: 500px; - overflow-y: auto; + .grid-section { + padding-bottom: 15px; + .section-title { + @extend .heading-5; + padding-bottom: 10px; + padding-left: 0px; + } + } .part-title { @extend .heading-5; padding-bottom: 10px; @@ -36,11 +38,44 @@ .part-title-small { @extend .heading-3; padding-bottom: 10px; - padding-left: 14px; + padding-left: 0px; } .network-radio label { font-size: 15px; } + + .packets-bytes-gen { + display: flex; + justify-content: space-between; + flex-direction: column; + .top-row { + display: flex; + .part-title-small { + padding-left: 0px; + &.packets { + flex: 0 0 52%; + } + &.bytes { + flex: 0 0 48%; + } + } + } + .bottom-row { + display: flex; + justify-content: space-between; + flex-direction: row; + flex: 1; + .inputs-wrapper { + display: flex; + flex-direction: row; + justify-content: space-between; + flex: 1; + .validation-input-wrapper { + flex: 0 0 22%; + } + } + } + } } } } diff --git a/openecomp-ui/resources/scss/modules/_softwareProductComponentProcessesPage.scss b/openecomp-ui/resources/scss/modules/_softwareProductComponentProcessesPage.scss new file mode 100644 index 0000000000..a6613190fd --- /dev/null +++ b/openecomp-ui/resources/scss/modules/_softwareProductComponentProcessesPage.scss @@ -0,0 +1,8 @@ +.edit-process-modal { + .vsp-process-dropzone-view .grid-section { + padding-bottom: 30px !important; + } + .component-process-description > textarea { + height: 113px; + } +} \ No newline at end of file diff --git a/openecomp-ui/resources/scss/modules/_softwareProductDependencies.scss b/openecomp-ui/resources/scss/modules/_softwareProductDependencies.scss new file mode 100644 index 0000000000..01a50dd741 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/_softwareProductDependencies.scss @@ -0,0 +1,25 @@ +.software-product-dependencies { + .software-product-dependencies-title { + @extend .heading-1; + @extend .text-uppercase !optional; + margin-bottom: 20px; + color: $blue; + } + .select-action-table-controllers { + justify-content: flex-end; + cursor: pointer; + color: $blue; + padding-right: 33px; + margin-bottom: 3px; + &:hover { + color: $dark-blue; + } + } + .select-action-table-view { + min-width: 770px; + } + .select-action-table-header { + @extend .body-1-medium; + color: $text-black; + } +} \ No newline at end of file diff --git a/openecomp-ui/resources/scss/modules/_softwareProductLandingPage.scss b/openecomp-ui/resources/scss/modules/_softwareProductLandingPage.scss index e40bb38ea9..e75b110425 100644 --- a/openecomp-ui/resources/scss/modules/_softwareProductLandingPage.scss +++ b/openecomp-ui/resources/scss/modules/_softwareProductLandingPage.scss @@ -10,18 +10,40 @@ @extend .body-1-medium; } } + + .software-product-view { display: flex; height:100%; .description { @extend .body-1; - overflow: hidden; + // overflow: hidden; padding-right: 20px; - text-overflow: ellipsis; - display: -webkit-box; - -webkit-line-clamp: 2; - -webkit-box-orient: vertical; + // text-overflow: ellipsis; + // display: -webkit-box; + // -webkit-line-clamp: 2; + // -webkit-box-orient: vertical; + + .missing-license { + display: flex; + align-items: baseline; + .svg-icon.exclamation-triangle-full { + fill: $orange; + } + .warning-text { + position: relative; + top: -2px; + } + .svg-icon-wrapper { + margin-right: 7px; + margin-left: 3px; + .svg-icon { + height: 17px; + width: 17px; + } + } + } } .name { @extend .body-1-medium; @@ -29,11 +51,6 @@ .software-product-landing-view-right-side { @extend .flex; overflow-y: hidden; - .processes-page-title { - padding-top: 38px; - padding-left: 53px; - padding-bottom: 20px; - } .list-editor-view { .list-editor-view-title { margin-bottom: 0; @@ -53,22 +70,36 @@ .software-product-landing-view-top { .details-container { @extend .flex-column; + .single-detail-section { + @extend .flex-column; &.title-section { flex: 0.8; @extend .heading-5-medium; } + &.title-text { + margin-bottom: 24px; + } + .description { + @include multiline-ellipsis(); + } + } + .title { + @extend .body-3; + color: $gray; + &.extra-large { + min-width: 130px; + } + } + .details-section { + display: flex; } .multiple-details-section { - @extend .flex; + @extend .flex-column; justify-content: space-between; .detail-col { - .title { - &.extra-large { - min-width: 130px; - } - } + padding-bottom: 10px; } } } @@ -107,8 +138,8 @@ .software-product-landing-view-top-block { cursor: pointer; border: 1px solid $light-gray; - padding: 28px 28px; - height: 250px; + padding: 20px 18px 0 18px; + height: 215px; display: flex; justify-content: space-between; background-color: $white; @@ -141,6 +172,7 @@ flex-direction: column; justify-content: center; border: 2px dashed $light-gray; + margin-bottom: 20px; @extend .body-1; align-items: center; .upload-btn { @@ -171,21 +203,10 @@ margin: 43px 0; padding: 0 52px; } - .section-title { - padding: 50px 0 30px 0; - &.general { - padding-top: 0; - } - } .validation-form-content { .vsp-general-tab-inline-section { display: flex; - &.coupling-items { - justify-content: flex-start; - .validation-input-wrapper:not(:last-child) { - margin-right: 40px; - } - } + .vsp-general-tab-sub-section:not(:last-of-type) { margin-right: 40px; } @@ -205,16 +226,6 @@ width: 440px; } } - - .vsp-general-tab-section { - &.licenses { - >.vsp-general-tab-inline-section { - .validation-input-wrapper:first-child { - margin-right: 40px; - } - } - } - } } .validation-buttons { position: fixed; @@ -223,7 +234,9 @@ width: 66%; } .validation-input-wrapper { - flex: none; + select.form-control { + width: 100%; + } } } } diff --git a/openecomp-ui/resources/scss/modules/_softwareProductNetworksPage.scss b/openecomp-ui/resources/scss/modules/_softwareProductNetworksPage.scss deleted file mode 100644 index 780f348374..0000000000 --- a/openecomp-ui/resources/scss/modules/_softwareProductNetworksPage.scss +++ /dev/null @@ -1,24 +0,0 @@ -.vsp-networks { - .wrapper { - display: flex; - height: 100%; - .left-side{ - height:100% - } - .right-side { - width:100%; - .network-data { - padding-left: 60px; - padding-right: 60px; - padding-top: 18px; - .network-data-title { - @extend .body-2-medium; - padding-bottom: 20px; - padding-left: 15px; - } - } - - } - } -} - diff --git a/openecomp-ui/resources/scss/modules/_softwareProductProcessesPage.scss b/openecomp-ui/resources/scss/modules/_softwareProductProcessesPage.scss index 167dad92e2..4956616687 100644 --- a/openecomp-ui/resources/scss/modules/_softwareProductProcessesPage.scss +++ b/openecomp-ui/resources/scss/modules/_softwareProductProcessesPage.scss @@ -51,12 +51,15 @@ opacity: 0.5; } } + .grid-section { + .section-title { + padding-bottom: 0px; + } + } } .validation-input-wrapper { - .form-group { - .vsp-process-description { - height: 200px; - } + .form-group.vsp-process-description > textarea { + height: 113px; } } } diff --git a/openecomp-ui/resources/scss/modules/_softwareproductComponentLoadBalancing.scss b/openecomp-ui/resources/scss/modules/_softwareproductComponentLoadBalancing.scss index 731ab89571..04cb3c2051 100644 --- a/openecomp-ui/resources/scss/modules/_softwareproductComponentLoadBalancing.scss +++ b/openecomp-ui/resources/scss/modules/_softwareproductComponentLoadBalancing.scss @@ -1,4 +1,13 @@ .vsp-components-load-balancing { + .svg-icon-wrapper { + position: relative; + top: -3px; + .svg-icon.chevron-up, .svg-icon.chevron-down { + width: 10px; + height: 10px; + } + } + .halb-data { .load-balancing-page-title { @extend .section-title; @@ -14,22 +23,15 @@ } .title { @extend .body-1-medium; - cursor: pointer; margin-bottom: 8px; - .fa { + cursor: pointer; + .svg-icon { @include transition(transform 0.3s); margin-right: 5px; - font-size: $icon-font-size; position: relative; - top: -1px; + top: 4px; } } - .row { - padding-left: 24px; - } - .col-md-9 { - padding-left: 8px; - } .add-padding { padding-bottom: 20px; } diff --git a/openecomp-ui/resources/scss/modules/_vspComponentQuestionnaire.scss b/openecomp-ui/resources/scss/modules/_vspComponentQuestionnaire.scss index aad628aac8..d194c678b9 100644 --- a/openecomp-ui/resources/scss/modules/_vspComponentQuestionnaire.scss +++ b/openecomp-ui/resources/scss/modules/_vspComponentQuestionnaire.scss @@ -11,18 +11,13 @@ } .component-questionnaire-validation-form { - - .section-sub-title { - @extend .heading-5; - padding-bottom: 10px; - } .section-field { textarea { height: 80px; } } - .rows-section { + .rows-section, .grid-items { .row-flex-components { display: flex; } diff --git a/openecomp-ui/resources/scss/modules/_vspHeatSetup.scss b/openecomp-ui/resources/scss/modules/_vspHeatSetup.scss new file mode 100644 index 0000000000..59e983686b --- /dev/null +++ b/openecomp-ui/resources/scss/modules/_vspHeatSetup.scss @@ -0,0 +1,316 @@ +@mixin modules-and-artifacts-list-items { + background-color: $tlv-gray; + margin-bottom: 12px; + border: 1px solid $light-gray; + border-left-width: 18px; + border-left-color: $blue; + display: flex; + flex-direction: column; + justify-content: space-between; + padding: 10px 20px 0 20px; +} + +.heat-setup-view { + margin-top: 20px; + display: flex; + justify-content: space-between; + padding: 0 60px 0 36px; + + .heat-setup-view-modules-and-artifacts { + margin-right: 20px; + flex: 1; + .heat-setup-module-icon { + margin: 0 6px 0 0; + position: relative; + top: -2px; + } + .modules-list-wrapper { + padding-bottom: 20px; + margin-bottom: 20px; + border-bottom: 1px solid $tlv-light-gray; + ul { + .undefined-dragging { + opacity: 0.5; + } + .modules-list-item-selectors { + display: flex; + justify-content: space-between; + flex-wrap: wrap; + + .Select-value-label { + @include ellipsis(85%); + } + + .validation-input-wrapper { + flex-basis: 48%; + } + + .control-label { + margin-bottom: 4px; + } + + .form-group { + margin-bottom: 12px; + } + } + } + + .modules-list-controllers { + text-align: right; + .btn-link { + &[disabled] { + color: $gray; + } + @extend .body-1; + color: $blue; + &:last-child { + padding-right: 0; + } + &:hover { + color: $dark-blue; + text-decoration: none; + } + } + } + + .modules-list-item-controllers { + display: flex; + justify-content: space-between; + margin-bottom: 7px; + + .btn { + min-width: 0; + } + + .svg-icon.trash-o { + fill: $dark-gray; + height: 18px; + width: 18px; + &:hover { + fill: $black; + } + } + .module-title-by-type { + @extend .heading-5-medium; + margin-right: 3px; + } + .modules-list-item-filename { + display: flex; + align-items: center; + + .svg-icon.pencil { + height: 15px; + width: 15px; + margin-left: 3px; + opacity: 0; + } + + .filename-text { + @extend .heading-5-medium; + + } + + .text-and-icon { + padding: 5px; + border: 1px solid transparent; + display: flex; + align-items: center; + height: 35px; + &.in-edit { + padding: 0; + .name-edit { + padding: 4px; + @extend .heading-5-medium; + height: 100%; + border: 1px solid $light-gray; + width: 400px; + } + } + } + + input[disabled] { + border: none; + } + &:hover { + .text-and-icon { + border-color: $light-gray; + background-color: $white; + + &.in-edit { + border-color: transparent; + } + } + .svg-icon.pencil { + margin-left: 10px; + opacity: 1; + stroke: $dark-gray; + &:hover { + stroke: $black; + } + } + } + } + } + + .modules-list-item { + @include modules-and-artifacts-list-items; + position: relative; + .Select-option { + @extend .body-1; + &.is-selected { + @extend .body-1-medium; + background-color: $white; + } + &.is-focused { + background-color: $blue; + color: $white; + } + } + .add-or-delete-volumes { + .svg-icon-wrapper { + margin-right: 8px; + .svg-icon { + height: 10px; + width: 10px; + fill: $blue; + } + } + cursor: pointer; + color: $blue; + margin-bottom: 11px; + &:hover { + color: $dark-blue; + .svg-icon { + fill: $dark-blue; + } + } + } + &:before { + content: "\00B7\00B7\00B7\00B7\00B7\00B7"; + color: $white; + position: absolute; + left: -27px; + top: 56%; + font-size: 27px; + width: 75px; + @include transform-rotate(90); + height: 0; + letter-spacing: 1px; + } + } + } + + .artifact-files { + @include modules-and-artifacts-list-items; + margin-top: 20px; + + &.nested { + .nested-list { + display: flex; + flex-wrap: wrap; + margin-bottom: 18px; + } + + .nested-list-item { + border-radius: 15px; + background-color: $tlv-light-gray; + padding: 4px 15px; + margin: 2px 10px 2px 0; + } + } + + .artifact-files-header { + @extend .heading-5-medium; + display: flex; + margin-bottom: 10px; + justify-content: space-between; + .image-icon.artifacts { + margin-right: 10px; + } + + span { + display: flex; + } + + .add-all-unassigned { + @extend .body-1; + margin-bottom: 0; + color: $blue; + cursor: pointer; + &:hover { + color: $dark-blue; + } + } + } + } + } + + .unassigned-files { + margin-top: 30px; + border: 1px solid $light-gray; + width: 25%; + background-color: $white; + height: 250px; + width: 250px; + + // Will work in chrome from chrome 56 + position: sticky; + top: 10px; + + .unassigned-files-title { + @extend .heading-5-medium; + background-color: $tlv-gray; + padding: 11px 0 9px 15px; + } + + .unassigned-files-list { + height: 207px; + overflow-y: auto; + padding-bottom: 5px; + + .go-to-validation-button-wrapper { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + margin-top: 70px; + .all-files-assigned { + @extend .heading-4; + margin-bottom: 10px; + } + .link { + color: $blue; + cursor: pointer; + display: flex; + align-items: center; + margin-bottom: 10px; + .svg-icon.angle-right { + height: 10px; + width: 10px; + margin-left: 7px; + fill: $blue; + } + &:hover { + color: $dark-blue; + .svg-icon.angle-right { + fill: $dark-blue; + } + } + } + } + + .unassigned-files-list-item { + @include ellipsis(); + border-bottom: 1px solid $tlv-light-gray; + padding: 0 5px 5px 15px; + &:first-child { + padding-top: 5px; + } + &:last-child { + border-bottom: none; + padding-bottom: 0; + } + } + } + } +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogHeader.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogHeader.scss new file mode 100644 index 0000000000..d29a95d3d6 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogHeader.scss @@ -0,0 +1,33 @@ +.catalog-header { + margin: 34px 0 29px 50px; + display: flex; + flex-direction: row; + .expandable-input-top { + margin-right: 60px; + } + &.workspace-header { + @extend .heading-1; + color: $blue; + } + .catalog-header-tabs { + display: flex; + flex-direction: row; + .tab-separator { + position: relative; + top: 13px; + } + .catalog-header-tab { + @extend .heading-1; + cursor: pointer; + padding: 0 15px 0 15px; + display: flex; + align-items: center; + &.active { + color: $blue; + } + &:first-child { + padding-left: 0; + } + } + } +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogList.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogList.scss new file mode 100644 index 0000000000..071268c50d --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogList.scss @@ -0,0 +1,31 @@ +.catalog-list { + height: 100%; + overflow: auto; + display: flex; + flex-direction: column; + padding: 0 10px 0 42px; + .catalog-title { + @extend .heading-1; + color: $blue; + margin:0 0 12px 18px; + } + + .catalog-items { + display: flex; + flex-wrap: wrap; + @import "tile"; + @import "createItemTile"; + @import "catalogTile"; + @import "vendorTile"; + @import "vlmTile"; + &:after { + content: " "; + height: 250px; + display: block; + width: 100%; + } + } + + // Bottom spacing - cross browser solution + +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogTile.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogTile.scss new file mode 100644 index 0000000000..5ce8e12ec3 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_catalogTile.scss @@ -0,0 +1,139 @@ +.catalog-tile { + &:hover { + box-shadow: 0.3px 5px 12.8px 1.3px rgba(24, 24, 25, 0.15); + border: 1px solid $light-gray; + } + .catalog-tile-top { + position: relative; + flex: 1; + display: flex; + padding-top: 29px; + padding-left: 10px; + align-items: flex-start; + flex-direction: column; + .catalog-tile-content { + margin-top: auto; + width: 180px; + } + + + .catalog-tile-type { + display: block; + margin-top: -25px; + font-size: $heading-font-5; + &.license-model-type { + color: $purple; + } + &.software-product-type { + color: $blue; + } + } + .catalog-tile-entity-details { + margin-top:23px; + .catalog-tile-version-info{ + display: flex; + justify-content: space-between; + + .catalog-tile-item-version { + @extend .body-2; + line-height: 6px; + } + } + .catalog-tile-vendor-name { + @extend .body-3-medium; + color: $gray; + line-height: 12px; + @include ellipsis(auto,inline-block,178px); + } + + } + .catalog-tile-item-name { + @extend .heading-5-medium; + color: $black; + @include ellipsis(auto,inline-block,175px); + } + } + .catalog-tile-icon { + + width: 58px; + height: 58px; + text-align: center; + justify-content: center; + display: flex; + + .icon { + align-self: center; + height: 58px; + width: 58px; + margin-left: 122px; + background-repeat: no-repeat; + .svg-icon { + &.vendor { + fill: $dark-gray; + margin-top: 22px; + width: 53px; + height: 47px; + &:hover { + fill: $dark-gray; + } + } + &.vsp { + fill: $light-blue; + margin-top: 18px; + margin-left: 3px; + width: 60px; + height: 40px; + } + &.vlm { + fill: $purple; + margin-top: 18px; + width: 45px; + height: 53px; + } + + } + } + } + .catalog-tile-content { + border-top: 1px solid $background-gray; + padding-top: 5px; + display: flex; + justify-content: space-between; + margin-top:2px; + padding-bottom: 3px; + @extend .body-2-medium; + .svg-icon.plus { + height: 9px; + width: 9px; + fill: $blue; + } + .catalog-tile-item-details { + overflow: hidden; + } + + .catalog-tile-add-new-vsp { + color: $blue; + margin-left:40px; + } + .catalog-tile-locking-user-name { + @extend .body-2; + @include ellipsis(auto,inline-block,180px); + } + .catalog-tile-check-in-status { + .svg-icon-wrapper { + .svg-icon { + &.locked { + margin-left: 7px; + width: 11px; + fill: $gray; + } + &.unlocked { + margin-left: 7px; + width: 11px; + fill: $gray; + } + } + } + } + } +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_createItemTile.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_createItemTile.scss new file mode 100644 index 0000000000..b9f83fc452 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_createItemTile.scss @@ -0,0 +1,71 @@ +.create-catalog-item-wrapper { + width: 204px; + height: 200px; + display: flex; + flex-direction: column; + margin: 9px; + + .tile.create-catalog-item { + margin: 9px 0 9px 0; + display: flex; + background-color: $white; + &:first-child{margin-top: 0;} + &:last-child{margin-bottom: 0;} + flex-direction: row; + align-items: center; + justify-content: center; + &.disabled { + color: $gray; + .create-item-plus-icon { + fill: $gray; + } + } + &:hover { + box-shadow: 0.3px 5px 12.8px 1.3px rgba(24, 24, 25, 0.15); + + border: 1px solid $light-gray; + } + &:only-child { + text-align: center; + flex-direction: column; + justify-content: center; + .create-item-plus-icon { + margin: 0 0 15px 0; + } + .create-item-text { + @extend .heading-4-medium; + } + } + .create-item-plus-icon{ + width: 19px; + height: 19px; + margin: -5px 12px 0 0; + .svg-icon.plus { + height: 19px; + width: 19px; + } + } + &.vlm-type { + .create-item-text { + color: $purple; + } + + .create-item-plus-icon { + fill: $purple; + } + } + &.vsp-type { + .create-item-text { + color: $blue; + } + + .create-item-plus-icon { + fill: $blue; + } + } + .create-item-text { + width: 140px; + @extend .heading-5-medium; + } + } +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_onboardHeader.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_onboardHeader.scss new file mode 100644 index 0000000000..da4c017d39 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_onboardHeader.scss @@ -0,0 +1,31 @@ +.onboard-header { + padding-top: 8px; + display: flex; + flex-direction: row; + justify-content: flex-end; + background-color: $tlv-light-gray; + margin-bottom: 2px; + @include box-shadow(0px 1px 3px 0 rgba(0, 0, 0, 0.2)); + .expandable-input-top { + margin-right: 60px; + margin-left: auto; + } + .onboard-header-tabs { + display: flex; + flex-direction: row; + margin-left: 60px; + .onboard-header-tab { + @extend .body-1-medium; + margin-right: 40px; + cursor: pointer; + display: flex; + padding-bottom: 5px; + align-items: flex-end; + &.active { + color: $blue; + padding-bottom: 2px; + border-bottom: 3px solid $blue; + } + } + } +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_tile.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_tile.scss new file mode 100644 index 0000000000..217098fb97 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_tile.scss @@ -0,0 +1,14 @@ +.tile { + background-color: $white; + margin: 9px; + width: 204px; + height: 200px; + display: flex; + flex-direction: column; + cursor: pointer; + border: 1px solid $tlv-light-gray; + @include box-shadow(0.5px 0.8px 4px 0 rgba(24, 24, 25, 0.05)); + &:active { + border: 1px solid $light-blue; + } +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_vendorPageHeader.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_vendorPageHeader.scss new file mode 100644 index 0000000000..f1af28a0a0 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_vendorPageHeader.scss @@ -0,0 +1,21 @@ +.vendor-page-header { + display: flex; + align-items: center; + margin-top: 34px; + margin-left: 9px; + margin-bottom: 29px; + .vendor-name { + @extend .heading-1; + color: $blue; + margin-left: 20px; + text-transform: uppercase; + } + .svg-icon-wrapper { + padding: 5px 18px 5px 0; + .svg-icon.back { + height: 25px; + width: 25px; + fill: $blue; + } + } +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_vendorTile.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_vendorTile.scss new file mode 100644 index 0000000000..79a64f84ee --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_vendorTile.scss @@ -0,0 +1,88 @@ +@mixin flipOverlayDirection($itemsInRow) { + &:nth-child(#{$itemsInRow}n){ + .vsp-overlay-wrapper { + right: 74%; + left: inherit; + .vsp-overlay-arrow { + border-right-color: transparent; + border-left-color: $tlv-light-gray; + border-right-width: 2px; + border-left-width: 6px; + left: 100%; + &:after { + border-left-color: $white; + border-right-color: transparent; + left: -11px; + } + } + } + } +} + + +.catalog-tile.vendor-type { + position: relative; + .catalog-tile-top { + .catalog-tile-item-name { + margin-top:21px; + } + .catalog-tile-vsp-count { + @extend .body-3-medium; + margin-top: 8px; + margin-left: 54px; + margin-bottom: 9px; + color: $dark-gray; + border: 1px solid $dark-gray; + padding: 0 15px 0 15px; + border-radius: 15px; + + &.clickable { + &:hover { + background-color: #eceff3; + color: $dark-gray ; + } + } + &.active { + background-color: $white; + color: $dark-gray ; + } + } + } + + .catalog-tile-content { + flex-basis: auto; + max-height: 31px; + height: 31px; + text-align: center; + color: $blue; + display: block; + background-color: $white; + margin-bottom: 7px; + padding-bottom: 0px; + .create-new-vsp-button { + margin-top: 1px; + } + &:hover { + color: $dark-blue; + .svg-icon.plus { + fill: $dark-blue; + } + } + &.disabled { + cursor: default; + } + } + @media (min-width: 1900px){ + @include flipOverlayDirection($itemsInRow: 8); + } + @media (min-width: 1586px) and (max-width: 1899px){ + @include flipOverlayDirection($itemsInRow: 7); + } + @media (min-width: 1368px) and (max-width: 1585px){ + @include flipOverlayDirection($itemsInRow: 6); + } + @media (max-width: 1367px){ + @include flipOverlayDirection($itemsInRow: 5); + } + @import "vspOverlay"; +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_vlmTile.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_vlmTile.scss new file mode 100644 index 0000000000..721a4f3f22 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_vlmTile.scss @@ -0,0 +1,8 @@ +.catalog-tile.license-model-type { + .catalog-tile-top { + &:hover { + //background-color: $purple; + //color: $white; + } + } +} diff --git a/openecomp-ui/resources/scss/modules/onboardingCatalog/_vspOverlay.scss b/openecomp-ui/resources/scss/modules/onboardingCatalog/_vspOverlay.scss new file mode 100644 index 0000000000..8816ca5df9 --- /dev/null +++ b/openecomp-ui/resources/scss/modules/onboardingCatalog/_vspOverlay.scss @@ -0,0 +1,74 @@ +.vsp-overlay-wrapper{ + display:flex; + align-items: center; + position:absolute; + left: 68%; + top: 14%; + height: 100%; + pointer-events: none; + z-index: 100; + .vsp-overlay-list { + padding: 0 20px; + } + .vsp-overlay-arrow { + border-style: solid; + position: relative; + bottom: -18px; + border-width: 6px; + border-left-width: 2px; + border-color: transparent; + border-right-color: $light-gray; + &:after { + position: absolute; + border-style: solid; + bottom: -10px; + left: -9px; + border-width: 10px; + border-color: transparent; + border-right-color: $white; + content:' '; + } + } + .vsp-overlay { + pointer-events: all; + width: 205px; + cursor: default; + background-color: $white; + @include box-shadow(0px 2px 9.2px 0.8px rgba(24, 24, 25, 0.25)); + border-radius: 6px; + padding: 0 0 10px 0; + display: flex; + flex-direction: column; + margin: 10px 0 10px 0; + .vsp-overlay-title { + @extend .heading-5-medium; + margin-bottom: 15px; + padding: 10px 20px 10px 20px; + background: $highlight-gray; + color: $text-black; + text-transform: uppercase; + border-radius: 6px 6px 0 0; + } + .vsp-overlay-detail{ + @extend .body-2; + &:hover { + color: $blue; + } + text-transform: uppercase; + @include ellipsis(auto, block); + border-bottom: 1px solid $tlv-light-gray; + cursor: pointer; + padding: 5px 0 5px 0; + &:last-child { + border-bottom: none; + } + } + .vsp-overlay-see-more{ + color: $blue; + cursor: pointer; + margin-top: 12px; + align-self:center; + } + + } +} diff --git a/openecomp-ui/resources/scss/onboarding.scss b/openecomp-ui/resources/scss/onboarding.scss index f146b3910b..6b892ac0a4 100644 --- a/openecomp-ui/resources/scss/onboarding.scss +++ b/openecomp-ui/resources/scss/onboarding.scss @@ -1,10 +1,68 @@ .dox-ui { - @import "bootstrap"; + @import "bootstrap"; + @import "~react-select/dist/react-select.min.css"; - @import "../css/font-awesome.min.css"; - @import "~react-select/dist/react-select.min.css"; + @import "common"; + @import "components"; + @import "modules"; +} + +/* Out of namespace context for tooltips */ +div[data-reactroot].tooltip { + @import "common/variables"; + @import "common/typography"; + + &.in { + opacity: 1; + } + &.validation-error-message { + &.bottom { + .tooltip-arrow { + border-bottom-color: $red !important; + } + } + } + &.bottom { + .tooltip-arrow { + border-bottom-color: $dark-gray !important; + } + } + &.top { + .tooltip-arrow { + border-top-color: $dark-gray !important; + } + } + .tooltip-inner { + max-width: 100%; + background-color: $dark-gray; + } + + // activity log tooltip + &.activity-log-message-tooltip { + @include base-font-regular; + font-size: $body-font-2; + .message-block { + text-align: left; + padding: 3px 12px; + } + } + //dependency table error tooltip + &.select-action-table-error-tooltip{ + @include base-font-regular; + margin-right: 5px; + font-size: $body-font-2; + .message-block { + text-align: left; + padding: 3px 12px; + } + .tooltip-arrow { + border-bottom-color: $red !important; + } - @import "common"; - @import "components"; - @import "modules"; + .tooltip-inner { + background-color: $red; + padding: 6px 8px; + font-size: $body-font-2; + } + } } diff --git a/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx b/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx index f2ec1582f3..0759f2c28d 100644 --- a/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx +++ b/openecomp-ui/src/nfvo-components/SubmitErrorResponse.jsx @@ -1,9 +1,24 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component} from 'react'; import ListGroupItem from 'react-bootstrap/lib/ListGroupItem.js'; -import ListGroup from 'react-bootstrap/lib/ListGroup.js'; -import Panel from 'react-bootstrap/lib/Panel.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; - +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import Icon from 'nfvo-components/icon/Icon.jsx'; +import {Collapse} from 'react-bootstrap'; /** * parsing and showing the following Java Response object * @@ -31,103 +46,117 @@ class SubmitErrorResponse extends Component { render() { - let {validationResponse} = this.props; + let {validationResponse : {vspErrors, licensingDataErrors, questionnaireValidationResult, uploadDataErrors}} = this.props; return (
- {validationResponse.vspErrors && this.renderVspErrors(validationResponse.vspErrors)} - {validationResponse.licensingDataErrors && this.renderVspErrors(validationResponse.licensingDataErrors)} - {validationResponse.compilationErrors && this.renderCompilationErrors(validationResponse.compilationErrors)} - {validationResponse.uploadDataErrors && this.renderUploadDataErrors(validationResponse.uploadDataErrors)} - {validationResponse.questionnaireValidationResult && this.renderQuestionnaireValidationResult(validationResponse.questionnaireValidationResult)} + {vspErrors && this.renderVspErrors(vspErrors)} + {licensingDataErrors && this.renderVspErrors(licensingDataErrors)} + {questionnaireValidationResult && this.renderComponentsErrors(questionnaireValidationResult)} + {uploadDataErrors && this.renderUploadDataErrors(uploadDataErrors)}
); } - renderVspErrors(vspErrors) { + renderVspErrors(errors) { return ( - {this.parseErrorCodeCollection(vspErrors)} + +
+ {errors.length && errors.map(error=>{return ();})} +
+
); } - renderLicensingDataErrors(licensingDataErrors) { + + renderComponentsErrors(errors) { return ( - {this.parseErrorCodeCollection(licensingDataErrors)} - + +
+ {errors.validationData.length && errors.validationData.map(item =>{ return ();})} +
+
); } renderUploadDataErrors(uploadDataErrors) { return ( - {this.parseMapOfErrorMessagesList(uploadDataErrors)} - + +
+ +
+
); } +} - renderCompilationErrors(compilationErrors) { - return ( - {this.parseMapOfErrorMessagesList(compilationErrors)} - - ); - } - parseErrorCodeCollection(errors) { - return ( - {errors.map(error => - -
{i18n('Category: ')}{error.category}
-
{i18n('Message: ')}{error.message}
-
- )}
- ); - } +const ComponentError = ({item}) => { + let i = 0; + return ( +
+
{item.entityName}
+ {item.errors.map(error => {return();})} +
+ ); +}; - parseMapOfErrorMessagesList(errorMap) { - return ( - - {Object.keys(errorMap).map(errorStringKey => - - {errorMap[errorStringKey].map(error => - -
{i18n('Level: ')}{error.level}
-
{i18n('Message: ')}{error.message}
-
- )}
-
- )} -
- ); +function* entries(obj) { + for (let key of Object.keys(obj)) { + yield {header: key, list: obj[key]}; } +} +const UploadErrorList = ({items}) => { + let generator = entries(items); + + let errors = []; + let i = 0; + for (let item of generator) {errors.push( +
+
{item.header}
+ {item.list.map(error => )} +
+ );} + return ( +
+ {errors} +
+ ); +}; + +class ErrorBlock extends React.Component { + state = { + collapsed: false + }; - renderQuestionnaireValidationResult(questionnaireValidationResult) { - if (!questionnaireValidationResult.valid) { - return this.parseAndRenderCompositionEntityValidationData(questionnaireValidationResult.validationData); - } - } - - parseAndRenderCompositionEntityValidationData(validationData) { - let {entityType, entityId, errors = [], subEntitiesValidationData = []} = validationData; + render() { + let {errorType, children} = this.props; return ( - - - {errors.map(error => - -
{error}
-
- )}
- {subEntitiesValidationData.map(subValidationData => this.parseAndRenderCompositionEntityValidationData(subValidationData))} -
-
+
+ {this.setState({collapsed: !this.state.collapsed});}} errorType={errorType}/> + + {children} + +
); } - - } +const ErrorHeader = ({errorType, collapsed, onClick}) => { + return( +
+ + {errorType} +
+ ); +}; + +const ErrorMessage = ({error, warning}) => { + return ( + + + + ); +}; + export default SubmitErrorResponse; diff --git a/openecomp-ui/src/nfvo-components/activity-log/ActivityLog.js b/openecomp-ui/src/nfvo-components/activity-log/ActivityLog.js new file mode 100644 index 0000000000..f7354f96e2 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/activity-log/ActivityLog.js @@ -0,0 +1,27 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 ActivityLogView from './ActivityLogView.jsx'; + +export const mapStateToProps = ({licenseModel: {activityLog}}) => { + + let activities = activityLog; + return { + activities + }; +}; + +export default connect(mapStateToProps, undefined, null, {withRef: true})(ActivityLogView); diff --git a/openecomp-ui/src/nfvo-components/activity-log/ActivityLogActionHelper.js b/openecomp-ui/src/nfvo-components/activity-log/ActivityLogActionHelper.js new file mode 100644 index 0000000000..01a27abbc5 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/activity-log/ActivityLogActionHelper.js @@ -0,0 +1,31 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; +import Configuration from 'sdc-app/config/Configuration.js'; +import ActivityLogConstants from './ActivityLogConstants.js'; + + +function baseUrl(itemId, versionId) { + const restPrefix = Configuration.get('restPrefix'); + return `${restPrefix}/v1.0/activity-logs/${itemId}/versions/${versionId}`; +} + +export default { + + fetchActivityLog(dispatch, {itemId, versionId}){ + return RestAPIUtil.fetch(baseUrl(itemId, versionId)).then(response => dispatch({type: ActivityLogConstants.ACTIVITY_LOG_UPDATED, response})); + } +}; diff --git a/openecomp-ui/src/nfvo-components/activity-log/ActivityLogConstants.js b/openecomp-ui/src/nfvo-components/activity-log/ActivityLogConstants.js new file mode 100644 index 0000000000..69faf7cbb6 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/activity-log/ActivityLogConstants.js @@ -0,0 +1,23 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; + +export default keyMirror({ + + ACTIVITY_LOG_UPDATED: null + +}); + diff --git a/openecomp-ui/src/nfvo-components/activity-log/ActivityLogReducer.js b/openecomp-ui/src/nfvo-components/activity-log/ActivityLogReducer.js new file mode 100644 index 0000000000..fc3dfa1515 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/activity-log/ActivityLogReducer.js @@ -0,0 +1,25 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 ActivityLogConstants from './ActivityLogConstants.js'; + +export default (state = [], action) => { + switch (action.type) { + case ActivityLogConstants.ACTIVITY_LOG_UPDATED: + return [...action.response.results]; + } + + return state; +}; diff --git a/openecomp-ui/src/nfvo-components/activity-log/ActivityLogView.jsx b/openecomp-ui/src/nfvo-components/activity-log/ActivityLogView.jsx new file mode 100644 index 0000000000..6ff3c806a8 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/activity-log/ActivityLogView.jsx @@ -0,0 +1,124 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 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'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import i18n from 'nfvo-utils/i18n/i18n.js'; + +function ActivityLogSortableCellHeader({isHeader, data, isDes, onSort}) { + 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}
+ }> + {'?'} +
} +
+ ); +} + +export function ActivityListItem({activity, isHeader, isDes, onSort}) { + let {type, timestamp, comment, user, status} = activity; + return ( +
  • +
    +
    {type}
    +
    {comment}
    +
    {user}
    +
    +
  • + ); +} + +class ActivityLogView extends Component { + + state = { + localFilter: '', + sortDescending: true + }; + + render() { + return ( +
    + this.setState({localFilter: filter})}> + this.setState({sortDescending: !this.state.sortDescending})}/> + {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 = '', comment = '', type = ''}) => escape(user).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/nfvo-components/confirmations/ConfirmationModalView.jsx b/openecomp-ui/src/nfvo-components/confirmations/ConfirmationModalView.jsx deleted file mode 100644 index cc971c608c..0000000000 --- a/openecomp-ui/src/nfvo-components/confirmations/ConfirmationModalView.jsx +++ /dev/null @@ -1,53 +0,0 @@ -import React from 'react'; -import Button from 'react-bootstrap/lib/Button.js'; - -import i18n from 'nfvo-utils/i18n/i18n.js'; -import Modal from 'nfvo-components/modal/Modal.jsx'; - -let typeClass = { - 'default': 'primary', - error: 'danger', - warning: 'warning', - success: 'success' -}; - - -class ConfirmationModalView extends React.Component { - - static propTypes = { - show: React.PropTypes.bool, - type: React.PropTypes.oneOf(['default', 'error', 'warning', 'success']), - msg: React.PropTypes.node, - title: React.PropTypes.string, - confirmationDetails: React.PropTypes.object, - confirmationButtonText: React.PropTypes.string, - - }; - - static defaultProps = { - show: false, - type: 'warning', - title: 'Warning', - msg: '', - confirmationButtonText: i18n('Delete') - }; - - render() { - let {title, type, msg, show, confirmationButtonText} = this.props; - - return( - - - {title} - - {msg} - - - - - - ); - }; -} - -export default ConfirmationModalView; diff --git a/openecomp-ui/src/nfvo-components/editor/TabulatedEditor.jsx b/openecomp-ui/src/nfvo-components/editor/TabulatedEditor.jsx index 4a106b5ff4..2a0b7d4d2a 100644 --- a/openecomp-ui/src/nfvo-components/editor/TabulatedEditor.jsx +++ b/openecomp-ui/src/nfvo-components/editor/TabulatedEditor.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import classnames from 'classnames'; @@ -7,10 +22,17 @@ import NavigationSideBar from 'nfvo-components/panel/NavigationSideBar.jsx'; export default class TabulatedEditor extends React.Component { render() { - const {versionControllerProps, navigationBarProps, onToggle, onVersionSwitching, onCreate, onSave, onClose, onVersionControllerAction, onNavigate, children} = this.props; + const {navigationBarProps, onToggle, onVersionSwitching, onCreate, onSave, onClose, onVersionControllerAction, onNavigate, children, meta} = 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 (
    @@ -19,11 +41,10 @@ export default class TabulatedEditor extends React.Component {
    onVersionSwitching(version)} - callVCAction={onVersionControllerAction} + onVersionSwitching={version => onVersionSwitching(version, meta)} + callVCAction={(action, version) => onVersionControllerAction(action, version, meta)} onCreate={onCreate && this.handleCreate} - onSave={onSave && this.handleSave} - onClose={() => onClose(versionControllerProps)}/> + onSave={onSave && this.handleSave}/>
    { child diff --git a/openecomp-ui/src/nfvo-components/grid/GridItem.jsx b/openecomp-ui/src/nfvo-components/grid/GridItem.jsx new file mode 100644 index 0000000000..8819ab78a3 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/grid/GridItem.jsx @@ -0,0 +1,26 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; + +const GridItem = ({colSpan = 1, children, stretch = false}) => ( +
    +
    + {children} +
    +
    +); + +export default GridItem; diff --git a/openecomp-ui/src/nfvo-components/grid/GridSection.jsx b/openecomp-ui/src/nfvo-components/grid/GridSection.jsx new file mode 100644 index 0000000000..175b3ee082 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/grid/GridSection.jsx @@ -0,0 +1,33 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; + +const GridSection = ({title, children, titleClassName}) => { + return ( +
    + {title &&
    {title}
    } +
    + {children} +
    +
    + ); +}; + +GridSection.propTypes = { + title: React.PropTypes.string, +}; + +export default GridSection; diff --git a/openecomp-ui/src/nfvo-components/icon/Icon.jsx b/openecomp-ui/src/nfvo-components/icon/Icon.jsx new file mode 100644 index 0000000000..125577664b --- /dev/null +++ b/openecomp-ui/src/nfvo-components/icon/Icon.jsx @@ -0,0 +1,45 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, { Component, PropTypes } from 'react'; + + +export default class Icon extends Component { + + static propTypes = { + image: PropTypes.string.isRequired, + onClick: PropTypes.func, + label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), + className: PropTypes.string, + iconClassName: PropTypes.string + }; + + static defaultProps = { + label: '', + className: '', + iconClassName: '' + }; + + render() { + let {image, onClick, label, className, iconClassName, ...other} = this.props; + let classes = `icon-component ${className} ${onClick ? 'clickable' : ''}`; + return ( +
    + + {label} +
    + ); + } +} diff --git a/openecomp-ui/src/nfvo-components/icon/SVGIcon.jsx b/openecomp-ui/src/nfvo-components/icon/SVGIcon.jsx new file mode 100644 index 0000000000..dd165fb52c --- /dev/null +++ b/openecomp-ui/src/nfvo-components/icon/SVGIcon.jsx @@ -0,0 +1,54 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {PropTypes} from 'react'; +import Configuration from 'sdc-app/config/Configuration.js'; + +export default class SVGIcon extends React.Component { + + static propTypes = { + name: PropTypes.string.isRequired, + onClick: PropTypes.func, + label: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), + labelPosition: PropTypes.string, + className: PropTypes.string, + iconClassName: PropTypes.string, + labelClassName: PropTypes.string + }; + + static defaultProps = { + name: '', + label: '', + className: '', + iconClassName: '', + labelClassName: '', + labelPosition: 'bottom' + }; + + render() { + let {name, onClick, label, className, iconClassName, labelClassName, labelPosition, ...other} = this.props; + let classes = `svg-icon-wrapper ${className} ${onClick ? 'clickable' : ''} ${labelPosition}`; + + return ( +
    + + + + {label && {label}} +
    + ); + } +} diff --git a/openecomp-ui/src/nfvo-components/icon/SVGIcon.stories.js b/openecomp-ui/src/nfvo-components/icon/SVGIcon.stories.js new file mode 100644 index 0000000000..6675670cea --- /dev/null +++ b/openecomp-ui/src/nfvo-components/icon/SVGIcon.stories.js @@ -0,0 +1,50 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import {select, text, withKnobs} from '@kadira/storybook-addon-knobs'; +import SVGIcon from './SVGIcon.jsx'; + +const stories = storiesOf('SVGIcon', module); + +const iconNames = ['locked', + 'pencil', + 'plus-circle', + 'plus', + 'search', + 'sliders', + 'trash-o', + 'unlocked', + 'vendor', + 'version-controller-lock-closed', + 'version-controller-lock-open', + 'version-controller-revert', + 'version-controller-save', + 'version-controller-submit', + 'vlm', + 'vsp' ]; + +function colorChanger() { + return {fill: text('Color', '')}; +} + +function iconName() { + return select('Icon name' , iconNames, iconNames[0]); +} + +stories.addDecorator(withKnobs); + +stories + .add('icon', () => { + return ( + + ); + }) + .add('icon with label', () => { + return ( + + ); + }) + .add('locked clickable', () => { + return ( + + ); + }); \ No newline at end of file diff --git a/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx b/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx index 3ac3fcad28..e2ee40fcd2 100644 --- a/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx +++ b/openecomp-ui/src/nfvo-components/input/ExpandableInput.jsx @@ -1,77 +1,115 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; -import FontAwesome from 'react-fontawesome'; -import classnames from 'classnames'; -import Input from 'react-bootstrap/lib/Input'; +import ReactDOM from 'react-dom'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import Input from 'nfvo-components/input/validation/InputWrapper.jsx'; +const ExpandableInputClosed = ({iconType, onClick}) => ( + +); -class ExpandableInput extends React.Component { - constructor(props){ - super(props); - this.state = {showInput: false, value: ''}; - this.toggleInput = this.toggleInput.bind(this); - this.handleFocus = this.handleFocus.bind(this); - this.handleInput = this.handleInput.bind(this); - this.handleClose = this.handleClose.bind(this); +class ExpandableInputOpened extends React.Component { + componentDidMount(){ + this.rawDomNode = ReactDOM.findDOMNode(this.searchInputNode.inputWrapper); + this.rawDomNode.focus(); } - toggleInput(){ - if (!this.state.showInput){ - this.searchInputNode.refs.input.focus(); - } else { - this.setState({showInput: false}); + componentWillReceiveProps(newProps){ + if (!newProps.value){ + if (!(document.activeElement === this.rawDomNode)){ + this.props.handleBlur(); + } } } - handleInput(e){ - let {onChange} = this.props; + handleClose(){ + this.props.onChange(''); + this.rawDomNode.focus(); + } - this.setState({value: e.target.value}); - onChange(e); + handleKeyDown(e){ + if (e.key === 'Escape'){ + e.preventDefault(); + if (this.props.value) { + this.handleClose(); + } else { + this.rawDomNode.blur(); + } + }; } - handleClose(){ - this.handleInput({target: {value: ''}}); - this.searchInputNode.refs.input.focus(); + 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 { - handleFocus(){ - if (!this.state.showInput){ - this.setState({showInput: true}); + static propTypes = { + iconType: React.PropTypes.string, + onChange: React.PropTypes.func, + value: React.PropTypes.string + }; + + state = {showInput: false}; + + closeInput(){ + if (!this.props.value) { + this.setState({showInput: false}); } } getValue(){ - return this.state.value; + return this.props.value; } render(){ - let {iconType} = this.props; - - let inputClasses = classnames({ - 'expandable-active': this.state.showInput, - 'expandable-not-active': !this.state.showInput - }); - - let iconClasses = classnames( - 'expandable-icon', - {'expandable-icon-active': this.state.showInput} - ); - + let {iconType, value, onChange = false} = this.props; return ( -
    - this.searchInputNode = input} - className={inputClasses} - groupClassName='expandable-input-control' - onChange={e => this.handleInput(e)} - onFocus={this.handleFocus}/> - {this.state.showInput && this.state.value && } - {!this.state.value && } +
    + {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 1036ac41c3..03c727379e 100644 --- a/openecomp-ui/src/nfvo-components/input/SelectInput.jsx +++ b/openecomp-ui/src/nfvo-components/input/SelectInput.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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. + */ /** * The HTML structure here is aligned with bootstrap HTML structure for form elements. * In this way we have proper styling and it is aligned with other form elements on screen. @@ -20,8 +35,9 @@ class SelectInput extends Component { 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.onSelectItems(event.target.selectedOptions)} groupClassName='dual-list-box-multi-select' type='select' name='dual-list-box-multi-select' - {...props}> + 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))} @@ -92,6 +106,11 @@ class DualListboxView extends React.Component { ); } + onSelectItems(selectedOptions) { + let selectedValues = Object.keys(selectedOptions).map((k) => selectedOptions[k].value); + this.setState({selectedValues}); + } + renderOption(value, name) { return (); } @@ -107,17 +126,19 @@ class DualListboxView extends React.Component { ); } - renderOperationBarButton(onClick, fontAwesomeIconName){ - return (
    ); + renderOperationBarButton(onClick, iconName){ + return (
    ); } addToSelectedList() { - this.props.onChange(this.props.selectedValuesList.concat(this.refs.availableValues.getValue())); + this.props.onChange(this.props.selectedValuesList.concat(this.state.selectedValues)); + this.setState({selectedValues: []}); } removeFromSelectedList() { - const selectedValues = this.refs.selectedValues.getValue(); + const selectedValues = this.state.selectedValues; this.props.onChange(this.props.selectedValuesList.filter(value => !selectedValues.find(selectedValue => selectedValue === value))); + this.setState({selectedValues: []}); } addAllToSelectedList() { diff --git a/openecomp-ui/src/nfvo-components/input/inputOptions/InputOptions.jsx b/openecomp-ui/src/nfvo-components/input/inputOptions/InputOptions.jsx index 5daaffea41..e8aadc4357 100644 --- a/openecomp-ui/src/nfvo-components/input/inputOptions/InputOptions.jsx +++ b/openecomp-ui/src/nfvo-components/input/inputOptions/InputOptions.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import classNames from 'classnames'; @@ -13,15 +28,21 @@ class InputOptions extends React.Component { title: React.PropTypes.string })), isEnabledOther: React.PropTypes.bool, - title: React.PropTypes.string, + label: React.PropTypes.string, selectedValue: React.PropTypes.string, - multiSelectedEnum: React.PropTypes.array, + multiSelectedEnum: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.array + ]), selectedEnum: React.PropTypes.string, otherValue: React.PropTypes.string, onEnumChange: React.PropTypes.func, onOtherChange: React.PropTypes.func, + onBlur: React.PropTypes.func, isRequired: React.PropTypes.bool, - isMultiSelect: React.PropTypes.bool + isMultiSelect: React.PropTypes.bool, + hasError: React.PropTypes.bool, + disabled: React.PropTypes.bool }; @@ -41,7 +62,7 @@ class InputOptions extends React.Component { render() { let {label, isRequired, values, otherValue, onOtherChange, isMultiSelect, onBlur, multiSelectedEnum, selectedEnum, hasError, validations, children} = this.props; - + const dataTestId = this.props['data-test-id'] ? {'data-test-id': this.props['data-test-id']} : {}; let currentMultiSelectedEnum = []; let currentSelectedEnum = ''; let {otherInputDisabled} = this.state; @@ -54,14 +75,18 @@ class InputOptions extends React.Component { else if(selectedEnum){ currentSelectedEnum = selectedEnum; } + if (!onBlur) { + onBlur = () => {}; + } let isReadOnlyMode = this.context.isReadOnlyMode; return( -
    +
    {label && } {isMultiSelect && otherInputDisabled ? onBlur()} disabled={isReadOnlyMode || Boolean(this.props.disabled)} onChange={ value => this.enumChanged(value)} type='select'> - {values && values.length && values.map(val => this.renderOptions(val))} + {children || (values && values.length && values.map((val, index) => this.renderOptions(val, index)))} {onOtherChange && } - {children} {!otherInputDisabled &&
    } @@ -104,9 +129,9 @@ class InputOptions extends React.Component { ); } - renderOptions(val){ - return( - + renderOptions(val, index){ + return ( + ); } @@ -154,9 +179,9 @@ class InputOptions extends React.Component { enumChanged() { let enumValue = this.refs._myInput.value; - let {onEnumChange, isMultiSelect, onChange} = this.props; + let {onEnumChange, onOtherChange, isMultiSelect, onChange} = this.props; this.setState({ - otherInputDisabled: enumValue !== other.OTHER + otherInputDisabled: !Boolean(onOtherChange) || enumValue !== other.OTHER }); let value = isMultiSelect ? [enumValue] : enumValue; @@ -169,7 +194,7 @@ class InputOptions extends React.Component { } multiSelectEnumChanged(enumValue) { - let {onEnumChange} = this.props; + let {onEnumChange, onOtherChange} = this.props; let selectedValues = enumValue.map(enumVal => { return enumVal.value; }); @@ -182,7 +207,7 @@ class InputOptions extends React.Component { } this.setState({ - otherInputDisabled: !selectedValues.includes(i18n(other.OTHER)) + otherInputDisabled: !Boolean(onOtherChange) || !selectedValues.includes(i18n(other.OTHER)) }); onEnumChange(selectedValues); } diff --git a/openecomp-ui/src/nfvo-components/input/validation/Form.jsx b/openecomp-ui/src/nfvo-components/input/validation/Form.jsx new file mode 100644 index 0000000000..47922f86a0 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/input/validation/Form.jsx @@ -0,0 +1,114 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import ValidationButtons from './ValidationButtons.jsx'; + +class Form extends React.Component { + + static defaultProps = { + hasButtons : true, + onSubmit : null, + onReset : null, + labledButtons: true, + onValidChange : null, + isValid: true + }; + + static propTypes = { + isValid : React.PropTypes.bool, + formReady : React.PropTypes.bool, + isReadOnlyMode : React.PropTypes.bool, + hasButtons : React.PropTypes.bool, + onSubmit : React.PropTypes.func, + onReset : React.PropTypes.func, + labledButtons: React.PropTypes.bool, + onValidChange : React.PropTypes.func, + onValidityChanged: React.PropTypes.func, + onValidateForm: React.PropTypes.func + }; + + constructor(props) { + super(props); + } + + + render() { + // eslint-disable-next-line no-unused-vars + let {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}/>} + + ); + } + + 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 default Form; diff --git a/openecomp-ui/src/nfvo-components/input/validation/Input.jsx b/openecomp-ui/src/nfvo-components/input/validation/Input.jsx new file mode 100644 index 0000000000..59c35d7993 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/input/validation/Input.jsx @@ -0,0 +1,180 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import ReactDOM from 'react-dom'; +import classNames from 'classnames'; +import Checkbox from 'react-bootstrap/lib/Checkbox.js'; +import Radio from 'react-bootstrap/lib/Radio.js'; +import FormGroup from 'react-bootstrap/lib/FormGroup.js'; +import FormControl from 'react-bootstrap/lib/FormControl.js'; +import Overlay from 'react-bootstrap/lib/Overlay.js'; +import Tooltip from 'react-bootstrap/lib/Tooltip.js'; + +class Input extends React.Component { + + state = { + value: this.props.value, + checked: this.props.checked, + selectedValues: [] + } + + 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, ...inputProps} = this.props; + let wrapperClassName = (type !== 'radio') ? 'validation-input-wrapper' : 'form-group'; + if (disabled) { + wrapperClassName += ' disabled'; + } + return( +
    + + {(label && (type !== 'checkbox' && type !== 'radio')) && } + {(type === 'text' || type === 'number') && + 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 === '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={value} + data-test-id={this.props['data-test-id']}>{label}} + + {type === 'radio' && + this.onChangeRadio(e)} + data-test-id={this.props['data-test-id']}>{label}} + {type === 'select' && + this.optionSelect(e) } + componentClass={type} + inputRef={(input) => this.input = input} + name={name} {...inputProps} + data-test-id={this.props['data-test-id']}/>} + + { this.renderErrorOverlay() } +
    + ); + } + + 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) { + const {onChange, type} = this.props; + let value = e.target.value; + if (type === 'number') { + value = Number(value); + } + this.setState({ + value + }); + onChange(value); + } + + onChangeCheckBox(e) { + let {onChange} = this.props; + this.setState({ + checked: e.target.checked + }); + onChange(e.target.checked); + } + + onChangeRadio(e) { + let {onChange} = this.props; + this.setState({ + checked: e.target.checked + }); + onChange(this.state.value); + } + + focus() { + ReactDOM.findDOMNode(this.input).focus(); + } + + 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 === 'password') { + position = 'bottom'; + } + + return ( + { + let target = ReactDOM.findDOMNode(this.input); + return target.offsetParent ? target : undefined; + }} + container={this}> + + {errorText} + + + ); + } + +} +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 new file mode 100644 index 0000000000..6e54254eb0 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/input/validation/InputOptions.jsx @@ -0,0 +1,279 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import ReactDOM from 'react-dom'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import classNames from 'classnames'; +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'}; + +class InputOptions extends React.Component { + + static propTypes = { + values: React.PropTypes.arrayOf(React.PropTypes.shape({ + enum: React.PropTypes.string, + title: React.PropTypes.string + })), + isEnabledOther: React.PropTypes.bool, + label: React.PropTypes.string, + selectedValue: React.PropTypes.string, + multiSelectedEnum: React.PropTypes.oneOfType([ + React.PropTypes.string, + React.PropTypes.array + ]), + selectedEnum: React.PropTypes.string, + otherValue: React.PropTypes.string, + overlayPos: React.PropTypes.string, + onEnumChange: React.PropTypes.func, + onOtherChange: React.PropTypes.func, + onBlur: React.PropTypes.func, + isRequired: React.PropTypes.bool, + isMultiSelect: React.PropTypes.bool, + isValid: React.PropTypes.bool, + disabled: React.PropTypes.bool + }; + + state = { + otherInputDisabled: !this.props.otherValue + }; + + 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} = this.state; + 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 && } + + + {!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 ( + + ); + } + + + 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; + + if (overlayPos) { + position = overlayPos; + } + else if (type === 'text' + || type === 'email' + || type === 'number' + || type === 'password') { + position = 'bottom'; + } + + return ( + { + let {otherInputDisabled} = this.state; + let target = otherInputDisabled ? ReactDOM.findDOMNode(this.input) : ReactDOM.findDOMNode(this.otherValue); + return target.offsetParent ? target : undefined; + }} + container={this}> + + {errorText} + + + ); + } + + getValue() { + let res = ''; + let {isMultiSelect} = this.props; + let {otherInputDisabled} = this.state; + + if (otherInputDisabled) { + res = isMultiSelect ? this.input.getValue() : this.input.value; + } else { + res = this.otherValue.value; + } + return res; + } + + enumChanged() { + let enumValue = this.input.value; + let {onEnumChange, onOtherChange, isMultiSelect, onChange} = this.props; + this.setState({ + otherInputDisabled: !Boolean(onOtherChange) || enumValue !== other.OTHER + }); + + let value = isMultiSelect ? [enumValue] : enumValue; + if (onEnumChange) { + onEnumChange(value); + } + if (onChange) { + onChange(value); + } + } + + multiSelectEnumChanged(enumValue) { + let {onEnumChange, onOtherChange} = this.props; + let selectedValues = enumValue.map(enumVal => { + return enumVal.value; + }); + + if (this.state.otherInputDisabled === false) { + selectedValues.shift(); + } + else if (selectedValues.includes(i18n(other.OTHER))) { + selectedValues = [i18n(other.OTHER)]; + } + + 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; + } + +} + +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 new file mode 100644 index 0000000000..5ca716cc20 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/input/validation/InputWrapper.jsx @@ -0,0 +1,134 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import ReactDOM from 'react-dom'; +import classNames from 'classnames'; +import Checkbox from 'react-bootstrap/lib/Checkbox.js'; +import Radio from 'react-bootstrap/lib/Radio.js'; +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.onChangeRadio(e)} + data-test-id={this.props['data-test-id']}>{label}} + {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(e) { + let {onChange} = this.props; + this.setState({ + checked: e.target.checked + }); + onChange(this.state.value); + } + + focus() { + ReactDOM.findDOMNode(this.inputWrapper).focus(); + } + +} +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 new file mode 100644 index 0000000000..95144b1468 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/input/validation/Tabs.jsx @@ -0,0 +1,79 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import ReactDOM from 'react-dom'; +import {default as BTabs} from 'react-bootstrap/lib/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 { + + static propTypes = { + children: React.PropTypes.node + }; + + cloneTab(element) { + const {invalidTabs} = this.props; + return React.cloneElement( + element, + { + key: element.props.eventKey, + tabClassName: invalidTabs.indexOf(element.props.eventKey) > -1 ? 'invalid-tab' : 'valid-tab' + } + ); + } + + showTabsError() { + const {invalidTabs} = this.props; + const showError = ((invalidTabs.length === 1 && invalidTabs[0] !== this.props.activeKey) || (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(.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(.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 a87c8d6f40..ebb1473c04 100644 --- a/openecomp-ui/src/nfvo-components/input/validation/ValidationButtons.jsx +++ b/openecomp-ui/src/nfvo-components/input/validation/ValidationButtons.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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. + */ /** * Holds the buttons for save/reset for forms. * Used by the ValidationForm that changes the state of the buttons according to its own state. @@ -8,7 +23,7 @@ import React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Button from 'react-bootstrap/lib/Button.js'; -import FontAwesome from 'react-fontawesome'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; class ValidationButtons extends React.Component { @@ -22,8 +37,8 @@ class ValidationButtons extends React.Component { }; render() { - var submitBtn = this.props.labledButtons ? i18n('Save') : ; - var closeBtn = this.props.labledButtons ? i18n('Cancel') : ; + var submitBtn = this.props.labledButtons ? i18n('Save') : ; + var closeBtn = this.props.labledButtons ? i18n('Cancel') : ; return (
    {!this.props.isReadOnlyMode ? diff --git a/openecomp-ui/src/nfvo-components/input/validation/ValidationForm.jsx b/openecomp-ui/src/nfvo-components/input/validation/ValidationForm.jsx deleted file mode 100644 index 098ccf1fd4..0000000000 --- a/openecomp-ui/src/nfvo-components/input/validation/ValidationForm.jsx +++ /dev/null @@ -1,200 +0,0 @@ -/** - * ValidationForm should be used in order to have a form that handles it's internal validation state. - * All ValidationInputs inside the form are checked for validity and the styling and submit buttons - * are updated accordingly. - * - * The properties that ahould be given to the form: - * labledButtons - whether or not use icons only as the form default buttons or use buttons with labels - * onSubmit - function for click on the submit button - * onReset - function for click on the reset button - */ -import React from 'react'; -import JSONSchema from 'nfvo-utils/json/JSONSchema.js'; -import JSONPointer from 'nfvo-utils/json/JSONPointer.js'; -import ValidationButtons from './ValidationButtons.jsx'; - -class ValidationForm extends React.Component { - - static childContextTypes = { - validationParent: React.PropTypes.any, - isReadOnlyMode: React.PropTypes.bool, - validationSchema: React.PropTypes.instanceOf(JSONSchema), - validationData: React.PropTypes.object - }; - - static defaultProps = { - hasButtons : true, - onSubmit : null, - onReset : null, - labledButtons: true, - onValidChange : null, - isValid: true - }; - - static propTypes = { - isValid : React.PropTypes.bool, - isReadOnlyMode : React.PropTypes.bool, - hasButtons : React.PropTypes.bool, - onSubmit : React.PropTypes.func, - onReset : React.PropTypes.func, - labledButtons: React.PropTypes.bool, - onValidChange : React.PropTypes.func, - onValidityChanged: React.PropTypes.func, - schema: React.PropTypes.object, - data: React.PropTypes.object - }; - - state = { - isValid: this.props.isValid - }; - - constructor(props) { - super(props); - this.validationComponents = []; - } - - componentWillMount() { - let {schema, data} = this.props; - if (schema) { - this.processSchema(schema, data); - } - } - - componentWillReceiveProps(nextProps) { - let {schema, data} = this.props; - let {schema: nextSchema, data: nextData} = nextProps; - - if (schema !== nextSchema || data !== nextData) { - if (!schema || !nextSchema) { - throw new Error('ValidationForm: dynamically adding/removing schema is not supported'); - } - - if (schema !== nextSchema) { - this.processSchema(nextSchema, nextData); - } else { - this.setState({data: nextData}); - } - } - } - - processSchema(rawSchema, rawData) { - let schema = new JSONSchema(); - schema.setSchema(rawSchema); - let data = schema.processData(rawData); - this.setState({ - schema, - data - }); - } - - render() { - // eslint-disable-next-line no-unused-vars - let {isValid, isReadOnlyMode, hasButtons, onSubmit, labledButtons, onValidChange, onValidityChanged, schema, data, children, ...formProps} = this.props; - return ( -
    this.handleFormSubmit(event)}> -
    {children}
    - {hasButtons && } - - ); - } - - handleFormSubmit(event) { - event.preventDefault(); - let isFormValid = true; - this.validationComponents.forEach(validationComponent => { - const isInputValid = validationComponent.validate().isValid; - isFormValid = isInputValid && isFormValid; - }); - if(isFormValid && this.props.onSubmit) { - return this.props.onSubmit(event); - } else if(!isFormValid) { - this.setState({isValid: false}); - } - } - - componentWillUpdate(nextProps, nextState) { - if(this.state.isValid !== nextState.isValid && this.props.onValidityChanged) { - this.props.onValidityChanged(nextState.isValid); - } - } - - componentDidUpdate(prevProps, prevState) { - // 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.refs.buttons.setState({isValid: this.state.isValid}); - } - } else if(this.state.isValid !== prevState.isValid) { - if (this.props.hasButtons) { - this.refs.buttons.setState({isValid: this.state.isValid}); - } - // callback in case form is part of bigger picture in view - if (this.props.onValidChange) { - this.props.onValidChange(this.state.isValid); - } - } - } - - componentDidMount() { - if (this.props.hasButtons) { - this.refs.buttons.setState({isValid: this.state.isValid}); - } - } - - - getChildContext() { - return { - validationParent: this, - isReadOnlyMode: this.props.isReadOnlyMode, - validationSchema: this.state.schema, - validationData: this.state.data - }; - } - - - /*** - * Used by ValidationInput in order to let the (parent) form know - * the valid state. If there is a change in the state of the form, - * the buttons will be updated. - * - * @param validationComponent - * @param isValid - */ - childValidStateChanged(validationComponent, isValid) { - if (isValid !== this.state.isValid) { - let oldState = this.state.isValid; - let newState = isValid && this.validationComponents.filter(otherValidationComponent => validationComponent !== otherValidationComponent).every(otherValidationComponent => { - return otherValidationComponent.isValid(); - }); - - if (oldState !== newState) { - this.setState({isValid: newState}); - } - } - } - - register(validationComponent) { - if (this.state.schema) { - // TODO: register - } else { - this.validationComponents.push(validationComponent); - } - } - - unregister(validationComponent) { - this.childValidStateChanged(validationComponent, true); - this.validationComponents = this.validationComponents.filter(otherValidationComponent => validationComponent !== otherValidationComponent); - } - - onValueChanged(pointer, value, isValid, error) { - this.props.onDataChanged({ - data: JSONPointer.setValue(this.props.data, pointer, value), - isValid, - error - }); - } -} - - -export default ValidationForm; diff --git a/openecomp-ui/src/nfvo-components/input/validation/ValidationInput.jsx b/openecomp-ui/src/nfvo-components/input/validation/ValidationInput.jsx deleted file mode 100644 index 0f14307645..0000000000 --- a/openecomp-ui/src/nfvo-components/input/validation/ValidationInput.jsx +++ /dev/null @@ -1,509 +0,0 @@ -/** - * Used for inputs on a validation form. - * All properties will be passed on to the input element. - * - * The following properties can be set for OOB validations and callbacks: - - required: Boolean: Should be set to true if the input must have a value - - numeric: Boolean : Should be set to true id the input should be an integer - - onChange : Function : Will be called to validate the value if the default validations are not sufficient, should return a boolean value - indicating whether the value is valid - - didUpdateCallback :Function: Will be called after the state has been updated and the component has rerendered. This can be used if - there are dependencies between inputs in a form. - * - * The following properties of the state can be set to determine - * the state of the input from outside components: - - isValid : Boolean - whether the value is valid - - value : value for the input field, - - disabled : Boolean, - - required : Boolean - whether the input value must be filled out. - */ -import React from 'react'; -import ReactDOM from 'react-dom'; -import Validator from 'validator'; -import FormGroup from 'react-bootstrap/lib/FormGroup.js'; -import Input from 'react-bootstrap/lib/Input.js'; -import Overlay from 'react-bootstrap/lib/Overlay.js'; -import Tooltip from 'react-bootstrap/lib/Tooltip.js'; -import isEqual from 'lodash/isEqual.js'; -import i18n from 'nfvo-utils/i18n/i18n.js'; -import JSONSchema from 'nfvo-utils/json/JSONSchema.js'; -import JSONPointer from 'nfvo-utils/json/JSONPointer.js'; - - -import InputOptions from '../inputOptions/InputOptions.jsx'; - -const globalValidationFunctions = { - required: value => value !== '', - maxLength: (value, length) => Validator.isLength(value, {max: length}), - minLength: (value, length) => Validator.isLength(value, {min: length}), - pattern: (value, pattern) => Validator.matches(value, pattern), - numeric: value => { - if (value === '') { - // to allow empty value which is not zero - return true; - } - return Validator.isNumeric(value); - }, - maxValue: (value, maxValue) => value < maxValue, - minValue: (value, minValue) => value >= minValue, - alphanumeric: value => Validator.isAlphanumeric(value), - alphanumericWithSpaces: value => Validator.isAlphanumeric(value.replace(/ /g, '')), - validateName: value => Validator.isAlphanumeric(value.replace(/\s|\.|\_|\-/g, ''), 'en-US'), - validateVendorName: value => Validator.isAlphanumeric(value.replace(/[\x7F-\xFF]|\s/g, ''), 'en-US'), - freeEnglishText: value => Validator.isAlphanumeric(value.replace(/\s|\.|\_|\-|\,|\(|\)|\?/g, ''), 'en-US'), - email: value => Validator.isEmail(value), - ip: value => Validator.isIP(value), - url: value => Validator.isURL(value) -}; - -const globalValidationMessagingFunctions = { - required: () => 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}), - pattern: (value, pattern) => i18n('Field value should match the pattern: {pattern}.', {pattern}), - numeric: () => i18n('Field value should contain numbers only.'), - maxValue: (value, maxValue) => i18n('Field value should be less than: {maxValue}.', {maxValue}), - minValue: (value, minValue) => i18n('Field value should be at least: {minValue}.', {minValue}), - 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.') -}; - -class ValidationInput extends React.Component { - - static contextTypes = { - validationParent: React.PropTypes.any, - isReadOnlyMode: React.PropTypes.bool, - validationSchema: React.PropTypes.instanceOf(JSONSchema), - validationData: React.PropTypes.object - }; - - static defaultProps = { - onChange: null, - disabled: null, - didUpdateCallback: null, - validations: {}, - value: '' - }; - - static propTypes = { - type: React.PropTypes.string.isRequired, - onChange: React.PropTypes.func, - disabled: React.PropTypes.bool, - didUpdateCallback: React.PropTypes.func, - validations: React.PropTypes.object, - isMultiSelect: React.PropTypes.bool, - onOtherChange: React.PropTypes.func, - pointer: React.PropTypes.string - }; - - - state = { - isValid: true, - style: null, - value: this.props.value, - error: {}, - previousErrorMessage: '', - wasInvalid: false, - validations: this.props.validations, - isMultiSelect: this.props.isMultiSelect - }; - - componentWillMount() { - if (this.context.validationSchema) { - let {validationSchema: schema, validationData: data} = this.context, - {pointer} = this.props; - - if (!schema.exists(pointer)) { - console.error(`Field doesn't exists in the schema ${pointer}`); - } - - let value = JSONPointer.getValue(data, pointer); - if (value === undefined) { - value = schema.getDefault(pointer); - if (value === undefined) { - value = ''; - } - } - this.setState({value}); - - let enums = schema.getEnum(pointer); - if (enums) { - let values = enums.map(value => ({enum: value, title: value, groupName: pointer})), - isMultiSelect = schema.isArray(pointer); - - if (!isMultiSelect && this.props.type !== 'radiogroup') { - values = [{enum: '', title: i18n('Select...')}, ...values]; - } - if (isMultiSelect && Array.isArray(value) && value.length === 0) { - value = ''; - } - - this.setState({ - isMultiSelect, - values, - onEnumChange: value => this.changedInputOptions(value), - value - }); - } - - this.setState({validations: this.extractValidationsFromSchema(schema, pointer, this.props)}); - } - } - - extractValidationsFromSchema(schema, pointer, props) { - /* props are here to get precedence over the scheme definitions */ - let validations = {}; - - if (schema.isRequired(pointer)) { - validations.required = true; - } - - if (schema.isNumber(pointer)) { - validations.numeric = true; - - const maxValue = props.validations.maxValue || schema.getMaxValue(pointer); - if (maxValue !== undefined) { - validations.maxValue = maxValue; - } - - const minValue = props.validations.minValue || schema.getMinValue(pointer); - if (minValue !== undefined) { - validations.minValue = minValue; - } - } - - - if (schema.isString(pointer)) { - - const pattern = schema.getPattern(pointer); - if (pattern) { - validations.pattern = pattern; - } - - const maxLength = schema.getMaxLength(pointer); - if (maxLength !== undefined) { - validations.maxLength = maxLength; - } - - const minLength = schema.getMinLength(pointer); - if (minLength !== undefined) { - validations.minLength = minLength; - } - } - - return validations; - } - - componentWillReceiveProps({value: nextValue, validations: nextValidations, pointer: nextPointer}, nextContext) { - const {validations, value} = this.props; - const validationsChanged = !isEqual(validations, nextValidations); - if (nextContext.validationSchema) { - if (this.props.pointer !== nextPointer || - this.context.validationData !== nextContext.validationData) { - let currentValue = JSONPointer.getValue(this.context.validationData, this.props.pointer), - nextValue = JSONPointer.getValue(nextContext.validationData, nextPointer); - if(nextValue === undefined) { - nextValue = ''; - } - if (this.state.isMultiSelect && Array.isArray(nextValue) && nextValue.length === 0) { - nextValue = ''; - } - if (currentValue !== nextValue) { - this.setState({value: nextValue}); - } - if (validationsChanged) { - this.setState({ - validations: this.extractValidationsFromSchema(nextContext.validationSchema, nextPointer, {validations: nextValidations}) - }); - } - } - } else { - if (validationsChanged) { - this.setState({validations: nextValidations}); - } - if (this.state.wasInvalid && (value !== nextValue || validationsChanged)) { - this.validate(nextValue, nextValidations); - } else if (value !== nextValue) { - this.setState({value: nextValue}); - } - } - } - - shouldTypeBeNumberBySchemeDefinition(pointer) { - return this.context.validationSchema && - this.context.validationSchema.isNumber(pointer); - } - - hasEnum(pointer) { - return this.context.validationSchema && - this.context.validationSchema.getEnum(pointer); - } - - render() { - let {value, isMultiSelect, values, onEnumChange, style, isValid, validations} = this.state; - let {onOtherChange, type, pointer} = this.props; - if (this.shouldTypeBeNumberBySchemeDefinition(pointer) && !this.hasEnum(pointer)) { - type = 'number'; - } - let props = {...this.props}; - - let groupClasses = this.props.groupClassName || ''; - if (validations.required) { - groupClasses += ' required'; - } - let isReadOnlyMode = this.context.isReadOnlyMode; - - if (value === true && (type === 'checkbox' || type === 'radio')) { - props.checked = true; - } - return ( -
    - { - !isMultiSelect && !onOtherChange && type !== 'select' && type !== 'radiogroup' - && this.changedInput()} - onBlur={() => this.blurInput()}> - {this.props.children} - - } - { - type === 'radiogroup' - && - { - values.map(val => - this.changedInput()}/> - ) - } - - } - { - (isMultiSelect || onOtherChange || type === 'select') - && this.changedInput()} - onBlur={() => this.blurInput()} - hasError={!isValid} - ref={'_myInput'} - isMultiSelect={isMultiSelect} - values={values} - onEnumChange={onEnumChange} - selectedEnum={value} - multiSelectedEnum={value} - {...props} /> - } - {this.renderOverlay()} -
    - ); - } - - renderOverlay() { - let position = 'right'; - if (this.props.type === 'text' - || this.props.type === 'email' - || this.props.type === 'number' - || this.props.type === 'password' - - ) { - position = 'bottom'; - } - - let validationMessage = this.state.error.message || this.state.previousErrorMessage; - return ( - { - let target = ReactDOM.findDOMNode(this.refs._myInput); - return target.offsetParent ? target : undefined; - }} - container={this}> - - {validationMessage} - - - ); - } - - componentDidMount() { - if (this.context.validationParent) { - this.context.validationParent.register(this); - } - } - - componentDidUpdate(prevProps, prevState) { - if (this.context.validationParent) { - if (prevState.isValid !== this.state.isValid) { - this.context.validationParent.childValidStateChanged(this, this.state.isValid); - } - } - if (this.props.didUpdateCallback) { - this.props.didUpdateCallback(); - } - - } - - componentWillUnmount() { - if (this.context.validationParent) { - this.context.validationParent.unregister(this); - } - } - - isNumberInputElement() { - return this.props.type === 'number' || this.refs._myInput.props.type === 'number'; - } - - /*** - * Adding same method as the actual input component - * @returns {*} - */ - getValue() { - if (this.props.type === 'checkbox') { - return this.refs._myInput.getChecked(); - } - if (this.props.type === 'radiogroup') { - for (let key in this.refs) { // finding the value of the radio button that was checked - if (this.refs[key].getChecked()) { - return this.refs[key].getValue(); - } - } - } - if (this.isNumberInputElement()) { - return Number(this.refs._myInput.getValue()); - } - - return this.refs._myInput.getValue(); - } - - resetValue() { - this.setState({value: this.props.value}); - } - - - /*** - * internal method that validated the value. includes callback to the onChange method - * @param value - * @param validations - map containing validation id and the limitation describing the validation. - * @returns {object} - */ - validateValue = (value, validations) => { - let {customValidationFunction} = validations; - let error = {}; - let isValid = true; - for (let validation in validations) { - if ('customValidationFunction' !== validation) { - if (validations[validation]) { - if (!globalValidationFunctions[validation](value, validations[validation])) { - error.id = validation; - error.message = globalValidationMessagingFunctions[validation](value, validations[validation]); - isValid = false; - break; - } - } - } else { - let customValidationResult = customValidationFunction(value); - - if (customValidationResult !== true) { - error.id = 'custom'; - isValid = false; - if (typeof customValidationResult === 'string') {//custom validation error message supplied. - error.message = customValidationResult; - } else { - error.message = globalValidationMessagingFunctions.general(); - } - break; - } - - - } - } - - return { - isValid, - error - }; - }; - - /*** - * Internal method that handles the change event of the input. validates and updates the state. - */ - changedInput() { - - let {isValid, error} = this.state.wasInvalid ? this.validate() : this.state; - let onChange = this.props.onChange; - if (onChange) { - onChange(this.getValue(), isValid, error); - } - if (this.context.validationSchema) { - let value = this.getValue(); - if (this.state.isMultiSelect && value === '') { - value = []; - } - if (this.shouldTypeBeNumberBySchemeDefinition(this.props.pointer)) { - value = Number(value); - } - this.context.validationParent.onValueChanged(this.props.pointer, value, isValid, error); - } - } - - changedInputOptions(value) { - this.context.validationParent.onValueChanged(this.props.pointer, value, true); - } - - blurInput() { - if (!this.state.wasInvalid) { - this.setState({wasInvalid: true}); - } - - let {isValid, error} = !this.state.wasInvalid ? this.validate() : this.state; - let onBlur = this.props.onBlur; - if (onBlur) { - onBlur(this.getValue(), isValid, error); - } - } - - validate(value = this.getValue(), validations = this.state.validations) { - let validationStatus = this.validateValue(value, validations); - let {isValid, error} = validationStatus; - let _style = isValid ? null : 'error'; - this.setState({ - isValid, - error, - value, - previousErrorMessage: this.state.error.message || '', - style: _style, - wasInvalid: !isValid || this.state.wasInvalid - }); - - return validationStatus; - } - - isValid() { - return this.state.isValid; - } - -} -export default ValidationInput; diff --git a/openecomp-ui/src/nfvo-components/input/validation/ValidationTab.jsx b/openecomp-ui/src/nfvo-components/input/validation/ValidationTab.jsx deleted file mode 100644 index 6036518288..0000000000 --- a/openecomp-ui/src/nfvo-components/input/validation/ValidationTab.jsx +++ /dev/null @@ -1,107 +0,0 @@ -import React from 'react'; -import Tab from 'react-bootstrap/lib/Tab.js'; - -export default -class ValidationTab extends React.Component { - - static propTypes = { - children: React.PropTypes.node, - eventKey: React.PropTypes.any.isRequired, - onValidationStateChange: React.PropTypes.func //This property is assigned dynamically via React.cloneElement. lookup ValidationTabs.jsx. therefore it cannot be stated as required! - }; - - constructor(props) { - super(props); - this.validationComponents = []; - } - - static childContextTypes = { - validationParent: React.PropTypes.any - }; - - static contextTypes = { - validationParent: React.PropTypes.any - }; - - getChildContext() { - return {validationParent: this}; - } - - state = { - isValid: true, - notifyParent: false - }; - - componentDidMount() { - let validationParent = this.context.validationParent; - if (validationParent) { - validationParent.register(this); - } - } - - componentWillUnmount() { - let validationParent = this.context.validationParent; - if (validationParent) { - validationParent.unregister(this); - } - } - - register(validationComponent) { - this.validationComponents.push(validationComponent); - } - - unregister(validationComponent) { - this.childValidStateChanged(validationComponent, true); - this.validationComponents = this.validationComponents.filter(otherValidationComponent => validationComponent !== otherValidationComponent); - } - - notifyValidStateChangedToParent(isValid) { - - let validationParent = this.context.validationParent; - if (validationParent) { - validationParent.childValidStateChanged(this, isValid); - } - } - - childValidStateChanged(validationComponent, isValid) { - - const currentValidState = this.state.isValid; - if (isValid !== currentValidState) { - let filteredValidationComponents = this.validationComponents.filter(otherValidationComponent => validationComponent !== otherValidationComponent); - let newValidState = isValid && filteredValidationComponents.every(otherValidationComponent => { - return otherValidationComponent.isValid(); - }); - this.setState({isValid: newValidState, notifyParent: true}); - } - } - - validate() { - let isValid = true; - this.validationComponents.forEach(validationComponent => { - const isValidationComponentValid = validationComponent.validate().isValid; - isValid = isValidationComponentValid && isValid; - }); - this.setState({isValid, notifyParent: false}); - return {isValid}; - } - - componentDidUpdate(prevProps, prevState) { - if(prevState.isValid !== this.state.isValid) { - if(this.state.notifyParent) { - this.notifyValidStateChangedToParent(this.state.isValid); - } - this.props.onValidationStateChange(this.props.eventKey, this.state.isValid); - } - } - - isValid() { - return this.state.isValid; - } - - render() { - let {children, ...tabProps} = this.props; - return ( - {children} - ); - } -} diff --git a/openecomp-ui/src/nfvo-components/input/validation/ValidationTabs.jsx b/openecomp-ui/src/nfvo-components/input/validation/ValidationTabs.jsx deleted file mode 100644 index 6eda4b9827..0000000000 --- a/openecomp-ui/src/nfvo-components/input/validation/ValidationTabs.jsx +++ /dev/null @@ -1,72 +0,0 @@ -import React from 'react'; -import ReactDOM from 'react-dom'; -import Tabs from 'react-bootstrap/lib/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 ValidationTab extends React.Component { - - static propTypes = { - children: React.PropTypes.node - }; - - state = { - invalidTabs: [] - }; - - cloneTab(element) { - const {invalidTabs} = this.state; - return React.cloneElement( - element, - { - key: element.props.eventKey, - tabClassName: invalidTabs.indexOf(element.props.eventKey) > -1 ? 'invalid-tab' : 'valid-tab', - onValidationStateChange: (eventKey, isValid) => this.validTabStateChanged(eventKey, isValid) - } - ); - } - - validTabStateChanged(eventKey, isValid) { - let {invalidTabs} = this.state; - let invalidTabIndex = invalidTabs.indexOf(eventKey); - if (isValid && invalidTabIndex > -1) { - this.setState({invalidTabs: invalidTabs.filter(otherEventKey => eventKey !== otherEventKey)}); - } else if (!isValid && invalidTabIndex === -1) { - this.setState({invalidTabs: [...invalidTabs, eventKey]}); - } - } - - showTabsError() { - const {invalidTabs} = this.state; - return invalidTabs.length > 0 && (invalidTabs.length > 1 || invalidTabs[0] !== this.props.activeKey); - } - - render() { - return ( -
    - - {this.props.children.map(element => this.cloneTab(element))} - - { - let target = ReactDOM.findDOMNode(this.refs.tabsList).querySelector('ul > li.invalid-tab:not(.active):nth-of-type(n)'); - return target && target.offsetParent ? target : undefined; - } - } - container={this}> - - {i18n('One or more tabs are invalid')} - - -
    - ); - } -} diff --git a/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemView.jsx b/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemView.jsx index e8d0fc2536..f6c906b56b 100644 --- a/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemView.jsx +++ b/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemView.jsx @@ -1,7 +1,24 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; -import FontAwesome from 'react-fontawesome'; +import classnames from 'classnames'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; import store from 'sdc-app/AppStore.js'; -import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js'; +import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; class ListEditorItem extends React.Component { static propTypes = { @@ -16,14 +33,14 @@ class ListEditorItem extends React.Component { let {onDelete, onSelect, onEdit, children, isReadOnlyMode} = this.props; let isAbilityToDelete = isReadOnlyMode === undefined ? true : !isReadOnlyMode; return ( -
    +
    {children}
    -
    - {onEdit && this.onClickedItem(onEdit)}/>} - {onDelete && isAbilityToDelete && this.onClickedItem(onDelete)}/>} -
    + {(onEdit || onDelete) &&
    + {onEdit && this.onClickedItem(onEdit)}/>} + {onDelete && isAbilityToDelete && this.onClickedItem(onDelete)}/>} +
    }
    ); } @@ -33,8 +50,11 @@ class ListEditorItem extends React.Component { let {isCheckedOut} = this.props; if (isCheckedOut === false) { store.dispatch({ - type: NotificationConstants.NOTIFY_ERROR, - data: {title: 'Error', msg: 'This item is checkedin/submitted, Click Check Out to continue'} + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: i18n('Error'), + msg: i18n('This item is checkedin/submitted, Click Check Out to continue') + } }); } else { diff --git a/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemViewField.jsx b/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemViewField.jsx new file mode 100644 index 0000000000..839f9a504a --- /dev/null +++ b/openecomp-ui/src/nfvo-components/listEditor/ListEditorItemViewField.jsx @@ -0,0 +1,24 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; + +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 1ee91f31f6..cc805e9ada 100644 --- a/openecomp-ui/src/nfvo-components/listEditor/ListEditorView.jsx +++ b/openecomp-ui/src/nfvo-components/listEditor/ListEditorView.jsx @@ -1,12 +1,63 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; -import FontAwesome from 'react-fontawesome'; -import Input from 'react-bootstrap/lib/Input.js'; +import classnames from 'classnames'; +import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx'; +const ListEditorHeader = ({onAdd, isReadOnlyMode, title, plusButtonTitle}) => { + return ( +
    + {title &&
    {title}
    } +
    + { onAdd && +
    + {`+ ${plusButtonTitle}`} +
    + } +
    +
    + ); +}; + +const ListEditorScroller = ({children, twoColumns}) => { + return ( +
    +
    + {children} +
    +
    + ); +}; + +const FilterWrapper = ({onFilter, filterValue}) => { + return ( +
    + +
    + ); +}; class ListEditorView extends React.Component { static defaultProps = { - className: '' + className: '', + twoColumns: false }; static propTypes = { @@ -17,45 +68,17 @@ class ListEditorView extends React.Component { onFilter: React.PropTypes.func, className: React.PropTypes.string, isReadOnlyMode: React.PropTypes.bool, - placeholder: React.PropTypes.string + placeholder: React.PropTypes.string, + twoColumns: React.PropTypes.bool }; render() { - let {title, plusButtonTitle, onAdd, children, filterValue, onFilter, className, placeholder, isReadOnlyMode} = this.props; + let {title, plusButtonTitle, onAdd, children, onFilter, className, isReadOnlyMode, twoColumns, filterValue} = this.props; return ( -
    - {title && onAdd &&
    {title}
    } -
    - {title && !onAdd &&
    {title}
    } -
    - { onAdd && -
    - - {plusButtonTitle} -
    - } -
    - - { - onFilter && -
    - onFilter(this.refs.filter.getValue())}/> - -
    - } -
    -
    -
    - {children} -
    -
    +
    + + {onFilter && (children.length || filterValue) && } +
    ); } diff --git a/openecomp-ui/src/nfvo-components/listEditor/listEditor.stories.js b/openecomp-ui/src/nfvo-components/listEditor/listEditor.stories.js new file mode 100644 index 0000000000..276b05e270 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/listEditor/listEditor.stories.js @@ -0,0 +1,60 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import ListEditorView from './ListEditorView.jsx'; +import ListEditorItemView from './ListEditorItemView.jsx'; +import ListEditorItemViewField from './ListEditorItemViewField.jsx'; +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')}
    +
    +
    ) + ) + ); +} + +const stories = storiesOf('ListEditor', module); +stories.addDecorator(withKnobs); + +stories + .add('regular', () => ( + + {makeChildren()} + + )) + .add('two columns', () => ( + + {makeChildren()} + + )) + .add('with add', () => ( + + {makeChildren()} + + )) + .add('with delete', () => ( + + {makeChildren({onDelete: action('onDelete')})} + + )) + .add('with edit', () => ( + + {makeChildren({onEdit: action('onEdit')})} + + )) + .add('with edit and delete', () => ( + + {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 cc1ffdb2b3..675b04c8ea 100644 --- a/openecomp-ui/src/nfvo-components/loader/Loader.jsx +++ b/openecomp-ui/src/nfvo-components/loader/Loader.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import {connect} from 'react-redux'; diff --git a/openecomp-ui/src/nfvo-components/loader/LoaderConstants.js b/openecomp-ui/src/nfvo-components/loader/LoaderConstants.js index e8e4953eb9..7c0c0e2b08 100644 --- a/openecomp-ui/src/nfvo-components/loader/LoaderConstants.js +++ b/openecomp-ui/src/nfvo-components/loader/LoaderConstants.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ diff --git a/openecomp-ui/src/nfvo-components/loader/LoaderReducer.js b/openecomp-ui/src/nfvo-components/loader/LoaderReducer.js index 582eff330d..2eff70a617 100644 --- a/openecomp-ui/src/nfvo-components/loader/LoaderReducer.js +++ b/openecomp-ui/src/nfvo-components/loader/LoaderReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './LoaderConstants.js'; export default (state = {}, action) => { diff --git a/openecomp-ui/src/nfvo-components/modal/GlobalModal.js b/openecomp-ui/src/nfvo-components/modal/GlobalModal.js new file mode 100644 index 0000000000..65a1ad683b --- /dev/null +++ b/openecomp-ui/src/nfvo-components/modal/GlobalModal.js @@ -0,0 +1,120 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import {connect} from 'react-redux'; + +import Modal from 'nfvo-components/modal/Modal.jsx'; +import Button from 'react-bootstrap/lib/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'; + + +const typeClass = { + 'default': 'primary', + error: 'danger', + warning: 'warning', + success: 'success' +}; + + +const ModalFooter = ({type, onConfirmed, onDeclined, onClose, confirmationButtonText, cancelButtonText}) => + + + {onConfirmed && } + ; + +ModalFooter.defaultProps = { + type: 'default', + confirmationButtonText: i18n('OK'), + cancelButtonText: i18n('Cancel') +}; + +export const mapStateToProps = ({modal}) => { + const show = !!modal; + return { + show, + ...modal + }; +}; + +export const mapActionToProps = (dispatch) => { + return { + onClose: () => dispatch({type: actionTypes.GLOBAL_MODAL_CLOSE}) + }; +}; + + +export class GlobalModalView extends React.Component { + + static propTypes = { + show: React.PropTypes.bool, + type: React.PropTypes.oneOf(['default', 'error', 'warning', 'success']), + title: React.PropTypes.string, + modalComponentProps: React.PropTypes.object, + modalComponentName: React.PropTypes.string, + onConfirmed: React.PropTypes.func, + onDeclined: React.PropTypes.func, + confirmationButtonText: React.PropTypes.string, + cancelButtonText: React.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} + + {(onConfirmed || onDeclined || type !== typeEnum.DEFAULT) && + } + + ); + } + + componentDidUpdate() { + if (this.props.timeout) { + setTimeout(this.props.onClose, this.props.timeout); + } + } +}; + +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 new file mode 100644 index 0000000000..0a0ed1fd71 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/modal/GlobalModalConstants.js @@ -0,0 +1,33 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 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, + +}); + + +export const typeEnum = { + DEFAULT: 'default', + ERROR: 'error', + WARNING: 'warning', + SUCCESS: 'success' +}; diff --git a/openecomp-ui/src/nfvo-components/modal/GlobalModalReducer.js b/openecomp-ui/src/nfvo-components/modal/GlobalModalReducer.js new file mode 100644 index 0000000000..28674ea569 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/modal/GlobalModalReducer.js @@ -0,0 +1,50 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {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 + }; + + case actionTypes.GLOBAL_MODAL_SUCCESS: + return { + type: typeEnum.SUCCESS, + modalClassName: 'notification-modal', + ...action.data + }; + + 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 be4963ef65..b0f704dba9 100644 --- a/openecomp-ui/src/nfvo-components/modal/Modal.jsx +++ b/openecomp-ui/src/nfvo-components/modal/Modal.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import ReactDOM from 'react-dom'; import BootstrapModal from 'react-bootstrap/lib/Modal.js'; diff --git a/openecomp-ui/src/nfvo-components/notifications/NotificationConstants.js b/openecomp-ui/src/nfvo-components/notifications/NotificationConstants.js deleted file mode 100644 index 1a53f4c135..0000000000 --- a/openecomp-ui/src/nfvo-components/notifications/NotificationConstants.js +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import keyMirror from 'nfvo-utils/KeyMirror.js'; - -export default keyMirror({ - NOTIFY_ERROR: null, - NOTIFY_SUCCESS: null, - NOTIFY_WARNING: null, - NOTIFY_INFO: null, - NOTIFY_CLOSE: null -}); diff --git a/openecomp-ui/src/nfvo-components/notifications/NotificationModal.jsx b/openecomp-ui/src/nfvo-components/notifications/NotificationModal.jsx deleted file mode 100644 index 71793097fb..0000000000 --- a/openecomp-ui/src/nfvo-components/notifications/NotificationModal.jsx +++ /dev/null @@ -1,100 +0,0 @@ -/** - * NotificationModal options: - * - * show: whether to show notification or not, - * type: the type of the notification. valid values are: 'default', 'error', 'warning', 'success' - * msg: the notification content. could be a string or node (React component) - * title: the notification title - * timeout: timeout for the notification to fade out. if timeout == 0 then the notification is rendered until the user closes it - * - */ -import React, {Component, PropTypes} from 'react'; -import {connect} from 'react-redux'; -import Button from 'react-bootstrap/lib/Button.js'; - -import i18n from 'nfvo-utils/i18n/i18n.js'; -import Modal from 'nfvo-components/modal/Modal.jsx'; -import SubmitErrorResponse from 'nfvo-components/SubmitErrorResponse.jsx'; -import NotificationConstants from './NotificationConstants.js'; - -let typeClass = { - 'default': 'primary', - error: 'danger', - warning: 'warning', - success: 'success' -}; - -const mapActionsToProps = (dispatch) => { - return {onCloseClick: () => dispatch({type: NotificationConstants.NOTIFY_CLOSE})}; -}; - -const mapStateToProps = ({notification}) => { - - let show = notification !== null && notification.title !== 'Conflict'; - let mapResult = {show}; - if (show) { - mapResult = {show, ...notification}; - } - - return mapResult; -}; - -export class NotificationModal extends Component { - - static propTypes = { - show: PropTypes.bool, - type: PropTypes.oneOf(['default', 'error', 'warning', 'success']), - title: PropTypes.string, - msg: PropTypes.node, - validationResponse: PropTypes.object, - timeout: PropTypes.number - }; - - static defaultProps = { - show: false, - type: 'default', - title: '', - msg: '', - timeout: 0 - }; - - state = {type: undefined}; - - componentWillReceiveProps(nextProps) { - if (this.props.show !== nextProps.show && nextProps.show === false) { - this.setState({type: this.props.type}); - } - else { - this.setState({type: undefined}); - } - } - - componentDidUpdate() { - if (this.props.timeout) { - setTimeout(this.props.onCloseClick, this.props.timeout); - } - } - - render() { - let {title, type, msg, show, validationResponse, onCloseClick} = this.props; - if (!show) { - type = this.state.type; - } - if (validationResponse) { - msg = (); - } - return ( - - - {title} - - {msg} - - - - - ); - } -} - -export default connect(mapStateToProps, mapActionsToProps)(NotificationModal); diff --git a/openecomp-ui/src/nfvo-components/notifications/NotificationReducer.js b/openecomp-ui/src/nfvo-components/notifications/NotificationReducer.js deleted file mode 100644 index c8b30d6e50..0000000000 --- a/openecomp-ui/src/nfvo-components/notifications/NotificationReducer.js +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import NotificationConstants from './NotificationConstants.js'; - -export default (state = null, action) => { - switch (action.type) { - case NotificationConstants.NOTIFY_INFO: - return {type: 'default', title: action.data.title, msg: action.data.msg, timeout: action.data.timeout}; - - case NotificationConstants.NOTIFY_ERROR: - return { - type: 'error', - title: action.data.title, - msg: action.data.msg, - validationResponse: action.data.validationResponse, - timeout: action.data.timeout - }; - - case NotificationConstants.NOTIFY_WARNING: - return {type: 'warning', title: action.data.title, msg: action.data.msg, timeout: action.data.timeout}; - - case NotificationConstants.NOTIFY_SUCCESS: - return { - type: 'success', title: action.data.title, msg: action.data.msg, timeout: action.data.timeout - }; - case NotificationConstants.NOTIFY_CLOSE: - return null; - - default: - return state; - } - -}; diff --git a/openecomp-ui/src/nfvo-components/panel/NavigationSideBar.jsx b/openecomp-ui/src/nfvo-components/panel/NavigationSideBar.jsx index feb0f813ea..3b89137090 100644 --- a/openecomp-ui/src/nfvo-components/panel/NavigationSideBar.jsx +++ b/openecomp-ui/src/nfvo-components/panel/NavigationSideBar.jsx @@ -1,9 +1,23 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import classnames from 'classnames'; import Collapse from 'react-bootstrap/lib/Collapse.js'; class NavigationSideBar extends React.Component { - static PropTypes = { activeItemId: React.PropTypes.string.isRequired, onSelect: React.PropTypes.func, @@ -11,51 +25,26 @@ class NavigationSideBar extends React.Component { groups: React.PropTypes.array }; + constructor(props) { + super(props); + this.state = { + activeItemId: null + }; + this.handleItemClicked = this.handleItemClicked.bind(this); + } + render() { let {groups, activeItemId} = this.props; return (
    {groups.map(group => ( -
    -
    {group.name}
    -
    - { - group.items && group.items.map(item => this.renderGroupItem(item, activeItemId)) - } -
    -
    + ))}
    ); } - renderGroupItem(item, activeItemId) { - let isGroup = item.items && item.items.length > 0; - return ( -
    -
    this.handleItemClicked(event, item)}> - {item.name} -
    - {isGroup && - -
    - {item.items.map(item => this.renderGroupItem(item, activeItemId))} -
    -
    - } -
    - ); - } - handleItemClicked(event, item) { event.stopPropagation(); if(this.props.onToggle) { @@ -70,4 +59,70 @@ class NavigationSideBar extends React.Component { } } +class NavigationMenu extends React.Component { + static PropTypes = { + activeItemId: React.PropTypes.string.isRequired, + onNavigationItemClick: React.PropTypes.func, + menu: React.PropTypes.array + }; + + render() { + const {menu, activeItemId, onNavigationItemClick} = this.props; + return ( +
    + + +
    ); + } +} + +function NavigationMenuHeader(props) { + return
    {props.title}
    ; +} + +function NavigationMenuItems(props) { + 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 => ()) } +
    +
    + } +
    + ); +} + +function NavigationLink(props) { + const {item, activeItemId, onClick} = props; + return ( +
    onClick(event, item)} + data-test-id={'navbar-group-item-' + item.id}> + {item.name} +
    + ); +} + export default NavigationSideBar; diff --git a/openecomp-ui/src/nfvo-components/panel/SlidePanel.jsx b/openecomp-ui/src/nfvo-components/panel/SlidePanel.jsx deleted file mode 100644 index 10c5326300..0000000000 --- a/openecomp-ui/src/nfvo-components/panel/SlidePanel.jsx +++ /dev/null @@ -1,109 +0,0 @@ -import React from 'react'; -import FontAwesome from 'react-fontawesome'; -import ReactDOM from 'react-dom'; - -class SlidePanel extends React.Component { - - static PropTypes = { - direction: React.PropTypes.string.isRequired, - className: React.PropTypes.string, - title: React.PropTypes.string, - isOpen: React.PropTypes.bool - }; - - static defaultProps = { - title: '', - className: '', - isOpen: true - }; - - state = { - isOpen: this.props.isOpen, - direction: this.props.direction, - width: 0, - arrowWidth: 0 - }; - - componentDidMount() { - this.setSliderPosition(); - } - - componentDidUpdate() { - this.setSliderPosition(); - } - - render() { - - let {children, className} = this.props; - let {isOpen} = this.state; - - return ( -
    - {this.renderHeader(isOpen)} -
    {children}
    -
    - ); - } - - renderHeader(isOpen) { - let {direction: initialDirection, title} = this.props; - let {direction: currentDirection} = this.state; - - let iconName = currentDirection === 'right' ? 'angle-double-right collapse-double-icon' : 'angle-double-left collapse-double-icon'; - - let awestyle = {padding: '5px'}; - - if (!isOpen && initialDirection === 'right') { - awestyle.marginLeft = '-1px'; - } - return ( -
    - { initialDirection === 'left' && {title}} - - { initialDirection === 'right' && {title}} -
    - ); - } - - handleClick = () => { - this.setState({ - isOpen: !this.state.isOpen, - direction: this.state.direction === 'left' ? 'right' : 'left' - }); - } - - setSliderPosition = () => { - - let el = ReactDOM.findDOMNode(this); - let {style} = el; - - let {direction: initialDirection} = this.props; - let arrowIconSize = Math.floor(ReactDOM.findDOMNode(this.refs.arrowIcon).getBoundingClientRect().width) * 2; - if (!this.state.isOpen) { - if (this.props.direction === 'left') { - style.left = arrowIconSize - el.getBoundingClientRect().width + 'px'; - } - if (initialDirection === 'right') { - style.right = arrowIconSize - el.getBoundingClientRect().width + 'px'; - } - } - else { - if (initialDirection === 'left') { - style.left = '0px'; - } - - if (this.props.direction === 'right') { - style.right = '0px'; - } - } - } - -} - -export default SlidePanel; \ No newline at end of file diff --git a/openecomp-ui/src/nfvo-components/panel/versionController/VersionController.jsx b/openecomp-ui/src/nfvo-components/panel/versionController/VersionController.jsx index 78525f84c6..6d900dd0bb 100644 --- a/openecomp-ui/src/nfvo-components/panel/versionController/VersionController.jsx +++ b/openecomp-ui/src/nfvo-components/panel/versionController/VersionController.jsx @@ -1,17 +1,31 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; -import classnames from 'classnames'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import Navbar from 'react-bootstrap/lib/Navbar.js'; -import Nav from 'react-bootstrap/lib/Nav.js'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; -import {actionsEnum, statusEnum} from './VersionControllerConstants.js'; +import {actionsEnum, statusEnum, statusBarTextMap } from './VersionControllerConstants.js'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import Tooltip from 'react-bootstrap/lib/Tooltip.js'; +import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; class VersionController extends React.Component { static propTypes = { - version: React.PropTypes.string, + version: React.PropTypes.object, viewableVersions: React.PropTypes.array, onVersionSwitching: React.PropTypes.func, isCheckedOut: React.PropTypes.bool.isRequired, @@ -23,143 +37,146 @@ class VersionController extends React.Component { }; render() { - let {status, isCheckedOut, version = '', viewableVersions = [], onVersionSwitching, callVCAction, onSave, isFormDataValid, onClose} = this.props; + let {status, isCheckedOut, version = {}, viewableVersions = [], onVersionSwitching, callVCAction, onSave, isFormDataValid, onClose} = this.props; let isCheckedIn = Boolean(status === statusEnum.CHECK_IN_STATUS); - let isLatestVersion = Boolean(version === viewableVersions[viewableVersions.length - 1]); + let isLatestVersion = Boolean(version.id === viewableVersions[viewableVersions.length - 1].id); if (!isLatestVersion) { status = statusEnum.PREVIOUS_VERSION; } - return (
    - - - - - - +
    +
    + + +
    +
    + this.submit(callVCAction, version) : undefined} + onRevert={callVCAction ? () => this.revertCheckout(callVCAction, version) : undefined} + status={status} + onCheckinCheckout={callVCAction ? () => this.checkinCheckoutVersion(callVCAction, version) : undefined} + onSave={onSave ? () => onSave() : undefined} + isLatestVersion={isLatestVersion} + isCheckedOut={isCheckedOut} + isCheckedIn={isCheckedIn} isFormDataValid={isFormDataValid} version={version}/> + {onClose &&
    onClose()} data-test-id='vc-cancel-btn'> X
    } +
    +
    ); } - renderStatus(status) { - switch (status) { - case statusEnum.CHECK_OUT_STATUS: - return ( -
    -
    -
    {i18n('CHECKED OUT')}
    -
    - ); - case statusEnum.LOCK_STATUS: - return ( -
    {i18n('LOCKED')}
    - ); - case statusEnum.CHECK_IN_STATUS: - return ( -
    {i18n('CHECKED IN')}
    - ); - case statusEnum.SUBMIT_STATUS: - return ( -
    {i18n('SUBMITTED')}
    - ); - default: - return ( -
    {i18n(status)}
    - ); - } + submit(callVCAction, version) { + const action = actionsEnum.SUBMIT; + callVCAction(action, version); + } + + revertCheckout(callVCAction, version) { + const action = actionsEnum.UNDO_CHECK_OUT; + callVCAction(action, version); } - checkinCheckoutVersion(callVCAction) { + checkinCheckoutVersion(callVCAction, version) { if (this.props.isCheckedOut) { - this.checkin(callVCAction); + this.checkin(callVCAction, version); } else { - this.checkout(callVCAction); + this.checkout(callVCAction, version); } } - - checkin(callVCAction) { - + checkin(callVCAction, version) { const action = actionsEnum.CHECK_IN; - if (this.props.onSave) { this.props.onSave().then(()=>{ - callVCAction(action); - }); + callVCAction(action, version); + }); }else{ - callVCAction(action); + callVCAction(action, version); } } - - checkout(callVCAction) { + checkout(callVCAction, version) { const action = actionsEnum.CHECK_OUT; - callVCAction(action); + callVCAction(action, version); } +} - submit(callVCAction) { - const action = actionsEnum.SUBMIT; - callVCAction(action); +class ActionButtons extends React.Component { + static propTypes = { + version: React.PropTypes.object, + onSubmit: React.PropTypes.func, + onRevert: React.PropTypes.func, + onSave: React.PropTypes.func, + isLatestVersion: React.PropTypes.bool, + isCheckedIn: React.PropTypes.bool, + isCheckedOut: React.PropTypes.bool, + isFormDataValid: React.PropTypes.bool + }; + render() { + const {onSubmit, onRevert, onSave, isLatestVersion, isCheckedIn, isCheckedOut, isFormDataValid, version, status, onCheckinCheckout} = this.props; + const [checkinBtnIconSvg, checkinCheckoutBtnTitle] = status === statusEnum.CHECK_OUT_STATUS ? + ['version-controller-lock-open', i18n('Check In')] : + ['version-controller-lock-closed', i18n('Check Out')]; + const disabled = (isLatestVersion && onCheckinCheckout && status !== statusEnum.LOCK_STATUS) ? false : true; + return ( +
    + + {onSubmit && onRevert && +
    + + +
    + } + {onSave && + onSave()} isDisabled={!isCheckedOut || !isFormDataValid || !isLatestVersion} + name='version-controller-save' tooltipText={i18n('Save')}/> + } +
    + ); } +} - revertCheckout(callVCAction) { - const action = actionsEnum.UNDO_CHECK_OUT; - callVCAction(action); - } +function StatusBarUpdates({status}) { + return ( +
    + {i18n(statusBarTextMap[status])} +
    + ); +} + +function VCButton({name, tooltipText, isDisabled, onClick, dataTestId}) { + let onClickAction = isDisabled ? ()=>{} : onClick; + let disabled = isDisabled ? 'disabled' : ''; + + return ( + {tooltipText}}> +
    + +
    +
    + ); +} + +function VersionSelector(props) { + let {version = {}, viewableVersions = [], onVersionSwitching} = props; + const includedVersions = viewableVersions.filter(ver => {return ver.id === version.id;}); + return (
    + +
    ); } 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 9251fd12c4..9af142433c 100644 --- a/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerConstants.js +++ b/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerConstants.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionsEnum = keyMirror({ @@ -36,3 +31,11 @@ export const statusEnum = keyMirror({ PREVIOUS_VERSION: 'READ ONLY' }); +export const statusBarTextMap = keyMirror({ + 'Locked': 'Checked Out', + 'LockedByUser': '', + 'Available': 'Checked In', + 'Final': 'Submitted', + 'READ ONLY': 'Locked' +}); + diff --git a/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerUtils.js b/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerUtils.js index de9914454c..e8c12abec3 100644 --- a/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerUtils.js +++ b/openecomp-ui/src/nfvo-components/panel/versionController/VersionControllerUtils.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 Configuration from 'sdc-app/config/Configuration.js'; import {statusEnum} from './VersionControllerConstants.js'; @@ -25,24 +20,32 @@ import {statusEnum} from './VersionControllerConstants.js'; const VersionControllerUtils = { getCheckOutStatusKindByUserID(status, lockingUser) { - let currentLoginUserID = Configuration.get('ATTUserID'); - let isCheckedOut = currentLoginUserID === lockingUser; + let returnStatus; + let isCheckedOut; + let currentLoginUserID = Configuration.get('UserID'); + if (lockingUser) { + isCheckedOut = currentLoginUserID === lockingUser; + returnStatus = isCheckedOut ? status : statusEnum.LOCK_STATUS; + } else { + isCheckedOut = false; + returnStatus = status; + } return { - status: isCheckedOut ? status : statusEnum.LOCK_STATUS, + status: returnStatus, isCheckedOut }; }, isCheckedOutByCurrentUser(resource) { - let currentLoginUserID = Configuration.get('ATTUserID'); + let currentLoginUserID = Configuration.get('UserID'); return resource.lockingUser !== undefined && resource.lockingUser === currentLoginUserID; }, isReadOnly(resource) { const {version, viewableVersions = []} = resource; const latestVersion = viewableVersions[viewableVersions.length - 1]; - return version !== latestVersion || !VersionControllerUtils.isCheckedOutByCurrentUser(resource); + return version.id !== latestVersion.id || !VersionControllerUtils.isCheckedOutByCurrentUser(resource); } }; diff --git a/openecomp-ui/src/nfvo-components/progressBar/ProgressBar.jsx b/openecomp-ui/src/nfvo-components/progressBar/ProgressBar.jsx index d786aeef8b..40720c39f4 100644 --- a/openecomp-ui/src/nfvo-components/progressBar/ProgressBar.jsx +++ b/openecomp-ui/src/nfvo-components/progressBar/ProgressBar.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; class ProgressBar extends React.Component { diff --git a/openecomp-ui/src/nfvo-components/table/SelectActionTable.jsx b/openecomp-ui/src/nfvo-components/table/SelectActionTable.jsx new file mode 100644 index 0000000000..06cb98bbe8 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/table/SelectActionTable.jsx @@ -0,0 +1,29 @@ +import React from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import uuid from 'uuid-js'; + +export default class SelectActionTable extends React.Component { + + render() { + let {columns, onAdd, isReadOnlyMode, children, onAddItem} = this.props; + return ( +
    +
    + {onAdd && onAddItem &&
    {onAddItem}
    } + +
    +
    +
    + {columns.map(column =>
    {i18n(column)}
    )} + + +
    +
    + {children} +
    +
    +
    + ); + } +} diff --git a/openecomp-ui/src/nfvo-components/table/SelectActionTableCell.jsx b/openecomp-ui/src/nfvo-components/table/SelectActionTableCell.jsx new file mode 100644 index 0000000000..2664c8e944 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/table/SelectActionTableCell.jsx @@ -0,0 +1,20 @@ +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} /> +
    + ); +}; + +export default SelectActionTableCell; diff --git a/openecomp-ui/src/nfvo-components/table/SelectActionTableRow.jsx b/openecomp-ui/src/nfvo-components/table/SelectActionTableRow.jsx new file mode 100644 index 0000000000..17d8a17c09 --- /dev/null +++ b/openecomp-ui/src/nfvo-components/table/SelectActionTableRow.jsx @@ -0,0 +1,30 @@ +import React from 'react'; +import SVGIcon from '../icon/SVGIcon.jsx'; +import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; +import Tooltip from 'react-bootstrap/lib/Tooltip.js'; + +function tooltip (msg) { + return ( + {msg} + ); +}; + +const IconWithOverlay = ({overlayMsg}) => ( + + + +); + +const SelectActionTableRow = ({children, onDelete, hasError, overlayMsg}) => ( +
    +
    + {children} +
    + {onDelete ? : } + {hasError ? overlayMsg ? : + : hasError === undefined ? : } + +
    +); + +export default SelectActionTableRow; diff --git a/openecomp-ui/src/nfvo-utils/DirectedGraph.js b/openecomp-ui/src/nfvo-utils/DirectedGraph.js new file mode 100644 index 0000000000..197625a013 --- /dev/null +++ b/openecomp-ui/src/nfvo-utils/DirectedGraph.js @@ -0,0 +1,45 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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. + */ + +export default class Graph { + constructor() { + this.nodes = {}; + } + + addNode(node) { + this.nodes[node] = []; + } + + hasNode(node) { + return this.nodes.hasOwnProperty(node); + } + + addEdge(firstNode, secondNode, payload) { + if (!this.hasNode(firstNode)) { + this.addNode(firstNode); + } + + if (!this.hasNode(secondNode)) { + this.addNode(secondNode); + } + + this.nodes[firstNode].push({...payload, target: secondNode}); + } + + getEdges(node) { + return this.nodes[node]; + } +} \ No newline at end of file diff --git a/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js b/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js index 0d27204bef..d58a2454b6 100644 --- a/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js +++ b/openecomp-ui/src/nfvo-utils/ErrorResponseHandler.js @@ -1,25 +1,23 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 store from 'sdc-app/AppStore.js'; -import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js'; +import React from 'react'; +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; @@ -45,6 +43,10 @@ function parseATTExceptionObject(responseJSON) { msg = showVariablesInMessage(variables, msg); } } + else if (responseJSON.uploadDataErrors) { + title = i18n('Error: Upload Data Error'); + msg = (); + } else { title = responseJSON.status; msg = responseJSON.message; @@ -60,12 +62,14 @@ var errorResponseHandler = (xhr/*, textStatus, errorThrown*/) => { else { errorData = { title: xhr.statusText, - msg: xhr.responseText + msg: xhr.responseText, }; } store.dispatch({ - type: NotificationConstants.NOTIFY_ERROR, - data: {...errorData} + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + ...errorData + } }); }; diff --git a/openecomp-ui/src/nfvo-utils/KeyMirror.js b/openecomp-ui/src/nfvo-utils/KeyMirror.js index eb50d31e07..220fe07430 100644 --- a/openecomp-ui/src/nfvo-utils/KeyMirror.js +++ b/openecomp-ui/src/nfvo-utils/KeyMirror.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ - var keyMirror = function (obj) { var ret = {}; var key; @@ -41,4 +36,4 @@ var keyMirror = function (obj) { return Object.freeze(ret); }; -export default keyMirror; +export default keyMirror; \ No newline at end of file diff --git a/openecomp-ui/src/nfvo-utils/RestAPIUtil.js b/openecomp-ui/src/nfvo-utils/RestAPIUtil.js index 24734739a2..c878c9e673 100644 --- a/openecomp-ui/src/nfvo-utils/RestAPIUtil.js +++ b/openecomp-ui/src/nfvo-utils/RestAPIUtil.js @@ -1,27 +1,19 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 + * 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. - * ============LICENSE_END========================================================= + * 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 _extend from 'lodash/extend.js'; -import _clone from 'lodash/clone.js'; -import _defaults from 'lodash/defaults.js'; -import $ from 'jquery'; +import {RestfulAPI} from 'restful-js'; import uuid from 'uuid-js'; import md5 from 'md5'; @@ -30,30 +22,81 @@ import {actionTypes as LoaderConstants} from 'nfvo-components/loader/LoaderConst import Configuration from 'sdc-app/config/Configuration.js'; import errorResponseHandler from './ErrorResponseHandler.js'; -const methodMap = { - 'create': 'POST', - 'update': 'PUT', - 'delete': 'DELETE', - 'read': 'GET' -}; const AUTHORIZATION_HEADER = 'X-AUTH-TOKEN'; const STORAGE_AUTH_KEY = 'sdc-auth-token'; const REQUEST_ID_HEADER = 'X-ECOMP-RequestID'; const CONTENT_MD5_HEADER = 'Content-MD5'; -const namedParam = /{(\w+)}/g; -const queryParamsNames = { - pageStart: 'pageStart', - pageSize: 'pageSize', - sortField: 'sortField', - sortDir: 'sortDir', - filtering: 'filter' -}; + + +function applyMD5Header(options, data) { + if (options.md5) { + let headers = options.headers; + headers[CONTENT_MD5_HEADER] = window.btoa(md5(JSON.stringify(data)).toLowerCase()); + } +} + +function handleResponse(xhr) { + let authToken = xhr.getResponseHeader(AUTHORIZATION_HEADER); + let prevToken = this && this.headers && this.headers[AUTHORIZATION_HEADER]; + if (authToken && authToken !== prevToken) { + if (authToken === 'null') { + localStorage.removeItem(STORAGE_AUTH_KEY); + } else { + localStorage.setItem(STORAGE_AUTH_KEY, authToken); + } + } +} + + +class RestAPIUtil extends RestfulAPI { + + applySecurity(options, data) { + let headers = options.headers || (options.headers = {}); + + let authToken = localStorage.getItem(STORAGE_AUTH_KEY); + if (authToken) { + headers[AUTHORIZATION_HEADER] = authToken; + } + + let attApiHeaders = Configuration.get('ATTApiHeaders'), + attUidHeader = attApiHeaders && attApiHeaders.userId; + if (attUidHeader) { + headers[attUidHeader.name] = attUidHeader.value; + } + + headers[REQUEST_ID_HEADER] = uuid.create().toString(); + applyMD5Header(options, data); + } + + handleRequest(url, type, options = {}, data){ + let success = options.success; + options.success = function (resp, textStatus, xhr) { + handleResponse.call(this, xhr); + if (success) { + success.call(options.context, {...resp}, textStatus, xhr); + } + }; + + if (DEBUG) { + console.log('--> Making REST call (' + type + '): ' + url); + } + return super.handleRequest(url, type, options, data); + } + +} + +const instance = new RestAPIUtil({ + errorResponseHandler, + ajaxStartHandler: () => store.dispatch({type: LoaderConstants.SHOW}), + ajaxStopHandler: () => store.dispatch({type: LoaderConstants.HIDE}) +}); + // jQuery binary transport to download files through XHR // http://www.henryalgus.com/reading-binary-files-using-jquery-ajax/ // https://github.com/henrya/js-jquery/tree/master/BinaryTransport -$.ajaxTransport('+binary', function (options/*, originalOptions , jqXHR*/) { +instance.$.ajaxTransport('+binary', function (options/*, originalOptions , jqXHR*/) { // check for conditions and support for blob / arraybuffer response type if (window.FormData && ((options.dataType && (options.dataType === 'binary')) || (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) || @@ -62,19 +105,19 @@ $.ajaxTransport('+binary', function (options/*, originalOptions , jqXHR*/) { return { // create new XMLHttpRequest send: function (headers, callback) { - // setup all variables - var xhr = new XMLHttpRequest(), + // setup all letiables + let xhr = new XMLHttpRequest(), url = options.url, type = options.type, async = options.async || true, - // blob or arraybuffer. Default is blob + // blob or arraybuffer. Default is blob dataType = options.responseType || 'blob', data = options.data || null, username = options.username || null, password = options.password || null; xhr.addEventListener('load', function () { - var data = {}; + let data = {}; data[options.dataType] = xhr.response; // make callback and send data callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders()); @@ -83,7 +126,7 @@ $.ajaxTransport('+binary', function (options/*, originalOptions , jqXHR*/) { xhr.open(type, url, async, username, password); // setup custom headers - for (var i in headers) { + for (let i in headers) { xhr.setRequestHeader(i, headers[i]); } @@ -96,193 +139,4 @@ $.ajaxTransport('+binary', function (options/*, originalOptions , jqXHR*/) { } }); -$(document).ajaxStart(()=> store.dispatch({type: LoaderConstants.SHOW})); -$(document).ajaxStop(()=> store.dispatch({type: LoaderConstants.HIDE})); - -function urlError() { - throw new Error('A "url" property or function must be specified'); -}; - -export function makeQueryParams(options) { - var qParams = {}; - if (options.pagination) { - qParams[queryParamsNames.pageStart] = options.pagination.pageStart; - qParams[queryParamsNames.pageSize] = options.pagination.pageSize; - } - if (options.sorting) { - qParams[queryParamsNames.sortField] = options.sorting.sortField; - qParams[queryParamsNames.sortDir] = options.sorting.sortDir; - } - if (options.filtering) { - qParams[queryParamsNames.filtering] = JSON.stringify(options.filtering); - } - - return _defaults(qParams, options.qParams); -} - -function appendQueryParam(p, value) { - var str = ''; - - if (value instanceof Array) { - if (value.length === 1) { - str = appendQueryParam(p, value[0]); - } else if (value.length > 1) { - str = appendQueryParam(p, value.shift()) + '&' + appendQueryParam(p, value); - } - } else { - str = p + '=' + encodeURIComponent(value); - } - - return str; -} - -function appendQueryString(url, qParams) { - var str = ''; - for (var param in qParams) { - str += (str ? '&' : '') + appendQueryParam(param, qParams[param]); - } - return url + (str ? '?' : '') + str; -} - -function composeURL(baseUrl, options) { - var url = baseUrl || urlError(); - if (options.url) { - delete options.url; - } - - var qParams = makeQueryParams(options); - url = appendQueryString(url, qParams); - - var matches = url.match(namedParam); - if (matches) { - for (var i = 0; i < matches.length; i++) { - var param = matches[i].substring(1, matches[i].length - 1); - var value = (options.params && options.params[param]); - - if (value === undefined) { - value = options[param]; - } - url = url.replace(matches[i], encodeURIComponent(value)); - } - } - - return url; -} - -function applyMD5Header(options, data) { - if (options.md5) { - let headers = options.headers; - headers[CONTENT_MD5_HEADER] = window.btoa(md5(JSON.stringify(data)).toLowerCase()); - } -} - -function applySecurity(options, data) { - var headers = options.headers || (options.headers = {}); - - var authToken = localStorage.getItem(STORAGE_AUTH_KEY); - if (authToken) { - headers[AUTHORIZATION_HEADER] = authToken; - } - - var attApiHeaders = Configuration.get('ATTApiHeaders'), - attUidHeader = attApiHeaders && attApiHeaders.userId; - if (attUidHeader) { - headers[attUidHeader.name] = attUidHeader.value; - } - - headers[REQUEST_ID_HEADER] = uuid.create().toString(); - - applyMD5Header(options, data); -} - -function handleResponse(options) { - var authToken = options.xhr.getResponseHeader(AUTHORIZATION_HEADER); - var prevToken = options.headers && options.headers[AUTHORIZATION_HEADER]; - if (authToken && authToken !== prevToken) { - if (authToken === 'null') { - localStorage.removeItem(STORAGE_AUTH_KEY); - } else { - localStorage.setItem(STORAGE_AUTH_KEY, authToken); - } - } -} - -function sync(baseUrl, method, options, data) { - - options = options ? _clone(options) : {}; - - var type = methodMap[method]; - _defaults(options || (options = {})); - var params = { - type: type, - dataType: 'json' - }; - params.url = composeURL(baseUrl, options); - - if ((method === 'create' || method === 'update') && data instanceof FormData) { - params.contentType = 'multipart/form-data'; - params.data = data; - } - else if (method === 'create' || method === 'update') { - params.contentType = 'application/json'; - params.data = JSON.stringify(data); - } - - if (params.type !== 'GET') { - params.processData = false; - } - var success = options.success; - options.success = function (resp) { - if (success) { - handleResponse(options); - success.call(options.context, _clone(resp), resp, options); - } - }; - - options.error = options.error || errorResponseHandler; - - if (typeof options.progressCallback === 'function' && options.fileSize) { - const {fileSize} = options; - options.xhrFields = { - // add listener to XMLHTTPRequest object directly for progress (jquery doesn't have this yet) - onprogress: function (progress) { - // calculate upload progress - let percentage = Math.floor((progress.loaded / fileSize) * 100); - // log upload progress to console - //console.log('progress', percentage); - options.progressCallback(percentage); - if (percentage === 100) { - console.log('DONE!'); - } - } - }; - } - - applySecurity(options, data); - - if (DEBUG) { - console.log('--> Making REST call (' + type + '): ' + params.url); - } - var xhr = options.xhr = $.ajax(_extend(params, options)); - return xhr; -} - -export default { - - fetch(baseUrl, options) { - return sync(baseUrl, 'read', options); - }, - - save(baseUrl, data, options) { - return sync(baseUrl, 'update', options, data); - }, - - create(baseUrl, data, options) { - return sync(baseUrl, 'create', options, data); - }, - - destroy(baseUrl, options) { - return sync(baseUrl, 'delete', options); - } - -}; +export default instance; diff --git a/openecomp-ui/src/nfvo-utils/UUID.js b/openecomp-ui/src/nfvo-utils/UUID.js index 314c98ba6f..e1d4c54b1f 100644 --- a/openecomp-ui/src/nfvo-utils/UUID.js +++ b/openecomp-ui/src/nfvo-utils/UUID.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 UUID from 'uuid-js'; let toCustomUUID = (uuid) => { diff --git a/openecomp-ui/src/nfvo-utils/Validator.js b/openecomp-ui/src/nfvo-utils/Validator.js new file mode 100644 index 0000000000..708179e9fb --- /dev/null +++ b/openecomp-ui/src/nfvo-utils/Validator.js @@ -0,0 +1,110 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 * as ValidatorJS from 'validator'; +import i18n from 'nfvo-utils/i18n/i18n.js'; + +class Validator { + static get globalValidationFunctions() { + return { + required: 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) => value <= maxValue, + minimum: (value, minValue) => value >= minValue, + maximumExclusive: (value, maxValue) => value < maxValue, + minimumExclusive: (value, minValue) => 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) + }; + } + + static get globalValidationMessagingFunctions() { + return { + required: () => 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}), + pattern: (value, pattern) => i18n('Field value should match the 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}), + 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}), + 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.') + }; + } + + 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 isItemNameAlreadyExistsInList({itemId, itemName, list}) { + return list[itemName] && list[itemName] !== itemId; + } +} + +export default Validator; diff --git a/openecomp-ui/src/nfvo-utils/i18n/i18n.js b/openecomp-ui/src/nfvo-utils/i18n/i18n.js index 64587713b7..4d03ddb8dd 100644 --- a/openecomp-ui/src/nfvo-utils/i18n/i18n.js +++ b/openecomp-ui/src/nfvo-utils/i18n/i18n.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 IntlObj from 'intl'; import IntlMessageFormatObj from 'intl-messageformat'; import IntlRelativeFormatObj from 'intl-relativeformat'; diff --git a/openecomp-ui/src/nfvo-utils/json/JSONPointer.js b/openecomp-ui/src/nfvo-utils/json/JSONPointer.js index a6e8198537..f4c0d4ed59 100644 --- a/openecomp-ui/src/nfvo-utils/json/JSONPointer.js +++ b/openecomp-ui/src/nfvo-utils/json/JSONPointer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ - const JSONPointer = { extractParentPointer(pointer) { @@ -29,7 +24,7 @@ const JSONPointer = { return lastPart; }, - extractParts(pointer) { + extractParts(pointer = '') { return pointer.split('/').slice(1) .map(part => part.replace(/~1/g, '/')) .map(part => part.replace(/~0/g, '~')); diff --git a/openecomp-ui/src/nfvo-utils/json/JSONSchema.js b/openecomp-ui/src/nfvo-utils/json/JSONSchema.js index 8c7d8cf9aa..3b3a9bf7b4 100644 --- a/openecomp-ui/src/nfvo-utils/json/JSONSchema.js +++ b/openecomp-ui/src/nfvo-utils/json/JSONSchema.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 Ajv from 'ajv'; import cloneDeep from 'lodash/cloneDeep.js'; import JSONPointer from './JSONPointer.js'; @@ -40,6 +35,108 @@ export default class JSONSchema { 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; } @@ -73,12 +170,12 @@ export default class JSONSchema { getMaxValue(pointer) { const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.maximum; + return fragment && fragment.exclusiveMaximum ? fragment.maximum - 1 : fragment.maximum; } getMinValue(pointer) { const fragment = this._getSchemaFragment(pointer); - return fragment && fragment.minimum; + return fragment && fragment.exclusiveMinimum ? fragment.minimum : fragment.minimum; } isString(pointer) { diff --git a/openecomp-ui/src/nfvo-utils/sortByStringProperty.js b/openecomp-ui/src/nfvo-utils/sortByStringProperty.js new file mode 100644 index 0000000000..b415dd7e07 --- /dev/null +++ b/openecomp-ui/src/nfvo-utils/sortByStringProperty.js @@ -0,0 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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. + */ +export default function sortByStringProperty(array, property) { + 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 0abcaac3fe..9157c340a3 100644 --- a/openecomp-ui/src/sdc-app/AppStore.js +++ b/openecomp-ui/src/sdc-app/AppStore.js @@ -1,46 +1,41 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {combineReducers, createStore} from 'redux'; +import {combineReducers, createStore, applyMiddleware, compose} from 'redux'; import onBoardingReducersMap from './onboarding/OnboardingReducersMap.js'; import flowsReducersMap from './flows/FlowsReducersMap.js'; -import notificationReducer from 'nfvo-components/notifications/NotificationReducer.js'; import loaderReducer from 'nfvo-components/loader/LoaderReducer.js'; -import uploadScreenReducer from 'sdc-app/heatvalidation/UploadScreenReducer.js'; -import SoftwareProductAttachmentsReducer from 'sdc-app/heatvalidation/attachments/AttachmentsReducer'; +import globalModalReducer from 'nfvo-components/modal/GlobalModalReducer.js'; +const thunk = store => 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(combineReducers({ // on-boarding reducers ...onBoardingReducersMap, // flows reducers ...flowsReducersMap, - - // heat validation stand-alone app - uploadScreen: combineReducers({ - upload: uploadScreenReducer, - attachments: SoftwareProductAttachmentsReducer - }), - notification: notificationReducer, + modal: globalModalReducer, loader: loaderReducer -}), initialState, window.devToolsExtension ? window.devToolsExtension() : undefined); +}), initialState, composeEnhancers(applyMiddleware(thunk))); + const store = storeCreator(); diff --git a/openecomp-ui/src/sdc-app/Application.jsx b/openecomp-ui/src/sdc-app/Application.jsx index 5cb385b61c..10e866a602 100644 --- a/openecomp-ui/src/sdc-app/Application.jsx +++ b/openecomp-ui/src/sdc-app/Application.jsx @@ -1,6 +1,21 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import {Provider} from 'react-redux'; -import NotificationModal from 'nfvo-components/notifications/NotificationModal.jsx'; +import GlobalModal from 'nfvo-components/modal/GlobalModal.js'; import Loader from 'nfvo-components/loader/Loader.jsx'; import store from './AppStore.js'; @@ -10,7 +25,7 @@ class Application extends React.Component { return (
    - + {this.props.children}
    diff --git a/openecomp-ui/src/sdc-app/ModulesOptions.jsx b/openecomp-ui/src/sdc-app/ModulesOptions.jsx index 4f66e579d1..61d19d9e7a 100644 --- a/openecomp-ui/src/sdc-app/ModulesOptions.jsx +++ b/openecomp-ui/src/sdc-app/ModulesOptions.jsx @@ -1,6 +1,21 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import {connect} from 'react-redux'; -import Input from 'react-bootstrap/lib/Input.js'; +import Input from 'nfvo-components/input/validation/InputWrapper.jsx'; import LicenseModelActionHelper from './onboarding/licenseModel/LicenseModelActionHelper.js'; import LicenseAgreementListEditor from './onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js'; @@ -13,7 +28,7 @@ import EntitlementPoolsListEditor from './onboarding/licenseModel/entitlementPoo 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 OnboardingCatalog from './onboarding/OnboardingCatalog.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'; @@ -125,7 +140,7 @@ class ModuleOptions extends React.Component { return ; case 'OnboardingCatalog': this.props.onOnboardingCatalog(); - return ; + return ; case 'Flows': this.props.onFlowsListEditor(); return ; diff --git a/openecomp-ui/src/sdc-app/Test.jsx b/openecomp-ui/src/sdc-app/Test.jsx deleted file mode 100644 index dd45e39eca..0000000000 --- a/openecomp-ui/src/sdc-app/Test.jsx +++ /dev/null @@ -1,122 +0,0 @@ -import React from 'react'; -import Tabs from 'react-bootstrap/lib/Tabs.js'; -import Tab from 'react-bootstrap/lib/Tab.js'; -import Button from 'react-bootstrap/lib/Button.js'; -import ButtonGroup from 'react-bootstrap/lib/ButtonGroup.js'; -import DropdownButton from 'react-bootstrap/lib/DropdownButton.js'; -import MenuItem from 'react-bootstrap/lib/MenuItem.js'; - -import Modal from 'nfvo-components/modal/Modal.jsx'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; -import ToggleInput from 'nfvo-components/input/ToggleInput.jsx'; - -export default class Test extends React.Component { - - render() { - return ( -
    - - Tab 1 content - Tab 2 content - Tab 3 content - -
    - - - - - - - - - - - - - -
    - - - - - -
    - - Action - Another action - Active Item - - Separated link - - -
    - - - Modal title - - - - One fine body... - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    - ); - } - - doSomething(a) { - if (a) { - this.doSomething2(); - } - else { - return 1; - } - } - - doSomething2() { - return 2; - } -} diff --git a/openecomp-ui/src/sdc-app/common/helpers/ValidationHelper.js b/openecomp-ui/src/sdc-app/common/helpers/ValidationHelper.js new file mode 100644 index 0000000000..51dfcf9a67 --- /dev/null +++ b/openecomp-ui/src/sdc-app/common/helpers/ValidationHelper.js @@ -0,0 +1,91 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {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 validateForm(dispatch, formName){ + dispatch({ + type: commonActionTypes.VALIDATE_FORM, + formName + }); + } + + 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 qValidateForm(dispatch, qName){ + dispatch({ + type: qcommonActionTypes.VALIDATE_FORM, + qName + }); + } + + 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 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/modal/ModalContentMapper.js b/openecomp-ui/src/sdc-app/common/modal/ModalContentMapper.js new file mode 100644 index 0000000000..548e0cfc9c --- /dev/null +++ b/openecomp-ui/src/sdc-app/common/modal/ModalContentMapper.js @@ -0,0 +1,31 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 SoftwareProductCreation from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js'; +import LicenseModelCreation from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js'; +import SubmitErrorResponse from 'nfvo-components/SubmitErrorResponse.jsx'; + +export const modalContentMapper = { + SOFTWARE_PRODUCT_CREATION: 'SOFTWARE_PRODUCT_CREATION', + LICENSE_MODEL_CREATION: 'LICENSE_MODEL_CREATION', + SUMBIT_ERROR_RESPONSE: 'SUMBIT_ERROR_RESPONSE' +}; + +export const modalContentComponents = { + SUMBIT_ERROR_RESPONSE: SubmitErrorResponse, + SOFTWARE_PRODUCT_CREATION: SoftwareProductCreation, + LICENSE_MODEL_CREATION: LicenseModelCreation, +}; \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js new file mode 100644 index 0000000000..35b2f936ce --- /dev/null +++ b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducer.js @@ -0,0 +1,145 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {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; + } +} + +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.data[key] ? state.data[key] : ''; + let result = Validator.validate(key, val, state.qgenericFieldInfo[key].validations, state, {}); + 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); + } + }; +}; + + + + + + + diff --git a/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js new file mode 100644 index 0000000000..6007b878dd --- /dev/null +++ b/openecomp-ui/src/sdc-app/common/reducers/JSONSchemaReducerConstants.js @@ -0,0 +1,23 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; + +export const actionTypes = keyMirror({ + 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 new file mode 100644 index 0000000000..0bbb5e63be --- /dev/null +++ b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducer.js @@ -0,0 +1,94 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {actionTypes} from './PlainDataReducerConstants.js'; +import Validator from 'nfvo-utils/Validator.js'; +import forOwn from 'lodash/forOwn.js'; + +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, {}); + 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); + } + }; +}; + + + + + + diff --git a/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js new file mode 100644 index 0000000000..135361dd20 --- /dev/null +++ b/openecomp-ui/src/sdc-app/common/reducers/PlainDataReducerConstants.js @@ -0,0 +1,22 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; + +export const actionTypes = keyMirror({ + 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 4bbe07864f..227e36995b 100644 --- a/openecomp-ui/src/sdc-app/config/Configuration.js +++ b/openecomp-ui/src/sdc-app/config/Configuration.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 + * 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. - * ============LICENSE_END========================================================= + * 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 configData from './config.json'; class Configuration { @@ -43,19 +38,17 @@ class Configuration { setATTApiHeaders(ATTApiHeaders) { this.set('ATTApiHeaders', ATTApiHeaders); - let {userId: {value: ATTUserID} = {}} = ATTApiHeaders; - this.set('ATTUserID', ATTUserID); + let {userId: {value: UserID} = {}} = ATTApiHeaders; + this.set('UserID', UserID); } - } const configuration = new Configuration(); (function setDefaultRestPrefixes(configuration) { - configuration.set('restPrefix', configuration.get('defaultRestPrefix')); configuration.set('restATTPrefix', configuration.get('defaultRestATTPrefix')); - + configuration.set('appContextPath', configuration.get('appContextPath')); })(configuration); diff --git a/openecomp-ui/src/sdc-app/config/config.json b/openecomp-ui/src/sdc-app/config/config.json index 4127e0c12e..2725cf1310 100644 --- a/openecomp-ui/src/sdc-app/config/config.json +++ b/openecomp-ui/src/sdc-app/config/config.json @@ -2,7 +2,7 @@ "pageSize": 25, "version": "9.4", "build": "dev", - + "appContextPath" : "/onboarding", "defaultRestPrefix": "/onboarding-api", "defaultRestATTPrefix": "/sdc1/feProxy/rest" } diff --git a/openecomp-ui/src/sdc-app/flows/FlowsActions.js b/openecomp-ui/src/sdc-app/flows/FlowsActions.js index b8772edb08..5a751064df 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsActions.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsActions.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes, enums} from './FlowsConstants.js'; @@ -59,7 +54,8 @@ function decodeContent(base64Contents) { sequenceDiagramModel = payload.data || payload; sequenceDiagramModel = sequenceDiagramModel.model || sequenceDiagramModel; - } else if (payload.VERSION.major === 1) { + } + else if (payload.VERSION.major === 1) { description = payload.description; sequenceDiagramModel = payload.sequenceDiagramModel; } @@ -80,7 +76,7 @@ function createOrUpdate(flowData) { description: flowData.description }; - return RestAPIUtil.create( + return RestAPIUtil.post( baseUrl(flowData.serviceID, flowData.uniqueId), createOrUpdateRequest, {md5: true} @@ -89,11 +85,13 @@ function createOrUpdate(flowData) { const FlowsActions = Object.freeze({ - fetchFlowArtifacts(dispatch, {artifacts, diagramType, participants, serviceID}) { + fetchFlowArtifacts(dispatch, {artifacts, diagramType, participants, serviceID, readonly}) { let results = []; if (!Object.keys(artifacts).length) { - dispatch({type: actionTypes.FLOW_LIST_LOADED, results, participants, serviceID, diagramType}); - FlowsActions.openFlowDetailsEditor(dispatch); + dispatch({type: actionTypes.FLOW_LIST_LOADED, results, participants, serviceID, diagramType, readonly}); + if (!readonly) { + FlowsActions.openFlowDetailsEditor(dispatch); + } } else { Object.keys(artifacts).forEach(artifact => results.push({ @@ -102,13 +100,13 @@ const FlowsActions = Object.freeze({ serviceID, ...artifacts[artifact] })); - dispatch({type: actionTypes.FLOW_LIST_LOADED, results, participants, serviceID, diagramType}); + dispatch({type: actionTypes.FLOW_LIST_LOADED, results, participants, serviceID, diagramType, readonly}); } }, fetchArtifact(dispatch, {flow}){ let {serviceID, uniqueId, participants} = flow; - RestAPIUtil.fetch(baseUrl(serviceID, uniqueId)).then(response => { + return RestAPIUtil.fetch(baseUrl(serviceID, uniqueId)).then(response => { let {artifactName, base64Contents} = response; let {sequenceDiagramModel, ...other} = decodeContent(base64Contents); @@ -146,7 +144,7 @@ const FlowsActions = Object.freeze({ name: flow.artifactName }); } - createOrUpdate(flow).then(response => { + return createOrUpdate(flow).then(response => { let {uniqueId, artifactLabel} = response; flow = {...flow, uniqueId, artifactLabel}; if (isNew) { @@ -157,7 +155,7 @@ const FlowsActions = Object.freeze({ }, deleteFlow(dispatch, {flow}) { - RestAPIUtil.destroy(baseUrl(flow.serviceID, flow.uniqueId)).then(() => dispatch({ + return RestAPIUtil.destroy(baseUrl(flow.serviceID, flow.uniqueId)).then(() => dispatch({ type: actionTypes.DELETE_FLOW, flow })); @@ -179,10 +177,6 @@ const FlowsActions = Object.freeze({ dispatch({type: actionTypes.CLOSE_FLOW_DIAGRAM_EDITOR}); }, - flowDetailsDataChanged(dispatch, {deltaData}) { - dispatch({type: actionTypes.CURRENT_FLOW_DATA_CHANGED, deltaData}); - }, - reset(dispatch) { dispatch({type: actionTypes.RESET}); } diff --git a/openecomp-ui/src/sdc-app/flows/FlowsConstants.js b/openecomp-ui/src/sdc-app/flows/FlowsConstants.js index 5a43a4df4f..2b3d86bae2 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsConstants.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsConstants.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ @@ -46,3 +41,5 @@ export const enums = { 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 eff1c36b80..f9585f985f 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsEditorModal.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsEditorModal.js @@ -1,42 +1,43 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 FlowsEditorModalView from './FlowsEditorModalView.jsx'; import FlowsActions from './FlowsActions.js'; +import {FLOWS_EDITOR_FORM} from './FlowsConstants.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; export const mapStateToProps = ({flows}) => { - let {currentFlow = {artifactName: '', description: ''}, serviceID, diagramType, flowParticipants} = flows; - if(!currentFlow.serviceID){ - currentFlow.serviceID = serviceID; + let {data = {artifactName: '', description: ''}, serviceID, diagramType, flowParticipants, genericFieldInfo, formReady} = flows; + if(!data.serviceID){ + data.serviceID = serviceID; } - if(!currentFlow.artifactType){ - currentFlow.artifactType = diagramType; + if(!data.artifactType){ + data.artifactType = diagramType; } - if(!currentFlow.participants){ - currentFlow.participants = flowParticipants; + if(!data.participants){ + data.participants = flowParticipants; } + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); return { - currentFlow + currentFlow: data, + genericFieldInfo, + isFormValid, + formReady }; }; @@ -47,7 +48,8 @@ const mapActionsToProps = (dispatch, {isNewArtifact}) => { FlowsActions.createOrUpdateFlow(dispatch, {flow}, isNewArtifact); }, onCancel: () => FlowsActions.closeFlowDetailsEditor(dispatch), - onDataChanged: deltaData => FlowsActions.flowDetailsDataChanged(dispatch, {deltaData}) + onDataChanged: deltaData => ValidationHelper.dataChanged(dispatch, {deltaData, formName: FLOWS_EDITOR_FORM}), + onValidateForm: () => ValidationHelper.validateForm(dispatch, FLOWS_EDITOR_FORM) }; }; diff --git a/openecomp-ui/src/sdc-app/flows/FlowsEditorModalView.jsx b/openecomp-ui/src/sdc-app/flows/FlowsEditorModalView.jsx index 8441c7d1d6..1250a0b58e 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsEditorModalView.jsx +++ b/openecomp-ui/src/sdc-app/flows/FlowsEditorModalView.jsx @@ -1,30 +1,54 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component} from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import Input from 'nfvo-components/input/validation/ValidationInput.jsx'; -import Form from 'nfvo-components/input/validation/ValidationForm.jsx'; +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} = this.props; + let {onCancel, onDataChanged, currentFlow, genericFieldInfo, formReady, isFormValid, onValidateForm} = this.props; let {artifactName, description} = currentFlow; return ( -
    this.onSaveClicked()} onReset={onCancel}> +
    + {genericFieldInfo && this.onSaveClicked()} + onReset={onCancel} formReady={formReady} isValid={isFormValid} onValidateForm={() => onValidateForm()} > onDataChanged({artifactName})}/> onDataChanged({description})}/> - + } +
    ); } diff --git a/openecomp-ui/src/sdc-app/flows/FlowsListEditor.js b/openecomp-ui/src/sdc-app/flows/FlowsListEditor.js index ff301b6e13..642c578eb7 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsListEditor.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsListEditor.js @@ -1,30 +1,28 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 FlowsActions from './FlowsActions.js'; import FlowsListEditorView from './FlowsListEditorView.jsx'; export const mapStateToProps = ({flows}) => { - let {flowList = [], isDisplayModal, isModalInEditMode, shouldShowWorkflowsEditor = true, currentFlow = undefined} = flows; - let isCheckedOut = currentFlow ? !currentFlow.readonly : true; + let {flowList = [], isDisplayModal, isModalInEditMode, shouldShowWorkflowsEditor = true, data = undefined, readonly} = flows; + let isCheckedOut = !readonly; + if(data && data.readonly){ + isCheckedOut = !data.readonly; + } return { flowList, @@ -32,7 +30,8 @@ export const mapStateToProps = ({flows}) => { isCheckedOut, isModalInEditMode, shouldShowWorkflowsEditor, - currentFlow + currentFlow: data, + readonly }; }; diff --git a/openecomp-ui/src/sdc-app/flows/FlowsListEditorView.jsx b/openecomp-ui/src/sdc-app/flows/FlowsListEditorView.jsx index 3cea3968ff..c5dbb4f909 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/flows/FlowsListEditorView.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {PropTypes, Component} from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; @@ -18,6 +33,7 @@ class FlowsListEditorView extends Component { isModalInEditMode: PropTypes.bool, isCheckedOut: PropTypes.bool, shouldShowWorkflowsEditor: PropTypes.bool, + readonly: PropTypes.bool, onAddWorkflowClick: PropTypes.func, onEditFlowDetailsClick: PropTypes.func, @@ -55,7 +71,7 @@ class FlowsListEditorView extends Component { onAdd={onAddWorkflowClick} filterValue={localFilter} onFilter={filter => this.setState({localFilter: filter})} - isCheckedOut={isCheckedOut}> + isReadOnlyMode={!isCheckedOut}> {this.filterList().map(flow => this.renderWorkflowListItem(flow, isCheckedOut))} @@ -68,7 +84,7 @@ class FlowsListEditorView extends Component { renderWorkflowEditorModal() { let { isDisplayModal, isModalInEditMode} = this.props; return ( - + {`${isModalInEditMode ? i18n('Edit Workflow') : i18n('Create New Workflow')}`} diff --git a/openecomp-ui/src/sdc-app/flows/FlowsListReducer.js b/openecomp-ui/src/sdc-app/flows/FlowsListReducer.js index f025450a58..14bf595050 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsListReducer.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsListReducer.js @@ -1,24 +1,19 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './FlowsConstants.js'; +import {actionTypes, FLOWS_EDITOR_FORM} from './FlowsConstants.js'; export default (state = {}, action) => { switch (action.type) { @@ -28,7 +23,8 @@ export default (state = {}, action) => { flowList: action.results, flowParticipants: action.participants, serviceID: action.serviceID, - diagramType: action.diagramType + diagramType: action.diagramType, + readonly: action.readonly }; case actionTypes.ADD_OR_UPDATE_FLOW: case actionTypes.ARTIFACT_LOADED: @@ -49,14 +45,6 @@ export default (state = {}, action) => { serviceID: action.flow.serviceID, diagramType: action.flow.artifactType || state.diagramType }; - case actionTypes.CURRENT_FLOW_DATA_CHANGED: - return { - ...state, - currentFlow: { - ...state.currentFlow, - ...action.deltaData - } - }; case actionTypes.DELETE_FLOW: return { ...state, @@ -65,7 +53,21 @@ export default (state = {}, action) => { case actionTypes.OPEN_FLOW_DETAILS_EDITOR: return { ...state, - currentFlow: action.flow, + 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) }; @@ -73,20 +75,20 @@ export default (state = {}, action) => { case actionTypes.CLOSE_FLOW_DETAILS_EDITOR: return { ...state, - currentFlow: undefined, + data: undefined, isDisplayModal: false, isModalInEditMode: false }; case actionTypes.OPEN_FLOW_DIAGRAM_EDITOR: return { ...state, - currentFlow: action.flow, + data: action.flow, shouldShowWorkflowsEditor: false }; case actionTypes.CLOSE_FLOW_DIAGRAM_EDITOR: return { ...state, - currentFlow: undefined, + data: undefined, shouldShowWorkflowsEditor: true }; case actionTypes.RESET: diff --git a/openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx b/openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx index 958f9a0a2d..873003492b 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx +++ b/openecomp-ui/src/sdc-app/flows/FlowsPunchOut.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import ReactDOM from 'react-dom'; import Configuration from 'sdc-app/config/Configuration.js'; diff --git a/openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js b/openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js index b3c0b2e27b..54043498f0 100644 --- a/openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js +++ b/openecomp-ui/src/sdc-app/flows/FlowsReducersMap.js @@ -1,25 +1,22 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 flowListReducer from './FlowsListReducer.js'; +import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js'; export default { - flows: 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 c4ab41841b..d0a5bf3251 100644 --- a/openecomp-ui/src/sdc-app/flows/ImportantLogic.jsx +++ b/openecomp-ui/src/sdc-app/flows/ImportantLogic.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component} from 'react'; import md5 from 'md5'; diff --git a/openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx b/openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx index 9970969884..b0bd40db40 100644 --- a/openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx +++ b/openecomp-ui/src/sdc-app/flows/SequenceDiagram.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component, PropTypes} from 'react'; import Button from 'react-bootstrap/lib/Button.js'; import Sequencer from 'dox-sequence-diagram-ui'; @@ -8,7 +23,7 @@ class SequenceDiagram extends Component { static propTypes = { onSave: PropTypes.func.isRequired, - onClose: PropTypes.func.isRequired, + onClose: PropTypes.func, model: PropTypes.object.isRequired }; diff --git a/openecomp-ui/src/sdc-app/flows/SequenceDiagramModelHelper.js b/openecomp-ui/src/sdc-app/flows/SequenceDiagramModelHelper.js index c2e10a6360..c83fdc91f0 100644 --- a/openecomp-ui/src/sdc-app/flows/SequenceDiagramModelHelper.js +++ b/openecomp-ui/src/sdc-app/flows/SequenceDiagramModelHelper.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 emptyModel from './emptyModel.json'; function mergeLifelines(oldLifelines, newLifelines) { diff --git a/openecomp-ui/src/sdc-app/heatValidation.app.jsx b/openecomp-ui/src/sdc-app/heatValidation.app.jsx index eb58a79b25..6ff3c7375c 100644 --- a/openecomp-ui/src/sdc-app/heatValidation.app.jsx +++ b/openecomp-ui/src/sdc-app/heatValidation.app.jsx @@ -1,5 +1,19 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 '../../resources/scss/bootstrap.scss'; -import '../../resources/css/font-awesome.min.css'; import 'react-select/dist/react-select.min.css'; import 'dox-sequence-diagram-ui/src/main/webapp/res/sdc-sequencer.scss'; import '../../resources/scss/style.scss'; diff --git a/openecomp-ui/src/sdc-app/heatvalidation/Attachments.js b/openecomp-ui/src/sdc-app/heatvalidation/Attachments.js new file mode 100644 index 0000000000..d3e30b0df8 --- /dev/null +++ b/openecomp-ui/src/sdc-app/heatvalidation/Attachments.js @@ -0,0 +1,44 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.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 + }; +}; + +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); diff --git a/openecomp-ui/src/sdc-app/heatvalidation/HeatSetup.js b/openecomp-ui/src/sdc-app/heatvalidation/HeatSetup.js new file mode 100644 index 0000000000..925b0095ba --- /dev/null +++ b/openecomp-ui/src/sdc-app/heatvalidation/HeatSetup.js @@ -0,0 +1,28 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 HeatSetupView from '../onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx'; +import UploadScreenActionHelper from './UploadScreenActionHelper.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) + }; +}; + +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 0bb496fc51..2d99c0f497 100644 --- a/openecomp-ui/src/sdc-app/heatvalidation/UploadScreen.jsx +++ b/openecomp-ui/src/sdc-app/heatvalidation/UploadScreen.jsx @@ -1,182 +1,32 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; -import {connect} from 'react-redux'; -import Button from 'react-bootstrap/lib/Button.js'; -import Dropzone from 'react-dropzone'; -import i18n from 'nfvo-utils/i18n/i18n.js'; -import ProgressBar from 'nfvo-components/progressBar/ProgressBar.jsx'; -import Modal from 'nfvo-components/modal/Modal.jsx'; -import UploadScreenActionHelper from './UploadScreenActionHelper.js'; -import Attachments from './attachments/Attachments.js'; +import SoftwareProductAttachmentsView from './Attachments.js'; -const mapStateToProps = ({uploadScreen}) => { - let {upload} = uploadScreen; - return {uploadScreen: upload}; -}; - - -const mapActionsToProps = dispatch => { - return { - onUpload: (formData) => UploadScreenActionHelper.uploadFile(dispatch, formData), - openMainScreen: () => UploadScreenActionHelper.openMainScreen(dispatch) - }; -}; class UploadScreen extends React.Component { - state = { - complete: '10', - showModal: false, - fileName: '', - dragging: false, - files: [] - }; - - interval = ''; - render() { - let {uploadScreen} = this.props; - let {showAttachments} = uploadScreen; return(
    - {showAttachments ? this.renderTree() : this.renderUploadScreen()} -
    - ); - } - - renderUploadModal() { - let {complete, showModal, fileName} = this.state; - return ( - - - {i18n('Uploading attachments')} - - -
    -
    - {i18n('File:')} - {fileName} -
    - -
    {i18n('Upload in progress')}
    -
    - - - - -
    -
    - ); - } - - renderUploadScreen() { - return( -
    -
    -
    -

    HEAT VALIDATION APPLICATION

    -
    -
    -
    -
    - this.handleImportSubmit(files)} - onDragEnter={() => this.setState({dragging:true})} - onDragLeave={() => this.setState({dragging:false})} - multiple={false} - disableClick={true} - ref='fileInput' - name='fileInput' - accept='.zip'> -
    -
    {i18n('Drag & drop for upload')}
    -
    {i18n('or')}
    -
    this.refs.fileInput.open()}> - {i18n('Select file')} -
    -
    -
    -
    - {this.renderUploadModal()} -
    -
    - ); - } - - renderTree() { - let {openMainScreen} = this.props; - return( -
    - -
    -
    openMainScreen()}> - {i18n('Back')} -
    -
    +
    ); } - - handleImportSubmit(files) { - this.setState({ - showModal: true, - fileName: files[0].name, - dragging: false, - complete: '0', - files - }); - - - this.interval = setInterval(() => { - if (this.state.complete >= 90) { - clearInterval(this.interval); - this.setState({ - showModal: false, - fileName: '' - }); - this.startUploading(files); - } else { - this.setState({ - complete: (parseInt(this.state.complete) + 10).toString() - }); - } - }, 20); - - } - - onRunBackground() { - let {files} = this.state; - clearInterval(this.interval); - this.startUploading(files); - this.setState({showModal: false, files: []}); - } - - onCancel() { - clearInterval(this.interval); - this.setState({ - showModal: false, - fileName: '', - files: [] - }); - - } - - startUploading(files) { - let {onUpload} = this.props; - if (!(files && files.length)) { - return; - } - let file = files[0]; - let formData = new FormData(); - formData.append('upload', file); - this.refs.fileInput.value = ''; - onUpload(formData); - } - } -export default connect(mapStateToProps, mapActionsToProps)(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 3b8de0f0d4..4e9120956e 100644 --- a/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenActionHelper.js +++ b/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenActionHelper.js @@ -1,60 +1,204 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; -import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js'; -import {actionTypes} from './UploadScreenConstants.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'; + + + +const options = { + headers: { + HTTP_CSP_ATTUID: 'validationOnlyVspUser' + } +}; + + +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())}`; +} + +function fetchVspId() { + + let vspId = sessionStorage.getItem('validationAppVspId'); + if (vspId) { + return Promise.resolve({value: vspId}); + }else { + return RestAPIUtil.fetch('/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/validation-vsp', options) + .then(response => { + sessionStorage.setItem('validationAppVspId', response.value); + return Promise.resolve(response); + }); + } + +} + + +function showFileSaveDialog({blob, xhr, defaultFilename, addTimestamp}) { + let filename; + let contentDisposition = xhr.getResponseHeader('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`); + } + + 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); +} + function uploadFile(formData) { - return RestAPIUtil.create('/sdc1/feProxy/onboarding-api/v1.0/validation/HEAT/validate', formData); + return fetchVspId() + .then(response => { + return RestAPIUtil.post(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/0.1/orchestration-template-candidate`, formData, options); + }); +} + +function loadSoftwareProductHeatCandidate(dispatch){ + return fetchVspId() + .then(response => { + return RestAPIUtil.fetch(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/0.1/orchestration-template-candidate/manifest`, options) + .then(response => dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response + })); + }); +} + +function updateHeatCandidate(dispatch, heatCandidate) { + return fetchVspId() + .then(response => { + return RestAPIUtil.put(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/0.1/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 fetchVspId() + .then(response => { + return RestAPIUtil.fetch(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/0.1`, options); + }); +} + +function downloadHeatFile() { + return fetchVspId() + .then(response => { + RestAPIUtil.fetch(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/0.1/orchestration-template-candidate`, { + ...options, + dataType: 'binary' + }) + .done((blob, statusText, xhr) => showFileSaveDialog({ + blob, + xhr, + defaultFilename: 'HEAT_file.zip', + addTimestamp: true + })); + }); +} + +function processAndValidateHeatCandidate(dispatch) { + return fetchVspId() + .then(response => { + return RestAPIUtil.put(`/sdc1/feProxy/onboarding-api/v1.0/vendor-software-products/${response.value}/versions/0.1/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) { - - Promise.resolve() + return Promise.resolve() .then(() => uploadFile(formData)) .then(response => { dispatch({ type: softwareProductsActionTypes.SOFTWARE_PRODUCT_LOADED, response }); - dispatch({ - type: actionTypes.OPEN_UPLOAD_SCREEN + type: HeatSetupActions.FILL_HEAT_SETUP_CACHE, + payload:{} }); + loadSoftwareProductHeatCandidate(dispatch); }) .catch(error => { - dispatch({ - type: NotificationConstants.NOTIFY_ERROR, - data: {title: 'File Upload Failed', msg: error.responseJSON.message} + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: i18n('File Upload Failed'), + msg: error.responseJSON.message, + cancelButtonText: i18n('Ok') + } }); }); }, - openMainScreen(dispatch) { - dispatch({ - type: actionTypes.OPEN_MAIN_SCREEN - }); - } + + 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/heatvalidation/UploadScreenConstants.js b/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenConstants.js deleted file mode 100644 index 2766a975ec..0000000000 --- a/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenConstants.js +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import keyMirror from 'nfvo-utils/KeyMirror.js'; - -export const actionTypes = keyMirror({ - FILE_UPLOADED: null, - OPEN_UPLOAD_SCREEN: null, - OPEN_ATTACHMENTS_SCREEN: null, - OPEN_MAIN_SCREEN: null -}); diff --git a/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenReducer.js b/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenReducer.js deleted file mode 100644 index e73e028233..0000000000 --- a/openecomp-ui/src/sdc-app/heatvalidation/UploadScreenReducer.js +++ /dev/null @@ -1,33 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import {actionTypes} from './UploadScreenConstants.js'; - - -export default (state = {}, action) => { - switch (action.type) { - case actionTypes.OPEN_UPLOAD_SCREEN: - return {...state, showAttachments: true}; - case actionTypes.OPEN_MAIN_SCREEN: - return {...state, showAttachments: false}; - default: - return state; - } -}; diff --git a/openecomp-ui/src/sdc-app/heatvalidation/attachments/Attachments.js b/openecomp-ui/src/sdc-app/heatvalidation/attachments/Attachments.js deleted file mode 100644 index 2a6a992844..0000000000 --- a/openecomp-ui/src/sdc-app/heatvalidation/attachments/Attachments.js +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import {connect} from 'react-redux'; -import AttachmentsView from './AttachmentsView.jsx'; -import AttachmentsActionHelper from './AttachmentsActionHelper.js'; - - -const mapStateToProps = ({uploadScreen: {attachments}}) => { - let {attachmentsTree = false, hoveredNode, selectedNode, errorList} = attachments; - return { - attachmentsTree, - hoveredNode, - selectedNode, - errorList - }; -}; - -const mapActionsToProps = (dispatch) => { - return { - - toggleExpanded: (path) => AttachmentsActionHelper.toggleExpanded(dispatch, {path}), - onSelectNode: (nodeName) => AttachmentsActionHelper.onSelectNode(dispatch, {nodeName}), - onUnselectNode: () => AttachmentsActionHelper.onUnselectNode(dispatch), - - }; -}; - -export default connect(mapStateToProps, mapActionsToProps)(AttachmentsView); diff --git a/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsActionHelper.js b/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsActionHelper.js deleted file mode 100644 index 15b0ffa4a9..0000000000 --- a/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsActionHelper.js +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import {actionTypes} from './AttachmentsConstants.js'; - -export default { - - toggleExpanded(dispatch, {path}) { - dispatch({ - type: actionTypes.TOGGLE_EXPANDED, - path - }); - }, - - onSelectNode(dispatch, {nodeName}) { - dispatch({ - type: actionTypes.SELECTED_NODE, - nodeName - }); - }, - - onUnselectNode(dispatch) { - dispatch({ - type: actionTypes.UNSELECTED_NODE - }); - } -}; diff --git a/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsConstants.js b/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsConstants.js deleted file mode 100644 index 33af476d9c..0000000000 --- a/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsConstants.js +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -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 -}); - -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') -}); - -export const nodeTypes = keyMirror({ - 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 -}); - diff --git a/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsReducer.js b/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsReducer.js deleted file mode 100644 index 01f68aede8..0000000000 --- a/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsReducer.js +++ /dev/null @@ -1,199 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import {actionTypes as softwareProductsActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; -import {actionTypes} from './AttachmentsConstants.js'; - -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 mapArtifactsData = ({fileName, errors}) => ({ - name: fileName, - type: 'artifact', - 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) : []) - ] -}); - -function createErrorList(node, parent, deep = 0, errorList = []) { - if (node.errors) { - errorList.push(...node.errors.map((error) => ({ - errorLevel: 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 => { - let {HEAT, volume, network, artifacts, other} = validationData.importStructure || {}; - return { - children: [ - { - name: 'HEAT', - expanded: true, - type: 'heat', - children: (HEAT ? HEAT.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; -}; - -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; - }); - - 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; - let attachmentsTree = currentSoftwareProduct.validationData ? mapValidationDataToTree(currentSoftwareProduct.validationData) : {}; - let errorList = createErrorList(attachmentsTree); - return { - ...state, - attachmentsTree, - errorList - }; - 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: undefined - }; - default: - return state; - } -}; diff --git a/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsView.jsx b/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsView.jsx deleted file mode 100644 index 7e2dda8d47..0000000000 --- a/openecomp-ui/src/sdc-app/heatvalidation/attachments/AttachmentsView.jsx +++ /dev/null @@ -1,190 +0,0 @@ -import React from 'react'; -import FontAwesome from 'react-fontawesome'; -import classNames from 'classnames'; -import Collapse from 'react-bootstrap/lib/Collapse.js'; - -import i18n from 'nfvo-utils/i18n/i18n.js'; -import {nodeTypes, mouseActions} from './AttachmentsConstants'; - -const typeToIcon = Object.freeze({ - heat: 'building-o', - volume: 'database', - network: 'cloud', - artifact: 'gear', - env: 'server', - other: 'cube' -}); - -const leftPanelWidth = 250; - -class SoftwareProductAttachmentsView extends React.Component { - - static propTypes = { - attachmentsTree: React.PropTypes.object.isRequired - }; - state = { - treeWidth: '400', - }; - - render() { - let {attachmentsTree, errorList = []} = this.props; - - let {treeWidth} = this.state; - return ( -
    -
    -
    -
    -
    -
    - { - attachmentsTree && attachmentsTree.children && attachmentsTree.children.map((child, ind) => this.renderNode(child, [ind])) - } -
    -
    -
    this.onChangeTreeWidth(e)} /> -
    - {errorList.length ? this.renderErrorList(errorList) :
    {attachmentsTree.children ? - i18n('VALIDATION SUCCESS') : i18n('THERE IS NO HEAT DATA TO PRESENT') }
    } -
    -
    -
    -
    -
    - ); - } - - - - renderNode(node, path) { - let isFolder = node.children && node.children.length > 0; - let {onSelectNode} = this.props; - return ( -
    - { -
    this.props.toggleExpanded(path)} className={this.getTreeRowClassName(node.name)}> - { - isFolder && -
    this.props.toggleExpanded(path)} className={classNames('tree-node-expander', {'tree-node-expander-collapsed': !node.expanded})}> - -
    - } - { - - - - - } - { - - onSelectNode(node.name)} className={this.getTreeTextClassName(node)}> - {node.name} - - } -
    - } - { - isFolder && - -
    - { - node.children.map((child, ind) => this.renderNode(child, [...path, ind])) - } -
    -
    - } -
    - ); - } - - createErrorList(errorList, node, parent) { - if (node.errors) { - node.errors.forEach(error => errorList.push({ - error, - name: node.name, - parentName: parent.name, - type: node.type - })); - } - if (node.children && node.children.length) { - node.children.map((child) => this.createErrorList(errorList, child, node)); - } - } - - renderErrorList(errors) { - let prevError = {}; - let {selectedNode} = this.props; - return errors.map(error => { - let isSameNodeError = error.name === prevError.name && error.parentName === prevError.parentName; - prevError = error; - - return ( -
    this.selectNode(error.name)} - className={classNames('error-item', {'clicked': selectedNode === error.name, 'shifted': !isSameNodeError})}> - - { - error.hasParent ? - i18n('{type} {name} in {parentName}: ', { - type: nodeTypes[error.type], - name: error.name, - parentName: error.parentName - }) : - i18n('{type} {name}: ', { - type: nodeTypes[error.type], - name: error.name - }) - } - - {error.errorMessage} -
    - ); - }); - } - - selectNode(currentSelectedNode) { - let {onUnselectNode, onSelectNode, selectedNode} = this.props; - if (currentSelectedNode !== selectedNode) { - onSelectNode(currentSelectedNode); - }else{ - onUnselectNode(); - } - - } - - getTreeRowClassName(name) { - let {hoveredNode, selectedNode} = this.props; - return classNames({ - 'tree-node-row': true, - 'tree-node-selected': name === hoveredNode, - 'tree-node-clicked': name === selectedNode - }); - } - - getTreeTextClassName(node) { - let {selectedNode} = this.props; - return classNames({ - 'tree-element-text': true, - 'error-status': node.errors, - 'error-status-selected': node.name === selectedNode - }); - } - - 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); - } - } -} - -export default SoftwareProductAttachmentsView; diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js index d39b2affd3..4945d33b23 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingActionHelper.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 LicenseModelActionHelper from './licenseModel/LicenseModelActionHelper.js'; import LicenseAgreementActionHelper from './licenseModel/licenseAgreement/LicenseAgreementActionHelper.js'; import FeatureGroupsActionHelper from './licenseModel/featureGroups/FeatureGroupsActionHelper.js'; @@ -29,9 +24,12 @@ import SoftwareProductNetworksActionHelper from './softwareProduct/networks/Soft import SoftwareProductComponentsActionHelper from './softwareProduct/components/SoftwareProductComponentsActionHelper.js'; import SoftwareProductComponentProcessesActionHelper from './softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js'; import SoftwareProductComponentsNetworkActionHelper from './softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js'; +import SoftwareProductDependenciesActionHelper from './softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js'; +import OnboardActionHelper from './onboard/OnboardActionHelper.js'; import SoftwareProductComponentsMonitoringAction from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js'; import {actionTypes, enums} from './OnboardingConstants.js'; import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import ActivityLogActionHelper from 'nfvo-components/activity-log/ActivityLogActionHelper.js'; import store from 'sdc-app/AppStore.js'; function setCurrentScreen(dispatch, screen, props = {}) { @@ -39,7 +37,8 @@ function setCurrentScreen(dispatch, screen, props = {}) { type: actionTypes.SET_CURRENT_SCREEN, currentScreen: { screen, - props + props, + forceBreadCrumbsUpdate: true } }); } @@ -48,21 +47,61 @@ function getCurrentLicenseModelVersion(licenseModelId) { return store.getState().licenseModelList.find(({id}) => id === licenseModelId).version; } +function getCurrentSoftwareProductVersion(softwareProductId) { + return store.getState().softwareProductList.find(({id}) => id === softwareProductId).version; +} + export default { navigateToOnboardingCatalog(dispatch) { LicenseModelActionHelper.fetchLicenseModels(dispatch); + LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch); SoftwareProductActionHelper.fetchSoftwareProductList(dispatch); + SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(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, + qdata: dataToSave.qdata + }); + } + return Promise.resolve(); + }, + + navigateToLicenseModelOverview(dispatch, {licenseModelId, version}) { + if (!version) { + version = getCurrentLicenseModelVersion(licenseModelId); + } + + /** + * 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}); + }); + + }); + }, navigateToLicenseAgreements(dispatch, {licenseModelId, version}) { if(!version) { version = getCurrentLicenseModelVersion(licenseModelId); } LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version}); LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { - setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, {licenseModelId}); + setCurrentScreen(dispatch, enums.SCREEN.LICENSE_AGREEMENTS, {licenseModelId, version}); }); }, @@ -71,7 +110,7 @@ export default { version = getCurrentLicenseModelVersion(licenseModelId); } FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version}); - setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, {licenseModelId}); + setCurrentScreen(dispatch, enums.SCREEN.FEATURE_GROUPS, {licenseModelId, version}); }, navigateToEntitlementPools(dispatch, {licenseModelId, version}) { @@ -79,7 +118,7 @@ export default { version = getCurrentLicenseModelVersion(licenseModelId); } EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); - setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, {licenseModelId}); + setCurrentScreen(dispatch, enums.SCREEN.ENTITLEMENT_POOLS, {licenseModelId, version}); }, navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}) { @@ -87,13 +126,30 @@ export default { version = getCurrentLicenseModelVersion(licenseModelId); } LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); - setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, {licenseModelId}); + setCurrentScreen(dispatch, enums.SCREEN.LICENSE_KEY_GROUPS, {licenseModelId, version}); + }, + + navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version}){ + if(!version) { + version = getCurrentLicenseModelVersion(licenseModelId); + } + ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id}); + setCurrentScreen(dispatch, enums.SCREEN.ACTIVITY_LOG, {licenseModelId, version}); }, navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, version, licensingVersion}) { + + if (!version) { + version = getCurrentSoftwareProductVersion(softwareProductId); + } + + SoftwareProductComponentsActionHelper.clearComponentsStore(dispatch); SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}).then(response => { if(!licensingVersion) { licensingVersion = response[0].licensingVersion; + if (!licensingVersion) { + licensingVersion = {id: '1.0', label: '1.0'}; + } } if (!licenseModelId) { licenseModelId = response[0].vendorId; @@ -101,74 +157,84 @@ export default { SoftwareProductActionHelper.loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion}); SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); - + SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version}); setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE, {softwareProductId, licenseModelId, version}); }); }, - navigateToSoftwareProductDetails(dispatch, {softwareProductId}) { - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId}); + navigateToSoftwareProductDetails(dispatch, {softwareProductId, version}) { + SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DETAILS, {softwareProductId, version}); }, - navigateToSoftwareProductAttachments(dispatch, {softwareProductId}) { - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId}); + navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version}) { + SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS, {softwareProductId, version}); }, navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}) { if (softwareProductId) { SoftwareProductProcessesActionHelper.fetchProcessesList(dispatch, {softwareProductId, version}); } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES, {softwareProductId, version}); }, navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}) { if (softwareProductId) { SoftwareProductNetworksActionHelper.fetchNetworksList(dispatch, {softwareProductId, version}); } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS, {softwareProductId, version}); + }, + + navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version}) { + SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES, {softwareProductId, version}); + }, + + navigateToSoftwareProductComponents(dispatch, {softwareProductId, version}) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId, version}); }, - navigateToSoftwareProductComponents(dispatch, {softwareProductId}) { - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS, {softwareProductId}); + navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version}){ + ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: softwareProductId, versionId: version.id}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG, {softwareProductId, version}); }, navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId, version}) { if (componentId && softwareProductId) { SoftwareProductComponentProcessesActionHelper.fetchProcessesList(dispatch, {componentId, softwareProductId, version}); } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES, {softwareProductId, componentId, version}); }, - navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId}){ - if (componentId && softwareProductId) { - SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId}); + navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, version, componentId}){ + if (componentId && softwareProductId && version) { + SoftwareProductComponentsMonitoringAction.fetchExistingFiles(dispatch, {componentId, softwareProductId, version}); } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING, {softwareProductId, componentId, version}); }, - navigateToComponentStorage(dispatch, {softwareProductId, componentId}) { - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, componentId}); + navigateToComponentStorage(dispatch, {softwareProductId, componentId, version}) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE, {softwareProductId, version, componentId}); }, - navigateToComponentCompute(dispatch, {softwareProductId, componentId}) { - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, componentId}); + navigateToComponentCompute(dispatch, {softwareProductId, componentId, version}) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE, {softwareProductId, version, componentId}); }, navigateToComponentNetwork(dispatch, {softwareProductId, componentId, version}) { SoftwareProductComponentsNetworkActionHelper.fetchNICsList(dispatch, {softwareProductId, componentId, version}); - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, componentId}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK, {softwareProductId, version, componentId}); }, navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version}) { if (componentId && softwareProductId) { SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(dispatch, { - softwareProductId, - vspComponentId: componentId, - version - }); } - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, componentId}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL, {softwareProductId, version, componentId}); }, navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version}) { @@ -182,7 +248,9 @@ export default { }); }, - navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId}) { - setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, componentId}); + navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId, version}) { + SoftwareProductComponentsActionHelper.fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, version}); + setCurrentScreen(dispatch, enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING, {softwareProductId, version, componentId}); } + }; diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingCatalog.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingCatalog.js deleted file mode 100644 index 4772c8d9af..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingCatalog.js +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import {connect} from 'react-redux'; -import {default as OnboardingCatalogView, catalogItemTypes} from './OnboardingCatalogView.jsx'; -import OnboardingActionHelper from './OnboardingActionHelper.js'; -import LicenseModelCreationActionHelper from './licenseModel/creation/LicenseModelCreationActionHelper.js'; -import SoftwareProductCreationActionHelper from './softwareProduct/creation/SoftwareProductCreationActionHelper.js'; - - -const mapStateToProps = ({licenseModelList, softwareProductList, softwareProduct: {softwareProductCreation}, licenseModel: {licenseModelCreation}}) => { - - let modalToShow; - - if(licenseModelCreation.data) { - modalToShow = catalogItemTypes.LICENSE_MODEL; - } else if(softwareProductCreation.showModal && softwareProductCreation.data) { - modalToShow = catalogItemTypes.SOFTWARE_PRODUCT; - } - - return { - licenseModelList, - softwareProductList, - modalToShow - }; -}; - -const mapActionsToProps = (dispatch) => { - return { - onSelectLicenseModel({id: licenseModelId}) { - OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId}); - }, - onSelectSoftwareProduct(softwareProduct) { - let {id: softwareProductId, vendorId: licenseModelId, licensingVersion} = softwareProduct; - OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, licensingVersion}); - }, - onAddSoftwareProductClick: () => SoftwareProductCreationActionHelper.open(dispatch), - onAddLicenseModelClick: () => LicenseModelCreationActionHelper.open(dispatch) - }; -}; - -export default connect(mapStateToProps, mapActionsToProps)(OnboardingCatalogView); diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingCatalogView.jsx b/openecomp-ui/src/sdc-app/onboarding/OnboardingCatalogView.jsx deleted file mode 100644 index f2a9db1342..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingCatalogView.jsx +++ /dev/null @@ -1,147 +0,0 @@ -import React from 'react'; -import i18n from 'nfvo-utils/i18n/i18n.js'; -import Modal from 'nfvo-components/modal/Modal.jsx'; -import objectValues from 'lodash/values.js'; -import LicenseModelCreation from './licenseModel/creation/LicenseModelCreation.js'; -import SoftwareProductCreation from './softwareProduct/creation/SoftwareProductCreation.js'; -import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; -import classnames from 'classnames'; -import ExpandableInput from 'nfvo-components/input/ExpandableInput.jsx'; - -export const catalogItemTypes = Object.freeze({ - LICENSE_MODEL: 'license-model', - SOFTWARE_PRODUCT: 'software-product' -}); - -const catalogItemTypeClasses = { - LICENSE_MODEL: 'license-model-type', - SOFTWARE_PRODUCT: 'software-product-type' -}; - -class OnboardingCatalogView extends React.Component { - - constructor(props) { - super(props); - this.state = {searchValue: ''}; - this.handleSearch = this.handleSearch.bind(this); - } - - handleSearch(event){ - this.setState({searchValue: event.target.value}); - } - - static propTypes = { - licenseModelList: React.PropTypes.array, - softwareProductList: React.PropTypes.array, - modalToShow: React.PropTypes.oneOf(objectValues(catalogItemTypes)), - onSelectLicenseModel: React.PropTypes.func.isRequired, - onSelectSoftwareProduct: React.PropTypes.func.isRequired, - onAddLicenseModelClick: React.PropTypes.func.isRequired, - onAddSoftwareProductClick: React.PropTypes.func.isRequired - }; - - 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 modalDetails = this.getModalDetails(); - const {licenseModelList, softwareProductList, onSelectLicenseModel, onSelectSoftwareProduct, onAddLicenseModelClick, onAddSoftwareProductClick, modalToShow} = this.props; - - return ( -
    -
    -
    {i18n('Onboarding Catalog')}
    - -
    -
    - -
    -
    -
    - {i18n('ADD')} -
    -
    - onAddLicenseModelClick()}>{i18n('New License Model')}
    -
    - onAddSoftwareProductClick()}>{i18n('New Vendor Software Product')} -
    -
    - {licenseModelList.filter(vlm => vlm.vendorName.toLowerCase().indexOf(this.state.searchValue.toLowerCase()) > -1).map(licenseModel => this.renderTile( - { - ...licenseModel, - name: licenseModel.vendorName - }, - catalogItemTypeClasses.LICENSE_MODEL, - () => onSelectLicenseModel(licenseModel)) - )} - {softwareProductList.filter(vsp => vsp.name.toLowerCase().indexOf(this.state.searchValue.toLowerCase()) > -1).map(softwareProduct => this.renderTile(softwareProduct, - catalogItemTypeClasses.SOFTWARE_PRODUCT, - () => onSelectSoftwareProduct(softwareProduct)) - )} -
    - - - {modalDetails && modalDetails.title} - - - { - modalDetails && modalDetails.element - } - - -
    - ); - - } - - getCatalogItemTypeClassByItemType(catalogItemType) { - switch (catalogItemType) { - case catalogItemTypes.LICENSE_MODEL: - return catalogItemTypeClasses.LICENSE_MODEL; - case catalogItemTypes.SOFTWARE_PRODUCT: - return catalogItemTypeClasses.SOFTWARE_PRODUCT; - } - } - - renderTile(catalogItemData, catalogItemTypeClass, onSelect) { - let {status: itemStatus} = VersionControllerUtils.getCheckOutStatusKindByUserID(catalogItemData.status, catalogItemData.lockingUser); - return ( -
    onSelect()}> -
    -
    -
    -
    -
    -
    -
    {catalogItemData.name}
    -
    V {catalogItemData.version}
    -
    -
    -
    -
    -
    - ); - } -} -export default OnboardingCatalogView; diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js index d9c177f606..7811950073 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingConstants.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ @@ -29,16 +24,21 @@ export const enums = keyMirror({ BREADCRUMS: { LICENSE_MODEL: 'LICENSE_MODEL', + 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_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_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_STORAGE: 'SOFTWARE_PRODUCT_COMPONENT_STORAGE', @@ -50,16 +50,20 @@ export const enums = keyMirror({ SCREEN: { ONBOARDING_CATALOG: null, + LICENSE_MODEL_OVERVIEW: null, LICENSE_AGREEMENTS: null, FEATURE_GROUPS: null, ENTITLEMENT_POOLS: null, LICENSE_KEY_GROUPS: null, + ACTIVITY_LOG: null, SOFTWARE_PRODUCT_LANDING_PAGE: null, SOFTWARE_PRODUCT_DETAILS: null, SOFTWARE_PRODUCT_ATTACHMENTS: null, SOFTWARE_PRODUCT_PROCESSES: null, SOFTWARE_PRODUCT_NETWORKS: null, + SOFTWARE_PRODUCT_DEPENDENCIES: null, + SOFTWARE_PRODUCT_ACTIVITY_LOG: null, SOFTWARE_PRODUCT_COMPONENTS: null, SOFTWARE_PRODUCT_COMPONENT_PROCESSES: null, SOFTWARE_PRODUCT_COMPONENT_COMPUTE: null, diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx index c4627b11b3..e8a844b03f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import ReactDOM from 'react-dom'; import {connect} from 'react-redux'; @@ -9,8 +24,12 @@ import Application from 'sdc-app/Application.jsx'; import store from 'sdc-app/AppStore.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import OnboardingCatalog from './OnboardingCatalog.js'; +import Onboard from './onboard/Onboard.js'; import LicenseModel from './licenseModel/LicenseModel.js'; +import LicenseModelOverview from './licenseModel/overview/LicenseModelOverview.js'; +import ActivityLog from 'nfvo-components/activity-log/ActivityLog.js'; +import {doesHeatDataExist} from './softwareProduct/attachments/SoftwareProductAttachmentsUtils.js'; + import LicenseAgreementListEditor from './licenseModel/licenseAgreement/LicenseAgreementListEditor.js'; import FeatureGroupListEditor from './licenseModel/featureGroups/FeatureGroupListEditor.js'; import LicenseKeyGroupsListEditor from './licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js'; @@ -21,6 +40,7 @@ import SoftwareProductDetails from './softwareProduct/details/SoftwareProductDe import SoftwareProductAttachments from './softwareProduct/attachments/SoftwareProductAttachments.js'; import SoftwareProductProcesses from './softwareProduct/processes/SoftwareProductProcesses.js'; import SoftwareProductNetworks from './softwareProduct/networks/SoftwareProductNetworks.js'; +import SoftwareProductDependencies from './softwareProduct/dependencies/SoftwareProductDependencies.js'; import SoftwareProductComponentsList from './softwareProduct/components/SoftwareProductComponentsList.js'; import SoftwareProductComponentProcessesList from './softwareProduct/components/processes/SoftwareProductComponentProcessesList.js'; import SoftwareProductComponentStorage from './softwareProduct/components/storage/SoftwareProductComponentStorage.js'; @@ -30,8 +50,12 @@ import SoftwareProductComponentsCompute from './softwareProduct/components/compu import SoftwareProductComponentLoadBalancing from './softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js'; import SoftwareProductComponentsMonitoring from './softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js'; import {navigationItems as SoftwareProductNavigationItems, actionTypes as SoftwareProductActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import {statusEnum as VCItemStatus} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; + +import HeatSetupActionHelper from './softwareProduct/attachments/setup/HeatSetupActionHelper.js'; -import {enums} from './OnboardingConstants.js'; +import {actionTypes, enums} from './OnboardingConstants.js'; import OnboardingActionHelper from './OnboardingActionHelper.js'; @@ -64,17 +88,21 @@ class OnboardingView extends React.Component { {(() => { switch (screen) { case enums.SCREEN.ONBOARDING_CATALOG: - return ; + 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: @@ -83,6 +111,8 @@ class OnboardingView extends React.Component { return ; case enums.SCREEN.LICENSE_KEY_GROUPS: return ; + case enums.SCREEN.ACTIVITY_LOG: + return ; } })() } @@ -94,6 +124,7 @@ class OnboardingView extends React.Component { 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_COMPONENTS: case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE: @@ -102,6 +133,7 @@ class OnboardingView extends React.Component { case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: + case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: return ( { @@ -112,11 +144,13 @@ class OnboardingView extends React.Component { case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: return ; case enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS: - return ; + return ; case enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES: 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: @@ -133,6 +167,8 @@ class OnboardingView extends React.Component { return ; case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: return ; + case enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG: + return ; } })() } @@ -184,151 +220,195 @@ export default class OnboardingPunchOut { handleData(data) { let {breadcrumbs: {selectedKeys = []} = {}} = data; let dispatch = action => store.dispatch(action); - let {softwareProductList, softwareProduct: {softwareProductEditor: {data: {id: currentSoftwareProductId, version: currentSoftwareProductVersion} = {}}}, - licenseModelList, licenseModel: {licenseModelEditor: {data: {id: currentLicenseModelId, version: currentLicenseModelVersion} = {}}}} = store.getState(); - + let {currentScreen, softwareProductList, softwareProduct: {softwareProductEditor: {data: vspData = {}}, + softwareProductComponents = {}, softwareProductQuestionnaire = {}}, + licenseModelList, licenseModel: {licenseModelEditor: {data: {id: currentLicenseModelId, version: currentLicenseModelVersion} = {}}}} = store.getState(); + let {id: currentSoftwareProductId, version: currentSoftwareProductVersion} = vspData; + 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)); - this.prevSelectedKeys = selectedKeys; - if (selectedKeys.length === 0) { - OnboardingActionHelper.navigateToOnboardingCatalog(dispatch); - } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) { - let [licenseModelId, , licenseModelScreen] = selectedKeys; - if (!licenseModelScreen) { - licenseModelScreen = enums.BREADCRUMS.LICENSE_AGREEMENTS; - } - if(currentLicenseModelId !== licenseModelId) { - currentLicenseModelVersion = licenseModelList.find(lm => lm.id === licenseModelId).version; - } - switch (licenseModelScreen) { - case enums.BREADCRUMS.LICENSE_AGREEMENTS: - OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version: currentLicenseModelVersion}); - break; - case enums.BREADCRUMS.FEATURE_GROUPS: - OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion}); - break; - case enums.BREADCRUMS.ENTITLEMENT_POOLS: - OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version: currentLicenseModelVersion}); - break; - case enums.BREADCRUMS.LICENSE_KEY_GROUPS: - OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion}); - break; - } - } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) { - let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys; - let softwareProduct = softwareProductId ? - softwareProductList.find(({id}) => id === softwareProductId) : - softwareProductList.find(({vendorId}) => vendorId === licenseModelId); - if (!softwareProductId) { - softwareProductId = softwareProduct.id; - } - if(currentSoftwareProductId !== softwareProductId) { - currentSoftwareProductVersion = softwareProduct.version; - } - switch (softwareProductScreen) { - case enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS: - OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, {softwareProductId}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: - OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES: - OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS: - OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: - OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); - dispatch({ - type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, - mapOfExpandedIds: { - [SoftwareProductNavigationItems.COMPONENTS]: true - } - }); - break; - default: - OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); - break; - } - }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 ? - softwareProductList.find(({id}) => id === softwareProductId) : - softwareProductList.find(({vendorId}) => vendorId === licenseModelId); - if (!softwareProductId) { - softwareProductId = softwareProduct.id; - } - if(currentSoftwareProductId !== softwareProductId) { - currentSoftwareProductVersion = softwareProduct.version; - } - OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); - }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 ? - softwareProductList.find(({id}) => id === softwareProductId) : - softwareProductList.find(({vendorId}) => vendorId === licenseModelId); - if (!softwareProductId) { - softwareProductId = softwareProduct.id; - } - if(currentSoftwareProductId !== softwareProductId) { - currentSoftwareProductVersion = softwareProduct.version; - } - switch (componentScreen) { - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL: - OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: - OnboardingActionHelper.navigateToComponentCompute(dispatch, {softwareProductId, componentId}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: - OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK: - OnboardingActionHelper.navigateToComponentNetwork(dispatch, {softwareProductId, componentId}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE: - OnboardingActionHelper.navigateToComponentStorage(dispatch, {softwareProductId, componentId}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: - OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId}); - break; - case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING: - OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId}); - break; - } - } else { - console.error('Unknown breadcrumbs path: ', selectedKeys); + const [, screenType, prevVspId, , prevComponentId] = this.prevSelectedKeys || []; + let preNavigate = Promise.resolve(); + if(screenType === enums.BREADCRUMS.SOFTWARE_PRODUCT && vspData.status === VCItemStatus.CHECK_OUT_STATUS && VersionControllerUtils.isCheckedOutByCurrentUser(vspData)) { + let dataToSave = prevVspId ? prevComponentId ? {componentData, qdata: componentQData} : {softwareProduct: vspData, qdata: softwareProductQuestionnaire.qdata} : {}; + preNavigate = OnboardingActionHelper.autoSaveBeforeNavigate(dispatch, { + softwareProductId: prevVspId, + version: currentSoftwareProductVersion, + 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) { + OnboardingActionHelper.navigateToOnboardingCatalog(dispatch); + } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) { + let [licenseModelId, , licenseModelScreen] = selectedKeys; + if (!licenseModelScreen) { + licenseModelScreen = enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW; + } + if (currentLicenseModelId !== licenseModelId) { + currentLicenseModelVersion = licenseModelList.find(lm => lm.id === licenseModelId).version; + } + switch (licenseModelScreen) { + case enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW: + OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId, version: currentLicenseModelVersion}); + break; + case enums.BREADCRUMS.LICENSE_AGREEMENTS: + OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version: currentLicenseModelVersion}); + break; + case enums.BREADCRUMS.FEATURE_GROUPS: + OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion}); + break; + case enums.BREADCRUMS.ENTITLEMENT_POOLS: + OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version: currentLicenseModelVersion}); + break; + case enums.BREADCRUMS.LICENSE_KEY_GROUPS: + OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version: currentLicenseModelVersion}); + break; + case enums.BREADCRUMS.ACTIVITY_LOG: + OnboardingActionHelper.navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version: currentLicenseModelVersion}); + break; + } + } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) { + let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys; + let softwareProduct = softwareProductId ? + softwareProductList.find(({id}) => id === softwareProductId) : + softwareProductList.find(({vendorId}) => vendorId === licenseModelId); + if (!softwareProductId) { + softwareProductId = softwareProduct.id; + } + if (currentSoftwareProductId !== softwareProductId) { + currentSoftwareProductVersion = softwareProduct.version; + } + switch (softwareProductScreen) { + case enums.BREADCRUMS.SOFTWARE_PRODUCT_LANDING_PAGE: + OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_DETAILS: + OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: + OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_PROCESSES: + OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS: + OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: + OnboardingActionHelper.navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_ACTIVITY_LOG: + OnboardingActionHelper.navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: + OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); + dispatch({ + type: SoftwareProductActionTypes.TOGGLE_NAVIGATION_ITEM, + mapOfExpandedIds: { + [SoftwareProductNavigationItems.COMPONENTS]: true + } + }); + break; + default: + OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: currentSoftwareProductVersion}); + break; + } + } 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 ? + softwareProductList.find(({id}) => id === softwareProductId) : + softwareProductList.find(({vendorId}) => vendorId === licenseModelId); + if (!softwareProductId) { + softwareProductId = softwareProduct.id; + } + if (currentSoftwareProductId !== softwareProductId) { + currentSoftwareProductVersion = softwareProduct.version; + } + OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); + } 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 ? + softwareProductList.find(({id}) => id === softwareProductId) : + softwareProductList.find(({vendorId}) => vendorId === licenseModelId); + if (!softwareProductId) { + softwareProductId = softwareProduct.id; + } + if (currentSoftwareProductId !== softwareProductId) { + currentSoftwareProductVersion = softwareProduct.version; + } + switch (componentScreen) { + case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_GENERAL: + OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId, version: currentSoftwareProductVersion}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_COMPUTE: + OnboardingActionHelper.navigateToComponentCompute(dispatch, {softwareProductId, componentId}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: + OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_NETWORK: + OnboardingActionHelper.navigateToComponentNetwork(dispatch, {softwareProductId, componentId}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_STORAGE: + OnboardingActionHelper.navigateToComponentStorage(dispatch, {softwareProductId, componentId}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_PROCESSES: + OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId}); + break; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENT_MONITORING: + OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId}); + break; + } + } else { + console.error('Unknown breadcrumbs path: ', selectedKeys); + } + }).catch(() => { + store.dispatch({ + type: actionTypes.SET_CURRENT_SCREEN, + currentScreen: { + ...currentScreen, + forceBreadCrumbsUpdate: true + } + }); + }); } } handleStoreChange() { - let {currentScreen, licenseModelList, softwareProductList} = store.getState(); - let breadcrumbsData = {currentScreen, licenseModelList, softwareProductList}; - - if (!isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) { + let {currentScreen, licenseModelList, softwareProductList, + softwareProduct: {softwareProductComponents: {componentsList}, softwareProductAttachments: {heatSetup}}} = store.getState(); + let breadcrumbsData = {currentScreen, licenseModelList, softwareProductList, componentsList, heatSetup}; + 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}, licenseModelList, softwareProductList}) { - let componentsList; - if(props.componentId) { - componentsList = store.getState().softwareProduct.softwareProductComponents.componentsList; - } + buildBreadcrumbs({currentScreen: {screen, props}, licenseModelList, softwareProductList, componentsList, heatSetup}) { let screenToBreadcrumb; switch (screen) { case enums.SCREEN.ONBOARDING_CATALOG: @@ -338,11 +418,15 @@ export default class OnboardingPunchOut { 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_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 [ { @@ -365,6 +449,9 @@ export default class OnboardingPunchOut { }, { selectedKey: screenToBreadcrumb[screen], menuItems: [{ + key: enums.BREADCRUMS.LICENSE_MODEL_OVERVIEW, + displayText: i18n('Overview') + },{ key: enums.BREADCRUMS.LICENSE_AGREEMENTS, displayText: i18n('License Agreements') }, { @@ -376,6 +463,9 @@ export default class OnboardingPunchOut { }, { key: enums.BREADCRUMS.LICENSE_KEY_GROUPS, displayText: i18n('License Key Groups') + }, { + key: enums.BREADCRUMS.ACTIVITY_LOG, + displayText: i18n('Activity Log') }] } ]; @@ -385,6 +475,8 @@ export default class OnboardingPunchOut { 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_COMPONENT_PROCESSES: @@ -395,11 +487,14 @@ export default class OnboardingPunchOut { case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING: 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_NETWORKS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_NETWORKS, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS + [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, @@ -438,24 +533,46 @@ export default class OnboardingPunchOut { displayText: name })) }, - ...(screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE ? [] : [{ + ...(/*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_ATTACHMENTS, - displayText: i18n('Attachments') }, { 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 => { + let isHeatData = doesHeatDataExist(heatSetup); + let isComponentsData = componentsList.length > 0; + switch (item.key) { + case enums.BREADCRUMS.SOFTWARE_PRODUCT_ATTACHMENTS: + return isHeatData; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_COMPONENTS: + return isComponentsData; + case enums.BREADCRUMS.SOFTWARE_PRODUCT_DEPENDENCIES: + return isComponentsData; + default: + return true; + } + }) }]) ]; if(props.componentId) { diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingReducers.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingReducers.js index 9af2427243..46fc58db95 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingReducers.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingReducers.js @@ -1,26 +1,21 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes, enums} from './OnboardingConstants.js'; -export const currentScreenReducer = (state = {screen: enums.SCREEN.ONBOARDING_CATALOG, props: {}}, action) => { +export const currentScreenReducer = (state = {forceBreadCrumbsUpdate: false, screen: enums.SCREEN.ONBOARDING_CATALOG, props: {}}, action) => { if (action.type === actionTypes.SET_CURRENT_SCREEN) { return action.currentScreen; } diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingReducersMap.js b/openecomp-ui/src/sdc-app/onboarding/OnboardingReducersMap.js index 92d53a3d4f..9428dd5829 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingReducersMap.js +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingReducersMap.js @@ -1,36 +1,34 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {currentScreenReducer} from './OnboardingReducers.js'; import licenseModelListReducer from './licenseModel/LicenseModelListReducer.js'; import finalizedLicenseModelListReducer from './licenseModel/FinalizedLicenseModelListReducer.js'; import licenseModelReducer from './licenseModel/LicenseModelReducer.js'; import softwareProductReducer from './softwareProduct/SoftwareProductReducer.js'; import softwareProductListReducer from './softwareProduct/SoftwareProductListReducer.js'; - +import finalizedSoftwareProductReducer from './softwareProduct/FinalizedSoftwareProductReducer.js'; +import onboardReducer from './onboard/OnboardReducer.js'; export default { currentScreen: currentScreenReducer, licenseModelList: licenseModelListReducer, finalizedLicenseModelList: finalizedLicenseModelListReducer, + finalizedSoftwareProductList: finalizedSoftwareProductReducer, licenseModel: licenseModelReducer, softwareProduct: softwareProductReducer, - softwareProductList: softwareProductListReducer + softwareProductList: softwareProductListReducer, + onboard: onboardReducer }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/FinalizedLicenseModelListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/FinalizedLicenseModelListReducer.js index a851e77dc8..cc9d9c536d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/FinalizedLicenseModelListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/FinalizedLicenseModelListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './LicenseModelConstants.js'; export default (state = [], action) => { diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js index ad91a0da65..e21b0a81b0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModel.js @@ -1,30 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 i18n from 'nfvo-utils/i18n/i18n.js'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import TabulatedEditor from 'src/nfvo-components/editor/TabulatedEditor.jsx'; - +import ActivityLogActionHelper from 'nfvo-components/activity-log/ActivityLogActionHelper.js'; import {enums} from 'sdc-app/onboarding/OnboardingConstants.js'; import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; @@ -44,6 +38,11 @@ const buildNavigationBarProps = (licenseModel, screen) => { id, name: vendorName, items: [ + { + id: navigationItems.LICENSE_MODEL_OVERVIEW, + name: i18n('Overview'), + meta + }, { id: navigationItems.LICENSE_AGREEMENTS, name: i18n('License Agreements'), @@ -63,15 +62,22 @@ const buildNavigationBarProps = (licenseModel, screen) => { id: navigationItems.LICENSE_KEY_GROUPS, name: i18n('License Key Groups'), meta + }, + { + id: navigationItems.ACTIVITY_LOG, + name: i18n('Activity Log'), + meta } ] }]; const activeItemId = ({ + [enums.SCREEN.LICENSE_MODEL_OVERVIEW]: navigationItems.LICENSE_MODEL_OVERVIEW, [enums.SCREEN.LICENSE_AGREEMENTS]: navigationItems.LICENSE_AGREEMENTS, [enums.SCREEN.FEATURE_GROUPS]: navigationItems.FEATURE_GROUPS, [enums.SCREEN.ENTITLEMENT_POOLS]: navigationItems.ENTITLEMENT_POOLS, - [enums.SCREEN.LICENSE_KEY_GROUPS]: navigationItems.LICENSE_KEY_GROUPS + [enums.SCREEN.LICENSE_KEY_GROUPS]: navigationItems.LICENSE_KEY_GROUPS, + [enums.SCREEN.ACTIVITY_LOG]: navigationItems.ACTIVITY_LOG })[screen]; return { @@ -82,9 +88,7 @@ const buildNavigationBarProps = (licenseModel, screen) => { const buildVersionControllerProps = (licenseModel) => { let {version, viewableVersions, status: currentStatus, lockingUser} = licenseModel; - let {status, isCheckedOut} = (currentStatus === versionStatusEnum.CHECK_OUT_STATUS) ? - VersionControllerUtils.getCheckOutStatusKindByUserID(currentStatus, lockingUser) : - {status: currentStatus, isCheckedOut: false}; + let {status, isCheckedOut} = VersionControllerUtils.getCheckOutStatusKindByUserID(currentStatus, lockingUser); return { version, @@ -104,29 +108,46 @@ const mapStateToProps = ({licenseModel: {licenseModelEditor}}, {currentScreen: { const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {licenseModelId}}}) => { + return { - onVersionControllerAction: action => - LicenseModelActionHelper.performVCAction(dispatch, {licenseModelId, action}).then(() => { + onVersionControllerAction: (action, version) => + LicenseModelActionHelper.performVCAction(dispatch, {licenseModelId, action, version}).then((newVersion) => { switch(screen) { + case enums.SCREEN.LICENSE_MODEL_OVERVIEW: + /** + * TODO change to specific rest + */ + LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version: newVersion}); + break; case enums.SCREEN.LICENSE_AGREEMENTS: - LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId}); + LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version: newVersion}); break; case enums.SCREEN.FEATURE_GROUPS: - FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId}); + FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version: newVersion}); break; case enums.SCREEN.ENTITLEMENT_POOLS: - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId}); + EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version: newVersion}); break; case enums.SCREEN.LICENSE_KEY_GROUPS: - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId}); + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version: newVersion}); + break; + case enums.SCREEN.ACTIVITY_LOG: + ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: newVersion.id}); break; } }), - onVersionSwitching: version => LicenseAgreementActionHelper.switchVersion(dispatch, {licenseModelId, version}), - onClose: () => OnboardingActionHelper.navigateToOnboardingCatalog(dispatch), + onVersionSwitching: version => { + LicenseModelActionHelper.switchVersion(dispatch, {licenseModelId, version}); + if(screen === enums.SCREEN.ACTIVITY_LOG) { + ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: licenseModelId, versionId: version.id}); + } + }, onNavigate: ({id, meta: {version}}) => { switch(id) { + case navigationItems.LICENSE_MODEL_OVERVIEW: + OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId, version}); + break; case navigationItems.LICENSE_AGREEMENTS: OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version}); break; @@ -139,6 +160,9 @@ const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {licenseMod case navigationItems.LICENSE_KEY_GROUPS: OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}); break; + case navigationItems.ACTIVITY_LOG: + OnboardingActionHelper.navigateToLicenseModelActivityLog(dispatch, {licenseModelId, version}); + break; } } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js index a379a2c40f..186f1cbc7b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js @@ -1,29 +1,28 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 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 i18n from 'nfvo-utils/i18n/i18n.js'; -import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.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'; function baseUrl() { const restPrefix = Configuration.get('restPrefix'); @@ -39,12 +38,32 @@ function fetchFinalizedLicenseModels() { } function fetchLicenseModelById(licenseModelId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl()}${licenseModelId}${versionQuery}`); + const {id: versionId} = version; + return RestAPIUtil.fetch(`${baseUrl()}${licenseModelId}/versions/${versionId}`); +} + +function putLicenseModelAction(id, action, version) { + const {id: versionId} = version; + return RestAPIUtil.put(`${baseUrl()}${id}/versions/${versionId}/actions`, {action: action}); +} + +function putLicenseModel(licenseModel) { + let {id, vendorName, description, iconRef, version: {id: versionId}} = licenseModel; + return RestAPIUtil.put(`${baseUrl()}${id}/versions/${versionId}`, { + vendorName, + description, + iconRef + }); +} + +function adjustMinorVersion(version, value) { + let ar = version.split('.'); + return ar[0] + '.' + (parseInt(ar[1]) + value); } -function putLicenseModelAction(id, action) { - return RestAPIUtil.save(`${baseUrl()}${id}/actions`, {action: action}); +function adjustMajorVersion(version, value) { + let ar = version.split('.'); + return (parseInt(ar[0]) + value) + '.0'; } const LicenseModelActionHelper = { @@ -67,13 +86,11 @@ const LicenseModelActionHelper = { }, fetchLicenseModelById(dispatch, {licenseModelId, version}) { - return fetchLicenseModelById(licenseModelId, version).then(response => { - if(version) { - response.version = version; - } + + return fetchLicenseModelById(licenseModelId, version).then(response => { dispatch({ type: actionTypes.LICENSE_MODEL_LOADED, - response + response: {...response, version} }); }); }, @@ -85,17 +102,68 @@ const LicenseModelActionHelper = { }); }, - performVCAction(dispatch, {licenseModelId, action}) { - return putLicenseModelAction(licenseModelId, action).then(() => { + 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}) + ]); + }, + + performVCAction(dispatch, {licenseModelId, action, version}) { + return putLicenseModelAction(licenseModelId, action, version).then(() => { if(action === vcActionsEnum.SUBMIT){ dispatch({ - type: NotificationConstants.NOTIFY_SUCCESS, - data: {title: i18n('Submit Succeeded'), msg: i18n('This license model successfully submitted'), timeout: 2000} + type: modalActionTypes.GLOBAL_MODAL_SUCCESS, + data: { + title: i18n('Submit Succeeded'), + msg: i18n('This license model successfully submitted'), + cancelButtonText: i18n('OK'), + timeout: 2000 + } }); } - return LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId}); + + let newVersionId = version.id; + /* + TODO Temorary switch to change version label + */ + switch(action) { + case vcActionsEnum.CHECK_OUT: + newVersionId = adjustMinorVersion(version.label, 1); + break; + case vcActionsEnum.UNDO_CHECK_OUT: + newVersionId = adjustMinorVersion(version.label, -1); + break; + case vcActionsEnum.SUBMIT: + newVersionId = adjustMajorVersion(version.label, 1); + } + + LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version:{id: newVersionId, label: newVersionId}}); + return Promise.resolve({id: newVersionId, label: newVersionId}); + }); + }, + + switchVersion(dispatch, {licenseModelId, version}) { + LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version: {id: version.id, label: version.label}}).then(() => { + LicenseModelActionHelper.fetchLicenseModelItems(dispatch, {licenseModelId, version}); + }); + }, + + saveLicenseModel(dispatch, {licenseModel}) { + return putLicenseModel(licenseModel).then(() => { + dispatch({ + type: actionTypes.ADD_LICENSE_MODEL, + licenseModel + }); + dispatch({ + type: actionTypes.LICENSE_MODEL_LOADED, + response: licenseModel + }); }); } + }; 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 13fa9f5284..4ba10c3a68 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelConstants.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ @@ -29,8 +24,10 @@ export const actionTypes = keyMirror({ }); export const navigationItems = keyMirror({ - LICENSE_AGREEMENTS: 'License Agreements', - FEATURE_GROUPS: 'Feature Groups', - ENTITLEMENT_POOLS: 'Entitlement Pools', - LICENSE_KEY_GROUPS: 'License Key Groups' + LICENSE_MODEL_OVERVIEW: 'overview', + LICENSE_AGREEMENTS: 'license-agreements', + FEATURE_GROUPS: 'feature-groups', + ENTITLEMENT_POOLS: 'entitlement-pools', + LICENSE_KEY_GROUPS: 'license-key-groups', + ACTIVITY_LOG: 'activity-log' }); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelEditorReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelEditorReducer.js index e92e32aa9e..add5ac6a98 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelEditorReducer.js @@ -1,28 +1,23 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './LicenseModelConstants.js'; export default (state = {}, action) => { switch (action.type) { - case actionTypes.LICENSE_MODEL_LOADED: + case actionTypes.LICENSE_MODEL_LOADED: return { ...state, data: action.response diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js index 8874c4ce21..fd73b462a3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './LicenseModelConstants.js'; export default (state = [], action) => { diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js index 5982b9f8ab..9a2d114bdc 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/LicenseModelReducer.js @@ -1,66 +1,85 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {combineReducers} from 'redux'; +import activityLogReducer from 'nfvo-components/activity-log/ActivityLogReducer.js'; + import licenseModelCreationReducer from './creation/LicenseModelCreationReducer.js'; import licenseModelEditorReducer from './LicenseModelEditorReducer.js'; import licenseAgreementListReducer from './licenseAgreement/LicenseAgreementListReducer.js'; import licenseAgreementEditorReducer from './licenseAgreement/LicenseAgreementEditorReducer.js'; -import {actionTypes as licenseAgreementActionTypes} from './licenseAgreement/LicenseAgreementConstants.js'; import featureGroupsEditorReducer from './featureGroups/FeatureGroupsEditorReducer.js'; import featureGroupsListReducer from './featureGroups/FeatureGroupsListReducer.js'; -import {actionTypes as featureGroupsActionConstants} from './featureGroups/FeatureGroupsConstants'; import entitlementPoolsListReducer from './entitlementPools/EntitlementPoolsListReducer.js'; import entitlementPoolsEditorReducer from './entitlementPools/EntitlementPoolsEditorReducer.js'; -import {actionTypes as entitlementPoolsConstants} from './entitlementPools/EntitlementPoolsConstants'; import licenseKeyGroupsEditorReducer from './licenseKeyGroups/LicenseKeyGroupsEditorReducer.js'; import licenseKeyGroupsListReducer from './licenseKeyGroups/LicenseKeyGroupsListReducer.js'; -import {actionTypes as licenseKeyGroupsConstants} from './licenseKeyGroups/LicenseKeyGroupsConstants.js'; + +import {createPlainDataReducer} from 'sdc-app/common/reducers/PlainDataReducer.js'; + +import {actionTypes as licenseModelOverviewConstants, selectedButton, VLM_DESCRIPTION_FORM} from './overview/LicenseModelOverviewConstants.js'; export default combineReducers({ - licenseModelCreation: licenseModelCreationReducer, + licenseModelCreation: createPlainDataReducer(licenseModelCreationReducer), licenseModelEditor: licenseModelEditorReducer, licenseAgreement: combineReducers({ - licenseAgreementEditor: licenseAgreementEditorReducer, - licenseAgreementList: licenseAgreementListReducer, - licenseAgreementToDelete: (state = false, action) => action.type === licenseAgreementActionTypes.LICENSE_AGREEMENT_DELETE_CONFIRM ? action.licenseAgreementToDelete : state + licenseAgreementEditor: createPlainDataReducer(licenseAgreementEditorReducer), + licenseAgreementList: licenseAgreementListReducer }), featureGroup: combineReducers({ - featureGroupEditor: featureGroupsEditorReducer, - featureGroupsList: featureGroupsListReducer, - featureGroupToDelete: (state = false, action) => action.type === featureGroupsActionConstants.FEATURE_GROUPS_DELETE_CONFIRM ? action.featureGroupToDelete : state + featureGroupEditor: createPlainDataReducer(featureGroupsEditorReducer), + featureGroupsList: featureGroupsListReducer }), entitlementPool: combineReducers({ - entitlementPoolEditor: entitlementPoolsEditorReducer, - entitlementPoolsList: entitlementPoolsListReducer, - entitlementPoolToDelete: (state = false, action) => action.type === entitlementPoolsConstants.ENTITLEMENT_POOLS_DELETE_CONFIRM ? action.entitlementPoolToDelete : state + entitlementPoolEditor: createPlainDataReducer(entitlementPoolsEditorReducer), + entitlementPoolsList: entitlementPoolsListReducer }), licenseKeyGroup: combineReducers({ - licenseKeyGroupsEditor: licenseKeyGroupsEditorReducer, - licenseKeyGroupsList: licenseKeyGroupsListReducer, - licenseKeyGroupToDelete: (state = false, action) => action.type === licenseKeyGroupsConstants.LICENSE_KEY_GROUPS_DELETE_CONFIRM ? action.licenseKeyGroupToDelete : state + licenseKeyGroupsEditor: createPlainDataReducer(licenseKeyGroupsEditorReducer), + licenseKeyGroupsList: licenseKeyGroupsListReducer }), + licenseModelOverview: combineReducers({ + selectedTab: (state = selectedButton.VLM_LIST_VIEW, 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; + } + } + )}), + activityLog: activityLogReducer }); 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 63d0f27b6a..d85618c85f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js @@ -1,40 +1,50 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; import LicenseModelCreationActionHelper from './LicenseModelCreationActionHelper.js'; import LicenseModelCreationView from './LicenseModelCreationView.jsx'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; +import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; + +export const mapStateToProps = ({licenseModelList, licenseModel: {licenseModelCreation}}) => { + let {genericFieldInfo} = licenseModelCreation; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); -const mapStateToProps = ({licenseModel: {licenseModelCreation}}) => licenseModelCreation; + let VLMNames = {}; + for (let i = 0; i < licenseModelList.length; i++) { + VLMNames[licenseModelList[i].vendorName] = licenseModelList[i].id; + } + + return {...licenseModelCreation, isFormValid: isFormValid, VLMNames}; +}; -const mapActionsToProps = (dispatch) => { +export const mapActionsToProps = (dispatch) => { return { - onDataChanged: deltaData => LicenseModelCreationActionHelper.dataChanged(dispatch, {deltaData}), + onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), onCancel: () => LicenseModelCreationActionHelper.close(dispatch), onSubmit: (licenseModel) => { LicenseModelCreationActionHelper.close(dispatch); - LicenseModelCreationActionHelper.createLicenseModel(dispatch, {licenseModel}).then(licenseModelId => { - OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId}); + LicenseModelCreationActionHelper.createLicenseModel(dispatch, {licenseModel}).then(response => { + LicenseModelActionHelper.fetchLicenseModels(dispatch).then(() => { + OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId: response.value}); + }); }); - } + }, + onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js index c2a0409bd2..51f5b7f276 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js @@ -1,27 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.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'); @@ -29,7 +26,7 @@ function baseUrl() { } function createLicenseModel(licenseModel) { - return RestAPIUtil.create(baseUrl(), { + return RestAPIUtil.post(baseUrl(), { vendorName: licenseModel.vendorName, description: licenseModel.description, iconRef: 'icon' @@ -43,30 +40,28 @@ export default { 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 }); - }, - dataChanged(dispatch, {deltaData}){ dispatch({ - type: actionTypes.DATA_CHANGED, - deltaData + type: modalActionTypes.GLOBAL_MODAL_CLOSE }); }, createLicenseModel(dispatch, {licenseModel}){ - return createLicenseModel(licenseModel).then(response => { - LicenseModelActionHelper.addLicenseModel(dispatch, { - licenseModel: { - ...licenseModel, - id: response.value - } - }); - return response.value; - }); + return createLicenseModel(licenseModel); } + }; 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 603d177048..28f1175676 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationConstants.js @@ -1,27 +1,23 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ OPEN: null, - CLOSE: null, - DATA_CHANGED: null + CLOSE: 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 a54d1b3089..879d356de2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationReducer.js @@ -1,42 +1,43 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} 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, - data: {} + 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 {}; - case actionTypes.DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData - } - }; 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 4dccc9e1c4..80040460c0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx @@ -1,7 +1,24 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; +import Validator from 'nfvo-utils/Validator.js'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +import Form from 'nfvo-components/input/validation/Form.jsx'; +import {LICENSE_MODEL_CREATION_FORM_NAME} from './LicenseModelCreationConstants.js'; const LicenseModelPropType = React.PropTypes.shape({ id: React.PropTypes.string, @@ -13,39 +30,49 @@ class LicenseModelCreationView extends React.Component { static propTypes = { data: LicenseModelPropType, + VLMNames: React.PropTypes.object, onDataChanged: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired, + onValidateForm: React.PropTypes.func.isRequired, onCancel: React.PropTypes.func.isRequired }; render() { - let {data = {}, onDataChanged} = this.props; + let {data = {}, onDataChanged, genericFieldInfo} = this.props; let {vendorName, description} = data; return (
    - this.submit() } onReset={ () => this.props.onCancel() } - labledButtons={true}> - this.validate() }> + onDataChanged({vendorName})} - validations={{maxLength: 25, required: true}} + data-test-id='vendor-name' + onChange={vendorName => 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})} - validations={{maxLength: 1000, required: true}} + data-test-id='vendor-description' + overlayPos='bottom' + onChange={description => onDataChanged({description}, LICENSE_MODEL_CREATION_FORM_NAME)} + isValid={genericFieldInfo.description.isValid} + errorText={genericFieldInfo.description.errorText} type='textarea' className='field-section'/> - + }
    ); } @@ -55,6 +82,18 @@ class LicenseModelCreationView extends React.Component { const {data:licenseModel} = this.props; this.props.onSubmit(licenseModel); } + + 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); + } } 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 631597a5b0..fe95b034dd 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js @@ -1,40 +1,35 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as entitlementPoolsActionTypes } from './EntitlementPoolsConstants.js'; import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; -function baseUrl(licenseModelId) { +function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/entitlement-pools`; + const {id: versionId} = version; + return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/entitlement-pools`; } -function fetchEntitlementPoolsList(licenseModelId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(licenseModelId)}${versionQuery}`); +function fetchEntitlementPoolsList(licenseModelId, version) { + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } -function postEntitlementPool(licenseModelId, entitlementPool) { - return RestAPIUtil.create(baseUrl(licenseModelId), { +function postEntitlementPool(licenseModelId, entitlementPool, version) { + return RestAPIUtil.post(baseUrl(licenseModelId, version), { name: entitlementPool.name, description: entitlementPool.description, thresholdValue: entitlementPool.thresholdValue, @@ -49,8 +44,8 @@ function postEntitlementPool(licenseModelId, entitlementPool) { } -function putEntitlementPool(licenseModelId, previousEntitlementPool, entitlementPool) { - return RestAPIUtil.save(`${baseUrl(licenseModelId)}/${entitlementPool.id}`, { +function putEntitlementPool(licenseModelId, previousEntitlementPool, entitlementPool, version) { + return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${entitlementPool.id}`, { name: entitlementPool.name, description: entitlementPool.description, thresholdValue: entitlementPool.thresholdValue, @@ -64,8 +59,8 @@ function putEntitlementPool(licenseModelId, previousEntitlementPool, entitlement }); } -function deleteEntitlementPool(licenseModelId, entitlementPoolId) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId)}/${entitlementPoolId}`); +function deleteEntitlementPool(licenseModelId, entitlementPoolId, version) { + return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${entitlementPoolId}`); } @@ -84,8 +79,8 @@ export default { }); }, - deleteEntitlementPool(dispatch, {licenseModelId, entitlementPoolId}) { - return deleteEntitlementPool(licenseModelId, entitlementPoolId).then(() => { + deleteEntitlementPool(dispatch, {licenseModelId, entitlementPoolId, version}) { + return deleteEntitlementPool(licenseModelId, entitlementPoolId, version).then(() => { dispatch({ type: entitlementPoolsActionTypes.DELETE_ENTITLEMENT_POOL, entitlementPoolId @@ -106,9 +101,9 @@ export default { }); }, - saveEntitlementPool(dispatch, {licenseModelId, previousEntitlementPool, entitlementPool}) { + saveEntitlementPool(dispatch, {licenseModelId, previousEntitlementPool, entitlementPool, version}) { if (previousEntitlementPool) { - return putEntitlementPool(licenseModelId, previousEntitlementPool, entitlementPool).then(() => { + return putEntitlementPool(licenseModelId, previousEntitlementPool, entitlementPool, version).then(() => { dispatch({ type: entitlementPoolsActionTypes.EDIT_ENTITLEMENT_POOL, entitlementPool @@ -116,11 +111,12 @@ export default { }); } else { - return postEntitlementPool(licenseModelId, entitlementPool).then(response => { + return postEntitlementPool(licenseModelId, entitlementPool, version).then(response => { dispatch({ type: entitlementPoolsActionTypes.ADD_ENTITLEMENT_POOL, entitlementPool: { ...entitlementPool, + referencingFeatureGroups: [], id: response.value } }); diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConfirmationModal.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConfirmationModal.jsx deleted file mode 100644 index 04f038f5f0..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConfirmationModal.jsx +++ /dev/null @@ -1,51 +0,0 @@ -import React from 'react'; -import {connect} from 'react-redux'; -import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx'; -import EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; -import i18n from 'nfvo-utils/i18n/i18n.js'; - -function renderMsg(entitlementPoolToDelete) { - let poolName = entitlementPoolToDelete ? entitlementPoolToDelete.name : ''; - let msg = i18n('Are you sure you want to delete "{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}

    -
    - ); -}; - -const mapStateToProps = ({licenseModel: {entitlementPool}}, {licenseModelId}) => { - let {entitlementPoolToDelete} = entitlementPool; - const show = entitlementPoolToDelete !== false; - return { - show, - title: 'Warning!', - type: 'warning', - msg: renderMsg(entitlementPoolToDelete), - confirmationDetails: {entitlementPoolToDelete, licenseModelId} - }; -}; - -const mapActionsToProps = (dispatch) => { - return { - onConfirmed: ({entitlementPoolToDelete, licenseModelId}) => { - EntitlementPoolsActionHelper.deleteEntitlementPool(dispatch, { - licenseModelId, - entitlementPoolId: entitlementPoolToDelete.id - }); - EntitlementPoolsActionHelper.hideDeleteConfirm(dispatch); - }, - onDeclined: () => { - EntitlementPoolsActionHelper.hideDeleteConfirm(dispatch); - } - }; -}; - -export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView); - 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 8a855076f3..ba0b238b17 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsConstants.js @@ -1,25 +1,21 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; +import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; export const actionTypes = keyMirror({ @@ -27,7 +23,6 @@ export const actionTypes = keyMirror({ ADD_ENTITLEMENT_POOL: null, EDIT_ENTITLEMENT_POOL: null, DELETE_ENTITLEMENT_POOL: null, - ENTITLEMENT_POOLS_DELETE_CONFIRM: null, entitlementPoolsEditor: { OPEN: null, @@ -107,6 +102,14 @@ export const optionsInputValues = { ] }; +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 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 d5bd07e929..f89cf8fbb5 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditor.js @@ -1,52 +1,60 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; import EntitlementPoolsEditorView from './EntitlementPoolsEditorView.jsx'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; const mapStateToProps = ({licenseModel: {entitlementPool}}) => { - let {data} = entitlementPool.entitlementPoolEditor; - - let previousData; + let {data, genericFieldInfo, formReady} = entitlementPool.entitlementPoolEditor; + + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + + 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] = list[i].id; + } + return { data, - previousData + genericFieldInfo, + previousData, + isFormValid, + formReady, + EPNames }; }; -const mapActionsToProps = (dispatch, {licenseModelId}) => { +const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { - onDataChanged: deltaData => EntitlementPoolsActionHelper.entitlementPoolsEditorDataChanged(dispatch, {deltaData}), + onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), onCancel: () => EntitlementPoolsActionHelper.closeEntitlementPoolsEditor(dispatch), onSubmit: ({previousEntitlementPool, entitlementPool}) => { EntitlementPoolsActionHelper.closeEntitlementPoolsEditor(dispatch); - EntitlementPoolsActionHelper.saveEntitlementPool(dispatch, {licenseModelId, previousEntitlementPool, entitlementPool}); - } + EntitlementPoolsActionHelper.saveEntitlementPool(dispatch, {licenseModelId, previousEntitlementPool, entitlementPool, version}); + }, + onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) }; }; 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 86e97ecf8d..db1a3a97ca 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorReducer.js @@ -1,30 +1,79 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes, defaultState} from './EntitlementPoolsConstants.js'; +import {actionTypes, defaultState, SP_ENTITLEMENT_POOL_FORM} from './EntitlementPoolsConstants.js'; export default (state = {}, action) => { switch (action.type) { case actionTypes.entitlementPoolsEditor.OPEN: 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: 'required', data: true}, {type: 'maxLength', data: 1000}] + }, + 'manufacturerReferenceNumber' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}, {type: 'maxLength', data: 100}] + }, + 'increments' : { + isValid: true, + errorText: '', + validations: [{type: 'maxLength', data: 120}] + }, + 'operationalScope' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + }, + 'thresholdUnits' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + }, + 'thresholdValue' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + }, + 'entitlementMetric' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + }, + 'aggregationFunction' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + }, + 'time' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + } + }, data: action.entitlementPool ? {...action.entitlementPool} : defaultState.ENTITLEMENT_POOLS_EDITOR_DATA }; case actionTypes.entitlementPoolsEditor.DATA_CHANGED: 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 77c5a12e03..d484437015 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsEditorView.jsx @@ -1,14 +1,31 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; - import i18n from 'nfvo-utils/i18n/i18n.js'; +import Validator from 'nfvo-utils/Validator.js'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; -import {optionsInputValues as EntitlementPoolsOptionsInputValues, thresholdUnitType} from './EntitlementPoolsConstants.js'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; +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 {optionsInputValues as EntitlementPoolsOptionsInputValues, thresholdUnitType, SP_ENTITLEMENT_POOL_FORM} from './EntitlementPoolsConstants.js'; import {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; - const EntitlementPoolPropType = React.PropTypes.shape({ id: React.PropTypes.string, name: React.PropTypes.string, @@ -33,11 +50,172 @@ const EntitlementPoolPropType = React.PropTypes.shape({ }) }); +const EntitlementPoolsFormContent = ({data, genericFieldInfo, onDataChanged, validateName, validateChoiceWithOther, validateTimeOtherValue, thresholdValueValidation}) => { + let { + name, description, manufacturerReferenceNumber, operationalScope , aggregationFunction, thresholdUnits, thresholdValue, + increments, time, entitlementMetric} = 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} + + isRequired={true} + onEnumChange={operationalScope => onDataChanged({operationalScope:{choices: operationalScope, other: ''}}, + SP_ENTITLEMENT_POOL_FORM, {operationalScope: validateChoiceWithOther})} + onOtherChange={operationalScope => onDataChanged({operationalScope:{choices: [optionInputOther.OTHER], + other: operationalScope}}, SP_ENTITLEMENT_POOL_FORM, {operationalScope: validateChoiceWithOther})} + 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} + isRequired={true} + 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 + 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' > + {EntitlementPoolsOptionsInputValues.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} + isRequired={true} + type='text'/> +
    + {}} + isMultiSelect={false} + isRequired={true} + onEnumChange={entitlementMetric => onDataChanged({entitlementMetric:{choice: entitlementMetric, other: ''}}, + SP_ENTITLEMENT_POOL_FORM, {entitlementMetric: validateChoiceWithOther})} + onOtherChange={entitlementMetric => onDataChanged({entitlementMetric:{choice: optionInputOther.OTHER, + other: entitlementMetric}}, SP_ENTITLEMENT_POOL_FORM, {entitlementMetric: validateChoiceWithOther})} + label={i18n('Entitlement Metric')} + data-test-id='create-ep-entitlement-metric' + type='select' + required={true} + selectedEnum={entitlementMetric && entitlementMetric.choice} + otherValue={entitlementMetric && entitlementMetric.other} + values={EntitlementPoolsOptionsInputValues.ENTITLEMENT_METRIC} + isValid={genericFieldInfo.entitlementMetric.isValid} + errorText={genericFieldInfo.entitlementMetric.errorText} /> + {}} + isMultiSelect={false} + isRequired={true} + onEnumChange={aggregationFunction => onDataChanged({aggregationFunction:{choice: aggregationFunction, other: ''}}, + SP_ENTITLEMENT_POOL_FORM, {aggregationFunction: validateChoiceWithOther})} + onOtherChange={aggregationFunction => onDataChanged({aggregationFunction:{choice: optionInputOther.OTHER, + other: aggregationFunction}}, SP_ENTITLEMENT_POOL_FORM, {aggregationFunction: validateChoiceWithOther})} + label={i18n('Aggregate Function')} + data-test-id='create-ep-aggregate-function' + type='select' + required={true} + selectedEnum={aggregationFunction && aggregationFunction.choice} + otherValue={aggregationFunction && aggregationFunction.other} + values={EntitlementPoolsOptionsInputValues.AGGREGATE_FUNCTION} + isValid={genericFieldInfo.aggregationFunction.isValid} + errorText={genericFieldInfo.aggregationFunction.errorText} /> +
    + + onDataChanged({manufacturerReferenceNumber}, SP_ENTITLEMENT_POOL_FORM)} + label={i18n('Manufacturer Reference Number')} + value={manufacturerReferenceNumber} + isRequired={true} + data-test-id='create-ep-reference-number' + type='text'/> + + + {}} + isMultiSelect={false} + isRequired={true} + onEnumChange={time => onDataChanged({time:{choice: time, other: ''}}, + SP_ENTITLEMENT_POOL_FORM, {time: validateChoiceWithOther})} + onOtherChange={time => onDataChanged({time:{choice: optionInputOther.OTHER, + other: time}}, SP_ENTITLEMENT_POOL_FORM, {time: validateTimeOtherValue})} + label={i18n('Time')} + data-test-id='create-ep-time' + type='select' + required={true} + selectedEnum={time && time.choice} + otherValue={time && time.other} + values={EntitlementPoolsOptionsInputValues.TIME} + isValid={genericFieldInfo.time.isValid} + errorText={genericFieldInfo.time.errorText} /> + + + onDataChanged({increments}, SP_ENTITLEMENT_POOL_FORM)} + label={i18n('Increments')} + value={increments} + data-test-id='create-ep-increments' + type='text'/> + +
    + ); +}; + class EntitlementPoolsEditorView extends React.Component { static propTypes = { data: EntitlementPoolPropType, previousData: EntitlementPoolPropType, + EPNames: React.PropTypes.object, isReadOnlyMode: React.PropTypes.bool, onDataChanged: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired, @@ -49,119 +227,88 @@ class EntitlementPoolsEditorView extends React.Component { }; render() { - let {data = {}, onDataChanged, isReadOnlyMode} = this.props; - let { - name, description, manufacturerReferenceNumber, operationalScope, aggregationFunction, thresholdUnits, thresholdValue, - increments, time, entitlementMetric} = data; - let thresholdValueValidation = thresholdUnits === thresholdUnitType.PERCENTAGE ? {numeric: true, required: true, maxValue: 100} : {numeric: true, required: true}; - let timeValidation = time && time.choice === optionInputOther.OTHER ? {numeric: true, required: true} : {required: true}; + let {data = {}, onDataChanged, isReadOnlyMode, genericFieldInfo} = this.props; + return ( - this.submit() } - onReset={ () => this.props.onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - className='entitlement-pools-form'> -
    - onDataChanged({name})} - label={i18n('Name')} - value={name} - validations={{maxLength: 120, required: true}} - type='text'/> +
    + { + genericFieldInfo &&
    this.submit() } + onReset={ () => this.props.onCancel() } + labledButtons={true} + isReadOnlyMode={isReadOnlyMode} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => this.props.onValidateForm(SP_ENTITLEMENT_POOL_FORM) } + className='entitlement-pools-form'> + this.validateName(value)} + validateTimeOtherValue ={(value)=> this.validateTimeOtherValue(value)} + validateChoiceWithOther={(value)=> this.validateChoiceWithOther(value)} + thresholdValueValidation={(value, state)=> this.thresholdValueValidation(value, state)}/> + + } +
    + ); + } - onDataChanged({operationalScope:{choices: operationalScope, other: ''}})} - onOtherChange={operationalScope => onDataChanged({operationalScope:{choices: [optionInputOther.OTHER], other: operationalScope}})} - multiSelectedEnum={operationalScope && operationalScope.choices} - label={i18n('Operational Scope')} - otherValue={operationalScope && operationalScope.other} - validations={{required: true}} - values={EntitlementPoolsOptionsInputValues.OPERATIONAL_SCOPE}/> + submit() { + const {data: entitlementPool, previousData: previousEntitlementPool} = this.props; + this.props.onSubmit({entitlementPool, previousEntitlementPool}); + } -
    -
    - onDataChanged({description})} - label={i18n('Description')} - value={description} - validations={{maxLength: 1000, required: true}} - type='textarea'/> -
    -
    - onDataChanged({thresholdUnits})} - selectedEnum={thresholdUnits} - label={i18n('Threshold Value')} - type='select' - values={EntitlementPoolsOptionsInputValues.THRESHOLD_UNITS} - validations={{required: true}}/> - onDataChanged({thresholdValue})} - value={thresholdValue} - validations={thresholdValueValidation} - type='text'/> -
    - - onDataChanged({entitlementMetric:{choice: entitlementMetric, other: ''}})} - onOtherChange={entitlementMetric => onDataChanged({entitlementMetric:{choice: optionInputOther.OTHER, other: entitlementMetric}})} - selectedEnum={entitlementMetric && entitlementMetric.choice} - otherValue={entitlementMetric && entitlementMetric.other} - label={i18n('Entitlement Metric')} - validations={{required: true}} - values={EntitlementPoolsOptionsInputValues.ENTITLEMENT_METRIC}/> - onDataChanged({aggregationFunction:{choice: aggregationFunction, other: ''}})} - onOtherChange={aggregationFunction => onDataChanged({aggregationFunction:{choice: optionInputOther.OTHER, other: aggregationFunction}})} - selectedEnum={aggregationFunction && aggregationFunction.choice} - otherValue={aggregationFunction && aggregationFunction.other} - validations={{required: true}} - label={i18n('Aggregate Function')} - values={EntitlementPoolsOptionsInputValues.AGGREGATE_FUNCTION}/> - -
    -
    -
    + validateName(value) { + const {data: {id}, EPNames} = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: EPNames}); - onDataChanged({manufacturerReferenceNumber})} - label={i18n('Manufacturer Reference Number')} - value={manufacturerReferenceNumber} - validations={{maxLength: 100, required: true}} - type='text'/> + return !isExists ? {isValid: true, errorText: ''} : + {isValid: false, errorText: i18n('Entitlement pool by the name \'' + value + '\' already exists. Entitlement pool name must be unique')}; + } - onDataChanged({time:{choice: time, other: ''}})} - onOtherChange={time => onDataChanged({time:{choice: optionInputOther.OTHER, other: time}})} - selectedEnum={time && time.choice} - otherValue={time && time.other} - validations={timeValidation} - label={i18n('Time')} - values={EntitlementPoolsOptionsInputValues.TIME}/> -
    -
    - onDataChanged({increments})} - label={i18n('Increments')} - value={increments} - validations={{maxLength: 120}} - type='text'/> + validateTimeOtherValue(value) { + return Validator.validate('time', value.other, [{type: 'required', data: true}, {type: 'numeric', data: true}]); + } -
    -
    - ); + validateChoiceWithOther(value) { + let chosen = value.choice; + // if we have an empty multiple select we have a problem since it's required + if (value.choices) { + if (value.choices.length === 0) { + return Validator.validate('field', '', [{type: 'required', data: true}]); + } else { + // continuing validation with the first chosen value in case we have the 'Other' field + chosen = value.choices[0]; + } + } + if (chosen !== optionInputOther.OTHER) { + return Validator.validate('field', chosen, [{type: 'required', data: true}]); + } else { // when 'Other' was chosen, validate other value + return Validator.validate('field', value.other, [{type: 'required', data: true}]); + } } - submit() { - const {data: entitlementPool, previousData: previousEntitlementPool} = this.props; - this.props.onSubmit({entitlementPool, previousEntitlementPool}); + thresholdValueValidation(value, state) { + + let unit = state.data.thresholdUnits; + if (unit === thresholdUnitType.PERCENTAGE) { + return Validator.validate('thresholdValue', value, [ + {type: 'required', data: true}, + {type: 'numeric', data: true}, + {type: 'maximum', data: 100}, + {type: 'minimum', data: 0}]); + } else { + return Validator.validate('thresholdValue', value, [ + {type: 'numeric', data: true}, + {type: 'required', data: true}]); + } } + } export default EntitlementPoolsEditorView; 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 4b21a2fea8..993ed48f2b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditor.js @@ -1,27 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 i18n from 'nfvo-utils/i18n/i18n.js'; import EntitlementPoolsActionHelper from './EntitlementPoolsActionHelper.js'; -import EntitlementPoolsListEditorView from './EntitlementPoolsListEditorView.jsx'; +import EntitlementPoolsListEditorView, {generateConfirmationMsg} from './EntitlementPoolsListEditorView.jsx'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; const mapStateToProps = ({licenseModel: {entitlementPool, licenseModelEditor}}) => { let {entitlementPoolsList} = entitlementPool; @@ -39,13 +36,21 @@ const mapStateToProps = ({licenseModel: {entitlementPool, licenseModelEditor}}) }; }; -const mapActionsToProps = (dispatch, {licenseModelId}) => { +const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { onAddEntitlementPoolClick: () => EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch), onEditEntitlementPoolClick: entitlementPool => EntitlementPoolsActionHelper.openEntitlementPoolsEditor(dispatch, {entitlementPool}), - onDeleteEntitlementPool: entitlementPool => EntitlementPoolsActionHelper.openDeleteEntitlementPoolConfirm(dispatch, { - licenseModelId, - entitlementPool + onDeleteEntitlementPool: entitlementPool => dispatch({ + type: globalMoadlActions.GLOBAL_MODAL_WARNING, + data:{ + msg: generateConfirmationMsg(entitlementPool), + title: i18n('Warning'), + onConfirmed: ()=>EntitlementPoolsActionHelper.deleteEntitlementPool(dispatch, { + licenseModelId, + entitlementPoolId: entitlementPool.id, + version + }) + } }) }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx index 52df102503..07a6f21a1a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListEditorView.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; @@ -6,10 +21,7 @@ import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import EntitlementPoolsEditor from './EntitlementPoolsEditor.js'; -import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; -import {optionsInputValues} from './EntitlementPoolsConstants'; -import EntitlementPoolsConfirmationModal from './EntitlementPoolsConfirmationModal.jsx'; - +import {extractUnits, extractValue} from './EntitlementPoolsConstants'; class EntitlementPoolsListEditorView extends React.Component { static propTypes = { @@ -33,35 +45,33 @@ class EntitlementPoolsListEditorView extends React.Component { }; render() { - let {licenseModelId, vendorName, isReadOnlyMode, isDisplayModal, isModalInEditMode} = this.props; + let {licenseModelId, vendorName, isReadOnlyMode, isDisplayModal, isModalInEditMode, version} = this.props; let {onAddEntitlementPoolClick} = this.props; const {localFilter} = this.state; return (
    this.setState({localFilter: filter})} + onFilter={value => 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 && ( - + ) } - -
    ); } @@ -92,14 +102,15 @@ class EntitlementPoolsListEditorView extends React.Component { className='list-editor-item-view' isReadOnlyMode={isReadOnlyMode}>
    +
    {i18n('Name')}
    -
    {name}
    +
    {name}
    {i18n('Entitlement')}
    -
    {`${this.extractValue(aggregationFunction)} ${this.extractValue(entitlementMetric)} per ${this.extractValue(time)}`}
    -
    {`${thresholdValue ? thresholdValue : ''} ${this.extractUnits(thresholdUnits)}`}
    +
    {`${extractValue(aggregationFunction)} ${extractValue(entitlementMetric)} per ${extractValue(time)}`}
    +
    {`${thresholdValue ? thresholdValue : ''} ${extractUnits(thresholdUnits)}`}
    @@ -115,18 +126,22 @@ class EntitlementPoolsListEditorView extends React.Component { ); } - - - extractUnits(units) { - if (units === undefined) {return '';} //TODO fix it later - return units === 'Absolute' ? '' : '%'; - } - - extractValue(item) { - if (item === undefined) {return '';} //TODO fix it later - - return item ? item.choice === optionInputOther.OTHER ? item.other : InputOptions.getTitleByName(optionsInputValues, item.choice) : ''; - } } export default EntitlementPoolsListEditorView; + +export function generateConfirmationMsg(entitlementPoolToDelete) { + let poolName = entitlementPoolToDelete ? entitlementPoolToDelete.name : ''; + let msg = i18n('Are you sure you want to delete "{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 63e351fce7..fefd823207 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './EntitlementPoolsConstants'; export default (state = [], action) => { switch (action.type) { 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 c2b269bcf9..c6249c98ca 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js @@ -1,66 +1,78 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; import FeatureGroupEditorView from './FeatureGroupEditorView.jsx'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -const mapStateToProps = ({licenseModel: {featureGroup, entitlementPool, licenseKeyGroup}}) => { - +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 {data, selectedTab, selectedEntitlementPoolsButtonTab, selectedLicenseKeyGroupsButtonTab} = featureGroupEditor; + let previousData, FGNames = {}, isFormValid = true, invalidTabs = []; - let previousData; - const featureGroupId = data ? data.id : null; if (featureGroupId) { - previousData = featureGroup.featureGroupsList.find(featureGroup => featureGroup.id === featureGroupId); + previousData = list.find(featureGroup => featureGroup.id === featureGroupId); + } + + for (let i = 0; i < list.length; i++) { + FGNames[list[i].name] = 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; + } + } } - let {entitlementPoolsList = []} = entitlementPool; - let {licenseKeyGroupsList = []} = licenseKeyGroup; return { data, previousData, selectedTab, - selectedEntitlementPoolsButtonTab, - selectedLicenseKeyGroupsButtonTab, entitlementPoolsList, - licenseKeyGroupsList + licenseKeyGroupsList, + isFormValid, + formReady, + genericFieldInfo, + invalidTabs, + FGNames }; }; -const mapActionsToProps = (dispatch, {licenseModelId}) => { +const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { + onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), onTabSelect: tab => FeatureGroupsActionHelper.selectEntitlementPoolsEditorTab(dispatch, {tab}), - onEntitlementPoolsButtonTabSelect: buttonTab => FeatureGroupsActionHelper.selectFeatureGroupsEditorEntitlementPoolsButtonTab(dispatch, {buttonTab}), - onLicenseKeyGroupsButtonTabSelect: buttonTab => FeatureGroupsActionHelper.selectFeatureGroupsEditorLicenseKeyGroupsButtonTab(dispatch, {buttonTab}), - onDataChanged: deltaData => FeatureGroupsActionHelper.featureGroupsEditorDataChanged(dispatch, {deltaData}), onSubmit: (previousFeatureGroup, featureGroup) => { FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch); - FeatureGroupsActionHelper.saveFeatureGroup(dispatch, {licenseModelId, previousFeatureGroup, featureGroup}); - } + FeatureGroupsActionHelper.saveFeatureGroup(dispatch, {licenseModelId, previousFeatureGroup, featureGroup, version}); + }, + onCancel: () => FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch), + onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) }; }; 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 6fecd16b71..5ae22cba95 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx @@ -1,27 +1,125 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; -import ValidationTabs from 'nfvo-components/input/validation/ValidationTabs.jsx'; -import ValidationTab from 'nfvo-components/input/validation/ValidationTab.jsx'; -import ButtonGroup from 'react-bootstrap/lib/ButtonGroup.js'; -import Button from 'react-bootstrap/lib/Button.js'; - -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; +import Tabs from 'nfvo-components/input/validation/Tabs.jsx'; +import Tab from 'react-bootstrap/lib/Tab.js'; +import GridSection from 'nfvo-components/grid/GridSection.jsx'; +import GridItem from 'nfvo-components/grid/GridItem.jsx'; +import Form from 'nfvo-components/input/validation/Form.jsx'; import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; -import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; -import ListEditorViewItem from 'nfvo-components/listEditor/ListEditorItemView.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} from './FeatureGroupsConstants.js'; +import {state as FeatureGroupStateConstants, FG_EDITOR_FORM} from './FeatureGroupsConstants.js'; const FeatureGroupsPropType = React.PropTypes.shape({ id: React.PropTypes.string, name: React.PropTypes.string, description: React.PropTypes.string, partNumber: React.PropTypes.string, - entitlementPoolsIds: React.PropTypes.array(React.PropTypes.string), - licenseKeyGroupsIds: React.PropTypes.array(React.PropTypes.string) + entitlementPoolsIds: React.PropTypes.arrayOf(React.PropTypes.string), + licenseKeyGroupsIds: React.PropTypes.arrayOf(React.PropTypes.string) }); +const GeneralTab = ({data = {}, onDataChanged, genericFieldInfo, validateName}) => { + let {name, description, partNumber} = 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' + isRequired={true} + 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} /> + + + ); +}; + +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 is 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 is no available licsense key groups')}

    + ); + } +}; + class FeatureGroupEditorView extends React.Component { @@ -29,6 +127,7 @@ class FeatureGroupEditorView extends React.Component { data: FeatureGroupsPropType, previousData: FeatureGroupsPropType, isReadOnlyMode: React.PropTypes.bool, + FGNames: React.PropTypes.object, onSubmit: React.PropTypes.func, onCancel: React.PropTypes.func, @@ -36,11 +135,6 @@ class FeatureGroupEditorView extends React.Component { selectedTab: React.PropTypes.number, onTabSelect: React.PropTypes.func, - selectedEntitlementPoolsButtonTab: React.PropTypes.number, - selectedLicenseKeyGroupsButtonTab: React.PropTypes.number, - onEntitlementPoolsButtonTabSelect: React.PropTypes.func, - onLicenseKeyGroupsButtonTabSelect: React.PropTypes.func, - entitlementPoolsList: DualListboxView.propTypes.availableList, licenseKeyGroupsList: DualListboxView.propTypes.availableList }; @@ -49,8 +143,6 @@ class FeatureGroupEditorView extends React.Component { static defaultProps = { data: {}, selectedTab: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL, - selectedEntitlementPoolsButtonTab: FeatureGroupStateConstants.SELECTED_ENTITLEMENT_POOLS_BUTTONTAB.ASSOCIATED_ENTITLEMENT_POOLS, - selectedLicenseKeyGroupsButtonTab: FeatureGroupStateConstants.SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB.ASSOCIATED_LICENSE_KEY_GROUPS }; state = { @@ -60,24 +152,39 @@ class FeatureGroupEditorView extends React.Component { render() { - let {selectedTab, onTabSelect, isReadOnlyMode} = this.props; + 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='feature-group-form'> - - {this.renderGeneralTab()} - {this.renderEntitlementPoolsTab()} - {this.renderLicenseKeyGroupsTab()} - - - + + + this.validateName(value)}/> + + + + + + + + + +
    } +
    ); } @@ -86,254 +193,14 @@ class FeatureGroupEditorView extends React.Component { this.props.onSubmit(previousFeatureGroup, featureGroup); } - renderGeneralTab() { - let {data = {}, onDataChanged} = this.props; - let {name, description, partNumber} = data; - return ( - -
    - onDataChanged({name})} - ref='name' - label={i18n('Name')} - value={name} - name='feature-group-name' - validations={{maxLength: 120, required: true}} - type='text'/> - onDataChanged({description})} - ref='description' - label={i18n('Description')} - value={description} - name='feature-group-description' - validations={{maxLength: 1000, required: true}} - type='textarea'/> - onDataChanged({partNumber})} - label={i18n('Part Number')} - value={partNumber} - validations={{required: true}} - type='text'/> -
    -
    - ); - } - - renderEntitlementPoolsTab() { - let {selectedEntitlementPoolsButtonTab, onEntitlementPoolsButtonTabSelect, entitlementPoolsList} = this.props; - if (entitlementPoolsList.length > 0) { - return ( - - - { - this.renderButtonsTab( - FeatureGroupStateConstants.SELECTED_ENTITLEMENT_POOLS_BUTTONTAB.ASSOCIATED_ENTITLEMENT_POOLS, - selectedEntitlementPoolsButtonTab, - i18n('Associated Entitlement Pools'), - onEntitlementPoolsButtonTabSelect - ) - } - { - this.renderButtonsTab( - FeatureGroupStateConstants.SELECTED_ENTITLEMENT_POOLS_BUTTONTAB.AVAILABLE_ENTITLEMENT_POOLS, - selectedEntitlementPoolsButtonTab, - i18n('Available Entitlement Pools'), - onEntitlementPoolsButtonTabSelect - ) - } - - {this.renderEntitlementPoolsButtonTabContent(selectedEntitlementPoolsButtonTab)} - - ); - } else { - return ( - -

    {i18n('There is no available entitlement pools.')}

    -
    - ); - } - } - - renderLicenseKeyGroupsTab() { - let {selectedLicenseKeyGroupsButtonTab, onLicenseKeyGroupsButtonTabSelect, licenseKeyGroupsList} = this.props; - if (licenseKeyGroupsList.length > 0) { - return ( - - - { - this.renderButtonsTab( - FeatureGroupStateConstants.SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB.ASSOCIATED_LICENSE_KEY_GROUPS, - selectedLicenseKeyGroupsButtonTab, - i18n('Associated License Key Groups'), - onLicenseKeyGroupsButtonTabSelect - ) - } - { - this.renderButtonsTab( - FeatureGroupStateConstants.SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB.AVAILABLE_LICENSE_KEY_GROUPS, - selectedLicenseKeyGroupsButtonTab, - i18n('Available License Key Groups'), - onLicenseKeyGroupsButtonTabSelect - ) - } - - {this.renderLicenseKeyGroupsTabContent(selectedLicenseKeyGroupsButtonTab)} - - ); - } else { - return ( - -

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

    -
    ); - } - } - - renderButtonsTab(buttonTab, selectedButtonTab, title, onClick) { - const isSelected = buttonTab === selectedButtonTab; - return ( - - ); - } - - renderEntitlementPoolsButtonTabContent(selectedFeatureGroupsButtonTab) { - const {entitlementPoolsList = [], data: {entitlementPoolsIds = []}} = this.props; - let dualBoxTitle = { - left: i18n('Available Entitlement Pools'), - right: i18n('Selected Entitlement Pools') - }; - - if (entitlementPoolsList.length) { - const {localEntitlementPoolsListFilter} = this.state; - let selectedEntitlementPools = entitlementPoolsIds.map(entitlementPoolId => entitlementPoolsList.find(entitlementPool => entitlementPool.id === entitlementPoolId)); - - switch (selectedFeatureGroupsButtonTab) { - case FeatureGroupStateConstants.SELECTED_ENTITLEMENT_POOLS_BUTTONTAB.ASSOCIATED_ENTITLEMENT_POOLS: - if (selectedEntitlementPools.length) { - return ( - this.setState({localEntitlementPoolsListFilter})}> - {this.filterAssociatedItems(selectedEntitlementPools, localEntitlementPoolsListFilter) - .map(entitlementPool => this.renderAssociatedListItem(entitlementPool - , FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.ENTITLEMENT_POOLS))} - - ); - } - else { - return ( -
    -
    {i18n('There are currently no entitlement pools associated with this feature group. Click "Available Entitlement Pools" to associate.')} -
    - ); - } - case FeatureGroupStateConstants.SELECTED_ENTITLEMENT_POOLS_BUTTONTAB.AVAILABLE_ENTITLEMENT_POOLS: - return ( - this.props.onDataChanged( { entitlementPoolsIds: selectedValuesList } )}/> - ); - } - } - } - - renderLicenseKeyGroupsTabContent(selectedFeatureGroupsButtonTab) { - const {licenseKeyGroupsList = [], data: {licenseKeyGroupsIds = []}} = this.props; - let dualBoxFilterTitle = { - left: i18n('Available License Key Groups'), - right: i18n('Selected License Key Groups') - }; - - if (licenseKeyGroupsList.length) { - const {localLicenseKeyGroupsListFilter} = this.state; - let selectedLicenseKeyGroups = licenseKeyGroupsIds.map(licenseKeyGroupId => licenseKeyGroupsList.find(licenseKeyGroup => licenseKeyGroup.id === licenseKeyGroupId)); - - switch (selectedFeatureGroupsButtonTab) { - case FeatureGroupStateConstants.SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB.ASSOCIATED_LICENSE_KEY_GROUPS: - if (selectedLicenseKeyGroups.length) { - return ( - this.setState({localLicenseKeyGroupsListFilter})}> - {this.filterAssociatedItems(selectedLicenseKeyGroups, localLicenseKeyGroupsListFilter) - .map(licenseKeyGroup => this.renderAssociatedListItem(licenseKeyGroup - , FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.LICENCE_KEY_GROUPS))} - - ); - } else { - return ( -
    - {i18n('There are currently no license key groups associated with this feature group. Click "Available License Key Groups" to associate.')} -
    - ); - } - case FeatureGroupStateConstants.SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB.AVAILABLE_LICENSE_KEY_GROUPS: - return ( - this.props.onDataChanged( { licenseKeyGroupsIds: selectedValuesList } )}/> - ); - } - } - } - - - renderAssociatedListItem(listItem, itemType) { - let {isReadOnlyMode} = this.props; - return ( - this.deleteAssociatedItem(listItem.id, itemType)} - isReadOnlyMode={isReadOnlyMode}> -
    {listItem.name}
    -
    {listItem.description}
    -
    - ); - } - - filterAssociatedItems(list, localList) { - if (localList) { - const filter = new RegExp(escape(localList), 'i'); - return list.filter(({name = '', description = ''}) => name.match(filter) || description.match(filter)); - } - else { - return list; - } - } - - deleteAssociatedItem(id, type) { - const {data: {licenseKeyGroupsIds = [], entitlementPoolsIds = []}} = this.props; - if (type === FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.LICENCE_KEY_GROUPS) { - this.props.onDataChanged({licenseKeyGroupsIds: licenseKeyGroupsIds.filter(listId => listId !== id)}); - } else { - this.props.onDataChanged({entitlementPoolsIds: entitlementPoolsIds.filter(listId => listId !== id)}); - } + 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 9ea5a31490..83473a30bb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js @@ -1,35 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; -import FeatureGroupListEditorView from './FeatureGroupListEditorView.jsx'; +import FeatureGroupListEditorView, {generateConfirmationMsg} from './FeatureGroupListEditorView.jsx'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; -const mapStateToProps = ({licenseModel: {featureGroup, licenseModelEditor}}) => { +export const mapStateToProps = ({licenseModel: {featureGroup, licenseModelEditor}}) => { const {featureGroupEditor: {data}, featureGroupsList} = featureGroup; - let {vendorName} = licenseModelEditor.data; + let {vendorName, version} = licenseModelEditor.data; let isReadOnlyMode = VersionControllerUtils.isReadOnly(licenseModelEditor.data); - return { vendorName, + version, featureGroupsModal: { show: Boolean(data), editMode: Boolean(data && data.id) @@ -42,13 +40,19 @@ const mapStateToProps = ({licenseModel: {featureGroup, licenseModelEditor}}) => const mapActionsToProps = (dispatch, {licenseModelId}) => { return { - onDeleteFeatureGroupClick: (featureGroup) => FeatureGroupsActionHelper.openDeleteFeatureGroupConfirm(dispatch, {licenseModelId, featureGroup}), - onCancelFeatureGroupsEditor: () => FeatureGroupsActionHelper.closeFeatureGroupsEditor(dispatch), - - onAddFeatureGroupClick: () => FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, {licenseModelId}), - onEditFeatureGroupClick: featureGroup => FeatureGroupsActionHelper.openFeatureGroupsEditor(dispatch, { + onDeleteFeatureGroupClick: (featureGroup, version) => dispatch({ + type: globalMoadlActions.GLOBAL_MODAL_WARNING, + data:{ + msg: generateConfirmationMsg(featureGroup), + title: i18n('Warning'), + 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 + licenseModelId, + version: actualVersion }) }; }; 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 d998f9216f..bc0f5c71c0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; @@ -6,7 +21,6 @@ import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import FeatureGroupEditor from './FeatureGroupEditor.js'; -import FeatureGroupsConfirmationModal from './FeatureGroupsConfirmationModal.jsx'; class FeatureGroupListEditorView extends React.Component { static propTypes = { @@ -37,46 +51,45 @@ class FeatureGroupListEditorView extends React.Component { }; render() { - let {vendorName, licenseModelId, featureGroupsModal, isReadOnlyMode, onAddFeatureGroupClick} = this.props; + let {vendorName, licenseModelId, featureGroupsModal, isReadOnlyMode, onAddFeatureGroupClick, version} = this.props; const {localFilter} = this.state; - return (
    this.setState({localFilter: filter})} - onAdd={() => onAddFeatureGroupClick()} + onFilter={value => this.setState({localFilter: value})} + onAdd={() => onAddFeatureGroupClick(version)} isReadOnlyMode={isReadOnlyMode}> - {this.filterList().map(listItem => this.renderFeatureGroupListItem(listItem, isReadOnlyMode))} + {this.filterList().map(listItem => this.renderFeatureGroupListItem(listItem, isReadOnlyMode, version))} - - - {`${featureGroupsModal.editMode ? i18n('Edit Feature Group') : i18n('Create New Feature Group')}`} - - - this.closeFeatureGroupsEditor()} - licenseModelId={licenseModelId} - isReadOnlyMode={isReadOnlyMode}/> - - - - + {featureGroupsModal.show && + + {`${featureGroupsModal.editMode ? i18n('Edit Feature Group') : i18n('Create New Feature Group')}`} + + + + + + }
    ); } - renderFeatureGroupListItem(listItem, isReadOnlyMode) { + renderFeatureGroupListItem(listItem, isReadOnlyMode, version) { let {name, description, entitlementPoolsIds = [], licenseKeyGroupsIds = []} = listItem; return ( this.deleteFeatureGroupItem(listItem)} - onSelect={() => this.editFeatureGroupItem(listItem)} + onDelete={() => this.deleteFeatureGroupItem(listItem, version)} + onSelect={() => this.editFeatureGroupItem(listItem, version)} className='list-editor-item-view' isReadOnlyMode={isReadOnlyMode}>
    @@ -120,17 +133,28 @@ class FeatureGroupListEditorView extends React.Component { } } - closeFeatureGroupsEditor() { - this.props.onCancelFeatureGroupsEditor(); - } - - editFeatureGroupItem(featureGroup) { - this.props.onEditFeatureGroupClick(featureGroup); + editFeatureGroupItem(featureGroup, version) { + this.props.onEditFeatureGroupClick(featureGroup, version); } - deleteFeatureGroupItem(featureGroup) { - this.props.onDeleteFeatureGroupClick(featureGroup); + 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}); + 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 3776c01263..a2015787a6 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as featureGroupsActionConstants} from './FeatureGroupsConstants.js'; @@ -25,22 +20,22 @@ import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseMod import EntitlementPoolsActionHelper from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js'; import LicenseKeyGroupsActionHelper from 'sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; -function baseUrl(licenseModelId) { +function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/feature-groups`; + const {id: versionId} = version; + return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/feature-groups`; } function fetchFeatureGroupsList(licenseModelId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(licenseModelId)}${versionQuery}`); + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } -function deleteFeatureGroup(licenseModelId, featureGroupId) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId)}/${featureGroupId}`); +function deleteFeatureGroup(licenseModelId, featureGroupId, version) { + return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${featureGroupId}`); } -function addFeatureGroup(licenseModelId, featureGroup) { - return RestAPIUtil.create(baseUrl(licenseModelId), { +function addFeatureGroup(licenseModelId, featureGroup, version) { + return RestAPIUtil.post(baseUrl(licenseModelId, version), { name: featureGroup.name, description: featureGroup.description, partNumber: featureGroup.partNumber, @@ -49,13 +44,13 @@ function addFeatureGroup(licenseModelId, featureGroup) { }); } -function updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup) { +function updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup, version) { const {licenseKeyGroupsIds = []} = featureGroup; const {licenseKeyGroupsIds: prevLicenseKeyGroupsIds = []} = previousFeatureGroup; const {entitlementPoolsIds = []} = featureGroup; const {entitlementPoolsIds: prevEntitlementPoolsIds = []} = previousFeatureGroup; - return RestAPIUtil.save(`${baseUrl(licenseModelId)}/${featureGroup.id}`, { + return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${featureGroup.id}`, { name: featureGroup.name, description: featureGroup.description, partNumber: featureGroup.partNumber, @@ -75,28 +70,37 @@ export default { })); }, - deleteFeatureGroup(dispatch, {licenseModelId, featureGroupId}) { - return deleteFeatureGroup(licenseModelId, featureGroupId).then(() => dispatch({ + deleteFeatureGroup(dispatch, {licenseModelId, featureGroupId, version}) { + return deleteFeatureGroup(licenseModelId, featureGroupId, version).then(() => dispatch({ type: featureGroupsActionConstants.DELETE_FEATURE_GROUPS, featureGroupId })); }, - saveFeatureGroup(dispatch, {licenseModelId, previousFeatureGroup, featureGroup}) { + saveFeatureGroup(dispatch, {licenseModelId, previousFeatureGroup, featureGroup, version}) { if (previousFeatureGroup) { - return updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup).then(() => dispatch({ - type: featureGroupsActionConstants.EDIT_FEATURE_GROUPS, - featureGroup - })); + return updateFeatureGroup(licenseModelId, previousFeatureGroup, featureGroup, version).then(() =>{ + dispatch({ + type: featureGroupsActionConstants.EDIT_FEATURE_GROUPS, + featureGroup + }); + EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); + }); } else { - return addFeatureGroup(licenseModelId, featureGroup).then(response => dispatch({ - type: featureGroupsActionConstants.ADD_FEATURE_GROUPS, - featureGroup: { - ...featureGroup, - id: response.value - } - })); + 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}); + }); } }, @@ -107,23 +111,9 @@ export default { }); }, - selectFeatureGroupsEditorEntitlementPoolsButtonTab(dispatch, {buttonTab}) { - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.SELECTED_ENTITLEMENT_POOLS_BUTTONTAB, - buttonTab - }); - }, - - selectFeatureGroupsEditorLicenseKeyGroupsButtonTab(dispatch, {buttonTab}) { - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB, - buttonTab - }); - }, - - openFeatureGroupsEditor(dispatch, {featureGroup, licenseModelId}) { - EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId}); - LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId}); + openFeatureGroupsEditor(dispatch, {featureGroup, licenseModelId, version}) { + EntitlementPoolsActionHelper.fetchEntitlementPoolsList(dispatch, {licenseModelId, version}); + LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(dispatch, {licenseModelId, version}); dispatch({ type: featureGroupsActionConstants.featureGroupsEditor.OPEN, featureGroup @@ -136,26 +126,6 @@ export default { }); }, - featureGroupsEditorDataChanged(dispatch, {deltaData}) { - dispatch({ - type: featureGroupsActionConstants.featureGroupsEditor.DATA_CHANGED, - deltaData - }); - }, - - hideDeleteConfirm(dispatch) { - dispatch({ - type: featureGroupsActionConstants.FEATURE_GROUPS_DELETE_CONFIRM, - featureGroupToDelete: false - }); - }, - - openDeleteFeatureGroupConfirm(dispatch, {featureGroup}) { - dispatch({ - type: featureGroupsActionConstants.FEATURE_GROUPS_DELETE_CONFIRM, - featureGroupToDelete: featureGroup - }); - }, switchVersion(dispatch, {licenseModelId, version}) { LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConfirmationModal.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConfirmationModal.jsx deleted file mode 100644 index 142ec3c4c8..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConfirmationModal.jsx +++ /dev/null @@ -1,48 +0,0 @@ -import React from 'react'; -import {connect} from 'react-redux'; -import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx'; -import FeatureGroupsActionHelper from './FeatureGroupsActionHelper.js'; -import i18n from 'nfvo-utils/i18n/i18n.js'; - -function renderMsg(featureGroupToDelete) { - let name = featureGroupToDelete ? featureGroupToDelete.name : ''; - let msg = i18n('Are you sure you want to delete "{name}"?', {name}); - let subMsg = featureGroupToDelete - && featureGroupToDelete.referencingLicenseAgreements - && featureGroupToDelete.referencingLicenseAgreements.length > 0 ? - i18n('This feature group is associated with one ore more license agreements') : - ''; - return ( -
    -

    {msg}

    -

    {subMsg}

    -
    - ); -}; - -const mapStateToProps = ({licenseModel: {featureGroup}}, {licenseModelId}) => { - let {featureGroupToDelete} = featureGroup; - const show = featureGroupToDelete !== false; - return { - show, - title: 'Warning!', - type: 'warning', - msg: renderMsg(featureGroupToDelete), - confirmationDetails: {featureGroupToDelete, licenseModelId} - }; -}; - -const mapActionsToProps = (dispatch) => { - return { - onConfirmed: ({featureGroupToDelete, licenseModelId}) => { - FeatureGroupsActionHelper.deleteFeatureGroup(dispatch, {featureGroupId: featureGroupToDelete.id, licenseModelId}); - FeatureGroupsActionHelper.hideDeleteConfirm(dispatch); - }, - onDeclined: () => { - FeatureGroupsActionHelper.hideDeleteConfirm(dispatch); - } - }; -}; - -export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView); - 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 e02c54595d..4c5a94f239 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsConstants.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ @@ -25,8 +20,6 @@ export const actionTypes = keyMirror({ ADD_FEATURE_GROUPS: null, EDIT_FEATURE_GROUPS: null, DELETE_FEATURE_GROUPS: null, - FEATURE_GROUPS_DELETE_CONFIRM: null, - ENTITLEMENT_POOLS_LIST_LOADED: null, @@ -34,27 +27,16 @@ export const actionTypes = keyMirror({ OPEN: null, CLOSE: null, DATA_CHANGED: null, - SELECT_TAB: null, - SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: null, - SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB: 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, - LICENCE_KEY_GROUPS: 3 - }, - SELECTED_ENTITLEMENT_POOLS_BUTTONTAB: { - ASSOCIATED_ENTITLEMENT_POOLS: 1, - AVAILABLE_ENTITLEMENT_POOLS: 2 - }, - SELECTED_LICENSE_KEY_GROUPS_BUTTONTAB: { - ASSOCIATED_LICENSE_KEY_GROUPS: 1, - AVAILABLE_LICENSE_KEY_GROUPS: 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 576a5358e6..001bd20d44 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsEditorReducer.js @@ -1,24 +1,20 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './FeatureGroupsConstants.js'; +import {actionTypes, FG_EDITOR_FORM, state as FeatureGroupStateConstants} from './FeatureGroupsConstants.js'; @@ -27,14 +23,28 @@ export default (state = {}, action) => { case actionTypes.featureGroupsEditor.OPEN: return { ...state, - data: action.featureGroup || {} - }; - case actionTypes.featureGroupsEditor.DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData + data: action.featureGroup || {}, + formReady: null, + formName: FG_EDITOR_FORM, + genericFieldInfo: { + 'description': { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}, {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 + }, + 'name': { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}, {type: 'maxLength', data: 120}], + tabId: FeatureGroupStateConstants.SELECTED_FEATURE_GROUP_TAB.GENERAL + } } }; case actionTypes.featureGroupsEditor.CLOSE: 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 5cf3248919..3b5f1c55e4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './FeatureGroupsConstants.js'; export default (state = [], action) => { switch (action.type) { 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 9616b60b76..efc4fb758f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js @@ -1,41 +1,36 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as licenseAgreementActionTypes} from './LicenseAgreementConstants.js'; import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js'; import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; -function baseUrl(licenseModelId) { +function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/license-agreements`; + const {id: versionId} = version; + return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/license-agreements`; } function fetchLicenseAgreementList(licenseModelId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(licenseModelId)}${versionQuery}`); + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } -function postLicenseAgreement(licenseModelId, licenseAgreement) { - return RestAPIUtil.create(baseUrl(licenseModelId), { +function postLicenseAgreement(licenseModelId, licenseAgreement, version) { + return RestAPIUtil.post(baseUrl(licenseModelId, version), { name: licenseAgreement.name, description: licenseAgreement.description, licenseTerm: licenseAgreement.licenseTerm, @@ -44,10 +39,10 @@ function postLicenseAgreement(licenseModelId, licenseAgreement) { }); } -function putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAgreement) { +function putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAgreement, version) { const {featureGroupsIds = []} = licenseAgreement; const {featureGroupsIds: prevFeatureGroupsIds = []} = previousLicenseAgreement; - return RestAPIUtil.save(`${baseUrl(licenseModelId)}/${licenseAgreement.id}`, { + return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${licenseAgreement.id}`, { name: licenseAgreement.name, description: licenseAgreement.description, licenseTerm: licenseAgreement.licenseTerm, @@ -57,8 +52,8 @@ function putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAg }); } -function deleteLicenseAgreement(licenseModelId, licenseAgreementId) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId)}/${licenseAgreementId}`); +function deleteLicenseAgreement(licenseModelId, licenseAgreementId, version) { + return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${licenseAgreementId}`); } export default { @@ -70,21 +65,14 @@ export default { })); }, - openLicenseAgreementEditor(dispatch, {licenseModelId, licenseAgreement}) { - FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId}); + openLicenseAgreementEditor(dispatch, {licenseModelId, licenseAgreement, version}) { + FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version}); dispatch({ type: licenseAgreementActionTypes.licenseAgreementEditor.OPEN, licenseAgreement }); }, - licenseAgreementEditorDataChanged(dispatch, {deltaData}) { - dispatch({ - type: licenseAgreementActionTypes.licenseAgreementEditor.DATA_CHANGED, - deltaData - }); - }, - closeLicenseAgreementEditor(dispatch) { dispatch({ type: licenseAgreementActionTypes.licenseAgreementEditor.CLOSE @@ -92,9 +80,9 @@ export default { }, - saveLicenseAgreement(dispatch, {licenseModelId, previousLicenseAgreement, licenseAgreement}) { + saveLicenseAgreement(dispatch, {licenseModelId, previousLicenseAgreement, licenseAgreement, version}) { if (previousLicenseAgreement) { - return putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAgreement).then(() => { + return putLicenseAgreement(licenseModelId, previousLicenseAgreement, licenseAgreement, version).then(() => { dispatch({ type: licenseAgreementActionTypes.EDIT_LICENSE_AGREEMENT, licenseAgreement @@ -102,7 +90,7 @@ export default { }); } else { - return postLicenseAgreement(licenseModelId, licenseAgreement).then(response => { + return postLicenseAgreement(licenseModelId, licenseAgreement, version).then(response => { dispatch({ type: licenseAgreementActionTypes.ADD_LICENSE_AGREEMENT, licenseAgreement: { @@ -114,8 +102,8 @@ export default { } }, - deleteLicenseAgreement(dispatch, {licenseModelId, licenseAgreementId}) { - return deleteLicenseAgreement(licenseModelId, licenseAgreementId).then(() => { + deleteLicenseAgreement(dispatch, {licenseModelId, licenseAgreementId, version}) { + return deleteLicenseAgreement(licenseModelId, licenseAgreementId, version).then(() => { dispatch({ type: licenseAgreementActionTypes.DELETE_LICENSE_AGREEMENT, licenseAgreementId @@ -130,31 +118,9 @@ export default { }); }, - selectLicenseAgreementEditorFeatureGroupsButtonTab(dispatch, {buttonTab}) { - dispatch({ - type: licenseAgreementActionTypes.licenseAgreementEditor.SELECT_FEATURE_GROUPS_BUTTONTAB, - buttonTab - }); - }, - - hideDeleteConfirm(dispatch) { - dispatch({ - type: licenseAgreementActionTypes.LICENSE_AGREEMENT_DELETE_CONFIRM, - licenseAgreementToDelete: false - }); - }, - - openDeleteLicenseAgreementConfirm(dispatch, {licenseAgreement} ) { - dispatch({ - type: licenseAgreementActionTypes.LICENSE_AGREEMENT_DELETE_CONFIRM, - licenseAgreementToDelete: licenseAgreement - }); - }, - switchVersion(dispatch, {licenseModelId, version}) { LicenseModelActionHelper.fetchLicenseModelById(dispatch, {licenseModelId, version}).then(() => { this.fetchLicenseAgreementList(dispatch, {licenseModelId, version}); }); } }; - diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConfirmationModal.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConfirmationModal.jsx deleted file mode 100644 index 42f2407696..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConfirmationModal.jsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from 'react'; -import {connect} from 'react-redux'; -import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx'; -import LicenseAgreementActionHelper from './LicenseAgreementActionHelper.js'; -import i18n from 'nfvo-utils/i18n/i18n.js'; - -function renderMsg(licenseAgreementToDelete) { - let name = licenseAgreementToDelete ? licenseAgreementToDelete.name : ''; - let msg = i18n('Are you sure you want to delete "{name}"?', {name}); - return( -
    -

    {msg}

    -
    - ); -}; - -const mapStateToProps = ({licenseModel: {licenseAgreement}}, {licenseModelId}) => { - let {licenseAgreementToDelete} = licenseAgreement; - const show = licenseAgreementToDelete !== false; - return { - show, - title: 'Warning!', - type: 'warning', - msg: renderMsg(licenseAgreementToDelete), - confirmationDetails: {licenseAgreementToDelete, licenseModelId} - }; -}; - -const mapActionsToProps = (dispatch) => { - return { - onConfirmed: ({licenseAgreementToDelete, licenseModelId}) => { - - LicenseAgreementActionHelper.deleteLicenseAgreement(dispatch, {licenseModelId, licenseAgreementId: licenseAgreementToDelete.id}); - LicenseAgreementActionHelper.hideDeleteConfirm(dispatch); - }, - onDeclined: () => { - LicenseAgreementActionHelper.hideDeleteConfirm(dispatch); - } - }; -}; - -export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView); - 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 af5c454e22..998d5f0e8d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementConstants.js @@ -1,52 +1,43 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; +import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; export const actionTypes = keyMirror({ LICENSE_AGREEMENT_LIST_LOADED: null, ADD_LICENSE_AGREEMENT: null, EDIT_LICENSE_AGREEMENT: null, DELETE_LICENSE_AGREEMENT: null, - LICENSE_AGREEMENT_DELETE_CONFIRM: null, licenseAgreementEditor: { OPEN: null, CLOSE: null, DATA_CHANGED: null, - SELECT_TAB: null, - SELECT_FEATURE_GROUPS_BUTTONTAB: 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_FEATURE_GROUPS_BUTTONTAB: { - ASSOCIATED_FEATURE_GROUPS: 1, - AVAILABLE_FEATURE_GROUPS: 2 } }); @@ -64,3 +55,11 @@ export const optionsInputValues = { {enum: 'Unlimited', title: 'Unlimited'} ] }; + +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) : ''; +}; 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 6a3e4dbc73..aada8ddca1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditor.js @@ -1,31 +1,29 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 LicenseAgreementActionHelper from './LicenseAgreementActionHelper.js'; import LicenseAgreementEditorView from './LicenseAgreementEditorView.jsx'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; export const mapStateToProps = ({licenseModel: {licenseAgreement, featureGroup}}) => { - let {data, selectedTab, selectedFeatureGroupsButtonTab} = licenseAgreement.licenseAgreementEditor; + let {data, selectedTab, genericFieldInfo, formReady} = licenseAgreement.licenseAgreementEditor; + const list = licenseAgreement.licenseAgreementList; + const LANames = {}; let previousData; const licenseAgreementId = data ? data.id : null; @@ -33,27 +31,47 @@ export const mapStateToProps = ({licenseModel: {licenseAgreement, featureGroup}} previousData = licenseAgreement.licenseAgreementList.find(licenseAgreement => licenseAgreement.id === licenseAgreementId); } + for (let i = 0; i < list.length; i++) { + LANames[list[i].name] = list[i].id; + } + 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, - selectedFeatureGroupsButtonTab, - featureGroupsList + featureGroupsList, + LANames, + genericFieldInfo, + isFormValid, + formReady, + invalidTabs }; }; -export const mapActionsToProps = (dispatch, {licenseModelId}) => { +export const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { - onDataChanged: deltaData => LicenseAgreementActionHelper.licenseAgreementEditorDataChanged(dispatch, {deltaData}), + onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), onTabSelect: tab => LicenseAgreementActionHelper.selectLicenseAgreementEditorTab(dispatch, {tab}), - onFeatureGroupsButtonTabSelect: buttonTab => LicenseAgreementActionHelper.selectLicenseAgreementEditorFeatureGroupsButtonTab(dispatch, {buttonTab}), onCancel: () => LicenseAgreementActionHelper.closeLicenseAgreementEditor(dispatch), onSubmit: ({previousLicenseAgreement, licenseAgreement}) => { LicenseAgreementActionHelper.closeLicenseAgreementEditor(dispatch); - LicenseAgreementActionHelper.saveLicenseAgreement(dispatch, {licenseModelId, previousLicenseAgreement, licenseAgreement}); - } + LicenseAgreementActionHelper.saveLicenseAgreement(dispatch, {licenseModelId, previousLicenseAgreement, licenseAgreement, version}); + }, + onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) }; }; 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 74e2f6e8c1..e02935c579 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorReducer.js @@ -1,40 +1,55 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes, defaultState} from './LicenseAgreementConstants.js'; +import {actionTypes, defaultState, LA_EDITOR_FORM, enums as LicenseAgreementEnums} from './LicenseAgreementConstants.js'; 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: 'required', data: true}, {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: [], + 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.DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData - } - }; case actionTypes.licenseAgreementEditor.CLOSE: return {}; case actionTypes.licenseAgreementEditor.SELECT_TAB: @@ -42,11 +57,6 @@ export default (state = {}, action) => { ...state, selectedTab: action.tab }; - case actionTypes.licenseAgreementEditor.SELECT_FEATURE_GROUPS_BUTTONTAB: - return { - ...state, - selectedFeatureGroupsButtonTab: action.buttonTab - }; 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 b21f943fed..67a3333a3a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementEditorView.jsx @@ -1,17 +1,36 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; -import ButtonGroup from 'react-bootstrap/lib/ButtonGroup.js'; -import Button from 'react-bootstrap/lib/Button.js'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationTabs from 'nfvo-components/input/validation/ValidationTabs.jsx'; -import ValidationTab from 'nfvo-components/input/validation/ValidationTab.jsx'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; + +import GridSection from 'nfvo-components/grid/GridSection.jsx'; +import GridItem from 'nfvo-components/grid/GridItem.jsx'; +import Form from 'nfvo-components/input/validation/Form.jsx'; +import Tabs from 'nfvo-components/input/validation/Tabs.jsx'; +import Tab from 'react-bootstrap/lib/Tab.js'; +import Input from 'nfvo-components/input/validation/Input.jsx'; import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx'; -import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; -import ListEditorViewItem from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; +import Validator from 'nfvo-utils/Validator.js'; -import {enums as LicenseAgreementEnums, optionsInputValues as LicenseAgreementOptionsInputValues} 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') +}; const LicenseAgreementPropType = React.PropTypes.shape({ id: React.PropTypes.string, @@ -19,14 +38,77 @@ const LicenseAgreementPropType = React.PropTypes.shape({ description: React.PropTypes.string, requirementsAndConstrains: React.PropTypes.string, licenseTerm: React.PropTypes.object, - featureGroupsIds: React.PropTypes.arrayOf(React.PropTypes.string) + featureGroupsIds: React.PropTypes.arrayOf(React.PropTypes.string), + version: React.PropTypes.object }); + +const GeneralTabContent = ({data, genericFieldInfo, onDataChanged, validateName, validateLTChoice}) => { + 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'/> + { + const selectedIndex = e.target.selectedIndex; + const licenseTerm = e.target.options[selectedIndex].value; + onDataChanged({licenseTerm:{choice: licenseTerm, other: ''}}, LA_EDITOR_FORM, { licenseTerm: validateLTChoice }); + }} + isValid={genericFieldInfo.licenseTerm.isValid} + errorText={genericFieldInfo.licenseTerm.errorText} + className='input-options-select' + groupClassName='bootstrap-input-options' + data-test-id='create-la-license-term' > + {LicenseAgreementOptionsInputValues.LICENSE_MODEL_TYPE.map(mtype => + )} + + + + onDataChanged({description}, LA_EDITOR_FORM)} + label={i18n('Description')} + value={description} + overlayPos='bottom' + data-test-id='create-la-description' + name='license-agreement-description' + isRequired={true} + type='textarea'/> + + + ); +}; + class LicenseAgreementEditorView extends React.Component { static propTypes = { data: LicenseAgreementPropType, previousData: LicenseAgreementPropType, + LANames: React.PropTypes.object, isReadOnlyMode: React.PropTypes.bool, onDataChanged: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired, @@ -42,7 +124,6 @@ class LicenseAgreementEditorView extends React.Component { static defaultProps = { selectedTab: LicenseAgreementEnums.SELECTED_LICENSE_AGREEMENT_TAB.GENERAL, - selectedFeatureGroupsButtonTab: LicenseAgreementEnums.SELECTED_FEATURE_GROUPS_BUTTONTAB.AVAILABLE_FEATURE_GROUPS, data: {} }; @@ -51,21 +132,44 @@ class LicenseAgreementEditorView extends React.Component { }; render() { - let {selectedTab, onTabSelect, isReadOnlyMode} = this.props; + let {selectedTab, onTabSelect, isReadOnlyMode, featureGroupsList, data, onDataChanged, genericFieldInfo} = this.props; return ( - this.submit() } - onReset={ () => this.props.onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - className='license-agreement-form'> - - {this.renderGeneralTab()} - {this.renderFeatureGroupsTab()} - - +
    + {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-agreement-form'> + + + this.validateLTChoice(value)} + validateName={(value)=>this.validateName(value)}/> + + + {featureGroupsList.length > 0 ? + onDataChanged( { featureGroupsIds: selectedValuesList }, LA_EDITOR_FORM )}/> : +

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

    } +
    +
    +
    } +
    ); } @@ -74,173 +178,19 @@ class LicenseAgreementEditorView extends React.Component { this.props.onSubmit({licenseAgreement, previousLicenseAgreement}); } - renderGeneralTab() { - let {data = {}, onDataChanged} = this.props; - let {name, description, requirementsAndConstrains, licenseTerm} = data; - return ( - -
    -
    - onDataChanged({name})} - label={i18n('Name')} - value={name} - name='license-agreement-name' - validations={{maxLength: 25, required: true}} - type='text'/> - onDataChanged({requirementsAndConstrains})} - label={i18n('Requirements and Constraints')} - value={requirementsAndConstrains} - name='license-agreement-requirements-and-constraints' - validations={{maxLength: 1000}} - type='textarea'/> -
    - onDataChanged({description})} - label={i18n('Description')} - value={description} - name='license-agreement-description' - validations={{maxLength: 1000, required: true}} - type='textarea'/> -
    -
    - onDataChanged({licenseTerm:{choice: licenseTerm, other: ''}})} - selectedEnum={licenseTerm && licenseTerm.choice} - validations={{required: true}} - type='select' - label={i18n('License Term')} - values={LicenseAgreementOptionsInputValues.LICENSE_MODEL_TYPE}/> -
    -
    - ); - } - - renderFeatureGroupsTab() { - let {onFeatureGroupsButtonTabSelect, selectedFeatureGroupsButtonTab, featureGroupsList} = this.props; - if (featureGroupsList.length > 0) { - return ( - - - { - this.renderFeatureGroupsButtonTab( - LicenseAgreementEnums.SELECTED_FEATURE_GROUPS_BUTTONTAB.ASSOCIATED_FEATURE_GROUPS, - selectedFeatureGroupsButtonTab, - i18n('Associated Feature Groups'), - onFeatureGroupsButtonTabSelect - ) - } - { - this.renderFeatureGroupsButtonTab( - LicenseAgreementEnums.SELECTED_FEATURE_GROUPS_BUTTONTAB.AVAILABLE_FEATURE_GROUPS, - selectedFeatureGroupsButtonTab, - i18n('Available Feature Groups'), - onFeatureGroupsButtonTabSelect - ) - } - - {this.renderFeatureGroupsButtonTabContent(selectedFeatureGroupsButtonTab)} - - ); - } else { - return ( - -

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

    -
    - ); + validateLTChoice(value) { + if (!value.choice) { + return {isValid: false, errorText: i18n('Field is required')}; } + return {isValid: true, errorText: ''}; } - renderFeatureGroupsButtonTabContent(selectedFeatureGroupsButtonTab) { - const {featureGroupsList = [], data: {featureGroupsIds = []}} = this.props; - const {localFeatureGroupsListFilter} = this.state; - let selectedFeatureGroups = featureGroupsIds.map(featureGroupId => featureGroupsList.find(featureGroup => featureGroup.id === featureGroupId)); - - const dualBoxFilterTitle = { - left: i18n('Available Feature Groups'), - right: i18n('Selected Feature Groups') - }; - - switch (selectedFeatureGroupsButtonTab) { - case LicenseAgreementEnums.SELECTED_FEATURE_GROUPS_BUTTONTAB.ASSOCIATED_FEATURE_GROUPS: - if (!selectedFeatureGroups.length) { - return ( -
    - {i18n('There are currently no feature groups associated with this license agreement. Click "Available Feature Groups" to associate.')} -
    - ); - } - if (featureGroupsList.length) { - return ( - this.setState({localFeatureGroupsListFilter})}> - {this.filterAssociatedFeatureGroupsList(selectedFeatureGroups).map(featureGroup => this.renderAssociatedFeatureGroupListItem(featureGroup))} - - ); - } - return; - case LicenseAgreementEnums.SELECTED_FEATURE_GROUPS_BUTTONTAB.AVAILABLE_FEATURE_GROUPS: - return ( - this.props.onDataChanged( { featureGroupsIds: selectedValuesList } )}/> - ); - } - } + validateName(value) { + const {data: {id}, LANames} = this.props; + const isExists = Validator.isItemNameAlreadyExistsInList({itemId: id, itemName: value, list: LANames}); - renderFeatureGroupsButtonTab(buttonTab, selectedButtonTab, title, onClick) { - const isSelected = buttonTab === selectedButtonTab; - return ( - - ); - } - - renderAssociatedFeatureGroupListItem({id, name, entitlementPoolsIds = [], licenseKeyGroupsIds = []}) { - const {onDataChanged, data: {featureGroupsIds}, isReadOnlyMode} = this.props; - return ( - onDataChanged({featureGroupsIds: featureGroupsIds.filter(featureGroupId => featureGroupId !== id)})} - isReadOnlyMode={isReadOnlyMode}> -
    {name}
    -
    { - i18n( - 'Entitlement Pools({entitlementPoolsCounter}), License Key Groups({licenseKeyGroupsCount})', - { - entitlementPoolsCounter: entitlementPoolsIds.length, - licenseKeyGroupsCount: licenseKeyGroupsIds.length - } - ) - }
    -
    - ); - } - - filterAssociatedFeatureGroupsList(featureGroupsList) { - let {localFeatureGroupsListFilter} = this.state; - if (localFeatureGroupsListFilter) { - const filter = new RegExp(escape(localFeatureGroupsListFilter), 'i'); - return featureGroupsList.filter(({name}) => name.match(filter)); - } - else { - return featureGroupsList; - } + return !isExists ? {isValid: true, errorText: ''} : + {isValid: false, errorText: i18n('License Agreement by the name \'' + value + '\' already exists. License agreement name must be unique')}; } } 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 ca18bfab79..373694f2bf 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditor.js @@ -1,39 +1,35 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; import LicenseAgreementActionHelper from './LicenseAgreementActionHelper.js'; import LicenseAgreementListEditorView from './LicenseAgreementListEditorView.jsx'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; -import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.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} = licenseModelEditor.data; + let {vendorName, version} = licenseModelEditor.data; let isReadOnlyMode = VersionControllerUtils.isReadOnly(licenseModelEditor.data); return { vendorName, + version, licenseAgreementList, isReadOnlyMode, isDisplayModal: Boolean(data), @@ -43,16 +39,16 @@ const mapStateToProps = ({licenseModel: {licenseAgreement, licenseModelEditor}}) const mapActionsToProps = (dispatch, {licenseModelId}) => { return { - onAddLicenseAgreementClick: () => LicenseAgreementActionHelper.openLicenseAgreementEditor(dispatch, {licenseModelId}), - onEditLicenseAgreementClick: licenseAgreement => LicenseAgreementActionHelper.openLicenseAgreementEditor(dispatch, {licenseModelId, licenseAgreement}), - onDeleteLicenseAgreement: licenseAgreement => LicenseAgreementActionHelper.openDeleteLicenseAgreementConfirm(dispatch, {licenseAgreement}), - onCallVCAction: action => { - LicenseModelActionHelper.performVCAction(dispatch, {licenseModelId, action}).then(() => { - LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId}); - }); - }, - switchLicenseModelVersion: version => LicenseAgreementActionHelper.switchVersion(dispatch, {licenseModelId, version}), - onClose: () => OnboardingActionHelper.navigateToOnboardingCatalog(dispatch) + 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}), + title: i18n('Warning'), + onConfirmed: ()=>LicenseAgreementActionHelper.deleteLicenseAgreement(dispatch, {licenseModelId, licenseAgreementId: licenseAgreement.id, version}) + } + }) }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx index 4d7e704ba3..776b04b8eb 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListEditorView.jsx @@ -1,15 +1,26 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; - import i18n from 'nfvo-utils/i18n/i18n.js'; 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 InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; -import {optionsInputValues} from './LicenseAgreementConstants'; -import LicenseAgreementConfirmationModal from './LicenseAgreementConfirmationModal.jsx'; - +import {extractValue} from './LicenseAgreementConstants'; class LicenseAgreementListEditorView extends React.Component { static propTypes = { @@ -22,7 +33,6 @@ class LicenseAgreementListEditorView extends React.Component { onAddLicenseAgreementClick: React.PropTypes.func, onEditLicenseAgreementClick: React.PropTypes.func, onDeleteLicenseAgreement: React.PropTypes.func, - onCallVCAction: React.PropTypes.func }; static defaultProps = { @@ -34,35 +44,33 @@ class LicenseAgreementListEditorView extends React.Component { }; render() { - const {licenseModelId, vendorName, isReadOnlyMode, isDisplayModal, isModalInEditMode} = this.props; + const {licenseModelId, vendorName, isReadOnlyMode, isDisplayModal, isModalInEditMode, version} = this.props; const {onAddLicenseAgreementClick} = this.props; const {localFilter} = this.state; return (
    - this.setState({localFilter: filter})} - isReadOnlyMode={isReadOnlyMode}> - {this.filterList().map(licenseAgreement => this.renderLicenseAgreementListItem(licenseAgreement, isReadOnlyMode))} - - + 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 && ( - + ) } - -
    ); } @@ -73,7 +81,7 @@ class LicenseAgreementListEditorView extends React.Component { 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(this.extractValue(licenseTerm)).match(filter); + return escape(name).match(filter) || escape(description).match(filter) || escape(extractValue(licenseTerm)).match(filter); }); } else { @@ -81,14 +89,14 @@ class LicenseAgreementListEditorView extends React.Component { } } - renderLicenseAgreementListItem(licenseAgreement, isReadOnlyMode) { + renderLicenseAgreementListItem(licenseAgreement, isReadOnlyMode, version) { let {id, name, description, licenseTerm, featureGroupsIds = []} = licenseAgreement; let {onEditLicenseAgreementClick, onDeleteLicenseAgreement} = this.props; return ( onEditLicenseAgreementClick(licenseAgreement)} - onDelete={() => onDeleteLicenseAgreement(licenseAgreement)} + onSelect={() => onEditLicenseAgreementClick(licenseAgreement, version)} + onDelete={() => onDeleteLicenseAgreement(licenseAgreement, version)} className='list-editor-item-view' isReadOnlyMode={isReadOnlyMode}>
    @@ -98,7 +106,7 @@ class LicenseAgreementListEditorView extends React.Component {
    {i18n('Type')}
    -
    {this.extractValue(licenseTerm)}
    +
    {extractValue(licenseTerm)}
    {i18n('Feature')}
    @@ -113,14 +121,6 @@ class LicenseAgreementListEditorView extends React.Component { ); } - - extractValue(item) { - if (item === undefined) { - return ''; - } //TODO fix it later - - return item ? item.choice === optionInputOther.OTHER ? item.other : InputOptions.getTitleByName(optionsInputValues, item.choice) : ''; - } } 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 5b5fa00df1..e6a8f34b58 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes as licenseAgreementActionTypes} from './LicenseAgreementConstants'; export default (state = [], action) => { 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 50ac2c85a3..dd2a5c6003 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js @@ -1,44 +1,39 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes as licenseKeyGroupsConstants} from './LicenseKeyGroupsConstants.js'; import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; -function baseUrl(licenseModelId) { +function baseUrl(licenseModelId, version) { const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/license-key-groups`; + const {id: versionId} = version; + return `${restPrefix}/v1.0/vendor-license-models/${licenseModelId}/versions/${versionId}/license-key-groups`; } function fetchLicenseKeyGroupsList(licenseModelId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(licenseModelId)}${versionQuery}`); + return RestAPIUtil.fetch(`${baseUrl(licenseModelId, version)}`); } -function deleteLicenseKeyGroup(licenseModelId, licenseKeyGroupId) { - return RestAPIUtil.destroy(`${baseUrl(licenseModelId)}/${licenseKeyGroupId}`); +function deleteLicenseKeyGroup(licenseModelId, licenseKeyGroupId, version) { + return RestAPIUtil.destroy(`${baseUrl(licenseModelId, version)}/${licenseKeyGroupId}`); } -function postLicenseKeyGroup(licenseModelId, licenseKeyGroup) { - return RestAPIUtil.create(baseUrl(licenseModelId), { +function postLicenseKeyGroup(licenseModelId, licenseKeyGroup, version) { + return RestAPIUtil.post(baseUrl(licenseModelId, version), { name: licenseKeyGroup.name, description: licenseKeyGroup.description, operationalScope: licenseKeyGroup.operationalScope, @@ -46,8 +41,8 @@ function postLicenseKeyGroup(licenseModelId, licenseKeyGroup) { }); } -function putLicenseKeyGroup(licenseModelId, licenseKeyGroup) { - return RestAPIUtil.save(`${baseUrl(licenseModelId)}/${licenseKeyGroup.id}`, { +function putLicenseKeyGroup(licenseModelId, licenseKeyGroup, version) { + return RestAPIUtil.put(`${baseUrl(licenseModelId, version)}/${licenseKeyGroup.id}`, { name: licenseKeyGroup.name, description: licenseKeyGroup.description, operationalScope: licenseKeyGroup.operationalScope, @@ -77,9 +72,9 @@ export default { }); }, - saveLicenseKeyGroup(dispatch, {licenseModelId, previousLicenseKeyGroup, licenseKeyGroup}) { + saveLicenseKeyGroup(dispatch, {licenseModelId, previousLicenseKeyGroup, licenseKeyGroup, version}) { if (previousLicenseKeyGroup) { - return putLicenseKeyGroup(licenseModelId, licenseKeyGroup).then(() => { + return putLicenseKeyGroup(licenseModelId, licenseKeyGroup, version).then(() => { dispatch({ type: licenseKeyGroupsConstants.EDIT_LICENSE_KEY_GROUP, licenseKeyGroup @@ -87,11 +82,12 @@ export default { }); } else { - return postLicenseKeyGroup(licenseModelId, licenseKeyGroup).then(response => { + return postLicenseKeyGroup(licenseModelId, licenseKeyGroup, version).then(response => { dispatch({ type: licenseKeyGroupsConstants.ADD_LICENSE_KEY_GROUP, licenseKeyGroup: { ...licenseKeyGroup, + referencingFeatureGroups: [], id: response.value } }); @@ -101,8 +97,8 @@ export default { }, - deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId}){ - return deleteLicenseKeyGroup(licenseModelId, licenseKeyGroupId).then(()=> { + deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId, version}){ + return deleteLicenseKeyGroup(licenseModelId, licenseKeyGroupId, version).then(()=> { dispatch({ type: licenseKeyGroupsConstants.DELETE_LICENSE_KEY_GROUP, licenseKeyGroupId @@ -110,13 +106,6 @@ export default { }); }, - licenseKeyGroupEditorDataChanged(dispatch, {deltaData}) { - dispatch({ - type: licenseKeyGroupsConstants.licenseKeyGroupsEditor.DATA_CHANGED, - deltaData - }); - }, - hideDeleteConfirm(dispatch) { dispatch({ type: licenseKeyGroupsConstants.LICENSE_KEY_GROUPS_DELETE_CONFIRM, diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConfirmationModal.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConfirmationModal.jsx deleted file mode 100644 index 2413db51d0..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConfirmationModal.jsx +++ /dev/null @@ -1,49 +0,0 @@ -import React from 'react'; -import {connect} from 'react-redux'; -import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx'; -import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; -import i18n from 'nfvo-utils/i18n/i18n.js'; - -function renderMsg(licenseKeyGroupToDelete) { - let name = licenseKeyGroupToDelete ? licenseKeyGroupToDelete.name : ''; - let msg = i18n('Are you sure you want to delete "{name}"?', {name}); - let subMsg = licenseKeyGroupToDelete - && licenseKeyGroupToDelete.referencingFeatureGroups - && licenseKeyGroupToDelete.referencingFeatureGroups.length > 0 ? - i18n('This license key group is associated with one or more feature groups') : - ''; - return( -
    -

    {msg}

    -

    {subMsg}

    -
    - ); -}; - -const mapStateToProps = ({licenseModel: {licenseKeyGroup}}, {licenseModelId}) => { - let {licenseKeyGroupToDelete} = licenseKeyGroup; - const show = licenseKeyGroupToDelete !== false; - return { - show, - title: 'Warning!', - type: 'warning', - msg: renderMsg(licenseKeyGroupToDelete), - confirmationDetails: {licenseKeyGroupToDelete, licenseModelId} - }; -}; - -const mapActionsToProps = (dispatch) => { - return { - onConfirmed: ({licenseKeyGroupToDelete, licenseModelId}) => { - - LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId:licenseKeyGroupToDelete.id}); - LicenseKeyGroupsActionHelper.hideDeleteConfirm(dispatch); - }, - onDeclined: () => { - LicenseKeyGroupsActionHelper.hideDeleteConfirm(dispatch); - } - }; -}; - -export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView); - 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 d32bc52744..50d1fe8625 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsConstants.js @@ -1,25 +1,21 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; +import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; export const actionTypes = keyMirror({ @@ -42,6 +38,8 @@ export const defaultState = { } }; +export const LKG_FORM_NAME = 'LKGFORM'; + export const optionsInputValues = { OPERATIONAL_SCOPE: [ {enum: '', title: i18n('please select…')}, @@ -61,4 +59,21 @@ export const optionsInputValues = { ] }; +export const extractValue = (item) => { + if (item === undefined) {return '';} //TODO fix it later + + 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; + } +}; 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 3940ec594a..aef1532dc1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditor.js @@ -1,52 +1,60 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; import LicenseKeyGroupsEditorView from './LicenseKeyGroupsEditorView.jsx'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; const mapStateToProps = ({licenseModel: {licenseKeyGroup}}) => { - let {data} = licenseKeyGroup.licenseKeyGroupsEditor; + let {data, genericFieldInfo, formReady} = licenseKeyGroup.licenseKeyGroupsEditor; - let previousData; + let previousData, LKGNames = {}; const licenseKeyGroupId = data ? data.id : null; if(licenseKeyGroupId) { previousData = licenseKeyGroup.licenseKeyGroupsList.find(licenseKeyGroup => licenseKeyGroup.id === licenseKeyGroupId); } + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + + const list = licenseKeyGroup.licenseKeyGroupsList; + for (let i = 0; i < list.length; i++) { + LKGNames[list[i].name] = list[i].id; + } + return { data, - previousData + previousData, + genericFieldInfo, + isFormValid, + formReady, + LKGNames }; }; -const mapActionsToProps = (dispatch, {licenseModelId}) => { +const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { - onDataChanged: deltaData => LicenseKeyGroupsActionHelper.licenseKeyGroupEditorDataChanged(dispatch, {deltaData}), + onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), onCancel: () => LicenseKeyGroupsActionHelper.closeLicenseKeyGroupEditor(dispatch), onSubmit: ({previousLicenseKeyGroup, licenseKeyGroup}) => { LicenseKeyGroupsActionHelper.closeLicenseKeyGroupEditor(dispatch); - LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(dispatch, {licenseModelId, previousLicenseKeyGroup, licenseKeyGroup}); - } + LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(dispatch, {licenseModelId, previousLicenseKeyGroup, licenseKeyGroup, version}); + }, + onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) }; }; 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 a74498269a..090c971c65 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorReducer.js @@ -1,42 +1,53 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes, defaultState} from './LicenseKeyGroupsConstants.js'; +import {actionTypes, defaultState, LKG_FORM_NAME} from './LicenseKeyGroupsConstants.js'; export default (state = {}, action) => { switch (action.type) { case actionTypes.licenseKeyGroupsEditor.OPEN: return { ...state, - data: action.licenseKeyGroup ? {...action.licenseKeyGroup} : defaultState.licenseKeyGroupsEditor + data: action.licenseKeyGroup ? {...action.licenseKeyGroup} : defaultState.licenseKeyGroupsEditor, + formReady: null, + formName: LKG_FORM_NAME, + genericFieldInfo: { + 'description' : { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}, {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: [] + } + } }; case actionTypes.licenseKeyGroupsEditor.CLOSE: return {}; - case actionTypes.licenseKeyGroupsEditor.DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData - } - }; 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 102e713060..b95efd0f9c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsEditorView.jsx @@ -1,10 +1,29 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; +import Validator from 'nfvo-utils/Validator.js'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; -import {optionsInputValues as licenseKeyGroupOptionsInputValues} from './LicenseKeyGroupsConstants.js'; -import {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; +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} from './LicenseKeyGroupsConstants.js'; +import {other as optionInputOther} from 'nfvo-components/input/validation/InputOptions.jsx'; +import InputOptions from 'nfvo-components/input/validation/InputOptions.jsx'; const LicenseKeyGroupPropType = React.PropTypes.shape({ id: React.PropTypes.string, @@ -17,10 +36,80 @@ const LicenseKeyGroupPropType = React.PropTypes.shape({ type: React.PropTypes.string }); +const LicenseKeyGroupFormContent = ({data, onDataChanged, genericFieldInfo, validateName, validateOperationalScope}) => { + let {name, description, operationalScope, type} = 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} + isRequired={true} + onEnumChange={operationalScope => onDataChanged({operationalScope:{choices: operationalScope, other: ''}}, + LKG_FORM_NAME, {operationalScope: validateOperationalScope})} + onOtherChange={operationalScope => onDataChanged({operationalScope:{choices: [optionInputOther.OTHER], + other: operationalScope}}, LKG_FORM_NAME, {operationalScope: validateOperationalScope})} + 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} + isRequired={true} + 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' + type='select' > + { + licenseKeyGroupOptionsInputValues.TYPE.map(type => + ()) + } + + + + ); +}; + class LicenseKeyGroupsEditorView extends React.Component { static propTypes = { data: LicenseKeyGroupPropType, previousData: LicenseKeyGroupPropType, + LKGNames: React.PropTypes.object, isReadOnlyMode: React.PropTypes.bool, onDataChanged: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired, @@ -32,54 +121,29 @@ class LicenseKeyGroupsEditorView extends React.Component { }; render() { - let {data = {}, onDataChanged, isReadOnlyMode} = this.props; - let {name, description, operationalScope, type} = data; + let {data = {}, onDataChanged, isReadOnlyMode, genericFieldInfo} = this.props; return ( - + { genericFieldInfo && +
    this.submit() } onReset={ () => this.props.onCancel() } + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => this.props.onValidateForm(LKG_FORM_NAME) } labledButtons={true} isReadOnlyMode={isReadOnlyMode} className='license-key-groups-form'> -
    - onDataChanged({name})} - ref='name' - label={i18n('Name')} - value={name} - validations={{maxLength: 120, required: true}} - type='text'/> - onDataChanged({operationalScope:{choices: operationalScope, other: ''}})} - onOtherChange={operationalScope => onDataChanged({operationalScope:{choices: [optionInputOther.OTHER], other: operationalScope}})} - label={i18n('Operational Scope')} - validations={{required: true}} - multiSelectedEnum={operationalScope && operationalScope.choices} - otherValue={operationalScope && operationalScope.other} - values={licenseKeyGroupOptionsInputValues.OPERATIONAL_SCOPE}/> -
    -
    - onDataChanged({description})} - ref='description' - label={i18n('Description')} - value={description} - validations={{maxLength: 1000, required: true}} - type='textarea'/> - onDataChanged({type})} - selectedEnum={type} - label={i18n('Type')} - type='select' - validations={{required: true}} - values={licenseKeyGroupOptionsInputValues.TYPE}/> -
    - + this.validateName(value)} + validateOperationalScope={this.validateOperationalScope}/> + } +
    ); } @@ -87,6 +151,37 @@ class LicenseKeyGroupsEditorView extends React.Component { const {data: licenseKeyGroup, previousData: previousLicenseKeyGroup} = this.props; this.props.onSubmit({licenseKeyGroup, previousLicenseKeyGroup}); } + + 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')}; + } + + validateOperationalScope(value) { + if (value && value.choices && value.choices.length > 0) { + if (value.choices[0] !== optionInputOther.OTHER) + { + return { + isValid: true, + errorText: '' + }; + } else { + if ( value.other ) { + return { + isValid: true, + errorText: '' + }; + } + } + } + return { + isValid: false, + errorText: 'Field is required' + }; + } } export default LicenseKeyGroupsEditorView; 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 e1b610f973..e2c6c30e21 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditor.js @@ -1,27 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 i18n from 'nfvo-utils/i18n/i18n.js'; import LicenseKeyGroupsActionHelper from './LicenseKeyGroupsActionHelper.js'; -import LicenseKeyGroupsListEditorView from './LicenseKeyGroupsListEditorView.jsx'; +import LicenseKeyGroupsListEditorView, {generateConfirmationMsg} from './LicenseKeyGroupsListEditorView.jsx'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import {actionTypes as globalMoadlActions} from 'nfvo-components/modal/GlobalModalConstants.js'; const mapStateToProps = ({licenseModel: {licenseKeyGroup, licenseModelEditor}}) => { let {licenseKeyGroupsList} = licenseKeyGroup; @@ -38,11 +35,18 @@ const mapStateToProps = ({licenseModel: {licenseKeyGroup, licenseModelEditor}}) }; }; -const mapActionsToProps = (dispatch) => { +const mapActionsToProps = (dispatch, {licenseModelId, version}) => { return { onAddLicenseKeyGroupClick: () => LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch), onEditLicenseKeyGroupClick: licenseKeyGroup => LicenseKeyGroupsActionHelper.openLicenseKeyGroupsEditor(dispatch, {licenseKeyGroup}), - onDeleteLicenseKeyGroupClick: licenseKeyGroup => LicenseKeyGroupsActionHelper.openDeleteLicenseAgreementConfirm(dispatch, {licenseKeyGroup}) + onDeleteLicenseKeyGroupClick: licenseKeyGroup => dispatch({ + type: globalMoadlActions.GLOBAL_MODAL_WARNING, + data:{ + msg: generateConfirmationMsg(licenseKeyGroup), + title: i18n('Warning'), + onConfirmed: ()=>LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(dispatch, {licenseModelId, licenseKeyGroupId:licenseKeyGroup.id, version}) + } + }) }; }; 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 1ed1d2093a..a303e46706 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListEditorView.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; @@ -8,8 +23,6 @@ import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.js import LicenseKeyGroupsEditor from './LicenseKeyGroupsEditor.js'; import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/InputOptions.jsx'; import {optionsInputValues} from './LicenseKeyGroupsConstants'; -import LicenseKeyGroupsConfirmationModal from './LicenseKeyGroupsConfirmationModal.jsx'; - class LicenseKeyGroupsListEditorView extends React.Component { static propTypes = { @@ -33,35 +46,33 @@ class LicenseKeyGroupsListEditorView extends React.Component { }; render() { - let {licenseModelId, vendorName, isReadOnlyMode, isDisplayModal, isModalInEditMode} = this.props; + let {licenseModelId, vendorName, isReadOnlyMode, isDisplayModal, isModalInEditMode, version} = this.props; let {onAddLicenseKeyGroupClick} = this.props; const {localFilter} = this.state; return (
    this.setState({localFilter: filter})} + onFilter={value => 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 && ( - + ) } - -
    ); } @@ -134,5 +145,17 @@ class LicenseKeyGroupsListEditorView extends React.Component { export default LicenseKeyGroupsListEditorView; - - +export function generateConfirmationMsg(licenseKeyGroupToDelete) { + let name = licenseKeyGroupToDelete ? licenseKeyGroupToDelete.name : ''; + let msg = i18n('Are you sure you want to delete "{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 54ce4e3955..1f0a64e295 100644 --- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './LicenseKeyGroupsConstants.js'; export default (state = [], action) => { switch (action.type) { diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js new file mode 100644 index 0000000000..1ca4f37988 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js @@ -0,0 +1,163 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js'; +import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import LicenseModelOverviewView from './LicenseModelOverviewView.jsx'; +import {overviewEditorHeaders, selectedButton} from './LicenseModelOverviewConstants.js'; +import licenseModelOverviewActionHelper from './licenseModelOverviewActionHelper.js'; + +export const mapStateToProps = ({licenseModel: {licenseModelEditor, entitlementPool, licenseAgreement, featureGroup, licenseKeyGroup, licenseModelOverview}}) => { + + 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; + } + + if (licenseModelOverview.selectedTab === selectedButton.NOT_IN_USE) { + licensingDataList = [ + ...featureGroup.featureGroupsList.reduce(checkFG, []), + ...entitlementPool.entitlementPoolsList.reduce(checkEP, []), + ...licenseKeyGroup.licenseKeyGroupsList.reduce(checkLG, []) + ]; + }else { + licensingDataList = licenseAgreement.licenseAgreementList && licenseAgreement.licenseAgreementList.length ? licenseAgreement.licenseAgreementList.map(mapLicenseAgreementData) : []; + } + + return { + isReadOnlyMode: VersionControllerUtils.isReadOnly(licenseModelEditor.data), + isDisplayModal, + modalHeader, + licenseModelId: licenseModelEditor.data.id, + version: licenseModelEditor.data.version, + licensingDataList, + selectedTab: licenseModelOverview.selectedTab + + }; +}; + +const mapActionsToProps = (dispatch, {licenseModelId}) => { + return { + onCallVCAction: action => { + LicenseModelActionHelper.performVCAction(dispatch, {licenseModelId, action}); + }, + onTabSelect: (buttonTab) => licenseModelOverviewActionHelper.selectVLMListView(dispatch,{buttonTab}) + }; +}; + +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 new file mode 100644 index 0000000000..b5a27ed018 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js @@ -0,0 +1,42 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 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' +}); + +export const overviewEditorHeaders = keyMirror({ + 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 +}); + +export const selectedButton = keyMirror({ + VLM_LIST_VIEW: null, + NOT_IN_USE: null +}); + +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 new file mode 100644 index 0000000000..d6c79ddb52 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx @@ -0,0 +1,105 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import Modal from 'nfvo-components/modal/Modal.jsx'; +import classNames from 'classnames'; + +import EntitlementPoolsEditor from '../entitlementPools/EntitlementPoolsEditor.js'; +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 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 ''; + } +}; + +class LicenseModelOverviewView extends React.Component { + + static propTypes = { + isDisplayModal: React.PropTypes.bool, + isReadOnlyMode: React.PropTypes.bool, + licenseModelId: React.PropTypes.string, + licensingDataList: React.PropTypes.array, + modalHeader: React.PropTypes.string, + selectedTab: React.PropTypes.symbol, + onTabSelect: React.PropTypes.func, + onCallVCAction: React.PropTypes.func, + onClose: React.PropTypes.func + }; + + render() { + let {isDisplayModal, modalHeader, licensingDataList, selectedTab, onTabSelect} = this.props; + let selectedInUse = selectedTab !== selectedButton.NOT_IN_USE; + + return( +
    + +
    +
    +
    {selectedInUse ? i18n('VLM List View') : i18n('Entities not in Use')}
    + +
    + +
    + { + isDisplayModal && + + + {`${i18n('Create New ')}${i18n(modalHeader)}`} + + + {this.renderModalBody(modalHeader)} + + + } +
    + ); + } + + renderModalBody(modalHeader) { + let {licenseModelId, version} = 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; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx new file mode 100644 index 0000000000..6fcdb477e6 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/SummaryView.jsx @@ -0,0 +1,33 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import {default as VendorDataView} from './summary/VendorDataView.js'; +import {default as SummaryCountList} from './summary/SummaryCountList.js'; + +function SummaryView() { + return( +
    +
    {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 new file mode 100644 index 0000000000..119008a849 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/VLMListView.jsx @@ -0,0 +1,123 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component} from 'react'; +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'; + +class VLMListView extends Component { + + static propTypes = { + licensingDataList: React.PropTypes.array, + showInUse: React.PropTypes.bool + }; + + 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; + } + } + + renderLicenseAgreementItem(licenseAgreement) { + return ( +
  • + this.updateCollapsable(event, licenseAgreement.id) }/> + +
      + {licenseAgreement.children && licenseAgreement.children.map(item => this.renderLicensingItem(item))} +
    +
    +
  • + ); + } + + renderFeatureGroupItem(featureGroup) { + const {showInUse} = this.props; + return ( +
  • + this.updateCollapsable(event, featureGroup.id) }/> + { + showInUse && +
      + {featureGroup.children && featureGroup.children.map(item => this.renderLicensingItem(item))} + +
    +
    + } +
  • + ); + } + + renderEntitlementPoolItem(entitlementPool) { + return ( +
  • + +
  • + ); + } + + renderLicenseKeyGroupItem(licenseKeyGroup) { + return ( +
  • + +
  • + ); + } + + 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 new file mode 100644 index 0000000000..f0286ba3bb --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/licenseModelOverviewActionHelper.js @@ -0,0 +1,39 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {actionTypes} from './LicenseModelOverviewConstants.js'; + +export default { + selectVLMListView(dispatch, {buttonTab}) { + dispatch({ + type: actionTypes.LICENSE_MODEL_OVERVIEW_TAB_SELECTED, + buttonTab + }); + }, + + editDescriptionOpen(dispatch, {description}) { + dispatch({ + type: actionTypes.LM_DATA_CHANGED, + description + }); + }, + + editDescriptionClose(dispatch) { + dispatch({ + type: actionTypes.LM_DATA_CHANGED, + description: false + }); + } +}; 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 new file mode 100644 index 0000000000..94977b40d1 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx @@ -0,0 +1,53 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component} from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import {extractValue, 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'; + +class EntitlementPool extends Component { + render() { + let {epData: {name, description, manufacturerReferenceNumber}} = this.props; + return ( +
    + + + + + + + +
    + ); + } + + getEntitlement() { + let {epData: {entitlementMetric, aggregationFunction, time, thresholdValue, thresholdUnits}} = this.props; + return `${extractValue(aggregationFunction)} ${extractValue(entitlementMetric)} per ${extractValue(time)} ${thresholdValue} ${extractUnits(thresholdUnits)}`; + } + +} + +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 new file mode 100644 index 0000000000..8dbd46a29e --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx @@ -0,0 +1,50 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 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'; + +class FeatureGroup extends Component { + render() { + let {fgData: {name, description, children = []}, isCollapsed, onClick} = this.props; + return ( +
    onClick(e)} className='vlm-list-item vlm-list-item-fg' data-test-id='vlm-list-item-fg'> + + + +
    + + Entitlement Pools: + + {`${children.filter(child => child.itemType === overviewEditorHeaders.ENTITLEMENT_POOL).length}`} + + + + 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 new file mode 100644 index 0000000000..dd4686d330 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx @@ -0,0 +1,53 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component} from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import InputOptions, {other as optionInputOther} from 'nfvo-components/input/inputOptions/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'; + +class LicenseAgreement extends Component { + render() { + let {laData: {name, description, licenseTerm, children = []}, isCollapsed, onClick} = this.props; + return ( +
    onClick(e)} className='vlm-list-item vlm-list-item-la' data-test-id='vlm-list-la-item'> + + + +
    + Feature Groups: {`${children.length}`} +
    +
    + + + +
    + ); + } + + extractValue(item) { + if (item === undefined) {return '';} //TODO fix it later + + 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 new file mode 100644 index 0000000000..9722b83336 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx @@ -0,0 +1,48 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component} from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.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'; + +class LicenseKeyGroup extends Component { + render() { + let {lkgData: {name, description, operationalScope, type}} = this.props; + return ( +
    + + + + + + + +
    + ); + } + +} + +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 new file mode 100644 index 0000000000..5b5daafb4f --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/AdditionalDataCol.jsx @@ -0,0 +1,51 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; + +function AdditionalDataCol({children}) { + return ( +
    +
    +
    + {children} +
    +
    + ); +} + +AdditionalDataCol.propTypes = { + children: React.PropTypes.oneOfType([ + React.PropTypes.arrayOf(React.PropTypes.node), + React.PropTypes.node + ]) +}; + +function AdditionalDataElement({className, name, value}) { + return ( +
    + {name}: + {value} +
    + ); +} + +AdditionalDataElement.propTypes = { + name: React.PropTypes.string, + value: React.PropTypes.string, + className: React.PropTypes.string +}; + +export {AdditionalDataCol, AdditionalDataElement}; diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ArrowCol.jsx b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ArrowCol.jsx new file mode 100644 index 0000000000..a5eb9d27dd --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ArrowCol.jsx @@ -0,0 +1,35 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import classNames from 'classnames'; + +function ArrowCol ({isCollapsed, length}) { + return ( +
    +
    0}, + {'down': (length > 0 && isCollapsed)}, + {'right': (length > 0 && (!isCollapsed))})} > +
    +
    + ); +} + +ArrowCol.propTypes = { + isCollapsed: React.PropTypes.bool, + length: React.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 new file mode 100644 index 0000000000..7fd7fcb88a --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/IconCol.jsx @@ -0,0 +1,26 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; + +function IconCol({className}) { + return ( +
    +
    +
    + ); +} + +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 new file mode 100644 index 0000000000..655a0dd4a8 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/listItems/listItemsComponents/ItemInfo.jsx @@ -0,0 +1,39 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; + +function ItemInfo({name, description, children}) { + return ( +
    +
    +
    {name}
    + {children} +
    +
    {description}
    +
    + ); +} + +ItemInfo.propTypes = { + name: React.PropTypes.string, + description: React.PropTypes.string, + children: React.PropTypes.oneOfType([ + React.PropTypes.arrayOf(React.PropTypes.node), + React.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 new file mode 100644 index 0000000000..0c0103fc10 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/LicenseModelDescriptionEdit.jsx @@ -0,0 +1,56 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import Input from 'nfvo-components/input/validation/Input.jsx'; + +class LicenseModelDescriptionEdit extends React.Component { + render() { + let {onDataChanged, description, genericFieldInfo} = this.props; + let saveButtonClassName = (genericFieldInfo.description.isValid) ? 'description-save' : 'description-save disabled'; + return( +
    + + onDataChanged({description})} + value={description} + isValid={genericFieldInfo.description.isValid} + errorText={genericFieldInfo.description.errorText} + className='description-edit-textarea' + type='textarea'/> +
    +
    +
    this.onClose()} className='description-button' data-test-id='vlm-summary-vendor-desc-cancel-btn'>cancel
    +
    this.submit()} className={saveButtonClassName} data-test-id='vlm-summary-vendor-desc-save-btn'>save
    +
    +
    +
    + ); + } + + onClose() { + this.props.onClose(); + } + + submit() { + let {onSubmit, data, description} = this.props; + onSubmit({ + ...data, + description: description + }); + } +} + +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 new file mode 100644 index 0000000000..730ccb33f1 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/ListButtons.jsx @@ -0,0 +1,39 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import {selectedButton} from '../LicenseModelOverviewConstants.js'; + +function ListButtons ({onTabSelect, selectedInUse}) { + return ( +
    +
    onTabSelect(selectedButton.VLM_LIST_VIEW)} + className={selectedInUse ? 'button-vlm-list-view vlm-list-icon selected' : 'button-vlm-list-view vlm-list-icon' } + data-test-id='vlm-overview-vlmlist-tab'>
    +
    onTabSelect(selectedButton.NOT_IN_USE)} + className={selectedInUse ? 'button-vlm-list-view entities-list-icon' : 'button-vlm-list-view entities-list-icon selected' } + data-test-id='vlm-overview-orphans-tab' > +
    + +
    + ); +} + +ListButtons.propTypes = { + onTabSelect: React.PropTypes.func, + selectedInUse: React.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 new file mode 100644 index 0000000000..66f2cc6838 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountItem.jsx @@ -0,0 +1,31 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; + +function SummaryCountItem ({name, counter, onAdd, onNavigate, isReadOnlyMode}) { + 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 new file mode 100644 index 0000000000..c69a092d23 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/SummaryCountList.js @@ -0,0 +1,126 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import {connect} from 'react-redux'; + +import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; + +import OnboardingActionHelper from '../../../OnboardingActionHelper.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 SummaryCountItem from './SummaryCountItem.jsx'; + +export const mapStateToProps = ({licenseModel: {licenseModelEditor, licenseAgreement: {licenseAgreementList}, + featureGroup: {featureGroupsList}, entitlementPool: {entitlementPoolsList}, licenseKeyGroup: {licenseKeyGroupsList}}}) => { + + let {vendorName, description, id, version} = licenseModelEditor.data; + + let isReadOnlyMode = VersionControllerUtils.isReadOnly(licenseModelEditor.data); + + let counts = [ + {name: overviewItems.LICENSE_AGREEMENTS, count: licenseAgreementList.length}, + {name: overviewItems.FEATURE_GROUPS, count: featureGroupsList.length}, + {name: overviewItems.ENTITLEMENT_POOLS, count: entitlementPoolsList.length}, + {name: overviewItems.LICENSE_KEY_GROUPS, count: licenseKeyGroupsList.length}, + ]; + return { + vendorName, + licenseModelId: id, + description, + counts, + isReadOnlyMode, + version + }; +}; + +const mapActionsToProps = (dispatch) => { + 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}) => { + switch (name) { + case overviewItems.ENTITLEMENT_POOLS: + OnboardingActionHelper.navigateToEntitlementPools(dispatch, {licenseModelId, version}); + break; + case overviewItems.FEATURE_GROUPS: + OnboardingActionHelper.navigateToFeatureGroups(dispatch, {licenseModelId, version}); + break; + case overviewItems.LICENSE_AGREEMENTS: + OnboardingActionHelper.navigateToLicenseAgreements(dispatch, {licenseModelId, version}); + break; + case overviewItems.LICENSE_KEY_GROUPS: + OnboardingActionHelper.navigateToLicenseKeyGroups(dispatch, {licenseModelId, version}); + break; + default: + break; + } + } + }; +}; + +export class SummaryCountList extends React.Component { + + 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} /> + ); + } + + 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}); + } +} + +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 new file mode 100644 index 0000000000..1d65ab9869 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js @@ -0,0 +1,86 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import {connect} from 'react-redux'; + +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; +import licenseModelOverviewActionHelper from '../licenseModelOverviewActionHelper.js'; +import LicenseModelActionHelper from '../../LicenseModelActionHelper.js'; +import LicenseModelDescriptionEdit from './LicenseModelDescriptionEdit.jsx'; +import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import {VLM_DESCRIPTION_FORM} from '../LicenseModelOverviewConstants.js'; + +export const mapStateToProps = ({licenseModel: {licenseModelEditor: {data}, licenseModelOverview: {descriptionEditor: {data: descriptionData, genericFieldInfo} }}}) => { + let description = (descriptionData && descriptionData.description) ? descriptionData.description : null; + let isReadOnlyMode = VersionControllerUtils.isReadOnly(data); + return { + data, + description, + genericFieldInfo, + isReadOnlyMode + }; +}; + +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 React.Component { + render() { + let {data: {vendorName}, description, isReadOnlyMode} = this.props; + return ( +
    +
    vendor
    +
    {vendorName}
    + { + description && !isReadOnlyMode ? this.renderDescriptionEdit() : this.renderDescription() + } +
    + ); + } + + renderDescription() { + let {data: {description}, onVendorDescriptionEdit, isReadOnlyMode} = this.props; + return ( +
    {if (!isReadOnlyMode) {onVendorDescriptionEdit(description);}}} className={!isReadOnlyMode ? 'vendor-description' : 'vendor-description-readonly'}> +
    + {description} +
    +
    + ); + } + + renderDescriptionEdit() { + let {onCancel, onDataChanged, onSubmit, description, genericFieldInfo, data} = this.props; + return( + + ); + } + +} + +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 new file mode 100644 index 0000000000..c63fbff21b --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.jsx @@ -0,0 +1,134 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import {catalogItemTypeClasses, migrationStatusMapper} from './onboardingCatalog/OnboardingCatalogConstants.js'; +import CatalogTile from './CatalogTile.jsx'; +import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import {statusEnum, statusBarTextMap} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; +import tooltip from './onboardingCatalog/Tooltip.jsx'; + + + +const CatalogTileIcon = ({catalogItemTypeClass}) => ( +
    +
    +
    +
    +); + +const ItemTypeTitle = ({catalogItemTypeClass}) => { + const itemTypeTitle = catalogItemTypeClass === catalogItemTypeClasses.LICENSE_MODEL ? i18n('VLM') : i18n('VSP'); + return( +
    {itemTypeTitle}
    + ); +}; + +const CatalogTileVendorName = ({vendorName, catalogItemTypeClass}) => { + const name = catalogItemTypeClass === catalogItemTypeClasses.SOFTWARE_PRODUCT ? vendorName : ''; + return( +
    + +
    {name}
    +
    +
    + ); +}; + +const CatalogTileItemName = ({name}) => ( +
    + +
    {name}
    +
    +
    +); + +const VersionInfo = ({version}) => ( +
    +
    + V {version} +
    +
    +); + +const EntityDetails = ({catalogItemData, catalogItemTypeClass}) => { + const {vendorName, name, version} = catalogItemData; + return ( +
    + + + +
    + ); +}; + + +const ItemStatusInfo = ({catalogItemTypeClass, lockingUser, itemStatus}) => { + const status = statusBarTextMap[itemStatus]; + const lockedBy = lockingUser ? ` by ${lockingUser}` : ''; + const toolTipMsg = `${status}${lockedBy}`; + + return ( +
    +
    {i18n(status)}
    + +
    +
    +
    +
    + + ); +}; + +const CatalogItemDetails = ({catalogItemData, catalogItemTypeClass, onSelect, onMigrate}) => { + + let {status: itemStatus} = VersionControllerUtils.getCheckOutStatusKindByUserID(catalogItemData.status, catalogItemData.lockingUser); + + return ( + { + if (catalogItemData.isOldVersion && catalogItemData.isOldVersion === migrationStatusMapper.OLD_VERSION) { + onMigrate({ + softwareProduct: catalogItemData + }); + } else { + onSelect(); + } + }} data-test-id={catalogItemTypeClass}> +
    + + + + +
    +
    + ); + +}; + +CatalogItemDetails.PropTypes = { + catalogItemData: React.PropTypes.obj, + catalogItemTypeClass: React.PropTypes.string, + onSelect: React.PropTypes.func, + onMigrate: React.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 new file mode 100644 index 0000000000..c4e2724eaf --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogItemDetails.stories.js @@ -0,0 +1,36 @@ +import React from 'react'; +import {storiesOf, action} from '@kadira/storybook'; +import {select, withKnobs} from '@kadira/storybook-addon-knobs'; +import CatalogItemDetails from './CatalogItemDetails.jsx'; +import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + + + +const stories = storiesOf('CatalogTiles', module); +stories.addDecorator(withKnobs); + +const types = [ + 'license-model-type', + 'software-product-type' +]; + +function selectType() { + return select('Item type' , types, types[0]); +} + +let vlm = FinalizedLicenseModelFactory.build({name: 'Test-VLM'}); +let unclockedVlm = {...vlm, status: statusEnum.CHECK_OUT_STATUS}; + + +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 new file mode 100644 index 0000000000..17248e3b02 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogList.jsx @@ -0,0 +1,51 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; + +const SoftwareProductListHeader = ({selectedVendor, onBack}) => ( +
    + +
    +
    {selectedVendor.vendorName}
    +
    +); + +const CatalogList = ({children, onAddVLM, onAddVSP, vendorPageOptions}) => ( +
    + {vendorPageOptions && } +
    +
    + {onAddVLM && } + {onAddVSP && + } +
    + {children} +
    +
    +); + +const CreateItemTile = ({onClick, dataTestId, title, className = ''}) => { + return ( +
    onClick()} data-test-id={dataTestId}> +
    +
    {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 new file mode 100644 index 0000000000..1ef9c82822 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogModal.jsx @@ -0,0 +1,62 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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{ + + 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); + + return ( + + + {modalDetails && modalDetails.title} + + + { + modalDetails && modalDetails.element + } + + + ); + } +} + +export default CatalogModal; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogTile.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogTile.jsx new file mode 100644 index 0000000000..c7720a9d0e --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/CatalogTile.jsx @@ -0,0 +1,31 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; + +const CatalogTile = ({catalogItemTypeClass, onSelect, children}) => { + return( +
    {e.stopPropagation(); e.preventDefault(); onSelect();}} data-test-id={catalogItemTypeClass}> + {children} +
    + ); +}; + +CatalogTile.PropTypes = { + catalogItemTypeClass: React.PropTypes.string, + onSelect: React.PropTypes.func +}; + +export default CatalogTile; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/DetailsCatalogView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/DetailsCatalogView.jsx new file mode 100644 index 0000000000..ef54848523 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/DetailsCatalogView.jsx @@ -0,0 +1,56 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import {catalogItemTypes, modalMapper, catalogItemTypeClasses} 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{ + + static propTypes = { + VLMList: React.PropTypes.array, + VSPList: React.PropTypes.array, + onSelectVLM: React.PropTypes.func.isRequired, + onSelectVSP: React.PropTypes.func.isRequired, + onAddVLM: React.PropTypes.func.isRequired, + onAddVSP: React.PropTypes.func.isRequired, + filter: React.PropTypes.string.isRequired + }; + + renderCatalogItems(items, type, filter, onSelect, onMigrate, tileType){ + return filterCatalogItemsByType(items, type, filter).map(item => + onSelect(item)} + tileType={tileType} /> + ); + } + + render() { + let {VLMList, VSPList, onAddVSP, onAddVLM, onSelectVLM, onSelectVSP, filter = '', onMigrate, tileType} = this.props; + return ( + + {this.renderCatalogItems(VLMList, catalogItemTypes.LICENSE_MODEL, filter, onSelectVLM, onMigrate, tileType)} + {this.renderCatalogItems(VSPList, catalogItemTypes.SOFTWARE_PRODUCT, filter, onSelectVSP, onMigrate, tileType)} + + ); + } +} +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 new file mode 100644 index 0000000000..b13ccbbba2 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js @@ -0,0 +1,90 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 OnboardView from './OnboardView.jsx'; +import OnboardingActionHelper from '../OnboardingActionHelper.js'; +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'; + +export const mapStateToProps = ({ + onboard: {onboardingCatalog, activeTab, searchValue}, licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList +}) => { + + const reduceLicenseModelList = (accum, vlm)=> { + let currentSoftwareProductList = sortByStringProperty( + finalizedSoftwareProductList + .filter(vsp => vsp.vendorId === vlm.id), + 'name' + ); + accum.push({...vlm, softwareProductList: currentSoftwareProductList}); + return accum; + }; + + finalizedLicenseModelList = sortByStringProperty( + licenseModelList + .filter(vlm => finalizedLicenseModelList.map(finalVlm => finalVlm.id).includes(vlm.id)) + .reduce(reduceLicenseModelList, []), + 'vendorName' + ); + + finalizedSoftwareProductList = sortByStringProperty( + softwareProductList + .filter(vsp => finalizedSoftwareProductList.map(finalVsp => finalVsp.id).includes(vsp.id)), + 'name' + ); + + + let {activeTab: catalogActiveTab, vendorCatalog: {vspOverlay, selectedVendor}} = onboardingCatalog; + + return { + finalizedLicenseModelList, + finalizedSoftwareProductList, + licenseModelList, + softwareProductList, + activeTab, + catalogActiveTab, + searchValue, + vspOverlay, + selectedVendor + }; +}; + +const mapActionsToProps = (dispatch) => { + return { + onSelectLicenseModel({id: licenseModelId, version}) { + OnboardingActionHelper.navigateToLicenseModelOverview(dispatch, {licenseModelId, version}); + }, + onSelectSoftwareProduct(softwareProduct) { + let {id: softwareProductId, vendorId: licenseModelId, licensingVersion, version} = softwareProduct; + OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version, licenseModelId, licensingVersion}); + }, + 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 new file mode 100644 index 0000000000..6ebb40878f --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js @@ -0,0 +1,45 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {actionTypes} from './OnboardConstants.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: '' + }); + } +}; + +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 new file mode 100644 index 0000000000..41128bfb11 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardConstants.js @@ -0,0 +1,28 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; + +export const tabsMapping = { + 'WORKSPACE': 1, + 'CATALOG': 2 +}; + +export const actionTypes = keyMirror({ + 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 new file mode 100644 index 0000000000..72145015db --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardReducer.js @@ -0,0 +1,31 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {actionTypes, tabsMapping} from './OnboardConstants.js'; +import {combineReducers} from 'redux'; +import onboardingCatalogReducer from './onboardingCatalog/OnboardingCatalogReducer.js'; + +const onboardReducer = combineReducers({ + onboardingCatalog: onboardingCatalogReducer, + 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); +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardView.jsx new file mode 100644 index 0000000000..b7a7fa5f68 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardView.jsx @@ -0,0 +1,95 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import OnboardingCatalogView from './onboardingCatalog/OnboardingCatalogView.jsx'; +import WorkspaceView from './workspace/WorkspaceView.jsx'; +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'; + +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}) => ( +
    + + +
    +); + +class OnboardView extends React.Component { + static propTypes = { + licenseModelList: React.PropTypes.array, + softwareProductList: React.PropTypes.array, + finalizedLicenseModelList: React.PropTypes.array, + finalizedSoftwareProductList: React.PropTypes.array, + modalToShow: React.PropTypes.oneOf(objectValues(catalogItemTypes)), + onSelectLicenseModel: React.PropTypes.func.isRequired, + onSelectSoftwareProduct: React.PropTypes.func.isRequired, + onAddLicenseModelClick: React.PropTypes.func.isRequired, + onAddSoftwareProductClick: React.PropTypes.func.isRequired, + closeVspOverlay: React.PropTypes.func.isRequired, + onVspOverlayChange: React.PropTypes.func.isRequired, + onTabClick: React.PropTypes.func.isRequired, + onCatalogTabClick: React.PropTypes.func.isRequired, + onSearch: React.PropTypes.func.isRequired, + activeTab: React.PropTypes.number.isRequired, + catalogActiveTab: React.PropTypes.number.isRequired, + searchValue: React.PropTypes.string.isRequired, + onMigrate: React.PropTypes.func.isRequired, + }; + renderViewByTab(activeTab){ + switch (activeTab){ + case tabsMapping.WORKSPACE: + return ; + case tabsMapping.CATALOG: + default: + return ; + } + } + + render() { + let {closeVspOverlay, 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/onboardingCatalog/OnboardingCatalogActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js new file mode 100644 index 0000000000..73a447558d --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js @@ -0,0 +1,85 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 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 {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.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})}
    +
    {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 {status, name, lockingUser} = softwareProduct; + if (status === statusEnum.CHECK_OUT_STATUS && !VersionControllerUtils.isCheckedOutByCurrentUser(softwareProduct)) { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data: { + title: 'WARNING', + msg: i18n('{name} is locked by user {lockingUser} for self-healing',{name, 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 new file mode 100644 index 0000000000..071160c4fd --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js @@ -0,0 +1,50 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; + +export const catalogItemTypes = Object.freeze({ + LICENSE_MODEL: 'license-model', + SOFTWARE_PRODUCT: 'software-product' +}); + +export const catalogItemTypeClasses = { + LICENSE_MODEL: 'license-model-type', + SOFTWARE_PRODUCT: 'software-product-type', + VENDOR: 'vendor-type' + +}; + +export const modalMapper = { + 'license-model': 'LICENSE_MODEL', + 'software-product': 'SOFTWARE_PRODUCT' +}; + +export const tabsMapping = { + 'BY_VENDOR': 1, + 'ALL': 2 +}; + +export const migrationStatusMapper = { + 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 +}); diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogReducer.js b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogReducer.js new file mode 100644 index 0000000000..d7d9d0bd6c --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogReducer.js @@ -0,0 +1,30 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {actionTypes, tabsMapping} from './OnboardingCatalogConstants.js'; +import {combineReducers} from 'redux'; +import vendorCatalogReducer from './VendorCatalogReducer.js'; + +const onboardingCatalogReducer = combineReducers({ + vendorCatalog: vendorCatalogReducer, + activeTab: (state = tabsMapping.ALL, 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); +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogUtils.js b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogUtils.js new file mode 100644 index 0000000000..ac623db920 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogUtils.js @@ -0,0 +1,21 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {catalogItemTypes} from './OnboardingCatalogConstants.js'; + +export const filterCatalogItemsByType = (items, type, filter) => { + const fieldName = type === catalogItemTypes.LICENSE_MODEL ? 'vendorName' : 'name'; + return items.filter(item => item[fieldName].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 new file mode 100644 index 0000000000..b1f002d2fb --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx @@ -0,0 +1,98 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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'; + +const CatalogHeaderTabs = ({onTabPress, activeTab}) => ( +
    +
    onTabPress(tabsMapping.ALL)} + data-test-id='catalog-all-tab'> + {i18n('ALL')} +
    +
    +
    onTabPress(tabsMapping.BY_VENDOR)} + data-test-id='catalog-by-vendor-tab'> + {i18n('BY VENDOR')} +
    +
    +); + +const CatalogHeader = ({activeTab, onTabPress}) => ( +
    + +
    +); + +class OnboardingCatalogView extends React.Component { + renderViewByTab(activeTab){ + const {finalizedLicenseModelList: licenseModelList, vspOverlay, finalizedSoftwareProductList: softwareProductList, onSelectLicenseModel, onSelectSoftwareProduct, + onAddLicenseModelClick, onAddSoftwareProductClick, onVspOverlayChange, onVendorSelect, selectedVendor, searchValue, onMigrate} = this.props; + switch (activeTab){ + case tabsMapping.ALL: + return ( + + ); + case tabsMapping.BY_VENDOR: + default: + return ( + + ); + } + } + + 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 new file mode 100644 index 0000000000..8d8d1162a0 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/Tooltip.jsx @@ -0,0 +1,24 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import Tooltip from 'react-bootstrap/lib/Tooltip.js'; + +export default function tooltip (msg) { + return ( + {msg} + ); +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx new file mode 100644 index 0000000000..1ba4834fa3 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx @@ -0,0 +1,50 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.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')}
    } +
    +
    +); + +VSPOverlay.PropTypes = { + VSPList: React.PropTypes.array, + onSelectVSP: React.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 new file mode 100644 index 0000000000..dd8b41bd22 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogReducer.js @@ -0,0 +1,38 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {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; + } +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogView.jsx new file mode 100644 index 0000000000..c4e0599d85 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorCatalogView.jsx @@ -0,0 +1,74 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import VendorItem from './VendorItem.jsx'; +import CatalogList from '../CatalogList.jsx'; +import CatalogItemDetails from '../CatalogItemDetails.jsx'; +import {catalogItemTypes, catalogItemTypeClasses} from './OnboardingCatalogConstants.js'; +import {filterCatalogItemsByType} from './OnboardingCatalogUtils.js'; + +const VendorList = ({onAddVLM, onAddVSP, onSelectVSP, licenseModelList = [], vspOverlay: currentOverlay, onVspOverlayChange, onVendorSelect, filter, onMigrate}) => { + return( + + { + filterCatalogItemsByType(licenseModelList, catalogItemTypes.LICENSE_MODEL, filter).map(vlm => + onVspOverlayChange(vlm.id === currentOverlay || !hasVSP ? null : vlm)} + onVendorSelect={onVendorSelect} + onMigrate={onMigrate} + vendor={vlm}/>) + } + + ); +}; + +const SoftwareProductListByVendor = ({onAddVSP, selectedVendor, onVendorSelect, onSelectVSP, onSelectVLM, filter, onMigrate}) => { + return( +
    + {onAddVSP(selectedVendor.id);}} vendorPageOptions={{selectedVendor, onBack: () => onVendorSelect(false)}}> + onSelectVLM(selectedVendor)} + catalogItemTypeClass={catalogItemTypeClasses.LICENSE_MODEL} + onMigrate={onMigrate} + catalogItemData={{...selectedVendor, name: selectedVendor.vendorName}}/> + { + filterCatalogItemsByType(selectedVendor.softwareProductList, catalogItemTypes.SOFTWARE_PRODUCT, filter).map(vsp => + onSelectVSP(vsp)} + catalogItemData={vsp}/> + ) + } + +
    + ); +}; + +class VendorCatalogView extends React.Component { + 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 new file mode 100644 index 0000000000..cecccdd9ad --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx @@ -0,0 +1,96 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import {catalogItemTypeClasses} from './OnboardingCatalogConstants.js'; +import CatalogTile from '../CatalogTile.jsx'; +import classnames from 'classnames'; +import VSPOverlay from './VSPOverlay.jsx'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; +import tooltip from './Tooltip.jsx'; + + +class VendorItem extends React.Component { + + static PropTypes = { + softwareProductList: React.PropTypes.array, + vendor: React.PropTypes.object, + onSelectVSP: React.PropTypes.func, + shouldShowOverlay: React.PropTypes.boolm, + onVendorSelect: React.PropTypes.func, + onAddVSP: React.PropTypes.func, + onVSPIconClick: React.PropTypes.func, + + }; + + render() { + let {vendor, onSelectVSP, shouldShowOverlay, onVendorSelect, onMigrate} = this.props; + let {softwareProductList = [], vendorName} = vendor; + return ( + onVendorSelect(vendor)}> +
    +
    +
    +
    + +
    {vendorName}
    +
    +
    this.handleVspCountClick(event)} + data-test-id='catalog-vsp-count'> + {i18n(`${softwareProductList.length} VSPs`)} +
    +
    this.onCreateVspClick(event)} data-test-id='catalog-create-new-vsp-from-vendor'> +
    +    {i18n('Create new VSP')} +
    +
    +
    + + {shouldShowOverlay && softwareProductList.length > 0 + && onVendorSelect(vendor)}/>} +
    + ); + } + + onClick(vlm) { + this.setState({ + licenseModelToShow: vlm + }); + } + + onCreateVspClick(event) { + let {onAddVSP, vendor: {id}} = this.props; + event.stopPropagation(); + event.preventDefault(); + onAddVSP(id); + } + + handleVspCountClick(e){ + let {onVSPIconClick, vendor: {softwareProductList}} = this.props; + e.stopPropagation(); + e.preventDefault(); + const hasVSP = Boolean(softwareProductList.length); + onVSPIconClick(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 new file mode 100644 index 0000000000..d86b674f13 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx @@ -0,0 +1,57 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import DetailsCatalogView from '../DetailsCatalogView.jsx'; +import {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import {tabsMapping} from 'sdc-app/onboarding/onboard/OnboardConstants.js'; + +const WorkspaceView = (props) => { + let { + licenseModelList, softwareProductList, onAddLicenseModelClick, + onAddSoftwareProductClick, onSelectLicenseModel, onSelectSoftwareProduct, searchValue, onMigrate + } = props; + + let {getCheckOutStatusKindByUserID} = VersionControllerUtils; + let unfinalizedLicenseModelList = licenseModelList.filter(vlm => { + let {status} = getCheckOutStatusKindByUserID(vlm.status, vlm.lockingUser); + return status !== statusEnum.SUBMIT_STATUS && status !== statusEnum.LOCK_STATUS; + }); + let unfinalizedSoftwareProductList = softwareProductList.filter(vsp =>{ + let {status} = getCheckOutStatusKindByUserID(vsp.status, vsp.lockingUser); + return status !== statusEnum.SUBMIT_STATUS && status !== statusEnum.LOCK_STATUS; + }); + + return ( +
    +
    + {i18n('WORKSPACE')} +
    + +
    ); +}; + +export default WorkspaceView; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/FinalizedSoftwareProductReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/FinalizedSoftwareProductReducer.js new file mode 100644 index 0000000000..396f65f5d7 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/FinalizedSoftwareProductReducer.js @@ -0,0 +1,25 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {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; + } +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js index 2dbef6baf2..12f68a2afe 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProduct.js @@ -1,36 +1,40 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 i18n from 'nfvo-utils/i18n/i18n.js'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import TabulatedEditor from 'src/nfvo-components/editor/TabulatedEditor.jsx'; import {enums} from 'sdc-app/onboarding/OnboardingConstants.js'; import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; -import {navigationItems} from './SoftwareProductConstants.js'; +import {navigationItems, mapScreenToNavigationItem} from './SoftwareProductConstants.js'; import SoftwareProductActionHelper from './SoftwareProductActionHelper.js'; import SoftwareProductComponentsActionHelper from './components/SoftwareProductComponentsActionHelper.js'; +import SoftwareProductDependenciesActionHelper from './dependencies/SoftwareProductDependenciesActionHelper.js'; +import {doesHeatDataExist} from './attachments/SoftwareProductAttachmentsUtils.js'; + +import HeatSetupActionHelper from './attachments/setup/HeatSetupActionHelper.js'; +import { actionsEnum as versionControllerActions } from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + +function getActiveNavigationId(screen, componentId) { + let activeItemId = componentId ? mapScreenToNavigationItem[screen] + '|' + componentId : mapScreenToNavigationItem[screen]; + return activeItemId; +} const buildComponentNavigationBarGroups = ({componentId, meta}) => { const groups = ([ @@ -106,6 +110,18 @@ const buildNavigationBarProps = ({softwareProduct, meta, screen, componentId, co id: navigationItems.ATTACHMENTS, name: i18n('Attachments'), disabled: false, + hidden: !doesHeatDataExist(meta.heatSetup), + meta + }, { + id: navigationItems.ACTIVITY_LOG, + name: i18n('Activity Log'), + disabled: false, + meta + }, { + id: navigationItems.DEPENDENCIES, + name: i18n('Component Dependencies'), + hidden: componentsList.length <= 1, + disabled: false, meta }, { id: navigationItems.COMPONENTS, @@ -125,29 +141,7 @@ const buildNavigationBarProps = ({softwareProduct, meta, screen, componentId, co } ] }]; - let activeItemId = ({ - [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: navigationItems.VENDOR_SOFTWARE_PRODUCT, - [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: navigationItems.GENERAL, - [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: navigationItems.ATTACHMENTS, - [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: navigationItems.PROCESS_DETAILS, - [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: navigationItems.NETWORKS, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: navigationItems.COMPONENTS - })[screen]; - - if(componentId) { - activeItemId = - Object.keys(mapOfExpandedIds).length === 1 && mapOfExpandedIds[navigationItems.COMPONENTS] === true ? - navigationItems.COMPONENTS : ({ - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: navigationItems.GENERAL, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: navigationItems.COMPUTE, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: navigationItems.LOAD_BALANCING, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: navigationItems.NETWORKS, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: navigationItems.STORAGE, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: navigationItems.PROCESS_DETAILS, - [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: navigationItems.MONITORING - })[screen] + '|' + componentId; - } - + let activeItemId = getActiveNavigationId(screen, componentId); return { activeItemId, groups }; @@ -158,9 +152,7 @@ const buildVersionControllerProps = (softwareProduct) => { const {data: currentSoftwareProduct = {}, isValidityData = true} = softwareProductEditor; const {version, viewableVersions, status: currentStatus, lockingUser} = currentSoftwareProduct; - const {status, isCheckedOut} = (currentStatus === versionStatusEnum.CHECK_OUT_STATUS) ? - VersionControllerUtils.getCheckOutStatusKindByUserID(currentStatus, lockingUser) : - {status: currentStatus, isCheckedOut: false}; + const {status, isCheckedOut} = VersionControllerUtils.getCheckOutStatusKindByUserID(currentStatus, lockingUser); return { status, isCheckedOut, version, viewableVersions, @@ -168,42 +160,56 @@ const buildVersionControllerProps = (softwareProduct) => { }; }; -const mapStateToProps = ({softwareProduct}, {currentScreen: {screen, props: {componentId}}}) => { - const {softwareProductEditor, softwareProductComponents, softwareProductQuestionnaire} = softwareProduct; - const {data: currentSoftwareProduct = {}, mapOfExpandedIds = []} = softwareProductEditor; +function buildMeta({softwareProduct, componentId, softwareProductDependencies}) { + const {softwareProductEditor, softwareProductComponents, softwareProductQuestionnaire, softwareProductAttachments} = softwareProduct; + const {data: currentSoftwareProduct = {}} = softwareProductEditor; const {version} = currentSoftwareProduct; - const {componentsList = []} = softwareProductComponents; const isReadOnlyMode = VersionControllerUtils.isReadOnly(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, isReadOnlyMode, currentComponentMeta}; + const meta = {softwareProduct: currentSoftwareProduct, qdata, version, heatSetup, heatSetupCache, isReadOnlyMode, currentComponentMeta, softwareProductDependencies}; + return meta; +} + +const mapStateToProps = ({softwareProduct}, {currentScreen: {screen, props: {componentId}}}) => { + const {softwareProductEditor, softwareProductComponents, softwareProductDependencies} = softwareProduct; + const {mapOfExpandedIds = []} = softwareProductEditor; + const {componentsList = []} = softwareProductComponents; + const meta = buildMeta({softwareProduct, componentId, softwareProductDependencies}); return { versionControllerProps: buildVersionControllerProps(softwareProduct), - navigationBarProps: buildNavigationBarProps({softwareProduct, meta, screen, componentId, componentsList, mapOfExpandedIds}) + navigationBarProps: buildNavigationBarProps({softwareProduct, meta, screen, componentId, componentsList, mapOfExpandedIds}), + meta }; }; -const autoSaveBeforeNavigate = ({dispatch, screen, softwareProductId, componentId, meta: {isReadOnlyMode, softwareProduct, qdata, currentComponentMeta: {componentData, componentQdata}}}) => { +const autoSaveBeforeNavigate = ({dispatch, screen, softwareProductId, componentId, + meta: {isReadOnlyMode, softwareProduct, version, qdata, softwareProductDependencies, + currentComponentMeta: {componentData, componentQdata}}}) => { let promise; if (isReadOnlyMode) { promise = Promise.resolve(); } else { switch(screen) { + case enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES: + promise = SoftwareProductDependenciesActionHelper.saveDependencies(dispatch,{softwareProductId, version, dependenciesList: softwareProductDependencies}); case enums.SCREEN.SOFTWARE_PRODUCT_DETAILS: promise = SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {softwareProduct, qdata}); break; case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL: - promise = SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId: componentId, componentData, qdata: componentQdata}); + 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_LOAD_BALANCING: - promise = SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId: componentId, qdata: componentQdata}); + promise = SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId: componentId, qdata: componentQdata}); break; default: promise = Promise.resolve(); @@ -228,22 +234,22 @@ const onComponentNavigate = (dispatch, {id, softwareProductId, version, currentC OnboardingActionHelper.navigateToSoftwareProductComponentGeneral(dispatch, {softwareProductId, componentId: nextComponentId, version}); break; case navigationItems.COMPUTE: - OnboardingActionHelper.navigateToComponentCompute(dispatch, {softwareProductId, componentId: nextComponentId}); + OnboardingActionHelper.navigateToComponentCompute(dispatch, {softwareProductId, componentId: nextComponentId, version}); break; case navigationItems.LOAD_BALANCING: - OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId: nextComponentId}); + OnboardingActionHelper.navigateToComponentLoadBalancing(dispatch, {softwareProductId, componentId: nextComponentId, version}); break; case navigationItems.NETWORKS: OnboardingActionHelper.navigateToComponentNetwork(dispatch, {softwareProductId, componentId: nextComponentId, version}); break; case navigationItems.STORAGE: - OnboardingActionHelper.navigateToComponentStorage(dispatch, {softwareProductId, componentId: nextComponentId}); + OnboardingActionHelper.navigateToComponentStorage(dispatch, {softwareProductId, componentId: nextComponentId, version}); break; case navigationItems.PROCESS_DETAILS: - OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId: nextComponentId}); + OnboardingActionHelper.navigateToSoftwareProductComponentProcesses(dispatch, {softwareProductId, componentId: nextComponentId, version}); break; case navigationItems.MONITORING: - OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId: nextComponentId}); + OnboardingActionHelper.navigateToSoftwareProductComponentMonitoring(dispatch, {softwareProductId, componentId: nextComponentId, version}); break; } }; @@ -251,44 +257,49 @@ const onComponentNavigate = (dispatch, {id, softwareProductId, version, currentC const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {softwareProductId, componentId: currentComponentId}}}) => { const props = { - onClose: ({version}) => { - if (screen === enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE) { - OnboardingActionHelper.navigateToOnboardingCatalog(dispatch); - } else { - OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version}); - } - }, - onVersionSwitching: (version) => { - OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version}); + onVersionSwitching: (version, meta) => { + SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId, version}); + props.onNavigate({id: getActiveNavigationId(screen, currentComponentId), meta, version}); }, onToggle: (groups, itemIdToExpand) => groups.map(({items}) => SoftwareProductActionHelper.toggleNavigationItems(dispatch, {items, itemIdToExpand})), - onNavigate: ({id, meta}) => { - let preNavigate = autoSaveBeforeNavigate({dispatch, screen, meta, softwareProductId, componentId: currentComponentId}); - preNavigate.then(() => { + onNavigate: ({id, meta, version}) => { + let {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, softwareProductId, componentId: currentComponentId}) : Promise.resolve(); + version = version || (meta ? meta.version : undefined); + Promise.all([preNavigate, heatSetupPopupPromise]).then(() => { switch(id) { case navigationItems.VENDOR_SOFTWARE_PRODUCT: - OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version: meta.version}); + OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, version}); break; case navigationItems.GENERAL: - OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, {softwareProductId}); + OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, {softwareProductId, version}); break; case navigationItems.PROCESS_DETAILS: - OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version: meta.version}); + OnboardingActionHelper.navigateToSoftwareProductProcesses(dispatch, {softwareProductId, version}); break; case navigationItems.NETWORKS: - OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version: meta.version}); + OnboardingActionHelper.navigateToSoftwareProductNetworks(dispatch, {softwareProductId, version}); + break; + case navigationItems.DEPENDENCIES: + OnboardingActionHelper.navigateToSoftwareProductDependencies(dispatch, {softwareProductId, version}); break; case navigationItems.ATTACHMENTS: - OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId}); + OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version}); break; case navigationItems.COMPONENTS: - OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, {softwareProductId}); + OnboardingActionHelper.navigateToSoftwareProductComponents(dispatch, {softwareProductId, version}); + break; + case navigationItems.ACTIVITY_LOG: + OnboardingActionHelper.navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version}); break; default: - onComponentNavigate(dispatch, {id, softwareProductId, version: meta.version, screen, currentComponentId}); + onComponentNavigate(dispatch, {id, softwareProductId, version, screen, currentComponentId}); break; } - }); + }).catch(() => {}); } }; @@ -297,6 +308,8 @@ const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {softwarePr 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_COMPONENT_PROCESSES: case enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING: @@ -310,11 +323,20 @@ const mapActionsToProps = (dispatch, {currentScreen: {screen, props: {softwarePr } - props.onVersionControllerAction = (action) => - SoftwareProductActionHelper.performVCAction(dispatch, {softwareProductId, action}).then(() => { - SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId}); - }); - + props.onVersionControllerAction = (action, version, meta) => { + let {heatSetup, heatSetupCache} = meta; + let heatSetupPopupPromise = screen === enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS && action === versionControllerActions.CHECK_IN ? + HeatSetupActionHelper.heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) : + Promise.resolve(); + heatSetupPopupPromise.then(() => { + return SoftwareProductActionHelper.performVCAction(dispatch, {softwareProductId, action, version}).then(({newVersion}) => { + //props.onNavigate({id: getActiveNavigationId(screen, currentComponentId), version}); + if(screen === enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG) { + OnboardingActionHelper.navigateToSoftwareProductActivityLog(dispatch, {softwareProductId, version: newVersion}); + } + }); + }).catch(() => {}); + }; return props; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js index d9ed8af679..6f53886350 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; @@ -26,10 +21,17 @@ import LicenseAgreementActionHelper from 'sdc-app/onboarding/licenseModel/licens import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js'; import {actionTypes} from './SoftwareProductConstants.js'; -import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.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 ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; +import {PRODUCT_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import {modalContentMapper} from 'sdc-app/common/modal/ModalContentMapper.js'; +import {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; function baseUrl() { const restPrefix = Configuration.get('restPrefix'); @@ -40,46 +42,58 @@ function softwareProductCategoriesUrl() { return `${restATTPrefix}/v1/categories/resources/`; } -function uploadFile(vspId, formData) { - - return RestAPIUtil.create(`${baseUrl()}${vspId}/upload`, formData); +function uploadFile(vspId, formData, version) { + return RestAPIUtil.post(`${baseUrl()}${vspId}/versions/${version.id}/orchestration-template-candidate`, formData); } -function putSoftwareProduct(softwareData) { - return RestAPIUtil.save(`${baseUrl()}${softwareData.id}`, { - name: softwareData.name, - description: softwareData.description, - category: softwareData.category, - subCategory: softwareData.subCategory, - vendorId: softwareData.vendorId, - vendorName: softwareData.vendorName, - licensingVersion: softwareData.licensingVersion, - icon: softwareData.icon, - licensingData: softwareData.licensingData +function putSoftwareProduct(softwareProduct) { + return RestAPIUtil.put(`${baseUrl()}${softwareProduct.id}/versions/${softwareProduct.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.id ? softwareProduct.licensingVersion : {} , + icon: softwareProduct.icon, + licensingData: softwareProduct.licensingData }); } -function putSoftwareProductQuestionnaire(vspId, qdata) { - return RestAPIUtil.save(`${baseUrl()}${vspId}/questionnaire`, qdata); +function putSoftwareProductQuestionnaire(vspId, qdata, version) { + return RestAPIUtil.put(`${baseUrl()}${vspId}/versions/${version.id}/questionnaire`, qdata); } -function putSoftwareProductAction(id, action) { - return RestAPIUtil.save(`${baseUrl()}${id}/actions`, {action: action}); +function putSoftwareProductAction(id, action, version) { + return RestAPIUtil.put(`${baseUrl()}${id}/versions/${version.id}/actions`, {action: action}); } function fetchSoftwareProductList() { return RestAPIUtil.fetch(baseUrl()); } +function fetchFinalizedSoftwareProductList() { + return RestAPIUtil.fetch(`${baseUrl()}?versionFilter=Final`); +} + function fetchSoftwareProduct(vspId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl()}${vspId}${versionQuery}`); + return RestAPIUtil.fetch(`${baseUrl()}${vspId}/versions/${version.id}`); } function fetchSoftwareProductQuestionnaire(vspId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl()}${vspId}/questionnaire${versionQuery}`); + 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 validateHeatCandidate(softwareProductId, version) { + 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 objToString(obj) { @@ -88,7 +102,8 @@ function objToString(obj) { obj.forEach((item) => { str += objToString(item) + '\n'; }); - } else { + } + else { for (let p in obj) { if (obj.hasOwnProperty(p)) { str += obj[p] + '\n'; @@ -115,24 +130,27 @@ function fetchSoftwareProductCategories(dispatch) { }); return RestAPIUtil.fetch(softwareProductCategoriesUrl()) .then(handleResponse) - .fail(() => handleResponse(null)); + .catch(() => handleResponse(null)); } function loadLicensingData(dispatch, {licenseModelId, licensingVersion}) { - LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version: licensingVersion}); - FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version: licensingVersion}); + return Promise.all([ + LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId, version: licensingVersion}), + FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId, version: licensingVersion}) + ]); } function getExpandedItemsId(items, itemIdToToggle) { - for(let i = 0; i < items.length; i++) { - if(items[i].id === itemIdToToggle) { + for (let i = 0; i < items.length; i++) { + if (items[i].id === itemIdToToggle) { if (items[i].expanded) { return {}; - } else { + } + else { return {[itemIdToToggle]: true}; } } - else if(items[i].items && items[i].items.length > 0) { + 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; @@ -143,8 +161,63 @@ function getExpandedItemsId(items, itemIdToToggle) { return false; } +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())}`; +} + +function showFileSaveDialog({blob, xhr, defaultFilename, addTimestamp}) { + let filename; + let contentDisposition = xhr.getResponseHeader('content-disposition') ? xhr.getResponseHeader('content-disposition') : ''; + let match = contentDisposition.match(/filename=(.*?)(;|$)/); + if (match) { + filename = match[1]; + } + else { + filename = defaultFilename; + } + + 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); +} + +function migrateSoftwareProduct(vspId, version) { + return RestAPIUtil.put(`${baseUrl()}${vspId}/versions/${version.id}/heal`); +} + +function adjustMinorVersion(version, value) { + let ar = version.split('.'); + return ar[0] + '.' + (parseInt(ar[1]) + value); +} + +function adjustMajorVersion(version, value) { + let ar = version.split('.'); + return (parseInt(ar[0]) + value) + '.0'; +} + const SoftwareProductActionHelper = { + fetchFinalizedSoftwareProductList(dispatch) { + return fetchFinalizedSoftwareProductList().then(response => dispatch({ + type: actionTypes.FINALIZED_SOFTWARE_PRODUCT_LIST_LOADED, + response + })); + }, + loadSoftwareProductAssociatedData(dispatch) { fetchSoftwareProductCategories(dispatch); LicenseModelActionHelper.fetchFinalizedLicenseModels(dispatch); @@ -152,7 +225,7 @@ const SoftwareProductActionHelper = { loadSoftwareProductDetailsData(dispatch, {licenseModelId, licensingVersion}) { SoftwareProductActionHelper.loadSoftwareProductAssociatedData(dispatch); - loadLicensingData(dispatch, {licenseModelId, licensingVersion}); + return loadLicensingData(dispatch, {licenseModelId, licensingVersion}); }, fetchSoftwareProductList(dispatch) { @@ -162,37 +235,61 @@ const SoftwareProductActionHelper = { })); }, - uploadFile(dispatch, {softwareProductId, formData, failedNotificationTitle}) { + loadSoftwareProductHeatCandidate(dispatch, {softwareProductId, version}){ + return RestAPIUtil.fetch(`${baseUrl()}${softwareProductId}/versions/${version.id}/orchestration-template-candidate/manifest`).then(response => dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response + })); + }, + + 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}); + } + }); + }, + + uploadFile(dispatch, {softwareProductId, formData, failedNotificationTitle, version}) { + dispatch({ + type: HeatSetupActions.FILL_HEAT_SETUP_CACHE, + payload: {} + }); + Promise.resolve() - .then(() => uploadFile(softwareProductId, formData)) + .then(() => uploadFile(softwareProductId, formData, version)) .then(response => { - if (response.status !== 'Success') { + if (response.status === 'Success') { + OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version}); + } + else { throw new Error(parseUploadErrorMsg(response.errors)); } }) - .then(() => { - SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId}); - OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId}); - SoftwareProductActionHelper.fetchSoftwareProduct(dispatch, {softwareProductId}); - }) .catch(error => { dispatch({ - type: NotificationConstants.NOTIFY_ERROR, - data: {title: failedNotificationTitle, msg: error.message} + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + title: failedNotificationTitle, + msg: error.message + } }); }); }, - uploadConfirmation(dispatch, {softwareProductId, formData, failedNotificationTitle}) { - dispatch({ - type: actionTypes.softwareProductEditor.UPLOAD_CONFIRMATION, - uploadData: { - softwareProductId, - formData, - failedNotificationTitle - } - }); + downloadHeatFile(dispatch, {softwareProductId, heatCandidate, isReadOnlyMode, version}){ + let p = isReadOnlyMode ? Promise.resolve() : SoftwareProductActionHelper.updateSoftwareProductHeatCandidate(dispatch, {softwareProductId, heatCandidate, version}); + p.then(() => { + fetchOrchestrationTemplateCandidate(softwareProductId, version) + .then((blob, statusText, xhr) => showFileSaveDialog({blob, xhr, defaultFilename: 'HEAT_file.zip', addTimestamp: true})); + }, null/* do not download if data was not saved correctly*/); }, + hideUploadConfirm (dispatch) { dispatch({ type: actionTypes.softwareProductEditor.UPLOAD_CONFIRMATION @@ -208,7 +305,8 @@ const SoftwareProductActionHelper = { ), SoftwareProductActionHelper.updateSoftwareProductQuestionnaire(dispatch, { softwareProductId: softwareProduct.id, - qdata + qdata, + version: softwareProduct.version }) ]); }, @@ -217,8 +315,8 @@ const SoftwareProductActionHelper = { return putSoftwareProduct(softwareProduct); }, - updateSoftwareProductQuestionnaire(dispatch, {softwareProductId, qdata}) { - return putSoftwareProductQuestionnaire(softwareProductId, qdata); + updateSoftwareProductQuestionnaire(dispatch, {softwareProductId, qdata, version}) { + return putSoftwareProductQuestionnaire(softwareProductId, qdata, version); }, softwareProductEditorDataChanged(dispatch, {deltaData}) { @@ -235,10 +333,34 @@ const SoftwareProductActionHelper = { }); }, - softwareProductEditorVendorChanged(dispatch, {deltaData}) { - LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, {licenseModelId: deltaData.vendorId, version: deltaData.licensingVersion}); - FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {licenseModelId: deltaData.vendorId, version: deltaData.licensingVersion}); - SoftwareProductActionHelper.softwareProductEditorDataChanged(dispatch, {deltaData}); + softwareProductEditorVendorChanged(dispatch, {deltaData, formName}) { + if (deltaData.licensingVersion.id){ + let p = Promise.all([ + LicenseAgreementActionHelper.fetchLicenseAgreementList(dispatch, { + licenseModelId: deltaData.vendorId, + version: {id: deltaData.licensingVersion.id} + }), + FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, { + licenseModelId: deltaData.vendorId, + version: {id: deltaData.licensingVersion.id} + }) + ]); + ValidationHelper.dataChanged(dispatch, {deltaData, formName}); + return p; + } 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}) { @@ -265,55 +387,67 @@ const SoftwareProductActionHelper = { return response; }), fetchSoftwareProductQuestionnaire(softwareProductId, version).then(response => { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_QUESTIONNAIRE_UPDATE, - payload: { - qdata: response.data ? JSON.parse(response.data) : {}, - qschema: JSON.parse(response.schema) - } - }); + ValidationHelper.qDataLoaded(dispatch, {response: {qdata: response.data ? JSON.parse(response.data) : {}, + qschema: JSON.parse(response.schema)}, qName: PRODUCT_QUESTIONNAIRE}); }) ]); }, - performVCAction(dispatch, {softwareProductId, action}) { + performVCAction(dispatch, {softwareProductId, action, version}) { if (action === VersionControllerActionsEnum.SUBMIT) { - return putSoftwareProductAction(softwareProductId, action).then(() => { - return putSoftwareProductAction(softwareProductId, VersionControllerActionsEnum.CREATE_PACKAGE).then(() => { + return putSoftwareProductAction(softwareProductId, action, version).then(() => { + return putSoftwareProductAction(softwareProductId, VersionControllerActionsEnum.CREATE_PACKAGE, version).then(() => { dispatch({ - type: NotificationConstants.NOTIFY_SUCCESS, + type: modalActionTypes.GLOBAL_MODAL_SUCCESS, data: { title: i18n('Submit Succeeded'), msg: i18n('This software product successfully submitted'), + cancelButtonText: i18n('OK'), timeout: 2000 } }); - fetchSoftwareProduct(softwareProductId).then(response => { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_LOADED, - response - }); - }); + const newVersionId = adjustMajorVersion(version.label, 1); + SoftwareProductActionHelper.fetchSoftwareProduct(dispatch,{softwareProductId, version: {id: newVersionId}}); + return Promise.resolve({newVersion: {id: newVersionId}}); }); }, error => dispatch({ - type: NotificationConstants.NOTIFY_ERROR, - data: {title: i18n('Submit Failed'), validationResponse: error.responseJSON} + type: modalActionTypes.GLOBAL_MODAL_ERROR, + data: { + modalComponentName: modalContentMapper.SUMBIT_ERROR_RESPONSE, + title: i18n('Submit Failed'), + modalComponentProps: { + validationResponse: error.responseJSON + }, + cancelButtonText: i18n('Ok') + } })); } else { - return putSoftwareProductAction(softwareProductId, action).then(() => { - fetchSoftwareProduct(softwareProductId).then(response => { - dispatch({ - type: actionTypes.SOFTWARE_PRODUCT_LOADED, - response - }); - }); + return putSoftwareProductAction(softwareProductId, action, version).then(() => { + let newVersionId = version.id; + /* + TODO Temorary switch to change version label + */ + switch(action) { + case VersionControllerActionsEnum.CHECK_OUT: + newVersionId = adjustMinorVersion(version.label, 1); + break; + case VersionControllerActionsEnum.UNDO_CHECK_OUT: + newVersionId = adjustMinorVersion(version.label, -1); + break; + } + SoftwareProductActionHelper.fetchSoftwareProduct(dispatch,{softwareProductId, version:{id: newVersionId}}); + return Promise.resolve({newVersion: {id: newVersionId}}); }); } }, switchVersion(dispatch, {softwareProductId, licenseModelId, version}) { - OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, version}); + OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, { + softwareProductId, + licenseModelId, + version + }); }, toggleNavigationItems(dispatch, {items, itemIdToExpand}) { @@ -327,7 +461,17 @@ const SoftwareProductActionHelper = { /** for the next verision */ addComponent(dispatch) { return dispatch; + }, + + migrateSoftwareProduct(dispatch, {softwareProduct}) { + let {licenseModelId, licensingVersion, id: softwareProductId, version, status} = softwareProduct; + const newVer = status === statusEnum.CHECK_IN_STATUS || status === statusEnum.SUBMIT_STATUS ? + adjustMinorVersion(version.id, 1) : version.id; + migrateSoftwareProduct(softwareProductId, version) + .then(() =>OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, + {softwareProductId, version: {id: newVer, label: newVer}, licenseModelId, licensingVersion})); } + }; 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 812afe5409..9b147415f9 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ - export default { getCurrentCategoryOfSubCategory(selectedSubCategory, softwareProductCategories) { diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js index 5f10c27084..f29b0f6e0d 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js @@ -1,28 +1,25 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; +import {enums} from 'sdc-app/onboarding/OnboardingConstants.js'; export const actionTypes = keyMirror({ SOFTWARE_PRODUCT_LOADED: null, 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, @@ -33,21 +30,46 @@ export const actionTypes = keyMirror({ OPEN: null, CLOSE: null, DATA_CHANGED: null, - IS_VALIDITY_DATA_CHANGED: null, - UPLOAD_CONFIRMATION: null + IS_VALIDITY_DATA_CHANGED: null } }); export const navigationItems = keyMirror({ - VENDOR_SOFTWARE_PRODUCT: 'Vendor Software Product', - GENERAL: 'General', - PROCESS_DETAILS: 'Process Details', - NETWORKS: 'Networks', - ATTACHMENTS: 'Attachments', - COMPONENTS: 'Components', + VENDOR_SOFTWARE_PRODUCT: 'vendor-software-product', + GENERAL: 'general', + PROCESS_DETAILS: 'process-details', + NETWORKS: 'networks', + DEPENDENCIES: 'dependencies', + ATTACHMENTS: 'attachments', + ACTIVITY_LOG: 'activity-log', + COMPONENTS: 'components', + + COMPUTE: 'compute', + LOAD_BALANCING: 'load-balancing', + STORAGE: 'storage', + MONITORING: 'monitoring' +}); - COMPUTE: 'Compute', - LOAD_BALANCING: 'Load Balancing', - STORAGE: 'Storage', - MONITORING: 'Monitoring' +export const forms = keyMirror({ + VENDOR_SOFTWARE_PRODUCT_DETAILS: 'vendor-software-product-details', }); + +export const PRODUCT_QUESTIONNAIRE = 'product'; + +export const mapScreenToNavigationItem = { + [enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE]: navigationItems.VENDOR_SOFTWARE_PRODUCT, + [enums.SCREEN.SOFTWARE_PRODUCT_DETAILS]: navigationItems.GENERAL, + [enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS]: navigationItems.ATTACHMENTS, + [enums.SCREEN.SOFTWARE_PRODUCT_PROCESSES]: navigationItems.PROCESS_DETAILS, + [enums.SCREEN.SOFTWARE_PRODUCT_NETWORKS]: navigationItems.NETWORKS, + [enums.SCREEN.SOFTWARE_PRODUCT_ACTIVITY_LOG]: navigationItems.ACTIVITY_LOG, + [enums.SCREEN.SOFTWARE_PRODUCT_DEPENDENCIES]: navigationItems.DEPENDENCIES, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENTS]: navigationItems.COMPONENTS, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_GENERAL]: navigationItems.GENERAL, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_COMPUTE]: navigationItems.COMPUTE, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_LOAD_BALANCING]: navigationItems.LOAD_BALANCING, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_NETWORK]: navigationItems.NETWORKS, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_STORAGE]: navigationItems.STORAGE, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_PROCESSES]: navigationItems.PROCESS_DETAILS, + [enums.SCREEN.SOFTWARE_PRODUCT_COMPONENT_MONITORING]: navigationItems.MONITORING, +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductListReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductListReducer.js index 6d1db1626f..2fde8c2216 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductConstants.js'; export default (state = [], action) => { diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js index 784ac9db84..97988d87f9 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/SoftwareProductReducer.js @@ -1,26 +1,23 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {combineReducers} from 'redux'; -import {actionTypes} from './SoftwareProductConstants.js'; -import SoftwareProductAttachmentsReducer from './attachments/SoftwareProductAttachmentsReducer.js'; +import {actionTypes, PRODUCT_QUESTIONNAIRE} from './SoftwareProductConstants.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 SoftwareProductCreationReducer from './creation/SoftwareProductCreationReducer.js'; import SoftwareProductDetailsReducer from './details/SoftwareProductDetailsReducer.js'; import SoftwareProductProcessesListReducer from './processes/SoftwareProductProcessesListReducer.js'; @@ -35,30 +32,40 @@ import {actionTypes as componentProcessesActionTypes} from './components/proces import SoftwareProductComponentsNICListReducer from './components/network/SoftwareProductComponentsNICListReducer.js'; import SoftwareProductComponentsNICEditorReducer from './components/network/SoftwareProductComponentsNICEditorReducer.js'; import SoftwareProductComponentsMonitoringReducer from './components/monitoring/SoftwareProductComponentsMonitoringReducer.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} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import {NIC_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js'; export default combineReducers({ - softwareProductAttachments: SoftwareProductAttachmentsReducer, - softwareProductCreation: SoftwareProductCreationReducer, - softwareProductEditor: SoftwareProductDetailsReducer, + softwareProductAttachments: combineReducers({ + 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: SoftwareProductProcessesEditorReducer, + processesEditor: createPlainDataReducer(SoftwareProductProcessesEditorReducer), processToDelete: (state = false, action) => action.type === processesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM ? action.processToDelete : state }), softwareProductNetworks: combineReducers({ networksList: SoftwareProductNetworksListReducer }), + softwareProductDependencies: SoftwareProductDependenciesReducer, softwareProductComponents: combineReducers({ componentsList: SoftwareProductComponentsListReducer, - componentEditor: SoftwareProductComponentEditorReducer, + componentEditor: createPlainDataReducer(createComposedJSONSchemaReducer(COMPONENTS_QUESTIONNAIRE, SoftwareProductComponentEditorReducer)), componentProcesses: combineReducers({ processesList: SoftwareProductComponentProcessesListReducer, - processesEditor: SoftwareProductComponentProcessesEditorReducer, + processesEditor: createPlainDataReducer(SoftwareProductComponentProcessesEditorReducer), processToDelete: (state = false, action) => action.type === componentProcessesActionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM ? action.processToDelete : state, }), network: combineReducers({ nicList: SoftwareProductComponentsNICListReducer, - nicEditor: SoftwareProductComponentsNICEditorReducer + nicEditor: createPlainDataReducer(createComposedJSONSchemaReducer(NIC_QUESTIONNAIRE, SoftwareProductComponentsNICEditorReducer)) }), monitoring: SoftwareProductComponentsMonitoringReducer }), @@ -68,13 +75,5 @@ export default combineReducers({ } return state; }, - softwareProductQuestionnaire: (state = {}, action) => { - if (action.type === actionTypes.SOFTWARE_PRODUCT_QUESTIONNAIRE_UPDATE) { - return { - ...state, - ...action.payload - }; - } - 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 a4b95a4b7e..8f2506abdd 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js @@ -1,42 +1,89 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 i18n from 'nfvo-utils/i18n/i18n.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 SoftwareProductAttachmentsActionHelper from './SoftwareProductAttachmentsActionHelper.js'; +import {errorLevels} from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js'; +import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; +import HeatSetup from './setup/HeatSetup.js'; +import {doesHeatDataExist} from './SoftwareProductAttachmentsUtils.js'; + +import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; + +export const mapStateToProps = (state) => { + let { + softwareProduct: { + softwareProductEditor:{data: currentSoftwareProduct = {}}, + softwareProductAttachments: {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); -export const mapStateToProps = ({softwareProduct: {softwareProductAttachments}}) => { - let {attachmentsTree, hoveredNode, selectedNode, errorList} = softwareProductAttachments; + let isReadOnlyMode = currentSoftwareProduct && currentSoftwareProduct.version ? + VersionControllerUtils.isReadOnly(currentSoftwareProduct) : false; + let {version} = currentSoftwareProduct; return { - attachmentsTree, - hoveredNode, - selectedNode, - errorList + isValidationAvailable: unassigned.length === 0 && modules.length > 0, + heatSetup, + heatSetupCache, + heatDataExist, + goToOverview, + HeatSetupComponent: HeatSetup, + isReadOnlyMode, + version }; }; -const mapActionsToProps = (dispatch) => { +export const mapActionsToProps = (dispatch, {softwareProductId}) => { return { - toggleExpanded: (path) => SoftwareProductAttachmentsActionHelper.toggleExpanded(dispatch, {path}), - onSelectNode: (nodeName) => SoftwareProductAttachmentsActionHelper.onSelectNode(dispatch, {nodeName}), - onUnselectNode: () => SoftwareProductAttachmentsActionHelper.onUnselectNode(dispatch) + onDownload: ({heatCandidate, isReadOnlyMode, version}) => SoftwareProductActionHelper.downloadHeatFile(dispatch, {softwareProductId, heatCandidate, isReadOnlyMode, version}), + onUpload: (formData, version) => dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data:{ + msg: i18n('Upload will erase existing data. Do you want to continue?'), + confirmationButtonText: i18n('Continue'), + onConfirmed: ()=>SoftwareProductActionHelper.uploadFile(dispatch, { + softwareProductId, + formData, + failedNotificationTitle: i18n('Upload validation failed'), + version + }) + } + }), + onSave: (heatCandidate, version) => SoftwareProductActionHelper.updateSoftwareProductHeatCandidate(dispatch, {softwareProductId, heatCandidate, version}), + onGoToOverview: () => { + OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId}); + }, + onProcessAndValidate: ({heatData, heatDataCache, isReadOnlyMode, version}) => { + return HeatSetupActionHelper.processAndValidateHeat(dispatch, + {softwareProductId, heatData, heatDataCache, isReadOnlyMode, version}); + } }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js deleted file mode 100644 index a7f7a5173b..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import {actionTypes} from './SoftwareProductAttachmentsConstants.js'; - -export default { - - toggleExpanded(dispatch, {path}) { - dispatch({ - type: actionTypes.TOGGLE_EXPANDED, - path - }); - }, - - onSelectNode(dispatch, {nodeName}) { - dispatch({ - type: actionTypes.SELECTED_NODE, - nodeName - }); - }, - - onUnselectNode(dispatch) { - dispatch({ - type: actionTypes.UNSELECTED_NODE - }); - } -}; 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 33af476d9c..b0410d1566 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js @@ -1,55 +1,19 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 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 -}); - -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') -}); - -export const nodeTypes = keyMirror({ - 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 -}); - +export const tabsMapping = { + SETUP: 1, + VALIDATION: 2 +}; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js deleted file mode 100644 index 5c5567b032..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsReducer.js +++ /dev/null @@ -1,199 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import {actionTypes as softwareProductsActionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; -import {actionTypes} from './SoftwareProductAttachmentsConstants.js'; - -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 mapArtifactsData = ({fileName, errors}) => ({ - name: fileName, - type: 'artifact', - 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) : []) - ] -}); - -function createErrorList(node, parent, deep = 0, errorList = []) { - if (node.errors) { - errorList.push(...node.errors.map((error) => ({ - errorLevel: 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 => { - let {HEAT, volume, network, artifacts, other} = validationData.importStructure || {}; - return { - children: [ - { - name: 'HEAT', - expanded: true, - type: 'heat', - children: (HEAT ? HEAT.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; -}; - -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; - }); - - 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; - let attachmentsTree = currentSoftwareProduct.validationData ? mapValidationDataToTree(currentSoftwareProduct.validationData) : {}; - let errorList = createErrorList(attachmentsTree); - return { - ...state, - attachmentsTree, - errorList - }; - 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: undefined - }; - 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 new file mode 100644 index 0000000000..2e76b11630 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsUtils.js @@ -0,0 +1,25 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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. + */ + +export function doesHeatDataExist(heatData) { + 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 c52999ca46..66fb2f8356 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx @@ -1,182 +1,119 @@ -import React from 'react'; -import FontAwesome from 'react-fontawesome'; -import classNames from 'classnames'; -import Collapse from 'react-bootstrap/lib/Collapse.js'; - +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component, PropTypes} from 'react'; +import Tabs from 'react-bootstrap/lib/Tabs.js'; +import Tab from 'react-bootstrap/lib/Tab.js'; +import {tabsMapping} from './SoftwareProductAttachmentsConstants.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import {nodeTypes, mouseActions} from './SoftwareProductAttachmentsConstants'; - -const typeToIcon = Object.freeze({ - heat: 'building-o', - volume: 'database', - network: 'cloud', - artifact: 'gear', - env: 'server', - other: 'cube' -}); +import Icon from 'nfvo-components/icon/Icon.jsx'; +import HeatValidation from './validation/HeatValidation.js'; -const leftPanelWidth = 250; - -class SoftwareProductAttachmentsView extends React.Component { +class HeatScreenView extends Component { static propTypes = { - attachmentsTree: React.PropTypes.object.isRequired + isValidationAvailable: PropTypes.bool, + goToOverview: PropTypes.bool }; + state = { - treeWidth: '400' + activeTab: tabsMapping.SETUP }; render() { - let {attachmentsTree, errorList} = this.props; - let {treeWidth} = this.state; + let {isValidationAvailable, isReadOnlyMode, heatDataExist, onDownload, softwareProductId, onProcessAndValidate, heatSetup, HeatSetupComponent, onGoToOverview, version, ...other} = this.props; return ( -
    -
    -
    - { - attachmentsTree && attachmentsTree.children && attachmentsTree.children.map((child, ind) => this.renderNode(child, [ind])) - } -
    +
    +
    + {(this.state.activeTab === tabsMapping.SETUP) && + onDownload({heatCandidate: heatSetup, isReadOnlyMode, version}) : undefined} + data-test-id='download-heat'/>} + {(this.state.activeTab === tabsMapping.VALIDATION && softwareProductId) && + } + {this.refs.hiddenImportFileInput.click(evt);}} + data-test-id='upload-heat'/> + this.handleImport(evt)}/>
    -
    this.onChangeTreeWidth(e)} className='software-product-attachments-separator'/> - -
    - {errorList.length ? this.renderErrorList(errorList) :
    {attachmentsTree.children ? - i18n('VALIDATION SUCCESS') : i18n('THERE IS NO HEAT DATA TO PRESENT') }
    } -
    -
    - ); - } - - renderNode(node, path) { - let isFolder = node.children && node.children.length > 0; - let {onSelectNode} = this.props; - return ( -
    - { -
    this.props.toggleExpanded(path)} className={this.getTreeRowClassName(node.name)}> - { - isFolder && -
    this.props.toggleExpanded(path)} className={classNames('tree-node-expander', {'tree-node-expander-collapsed': !node.expanded})}> - -
    - } - { - - - - - } - { - - onSelectNode(node.name)} className={this.getTreeTextClassName(node)}> - {node.name} - - } -
    - } - { - isFolder && - -
    - { - node.children.map((child, ind) => this.renderNode(child, [...path, ind])) - } -
    -
    - } + this.handleTabPress(key)}> + + this.setState({activeTab: tab})} + onProcessAndValidate={onProcessAndValidate} + softwareProductId={softwareProductId} + isReadOnlyMode={isReadOnlyMode} + version={version}/> + + + + +
    ); } - createErrorList(errorList, node, parent) { - if (node.errors) { - node.errors.forEach(error => errorList.push({ - error, - name: node.name, - parentName: parent.name, - type: node.type - })); + handleTabPress(key) { + let {heatSetup, heatSetupCache, onProcessAndValidate, isReadOnlyMode, version} = this.props; + switch (key) { + case tabsMapping.VALIDATION: + onProcessAndValidate({heatData: heatSetup, heatDataCache: heatSetupCache, isReadOnlyMode, version}).then( + () => this.setState({activeTab: tabsMapping.VALIDATION}) + ); + return; + case tabsMapping.SETUP: + this.setState({activeTab: tabsMapping.SETUP}); + return; } - if (node.children && node.children.length) { - node.children.map((child) => this.createErrorList(errorList, child, node)); - } - } - - renderErrorList(errors) { - let prevError = {}; - let {selectedNode} = this.props; - return errors.map(error => { - let isSameNodeError = error.name === prevError.name && error.parentName === prevError.parentName; - prevError = error; - - return ( -
    this.selectNode(error.name)} - className={classNames('error-item', {'clicked': selectedNode === error.name, 'shifted': !isSameNodeError})}> - - { - error.hasParent ? - i18n('{type} {name} in {parentName}: ', { - type: nodeTypes[error.type], - name: error.name, - parentName: error.parentName - }) : - i18n('{type} {name}: ', { - type: nodeTypes[error.type], - name: error.name - }) - } - - {error.errorMessage} -
    - ); - }); } - selectNode(currentSelectedNode) { - let {onUnselectNode, onSelectNode, selectedNode} = this.props; - if (currentSelectedNode !== selectedNode) { - onSelectNode(currentSelectedNode); - }else{ - onUnselectNode(); - } - - } - - getTreeRowClassName(name) { - let {hoveredNode, selectedNode} = this.props; - return classNames({ - 'tree-node-row': true, - 'tree-node-selected': name === hoveredNode, - 'tree-node-clicked': name === selectedNode - }); + handleImport(evt) { + evt.preventDefault(); + let {version} = this.props; + let formData = new FormData(); + formData.append('upload', this.refs.hiddenImportFileInput.files[0]); + this.refs.hiddenImportFileInput.value = ''; + this.props.onUpload(formData, version); + this.setState({activeTab: tabsMapping.SETUP}); } - getTreeTextClassName(node) { - let {selectedNode} = this.props; - return classNames({ - 'tree-element-text': true, - 'error-status': node.errors, - 'error-status-selected': node.name === selectedNode - }); + save() { + return this.props.onSave(this.props.heatSetup, this.props.version); } - 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); - } - } } -export default SoftwareProductAttachmentsView; +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 new file mode 100644 index 0000000000..4c3adc6a7d --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetup.js @@ -0,0 +1,62 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 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; +} + +export const mapStateToProps = ({softwareProduct: {softwareProductAttachments: {heatSetup, heatSetupCache}}}) => { + let {modules = [], unassigned = [], artifacts = [], nested = []} = heatSetup; + let isBaseExist = baseExists(modules); + + 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) + }; +}; + +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 new file mode 100644 index 0000000000..53143647a3 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js @@ -0,0 +1,77 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {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'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; + +export default { + + addModule(dispatch, isBase){ + dispatch({type: actionTypes.ADD_MODULE, data: {isBase}}); + }, + + deleteModule(dispatch, moduleName){ + dispatch({type: actionTypes.REMOVE_MODULE, data: {moduleName}}); + }, + + 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}}); + }, + + 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}})); + }, + + addAllUnassignedFilesToArtifacts(dispatch){ + dispatch({type: actionTypes.ADD_ALL_UNASSIGNED_TO_ARTIFACTS}); + }, + + heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) { + return new Promise((resolve, reject) => { + if (isEqual({...heatSetup, softwareProductId}, heatSetupCache)) { + resolve(); + } else { + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data:{ + msg: i18n(`You have uploaded a new HEAT. If you navigate away or Check-in without proceeding to validation, + Old HEAT zip file will be in use. new HEAT will be ignored. Do you want to continue?`), + confirmationButtonText: i18n('Continue'), + onConfirmed: () => resolve(), + onDeclined: () => reject() + } + }); + } + }); + } +}; 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 new file mode 100644 index 0000000000..2d6bd574a7 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js @@ -0,0 +1,42 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 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, + + 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 + +}); + +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} +}; 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 new file mode 100644 index 0000000000..f49339ce35 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupReducer.js @@ -0,0 +1,124 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {actionTypes} from './HeatSetupConstants.js'; +import differenceWith from 'lodash/differenceWith.js'; + + +const emptyModule = (isBase, currentLength) => ({ + 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 findModuleIndexByName(modules, 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]); + } + } + } + + 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; + } +}; 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 new file mode 100644 index 0000000000..0d8bc58361 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx @@ -0,0 +1,328 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component} from 'react'; +import Button from 'react-bootstrap/lib/Button.js'; +import Tooltip from 'react-bootstrap/lib/Tooltip.js'; +import OverlayTrigger from 'react-bootstrap/lib/OverlayTrigger.js'; +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 Icon from 'nfvo-components/icon/Icon.jsx'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import {fileTypes} from './HeatSetupConstants.js'; +import {tabsMapping} from '../SoftwareProductAttachmentsConstants.js'; +import {sortable} from 'react-sortable'; + +class ListItem extends Component { + + 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} = 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 ( +
    +
    +
    + {!isBaseExist && } + +
    +
    +
      {listItems}
    +
    + ); + } +} + +const tooltip = (name) => {name}; +const UnassignedFileList = (props) => { + return ( +
    +
    {i18n('UNASSIGNED FILES')}
    +
    {props.children}
    +
    + ); +}; + +const EmptyListContent = props => { + let {onClick, heatDataExist} = props; + let displayText = heatDataExist ? 'All Files Are Assigned' : ''; + return ( +
    +
    {i18n(displayText)}
    + {heatDataExist &&
    {i18n('Proceed To Validation')}
    } +
    + ); +}; +const UnassignedFile = (props) => ( + +
  • {props.name}
  • +
    +); + +const AddOrDeleteVolumeFiels = ({add = true, onAdd, onDelete}) => { + const displayText = add ? 'Add Volume Files' : 'Delete Volume Files'; + const action = add ? onAdd : onDelete; + return ( +
    + + {i18n(displayText)} +
    + ); +}; + +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}/> + ); + } +} + +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} = 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} = this.props; + return ( +
    +
    + + {type === 'artifact' && ()} + {`${title}`} + + {type === 'artifact' && {i18n('Add All Unassigned Files')}} +
    + {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); + +class SoftwareProductHeatSetupView extends Component { + + processAndValidateHeat(heatData, heatDataCache){ + let {onProcessAndValidate, changeAttachmentsTab, version} = this.props; + onProcessAndValidate({heatData, heatDataCache, version}).then( + () => changeAttachmentsTab(tabsMapping.VALIDATION) + ); + } + + render() { + let {modules, heatSetupCache, isReadOnlyMode, heatDataExist, unassigned, artifacts, nested, onArtifactListChange, onAddAllUnassigned} = this.props; + + const formattedUnassigned = unassigned.map(buildLabelValueObject); + const formattedArtifacts = artifacts.map(buildLabelValueObject); + return ( +
    +
    + + + +
    + + { + formattedUnassigned.length > 0 ? + (
      {formattedUnassigned.map(file => )}
    ) + : + ( this.processAndValidateHeat({modules, unassigned, artifacts, nested}, heatSetupCache)}/>) + } +
    +
    + ); + } + +} + +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 new file mode 100644 index 0000000000..21f6e6c77f --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidation.js @@ -0,0 +1,51 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 HeatValidationView from './HeatValidationView.jsx'; +import HeatValidationActionHelper from './HeatValidationActionHelper.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 + }; +}; + +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); 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 new file mode 100644 index 0000000000..73366c20cc --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js @@ -0,0 +1,39 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {actionTypes} from './HeatValidationConstants.js'; + +export default { + + toggleExpanded(dispatch, {path}) { + dispatch({ + type: actionTypes.TOGGLE_EXPANDED, + path + }); + }, + + onSelectNode(dispatch, {nodeName}) { + dispatch({ + type: actionTypes.SELECTED_NODE, + nodeName + }); + }, + + 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 new file mode 100644 index 0000000000..f783fe6482 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js @@ -0,0 +1,57 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 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 +}); + +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') +}); + +export const errorLevels = keyMirror({ + WARNING: 'WARNING', + ERROR: 'ERROR' +}); +export const nodeFilters = keyMirror({ + ALL: 'All' +}); +export const nodeTypes = keyMirror({ + 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 +}); + 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 new file mode 100644 index 0000000000..f0c10ed457 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationReducer.js @@ -0,0 +1,196 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {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 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 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) : []) + ] +}); + +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; +} + +const mapValidationDataToTree = validationData => { + let {heat, volume, network, artifacts, other} = validationData.importStructure || {}; + return { + children: [ + { + name: 'HEAT', + expanded: true, + type: 'heat', + header: true, + children: (heat ? heat.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; +}; + +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; + }); + + 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; + let attachmentsTree = currentSoftwareProduct.validationData ? mapValidationDataToTree(currentSoftwareProduct.validationData) : {}; + 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 new file mode 100644 index 0000000000..25ad90f351 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx @@ -0,0 +1,274 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component, PropTypes} from 'react'; +import classNames from 'classnames'; +import Collapse from 'react-bootstrap/lib/Collapse.js'; +import Icon from 'nfvo-components/icon/Icon.jsx'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import {mouseActions, errorLevels, nodeFilters} from './HeatValidationConstants.js'; + +const leftPanelWidth = 250; +const typeToIcon = Object.freeze({ + heat: 'heat', + volume: 'volume', + network: 'network', + artifact: 'validation-artifacts', + env: 'env', + other: 'validation-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 + }; + + 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)} /> +
    ); +} + +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(`HEAT${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(); + } + + + + } + + 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) ? + + + {i18n('{errorName}:', { + errorName: error.name + })} + + + {i18n('{message}', {message: error.errorMessage})} + + : + i18n('{errorMsg}', { + errorMsg: 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 errIcon = 'error'; + let {size} = this.props; + if (size && size === 'large') { + errIcon += '-lg'; + } + 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 3b8bc4f171..2ae9ad0bae 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentEditorReducer.js @@ -1,44 +1,43 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductComponentsConstants.js'; +import {actionTypes, forms} from './SoftwareProductComponentsConstants.js'; export default (state = {}, action) => { switch (action.type) { - 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: + case actionTypes.COMPONENT_LOAD: return { ...state, - data: { - ...state.data, - ...action.deltaData + formReady: null, + formName: forms.ALL_SPC_FORMS, + genericFieldInfo: { + 'displayName' : { + isValid: true, + errorText: '', + validations: [] + }, + 'vfcCode' : { + isValid: true, + errorText: '', + validations: [] + }, + 'description' : { + isValid: true, + errorText: '', + validations: [] + } } }; default: 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 e53b2ecafe..9b3c9eaa73 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js @@ -1,56 +1,51 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -import {actionTypes} from './SoftwareProductComponentsConstants.js'; +import {actionTypes, COMPONENTS_QUESTIONNAIRE, forms} from './SoftwareProductComponentsConstants.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; -function baseUrl(softwareProductId) { +function baseUrl(softwareProductId, version) { + const versionId = version.id; const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components`; + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components`; } function fetchSoftwareProductComponents(softwareProductId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(softwareProductId)}${versionQuery}`); + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); } -function putSoftwareProductComponentQuestionnaire(softwareProductId, vspComponentId, vspComponent) { - return RestAPIUtil.save(`${baseUrl(softwareProductId)}/${vspComponentId}/questionnaire`, vspComponent); +function putSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId, vspComponent) { + return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${vspComponentId}/questionnaire`, vspComponent); } -function fetchSoftwareProductComponentQuestionnaire(softwareProductId, vspComponentId, version){ - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(softwareProductId)}/${vspComponentId}/questionnaire${versionQuery}`); +function fetchSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId){ + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}/${vspComponentId}/questionnaire`); } -function fetchSoftwareProductComponent(softwareProductId, vspComponentId, version){ - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(softwareProductId)}/${vspComponentId}${versionQuery}`); +function fetchSoftwareProductComponent(softwareProductId, version, vspComponentId){ + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}/${vspComponentId}`); } -function putSoftwareProductComponent(softwareProductId, vspComponentId, vspComponent) { - return RestAPIUtil.save(`${baseUrl(softwareProductId)}/${vspComponentId}`, { +function putSoftwareProductComponent(softwareProductId, version, vspComponentId, vspComponent) { + return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${vspComponentId}`, { name: vspComponent.name, displayName: vspComponent.displayName, + vfcCode: vspComponent.vfcCode, description: vspComponent.description }); } @@ -65,27 +60,19 @@ const SoftwareProductComponentsActionHelper = { }); }, - componentDataChanged(dispatch, {deltaData}) { - dispatch({ - type: actionTypes.COMPONENT_DATA_CHANGED, - deltaData - }); - }, - - - updateSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId, componentData, qdata}) { + updateSoftwareProductComponent(dispatch, {softwareProductId, version, vspComponentId, componentData, qdata}) { return Promise.all([ - SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId, qdata}), - SoftwareProductComponentsActionHelper.updateSoftwareProductComponentData(dispatch, {softwareProductId, vspComponentId, componentData}) + SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId, qdata}), + SoftwareProductComponentsActionHelper.updateSoftwareProductComponentData(dispatch, {softwareProductId, version, vspComponentId, componentData}) ]); }, - updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId, qdata}) { - return putSoftwareProductComponentQuestionnaire(softwareProductId, vspComponentId, qdata); + updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId, qdata}) { + return putSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId, qdata); }, - updateSoftwareProductComponentData(dispatch, {softwareProductId, vspComponentId, componentData}) { - return putSoftwareProductComponent(softwareProductId, vspComponentId, componentData).then(() => dispatch({ + updateSoftwareProductComponentData(dispatch, {softwareProductId, version, vspComponentId, componentData}) { + return putSoftwareProductComponent(softwareProductId, version, vspComponentId, componentData).then(() => dispatch({ type: actionTypes.COMPONENTS_LIST_EDIT, component: { id: vspComponentId, @@ -94,36 +81,36 @@ const SoftwareProductComponentsActionHelper = { })); }, - - fetchSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId, version}) { - return fetchSoftwareProductComponentQuestionnaire(softwareProductId, vspComponentId, version).then(response => { - dispatch({ - type: actionTypes.COMPONENT_QUESTIONNAIRE_UPDATE, - payload: { - qdata: response.data ? JSON.parse(response.data) : {}, - qschema: JSON.parse(response.schema) - } - }); + 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, vspComponentId, version}) { - return fetchSoftwareProductComponent(softwareProductId, vspComponentId, version).then(response => { - dispatch({ - type: actionTypes.COMPONENT_UPDATE, - component: response.data - }); + fetchSoftwareProductComponent(dispatch, {softwareProductId, version, vspComponentId}) { + dispatch({ + type: actionTypes.COMPONENT_LOAD }); + return Promise.all([ + fetchSoftwareProductComponent(softwareProductId, version, vspComponentId).then(response => { + ValidationHelper.dataChanged(dispatch,{deltaData: response.data, formName: forms.ALL_SPC_FORMS}); + 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)}}); + }) + ]); }, - componentQuestionnaireUpdated(dispatch, {data}) { + + clearComponentsStore(dispatch) { dispatch({ - type: actionTypes.COMPONENT_QUESTIONNAIRE_UPDATE, - payload: { - qdata: data - } + type: actionTypes.COMPONENTS_LIST_UPDATE, + componentsList: [] }); - }, + } }; 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 dee517e5d1..9307b099ed 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js @@ -1,31 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 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_QUESTIONNAIRE_UPDATE: null + COMPONENT_LOAD: null }); export const storageConstants = keyMirror({ @@ -35,12 +28,18 @@ export const storageConstants = keyMirror({ } }); +export const forms = keyMirror({ + ALL_SPC_FORMS: null, + NIC_EDIT_FORM: null +}); + +export const COMPONENTS_QUESTIONNAIRE = 'component'; + export const navigationItems = keyMirror({ STORAGE: 'Storage', PROCESS_DETAILS: 'Process Details', MONITORING: 'Monitoring', NETWORK: 'Network', COMPUTE: 'Compute', - NETWORK: 'Network', LOAD_BALANCING: 'High Availability & Load Balancing' }); diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsList.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsList.js index f1c1ed1fcc..f789a92c6f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsList.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsList.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 SoftwareProductComponentsListView from './SoftwareProductComponentsListView.jsx'; import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; @@ -37,9 +32,9 @@ const mapStateToProps = ({softwareProduct}) => { }; -const mapActionToProps = (dispatch, {version}) => { +const mapActionToProps = (dispatch) => { return { - onComponentSelect: ({id: softwareProductId, componentId}) => { + onComponentSelect: ({id: softwareProductId, componentId, version}) => { OnboardingActionHelper.navigateToSoftwareProductComponentGeneralAndUpdateLeftPanel(dispatch, {softwareProductId, componentId, version }); } }; 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 b91362a0cf..c7aaca5573 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductComponentsConstants.js'; export default (state = [], action) => { 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 0c0ba0f646..c28831fbde 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsListView.jsx @@ -1,8 +1,24 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; 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 ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; const ComponentPropType = React.PropTypes.shape({ id: React.PropTypes.string, @@ -43,8 +59,9 @@ class SoftwareProductComponentsListView extends React.Component { title={i18n('Virtual Function Components')} filterValue={localFilter} placeholder={i18n('Filter Components')} - onFilter={filter => this.setState({localFilter: filter})} - isReadOnlyMode={isReadOnlyMode}> + onFilter={value => this.setState({localFilter: value})} + isReadOnlyMode={isReadOnlyMode} + twoColumns> {this.filterList().map(component => this.renderComponentsListItem(component))} ); @@ -52,20 +69,18 @@ class SoftwareProductComponentsListView extends React.Component { renderComponentsListItem(component) { let {id: componentId, name, displayName, description = ''} = component; - let {currentSoftwareProduct: {id}, onComponentSelect} = this.props; + let {currentSoftwareProduct: {id, version}, onComponentSelect} = this.props; return ( onComponentSelect({id, componentId})}> -
    -
    {i18n('Component')}
    + onSelect={() => onComponentSelect({id, componentId, version})}> +
    {displayName}
    -
    -
    -
    {i18n('Description')}
    + +
    {description}
    -
    +
    ); } 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 7ac1c707ab..e97477b54d 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 @@ -1,51 +1,46 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 SoftwareProductComponentComputeView from './SoftwareProductComponentComputeView.jsx'; import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import {COMPONENTS_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; const mapStateToProps = ({softwareProduct}) => { let {softwareProductEditor: {data: currentVSP}, softwareProductComponents} = softwareProduct; - let {componentEditor: {qdata, qschema}} = softwareProductComponents; + let {componentEditor: {qdata, dataMap, qgenericFieldInfo}} = softwareProductComponents; let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentVSP); - let minNumberOfVMsSelectedByUser = 0; - if(qdata && qdata.compute && qdata.compute.numOfVMs){ - minNumberOfVMsSelectedByUser = qdata.compute.numOfVMs.minimum || 0; - } - return { qdata, - qschema, - isReadOnlyMode, - minNumberOfVMsSelectedByUser + dataMap, + qgenericFieldInfo, + isReadOnlyMode }; }; -const mapActionToProps = (dispatch, {softwareProductId, componentId}) => { +const mapActionToProps = (dispatch, {softwareProductId, version, componentId}) => { return { - onQDataChanged: ({data}) => SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(dispatch, {data}), - onSubmit: ({qdata}) =>{ return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId: componentId, qdata});} + 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}) }; }; 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 3bad147117..8c197f0d49 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 @@ -1,128 +1,71 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; -import i18n from 'nfvo-utils/i18n/i18n.js'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from'nfvo-components/input/validation/ValidationInput.jsx'; - +import Form from 'nfvo-components/input/validation/Form.jsx'; +import VmSizing from './computeComponents/VmSizing.jsx'; +import NumberOfVms from './computeComponents/NumberOfVms.jsx'; +import GuestOs from './computeComponents/GuestOs.jsx'; +import Validator from 'nfvo-utils/Validator.js'; class SoftwareProductComponentComputeView extends React.Component { static propTypes = { - qdata: React.PropTypes.object, - qschema: React.PropTypes.object, + dataMap: React.PropTypes.object, + qgenericFieldInfo: React.PropTypes.object, isReadOnlyMode: React.PropTypes.bool, - minNumberOfVMsSelectedByUser: React.PropTypes.number, onQDataChanged: React.PropTypes.func.isRequired, + qValidateData: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired }; render() { - let {qdata, qschema, isReadOnlyMode, minNumberOfVMsSelectedByUser, onQDataChanged, onSubmit} = this.props; + let {qdata, dataMap, qgenericFieldInfo, isReadOnlyMode, onQDataChanged, qValidateData, onSubmit} = this.props; return (
    - { this.form = form; }} + formReady={null} + isValid={true} hasButtons={false} onSubmit={() => onSubmit({qdata})} className='component-questionnaire-validation-form' - isReadOnlyMode={isReadOnlyMode} - onDataChanged={onQDataChanged} - data={qdata} - schema={qschema}> - -
    {i18n('VM Sizing')}
    -
    -
    -
    - -
    -
    - -
    -
    - -
    - -
    -
    -
    {i18n('Number of VMs')}
    -
    -
    -
    - -
    -
    - -
    -
    - -
    - -
    -
    - -
    {i18n('Guest OS')}
    -
    -
    -
    - -
    -
    -
    -
    - -
    - -
    -
    -
    -
    - -
    -
    -
    -
    - + isReadOnlyMode={isReadOnlyMode} > + + + + }
    ); } save(){ - return this.refs.computeValidationForm.handleFormSubmit(new Event('dummy')); + return this.form.handleFormSubmit(new Event('dummy')); + } + + validateMin(value, state) { + let maxVal = state.dataMap['compute/numOfVMs/maximum']; + return Validator.validateItem(value,maxVal,'maximum'); + } + + validateMax(value, state) { + let minVal = state.dataMap['compute/numOfVMs/minimum']; + return Validator.validateItem(value,minVal,'minimum'); } } 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 new file mode 100644 index 0000000000..7a730d6f94 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/GuestOs.jsx @@ -0,0 +1,76 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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 GuestOs = ({qgenericFieldInfo, dataMap, onQDataChanged}) => { + return( +
    + + + onQDataChanged({'compute/guestOS/name' : tools})} + isValid={qgenericFieldInfo['compute/guestOS/name'].isValid} + errorText={qgenericFieldInfo['compute/guestOS/name'].errorText} + value={dataMap['compute/guestOS/name']} /> + + + +
    + +
    + {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/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 new file mode 100644 index 0000000000..efeedc653e --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/NumberOfVms.jsx @@ -0,0 +1,94 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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 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 selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({'compute/numOfVMs/CpuOverSubscriptionRatio' : val});} + }> + + {qgenericFieldInfo['compute/numOfVMs/CpuOverSubscriptionRatio'].enum.map(cpuOSR => )} + + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({'compute/numOfVMs/MemoryRAM' : val});} + }> + + {qgenericFieldInfo['compute/numOfVMs/MemoryRAM'].enum.map(mRAM => )} + + + + ); +}; + +NumberOfVms.propTypes = { + minNumberOfVMsSelectedByUser: React.PropTypes.number +}; + +export default NumberOfVms; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/VmSizing.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/VmSizing.jsx new file mode 100644 index 0000000000..39f84807a2 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/compute/computeComponents/VmSizing.jsx @@ -0,0 +1,68 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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({'compute/vmSizing/numOfCPUs' : tools})} + isValid={qgenericFieldInfo['compute/vmSizing/numOfCPUs'].isValid} + errorText={qgenericFieldInfo['compute/vmSizing/numOfCPUs'].errorText} + value={dataMap['compute/vmSizing/numOfCPUs']} /> + + + onQDataChanged({'compute/vmSizing/fileSystemSizeGB' : tools})} + isValid={qgenericFieldInfo['compute/vmSizing/fileSystemSizeGB'].isValid} + errorText={qgenericFieldInfo['compute/vmSizing/fileSystemSizeGB'].errorText} + value={dataMap['compute/vmSizing/fileSystemSizeGB']} /> + + + onQDataChanged({'compute/vmSizing/persistentStorageVolumeSize' : tools})} + isValid={qgenericFieldInfo['compute/vmSizing/persistentStorageVolumeSize'].isValid} + errorText={qgenericFieldInfo['compute/vmSizing/persistentStorageVolumeSize'].errorText} + value={dataMap['compute/vmSizing/persistentStorageVolumeSize']} /> + + + onQDataChanged({'compute/vmSizing/IOOperationsPerSec' : tools})} + isValid={qgenericFieldInfo['compute/vmSizing/IOOperationsPerSec'].isValid} + errorText={qgenericFieldInfo['compute/vmSizing/IOOperationsPerSec'].errorText} + value={dataMap['compute/vmSizing/IOOperationsPerSec']} /> + + + ); +}; + +export default VmSizing; 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 e4c330bec8..34374aa7fb 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 @@ -1,50 +1,55 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 SoftwareProductComponentsGeneralView from './SoftwareProductComponentsGeneralView.jsx'; import SoftwareProductComponentsActionHelper from '../SoftwareProductComponentsActionHelper.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.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'; + export const mapStateToProps = ({softwareProduct}) => { let {softwareProductEditor: {data: currentVSP}, softwareProductComponents} = softwareProduct; - let {componentEditor: {data: componentData = {} , qdata, qschema}} = softwareProductComponents; - + let {componentEditor: {data: componentData = {} , qdata, qgenericFieldInfo : qGenericFieldInfo, dataMap, genericFieldInfo}} = softwareProductComponents; let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentVSP); + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); return { componentData, qdata, - qschema, - isReadOnlyMode + isReadOnlyMode, + genericFieldInfo, + qGenericFieldInfo, + dataMap, + isFormValid }; }; -const mapActionsToProps = (dispatch, {softwareProductId, componentId}) => { +const mapActionsToProps = (dispatch, {softwareProductId, version, componentId}) => { return { - onDataChanged: deltaData => SoftwareProductComponentsActionHelper.componentDataChanged(dispatch, {deltaData}), - onQDataChanged: ({data}) => SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(dispatch, {data}), + 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, vspComponentId: componentId, componentData, qdata}); - } + {softwareProductId, version, vspComponentId: componentId, componentData, qdata}); + }, + onValidityChanged: isValidityData => SoftwareProductActionHelper.setIsValidityData(dispatch, {isValidityData}) }; }; 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 5d11e42cd3..e4595f97d6 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 @@ -1,177 +1,285 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from'nfvo-components/input/validation/ValidationInput.jsx'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +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, description, isReadOnlyMode, genericFieldInfo}) => ( + + {/* disabled until backend will be ready to implement it +
    +
    + +
    {name}
    +
    +
    + + */} + + + onDataChanged({vfcCode})} + 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 ImageSection = ({dataMap, onQDataChanged, qgenericFieldInfo}) => ( + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({'general/image/format' : val});} + }> + + {qgenericFieldInfo['general/image/format'].enum.map(hv => )} + + + + { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({'general/image/providedBy' : val});} + }> + + {qgenericFieldInfo['general/image/providedBy'].enum.map(hv => )} + + + + onQDataChanged({'general/image/bootDiskSizePerVM' : bootDiskSizePerVM})} + label={i18n('Size of boot disk per VM (GB)')} + type='number' + isValid={qgenericFieldInfo['general/image/bootDiskSizePerVM'].isValid} + errorText={qgenericFieldInfo['general/image/bootDiskSizePerVM'].errorText} + value={dataMap['general/image/bootDiskSizePerVM']}/> + + + onQDataChanged({'general/image/ephemeralDiskSizePerVM' : ephemeralDiskSizePerVM})} + label={i18n('Size of ephemeral disk per VM (GB)')} + type='number' + isValid={qgenericFieldInfo['general/image/ephemeralDiskSizePerVM'].isValid} + errorText={qgenericFieldInfo['general/image/ephemeralDiskSizePerVM'].errorText} + value={dataMap['general/image/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 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']}/> + + +); class SoftwareProductComponentsGeneralView extends React.Component { render() { - let {qdata, qschema, onQDataChanged, onDataChanged, componentData: {displayName, description}, isReadOnlyMode} = this.props; + let {onQDataChanged, onDataChanged, genericFieldInfo, dataMap, qGenericFieldInfo, componentData: {displayName, vfcCode, description}, isReadOnlyMode} = this.props; return(
    - -
    -

    {i18n('General')}

    -
    -
    - {/** disabled until backend will be ready to implement it -
    -
    - -
    {name}
    -
    -
    - - */} -
    - -
    -
    - onDataChanged({description})} - disabled={isReadOnlyMode} - value={description} - type='textarea'/> -
    -
    -
    -
    -
    - - { - qschema && - this.props.onValidityChanged(isValidityData)} hasButtons={false}> -

    {i18n('Hypervisor')}

    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    - -
    -
    -
    -
    -

    {i18n('Image')}

    -
    -
    -
    - -
    -
    - -
    -
    - -
    - -
    -
    -

    {i18n('Recovery')}

    -
    -
    -
    - -
    - -
    -
    - - -
    -
    - -
    -
    - { - /** disabled until backend will be ready to implement it -
    -
    - -
    -
    - */ - } -
    -
    -

    {i18n('DNS Configuration')}

    -
    -
    -
    - -
    -
    -
    -
    -

    {i18n('Clone')}

    -
    -
    -
    - -
    -
    -
    -
    - - } + + + + + + + }
    ); 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 4d4034de5b..0634858219 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 @@ -1,45 +1,43 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 SoftwareProductComponentLoadBalancingView from './SoftwareProductComponentLoadBalancingRefView.jsx'; import SoftwareProductComponentsActionHelper from '../SoftwareProductComponentsActionHelper.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import {COMPONENTS_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; export const mapStateToProps = ({softwareProduct}) => { let {softwareProductEditor: {data: currentVSP}, softwareProductComponents} = softwareProduct; - let {componentEditor: {qdata, qschema}} = softwareProductComponents; + let {componentEditor: {qdata, qgenericFieldInfo : genericFieldInfo, dataMap}} = softwareProductComponents; let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentVSP); return { qdata, - qschema, + genericFieldInfo, + dataMap, isReadOnlyMode }; }; -const mapActionsToProps = (dispatch, {softwareProductId, componentId}) => { +const mapActionsToProps = (dispatch, {softwareProductId, version, componentId}) => { return { - onQDataChanged: ({data}) => SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(dispatch, {data}), - onSubmit: ({qdata}) =>{ return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId: componentId, qdata});} + onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, qName: COMPONENTS_QUESTIONNAIRE}), + onSubmit: ({qdata}) =>{ return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId: componentId, qdata});} }; }; 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 1aa2babc12..dc86771400 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 @@ -1,11 +1,29 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; -import FontAwesome from 'react-fontawesome'; +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from'nfvo-components/input/validation/ValidationInput.jsx'; +import Form from 'nfvo-components/input/validation/Form.jsx'; +import Input from'nfvo-components/input/validation/Input.jsx'; -const prefix = '/highAvailabilityAndLoadBalancing/'; +import GridSection from 'nfvo-components/grid/GridSection.jsx'; +import GridItem from 'nfvo-components/grid/GridItem.jsx'; + +const prefix = 'highAvailabilityAndLoadBalancing/'; const pointers = [ { @@ -33,6 +51,31 @@ const pointers = [ } ]; +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: React.PropTypes.string.isRequired, @@ -46,42 +89,65 @@ class SoftwareProductComponentLoadBalancingView extends React.Component { expanded: {} }; - renderTextAreaItem(item) { - return ( -
    -
    this.toggle(item.key)}> - - {i18n(item.description)} - {item.added &&
    {i18n(item.added)}
    } -
    -
    -
    -
    - -
    -
    -
    -
    - ); - } - render() { - let {qdata, qschema, onQDataChanged, isReadOnlyMode} = this.props; + let {dataMap, genericFieldInfo, onQDataChanged, isReadOnlyMode} = this.props; return (
    -
    {i18n('High Availability & Load Balancing')}
    - this.save()} isReadOnlyMode={isReadOnlyMode} hasButtons={false}> - {pointers.map(pointer => this.renderTextAreaItem(pointer))} - + + + { + 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);}} />)} + + }
    ); 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 ed7c5a116a..293e252dca 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 @@ -1,27 +1,25 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import SoftwareProductComponentsMonitoringView from './SoftwareProductComponentsMonitoringView.jsx'; import SoftwareProductComponentsMonitoringAction from './SoftwareProductComponentsMonitoringActionHelper.js'; +import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; +import i18n from 'nfvo-utils/i18n/i18n.js'; + export const mapStateToProps = ({softwareProduct}) => { @@ -37,11 +35,12 @@ export const mapStateToProps = ({softwareProduct}) => { }; }; -const mapActionsToProps = (dispatch, {softwareProductId, componentId}) => { +const mapActionsToProps = (dispatch, {softwareProductId, version, componentId}) => { return { onDropMibFileToUpload: (formData, type) => SoftwareProductComponentsMonitoringAction.uploadSnmpFile(dispatch, { softwareProductId, + version, componentId, formData, type @@ -49,9 +48,18 @@ const mapActionsToProps = (dispatch, {softwareProductId, componentId}) => { onDeleteSnmpFile: type => SoftwareProductComponentsMonitoringAction.deleteSnmpFile(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.') + } + }), }; }; 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 3faf571c09..64403faa78 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 @@ -1,80 +1,76 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 i18n from 'nfvo-utils/i18n/i18n.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; -import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js'; import Configuration from 'sdc-app/config/Configuration.js'; import SoftwareProductComponentsMonitoringConstants, {actionTypes} from './SoftwareProductComponentsMonitoringConstants.js'; +import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; const UPLOAD = true; -function baseUrl(vspId, componentId) { +function baseUrl(vspId, version, componentId) { + const versionId = version.id; const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${vspId}/components/${componentId}/monitors`; + return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/components/${componentId}/monitors`; } -function snmpTrapUrl(vspId, componentId, isUpload) { - return `${baseUrl(vspId, componentId)}/snmp-trap${isUpload ? '/upload' : ''}`; +function snmpTrapUrl(vspId, version, componentId, isUpload) { + return `${baseUrl(vspId, version, componentId)}/snmp-trap${isUpload ? '/upload' : ''}`; } -function snmpPollUrl(vspId, componentId, isUpload) { - return `${baseUrl(vspId, componentId)}/snmp${isUpload ? '/upload' : ''}`; +function snmpPollUrl(vspId, version, componentId, isUpload) { + return `${baseUrl(vspId, version, componentId)}/snmp${isUpload ? '/upload' : ''}`; } let onInvalidFileSizeUpload = (dispatch) => dispatch({ - type: NotificationConstants.NOTIFY_ERROR, + type: modalActionTypes.GLOBAL_MODAL_ERROR, data: { title: i18n('Upload Failed'), msg: i18n('no zip file was uploaded or zip file doesn\'t exist') } }); -let uploadSnmpTrapFile = (dispatch, {softwareProductId, componentId, formData}) => { - RestAPIUtil.create(snmpTrapUrl(softwareProductId, componentId, UPLOAD), formData).then(()=> dispatch({ +let uploadSnmpTrapFile = (dispatch, {softwareProductId, version, componentId, formData}) => { + RestAPIUtil.post(snmpTrapUrl(softwareProductId, version, componentId, UPLOAD), formData).then(()=> dispatch({ type: actionTypes.SNMP_TRAP_UPLOADED, data: {filename: formData.get('upload').name} })); }; -let uploadSnmpPollFile = (dispatch, {softwareProductId, componentId, formData}) => { - RestAPIUtil.create(snmpPollUrl(softwareProductId, componentId, UPLOAD), formData).then(()=> dispatch({ +let uploadSnmpPollFile = (dispatch, {softwareProductId, version, componentId, formData}) => { + RestAPIUtil.post(snmpPollUrl(softwareProductId, version, componentId, UPLOAD), formData).then(()=> dispatch({ type: actionTypes.SNMP_POLL_UPLOADED, data: {filename: formData.get('upload').name} })); }; -let deleteSnmpTrapFile = (dispatch, {softwareProductId, componentId}) => { - RestAPIUtil.destroy(snmpTrapUrl(softwareProductId, componentId, !UPLOAD)).then(()=> dispatch({ +let deleteSnmpTrapFile = (dispatch, {softwareProductId, version, componentId}) => { + RestAPIUtil.destroy(snmpTrapUrl(softwareProductId, version, componentId, !UPLOAD)).then(()=> dispatch({ type: actionTypes.SNMP_TRAP_DELETED })); }; -let deleteSnmpPollFile = (dispatch, {softwareProductId, componentId}) => { - RestAPIUtil.destroy(snmpPollUrl(softwareProductId, componentId, !UPLOAD)).then(()=> dispatch({ +let deleteSnmpPollFile = (dispatch, {softwareProductId, version, componentId}) => { + RestAPIUtil.destroy(snmpPollUrl(softwareProductId, version, componentId, !UPLOAD)).then(()=> dispatch({ type: actionTypes.SNMP_POLL_DELETED })); }; const SoftwareProductComponentsMonitoringAction = { - fetchExistingFiles(dispatch, {softwareProductId, componentId}){ - RestAPIUtil.fetch(`${baseUrl(softwareProductId, componentId)}/snmp`).then(response => + fetchExistingFiles(dispatch, {softwareProductId, version, componentId}){ + RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}/snmp`).then(response => dispatch({ type: actionTypes.SNMP_FILES_DATA_CHANGE, data: {trapFilename: response.snmpTrap, pollFilename: response.snmpPoll} @@ -82,13 +78,13 @@ const SoftwareProductComponentsMonitoringAction = { ); }, - uploadSnmpFile(dispatch, {softwareProductId, componentId, formData, type}){ + uploadSnmpFile(dispatch, {softwareProductId, version, componentId, formData, type}){ if (formData.get('upload').size) { if (type === SoftwareProductComponentsMonitoringConstants.SNMP_TRAP) { - uploadSnmpTrapFile(dispatch, {softwareProductId, componentId, formData}); + uploadSnmpTrapFile(dispatch, {softwareProductId, version, componentId, formData}); } else { - uploadSnmpPollFile(dispatch, {softwareProductId, componentId, formData}); + uploadSnmpPollFile(dispatch, {softwareProductId, version, componentId, formData}); } } else { @@ -96,12 +92,12 @@ const SoftwareProductComponentsMonitoringAction = { } }, - deleteSnmpFile(dispatch, {softwareProductId, componentId, type}){ + deleteSnmpFile(dispatch, {softwareProductId, version, componentId, type}){ if (type === SoftwareProductComponentsMonitoringConstants.SNMP_TRAP) { - deleteSnmpTrapFile(dispatch, {softwareProductId, componentId}); + deleteSnmpTrapFile(dispatch, {softwareProductId, version, componentId}); } else { - deleteSnmpPollFile(dispatch, {softwareProductId, componentId}); + deleteSnmpPollFile(dispatch, {softwareProductId, version, componentId}); } } 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 eeececb050..d908d36aaa 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 @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ 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 72e0a85b10..54513b9634 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 @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductComponentsMonitoringConstants.js'; export default (state = {}, action) => { 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 ca090c5f2f..329cc70353 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 @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component, PropTypes} from 'react'; import Dropzone from 'react-dropzone'; import ButtonGroup from 'react-bootstrap/lib/ButtonGroup.js'; @@ -46,7 +61,7 @@ class SoftwareProductComponentsMonitoringView extends Component { return ( this.handleImport(files, {isReadOnlyMode, type, refAndName})} + onDrop={(acceptedFiles, rejectedFiles) => this.handleImport(acceptedFiles, rejectedFiles, {isReadOnlyMode, type, refAndName})} onDragEnter={() => this.handleOnDragEnter(isReadOnlyMode)} onDragLeave={() => this.setState({dragging:false})} multiple={false} @@ -70,7 +85,7 @@ class SoftwareProductComponentsMonitoringView extends Component { className={`software-product-landing-view-top-block-col-upl${isReadOnlyMode ? ' disabled' : ''}`}>
    {i18n('Drag & drop for upload')}
    {i18n('or')}
    -
    this.refs[refAndName].open()}> +
    this.refs[refAndName].open()}> {i18n('Select file')}
    @@ -95,17 +110,21 @@ class SoftwareProductComponentsMonitoringView extends Component { } } - handleImport(files, {isReadOnlyMode, type, refAndName}) { + handleImport(files, rejectedFiles, {isReadOnlyMode, type, refAndName}) { if (isReadOnlyMode) { return; } - - 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); + 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(); + } } getFileTypeDisplayName(type) { 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 a412456e13..7cf1f0189e 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 @@ -1,53 +1,66 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 SoftwareProductComponentsNetworkActionHelper from './SoftwareProductComponentsNetworkActionHelper.js'; import SoftwareProductComponentsNICEditorView from './SoftwareProductComponentsNICEditorView.jsx'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +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'; export const mapStateToProps = ({softwareProduct}) => { let {softwareProductEditor: {data:currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents} = softwareProduct; let {network: {nicEditor = {}}} = softwareProductComponents; - let {data, qdata, qschema} = nicEditor; + let {data, qdata, genericFieldInfo, qgenericFieldInfo, dataMap, formReady} = nicEditor; let isReadOnlyMode = VersionControllerUtils.isReadOnly(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, - qschema, - isReadOnlyMode + dataMap, + isFormValid, + formReady, + genericFieldInfo, + qgenericFieldInfo, + isReadOnlyMode, + protocols }; }; const mapActionsToProps = (dispatch, {softwareProductId, componentId}) => { return { - onDataChanged: deltaData => SoftwareProductComponentsNetworkActionHelper.updateNICData(dispatch, {deltaData}), - onSubmit: ({data, qdata}) => SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(dispatch, {softwareProductId, componentId, data, qdata}), + onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, + formName: forms.NIC_EDIT_FORM}), + onSubmit: ({data, qdata, version}) => SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(dispatch, {softwareProductId, version, componentId, data, qdata}), onCancel: () => SoftwareProductComponentsNetworkActionHelper.closeNICEditor(dispatch), - onQDataChanged: ({data}) => SoftwareProductComponentsNetworkActionHelper.updateNICQuestionnaire(dispatch, {data}) + onValidateForm: () => ValidationHelper.validateForm(dispatch, forms.NIC_EDIT_FORM), + onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, + qName: NIC_QUESTIONNAIRE}), }; }; 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 d49f9ccb1e..b3c9fe5d98 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 @@ -1,48 +1,43 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductComponentsNetworkConstants.js'; +import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; export default (state = {}, action) => { switch (action.type) { case actionTypes.NICEditor.OPEN: return { ...state, - data: action.nic + data: action.nic, + genericFieldInfo: { + 'description' : { + isValid: true, + errorText: '', + validations: [] + }, + 'name' : { + isValid: true, + errorText: '', + validations: [] + } + }, + formName: forms.NIC_EDIT_FORM }; case actionTypes.NICEditor.CLOSE: return {}; - case actionTypes.NICEditor.NIC_QUESTIONNAIRE_UPDATE: - return { - ...state, - qdata: action.payload.qdata || state.qdata, - qschema: action.payload.qschema || state.qschema - }; - case actionTypes.NICEditor.DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData - } - }; 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 7393a835dc..aad06c82f0 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 @@ -1,321 +1,71 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; - -import i18n from 'nfvo-utils/i18n/i18n.js'; - -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; +import Form from 'nfvo-components/input/validation/Form.jsx'; +import Acceptable from './nicEditorComponents/Acceptable.jsx'; +import FlowLength from './nicEditorComponents/FlowLength.jsx'; +import OutFlowTraffic from './nicEditorComponents/OutFlowTraffic.jsx'; +import InFlowTraffic from './nicEditorComponents/InFlowTraffic.jsx'; +import Sizing from './nicEditorComponents/Sizing.jsx'; +import Network from './nicEditorComponents/Network.jsx'; +import IpConfig from './nicEditorComponents/IpConfig.jsx'; +import Protocols from './nicEditorComponents/Protocols.jsx'; +import NameAndPurpose from './nicEditorComponents/NameAndPurpose.jsx'; class SoftwareProductComponentsNetworkEditorView extends React.Component { render() { - let {onCancel, isReadOnlyMode} = this.props; - return ( - this.submit() } - onReset={ () => onCancel() } - labledButtons={true} - isReadOnlyMode={isReadOnlyMode} - className='vsp-components-network-editor'> - {this.renderEditorFields()} - - ); - } - - renderEditorFields() { - let {data = {}, qdata = {}, qschema = {}, onQDataChanged, onDataChanged, isReadOnlyMode} = this.props; + let {onCancel, onValidateForm, isReadOnlyMode, isFormValid, formReady, data = {}, qgenericFieldInfo, dataMap, onDataChanged, protocols, onQDataChanged} = this.props; let {name, description, networkName} = data; let netWorkValues = [{ enum: networkName, title: networkName }]; - return( -
    -
    -
    - -
    -
    - onDataChanged({description})} - disabled={isReadOnlyMode} - type='textarea'/> -
    -
    - -
    -
    {i18n('Protocols')}
    -
    - -
    -
    - -
    -
    -
    -
    {i18n('IP Configuration')}
    -
    - -
    -
    - -
    -
    -
    -
    -
    {i18n('Network')}
    -
    - -
    -
    - -
    -
    - -
    + 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'> +
    + + + + + + + + +
    - -
    -
    {i18n('Sizing')}
    -
    - -
    -
    - -
    -
    {i18n('Inflow Traffic per second')}
    -
    - -
    -
    -
    -
    {i18n('Packets')}
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    {i18n('Bytes')}
    -
    -
    -
    - - -
    -
    - -
    -
    -
    -
    - -
    -
    {i18n('Outflow Traffic per second')}
    -
    - -
    -
    -
    -
    {i18n('Packets')}
    -
    -
    -
    - -
    -
    - - -
    -
    -
    -
    -
    -
    {i18n('Bytes')}
    -
    -
    -
    - - -
    -
    - - -
    -
    -
    -
    - -
    -
    {i18n('Flow Length')}
    -
    - -
    -
    -
    -
    {i18n('Packets')}
    -
    -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    {i18n('Bytes')}
    -
    -
    -
    - - -
    -
    - -
    -
    -
    -
    - -
    -
    -
    -
    {i18n('Acceptable Jitter')}
    -
    -
    -
    - -
    -
    - -
    -
    - -
    -
    -
    -
    -
    -
    {i18n('Acceptable Packet Loss %')}
    -
    -
    -
    - -
    -
    -
    -
    -
    +
    }
    - ); } + submit() { - let {data, qdata, onSubmit} = this.props; - onSubmit({data, qdata}); + let {data, qdata, onSubmit, version} = this.props; + onSubmit({data, qdata, version}); } } 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 bc53e1a7af..5cfc88bdc9 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 @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductComponentsNetworkConstants.js'; export default (state = [], action) => { 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 8ff6b50189..bc061469b1 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 @@ -1,65 +1,60 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes} from './SoftwareProductComponentsNetworkConstants.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; +import {NIC_QUESTIONNAIRE} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkConstants.js'; -function baseUrl(softwareProductId, componentId) { +function baseUrl(softwareProductId, version, componentId) { + const versionId = version.id; const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics`; + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/nics`; } -function fetchNICQuestionnaire({softwareProductId, componentId, nicId, version}) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, componentId)}/${nicId}/questionnaire${versionQuery}`); +function fetchNICQuestionnaire({softwareProductId, version, componentId, nicId}) { + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}/${nicId}/questionnaire`); } -function fetchNIC({softwareProductId, componentId, nicId, version}) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, componentId)}/${nicId}${versionQuery}`); +function fetchNIC({softwareProductId, version, componentId, nicId}) { + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}/${nicId}`); } -function fetchNICsList({softwareProductId, componentId, version}) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, componentId)}${versionQuery}`); +function fetchNICsList({softwareProductId, version, componentId}) { + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}`); } -function saveNIC({softwareProductId, componentId, nic: {id, name, description, networkId}}) { - return RestAPIUtil.save(`${baseUrl(softwareProductId, componentId)}/${id}`,{ +function saveNIC({softwareProductId, version, componentId, nic: {id, name, description, networkId}}) { + return RestAPIUtil.put(`${baseUrl(softwareProductId, version, componentId)}/${id}`,{ name, description, networkId }); } -function saveNICQuestionnaire({softwareProductId, componentId, nicId, qdata}) { - return RestAPIUtil.save(`${baseUrl(softwareProductId, 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, componentId, version}) { - return fetchNICsList({softwareProductId, componentId, version}).then((response) => { + fetchNICsList(dispatch, {softwareProductId, version, componentId}) { + return fetchNICsList({softwareProductId, version, componentId}).then((response) => { dispatch({ type: actionTypes.NIC_LIST_UPDATE, response: response.results @@ -80,43 +75,24 @@ const SoftwareProductComponentNetworkActionHelper = { }); }, - loadNICData({softwareProductId, componentId, nicId, version}) { - return fetchNIC({softwareProductId, componentId, nicId, version}); - }, - - loadNICQuestionnaire(dispatch, {softwareProductId, componentId, nicId, version}) { - return fetchNICQuestionnaire({softwareProductId, componentId, nicId, version}).then((response) => { - dispatch({ - type: actionTypes.NICEditor.NIC_QUESTIONNAIRE_UPDATE, - payload: { - qdata: response.data ? JSON.parse(response.data) : {}, - qschema: JSON.parse(response.schema) - } - }); - }); + loadNICData({softwareProductId, version, componentId, nicId}) { + return fetchNIC({softwareProductId, version, componentId, nicId}); }, - updateNICData(dispatch, {deltaData}) { - dispatch({ - type: actionTypes.NICEditor.DATA_CHANGED, - deltaData - }); - }, - - updateNICQuestionnaire(dispatch, {data}) { - dispatch({ - type: actionTypes.NICEditor.NIC_QUESTIONNAIRE_UPDATE, - payload: { - qdata: data - } + 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, componentId, data, qdata}) { + saveNICDataAndQuestionnaire(dispatch, {softwareProductId, version, componentId, data, qdata}) { SoftwareProductComponentNetworkActionHelper.closeNICEditor(dispatch); return Promise.all([ - saveNICQuestionnaire({softwareProductId, componentId, nicId: data.id, qdata}), - saveNIC({softwareProductId, componentId, nic: data}).then(() => { + saveNICQuestionnaire({softwareProductId, version, componentId, nicId: data.id, qdata}), + saveNIC({softwareProductId, version, componentId, nic: data}).then(() => { dispatch({ type: actionTypes.NIC_LIST_EDIT, nic: data 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 193f4b20b5..39c55d876c 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 @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ @@ -26,8 +21,8 @@ export const actionTypes = keyMirror({ NICEditor: { OPEN: null, - CLOSE: null, - NIC_QUESTIONNAIRE_UPDATE: null, - DATA_CHANGED: null + CLOSE: null } }); + +export const NIC_QUESTIONNAIRE = 'nic'; 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 9172dc691a..c2bd8ce479 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 @@ -1,51 +1,47 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.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 ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; export const mapStateToProps = ({softwareProduct}) => { let {softwareProductEditor: {data: currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents} = softwareProduct; - let {network: {nicEditor = {}, nicList = []}, componentEditor: {data: componentData, qdata, qschema}} = softwareProductComponents; + let {network: {nicEditor = {}, nicList = []}, componentEditor: {data: componentData, qdata, dataMap, qgenericFieldInfo}} = softwareProductComponents; let {data} = nicEditor; let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentSoftwareProduct); let {version} = currentSoftwareProduct; - let manualMode = nicList.length <= 0; let isModalInEditMode = true; return { version, componentData, qdata, - qschema, + dataMap, + qgenericFieldInfo, isValidityData, nicList, isDisplayModal: Boolean(data), isModalInEditMode, - manualMode, isReadOnlyMode }; @@ -53,28 +49,28 @@ export const mapStateToProps = ({softwareProduct}) => { const mapActionsToProps = (dispatch, {softwareProductId, componentId}) => { return { - onQDataChanged: ({data}) => SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(dispatch, {data}), - onAddNIC: () => SoftwareProductComponentsNetworkActionHelper.openNICEditor(dispatch), + onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, + qName: COMPONENTS_QUESTIONNAIRE}), onEditNicClick: (nic, version) => { Promise.all([ SoftwareProductComponentsNetworkActionHelper.loadNICData({ softwareProductId, + version, componentId, - nicId: nic.id, - version + nicId: nic.id }), SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(dispatch, { softwareProductId, + version, componentId, - nicId: nic.id, - version + nicId: nic.id }) ]).then( ([{data}]) => SoftwareProductComponentsNetworkActionHelper.openNICEditor(dispatch, {nic, data}) ); }, - onSubmit: ({qdata}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, - {softwareProductId, + onSubmit: ({qdata, version}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, + {softwareProductId, version, vspComponentId: componentId, qdata}); } 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 b3e17ff94b..f715016ba3 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 @@ -1,10 +1,26 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; +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 ValidationInput from'nfvo-components/input/validation/ValidationInput.jsx'; +import ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; +import Input from'nfvo-components/input/validation/Input.jsx'; import Modal from 'nfvo-components/modal/Modal.jsx'; import SoftwareProductComponentsNICEditor from './SoftwareProductComponentsNICEditor.js'; @@ -16,38 +32,56 @@ class SoftwareProductComponentsNetworkView extends React.Component { }; render() { - let {qdata, qschema, onQDataChanged, isModalInEditMode, isDisplayModal, softwareProductId, componentId, isReadOnlyMode} = this.props; + let {dataMap, qgenericFieldInfo, onQDataChanged, isModalInEditMode, isDisplayModal, softwareProductId, componentId, isReadOnlyMode} = this.props; return(
    - +{ qgenericFieldInfo &&
    this.save()} + isReadOnlyMode={isReadOnlyMode} + hasButtons={false}>

    {i18n('Network Capacity')}

    -
    +
    - + groupClassName='bootstrap-input-options' + className='input-options-select' + isValid={qgenericFieldInfo['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs'].isValid} + errorText={qgenericFieldInfo['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs'].errorText} + value={dataMap['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs']} + onChange={(e) => { + const selectedIndex = e.target.selectedIndex; + const val = e.target.options[selectedIndex].value; + onQDataChanged({'network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs' : val});} + }> + + { qgenericFieldInfo['network/networkCapacity/protocolWithHighestTrafficProfileAcrossAllNICs'].enum.map(proto => + ) } +
    - + type='number' + onChange={(ntps) => onQDataChanged({'network/networkCapacity/networkTransactionsPerSecond' : ntps})} + isValid={qgenericFieldInfo['network/networkCapacity/networkTransactionsPerSecond'].isValid} + errorText={qgenericFieldInfo['network/networkCapacity/networkTransactionsPerSecond'].errorText} + value={dataMap['network/networkCapacity/networkTransactionsPerSecond']} />
    - + }
    {this.renderNicList()}
    @@ -70,18 +104,16 @@ class SoftwareProductComponentsNetworkView extends React.Component { renderNicList() { const {localFilter} = this.state; - let {onAddNIC, manualMode, isReadOnlyMode} = this.props; - let onAdd = manualMode ? onAddNIC : false; + let {isReadOnlyMode} = this.props; return ( this.setState({localFilter: filter})}> - {!manualMode && this.filterList().map(nic => this.renderNicListItem(nic, isReadOnlyMode))} + onFilter={value => this.setState({localFilter: value})} + twoColumns> + {this.filterList().map(nic => this.renderNicListItem(nic, isReadOnlyMode))} ); } @@ -92,22 +124,22 @@ class SoftwareProductComponentsNetworkView extends React.Component { return ( onEditNicClick(nic, version)}> -
    -
    {i18n('Name')}
    +
    {name}
    -
    -
    -
    {i18n('Purpose of NIC')}
    -
    {description}
    -
    -
    -
    {i18n('Network')}
    -
    {networkName}
    -
    + + +
    +
    {i18n('Purpose of NIC')}
    +
    {description}
    +
    +
    +
    {i18n('Network')}
    +
    {networkName}
    +
    +
    ); @@ -128,8 +160,8 @@ class SoftwareProductComponentsNetworkView extends React.Component { } save() { - let {onSubmit, qdata} = this.props; - return onSubmit({qdata}); + let {onSubmit, qdata, version} = this.props; + return onSubmit({qdata, version}); } } 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 new file mode 100644 index 0000000000..524b95c3ad --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Acceptable.jsx @@ -0,0 +1,75 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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 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 new file mode 100644 index 0000000000..3745fc7c2e --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/FlowLength.jsx @@ -0,0 +1,35 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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'}, +]; + +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 new file mode 100644 index 0000000000..5476ed90e6 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/InFlowTraffic.jsx @@ -0,0 +1,35 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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'}, +]; + +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 new file mode 100644 index 0000000000..b3a5d21625 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/IpConfig.jsx @@ -0,0 +1,45 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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 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 new file mode 100644 index 0000000000..3dc153d27f --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/NameAndPurpose.jsx @@ -0,0 +1,54 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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 NameAndPurpose = ({onDataChanged, isReadOnlyMode, name, description}) => { + + return ( + + + + + + onDataChanged({description})} + disabled={isReadOnlyMode} + type='textarea'/> + + + ); +}; + +NameAndPurpose.PropTypes = { + name: React.PropTypes.string, + description: React.PropTypes.array, + onDataChanged: React.PropTypes.func, + isReadOnlyMode: React.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 new file mode 100644 index 0000000000..43afdbed3a --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Network.jsx @@ -0,0 +1,62 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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 Network = ({networkValues}) => { + return ( + + + + + + + + + + {networkValues.map(val => )} + + + + ); +}; + +Network.PropTypes = { + networkValues: React.PropTypes.array +}; + +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 new file mode 100644 index 0000000000..80a3d1579b --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/OutFlowTraffic.jsx @@ -0,0 +1,35 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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'}, +]; + +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 new file mode 100644 index 0000000000..d7ee91bd15 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/PacketsBytes.jsx @@ -0,0 +1,65 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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 PointerInput = ({label, value, onQDataChanged, qgenericFieldInfo, dataMap}) => { + return ( + + onQDataChanged({[value]: val})} /> + + ); +}; + +PointerInput.PropTypes = { + label: React.PropTypes.string, + value: React.PropTypes.string +}; + +const PacketsBytes = ({title, pointers = [], qgenericFieldInfo, dataMap, onQDataChanged}) => { + return( + + +
    {i18n('Packets')}
    +
    + +
    {i18n('Bytes')}
    +
    + {pointers.map(pointer => {return ();})} +
    + ); +}; + +PacketsBytes.PropTypes = { + title: React.PropTypes.string, + pointers: React.PropTypes.array, + onQDataChanged: React.PropTypes.function, + dataMap: React.PropTypes.object, + qgenericFieldInfo: React.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 new file mode 100644 index 0000000000..3e8a9f4e77 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Protocols.jsx @@ -0,0 +1,74 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import i18n from 'nfvo-utils/i18n/i18n.js'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +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 => )} + + + + ); +}; + +Protocols.PropTypes = { + protocols: React.PropTypes.array, + onQDataChanged: React.PropTypes.function, + dataMap: React.PropTypes.object, + qgenericFieldInfo: React.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 new file mode 100644 index 0000000000..1dd0045f7b --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/network/nicEditorComponents/Sizing.jsx @@ -0,0 +1,39 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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 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 d535a34a82..b2133ad5d8 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 @@ -1,69 +1,65 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; import {actionTypes} from './SoftwareProductComponentProcessesConstants.js'; -function baseUrl(softwareProductId, componentId) { +function baseUrl(softwareProductId, version, componentId) { const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes`; + return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/processes`; } -function fetchProcessesList({softwareProductId, componentId, version}) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(softwareProductId, componentId)}${versionQuery}`); +function fetchProcessesList({softwareProductId, version, componentId}) { + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version, componentId)}`); } -function deleteProcess({softwareProductId, componentId, processId}) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId, componentId)}/${processId}`); +function deleteProcess({softwareProductId, version, componentId, processId}) { + return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version, componentId)}/${processId}`); } -function putProcess({softwareProductId, componentId, process}) { - return RestAPIUtil.save(`${baseUrl(softwareProductId, componentId)}/${process.id}`, { +function putProcess({softwareProductId, version, componentId, process}) { + return RestAPIUtil.put(`${baseUrl(softwareProductId, version, componentId)}/${process.id}`, { name: process.name, - description: process.description + description: process.description, + type: process.type === '' ? null : process.type }); } -function postProcess({softwareProductId,componentId, process}) { - return RestAPIUtil.create(`${baseUrl(softwareProductId, componentId)}`, { +function postProcess({softwareProductId, version, componentId, process}) { + return RestAPIUtil.post(`${baseUrl(softwareProductId, version, componentId)}`, { name: process.name, - description: process.description + description: process.description, + type: process.type === '' ? null : process.type }); } -function uploadFileToProcess({softwareProductId, processId, componentId, formData}) { - return RestAPIUtil.create(`${baseUrl(softwareProductId, 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, componentId, version}) { + fetchProcessesList(dispatch, {softwareProductId, version, componentId}) { dispatch({ type: actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES, processesList: [] }); - return fetchProcessesList({softwareProductId, componentId, version}).then(response => { + return fetchProcessesList({softwareProductId, version, componentId}).then(response => { dispatch({ type: actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES, processesList: response.results @@ -71,8 +67,8 @@ const SoftwareProductComponentProcessesActionHelper = { }); }, - deleteProcess(dispatch, {process, softwareProductId, componentId}) { - return deleteProcess({softwareProductId, processId:process.id, componentId}).then(() => { + 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 @@ -81,11 +77,11 @@ const SoftwareProductComponentProcessesActionHelper = { }, - saveProcess(dispatch, {softwareProductId, componentId, previousProcess, process}) { + saveProcess(dispatch, {softwareProductId, version, componentId, previousProcess, process}) { if (previousProcess) { - return putProcess({softwareProductId,componentId, process}).then(() => { + return putProcess({softwareProductId, version, componentId, process}).then(() => { if (process.formData && process.formData.name !== previousProcess.artifactName){ - uploadFileToProcess({softwareProductId, processId: process.id, formData: process.formData, componentId}); + uploadFileToProcess({softwareProductId, version, processId: process.id, formData: process.formData, componentId}); } dispatch({ type: actionTypes.EDIT_SOFTWARE_PRODUCT_COMPONENTS_PROCESS, @@ -94,9 +90,9 @@ const SoftwareProductComponentProcessesActionHelper = { }); } else { - return postProcess({softwareProductId, componentId, process}).then(response => { + return postProcess({softwareProductId, version, componentId, process}).then(response => { if (process.formData) { - uploadFileToProcess({softwareProductId, processId: response.value, formData: process.formData, componentId}); + uploadFileToProcess({softwareProductId, version, processId: response.value, formData: process.formData, componentId}); } dispatch({ type: actionTypes.ADD_SOFTWARE_PRODUCT_COMPONENTS_PROCESS, @@ -133,12 +129,6 @@ const SoftwareProductComponentProcessesActionHelper = { dispatch({ type:actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_CLOSE }); - }, - processEditorDataChanged(dispatch, {deltaData}) { - dispatch({ - type: actionTypes.processEditor.DATA_CHANGED, - deltaData - }); } }; 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 78a111a426..d15432b3fb 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 @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ @@ -27,8 +22,15 @@ export const actionTypes = keyMirror({ 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, - processEditor: { - DATA_CHANGED: 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'} + ] +}; + +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 0138023c30..9502e24b1a 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 @@ -1,31 +1,29 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 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'; -const mapStateToProps = ({softwareProduct}) => { +export const mapStateToProps = ({softwareProduct}) => { let {softwareProductComponents: {componentProcesses = {}}} = softwareProduct; let {processesList = [], processesEditor = {}} = componentProcesses; - let {data} = processesEditor; + let {data, genericFieldInfo, formReady} = processesEditor; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); let previousData; const processId = data ? data.id : null; @@ -35,19 +33,23 @@ const mapStateToProps = ({softwareProduct}) => { return { data, - previousData + genericFieldInfo, + previousData, + isFormValid, + formReady }; }; -const mapActionsToProps = (dispatch, {softwareProductId, componentId}) => { +const mapActionsToProps = (dispatch, {softwareProductId, version, componentId}) => { return { - onDataChanged: deltaData => SoftwareProductComponentProcessesActionHelper.processEditorDataChanged(dispatch, {deltaData}), + 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, previousProcess, componentId, process}); - } + SoftwareProductComponentProcessesActionHelper.saveProcess(dispatch, {softwareProductId, version, previousProcess, componentId, process}); + }, + onValidateForm: () => ValidationHelper.validateForm(dispatch, SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_FORM) }; }; 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 f859f690e8..9afaa6d5fd 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 @@ -1,43 +1,53 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} 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 {}; - - case actionTypes.processEditor.DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData - } - }; 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 ca6d843af7..18f2ee129c 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 @@ -1,18 +1,48 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Dropzone from 'react-dropzone'; - -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; +import {optionsInputValues as ComponentProcessesOptionsInputValues} from './SoftwareProductComponentProcessesConstants.js'; +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'; const SoftwareProductProcessEditorPropType = React.PropTypes.shape({ id: React.PropTypes.string, name: React.PropTypes.string, description: React.PropTypes.string, - artifactName: React.PropTypes.string + artifactName: React.PropTypes.string, + type: React.PropTypes.string }); +const FileUploadBox = ({onClick}) => { + return ( +
    +
    {i18n('Drag & drop for upload')}
    +
    {i18n('or')}
    +
    + {i18n('Select file')} +
    +
    + ); +}; + class SoftwareProductProcessesEditorView extends React.Component { state = { @@ -30,65 +60,91 @@ class SoftwareProductProcessesEditorView extends React.Component { }; render() { - let {isReadOnlyMode, onCancel, onDataChanged, data = {}} = this.props; - let {name, description, artifactName} = data; + let {isReadOnlyMode, onCancel, onDataChanged, genericFieldInfo, data = {}} = this.props; + let {name, description, artifactName, type} = data; return (
    - this.submit() } onReset={ () => onCancel() } + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => this.props.onValidateForm() } className='vsp-processes-editor'> -
    - this.handleImportSubmit(files)} - onDragEnter={() => this.setState({dragging:true})} - onDragLeave={() => this.setState({dragging:false})} - multiple={false} - disableClick={true} - ref='processEditorFileInput' - name='processEditorFileInput' - accept='*.*'> -
    -
    - onDataChanged({name})} - label={i18n('Name')} - value={name} - validations={{validateName: true, maxLength: 120, required: true}} - type='text'/> - -
    -
    -
    -
    {i18n('Drag & drop for upload')}
    -
    {i18n('or')}
    -
    this.refs.processEditorFileInput.open()}> - {i18n('Select file')} -
    -
    -
    -
    - onDataChanged({description})} - label={i18n('Notes')} - value={description} - name='vsp-process-description' - className='vsp-process-description' - validations={{maxLength: 1000}} - type='textarea'/> -
    -
    -
    +
    + 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')} + data-test-id='process-type' + isValid={genericFieldInfo.type.isValid} + errorText={genericFieldInfo.type.errorText} + type='select' + className='input-options-select' + groupClassName='bootstrap-input-options' > + {ComponentProcessesOptionsInputValues.PROCESS_TYPE.map(mtype => + )} + + + + +
    + }
    ); } @@ -110,14 +166,25 @@ class SoftwareProductProcessesEditorView extends React.Component { } - handleImportSubmit(files) { - let {onDataChanged} = this.props; - this.setState({ - dragging: false, - complete: '0', - files - }); - onDataChanged({artifactName: files[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); + } + } + } } 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 5f6932897e..a8cb709194 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 @@ -1,30 +1,27 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 i18n from 'nfvo-utils/i18n/i18n.js'; +import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import SoftwareProductComponentProcessesActionHelper from './SoftwareProductComponentProcessesActionHelper.js'; import SoftwareProductComponentsProcessesListView from './SoftwareProductComponentsProcessesListView.jsx'; -const mapStateToProps = ({softwareProduct}) => { +export const mapStateToProps = ({softwareProduct}) => { let {softwareProductEditor: {data:currentSoftwareProduct = {}, isValidityData = true}, softwareProductComponents: {componentProcesses = {}}} = softwareProduct; let{processesList = [], processesEditor = {}} = componentProcesses; @@ -42,12 +39,19 @@ const mapStateToProps = ({softwareProduct}) => { }; -const mapActionsToProps = (dispatch, {softwareProductId}) => { +const mapActionsToProps = (dispatch, {componentId, softwareProductId}) => { return { onAddProcess: () => SoftwareProductComponentProcessesActionHelper.openEditor(dispatch), onEditProcessClick: (process) => SoftwareProductComponentProcessesActionHelper.openEditor(dispatch, process), - onDeleteProcessClick: (process) => SoftwareProductComponentProcessesActionHelper.openDeleteProcessesConfirm(dispatch, {process, softwareProductId}) + onDeleteProcessClick: (process, version) => dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data:{ + msg: i18n('Are you sure you want to delete "{name}"?', {name: process.name}), + onConfirmed: ()=> SoftwareProductComponentProcessesActionHelper.deleteProcess(dispatch, + {process, softwareProductId, version, componentId}) + } + }) }; }; 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 4bb124d52f..98e24a9c21 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 @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductComponentProcessesConstants.js'; export default (state = [], action) => { diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesConfirmationModal.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesConfirmationModal.jsx deleted file mode 100644 index 48fa862364..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesConfirmationModal.jsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react'; -import {connect} from 'react-redux'; -import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx'; -import SoftwareProductComponentProcessesActionHelper from './SoftwareProductComponentProcessesActionHelper.js'; -import i18n from 'nfvo-utils/i18n/i18n.js'; - -function renderMsg(processToDelete) { - let name = processToDelete ? processToDelete.name : ''; - let msg = i18n('Are you sure you want to delete "{name}"?', {name}); - return ( -
    -

    {msg}

    -
    - ); -}; - -const mapStateToProps = ({softwareProduct}) => { - let {softwareProductEditor, softwareProductComponents} = softwareProduct; - let {componentProcesses} = softwareProductComponents; - let {processToDelete} = componentProcesses; - let softwareProductId = softwareProductEditor.data.id; - const show = processToDelete !== false; - return { - show, - title: 'Warning!', - type: 'warning', - msg: renderMsg(processToDelete), - confirmationDetails: {processToDelete, softwareProductId} - }; -}; - -const mapActionsToProps = (dispatch,{componentId, softwareProductId}) => { - return { - onConfirmed: ({processToDelete}) => { - SoftwareProductComponentProcessesActionHelper.deleteProcess(dispatch, {process: processToDelete, softwareProductId, componentId}); - SoftwareProductComponentProcessesActionHelper.hideDeleteConfirm(dispatch); - }, - onDeclined: () => { - SoftwareProductComponentProcessesActionHelper.hideDeleteConfirm(dispatch); - } - }; -}; - -export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView); - 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 a8b07e9194..650d6d5ebc 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 @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; @@ -6,7 +21,6 @@ import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import SoftwareProductProcessesEditor from './SoftwareProductComponentProcessesEditor.js'; -import SoftwareProductComponentsProcessesConfirmationModal from './SoftwareProductComponentsProcessesConfirmationModal.jsx'; class SoftwareProductProcessesView extends React.Component { @@ -22,12 +36,11 @@ class SoftwareProductProcessesView extends React.Component { isModalInEditMode: React.PropTypes.bool, onStorageSelect: React.PropTypes.func, componentId: React.PropTypes.string, - softwareProductId: React.PropTypes.string + softwareProductId: React.PropTypes.string, + currentSoftwareProduct: React.PropTypes.object }; render() { - let { softwareProductId, componentId} = this.props; - return (
    @@ -35,18 +48,15 @@ class SoftwareProductProcessesView extends React.Component { {this.renderEditor()} {this.renderProcessList()}
    -
    ); } renderEditor() { - let {softwareProductId, componentId, isReadOnlyMode, isDisplayModal, isModalInEditMode} = this.props; + let {softwareProductId, currentSoftwareProduct: {version}, componentId, isReadOnlyMode, isDisplayModal, isModalInEditMode} = this.props; return ( - + {isModalInEditMode ? i18n('Edit Process Details') : i18n('Create New Process Details')} @@ -54,6 +64,7 @@ class SoftwareProductProcessesView extends React.Component { @@ -72,7 +83,8 @@ class SoftwareProductProcessesView extends React.Component { placeholder={i18n('Filter Process')} onAdd={onAddProcess} isReadOnlyMode={isReadOnlyMode} - onFilter={filter => this.setState({localFilter: filter})}> + title={i18n('Process Details')} + onFilter={value => this.setState({localFilter: value})}> {this.filterList().map(processes => this.renderProcessListItem(processes, isReadOnlyMode))}
    @@ -81,14 +93,14 @@ class SoftwareProductProcessesView extends React.Component { renderProcessListItem(process, isReadOnlyMode) { let {id, name, description, artifactName = ''} = process; - let {onEditProcessClick, onDeleteProcessClick} = this.props; + let {currentSoftwareProduct: {version}, onEditProcessClick, onDeleteProcessClick} = this.props; return ( onEditProcessClick(process)} - onDelete={() => onDeleteProcessClick(process)}> + onDelete={() => onDeleteProcessClick(process, version)}>
    {i18n('Name')}
    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 fbd3f81ec2..18a3b1e8ff 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 @@ -1,47 +1,48 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +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'; + const mapStateToProps = ({softwareProduct}) => { let {softwareProductEditor: {data: currentVSP}, softwareProductComponents} = softwareProduct; - let {componentEditor: {data: componentData , qdata, qschema}} = softwareProductComponents; + let {componentEditor: {data: componentData , qdata, qgenericFieldInfo : qGenericFieldInfo, dataMap}} = softwareProductComponents; let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentVSP); return { componentData, qdata, - qschema, - isReadOnlyMode + isReadOnlyMode, + qGenericFieldInfo, + dataMap }; }; -const mapActionToProps = (dispatch, {softwareProductId, componentId}) => { +const mapActionToProps = (dispatch, {softwareProductId, version, componentId}) => { return { - onQDataChanged: ({data}) => SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(dispatch, {data}), - onSubmit: ({qdata}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId: componentId, qdata});} + onQDataChanged: (deltaData) => ValidationHelper.qDataChanged(dispatch, {deltaData, qName: COMPONENTS_QUESTIONNAIRE}), + onSubmit: ({componentData, qdata}) => { return SoftwareProductComponentsActionHelper.updateSoftwareProductComponent(dispatch, + {softwareProductId, version, vspComponentId: componentId, componentData, qdata}); + } }; }; 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 9c9600c376..28bdf8e5e5 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 @@ -1,8 +1,156 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from'nfvo-components/input/validation/ValidationInput.jsx'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +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 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 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']}/> + + +); class SoftwareProductComponentStorageView extends React.Component { @@ -14,110 +162,28 @@ class SoftwareProductComponentStorageView extends React.Component { }; render() { - let {qdata, qschema, onQDataChanged, onSubmit, isReadOnlyMode} = this.props; + let {onQDataChanged, dataMap, qGenericFieldInfo, isReadOnlyMode, onSubmit, qdata} = this.props; return(
    - this.form = form } + isValid={true} + formReady={null} onSubmit={() => onSubmit({qdata})} className='component-questionnaire-validation-form' isReadOnlyMode={isReadOnlyMode} - onDataChanged={onQDataChanged} - data={qdata} - schema={qschema}> - -
    {i18n('Backup')}
    -
    -
    -
    -
    - -
    - -
    -
    -
    -
    - -
    -
    - -
    - -
    -
    - -
    {i18n('Snapshot Backup')}
    -
    -
    -
    - -
    -
    -
    -
    -
    - -
    {i18n('Log Backup')}
    -
    -
    -
    - -
    -
    - -
    -
    - -
    - -
    -
    - + hasButtons={false}> + + + + }
    ); } save(){ - return this.refs.storageValidationForm.handleFormSubmit(new Event('dummy')); + return this.form.handleFormSubmit(new Event('dummy')); } } 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 46308f0045..19e2d5b0db 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js @@ -1,48 +1,62 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.js'; import SoftwareProductCreationActionHelper from './SoftwareProductCreationActionHelper.js'; import SoftwareProductCreationView from './SoftwareProductCreationView.jsx'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; +import SoftwareProductActionHelper from '../SoftwareProductActionHelper.js'; + +export const mapStateToProps = ({finalizedLicenseModelList, softwareProductList, softwareProduct: {softwareProductCreation, softwareProductCategories} }) => { + let {genericFieldInfo} = softwareProductCreation; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + + let VSPNames = {}; + for (let i = 0; i < softwareProductList.length; i++) { + VSPNames[softwareProductList[i].name] = softwareProductList[i].id; + } -const mapStateToProps = ({finalizedLicenseModelList, softwareProduct: {softwareProductCreation, softwareProductCategories} }) => { return { data: softwareProductCreation.data, + selectedVendorId: softwareProductCreation.selectedVendorId, + disableVendor: softwareProductCreation.disableVendor, softwareProductCategories, - finalizedLicenseModelList + finalizedLicenseModelList, + isFormValid, + formReady: softwareProductCreation.formReady, + genericFieldInfo, + VSPNames }; }; -const mapActionsToProps = (dispatch) => { +export const mapActionsToProps = (dispatch) => { return { - onDataChanged: deltaData => SoftwareProductCreationActionHelper.changeData(dispatch, {deltaData}), + onDataChanged: (deltaData, formName, customValidations) => ValidationHelper.dataChanged(dispatch, {deltaData, formName, customValidations}), onCancel: () => SoftwareProductCreationActionHelper.resetData(dispatch), onSubmit: (softwareProduct) => { SoftwareProductCreationActionHelper.resetData(dispatch); - SoftwareProductCreationActionHelper.createSoftwareProduct(dispatch, {softwareProduct}).then(softwareProductId => { - let {vendorId: licenseModelId, licensingVersion} = softwareProduct; - OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId, licenseModelId, licensingVersion}); + SoftwareProductCreationActionHelper.createSoftwareProduct(dispatch, {softwareProduct}).then(response => { + SoftwareProductActionHelper.fetchSoftwareProductList(dispatch).then(() => { + let {vendorId: licenseModelId, licensingVersion} = softwareProduct; + OnboardingActionHelper.navigateToSoftwareProductLandingPage(dispatch, {softwareProductId: response.vspId, licenseModelId, licensingVersion}); + }); }); - } + }, + onValidateForm: (formName) => ValidationHelper.validateForm(dispatch, formName) }; }; 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 f4e51f198e..3b434e3ba4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js @@ -1,29 +1,26 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 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} 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'); @@ -31,7 +28,7 @@ function baseUrl() { } function createSoftwareProduct(softwareProduct) { - return RestAPIUtil.create(baseUrl(), { + return RestAPIUtil.post(baseUrl(), { ...softwareProduct, icon: 'icon', licensingData: {} @@ -40,36 +37,39 @@ function createSoftwareProduct(softwareProduct) { const SoftwareProductCreationActionHelper = { - open(dispatch) { + open(dispatch, vendorId) { SoftwareProductActionHelper.loadSoftwareProductAssociatedData(dispatch); dispatch({ - type: actionTypes.OPEN + type: actionTypes.OPEN, + selectedVendorId: vendorId }); + + dispatch({ + type: modalActionTypes.GLOBAL_MODAL_SHOW, + data: { + modalComponentName: modalContentMapper.SOFTWARE_PRODUCT_CREATION, + title: i18n('New Software Product'), + modalComponentProps: { + vendorId + } + } + }); + }, resetData(dispatch) { + dispatch({ - type: actionTypes.RESET_DATA + type: modalActionTypes.GLOBAL_MODAL_CLOSE }); - }, - changeData(dispatch, {deltaData}) { dispatch({ - type: actionTypes.DATA_CHANGED, - deltaData + type: actionTypes.RESET_DATA }); }, createSoftwareProduct(dispatch, {softwareProduct}) { - return createSoftwareProduct(softwareProduct).then(response => { - SoftwareProductActionHelper.addSoftwareProduct(dispatch, { - softwareProduct: { - ...softwareProduct, - id: response.vspId - } - }); - return response.vspId; - }); + return createSoftwareProduct(softwareProduct); } }; 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 0a9cdb911c..241d7985b1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationConstants.js @@ -1,27 +1,23 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ OPEN: null, - RESET_DATA: null, - DATA_CHANGED: null + RESET_DATA: 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 5e3db09e56..f7a738518e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationReducer.js @@ -1,40 +1,58 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductCreationConstants.js'; +import {actionTypes, SP_CREATION_FORM_NAME} from './SoftwareProductCreationConstants.js'; export default (state = {}, action) => { switch (action.type) { case actionTypes.OPEN: return { ...state, - data: {}, - showModal: true - }; - case actionTypes.DATA_CHANGED: - return { - ...state, + formName: SP_CREATION_FORM_NAME, + disableVendor: action.selectedVendorId ? true : false, data: { - ...state.data, - ...action.deltaData - } + 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}] + } + }, + showModal: true }; case actionTypes.RESET_DATA: return {}; 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 2c8f243457..11b696855b 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx @@ -1,11 +1,28 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; +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 {SP_CREATION_FORM_NAME} from './SoftwareProductCreationConstants.js'; +import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js'; import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js'; - const SoftwareProductPropType = React.PropTypes.shape({ id: React.PropTypes.string, name: React.PropTypes.string, @@ -21,50 +38,66 @@ class SoftwareProductCreationView extends React.Component { data: SoftwareProductPropType, finalizedLicenseModelList: React.PropTypes.array, softwareProductCategories: React.PropTypes.array, + VSPNames: React.PropTypes.object, onDataChanged: React.PropTypes.func.isRequired, onSubmit: React.PropTypes.func.isRequired, onCancel: React.PropTypes.func.isRequired }; render() { - let {softwareProductCategories, data = {}, onDataChanged, onCancel} = this.props; + let {softwareProductCategories, data = {}, onDataChanged, onCancel, genericFieldInfo, disableVendor} = this.props; let {name, description, vendorId, subCategory} = data; const vendorList = this.getVendorList(); - return (
    - this.validationForm = validationForm} hasButtons={true} onSubmit={() => this.submit() } onReset={() => onCancel() } - labledButtons={true}> + labledButtons={true} + isValid={this.props.isFormValid} + formReady={this.props.formReady} + onValidateForm={() => this.validate() }>
    - onDataChanged({name})} - validations={{validateName: true, maxLength: 25, required: true}} + isRequired={true} + onChange={name => onDataChanged({name},SP_CREATION_FORM_NAME, {name: name => this.validateName(name)})} + isValid={genericFieldInfo.name.isValid} + errorText={genericFieldInfo.name.errorText} type='text' - className='field-section'/> - onDataChanged({vendorId})} - value={vendorId} + 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(subCategory)} - validations={{required: true}} - className='options-input-category'> + isRequired={true} + onChange={e => 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 && @@ -74,20 +107,23 @@ class SoftwareProductCreationView extends React.Component { )} ) } - +
    - onDataChanged({description})} - validations={{freeEnglishText: true, maxLength: 1000, required: true}} + isRequired={true} + overlayPos='bottom' + onChange={description => onDataChanged({description},SP_CREATION_FORM_NAME)} + isValid={genericFieldInfo.description.isValid} + errorText={genericFieldInfo.description.errorText} type='textarea' - className='field-section'/> + className='field-section' + data-test-id='new-vsp-description' />
    -
    + }
    ); } @@ -95,29 +131,47 @@ class SoftwareProductCreationView extends React.Component { getVendorList() { let {finalizedLicenseModelList} = this.props; - return [{enum: '', title: i18n('please select...')}].concat(finalizedLicenseModelList.map(vendor => { - return { - enum: vendor.id, - title: vendor.vendorName - }; - })); + return [{enum: '', title: i18n('please select...')}].concat( + sortByStringProperty(finalizedLicenseModelList, 'vendorName').map(vendor => { + return { + enum: vendor.id, + title: vendor.vendorName + }; + }) + ); } - onSelectSubCategory(subCategory) { - let {softwareProductCategories, onDataChanged} = this.props; - let category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory(subCategory, softwareProductCategories); - onDataChanged({category, subCategory}); + onSelectVendor(e) { + const selectedIndex = e.target.selectedIndex; + const vendorId = e.target.options[selectedIndex].value; + this.props.onDataChanged({vendorId},SP_CREATION_FORM_NAME); } - create(){ - this.refs.validationForm.handleFormSubmit(new Event('dummy')); + 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() { - const {data:softwareProduct, finalizedLicenseModelList} = this.props; + let {data:softwareProduct, finalizedLicenseModelList} = this.props; softwareProduct.vendorName = finalizedLicenseModelList.find(vendor => vendor.id === softwareProduct.vendorId).vendorName; this.props.onSubmit(softwareProduct); } + + 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); + } } 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 new file mode 100644 index 0000000000..9540d3f869 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js @@ -0,0 +1,40 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 SoftwareProductDependenciesView from './SoftwareProductDependenciesView.jsx'; +import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; +import SoftwareProductDependenciesActionHelper from './SoftwareProductDependenciesActionHelper.js'; + +export const mapStateToProps = ({softwareProduct}) => { + let {softwareProductEditor: {data: currentSoftwareProduct = {}}, softwareProductDependencies, softwareProductComponents: {componentsList}} = softwareProduct; + let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentSoftwareProduct); + return { + isReadOnlyMode, + softwareProductDependencies: softwareProductDependencies.length ? softwareProductDependencies : [{sourceId: '', targetId: '', relationType: 'dependsOn', id: 'fake'}], + componentsOptions: componentsList.map(component => ({value: component.id, label: component.name})) + }; +}; + +const mapActionsToProps = (dispatch, {softwareProductId, version}) => { + return { + onDataChanged: dependenciesList => SoftwareProductDependenciesActionHelper.updateDependencyList(dispatch, {dependenciesList}), + onAddDependency: () => SoftwareProductDependenciesActionHelper.addDependency(dispatch), + onSubmit: (dependenciesList) => SoftwareProductDependenciesActionHelper.saveDependencies(dispatch, {softwareProductId, version, dependenciesList}) + }; +}; + +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 new file mode 100644 index 0000000000..e47b33a577 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js @@ -0,0 +1,58 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; +import Configuration from 'sdc-app/config/Configuration.js'; +import {actionTypes} from './SoftwareProductDependenciesConstants.js'; +import uuid from 'uuid-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-dependency-model`; +} + +function fetchDependency(softwareProductId, version) { + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); +} + +function postDependency(softwareProductId, version, dependenciesList) { + let modifedDependencyList = dependenciesList ? dependenciesList.filter(item => item.sourceId && item.targetId) + .map(item => ({sourceId: item.sourceId, targetId: item.targetId, relationType: item.relationType})) : []; + return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, {componentDependencyModels:modifedDependencyList}); +} + +const SoftwareProductDependenciesActionHelper = { + updateDependencyList(dispatch, {dependenciesList}) { + dispatch({type: actionTypes.SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE, dependenciesList}); + }, + addDependency(dispatch) { + dispatch({type: actionTypes.ADD_SOFTWARE_PRODUCT_DEPENDENCY}); + }, + fetchDependencies(dispatch, {softwareProductId, version}) { + return fetchDependency(softwareProductId, version).then( response => { + const dependenciesList = response.results ? response.results.map(item => {return {...item, id: uuid.create().toString()};}) : []; + dispatch({ + type: actionTypes.SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE, + dependenciesList + }); + }); + }, + saveDependencies(dispatch, {softwareProductId, version, dependenciesList}) { + return postDependency(softwareProductId, version, dependenciesList); + } +}; + +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 new file mode 100644 index 0000000000..1f27ed8311 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesConstants.js @@ -0,0 +1,29 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; + +export const actionTypes = keyMirror({ + SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE: null, + ADD_SOFTWARE_PRODUCT_DEPENDENCY: null +}); + +export const relationTypes = { + DEPENDS_ON: 'dependsOn' +}; + +export const relationTypesOptions = [ + {value: relationTypes.DEPENDS_ON, label: 'Depends On'} +]; diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesReducer.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesReducer.js new file mode 100644 index 0000000000..3fb479eedc --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesReducer.js @@ -0,0 +1,36 @@ + +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {actionTypes, relationTypes} from './SoftwareProductDependenciesConstants.js'; +import {checkCyclesAndMarkDependencies} from './SoftwareProductDependenciesUtils.js'; +import uuid from 'uuid-js'; + +export default (state = [], action) => { + switch (action.type) { + case actionTypes.SOFTWARE_PRODUCT_DEPENDENCIES_LIST_UPDATE: + return checkCyclesAndMarkDependencies(action.dependenciesList); + case actionTypes.ADD_SOFTWARE_PRODUCT_DEPENDENCY: + return [...state, { + sourceId: null, + relationType: relationTypes.DEPENDS_ON, + targetId: null, + id: uuid.create() + }]; + 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 new file mode 100644 index 0000000000..94d21bd49d --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesUtils.js @@ -0,0 +1,64 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 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}; +} + +export function checkCyclesAndMarkDependencies(dependenciesList) { + 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}); + } + } + + 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 new file mode 100644 index 0000000000..da975a7be2 --- /dev/null +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx @@ -0,0 +1,98 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +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} from './SoftwareProductDependenciesConstants.js'; + +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); + } + }); + } + + render() { + let {componentsOptions, softwareProductDependencies, onDataChanged, onAddDependency, isReadOnlyMode} = this.props; + let canAdd = softwareProductDependencies.length < componentsOptions.length * (componentsOptions.length - 1); + 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]; + } + }); + return ( +
    +
    {i18n('Dependencies')}
    + + {softwareProductDependencies.map(dependency => ( + onDataChanged(softwareProductDependencies.filter(currentDependency => currentDependency.id !== dependency.id))} + overlayMsg={i18n('There is a loop between selections')} + hasError={dependency.hasCycle}> + onDataChanged(softwareProductDependencies.map(currentDependency => + ({...currentDependency, sourceId: currentDependency.id === dependency.id ? newSourceId : currentDependency.sourceId}) + ))} /> + + onDataChanged(softwareProductDependencies.map(currentDependency => + ({...currentDependency, targetId: currentDependency.id === dependency.id ? newTargetId : currentDependency.targetId}) + ))} /> + + ))} + +
    + ); + } + + save() { + let {onSubmit, softwareProductDependencies} = this.props; + return onSubmit(softwareProductDependencies); + } +} 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 16a100c664..ac0282e593 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js @@ -1,35 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.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'; + export const mapStateToProps = ({finalizedLicenseModelList, softwareProduct, licenseModel: {licenseAgreement, featureGroup}}) => { - let {softwareProductEditor: {data: currentSoftwareProduct}, softwareProductCategories, softwareProductQuestionnaire} = softwareProduct; + let {softwareProductEditor: {data: currentSoftwareProduct, genericFieldInfo}, softwareProductCategories, softwareProductQuestionnaire} = softwareProduct; let {licensingData = {}, licensingVersion} = currentSoftwareProduct; let licenseAgreementList = [], filteredFeatureGroupsList = []; - if(licensingVersion && licensingVersion !== '') { - licenseAgreementList = licenseAgreement.licenseAgreementList; + licenseAgreementList = licenseAgreement.licenseAgreementList; + if(licensingVersion && 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)); @@ -38,9 +36,11 @@ export const mapStateToProps = ({finalizedLicenseModelList, softwareProduct, lic } } } - let {qdata, qschema} = softwareProductQuestionnaire; + let {qdata, qgenericFieldInfo : qGenericFieldInfo, dataMap} = softwareProductQuestionnaire; let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentSoftwareProduct); + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); + return { currentSoftwareProduct, softwareProductCategories, @@ -48,16 +48,19 @@ export const mapStateToProps = ({finalizedLicenseModelList, softwareProduct, lic featureGroupsList: filteredFeatureGroupsList, finalizedLicenseModelList, qdata, - qschema, - isReadOnlyMode + isReadOnlyMode, + isFormValid, + genericFieldInfo, + qGenericFieldInfo, + dataMap }; }; export const mapActionsToProps = (dispatch) => { return { - onDataChanged: deltaData => SoftwareProductActionHelper.softwareProductEditorDataChanged(dispatch, {deltaData}), - onVendorParamChanged: deltaData => SoftwareProductActionHelper.softwareProductEditorVendorChanged(dispatch, {deltaData}), - onQDataChanged: ({data}) => SoftwareProductActionHelper.softwareProductQuestionnaireUpdate(dispatch, {data}), + 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) =>{ return SoftwareProductActionHelper.updateSoftwareProduct(dispatch, {softwareProduct, qdata});} }; 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 e060706b37..d62207ff9f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsReducer.js @@ -1,55 +1,43 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} 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.OPEN: - return { - ...state, - data: {} - }; - case actionTypes.softwareProductEditor.DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData - } - }; - case actionTypes.softwareProductEditor.UPLOAD_CONFIRMATION: - return { - ...state, - uploadData:action.uploadData - }; case actionTypes.softwareProductEditor.IS_VALIDITY_DATA_CHANGED: return { ...state, isValidityData: action.isValidityData }; - case actionTypes.softwareProductEditor.CLOSE: - return {}; 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: 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 75a5797dec..1d52da38b0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx @@ -1,9 +1,266 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React, {Component, PropTypes} from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import Form from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; +import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js'; +import Form from 'nfvo-components/input/validation/Form.jsx'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +import InputOptions from 'nfvo-components/input/inputOptions/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'; + +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 + }; + + 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); + } + + render (){ + let {genericFieldInfo} = this.props; + return ( +
    + {genericFieldInfo && + + this.props.onDataChanged({name}, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS)}/> + this.onVendorParamChanged(e)}> + {sortByStringProperty( + this.props.finalizedLicenseModelList, + 'vendorName' + ).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.object, + 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 + }; + + onVendorParamChanged(e) { + const selectedIndex = e.target.selectedIndex; + const licensingVersion = e.target.options[selectedIndex].value; + this.props.onVendorParamChanged({vendorId: this.props.vendorId, licensingVersion:{id:licensingVersion, label: 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: []}); + } + + render(){ + return ( + + + this.onVendorParamChanged(e)} + value={this.props.licensingVersion ? this.props.licensingVersion.id : ''} + label={i18n('Licensing Version')} + type='select'> + {this.props.licensingVersionsList.map(version => + + )} + + + + this.onLicensingDataChanged(e)}> + + {this.props.licenseAgreementList.map(la => )} + + + + {this.props.licensingData.licenseAgreement && ( + {}} + 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 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})} /> + + +); class SoftwareProductDetails extends Component { @@ -17,7 +274,7 @@ class SoftwareProductDetails extends Component { subCategory: PropTypes.string, vendorId: PropTypes.string, vendorName: PropTypes.string, - licensingVersion: PropTypes.string, + licensingVersion: PropTypes.object, licensingData: PropTypes.shape({ licenceAgreement: PropTypes.string, featureGroups: PropTypes.array @@ -31,7 +288,6 @@ class SoftwareProductDetails extends Component { onDataChanged: PropTypes.func.isRequired, onValidityChanged: PropTypes.func.isRequired, qdata: PropTypes.object.isRequired, - qschema: PropTypes.object.isRequired, onQDataChanged: PropTypes.func.isRequired, onVendorParamChanged: PropTypes.func.isRequired }; @@ -40,161 +296,63 @@ class SoftwareProductDetails extends Component { licensingVersionsList: [] }; - render() { - let {softwareProductCategories, finalizedLicenseModelList, onDataChanged, featureGroupsList, licenseAgreementList, currentSoftwareProduct} = this.props; - let {name, description, vendorId, licensingVersion, subCategory, licensingData = {}} = currentSoftwareProduct; + prepareDataForGeneralSection(){ + let {softwareProductCategories, finalizedLicenseModelList, onDataChanged, currentSoftwareProduct, genericFieldInfo} = this.props; + let {name, description, vendorId, subCategory} = currentSoftwareProduct; + return { + name, + description, + vendorId, + subCategory, + softwareProductCategories, + finalizedLicenseModelList, + onDataChanged, + onVendorParamChanged: args => this.onVendorParamChanged(args), + onSelectSubCategory: args => this.onSelectSubCategory(args), + genericFieldInfo + }; + + } + + prepareDataForLicensesSection(){ + let { featureGroupsList, licenseAgreementList, currentSoftwareProduct } = this.props; + let {vendorId, licensingVersion, licensingData = {}} = currentSoftwareProduct; let licensingVersionsList = this.state.licensingVersionsList.length > 0 ? this.state.licensingVersionsList : this.refreshVendorVersionsList(vendorId); - let {qdata, qschema, onQDataChanged} = this.props; + return { + onVendorParamChanged: args => this.onVendorParamChanged(args), + vendorId, + licensingVersion, + licensingVersionsList, + licensingData, + onFeatureGroupsChanged: args => this.onFeatureGroupsChanged(args), + onLicensingDataChanged: args => this.onLicensingDataChanged(args), + featureGroupsList, + licenseAgreementList, + }; + + } + + 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}> -
    {i18n('General')}
    -
    -
    - onDataChanged({name})} - validations={{validateName: true, maxLength: 120, required: true}} - className='field-section'/> - this.onVendorParamChanged({vendorId})} - className='field-section'> - {finalizedLicenseModelList.map(lm => )} - -
    - this.onSelectSubCategory(subCategory)} - className='field-section'> - { - softwareProductCategories.map(category => - category.subcategories && - {category.subcategories.map(sub => - )} - - ) - } - -
    -
    -
    - onDataChanged({description})} - className='field-section' - validations={{required: true}}/> -
    -
    -
    -
    {i18n('Licenses')}
    -
    - this.onVendorParamChanged({vendorId, licensingVersion})} - selectedEnum={licensingVersion} - label={i18n('Licensing Version')} - values={licensingVersionsList} - type='select' - className='field-section'/> - this.onLicensingDataChanged({licenseAgreement, featureGroups: []})}> - - {licenseAgreementList.map(la => )} - -
    -
    - {licensingData.licenseAgreement && ( - this.onFeatureGroupsChanged({featureGroups})} - multiSelectedEnum={licensingData.featureGroups} - name='feature-groups' - label={i18n('Feature Groups')} - clearable={false} - values={featureGroupsList}/>) - } -
    -
    -
    -
    -
    -
    {i18n('Availability')}
    -
    -
    - -
    -
    -
    {i18n('Regions')}
    -
    -
    - -
    -
    -
    {i18n('Storage Data Replication')}
    -
    -
    - - -
    -
    - - -
    -
    -
    + + + + +
    ); @@ -213,7 +371,9 @@ class SoftwareProductDetails extends Component { licensingVersion, licensingData: {} }; - onVendorParamChanged(deltaData); + + onVendorParamChanged(deltaData, forms.VENDOR_SOFTWARE_PRODUCT_DETAILS); + } refreshVendorVersionsList(vendorId) { @@ -229,20 +389,14 @@ class SoftwareProductDetails extends Component { }]; if(finalVersions) { finalVersions.forEach(version => licensingVersionsList.push({ - enum: version, - title: version + enum: version.id, + title: version.label })); } return licensingVersionsList; } - onSelectSubCategory(subCategory) { - let {softwareProductCategories, onDataChanged} = this.props; - let category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory(subCategory, softwareProductCategories); - onDataChanged({category, subCategory}); - } - onFeatureGroupsChanged({featureGroups}) { this.onLicensingDataChanged({featureGroups}); } @@ -253,11 +407,17 @@ class SoftwareProductDetails extends Component { ...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); } save(){ - return this.refs.validationForm.handleFormSubmit(new Event('dummy')); + return this.validationForm.handleFormSubmit(new Event('dummy')); } } 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 7604f5841d..e8091bf8d1 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js @@ -1,33 +1,27 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 i18n from 'nfvo-utils/i18n/i18n.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; -import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js'; import OnboardingActionHelper from 'sdc-app/onboarding/OnboardingActionHelper.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'; -const mapStateToProps = ({softwareProduct, licenseModel: {licenseAgreement}}) => { +export const mapStateToProps = ({softwareProduct, licenseModel: {licenseAgreement}}) => { let {softwareProductEditor: {data:currentSoftwareProduct = {}}, softwareProductComponents, softwareProductCategories = []} = softwareProduct; let {licensingData = {}} = currentSoftwareProduct; let {licenseAgreementList} = licenseAgreement; @@ -35,6 +29,8 @@ const mapStateToProps = ({softwareProduct, licenseModel: {licenseAgreement}}) => 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 = ''; @@ -62,27 +58,44 @@ const mapStateToProps = ({softwareProduct, licenseModel: {licenseAgreement}}) => const mapActionsToProps = (dispatch, {version}) => { return { - onDetailsSelect: ({id: softwareProductId, vendorId: licenseModelId}) => OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, { + onDetailsSelect: ({id: softwareProductId, vendorId: licenseModelId, version}) => OnboardingActionHelper.navigateToSoftwareProductDetails(dispatch, { softwareProductId, - licenseModelId + licenseModelId, + version }), - onAttachmentsSelect: ({id: softwareProductId}) => OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId}), + onAttachmentsSelect: ({id: softwareProductId}) => OnboardingActionHelper.navigateToSoftwareProductAttachments(dispatch, {softwareProductId, version}), onUpload: (softwareProductId, formData) => SoftwareProductActionHelper.uploadFile(dispatch, { softwareProductId, formData, - failedNotificationTitle: i18n('Upload validation failed') + failedNotificationTitle: i18n('Upload validation failed'), + version }), + onUploadConfirmation: (softwareProductId, formData) => - SoftwareProductActionHelper.uploadConfirmation(dispatch, { - softwareProductId, - formData, - failedNotificationTitle: i18n('Upload validation failed')}), + 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: NotificationConstants.NOTIFY_ERROR, + type: modalActionTypes.GLOBAL_MODAL_ERROR, data: { title: i18n('Upload Failed'), + confirmationButtonText: i18n('Continue'), msg: i18n('no zip file was uploaded or zip file doesn\'t exist') } }), diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageUploadConfirmationModal.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageUploadConfirmationModal.jsx deleted file mode 100644 index 4a848834b2..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageUploadConfirmationModal.jsx +++ /dev/null @@ -1,38 +0,0 @@ -import {connect} from 'react-redux'; -import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx'; -import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; - -import i18n from 'nfvo-utils/i18n/i18n.js'; - -const mapStateToProps = ({softwareProduct}) => { - let {softwareProductEditor} = softwareProduct; - let {uploadData} = softwareProductEditor; - const show = uploadData ? true : false; - return { - show, - title: 'Warning!', - type: 'warning', - msg: i18n('Upload will erase existing data. Do you want to continue?'), - confirmationDetails: {uploadData} - }; -}; - -const mapActionsToProps = (dispatch) => { - return { - onConfirmed: ({uploadData}) => { - let {softwareProductId, formData, failedNotificationTitle} = uploadData; - SoftwareProductActionHelper.uploadFile(dispatch, { - softwareProductId, - formData, - failedNotificationTitle - }); - SoftwareProductActionHelper.hideUploadConfirm(dispatch); - }, - onDeclined: () => { - SoftwareProductActionHelper.hideUploadConfirm(dispatch); - } - }; -}; - -export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView); - 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 cf7c7a31a5..5fbf1b74b0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import classnames from 'classnames'; import Dropzone from 'react-dropzone'; @@ -6,15 +21,14 @@ import Dropzone from 'react-dropzone'; 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 ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; -import FontAwesome from 'react-fontawesome'; -import SoftwareProductLandingPageUploadConfirmationModal from './SoftwareProductLandingPageUploadConfirmationModal.jsx'; - +import SVGIcon from 'nfvo-components/icon/SVGIcon.jsx'; const SoftwareProductPropType = React.PropTypes.shape({ name: React.PropTypes.string, description: React.PropTypes.string, - version: React.PropTypes.string, + version: React.PropTypes.object, id: React.PropTypes.string, categoryId: React.PropTypes.string, vendorId: React.PropTypes.string, @@ -79,7 +93,6 @@ class SoftwareProductLandingPageView extends React.Component { { componentsList.length > 0 && this.renderComponents() } -
    ); } @@ -101,29 +114,31 @@ class SoftwareProductLandingPageView extends React.Component { onClick={() => onDetailsSelect(currentSoftwareProduct)}>
    -
    -
    {name}
    +
    + {name}
    -
    -
    -
    {i18n('Vendor')}
    -
    {vendorName}
    -
    -
    -
    {i18n('Category')}
    -
    {fullCategoryDisplayName}
    -
    -
    -
    {i18n('License Agreement')}
    -
    - {this.renderLicenseAgreement(licenseAgreementName)} +
    +
    +
    +
    {i18n('Vendor')}
    +
    {vendorName}
    +
    +
    +
    {i18n('Category')}
    +
    {fullCategoryDisplayName}
    +
    +
    +
    {i18n('License Agreement')}
    +
    + {this.renderLicenseAgreement(licenseAgreementName)} +
    -
    -
    -
    {i18n('Description')}
    -
    {description}
    +
    +
    {i18n('Description')}
    +
    {description}
    +
    @@ -151,19 +166,13 @@ class SoftwareProductLandingPageView extends React.Component {
    {i18n('HEAT Templates')} ({details.heatTemplates})
    -
    {i18n('Images')} ({details.images}) -
    -
    {i18n('Other Artifacts')} ({details.otherArtifacts}) -
    {i18n('Drag & drop for upload')}
    {i18n('or')}
    -
    this.refs.fileInput.open()}> +
    this.refs.fileInput.open()}> {i18n('Select file')}
    @@ -180,7 +189,8 @@ class SoftwareProductLandingPageView extends React.Component { title={i18n('Virtual Function Components')} filterValue={localFilter} placeholder={i18n('Filter Components')} - onFilter={filter => this.setState({localFilter: filter})}> + onFilter={value => this.setState({localFilter: value})} + twoColumns> {this.filterList().map(component => this.renderComponentsListItem(component))} ); @@ -194,21 +204,19 @@ class SoftwareProductLandingPageView extends React.Component { key={name + Math.floor(Math.random() * (100 - 1) + 1).toString()} className='list-editor-item-view' onSelect={() => onComponentSelect({id, componentId})}> -
    -
    {i18n('Component')}
    +
    {displayName}
    -
    -
    -
    {i18n('Description')}
    + +
    {description}
    -
    + ); } renderLicenseAgreement(licenseAgreementName) { - if (!licenseAgreementName) { - return (); + if (licenseAgreementName !== null && !licenseAgreementName) { + return (
    {i18n('Missing')}
    ); } return (licenseAgreementName); } @@ -242,6 +250,9 @@ class SoftwareProductLandingPageView extends React.Component { this.startUploading(files); } else { + this.setState({ + dragging: false + }); this.props.onInvalidFileSizeUpload(); } 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 dadc7777e1..6161eadba9 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworks.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworks.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 SoftwareProductNetworksView from './SoftwareProductNetworksView.jsx'; 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 d0e29bcfe5..4cb460ecc6 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js @@ -1,36 +1,31 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductNetworksConstants.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -function baseUrl(svpId) { +function baseUrl(vspId, version) { + let {id: versionId} = version; const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${svpId}/networks`; + return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/networks`; } function fetchNetworksList(softwareProductId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(softwareProductId)}${versionQuery}`); + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); } const 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 d428d21a26..a3d5578dc4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksConstants.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ 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 0c9c62372a..e7c2fcb045 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductNetworksConstants.js'; export default (state = [], action) => { 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 bd47467fe1..024c5cc44c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx @@ -1,8 +1,24 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; 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 ListEditorItemViewField from 'nfvo-components/listEditor/ListEditorItemViewField.jsx'; class SoftwareProductNetworksView extends React.Component { @@ -27,7 +43,8 @@ class SoftwareProductNetworksView extends React.Component { title={i18n('Networks')} filterValue={localFilter} placeholder={i18n('Filter Networks')} - onFilter={filter => this.setState({localFilter: filter})}> + onFilter={value => this.setState({localFilter: value})} + twoColumns> {this.filterList().map(network => this.renderNetworksListItem(network))}
    @@ -42,14 +59,15 @@ class SoftwareProductNetworksView extends React.Component { className='list-editor-item-view' isReadOnlyMode={true}> -
    -
    {i18n('Name')}
    +
    {name}
    -
    -
    -
    {i18n('DHCP')}
    -
    {dhcp ? i18n('YES') : i18n('NO')}
    -
    + + +
    +
    {i18n('DHCP')}
    +
    {dhcp ? i18n('YES') : i18n('NO')}
    +
    +
    ); } 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 5c3a8dae01..66926ce4b3 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcesses.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcesses.js @@ -1,30 +1,27 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 i18n from 'nfvo-utils/i18n/i18n.js'; +import {actionTypes as modalActionTypes} from 'nfvo-components/modal/GlobalModalConstants.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import SoftwareProductProcessesActionHelper from './SoftwareProductProcessesActionHelper.js'; import SoftwareProductProcessesView from './SoftwareProductProcessesView.jsx'; -const mapStateToProps = ({softwareProduct}) => { +export const mapStateToProps = ({softwareProduct}) => { let {softwareProductEditor: {data: currentSoftwareProduct = {}}, softwareProductProcesses: {processesList, processesEditor}} = softwareProduct; let isReadOnlyMode = VersionControllerUtils.isReadOnly(currentSoftwareProduct); let {data} = processesEditor; @@ -42,7 +39,14 @@ const mapActionsToProps = (dispatch, {softwareProductId}) => { return { onAddProcess: () => SoftwareProductProcessesActionHelper.openEditor(dispatch), onEditProcess: (process) => SoftwareProductProcessesActionHelper.openEditor(dispatch, process), - onDeleteProcess: (process) => SoftwareProductProcessesActionHelper.openDeleteProcessesConfirm(dispatch, {process, softwareProductId}) + onDeleteProcess: (process, version) => dispatch({ + type: modalActionTypes.GLOBAL_MODAL_WARNING, + data:{ + msg: i18n('Are you sure you want to delete "{name}"?', {name: process.name}), + onConfirmed: ()=> SoftwareProductProcessesActionHelper.deleteProcess(dispatch, + {process, softwareProductId, version}) + } + }) }; }; 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 df5d08ffe5..8fd370b6cc 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js @@ -1,62 +1,57 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductProcessesConstants.js'; import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js'; import Configuration from 'sdc-app/config/Configuration.js'; -function baseUrl(svpId) { +function baseUrl(vspId, version) { + let {id: versionId} = version; const restPrefix = Configuration.get('restPrefix'); - return `${restPrefix}/v1.0/vendor-software-products/${svpId}/processes`; + return `${restPrefix}/v1.0/vendor-software-products/${vspId}/versions/${versionId}/processes`; } -function putProcess(softwareProductId, process) { - return RestAPIUtil.save(`${baseUrl(softwareProductId)}/${process.id}`, { +function putProcess(softwareProductId, version, process) { + return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${process.id}`, { name: process.name, - description: process.description + description: process.description, + type: process.type === '' ? null : process.type }); } -function postProcess(softwareProductId, process) { - return RestAPIUtil.create(`${baseUrl(softwareProductId)}`, { +function postProcess(softwareProductId, version, process) { + return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}`, { name: process.name, - description: process.description + description: process.description, + type: process.type === '' ? null : process.type }); } -function deleteProcess(softwareProductId, processId) { - return RestAPIUtil.destroy(`${baseUrl(softwareProductId)}/${processId}`); +function deleteProcess(softwareProductId, version, processId) { + return RestAPIUtil.destroy(`${baseUrl(softwareProductId, version)}/${processId}`); } -function uploadFileToProcess(softwareProductId, processId, formData) +function uploadFileToProcess(softwareProductId, version, processId, formData) { - return RestAPIUtil.create(`${baseUrl(softwareProductId)}/${processId}/upload`, formData); + return RestAPIUtil.post(`${baseUrl(softwareProductId, version)}/${processId}/upload`, formData); } function fetchProcesses(softwareProductId, version) { - let versionQuery = version ? `?version=${version}` : ''; - return RestAPIUtil.fetch(`${baseUrl(softwareProductId)}${versionQuery}`); + return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`); } - - const SoftwareProductActionHelper = { fetchProcessesList(dispatch, {softwareProductId, version}) { @@ -80,8 +75,8 @@ const SoftwareProductActionHelper = { }); }, - deleteProcess(dispatch, {process, softwareProductId}) { - return deleteProcess(softwareProductId, process.id).then(() => { + deleteProcess(dispatch, {process, softwareProductId, version}) { + return deleteProcess(softwareProductId, version, process.id).then(() => { dispatch({ type: actionTypes.DELETE_SOFTWARE_PRODUCT_PROCESS, processId: process.id @@ -96,18 +91,11 @@ const SoftwareProductActionHelper = { }); }, - processEditorDataChanged(dispatch, {deltaData}) { - dispatch({ - type: actionTypes.processEditor.DATA_CHANGED, - deltaData - }); - }, - - saveProcess(dispatch, {softwareProductId, previousProcess, process}) { + saveProcess(dispatch, {softwareProductId, version, previousProcess, process}) { if (previousProcess) { - return putProcess(softwareProductId, process).then(() => { + return putProcess(softwareProductId, version, process).then(() => { if (process.formData){ - uploadFileToProcess(softwareProductId, process.id, process.formData); + uploadFileToProcess(softwareProductId, version, process.id, process.formData); } dispatch({ type: actionTypes.EDIT_SOFTWARE_PRODUCT_PROCESS, @@ -116,9 +104,9 @@ const SoftwareProductActionHelper = { }); } else { - return postProcess(softwareProductId, process).then(response => { + return postProcess(softwareProductId, version, process).then(response => { if (process.formData) { - uploadFileToProcess(softwareProductId, response.value, process.formData); + uploadFileToProcess(softwareProductId, version, response.value, process.formData); } dispatch({ type: actionTypes.ADD_SOFTWARE_PRODUCT_PROCESS, diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConfirmationModal.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConfirmationModal.jsx deleted file mode 100644 index 0159352dae..0000000000 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConfirmationModal.jsx +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react'; -import {connect} from 'react-redux'; -import i18n from 'nfvo-utils/i18n/i18n.js'; -import ConfirmationModalView from 'nfvo-components/confirmations/ConfirmationModalView.jsx'; -import SoftwareProductProcessesActionHelper from './SoftwareProductProcessesActionHelper.js'; - -function renderMsg(processToDelete) { - let name = processToDelete ? processToDelete.name : ''; - let msg = i18n('Are you sure you want to delete "{name}"?', {name}); - return ( -
    -

    {msg}

    -
    - ); -}; - -const mapStateToProps = ({softwareProduct}) => { - let {softwareProductEditor, softwareProductProcesses} = softwareProduct; - let {processToDelete} = softwareProductProcesses; - let softwareProductId = softwareProductEditor.data.id; - - const show = processToDelete !== false; - return { - show, - title: i18n('Warning!'), - type: 'warning', - msg: renderMsg(processToDelete), - confirmationDetails: {processToDelete, softwareProductId} - }; -}; - -const mapActionsToProps = (dispatch) => { - return { - onConfirmed: ({processToDelete, softwareProductId}) => { - SoftwareProductProcessesActionHelper.deleteProcess(dispatch, {process: processToDelete, softwareProductId}); - SoftwareProductProcessesActionHelper.hideDeleteConfirm(dispatch); - }, - onDeclined: () => { - SoftwareProductProcessesActionHelper.hideDeleteConfirm(dispatch); - } - }; -}; - -export default connect(mapStateToProps, mapActionsToProps)(ConfirmationModalView); - 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 63f3067a89..6eee24cdde 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConstants.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesConstants.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 keyMirror from 'nfvo-utils/KeyMirror.js'; export const actionTypes = keyMirror({ @@ -27,8 +22,14 @@ export const actionTypes = keyMirror({ SOFTWARE_PRODUCT_PROCESS_EDITOR_OPEN: null, SOFTWARE_PRODUCT_PROCESS_EDITOR_CLOSE: null, FETCH_SOFTWARE_PRODUCT_PROCESSES: null, - SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM: null, - processEditor: { - DATA_CHANGED: null - } + SOFTWARE_PRODUCT_PROCESS_DELETE_CONFIRM: null }); + +export const optionsInputValues = { + 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 8dc48c50b1..ff787c357e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditor.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditor.js @@ -1,31 +1,28 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; import SoftwareProductProcessesActionHelper from './SoftwareProductProcessesActionHelper'; import SoftwareProductProcessesEditorView from './SoftwareProductProcessesEditorView.jsx'; +import {VSP_PROCESS_FORM} from './SoftwareProductProcessesConstants.js'; -const mapStateToProps = ({softwareProduct}) => { +export const mapStateToProps = ({softwareProduct}) => { let {softwareProductProcesses: {processesList, processesEditor}} = softwareProduct; - let {data} = processesEditor; - + let {data, genericFieldInfo, formReady} = processesEditor; + let isFormValid = ValidationHelper.checkFormValid(genericFieldInfo); let previousData; const processId = data ? data.id : null; if(processId) { @@ -34,18 +31,22 @@ const mapStateToProps = ({softwareProduct}) => { return { data, - previousData + genericFieldInfo, + previousData, + isFormValid, + formReady }; }; -const mapActionsToProps = (dispatch, {softwareProductId}) => { +const mapActionsToProps = (dispatch, {softwareProductId, version}) => { return { - onDataChanged: deltaData => SoftwareProductProcessesActionHelper.processEditorDataChanged(dispatch, {deltaData}), + onDataChanged: (deltaData) => ValidationHelper.dataChanged(dispatch, {deltaData, formName: VSP_PROCESS_FORM}), onSubmit: ({previousProcess, process}) => { SoftwareProductProcessesActionHelper.closeEditor(dispatch); - SoftwareProductProcessesActionHelper.saveProcess(dispatch, {softwareProductId, previousProcess, process}); + SoftwareProductProcessesActionHelper.saveProcess(dispatch, {softwareProductId, version, previousProcess, process}); }, - onClose: () => SoftwareProductProcessesActionHelper.closeEditor(dispatch) + onClose: () => SoftwareProductProcessesActionHelper.closeEditor(dispatch), + onValidateForm: () => ValidationHelper.validateForm(dispatch, VSP_PROCESS_FORM) }; }; 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 cae25e2c89..11b89b17c2 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorReducer.js @@ -1,43 +1,54 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} 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 {}; - case actionTypes.processEditor.DATA_CHANGED: - return { - ...state, - data: { - ...state.data, - ...action.deltaData - } - }; 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 c2c4aff382..137e4a2b4e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorView.jsx @@ -1,18 +1,50 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import Dropzone from 'react-dropzone'; import classnames from 'classnames'; import i18n from 'nfvo-utils/i18n/i18n.js'; -import ValidationForm from 'nfvo-components/input/validation/ValidationForm.jsx'; -import ValidationInput from 'nfvo-components/input/validation/ValidationInput.jsx'; +import {optionsInputValues as ProcessesOptionsInputValues} from './SoftwareProductProcessesConstants.js'; +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'; const SoftwareProductProcessEditorPropType = React.PropTypes.shape({ id: React.PropTypes.string, name: React.PropTypes.string, description: React.PropTypes.string, - artifactName: React.PropTypes.string + artifactName: React.PropTypes.string, + type: React.PropTypes.string }); +const FileUploadBox = ({onClick}) => { + return ( +
    +
    {i18n('Drag & drop for upload')}
    +
    {i18n('or')}
    +
    + {i18n('Select file')} +
    +
    + ); +}; + + class SoftwareProductProcessesEditorView extends React.Component { state = { @@ -30,63 +62,89 @@ class SoftwareProductProcessesEditorView extends React.Component { }; render() { - let {data = {}, isReadOnlyMode, onDataChanged, onClose} = this.props; - let {name, description, artifactName} = data; + let {data = {}, isReadOnlyMode, onDataChanged, onClose, genericFieldInfo} = this.props; + let {name, description, artifactName, type} = data; + return ( - this.submit() } - onReset={ () => onClose() } - className='vsp-processes-editor'> -
    - this.handleImportSubmit(files)} - onDragEnter={() => this.setState({dragging: true})} - onDragLeave={() => this.setState({dragging: false})} - multiple={false} - disableClick={true} - ref='processEditorFileInput' - name='processEditorFileInput' - accept='*.*'> -
    -
    - onDataChanged({name})} - label={i18n('Name')} - value={name} - validations={{validateName: true, maxLength: 120, required: true}} - type='text'/> - -
    -
    -
    -
    {i18n('Drag & drop for upload')}
    -
    {i18n('or')}
    -
    this.refs.processEditorFileInput.open()}> - {i18n('Select file')} -
    -
    -
    -
    - onDataChanged({description})} - label={i18n('Notes')} - value={description} - name='vsp-process-description' - className='vsp-process-description' - validations={{maxLength: 1000}} - type='textarea'/> -
    -
    -
    +
    + {genericFieldInfo &&
    this.submit() } + onReset={ () => onClose() } + 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')} + data-test-id='process-type' + isValid={genericFieldInfo.type.isValid} + errorText={genericFieldInfo.type.errorText} + type='select'> + {ProcessesOptionsInputValues.PROCESS_TYPE.map(mtype => + )} + + + + +
    +
    } +
    ); } @@ -108,14 +166,24 @@ class SoftwareProductProcessesEditorView extends React.Component { } - handleImportSubmit(files) { - let {onDataChanged} = this.props; - this.setState({ - dragging: false, - complete: '0', - files - }); - onDataChanged({artifactName: files[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); + } + } } } 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 619a2dba0f..20390d1f60 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesListReducer.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesListReducer.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {actionTypes} from './SoftwareProductProcessesConstants.js'; export default (state = [], action) => { 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 a2aa3d414e..8f52434042 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesView.jsx @@ -1,3 +1,18 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Modal from 'nfvo-components/modal/Modal.jsx'; @@ -6,7 +21,7 @@ import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'nfvo-components/listEditor/ListEditorItemView.jsx'; import SoftwareProductProcessesEditor from './SoftwareProductProcessesEditor.js'; -import SoftwareProductProcessesConfirmationModal from './SoftwareProductProcessesConfirmationModal.jsx'; + class SoftwareProductProcessesView extends React.Component { @@ -20,30 +35,29 @@ class SoftwareProductProcessesView extends React.Component { onEditProcess: React.PropTypes.func.isRequired, onDeleteProcess: React.PropTypes.func.isRequired, isDisplayEditor: React.PropTypes.bool.isRequired, - isReadOnlyMode: React.PropTypes.bool.isRequired + isReadOnlyMode: React.PropTypes.bool.isRequired, + currentSoftwareProduct:React.PropTypes.object }; render() { - let { currentSoftwareProduct} = this.props; return (
    {this.renderEditor()} {this.renderProcessList()} -
    ); } renderEditor() { - let {currentSoftwareProduct: {id}, isModalInEditMode, isReadOnlyMode, isDisplayEditor} = this.props; + let {currentSoftwareProduct: {id, version}, isModalInEditMode, isReadOnlyMode, isDisplayEditor} = this.props; return ( - + {isModalInEditMode ? i18n('Edit Process Details') : i18n('Create New Process Details')} - + ); @@ -60,7 +74,8 @@ class SoftwareProductProcessesView extends React.Component { placeholder={i18n('Filter Process')} onAdd={onAddProcess} isReadOnlyMode={isReadOnlyMode} - onFilter={filter => this.setState({localFilter: filter})}> + title={i18n('Process Details')} + onFilter={value => this.setState({localFilter: value})}> {this.filterList().map(processes => this.renderProcessListItem(processes, isReadOnlyMode))} ); @@ -68,14 +83,14 @@ class SoftwareProductProcessesView extends React.Component { renderProcessListItem(process, isReadOnlyMode) { let {id, name, description, artifactName = ''} = process; - let {onEditProcess, onDeleteProcess} = this.props; + let {currentSoftwareProduct: {version}, onEditProcess, onDeleteProcess} = this.props; return ( onEditProcess(process)} - onDelete={() => onDeleteProcess(process)}> + onDelete={() => onDeleteProcess(process, version)}>
    {i18n('Name')}
    diff --git a/openecomp-ui/src/sdc-app/punch-outs.js b/openecomp-ui/src/sdc-app/punch-outs.js index 46e84a60a4..78b64da846 100644 --- a/openecomp-ui/src/sdc-app/punch-outs.js +++ b/openecomp-ui/src/sdc-app/punch-outs.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 '../../resources/scss/onboarding.scss'; import 'dox-sequence-diagram-ui/src/main/webapp/res/sdc-sequencer.scss'; diff --git a/openecomp-ui/src/sdc-app/sdc.app.jsx b/openecomp-ui/src/sdc-app/sdc.app.jsx index 0929fa0bb9..5fdea27fea 100644 --- a/openecomp-ui/src/sdc-app/sdc.app.jsx +++ b/openecomp-ui/src/sdc-app/sdc.app.jsx @@ -1,5 +1,19 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 '../../resources/scss/bootstrap.scss'; -import '../../resources/css/font-awesome.min.css'; import 'react-select/dist/react-select.min.css'; import 'dox-sequence-diagram-ui/src/main/webapp/res/sdc-sequencer.scss'; import '../../resources/scss/style.scss'; diff --git a/openecomp-ui/test-utils/MockRest.js b/openecomp-ui/test-utils/MockRest.js index 927da6030a..c49d53d984 100644 --- a/openecomp-ui/test-utils/MockRest.js +++ b/openecomp-ui/test-utils/MockRest.js @@ -1,34 +1,29 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ - const queue = { fetch: [], - save: [], - create: [], + put: [], + post: [], destroy: [] }; const initQueue = () => { queue['fetch'] = []; - queue['save'] = []; - queue['create'] = []; + queue['put'] = []; + queue['post'] = []; queue['destroy'] = []; }; @@ -51,20 +46,20 @@ export default { return handleOperation(fetch.shift(), {options, baseUrl}); }, - save(baseUrl, data, options) { - const {save} = queue; - if(!save.length) { - throw new Error(`Save operation was called without proper handler. baseUrl: '${baseUrl}' options: '${options}'`); + put(baseUrl, data, options) { + const {put} = queue; + if(!put.length) { + throw new Error(`put operation was called without proper handler. baseUrl: '${baseUrl}' options: '${options}'`); } - return handleOperation(save.shift(), {data, options, baseUrl}); + return handleOperation(put.shift(), {data, options, baseUrl}); }, - create(baseUrl, data, options) { - const {create} = queue; - if(!create.length) { - throw new Error(`Create operation was called without proper handler. baseUrl: '${baseUrl}' options: '${options}'`); + post(baseUrl, data, options) { + const {post} = queue; + if(!post.length) { + throw new Error(`post operation was called without proper handler. baseUrl: '${baseUrl}' options: '${options}'`); } - return handleOperation(create.shift(), {data, options, baseUrl}); + return handleOperation(post.shift(), {data, options, baseUrl}); }, destroy(baseUrl, options) { diff --git a/openecomp-ui/test-utils/Util.js b/openecomp-ui/test-utils/Util.js index 7146267afe..415736fa60 100644 --- a/openecomp-ui/test-utils/Util.js +++ b/openecomp-ui/test-utils/Util.js @@ -1,26 +1,38 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 deepFreeze from 'deep-freeze'; +import times from 'lodash/times'; +import pick from 'lodash/pick'; +import intersection from 'lodash/intersection'; import ReactTestUtils from 'react-addons-test-utils'; +export const buildListFromFactory = (factory, quantity = 3, overrides) => { + let list = []; + times(quantity, () =>{ + list.push(factory.build(overrides)); + }); + return list; +}; + +export const buildFromExistingObject = (factory, obj, overrides = {}, options = {}) => { + const mock = factory.build(); + const sharedProperties = intersection(Object.keys(mock), Object.keys(obj)); + return factory.build({...pick(obj, sharedProperties), ...overrides}, options); +}; + //returned object should be treated as immutable. export const cloneAndSet = (obj, path, value) => { let retVal = {...obj}; @@ -53,3 +65,17 @@ export const findAllRenderedComponentsWithTestId = (tree, testId) => { return ReactTestUtils.findAllInRenderedTree(tree, component => component.props.testId === testId); }; +/** + * Finds all instance of components in the rendered tree that are DOM + * components with the data-test-id + * @return {array} an array of all the matches. + */ +export const scryRenderedDOMComponentsWithTestId = (root, testId) => { + return ReactTestUtils.findAllInRenderedTree(root, function (inst) { + if (ReactTestUtils.isDOMComponent(inst)) { + var compTestId = inst.getAttribute('data-test-id'); + return compTestId === testId; + } + return false; + }); +}; diff --git a/openecomp-ui/test-utils/factories/SubnitErrorMessageFactorie.js b/openecomp-ui/test-utils/factories/SubnitErrorMessageFactorie.js new file mode 100644 index 0000000000..a553d9a9a0 --- /dev/null +++ b/openecomp-ui/test-utils/factories/SubnitErrorMessageFactorie.js @@ -0,0 +1,56 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import randomstring from 'randomstring'; + +export const SubmitErrorMessageFactory = new Factory() + .attrs({ + vspErrors: [ + {message: randomstring.generate(5)}, + {message: randomstring.generate(5)}, + ], + licensingDataErrors: [ + {message: randomstring.generate(5)}, + {message: randomstring.generate(5)}, + ], + questionnaireValidationResult: { + validationData: [ + { + entityName: randomstring.generate(5), + errors: ['1212', '232323'] + } + ] + }, + uploadDataErrors: { + eca_oam: [ + { + level: 'ERROR', + message: randomstring.generate(25) + }, + { + level: 'ERROR', + message: randomstring.generate(25) + } + ], + cmaui_env: [ + { + level: 'ERROR', + message: randomstring.generate(25) + } + ] + } + }); diff --git a/openecomp-ui/test-utils/factories/activity-log/ActivityLogFactories.js b/openecomp-ui/test-utils/factories/activity-log/ActivityLogFactories.js new file mode 100644 index 0000000000..8f1ff5d40c --- /dev/null +++ b/openecomp-ui/test-utils/factories/activity-log/ActivityLogFactories.js @@ -0,0 +1,30 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 { Factory } from 'rosie'; +import IdMixin from 'test-utils/factories/mixins/IdMixin.js'; + +const ActivityLogBaseFactory = new Factory() + .attrs({ timestamp: new Date().getTime(), + type: 'CREATE_NEW', + comment: '', + user: 'cs0008', + status: { success: true, message: ''} + }); + +export const ActivityLogStoreFactory = new Factory() + .extend(ActivityLogBaseFactory) + .extend(IdMixin); diff --git a/openecomp-ui/test-utils/factories/flows/FlowsFactories.js b/openecomp-ui/test-utils/factories/flows/FlowsFactories.js new file mode 100644 index 0000000000..f487ee7404 --- /dev/null +++ b/openecomp-ui/test-utils/factories/flows/FlowsFactories.js @@ -0,0 +1,118 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import SequenceDiagramFactory from './SequenceDiagramFactory.js'; +import ParticipantFactory from './ParticipantFactory.js'; +import UUID from 'uuid-js'; + +const serviceIDByArtifactType = { + NETWORK_CALL_FLOW: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b', + WORKFLOW: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b', + PUPPET: '0280b577-2c7b-426e-b7a2-f0dc16508c37' +}; + +const defaultServiceId = '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b'; + +Factory.define('FlowBaseFactory') + .attrs({ + artifactName: 'zizizi', + artifactType: 'WORKFLOW', + description: 'aslkjdfl asfdasdf', + }); + +Factory.define('FlowBaseWithServiceIdFactory') + .extend('FlowBaseFactory') + .attr( + 'serviceID', ['artifactType'], artifactType => serviceIDByArtifactType[artifactType] || defaultServiceId + ); + +Factory.define('FlowBaseWithUniqueIdFactory') + .extend('FlowBaseFactory') + .attr('uniqueId', ['artifactType', 'artifactName'], (artifactType, artifactName) => `${serviceIDByArtifactType[artifactType] || defaultServiceId}.${artifactName}`); + +Factory.define('FlowBaseFetchAndDeleteFactory') + .extend('FlowBaseWithServiceIdFactory') + .extend('FlowBaseWithUniqueIdFactory') + .attrs({ + participants: [] + }); + +Factory.define('FlowBaseWithEsIdFactory') + .extend('FlowBaseWithUniqueIdFactory') + .attr('esId', ['uniqueId'], uniqueId => uniqueId); + +export const FlowBasicFactory = new Factory() + .extend('FlowBaseFactory').attrs({uniqueId: () => UUID.create(4)}); + +export const FlowCreateFactory = new Factory() + .extend('FlowBaseWithServiceIdFactory'); + +export const FlowPostRequestFactory = new Factory() + .extend('FlowBaseFactory') + .attrs({ + artifactGroupType: 'INFORMATIONAL', + payloadData: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ==' + }) + .attr('artifactLabel', ['artifactName'], name => name); + +Factory.define('FlowPostResponeAndUpdateBaseFactory') + .extend('FlowBaseFactory') + .extend('FlowBaseWithUniqueIdFactory') + .extend('FlowBaseWithEsIdFactory') + .attrs({ + artifactGroupType: 'INFORMATIONAL', + artifactUUID: () => UUID.create(4), + artifactVersion: '1', + creationDate: 1470144601623, + lastUpdateDate: 1470144601623, + mandatory: false, + timeout: 0, + artifactChecksum: 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=' + }) + .attr('artifactLabel', ['artifactName'], name => name) + .attr('artifactDisplayName', ['artifactName'], name => name); + +export const FlowPostResponseFactory = new Factory() + .extend('FlowPostResponeAndUpdateBaseFactory') + .attrs({ + attUidLastUpdater: 'cs0008', + payloadUpdateDate: 1470144602131, + serviceApi: false, + updaterFullName: 'Carlos Santana', + artifactCreator: 'cs0008' + }); + +export const FlowUpdateRequestFactory = new Factory() + .extend('FlowPostResponeAndUpdateBaseFactory') + .extend('FlowBaseFetchAndDeleteFactory') + .extend('FlowBaseWithEsIdFactory') + .attrs({ + heatParameters: [], + participants: ParticipantFactory.buildList(10) + }) + .attr('sequenceDiagramModel', ['participants'], participants => SequenceDiagramFactory.build({}, {participants})); + +export const FlowFetchRequestFactory = new Factory() + .extend('FlowBaseFetchAndDeleteFactory'); + +export const FlowDeleteRequestFactory = new Factory() + .extend('FlowBaseFetchAndDeleteFactory'); + +export const FlowFetchResponseFactory = new Factory() + .extend('FlowBaseFactory') + .attrs({ + base64Contents: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ==' + }); diff --git a/openecomp-ui/test-utils/factories/flows/ParticipantFactory.js b/openecomp-ui/test-utils/factories/flows/ParticipantFactory.js new file mode 100644 index 0000000000..2e74649cb8 --- /dev/null +++ b/openecomp-ui/test-utils/factories/flows/ParticipantFactory.js @@ -0,0 +1,20 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; + +export default new Factory() + .attr('name', 'participantName') + .sequence('id', index => index.toString()); diff --git a/openecomp-ui/test-utils/factories/flows/SequenceDiagramFactory.js b/openecomp-ui/test-utils/factories/flows/SequenceDiagramFactory.js new file mode 100644 index 0000000000..7662f5b2f2 --- /dev/null +++ b/openecomp-ui/test-utils/factories/flows/SequenceDiagramFactory.js @@ -0,0 +1,50 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import UUID from 'uuid-js'; + +Factory.define('LifeLineFactory') + .attr('name', 'participantName') + .sequence('id', index => index.toString()) + .sequence('index') + .sequence('x', index => 175 + (index - 1) * 400); + +Factory.define('StepMessageFactory') + .attrs({ + name: '[Unnamed Message]', + type: 'request', + from: '1', + to: '2', + }) + .attr('id', () => UUID.create(4)) + .sequence('index'); + +Factory.define('StepFactory') + .attr('message', () => Factory.build('StepMessageFactory')); + +export default new Factory() + .option('participants', []) + .option('stepsCount', 2) + .attr('diagram', ['participants', 'stepsCount'], (participants, stepsCount) => ({ + metadata: { + 'id': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', + 'name': 'zizizi', + 'ref': 'BLANK' + }, + lifelines: participants.map(participant => Factory.build('LifeLineFactory', participant)), + steps: Factory.buildList('StepFactory', stepsCount) + }) +); diff --git a/openecomp-ui/test-utils/factories/licenseModel/EntitlementPoolFactories.js b/openecomp-ui/test-utils/factories/licenseModel/EntitlementPoolFactories.js new file mode 100644 index 0000000000..14df58e4c2 --- /dev/null +++ b/openecomp-ui/test-utils/factories/licenseModel/EntitlementPoolFactories.js @@ -0,0 +1,61 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import {overviewEditorHeaders} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; + +Factory.define('EntitlementPoolBaseFactory') + .attrs({ + name: 'EntitlementPoolName', + description: 'description', + entitlementMetric: {'choice': 'User', 'other': ''}, + manufacturerReferenceNumber: '123' + }); + +Factory.define('EntitlementPoolExtendedBaseFactory') + .extend('EntitlementPoolBaseFactory') + .attrs({ + thresholdValue: 75, + thresholdUnits: '%', + increments: 'string', + aggregationFunction: {'choice': 'Average', 'other': ''}, + operationalScope: {'choices': ['Other'], 'other': 'blabla'}, + time: {'choice': 'Hour', 'other': ''} + }); + +export const EntitlementPoolListItemFactory = new Factory() + .extend('EntitlementPoolBaseFactory') + .attrs({ + id: () => Math.floor(Math.random() * (1000 - 1) + 1), + itemType: overviewEditorHeaders.ENTITLEMENT_POOL + }); + +export const EntitlementPoolStoreFactory = new Factory() + .extend('EntitlementPoolExtendedBaseFactory') + .attrs({ + id: () => Math.floor(Math.random() * (1000 - 1) + 1), + referencingFeatureGroups: [] + }); + +export const EntitlementPoolDataListFactory = new Factory() + .extend('EntitlementPoolExtendedBaseFactory') + .attrs({ + id: () => Math.floor(Math.random() * (1000 - 1) + 1), + referencingFeatureGroups: [], + itemType: overviewEditorHeaders.ENTITLEMENT_POOL + }); + +export const EntitlementPoolPostFactory = new Factory() + .extend('EntitlementPoolExtendedBaseFactory'); diff --git a/openecomp-ui/test-utils/factories/licenseModel/FeatureGroupFactories.js b/openecomp-ui/test-utils/factories/licenseModel/FeatureGroupFactories.js new file mode 100644 index 0000000000..42209792b9 --- /dev/null +++ b/openecomp-ui/test-utils/factories/licenseModel/FeatureGroupFactories.js @@ -0,0 +1,82 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 { Factory } from 'rosie'; +import {overviewEditorHeaders} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; +import IdMixin from 'test-utils/factories/mixins/IdMixin.js'; + +Factory.define('FeatureGroupBaseFactory') + .attrs({ + 'name': 'featureGroup', + 'description': 'description' + }); + +Factory.define('FeatureGroupExtendedBaseFactory') + .extend('FeatureGroupBaseFactory') + .attrs({ + 'partNumber': '1212' + }); + +export const FeatureGroupListItemFactory = new Factory() + .extend('FeatureGroupBaseFactory') + .extend(IdMixin) + .attrs({ + children: [], + isCollapsed: true, + itemType: overviewEditorHeaders.FEATURE_GROUP + }); + +export const FeatureGroupDispatchFactory = new Factory() + .extend('FeatureGroupExtendedBaseFactory') + .attrs({ + 'licenseKeyGroupsIds': [], + 'entitlementPoolsIds': [] + }); + +export const FeatureGroupStoreFactory = new Factory() + .extend('FeatureGroupExtendedBaseFactory') + .extend(IdMixin) + .attrs({ + licenseKeyGroupsIds: [], + entitlementPoolsIds: [], + referencingLicenseAgreements: [] + }); + +export const FeatureGroupDataListFactory = new Factory() + .extend('FeatureGroupExtendedBaseFactory') + .extend(IdMixin) + .attrs({ + licenseKeyGroupsIds: [], + entitlementPoolsIds: [], + referencingLicenseAgreements: [], + children: [], + itemType: overviewEditorHeaders.FEATURE_GROUP + }); + +export const FeatureGroupPostFactory = new Factory() + .extend('FeatureGroupExtendedBaseFactory') + .attrs({ + addedLicenseKeyGroupsIds: [], + addedEntitlementPoolsIds: [] + }); + +export const FeatureGroupPutFactory = new Factory() + .extend('FeatureGroupExtendedBaseFactory') + .attrs({ + addedLicenseKeyGroupsIds: [], + addedEntitlementPoolsIds: [], + removedLicenseKeyGroupsIds: [], + removedEntitlementPoolsIds: [] + }); diff --git a/openecomp-ui/test-utils/factories/licenseModel/LicenseAgreementFactories.js b/openecomp-ui/test-utils/factories/licenseModel/LicenseAgreementFactories.js new file mode 100644 index 0000000000..0c91456123 --- /dev/null +++ b/openecomp-ui/test-utils/factories/licenseModel/LicenseAgreementFactories.js @@ -0,0 +1,77 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 { Factory } from 'rosie'; +import {overviewEditorHeaders} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; +import IdMixin from 'test-utils/factories/mixins/IdMixin.js'; + +Factory.define('LicenseAgreementBaseFactory') + .attrs({ + name: 'License Agreement', + description: 'sdsd', + licenseTerm: { + choice: 'Fixed_Term' + } + }); + +Factory.define('LicenseAgreementExtendedBaseFactory') + .extend('LicenseAgreementBaseFactory') + .attrs({ + requirementsAndConstrains: 'req_and_constraints_ADDED_LA' + }); + +export const LicenseAgreementListItemFactory = new Factory() + .extend('LicenseAgreementExtendedBaseFactory') + .extend(IdMixin) + .attrs({ + children: [], + isCollapsed: true, + itemType: overviewEditorHeaders.LICENSE_AGREEMENT + }); + +export const LicenseAgreementDispatchFactory = new Factory() + .extend('LicenseAgreementExtendedBaseFactory') + .attrs({ + featureGroupsIds: [] + }); + +export const LicenseAgreementStoreFactory = new Factory() + .extend('LicenseAgreementExtendedBaseFactory') + .extend(IdMixin) + .attrs({ + featureGroupsIds: [] + }); + +export const LicenseAgreementDataListFactory = new Factory() + .extend('LicenseAgreementExtendedBaseFactory') + .extend(IdMixin) + .attrs({ + featureGroupsIds: [], + children:[], + itemType: overviewEditorHeaders.LICENSE_AGREEMENT + }); + +export const LicenseAgreementPostFactory = new Factory() + .extend('LicenseAgreementExtendedBaseFactory') + .attrs({ + addedFeatureGroupsIds: [] + }); + +export const LicenseAgreementPutFactory = new Factory() + .extend('LicenseAgreementExtendedBaseFactory') + .attrs({ + addedFeatureGroupsIds: [], + removedFeatureGroupsIds: [] + }); diff --git a/openecomp-ui/test-utils/factories/licenseModel/LicenseKeyGroupFactories.js b/openecomp-ui/test-utils/factories/licenseModel/LicenseKeyGroupFactories.js new file mode 100644 index 0000000000..50890dd7ec --- /dev/null +++ b/openecomp-ui/test-utils/factories/licenseModel/LicenseKeyGroupFactories.js @@ -0,0 +1,52 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import {overviewEditorHeaders} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; + +Factory.define('LicenseKeyGroupBaseFactory') + .attrs({ + name: 'License Key Group', + description: 'wewe', + type: 'Unique', + operationalScope: { + choices: ['Data_Center'] + } + }); + +export const LicenseKeyGroupListItemFactory = new Factory() + .extend('LicenseKeyGroupBaseFactory') + .attrs({ + id: () => Math.floor(Math.random() * (1000 - 1) + 1), + itemType: overviewEditorHeaders.LICENSE_KEY_GROUP + }); + +export const LicenseKeyGroupStoreFactory = new Factory() + .extend('LicenseKeyGroupBaseFactory') + .attrs({ + id: () => Math.floor(Math.random() * (1000 - 1) + 1), + referencingFeatureGroups: [] + }); + +export const LicenseKeyGroupDataListFactory = new Factory() + .extend('LicenseKeyGroupBaseFactory') + .attrs({ + id: () => Math.floor(Math.random() * (1000 - 1) + 1), + referencingFeatureGroups: [], + itemType: overviewEditorHeaders.LICENSE_KEY_GROUP + }); + +export const LicenseKeyGroupPostFactory = new Factory() + .extend('LicenseKeyGroupBaseFactory'); diff --git a/openecomp-ui/test-utils/factories/licenseModel/LicenseModelFactories.js b/openecomp-ui/test-utils/factories/licenseModel/LicenseModelFactories.js new file mode 100644 index 0000000000..716eb15559 --- /dev/null +++ b/openecomp-ui/test-utils/factories/licenseModel/LicenseModelFactories.js @@ -0,0 +1,77 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 { Factory } from 'rosie'; +import { selectedButton } from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; +import IdMixin from 'test-utils/factories/mixins/IdMixin.js'; +import randomstring from 'randomstring'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +Factory.define('LicenseModelBaseFactory') + .attrs({ + vendorName: 'vlm1', + description: 'string', + iconRef: 'icon' + }); + +export const LicenseModelCreationFactory = new Factory() + .attrs({ + data: { + vendorName: () => randomstring.generate(), + description: () => randomstring.generate() + } + }); + +export const LicenseModelPostFactory = new Factory() + .extend('LicenseModelBaseFactory'); + +export const LicenseModelDispatchFactory = new Factory() + .extend('LicenseModelBaseFactory'); + +export const LicenseModelStoreFactory = new Factory() + .extend('LicenseModelBaseFactory') + .extend(IdMixin); + + +export const FinalizedLicenseModelFactory = new Factory() + .extend(IdMixin) + .attrs({ + vendorName: randomstring.generate(), + description: randomstring.generate(), + iconRef: 'iconRef_lBpEgzhuiY1', + version: {id: '1.0', label: '1.0'}, + status: 'Final', + viewableVersion: [{id: '1.0', label: '1.0'}], + finalVersions: [{id: '1.0', label: '1.0'}] + }); + +export const LicenseModelOverviewFactory = new Factory() +.attrs({ + licenseModelEditor: { + data: { + ...Factory.attributes('LicenseModelBaseFactory'), + id: () => Math.floor(Math.random() * (1000 - 1) + 1), + ...VersionControllerUtilsFactory.build() + } + }, + entitlementPool: {}, + licenseAgreement: {}, + featureGroup: {}, + licenseKeyGroup: {}, + licenseModelOverview: { + descriptionEditor : { data : { description : undefined}}, + selectedTab: selectedButton.VLM_LIST_VIEW + } +}); diff --git a/openecomp-ui/test-utils/factories/mixins/IdMixin.js b/openecomp-ui/test-utils/factories/mixins/IdMixin.js new file mode 100644 index 0000000000..9fd98a23be --- /dev/null +++ b/openecomp-ui/test-utils/factories/mixins/IdMixin.js @@ -0,0 +1,20 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import randomstring from 'randomstring'; + +export default new Factory() + .attr('id', () => randomstring.generate(33)); diff --git a/openecomp-ui/test-utils/factories/mixins/RandomNameMixin.js b/openecomp-ui/test-utils/factories/mixins/RandomNameMixin.js new file mode 100644 index 0000000000..3d5588c0d2 --- /dev/null +++ b/openecomp-ui/test-utils/factories/mixins/RandomNameMixin.js @@ -0,0 +1,20 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import randomstring from 'randomstring'; + +export default new Factory() + .attr('name', () => randomstring.generate()); diff --git a/openecomp-ui/test-utils/factories/onboard/OnboardFactories.js b/openecomp-ui/test-utils/factories/onboard/OnboardFactories.js new file mode 100644 index 0000000000..3228694ccd --- /dev/null +++ b/openecomp-ui/test-utils/factories/onboard/OnboardFactories.js @@ -0,0 +1,23 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import {storeCreator} from 'sdc-app/AppStore.js'; + +const store = storeCreator(); +const defaultStore = store.getState(); + +export const OnboardStoreFactory = new Factory() + .attrs(defaultStore.onboard); diff --git a/openecomp-ui/test-utils/factories/onboard/OnboardingCatalogFactories.js b/openecomp-ui/test-utils/factories/onboard/OnboardingCatalogFactories.js new file mode 100644 index 0000000000..ff926acdf5 --- /dev/null +++ b/openecomp-ui/test-utils/factories/onboard/OnboardingCatalogFactories.js @@ -0,0 +1,26 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import {storeCreator} from 'sdc-app/AppStore.js'; + +const store = storeCreator(); +const defaultStore = store.getState(); + +export const OnboardingCatalogStoreFactory = new Factory() + .attrs(defaultStore.onboard.onboardingCatalog); + +export const defaultStoreFactory = new Factory() + .attrs(defaultStore); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js new file mode 100644 index 0000000000..eb010da790 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js @@ -0,0 +1,106 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import randomstring from 'randomstring'; + +export const VSPAttachmentsErrorFactory = new Factory() + .attrs({ + level: 'WARNING' + }) + .sequence('message', index => `error no. ${index}`); + +export const VSPHeatFactory = new Factory() + .attrs({ + fileName: () => `${randomstring.generate()}.yaml`, + env: { + fileName: () => `${randomstring.generate()}.env` + }, + errors: Factory.buildList(VSPAttachmentsErrorFactory) + }); + +export const VSPAttachmentTreeNodeFactory = new Factory() + .attrs({ + name: 'HEAT', + type: 'heat' + }); + +export const VSPAttachmentTreeNodeWithChildrenFactory = new Factory() + .extend(VSPAttachmentTreeNodeFactory) + .attrs({ + expanded: true, + children: [] + }); + +export const VSPAttachmentDetailedError = new Factory() + .attrs({ + level: 'WARNING', + errorMessage: 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', + name: () => `${randomstring.generate()}.yaml`, + hasParent: false, + parentName: 'HEAT', + type: 'heat' + }); + +export const HeatSetupModuleBase = new Factory() + .option('name', 0) + .attr('name', ['name'], (name) => { + return name ? randomstring.generate(5) : ''; + }) + .attrs({ + isBase: false, + yaml: () => {return 'yaml_' + randomstring.generate(5) + '.yaml';}, + env: () => {return 'env_' + randomstring.generate(5) + '.env';}, + vol: () => {return 'vol_' + randomstring.generate(5) + '.vol';}, + volEnv: () => {return 'volEnv_' + randomstring.generate(5) + '.env';} + }); + +export const heatSetupManifest = new Factory() + .attrs({ + modules: [ + { + name: 'BASE_sdjflsjldfsd', + isBase: true, + yaml: 'yaml_filename9.yaml', + env: 'env_filename8.env', + vol: 'vol_filename5.vol', + volEnv: 'vol_env_filename1.8.vol', + + }, + { + name: 'MODULE_asdkjfhkajsf', + isBase: false, + yaml: 'yaml_filename.yaml', + env: 'env_filename.env', + vol: 'vol_filename.vol', + volEnv: 'vol_env_filename.vol', + + } + ], + unassigned: [ + 'hot-nimbus-oam-volumes_v1.0.env', + 'hot-nimbus-oam_v1.0.env', + 'hot-nimbus-oam-volumes_v1.1.env', + 'hot-nimbus-oam-volumes_v2.0.env', + 'vol_filename2.vol', + 'hot-nimbus-oam-volumes_v4.0.env', + 'hot-nimbus-oam-volumes_v5.0.env', + 'hot-nimbus-oam_v6.0.env', + 'hot-nimbus-oam-volumes_v7.0.env', + 'vol_filename1.vol' + ], + artifacts: ['hot-nimbus-oam_v3.0.env'], + nested: ['nested-ppd_v1.1.yaml', 'nested-ppd_v1.0.yaml', 'nested-ppd_v8.0.yaml'] + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js new file mode 100644 index 0000000000..58e5db7a7d --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js @@ -0,0 +1,35 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; + +export default new Factory() + .attrs({ + 'vmSizing':{ + 'numOfCPUs': 3, + 'fileSystemSizeGB': 888 + }, + 'numOfVMs':{ + 'minimum':2 + } + }); + + +export const VSPComponentsComputeDataMapFactory = new Factory() + .attrs({ + 'vmSizing/numOfCPUs' : 3, + 'vmSizing/fileSystemSizeGB': 888, + 'numOfVMs/minimum':2 + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js new file mode 100644 index 0000000000..a98249bf14 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js @@ -0,0 +1,34 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import randomstring from 'randomstring'; + +export const VSPComponentsFactory = new Factory() + .option('componentName', 'comp') + .option('componentType', 'server') + .attr('displayName', ['componentName', 'componentType'], (componentName, componentType) => `${componentName}_${componentType}`) + .attr('name', ['displayName'], displayName => `com.ecomp.d2.resource.vfc.nodes.heat.${displayName}`) + .attr('id', () => randomstring.generate()) + .attr('description', 'description'); + +export const VSPComponentsGeneralFactory = new Factory() + .attrs({ + hypervisor: { + containerFeatureDescription: 'aaaUpdated', + drivers: 'bbbUpdated', + hypervisor: 'cccUpdated' + } + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js new file mode 100644 index 0000000000..6bfa091fd3 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js @@ -0,0 +1,32 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import randomstring from 'randomstring'; + +export const VSPComponentsMonitoringRestFactory = new Factory() + .option('snmpTrapFlag', false) + .option('snmpPollFlag', false) + .attr('snmpTrap', ['snmpTrapFlag'], snmpTrapFlag => snmpTrapFlag ? randomstring.generate() : undefined) + .attr('snmpPoll', ['snmpPollFlag'], snmpPollFlag => snmpPollFlag ? randomstring.generate() : undefined); + +export const VSPComponentsMonitoringViewFactory = new Factory() + .extend(VSPComponentsMonitoringRestFactory) + .after(monitoring => { + monitoring['trapFilename'] = monitoring['snmpTrap']; + monitoring['pollFilename'] = monitoring['snmpPoll']; + delete monitoring['snmpTrap']; + delete monitoring['snmpPoll']; + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js new file mode 100644 index 0000000000..f08d282131 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js @@ -0,0 +1,260 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import randomstring from 'randomstring'; +import IdMixin from 'test-utils/factories/mixins/IdMixin.js'; + +export const VSPComponentsNicFactory = new Factory() + .attrs({ + name: () => randomstring.generate(), + description: () => randomstring.generate(), + networkId: 'network', + }) + .attr('networkName', ['name'], name => `n${name}`); + +export const VSPComponentsNicWithIdFactory = new Factory() + .extend(VSPComponentsNicFactory) + .extend(IdMixin); + +export const VSPComponentsNetworkFactory = new Factory() + .attrs({ + nicEditor: {}, + nicList: [] + }); + +export const VSPComponentsNetworkQDataFactory = new Factory() + .attrs({ + protocols: { + protocolWithHighestTrafficProfile: 'UDP', + protocols: ['UDP'] + }, + ipConfiguration: { + ipv4Required: true + } + }); + +export const VSPComponentsNetworkDataMapFactory = new Factory() + .attrs({ + 'protocols/protocolWithHighestTrafficProfile' : 'UDP', + 'protocols/protocols' : ['UDP'], + 'ipConfiguration/ipv4Required' : true + }); + +export const VSPComponentsNicFactoryGenericFieldInfo = new Factory() + .attrs({ + 'description' : { + isValid: true, + errorText: '', + validations: [] + }, + 'name' : { + isValid: true, + errorText: '', + validations: [] + } + }); + +export const VSPComponentsNicFactoryQGenericFieldInfo = new Factory() + .attrs({ + 'protocols/protocols': { + isValid: true, + errorText: '', + 'enum': [ + { + 'enum': 'TCP', + title: 'TCP' + }, + { + 'enum': 'UDP', + title: 'UDP' + }, + { + 'enum': 'SCTP', + title: 'SCTP' + }, + { + 'enum': 'IPsec', + title: 'IPsec' + } + ], + items: { + type: 'string', + 'enum': [ + '', + 'TCP', + 'UDP', + 'SCTP', + 'IPsec' + ], + 'default': '' + }, + minItems: 1, + validations: [] + }, + 'protocols/protocolWithHighestTrafficProfile': { + isValid: true, + errorText: '', + validations: [] + }, + 'ipConfiguration/ipv4Required': { + isValid: true, + errorText: '', + type: 'boolean', + 'default': true, + validations: [] + }, + 'ipConfiguration/ipv6Required': { + isValid: true, + errorText: '', + type: 'boolean', + 'default': false, + validations: [] + }, + 'network/networkDescription': { + isValid: true, + errorText: '', + type: 'string', + validations: [ + { + type: 'pattern', + data: '[A-Za-z]+' + }, + { + type: 'maxLength', + data: 300 + } + ] + }, + 'sizing/describeQualityOfService': { + isValid: true, + errorText: '', + type: 'string', + validations: [] + }, + 'sizing/inflowTrafficPerSecond/packets/peak': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/inflowTrafficPerSecond/packets/avg': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/inflowTrafficPerSecond/bytes/peak': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/inflowTrafficPerSecond/bytes/avg': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/outflowTrafficPerSecond/packets/peak': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/outflowTrafficPerSecond/packets/avg': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/outflowTrafficPerSecond/bytes/peak': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/outflowTrafficPerSecond/bytes/avg': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/flowLength/packets/peak': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/flowLength/packets/avg': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/flowLength/bytes/peak': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/flowLength/bytes/avg': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/acceptableJitter/mean': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/acceptableJitter/max': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/acceptableJitter/variable': { + isValid: true, + errorText: '', + type: 'number', + validations: [] + }, + 'sizing/acceptablePacketLoss': { + isValid: true, + errorText: '', + type: 'number', + validations: [ + { + type: 'minimum', + data: 0 + }, + { + type: 'maximum', + data: 100 + } + ] + } + }); + +export const VSPComponentsVersionControllerFactory = new Factory() + .attrs({ + version: { id: '1.1', label: '1.1'}, + viewableVersions: [{id: '1.0', label: '1.0'}, {id: '1.1', label: '1.1'}, {id: '1.2', label: '1.2'}], + status: 'locked', + isCheckedOut: true + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsStorageFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsStorageFactory.js new file mode 100644 index 0000000000..2691da2288 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductComponentsStorageFactory.js @@ -0,0 +1,34 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; + +export default new Factory() + .attrs({ + 'backup':{ + 'backupType':'OnSite', + 'backupSolution':76333 + }, + 'snapshotBackup':{ + 'snapshotFrequency':2 + } + }); + +export const VSPComponentsStorageDataMapFactory = new Factory() + .attrs({ + 'backup/backupType' : 'OnSite', + 'backup/backupSolution' : 76333, + 'snapshotBackup/snapshotFrequency' : 2 + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductCreationFactories.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductCreationFactories.js new file mode 100644 index 0000000000..d8ae58d105 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductCreationFactories.js @@ -0,0 +1,33 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import {CategoryWithSubFactory} from './VSPCategoriesFactory'; +import {FinalizedLicenseModelFactory} from '../licenseModel/LicenseModelFactories'; +import randomstring from 'randomstring'; + +export const SoftwareProductCreationFactory = new Factory() + .attrs({ + name: () => randomstring.generate(), + description: () => randomstring.generate(), + vendorId: () => FinalizedLicenseModelFactory.build().id, + subCategory: () => CategoryWithSubFactory.build({}, {quantity: 3}).subcategories[0], + }); + +export const SoftwareProductCreationFactoryWithSelectedVendor = new Factory() + .extend(SoftwareProductCreationFactory) + .attrs({ + selectedVendorId: FinalizedLicenseModelFactory.build().id, + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductDependenciesFactories.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductDependenciesFactories.js new file mode 100644 index 0000000000..6521c58a35 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductDependenciesFactories.js @@ -0,0 +1,34 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 { Factory } from 'rosie'; +import IdMixin from 'test-utils/factories/mixins/IdMixin.js'; +import randomstring from 'randomstring'; +import {relationTypes} from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesConstants.js'; + +const SoftwareProductDependenciesBaseFactory = new Factory() + .attrs({ sourceId: () => randomstring.generate(), + targetId: () => randomstring.generate(), + relationType: relationTypes.DEPENDS_ON + }); + +export const SoftwareProductDependenciesResponseFactory = new Factory() + .extend(SoftwareProductDependenciesBaseFactory); + +export const SoftwareProductDependenciesStoreFactory = new Factory() +.extend(SoftwareProductDependenciesBaseFactory) +.extend(IdMixin) +.attrs({ hasCycle: false }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js new file mode 100644 index 0000000000..5c5936155e --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js @@ -0,0 +1,63 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import IdMixin from 'test-utils/factories/mixins/IdMixin.js'; +import randomstring from 'randomstring'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +Factory.define('VSPBaseFactory') + .attrs( + { + name: 'VSP2', + description: 'sdsd', + category: 'resourceNewCategory.application l4+', + subCategory: 'resourceNewCategory.application l4+.media servers', + vendorName: 'V1 ', + vendorId: () => randomstring.generate(33), + licensingVersion: {id: '1', label: '1'}, + licensingData: {}, + icon: 'icon', + version: {id: '1', label: '1'} + } +); + +Factory.define('LicensingDataMixin') + .attrs({ + licensingData: { + licenseAgreement: () => randomstring.generate(33), + featureGroups: [ + () => randomstring.generate(33) + ] + } + }); + +export const VSPEditorFactory = new Factory() + .extend('VSPBaseFactory') + .extend(VersionControllerUtilsFactory) + .extend(IdMixin); + +export const VSPEditorPostFactory = new Factory() + .extend('VSPBaseFactory'); + +export const VSPEditorFactoryWithLicensingData = new Factory() + .extend('VSPBaseFactory') + .extend(VersionControllerUtilsFactory) + .extend('LicensingDataMixin') + .extend(IdMixin); + +export const VSPEditorPostFactoryWithLicensingData = new Factory() + .extend('VSPBaseFactory') + .extend('LicensingDataMixin'); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductFactory.js new file mode 100644 index 0000000000..86a8276beb --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductFactory.js @@ -0,0 +1,47 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; + +export const SoftwareProductFactory = new Factory() + .attrs({ + softwareProductAttachments: {}, + softwareProductCreation: {}, + softwareProductEditor: {}, + softwareProductProcesses: { + processesList: [], + processesEditor: {}, + processToDelete: false + }, + softwareProductNetworks: { + networksList: [] + }, + softwareProductComponents: { + componentsList: [], + componentEditor: {}, + componentProcesses: { + processesList: [], + processesEditor: {}, + processToDelete: false + }, + network: { + nicList: [], + nicEditor: {} + } + }, + monitoring: {}, + softwareProductCategories: [], + softwareProductQuestionnaire: {} + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js new file mode 100644 index 0000000000..08b4daa973 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js @@ -0,0 +1,25 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import IdMixin from 'test-utils/factories/mixins/IdMixin'; +import RandomNameMixin from 'test-utils/factories/mixins/RandomNameMixin'; + +export default new Factory() + .extend(RandomNameMixin) + .extend(IdMixin) + .attrs({ + dhcp: true + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js new file mode 100644 index 0000000000..26ac49dbe5 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js @@ -0,0 +1,73 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import IdMixin from 'test-utils/factories/mixins/IdMixin.js'; + +Factory.define('VSPProcessBaseFactory') + .attrs({ + name: 'Pr1', + description: 'string', + type: '' + }); + +Factory.define('VSPProcessBaseFactoryWithType') + .attrs({ + name: 'Pr1', + description: 'string', + type: 'Other' + }); + + +Factory.define('VSPProcessBaseFactoryWithNullType') + .attrs({ + name: 'Pr1', + description: 'string', + type: null + }); + +Factory.define('FormDataMixin') + .option('artifactName', 'artifact') + .attr('formData', ['artifactName'], artifactName => ({name: artifactName})); + + +export const VSPProcessPostFactory = new Factory() + .extend('VSPProcessBaseFactory'); + +export const VSPProcessStoreFactory = new Factory() + .extend('VSPProcessBaseFactoryWithNullType') + .extend(IdMixin); + + +export const VSPProcessPostFactoryWithType = new Factory() + .extend('VSPProcessBaseFactoryWithType'); + +export const VSPProcessStoreFactoryWithType = new Factory() + .extend('VSPProcessBaseFactoryWithType') + .extend(IdMixin); + + +export const VSPProcessPostWithFormDataFactory = new Factory() + .extend(VSPProcessPostFactoryWithType) + .extend('FormDataMixin'); + +export const VSPProcessStoreWithFormDataFactory = new Factory() + .extend(VSPProcessStoreFactoryWithType) + .extend('FormDataMixin'); + + +export const VSPProcessStoreWithArtifactNameFactory = new Factory() + .extend(VSPProcessStoreFactoryWithType) + .attr('artifactName', 'artifact'); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js new file mode 100644 index 0000000000..bb640cfd89 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js @@ -0,0 +1,131 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; + +const parsePropertiesForSchema = (obj) => { + let schemaProperties = {}; + + Object.keys(obj).forEach(prop => { + let type = typeof obj[prop]; + if (type === undefined){throw new Error('Schema property cannot be undefined');} + if (type === 'object'){ + if (Array.isArray(obj[prop])) { + schemaProperties[prop] = {type: 'array'}; + } else if (Object.is(obj[prop], null)){ + throw new Error('Schema property cannot be null'); + } else { + schemaProperties[prop] = {properties: parsePropertiesForSchema(obj[prop]), type: 'object'}; + } + } else { + schemaProperties[prop] = {type}; + } + }); + + return schemaProperties; +}; + +export default new Factory() + .after(schema => { + const propertiesForSchema = parsePropertiesForSchema(schema); + for (let attribute in schema) { + delete schema[attribute]; + } + schema.$schema = 'http://json-schema.org/draft-04/schema#'; + schema.type = 'object'; + schema.properties = propertiesForSchema; + }); + + +export const SchemaGenericFieldInfoFactory = new Factory() + .attrs({ + 'general/affinityData': { + 'hasErrors': false, + 'errorText': '', + 'type': 'string', + 'enum': [{'enum': 'Affinity', 'title': 'Affinity'}, { + 'enum': 'Anti Affinity', + 'title': 'Anti Affinity' + }, {'enum': 'None', 'title': 'None'}], + 'default': '', + 'validations': [] + }, + 'general/availability/useAvailabilityZonesForHighAvailability': { + 'hasErrors': false, + 'errorText': '', + 'type': 'boolean', + 'default': false, + 'validations': [] + }, + 'general/regionsData/multiRegion': { + 'hasErrors': false, + 'errorText': '', + 'type': 'boolean', + 'default': false, + 'validations': [] + }, + 'general/regionsData/regions': { + 'hasErrors': false, + 'errorText': '', + 'enum': [{'enum': 'Alphareta', 'title': 'Alphareta'}, { + 'enum': 'Birmingham', + 'title': 'Birmingham' + }, {'enum': 'Dallas', 'title': 'Dallas'}, { + 'enum': 'Fairfield CA', + 'title': 'Fairfield CA' + }, {'enum': 'Hayward CA', 'title': 'Hayward CA'}, {'enum': 'Lisle', 'title': 'Lisle'}, { + 'enum': 'Mission', + 'title': 'Mission' + }, {'enum': 'San Diego', 'title': 'San Diego'}, {'enum': 'Secaucus', 'title': 'Secaucus'}], + 'items': { + 'type': 'string', + 'enum': ['', 'Alphareta', 'Birmingham', 'Dallas', 'Fairfield CA', 'Hayward CA', 'Lisle', 'Mission', 'San Diego', 'Secaucus'], + 'default': '' + }, + 'validations': [] + }, + 'general/storageDataReplication/storageReplicationAcrossRegion': { + 'hasErrors': false, + 'errorText': '', + 'type': 'boolean', + 'default': false, + 'validations': [] + }, + 'general/storageDataReplication/storageReplicationSize': { + 'hasErrors': false, + 'errorText': '', + 'type': 'number', + 'exclusiveMaximum': true, + 'validations': [{'type': 'maximumExclusive', 'data': 100}] + }, + 'general/storageDataReplication/storageReplicationFrequency': { + 'hasErrors': false, + 'errorText': '', + 'type': 'number', + 'validations': [{'type': 'minimum', 'data': 5}] + }, + 'general/storageDataReplication/storageReplicationSource': { + 'hasErrors': false, + 'errorText': '', + 'type': 'string', + 'validations': [{'type': 'maxLength', 'data': 300}] + }, + 'general/storageDataReplication/storageReplicationDestination': { + 'hasErrors': false, + 'errorText': '', + 'type': 'string', + 'validations': [{'type': 'maxLength', 'data': 300}] + } + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/VSPCategoriesFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/VSPCategoriesFactory.js new file mode 100644 index 0000000000..eabd02df7b --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/VSPCategoriesFactory.js @@ -0,0 +1,40 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import randomstring from 'randomstring'; + +Factory.define('baseCategory') + .attrs({ + name: () => randomstring.generate(), + normalizedName: () => randomstring.generate(), + uniqueId: () => randomstring.generate() + }); + +export const CategoryFactory = new Factory() + .extend('baseCategory'); + +export const CategoryWithSubFactory = new Factory() + .extend('baseCategory') + .option('quantity', 0) + .attr('subcategories', ['quantity'], (quantity) => { + var subs = []; + for (let i = 1; i <= quantity; i++) { + subs.push({ + uniqueId: randomstring.generate() + }); + } + return subs; + }); diff --git a/openecomp-ui/test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js new file mode 100644 index 0000000000..8c9640714d --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js @@ -0,0 +1,30 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; +import {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + +export default new Factory() + .attrs({ + version: { id: '1.2', label: '1.2'}, + viewableVersions: [{id: '1.0', label: '1.0'}, {id: '1.1', label: '1.1'}, {id: '1.2', label: '1.2'}], + status: statusEnum.CHECK_OUT_STATUS, + lockingUser: 'current' + }).after(function(inst) { + if (inst.status !== statusEnum.CHECK_OUT_STATUS) { + delete inst.lockingUser; + } + }); + diff --git a/openecomp-ui/test-utils/factories/softwareProduct/VspQdataFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/VspQdataFactory.js new file mode 100644 index 0000000000..66c08dac49 --- /dev/null +++ b/openecomp-ui/test-utils/factories/softwareProduct/VspQdataFactory.js @@ -0,0 +1,55 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {Factory} from 'rosie'; + +export default new Factory() + .attrs({ + 'general': { + 'regionsData': { + 'regions': '', + 'multiRegion': '' + }, + 'storageDataReplication': { + 'storageReplicationAcrossRegion': '', + 'storageReplicationSize': '', + 'storageReplicationFrequency': '', + 'storageReplicationSource': '', + 'storageReplicationDestination': '' + }, + 'availability': { + 'useAvailabilityZonesForHighAvailability': '' + }, + 'affinityData': { + 'affinityGrouping': '', + 'antiAffinityGrouping': '' + } + } + }); + +export const VspDataMapFactory = new Factory() + .attrs({ + 'general/regionsData/regions': '', + 'general/regionsData/multiRegion': '', + 'general/storageDataReplication/storageReplicationAcrossRegion' : '', + 'general/storageDataReplication/storageReplicationSize' : '', + 'general/storageDataReplication/storageReplicationFrequency' : '', + 'general/storageDataReplication/storageReplicationSource' : '', + 'general/storageDataReplication/storageReplicationDestination' : '', + 'general/availability/useAvailabilityZonesForHighAvailability' : '', + 'general/affinityData/affinityGrouping' : '', + 'general/affinityData/antiAffinityGrouping' : '' + }); + diff --git a/openecomp-ui/test-utils/failedTestReport.js b/openecomp-ui/test-utils/failedTestReport.js new file mode 100644 index 0000000000..9520cc9c99 --- /dev/null +++ b/openecomp-ui/test-utils/failedTestReport.js @@ -0,0 +1,34 @@ +var stdin = process.stdin; +var inputJSON = ''; +var startJSON = false; +stdin.resume(); +stdin.setEncoding('utf8'); + +stdin.on('data', function (chunk) { + if (chunk.startsWith('{')) { + startJSON = true; + } + if (startJSON) { + inputJSON += chunk; + } +}); + +stdin.on('end', function () { + let report = JSON.parse(inputJSON); + if (!report.numFailedTestSuites) { + return; + } else { + console.log('--------------------------------'); + console.log('Failure Summary: \n'); + } + report.testResults.forEach((suite) => { + if(suite.status == 'failed') { + console.log('Suite: ' + suite.name); + suite.assertionResults.forEach((test) => { + if (test.status === 'failed') { + console.log('\tTest: ' + test.title); + } + }); + } + }); +}); diff --git a/openecomp-ui/test-utils/fileMock.js b/openecomp-ui/test-utils/fileMock.js new file mode 100644 index 0000000000..84c1da6fdc --- /dev/null +++ b/openecomp-ui/test-utils/fileMock.js @@ -0,0 +1 @@ +module.exports = 'test-file-stub'; \ No newline at end of file diff --git a/openecomp-ui/test-utils/styleMock.js b/openecomp-ui/test-utils/styleMock.js new file mode 100644 index 0000000000..a099545376 --- /dev/null +++ b/openecomp-ui/test-utils/styleMock.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file diff --git a/openecomp-ui/test-utils/test-env-setup.js b/openecomp-ui/test-utils/test-env-setup.js new file mode 100644 index 0000000000..a2ed491319 --- /dev/null +++ b/openecomp-ui/test-utils/test-env-setup.js @@ -0,0 +1,16 @@ +var localStorageMock = (function() { + var store = {}; + return { + getItem: function(key) { + return store[key]; + }, + setItem: function(key, value) { + store[key] = value.toString(); + }, + clear: function() { + store = {}; + } + }; +})(); + +Object.defineProperty(window, 'localStorage', { value: localStorageMock }); \ No newline at end of file diff --git a/openecomp-ui/test-utils/test-setup.js b/openecomp-ui/test-utils/test-setup.js new file mode 100644 index 0000000000..ec3ca72fc5 --- /dev/null +++ b/openecomp-ui/test-utils/test-setup.js @@ -0,0 +1,2 @@ +import mockRest from 'test-utils/MockRest.js'; +mockRest.resetQueue(); diff --git a/openecomp-ui/test/flows/FlowsListEditor.test.js b/openecomp-ui/test/flows/FlowsListEditor.test.js index 534253567e..007b137ab0 100644 --- a/openecomp-ui/test/flows/FlowsListEditor.test.js +++ b/openecomp-ui/test/flows/FlowsListEditor.test.js @@ -1,33 +1,30 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/flows/FlowsListEditor.js'; import FlowsListEditorView from 'sdc-app/flows/FlowsListEditorView.jsx'; +import {FlowUpdateRequestFactory, FlowBasicFactory} from 'test-utils/factories/flows/FlowsFactories.js'; + describe('Flows List Editor Mapper and View Classes: ', function () { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('mapStateToProps mapper - without flowList', () => { @@ -37,242 +34,106 @@ describe('Flows List Editor Mapper and View Classes: ', function () { shouldShowWorkflowsEditor: undefined }; let results = mapStateToProps({flows}); - expect(results.flowList).toExist(); + expect(results.flowList).toBeTruthy(); expect(results.flowList.length).toEqual(0); expect(results.shouldShowWorkflowsEditor).toBe(true); }); it('mapStateToProps mapper - populated flowList', () => { - let artifactName = 'test1', description = 'desc'; let flows = { - flowList: [{artifactName, description}], + flowList: FlowBasicFactory.buildList(1), isDisplayModal: true, isModalInEditMode: false, shouldShowWorkflowsEditor: false }; let results = mapStateToProps({flows}); - expect(results.flowList).toExist(); + expect(results.flowList).toBeTruthy(); expect(results.flowList.length).toEqual(1); expect(results.shouldShowWorkflowsEditor).toBe(false); }); it('mapStateToProps mapper - populated flowList and currentFlow is in readonly', () => { - let artifactName = 'test1', description = 'desc'; - let currentFlow = {artifactName, description, readonly: true}; + let currentFlow = FlowBasicFactory.build(); + currentFlow.readonly = true; let flows = { flowList: [currentFlow], - currentFlow, + data: currentFlow, isDisplayModal: true, isModalInEditMode: false, shouldShowWorkflowsEditor: false }; let results = mapStateToProps({flows}); - expect(results.currentFlow).toExist(); + expect(results.currentFlow).toBeTruthy(); expect(results.isCheckedOut).toEqual(false); }); it('mapStateToProps mapper - populated flowList and currentFlow is in not readonly', () => { - let artifactName = 'test1', description = 'desc'; - let currentFlow = {artifactName, description, readonly: false}; + let currentFlow = FlowBasicFactory.build(); + currentFlow.readonly = false; let flows = { flowList: [currentFlow], - currentFlow, + data: currentFlow, isDisplayModal: true, isModalInEditMode: false, shouldShowWorkflowsEditor: false }; let results = mapStateToProps({flows}); - expect(results.currentFlow).toExist(); + expect(results.currentFlow).toBeTruthy(); + expect(results.isCheckedOut).toEqual(true); + }); + + it('mapStateToProps mapper - populated flowList and service is in readonly', () => { + let currentFlow = FlowBasicFactory.build(); + let flows = { + flowList: [currentFlow], + data: currentFlow, + isDisplayModal: true, + isModalInEditMode: false, + shouldShowWorkflowsEditor: false, + readonly: true + }; + let results = mapStateToProps({flows}); + expect(results.currentFlow).toBeTruthy(); + expect(results.isCheckedOut).toEqual(false); + }); + + it('mapStateToProps mapper - populated flowList and service is in not readonly', () => { + let currentFlow = FlowBasicFactory.build(); + let flows = { + flowList: [currentFlow], + data: currentFlow, + isDisplayModal: true, + isModalInEditMode: false, + shouldShowWorkflowsEditor: false, + readonly: false + }; + let results = mapStateToProps({flows}); + expect(results.currentFlow).toBeTruthy(); expect(results.isCheckedOut).toEqual(true); }); it('basic view component run with empty flowList and should show the list', () => { let renderer = TestUtils.createRenderer(); - let artifactName = 'test1', description = 'desc'; - let currentFlow = {artifactName, description, readonly: false}; + let currentFlow = FlowBasicFactory.build(); renderer.render(); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('basic view component run with empty flowList and should show the diagram', () => { - const flow = { - 'artifactType': 'WORKFLOW', - 'participants': [ - { - 'id': '1', - 'name': 'Customer' - }, - { - 'id': '2', - 'name': 'CCD' - }, - { - 'id': '3', - 'name': 'Infrastructure' - }, - { - 'id': '4', - 'name': 'MSO' - }, - { - 'id': '5', - 'name': 'SDN-C' - }, - { - 'id': '6', - 'name': 'A&AI' - }, - { - 'id': '7', - 'name': 'APP-C' - }, - { - 'id': '8', - 'name': 'Cloud' - }, - { - 'id': '9', - 'name': 'DCAE' - }, - { - 'id': '10', - 'name': 'ALTS' - }, - { - 'id': '11', - 'name': 'VF' - } - ], - 'serviceID': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b', - 'artifactDisplayName': 'zizizi', - 'artifactGroupType': 'INFORMATIONAL', - 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - 'artifactName': 'zizizi', - 'artifactLabel': 'zizizi', - 'artifactUUID': '0295a7cc-8c02-4105-9d7e-c30ce67ecd07', - 'artifactVersion': '1', - 'creationDate': 1470144601623, - 'lastUpdateDate': 1470144601623, - 'description': 'aslkjdfl asfdasdf', - 'mandatory': false, - 'timeout': 0, - 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - 'artifactChecksum': 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=', - 'heatParameters': [], - 'sequenceDiagramModel': { - 'diagram': { - 'metadata': { - 'id': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - 'name': 'zizizi', - 'ref': 'BLANK' - }, - 'lifelines': [ - { - 'id': '1', - 'name': 'Customer', - 'index': 1, - 'x': 175 - }, - { - 'id': '2', - 'name': 'CCD', - 'index': 2, - 'x': 575 - }, - { - 'id': '3', - 'name': 'Infrastructure', - 'index': 3, - 'x': 975 - }, - { - 'id': '4', - 'name': 'MSO', - 'index': 4, - 'x': 1375 - }, - { - 'id': '5', - 'name': 'SDN-C', - 'index': 5, - 'x': 1775 - }, - { - 'id': '6', - 'name': 'A&AI', - 'index': 6, - 'x': 2175 - }, - { - 'id': '7', - 'name': 'APP-C', - 'index': 7, - 'x': 2575 - }, - { - 'id': '8', - 'name': 'Cloud', - 'index': 8, - 'x': 2975 - }, - { - 'id': '9', - 'name': 'DCAE', - 'index': 9, - 'x': 3375 - }, - { - 'id': '10', - 'name': 'ALTS', - 'index': 10, - 'x': 3775 - }, - { - 'id': '11', - 'name': 'VF', - 'index': 11, - 'x': 4175 - } - ], - 'steps': [ - { - 'message': { - 'id': '9377-5036-c011-cb95-3a8b-82c6-bbb5-bc84', - 'name': '[Unnamed Message]', - 'type': 'request', - 'from': '1', - 'to': '2', - 'index': 1 - } - }, - { - 'message': { - 'id': '64c4-4fd1-b1da-4355-a060-6e48-ee47-c85c', - 'name': '[Unnamed Message]', - 'type': 'request', - 'from': '1', - 'to': '2', - 'index': 2 - } - } - ] - } - } - }; + const flow = FlowUpdateRequestFactory.build(); let renderer = TestUtils.createRenderer(); renderer.render(); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('basic view component run with empty flowList and should show popup modal', () => { let renderer = TestUtils.createRenderer(); - let artifactName = 'test1', description = 'desc'; - let currentFlow = {artifactName, description, readonly: false}; + let currentFlow = FlowBasicFactory.build(); renderer.render(); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); diff --git a/openecomp-ui/test/flows/flowsEditorModal.test.js b/openecomp-ui/test/flows/flowsEditorModal.test.js index d8da97af4e..8371432032 100644 --- a/openecomp-ui/test/flows/flowsEditorModal.test.js +++ b/openecomp-ui/test/flows/flowsEditorModal.test.js @@ -1,33 +1,30 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/flows/FlowsEditorModal.js'; import FlowsEditorModalView from 'sdc-app/flows/FlowsEditorModalView.jsx'; +import {FlowBasicFactory} from 'test-utils/factories/flows/FlowsFactories.js'; + describe('Flows Editor Modal Mapper and View Classes: ', function () { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('mapStateToProps mapper - without currentFlow', () => { @@ -36,22 +33,22 @@ describe('Flows Editor Modal Mapper and View Classes: ', function () { diagramType: 'SOME_TYPE' }; var results = mapStateToProps({flows}); - expect(results.currentFlow).toExist(); + expect(results.currentFlow).toBeTruthy(); expect(results.currentFlow.artifactName).toBe(''); expect(results.currentFlow.description).toBe(''); }); it('mapStateToProps mapper - populated currentFlow', () => { - let artifactName = 'test1', description = 'desc'; + const currentFlow = FlowBasicFactory.build({artifactType: 'WORKFLOW'}); var flows = { - currentFlow: {artifactName, description}, + data: currentFlow, serviceID: '123', - diagramType: 'SOME_TYPE' + diagramType: 'WORKFLOW' }; var results = mapStateToProps({flows}); - expect(results.currentFlow).toExist(); - expect(results.currentFlow.artifactName).toBe(artifactName); - expect(results.currentFlow.description).toBe(description); + expect(results.currentFlow).toBeTruthy(); + expect(results.currentFlow.artifactName).toBe(currentFlow.artifactName); + expect(results.currentFlow.description).toBe(currentFlow.description); expect(results.currentFlow.serviceID).toBe(flows.serviceID); expect(results.currentFlow.artifactType).toBe(flows.diagramType); }); @@ -62,9 +59,9 @@ describe('Flows Editor Modal Mapper and View Classes: ', function () { {}} onDataChanged={()=>{}} - currentFlow={{artifactName: '', description: ''}}/>); + currentFlow={FlowBasicFactory.build({artifactName: '', description: ''})}/>); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('modal view component run with data changed handler', done => { @@ -73,10 +70,11 @@ describe('Flows Editor Modal Mapper and View Classes: ', function () { {}} onDataChanged={handler} - currentFlow={{artifactName: '', description: ''}}/>); + currentFlow={FlowBasicFactory.build({artifactName: '', description: ''})} + genericFieldInfo={{artifactName : {isValid: true, errorText: ''}, description: {isValid: true, errorText: ''}}} />); let result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'input'); - expect(result).toExist(); - expect(result.length).toExist(); + expect(result).toBeTruthy(); + expect(result.length).toBeTruthy(); TestUtils.Simulate.change(result[0]); }); diff --git a/openecomp-ui/test/flows/test.js b/openecomp-ui/test/flows/test.js index 4c5ab78640..6e02e54816 100644 --- a/openecomp-ui/test/flows/test.js +++ b/openecomp-ui/test/flows/test.js @@ -1,30 +1,36 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import store from 'sdc-app/AppStore.js'; import FlowsActions from 'sdc-app/flows/FlowsActions.js'; import {enums} from 'sdc-app/flows/FlowsConstants.js'; +import { + FlowCreateFactory, + FlowPostRequestFactory, + FlowPostResponseFactory, + FlowFetchRequestFactory, + FlowFetchResponseFactory, + FlowDeleteRequestFactory, + FlowUpdateRequestFactory } from 'test-utils/factories/flows/FlowsFactories.js'; + +import {buildFromExistingObject} from 'test-utils/Util.js'; + const NEW_FLOW = true; let assertFlowDataAfterCreateFetchAndUpdate = (data) => { @@ -33,13 +39,13 @@ let assertFlowDataAfterCreateFetchAndUpdate = (data) => { expect(diagramType).toBe(data.artifactType); let uniqueId = data.uniqueId || `${data.serviceID}.${data.artifactName}`; let index = flowList.findIndex(flow => flow.uniqueId === uniqueId); - expect(index).toNotBe(-1); + expect(index).not.toBe(-1); }; describe('Workflows and Management Flows Module Tests:', function () { - it('empty artifact should open flow creation modal', done => { + it('empty artifact should open flow creation modal', () => { const artifacts = {}; @@ -51,96 +57,30 @@ describe('Workflows and Management Flows Module Tests:', function () { participants: [], serviceID: '1234' }); - setTimeout(() => { - let state = store.getState(); - expect(state.flows.isDisplayModal).toBe(true); - expect(state.flows.isModalInEditMode).toBe(false); - done(); - }, 50); + let state = store.getState(); + expect(state.flows.isDisplayModal).toBe(true); + expect(state.flows.isModalInEditMode).toBe(false); }); - it('Close flow details editor modal', done => { + it('Close flow details editor modal', () => { deepFreeze(store.getState()); FlowsActions.closeFlowDetailsEditor(store.dispatch); - setTimeout(() => { - let state = store.getState(); - expect(state.flows.isDisplayModal).toBe(false); - expect(state.flows.isModalInEditMode).toBe(false); - done(); - }, 50); + let state = store.getState(); + expect(state.flows.isDisplayModal).toBe(false); + expect(state.flows.isModalInEditMode).toBe(false); }); - it('Get Flows List from loaded artifact', done => { + it('Get Flows List from loaded artifact', () => { deepFreeze(store.getState()); const artifacts = { - 'test1': { - 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test1', - 'artifactType': 'NETWORK_CALL_FLOW', - 'artifactName': 'test1', - 'artifactChecksum': 'MzYxZGIyNjlkNjRmMTM4ZWMxM2FjNDUyNDQwMTI3NzM=', - 'attUidLastUpdater': 'cs0008', - 'updaterFullName': 'Carlos Santana', - 'creationDate': 1468164899724, - 'lastUpdateDate': 1468164899724, - 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test1', - 'artifactLabel': 'test1', - 'artifactCreator': 'cs0008', - 'description': 'www', - 'mandatory': false, - 'artifactDisplayName': 'test1', - 'serviceApi': false, - 'artifactGroupType': 'INFORMATIONAL', - 'timeout': 0, - 'artifactVersion': '1', - 'artifactUUID': '28d4cb95-bb46-4666-b858-e333671e6444', - 'payloadUpdateDate': 1468164900232 - }, - 'kukuriku': { - 'uniqueId': '0280b577-2c7b-426e-b7a2-f0dc16508c37.kukuriku', + 'test1': FlowPostResponseFactory.build({artifactName: 'test1'}), + 'kukuriku': FlowPostResponseFactory.build({ 'artifactType': 'PUPPET', - 'artifactName': 'fuel.JPG', - 'artifactChecksum': 'OWEyYTVjMWFiNWQ4ZDIwZDUxYTE3Y2EzZmI3YTYyMjA=', - 'attUidLastUpdater': 'cs0008', - 'updaterFullName': 'Carlos Santana', - 'creationDate': 1467877631512, - 'lastUpdateDate': 1467877631512, - 'esId': '0280b577-2c7b-426e-b7a2-f0dc16508c37.kukuriku', - 'artifactLabel': 'kukuriku', - 'artifactCreator': 'cs0008', - 'description': 'asdfasdf', - 'mandatory': false, - 'artifactDisplayName': 'kukuriku', - 'serviceApi': false, - 'artifactGroupType': 'INFORMATIONAL', - 'timeout': 0, - 'artifactVersion': '1', - 'artifactUUID': 'c1e98336-03f4-4b2a-b6a5-08eca44fe3c4', - 'payloadUpdateDate': 1467877632722 - }, - 'test3': { - 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test3', - 'artifactType': 'NETWORK_CALL_FLOW', - 'artifactName': 'test3', - 'artifactChecksum': 'ZmJkZGU1M2M2ZWUxZTdmNGU5NTNiNTdiYTAzMmM1YzU=', - 'attUidLastUpdater': 'cs0008', - 'updaterFullName': 'Carlos Santana', - 'creationDate': 1468165068570, - 'lastUpdateDate': 1468165128827, - 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test3', - 'artifactLabel': 'test3', - 'artifactCreator': 'cs0008', - 'description': '333', - 'mandatory': false, - 'artifactDisplayName': 'test3', - 'serviceApi': false, - 'artifactGroupType': 'INFORMATIONAL', - 'timeout': 0, - 'artifactVersion': '2', - 'artifactUUID': '0988027c-d19c-43db-8315-2c68fc773775', - 'payloadUpdateDate': 1468165129335 - } + 'artifactName': 'kukuriku', + }), + 'test3': FlowPostResponseFactory.build({artifactName: 'test3'}) }; const artifactsArray = Object.keys(artifacts).map(artifact => artifact); @@ -157,41 +97,25 @@ describe('Workflows and Management Flows Module Tests:', function () { }; FlowsActions.fetchFlowArtifacts(store.dispatch, actionData); - setTimeout(() => { - let state = store.getState(); - expect(state.flows.isDisplayModal).toBe(false); - expect(state.flows.isModalInEditMode).toBe(false); - expect(state.flows.flowList.length).toEqual(artifactsArray.length); - expect(state.flows.flowParticipants).toEqual(actionData.participants); - expect(state.flows.serviceID).toBe(actionData.serviceID); - expect(state.flows.diagramType).toBe(actionData.diagramType); - done(); - }, 50); + let state = store.getState(); + expect(state.flows.isDisplayModal).toBe(false); + expect(state.flows.isModalInEditMode).toBe(false); + expect(state.flows.flowList.length).toEqual(artifactsArray.length); + expect(state.flows.flowParticipants).toEqual(actionData.participants); + expect(state.flows.serviceID).toBe(actionData.serviceID); + expect(state.flows.diagramType).toBe(actionData.diagramType); }); - it('Add New Flow', done => { + it('Add New Flow', () => { deepFreeze(store.getState()); - const flowCreateData = deepFreeze({ - artifactName: 'zizizi', - artifactType: 'WORKFLOW', - description: 'aslkjdfl asfdasdf', - serviceID: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b', - }); - + const flowCreateData = FlowCreateFactory.build(); + let expectedDataToBeSentInTheRequest = buildFromExistingObject(FlowPostRequestFactory, flowCreateData); - let expectedDataToBeSentInTheRequest = { - artifactGroupType: 'INFORMATIONAL', - artifactLabel: 'zizizi', - artifactName: 'zizizi', - artifactType: 'WORKFLOW', - description: 'aslkjdfl asfdasdf', - payloadData: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ==' - }; - mockRest.addHandler('create', ({data, baseUrl, options}) => { + mockRest.addHandler('post', ({data, baseUrl, options}) => { expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowCreateData.serviceID}/artifacts/`); expect(data.artifactLabel).toBe(expectedDataToBeSentInTheRequest.artifactLabel); expect(data.artifactName).toBe(expectedDataToBeSentInTheRequest.artifactName); @@ -199,299 +123,65 @@ describe('Workflows and Management Flows Module Tests:', function () { expect(data.description).toBe(expectedDataToBeSentInTheRequest.description); expect(data.payloadData).toBe(expectedDataToBeSentInTheRequest.payloadData); expect(options.md5).toBe(true); - return { - artifactChecksum: 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=', - artifactCreator: 'cs0008', - artifactDisplayName: 'zizizi', - artifactGroupType: 'INFORMATIONAL', - artifactLabel: 'zizizi', - artifactName: 'zizizi', - artifactType: 'WORKFLOW', - artifactUUID: '0295a7cc-8c02-4105-9d7e-c30ce67ecd07', - artifactVersion: '1', - attUidLastUpdater: 'cs0008', - creationDate: 1470144601623, - description: 'aslkjdfl asfdasdf', - esId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - lastUpdateDate: 1470144601623, - mandatory: false, - payloadUpdateDate: 1470144602131, - serviceApi: false, - timeout: 0, - uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - updaterFullName: 'Carlos Santana', - }; + return buildFromExistingObject(FlowPostResponseFactory, expectedDataToBeSentInTheRequest); }); - FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowCreateData}, NEW_FLOW); - - setTimeout(() => { + return FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowCreateData}, NEW_FLOW).then(() => { assertFlowDataAfterCreateFetchAndUpdate(flowCreateData); - done(); - }, 50); + }); + + }); - it('Fetch Flow', done => { + it('Fetch Flow', () => { deepFreeze(store.getState()); - const flowFetchData = { - artifactName: 'zizizi', - artifactType: 'WORKFLOW', - description: 'aslkjdfl asfdasdf', - serviceID: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b', - uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - participants: [] - }; + const flowFetchData = FlowFetchRequestFactory.build(); mockRest.addHandler('fetch', ({baseUrl}) => { //sdc1/feProxy/rest/v1/catalog/services/338d75f0-aec8-4eb4-89c9-8733fcd9bf3b/artifacts/338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowFetchData.serviceID}/artifacts/${flowFetchData.uniqueId}`); - return { - artifactName: 'zizizi', - base64Contents: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ==' - }; + return buildFromExistingObject(FlowFetchResponseFactory, flowFetchData); }); - FlowsActions.fetchArtifact(store.dispatch, {flow: flowFetchData}); - - setTimeout(() => { + return FlowsActions.fetchArtifact(store.dispatch, {flow: flowFetchData}).then(() => { assertFlowDataAfterCreateFetchAndUpdate(flowFetchData); - done(); - }, 50); + }); }); - it('Update Existing Flow', done => { + it('Update Existing Flow', () => { deepFreeze(store.getState()); + const flowUpdateData = FlowUpdateRequestFactory.build(); - const flowUpdateData = { - 'artifactType': 'WORKFLOW', - 'participants': [ - { - 'id': '1', - 'name': 'Customer' - }, - { - 'id': '2', - 'name': 'CCD' - }, - { - 'id': '3', - 'name': 'Infrastructure' - }, - { - 'id': '4', - 'name': 'MSO' - }, - { - 'id': '5', - 'name': 'SDN-C' - }, - { - 'id': '6', - 'name': 'A&AI' - }, - { - 'id': '7', - 'name': 'APP-C' - }, - { - 'id': '8', - 'name': 'Cloud' - }, - { - 'id': '9', - 'name': 'DCAE' - }, - { - 'id': '10', - 'name': 'ALTS' - }, - { - 'id': '11', - 'name': 'VF' - } - ], - 'serviceID': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b', - 'artifactDisplayName': 'zizizi', - 'artifactGroupType': 'INFORMATIONAL', - 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - 'artifactName': 'zizizi', - 'artifactLabel': 'zizizi', - 'artifactUUID': '0295a7cc-8c02-4105-9d7e-c30ce67ecd07', - 'artifactVersion': '1', - 'creationDate': 1470144601623, - 'lastUpdateDate': 1470144601623, - 'description': 'aslkjdfl asfdasdf', - 'mandatory': false, - 'timeout': 0, - 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - 'artifactChecksum': 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=', - 'heatParameters': [], - 'sequenceDiagramModel': { - 'diagram': { - 'metadata': { - 'id': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - 'name': 'zizizi', - 'ref': 'BLANK' - }, - 'lifelines': [ - { - 'id': '1', - 'name': 'Customer', - 'index': 1, - 'x': 175 - }, - { - 'id': '2', - 'name': 'CCD', - 'index': 2, - 'x': 575 - }, - { - 'id': '3', - 'name': 'Infrastructure', - 'index': 3, - 'x': 975 - }, - { - 'id': '4', - 'name': 'MSO', - 'index': 4, - 'x': 1375 - }, - { - 'id': '5', - 'name': 'SDN-C', - 'index': 5, - 'x': 1775 - }, - { - 'id': '6', - 'name': 'A&AI', - 'index': 6, - 'x': 2175 - }, - { - 'id': '7', - 'name': 'APP-C', - 'index': 7, - 'x': 2575 - }, - { - 'id': '8', - 'name': 'Cloud', - 'index': 8, - 'x': 2975 - }, - { - 'id': '9', - 'name': 'DCAE', - 'index': 9, - 'x': 3375 - }, - { - 'id': '10', - 'name': 'ALTS', - 'index': 10, - 'x': 3775 - }, - { - 'id': '11', - 'name': 'VF', - 'index': 11, - 'x': 4175 - } - ], - 'steps': [ - { - 'message': { - 'id': '9377-5036-c011-cb95-3a8b-82c6-bbb5-bc84', - 'name': '[Unnamed Message]', - 'type': 'request', - 'from': '1', - 'to': '2', - 'index': 1 - } - }, - { - 'message': { - 'id': '64c4-4fd1-b1da-4355-a060-6e48-ee47-c85c', - 'name': '[Unnamed Message]', - 'type': 'request', - 'from': '1', - 'to': '2', - 'index': 2 - } - } - ] - } - } - }; - - mockRest.addHandler('create', ({baseUrl}) => { + mockRest.addHandler('post', ({baseUrl}) => { expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowUpdateData.serviceID}/artifacts/${flowUpdateData.uniqueId}`); - return { - artifactChecksum: 'MmE5MWJmN2ZlN2FhM2JhMzA0NGQ1ODMyOWFhNWI0NDA=', - artifactCreator: 'cs0008', - artifactDisplayName: 'zizizi', - artifactGroupType: 'INFORMATIONAL', - artifactLabel: 'zizizi', - artifactName: 'zizizi', - artifactType: 'WORKFLOW', - artifactUUID: '3319335b-969e-4d72-b5a2-409645de6d64', - artifactVersion: '3', - attUidLastUpdater: 'cs0008', - creationDate: 1470144601623, - description: 'aslkjdfl asfdasdf', - esId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - lastUpdateDate: 1470208425904, - mandatory: false, - payloadUpdateDate: 1470208426424, - serviceApi: false, - timeout: 0, - uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - updaterFullName: 'Carlos Santana' - }; + return buildFromExistingObject(FlowPostResponseFactory, flowUpdateData); }); - FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowUpdateData}, !NEW_FLOW); - - setTimeout(() => { + return FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowUpdateData}, !NEW_FLOW).then(() => { assertFlowDataAfterCreateFetchAndUpdate(flowUpdateData); - done(); - }, 50); + }); + }); - it('Delete Flow', done => { + it('Delete Flow', () => { deepFreeze(store.getState()); - const flowDeleteData = deepFreeze({ - artifactName: 'zizizi', - artifactType: 'WORKFLOW', - description: 'aslkjdfl asfdasdf', - serviceID: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b', - uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi', - participants: [] - }); + const flowDeleteData = FlowDeleteRequestFactory.build(); mockRest.addHandler('destroy', ({baseUrl}) => { expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowDeleteData.serviceID}/artifacts/${flowDeleteData.uniqueId}`); return {}; }); - FlowsActions.deleteFlow(store.dispatch, {flow: flowDeleteData}); - - setTimeout(() => { + return FlowsActions.deleteFlow(store.dispatch, {flow: flowDeleteData}).then(() => { let {flowList} = store.getState().flows; let index = flowList.findIndex(flow => flow.uniqueId === flowDeleteData.uniqueId); expect(index).toBe(-1); - done(); - }, 50); + }); }); - }); - diff --git a/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js b/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js new file mode 100644 index 0000000000..0d8ce945c8 --- /dev/null +++ b/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js @@ -0,0 +1,75 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps } from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js'; +import LicenseModelCreationView from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx'; +import {LicenseModelCreationFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; + +describe('License Model Creation Module Tests', function() { + it ('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it ('should return empty data', () => { + let state = { + licenseModelList: [], + licenseModel: { + licenseModelCreation: { + data: {} + } + } + }; + let props = mapStateToProps(state); + expect(props.data).toEqual({}); + }); + + it ('should return vlm names list', () => { + let state = { + licenseModelList: [{ + vendorName: 'vlm1', + id: 'vlm1_id' + }, { + vendorName: 'vlm2', + id: 'vlm2_id' + }], + licenseModel: { + licenseModelCreation: { + data: {} + } + } + }; + let props = mapStateToProps(state); + expect(props.data).toEqual({}); + expect(props.VLMNames).toEqual({vlm1: 'vlm1_id', vlm2: 'vlm2_id'}); + }); + + it('simple jsx test', () => { + let data = LicenseModelCreationFactory.build(); + var renderer = TestUtils.createRenderer(); + renderer.render( + {}} + onValidateForm={() => {}} + onSubmit={() => {}} + onCancel={() => {}}/> + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/licenseModel/entitlementPools/test.js b/openecomp-ui/test/licenseModel/entitlementPools/test.js index 32705385b4..15e1deecd6 100644 --- a/openecomp-ui/test/licenseModel/entitlementPools/test.js +++ b/openecomp-ui/test/licenseModel/entitlementPools/test.js @@ -1,52 +1,34 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 deepFreeze from 'deep-freeze'; -import {expect} from 'chai'; import mockRest from 'test-utils/MockRest.js'; -import {cloneAndSet} from 'test-utils/Util.js'; +import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import EntitlementPoolsActionHelper from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js'; +import {EntitlementPoolStoreFactory, EntitlementPoolPostFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; describe('Entitlement Pools Module Tests', function () { const LICENSE_MODEL_ID = '555'; + const version = VersionControllerUtilsFactory.build().version; it('Load Entitlement Pools List', () => { - const entitlementPoolsList = [ - { - name: 'ep1', - description: 'string', - thresholdValue: 75, - thresholdUnits: '%', - entitlementMetric: {'choice': 'User', 'other': ''}, - increments: 'string', - aggregationFunction: {'choice': 'Average', 'other': ''}, - operationalScope: {'choices': ['Other'], 'other': 'blabla'}, - time: {'choice': 'Hour', 'other': ''}, - sku: 'DEF2-385A-4521-AAAA', - id: '1', - referencingFeatureGroups: [], - partNumber: '51529' - } - ]; + + const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory); deepFreeze(entitlementPoolsList); const store = storeCreator(); deepFreeze(store.getState()); @@ -54,36 +36,20 @@ describe('Entitlement Pools Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', entitlementPoolsList); mockRest.addHandler('fetch', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: entitlementPoolsList}; }); - return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); it('Delete Entitlement Pool', () => { - const entitlementPoolsList = [ - { - name: 'ep1', - description: 'string', - thresholdValue: 75, - thresholdUnits: '%', - entitlementMetric: {'choice': 'User', 'other': ''}, - increments: 'string', - aggregationFunction: {'choice': 'Average', 'other': ''}, - operationalScope: {'choices': ['Other'], 'other': 'blabla'}, - time: {'choice': 'Hour', 'other': ''}, - sku: 'DEF2-385A-4521-AAAA', - id: '1', - referencingFeatureGroups: [], - partNumber: '51529' - } - ]; + const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory,1); deepFreeze(entitlementPoolsList); const store = storeCreator({ licenseModel: { @@ -97,9 +63,9 @@ describe('Entitlement Pools Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', []); mockRest.addHandler('destroy', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools/${entitlementPoolsList[0].id}`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPoolsList[0].id}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return { results: { returnCode: 'OK' @@ -109,9 +75,10 @@ describe('Entitlement Pools Module Tests', function () { return EntitlementPoolsActionHelper.deleteEntitlementPool(store.dispatch, { licenseModelId: LICENSE_MODEL_ID, + version, entitlementPoolId: entitlementPoolsList[0].id }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -120,43 +87,20 @@ describe('Entitlement Pools Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const entitlementPoolPostRequest = { - name: 'ep1', - description: 'string', - thresholdValue: 75, - thresholdUnits: '%', - entitlementMetric: {'choice': 'User', 'other': ''}, - increments: 'string', - aggregationFunction: {'choice': 'Average', 'other': ''}, - operationalScope: {'choices': ['Other'], 'other': 'blabla'}, - time: {'choice': 'Hour', 'other': ''}, - manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA', - }; - const entitlementPoolToAdd = { - name: 'ep1', - description: 'string', - thresholdValue: 75, - thresholdUnits: '%', - entitlementMetric: {'choice': 'User', 'other': ''}, - increments: 'string', - aggregationFunction: {'choice': 'Average', 'other': ''}, - operationalScope: {'choices': ['Other'], 'other': 'blabla'}, - time: {'choice': 'Hour', 'other': ''}, - manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA', - referencingFeatureGroups: [] - }; + const EntitlementPoolPostRequest = EntitlementPoolPostFactory.build(); + + deepFreeze(EntitlementPoolPostRequest); + const entitlementPoolIdFromResponse = 'ADDED_ID'; - const entitlementPoolAfterAdd = { - ...entitlementPoolToAdd, - id: entitlementPoolIdFromResponse - }; + const entitlementPoolAfterAdd = EntitlementPoolStoreFactory.build({id: entitlementPoolIdFromResponse}); + deepFreeze(entitlementPoolAfterAdd); const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolAfterAdd]); - mockRest.addHandler('create', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools`); - expect(data).to.deep.equal(entitlementPoolPostRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`); + expect(data).toEqual(EntitlementPoolPostRequest); + expect(options).toEqual(undefined); return { returnCode: 'OK', value: entitlementPoolIdFromResponse @@ -166,28 +110,18 @@ describe('Entitlement Pools Module Tests', function () { return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, { licenseModelId: LICENSE_MODEL_ID, + version, previousEntitlementPool: null, - entitlementPool: entitlementPoolToAdd + entitlementPool: EntitlementPoolPostRequest } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Update Entitlement Pool', () => { - const entitlementPoolsList = [{ - name: 'ep1', - id: '0', - description: 'string', - thresholdValue: 75, - thresholdUnits: '%', - entitlementMetric: {'choice': 'User', 'other': ''}, - increments: 'string', - aggregationFunction: {'choice': 'Average', 'other': ''}, - operationalScope: {'choices': ['Other'], 'other': 'blabla'}, - time: {'choice': 'Hour', 'other': ''}, - manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA' - }]; + + const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory, 1); deepFreeze(entitlementPoolsList); const store = storeCreator({ @@ -197,47 +131,34 @@ describe('Entitlement Pools Module Tests', function () { } } }); + deepFreeze(store.getState()); const toBeUpdatedEntitlementPoolId = entitlementPoolsList[0].id; const previousEntitlementPoolData = entitlementPoolsList[0]; - const entitlementPoolUpdateData = { - ...entitlementPoolsList[0], - name: 'ep1_UPDATED', - description: 'string_UPDATED' - }; + const entitlementPoolUpdateData = EntitlementPoolStoreFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED', id: toBeUpdatedEntitlementPoolId}); deepFreeze(entitlementPoolUpdateData); - const entitlementPoolPutRequest = { - name: 'ep1_UPDATED', - description: 'string_UPDATED', - thresholdValue: 75, - thresholdUnits: '%', - entitlementMetric: {'choice': 'User', 'other': ''}, - increments: 'string', - aggregationFunction: {'choice': 'Average', 'other': ''}, - operationalScope: {'choices': ['Other'], 'other': 'blabla'}, - time: {'choice': 'Hour', 'other': ''}, - manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA' - }; + const entitlementPoolPutRequest = EntitlementPoolPostFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED'}); deepFreeze(entitlementPoolPutRequest); const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolUpdateData]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools/${toBeUpdatedEntitlementPoolId}`); - expect(data).to.deep.equal(entitlementPoolPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${toBeUpdatedEntitlementPoolId}`); + expect(data).toEqual(entitlementPoolPutRequest); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, { licenseModelId: LICENSE_MODEL_ID, + version, previousEntitlementPool: previousEntitlementPoolData, entitlementPool: entitlementPoolUpdateData }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); diff --git a/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js new file mode 100644 index 0000000000..5f5e2a0c9e --- /dev/null +++ b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js @@ -0,0 +1,74 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps} from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js'; +import FeatureGroupEditorView from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx'; +import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; + +describe('License Model Feature Groups Editor Module Tests', function () { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should return empty data', () => { + + let licenseModel = LicenseModelOverviewFactory.build({ + featureGroup: { + featureGroupEditor: { + data: FeatureGroupStoreFactory.build() + }, + featureGroupsList: [] + } + }); + + var results = mapStateToProps({licenseModel}); + expect(results.entitlementPoolsList).toEqual([]); + expect(results.licenseKeyGroupsList).toEqual([]); + }); + + it ('should return fg names list', () => { + let licenseModel = LicenseModelOverviewFactory.build({ + featureGroup: { + featureGroupEditor: { + data: FeatureGroupStoreFactory.build() + }, + featureGroupsList: [{ + name: 'fg1', + id: 'fg1_id' + }, { + name: 'fg2', + id: 'fg2_id' + }] + } + }); + var results = mapStateToProps({licenseModel}); + expect(results.FGNames).toEqual({fg1: 'fg1_id', fg2: 'fg2_id'}); + }); + + it('jsx view test', () => { + var view = TestUtils.renderIntoDocument( {}} + entitlementPoolsList={[{id: '1', name: '1'}]} + licenseKeyGroupsList={[{id: '1', name: '1'}]}/>); + expect(view).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js new file mode 100644 index 0000000000..5dc20047bc --- /dev/null +++ b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js @@ -0,0 +1,90 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps} from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js'; +import FeatureGroupsListEditorView from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx'; +import { FeatureGroupStoreFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import { buildListFromFactory } from 'test-utils/Util.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +describe('License Model Feature Group List Module Tests', function () { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + + it('should return empty data', () => { + + + let licenseModel = LicenseModelOverviewFactory.build({ + featureGroup: { + featureGroupEditor: {}, + featureGroupsList: [] + }, + licenseModelEditor: { + data:{ + ...VersionControllerUtilsFactory.build() + } + } + }); + var results = mapStateToProps({licenseModel}); + expect(results.vendorName).toEqual(undefined); + expect(results.featureGroupsModal.show).toEqual(false); + expect(results.featureGroupsModal.editMode).toEqual(false); + expect(results.featureGroupsList).toEqual([]); + }); + + it('should return true for show and edit mode and vendorName should be not empty', () => { + + let licenseModel = LicenseModelOverviewFactory.build({ + featureGroup: { + featureGroupEditor: { + data: FeatureGroupStoreFactory.build() + }, + featureGroupsList: [] + } + }); + var results = mapStateToProps({licenseModel}); + expect(results.featureGroupsModal.show).toEqual(true); + expect(results.featureGroupsModal.editMode).toEqual(true); + expect(results.vendorName).toEqual(licenseModel.licenseModelEditor.data.vendorName); + }); + + it('jsx view test', () => { + var view = TestUtils.renderIntoDocument({}} + featureGroupsList={[]} />); + expect(view).toBeTruthy(); + }); + + it('jsx view list test', () => { + var view = TestUtils.renderIntoDocument({}} + featureGroupsList={buildListFromFactory(FeatureGroupStoreFactory)} />); + expect(view).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/licenseModel/featureGroups/test.js b/openecomp-ui/test/licenseModel/featureGroups/test.js index d334ab758e..7d0d7242b5 100644 --- a/openecomp-ui/test/licenseModel/featureGroups/test.js +++ b/openecomp-ui/test/licenseModel/featureGroups/test.js @@ -1,75 +1,56 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; -import {cloneAndSet} from 'test-utils/Util.js'; +import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js'; +import { FeatureGroupStoreFactory, FeatureGroupPostFactory, FeatureGroupDispatchFactory, FeatureGroupPutFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; describe('Feature Groups Module Tests', function () { const LICENSE_MODEL_ID = '555'; + const version = VersionControllerUtilsFactory.build().version; it('Load Feature Groups List', () => { - const featureGroupsList = [ - { - name: 'fs1', - id: 0, - description: 'fs1-d', - licenseKeyGroupsIds: [1], - entitlementPoolsIds: [1], - refCount: 0 - } - ]; + + const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory); deepFreeze(featureGroupsList); + const store = storeCreator(); deepFreeze(store.getState()); const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', featureGroupsList); mockRest.addHandler('fetch', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: featureGroupsList}; }); - return FeatureGroupsActionHelper.fetchFeatureGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return FeatureGroupsActionHelper.fetchFeatureGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); it('Delete Feature Group', () => { - const featureGroupsList = [ - { - name: 'fs1', - id: 0, - description: 'fs1-d', - licenseKeyGroupsIds: [1], - entitlementPoolsIds: [1], - refCount: 0 - } - ]; + const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1); deepFreeze(featureGroupsList); const store = storeCreator({ licenseModel: { @@ -82,10 +63,12 @@ describe('Feature Groups Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', []); + const idToDelete = featureGroupsList[0].id; + mockRest.addHandler('destroy', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups/${featureGroupsList[0].id}`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups/${idToDelete}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return { results: { returnCode: 'OK' @@ -95,9 +78,10 @@ describe('Feature Groups Module Tests', function () { return FeatureGroupsActionHelper.deleteFeatureGroup(store.dispatch, { licenseModelId: LICENSE_MODEL_ID, - featureGroupId: featureGroupsList[0].id + version, + featureGroupId: idToDelete }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -106,56 +90,62 @@ describe('Feature Groups Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const featureGroupPostRequest = { - name: 'fs1', - description: 'fs1-d', - partNumber: '123', + const FeatureGroupPostRequest = FeatureGroupPostFactory.build({ addedLicenseKeyGroupsIds: [1], addedEntitlementPoolsIds: [1] - }; - const featureGroupToAdd = { - name: 'fs1', - description: 'fs1-d', - partNumber: '123', + }); + const featureGroupToAdd = FeatureGroupDispatchFactory.build({ licenseKeyGroupsIds: [1], entitlementPoolsIds: [1] - }; + }); + const featureGroupIdFromResponse = 'ADDED_ID'; - const featureGroupAfterAdd = { + const featureGroupAfterAdd = FeatureGroupStoreFactory.build({ ...featureGroupToAdd, id: featureGroupIdFromResponse - }; + }); const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupAfterAdd]); - mockRest.addHandler('create', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups`); - expect(data).to.deep.equal(featureGroupPostRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`); + expect(data).toEqual(FeatureGroupPostRequest); + expect(options).toEqual(undefined); return { returnCode: 'OK', value: featureGroupIdFromResponse }; }); + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + + return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, { licenseModelId: LICENSE_MODEL_ID, + version, featureGroup: featureGroupToAdd }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Update Feature Group', () => { - const featureGroupsList = [{ - name: 'fs1', - id: 0, - description: 'fs1-d', - partNumber: '123', + const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1, { licenseKeyGroupsIds: [1], - entitlementPoolsIds: [1], - refCount: 0 - }]; + entitlementPoolsIds: [1] + }); deepFreeze(featureGroupsList); const store = storeCreator({ @@ -169,44 +159,92 @@ describe('Feature Groups Module Tests', function () { const toBeUpdatedFeatureGroupId = featureGroupsList[0].id; const previousFeatureGroupData = featureGroupsList[0]; - const featureGroupUpdateData = { - ...featureGroupsList[0], - name: 'fs_UPDATED', - description: 'description_UPDATED', - partNumber: '123_UPDATED', + + const featureGroupUpdateData = FeatureGroupStoreFactory.build({ + ...previousFeatureGroupData, licenseKeyGroupsIds: [7], entitlementPoolsIds: [7] - }; + }); deepFreeze(featureGroupUpdateData); - const featureGroupPutRequest = { - name: 'fs_UPDATED', - description: 'description_UPDATED', - partNumber: '123_UPDATED', + const FeatureGroupPutFactoryRequest = FeatureGroupPutFactory.build({ + name: featureGroupUpdateData.name, + description: featureGroupUpdateData.description, + partNumber: featureGroupUpdateData.partNumber, addedLicenseKeyGroupsIds: [7], addedEntitlementPoolsIds: [7], removedLicenseKeyGroupsIds: [1], removedEntitlementPoolsIds: [1] - }; - deepFreeze(featureGroupPutRequest); + }); + deepFreeze(FeatureGroupPutFactoryRequest); const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupUpdateData]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups/${toBeUpdatedFeatureGroupId}`); - expect(data).to.deep.equal(featureGroupPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups/${toBeUpdatedFeatureGroupId}`); + expect(data).toEqual(FeatureGroupPutFactoryRequest); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, { licenseModelId: LICENSE_MODEL_ID, + version, previousFeatureGroup: previousFeatureGroupData, featureGroup: featureGroupUpdateData }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); + + }); + + it('Open Editor', () => { + + const store = storeCreator(); + deepFreeze(store.getState()); + + const editorData = FeatureGroupStoreFactory.build(); + deepFreeze(editorData); + const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupEditor.data', editorData); + const LICENSE_MODEL_ID = '123'; + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + + + FeatureGroupsActionHelper.openFeatureGroupsEditor(store.dispatch, {featureGroup: editorData, licenseModelId: '123', version}); + setTimeout(() =>{ + expect(store.getState()).toEqual(expectedStore); + }, 100); + + + }); }); diff --git a/openecomp-ui/test/licenseModel/licenseAgreement/test.js b/openecomp-ui/test/licenseModel/licenseAgreement/test.js index a6e8a3d363..442f7bf91f 100644 --- a/openecomp-ui/test/licenseModel/licenseAgreement/test.js +++ b/openecomp-ui/test/licenseModel/licenseAgreement/test.js @@ -1,75 +1,54 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; +import pickBy from 'lodash/pickBy'; import mockRest from 'test-utils/MockRest.js'; -import {cloneAndSet} from 'test-utils/Util.js'; +import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import LicenseAgreementActionHelper from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js'; +import { LicenseAgreementStoreFactory, LicenseAgreementDispatchFactory, LicenseAgreementPostFactory, LicenseAgreementPutFactory } from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; describe('License Agreement Module Tests', () => { const LICENSE_MODEL_ID = '777'; + const version = VersionControllerUtilsFactory.build().version; it('Load License Agreement List', () => { - const licenseAgreementList = [ - { - id: '0', - name: 'name0', - description: 'description0', - licenseTerm: 'licenseTerm0', - requirementsAndConstrains: 'req_and_constraints0', - featureGroupsIds: ['77'] - } - ]; - deepFreeze(licenseAgreementList); + const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory); + const store = storeCreator(); deepFreeze(store.getState()); const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', licenseAgreementList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: licenseAgreementList}; }); - return LicenseAgreementActionHelper.fetchLicenseAgreementList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return LicenseAgreementActionHelper.fetchLicenseAgreementList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); it('Delete License Agreement', () => { - const licenseAgreementList = [ - { - id: '0', - name: 'name0', - description: 'description0', - licenseTerm: 'licenseTerm0', - requirementsAndConstrains: 'req_and_constraints0', - featureGroupsIds: ['77'] - } - ]; - deepFreeze(licenseAgreementList); + const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory, 1); const store = storeCreator({ licenseModel: { licenseAgreement: { @@ -78,57 +57,49 @@ describe('License Agreement Module Tests', () => { } }); deepFreeze(store.getState()); - const toBeDeletedLicenseAgreementId = '0'; + const toBeDeletedLicenseAgreementId = licenseAgreementList[0].id; const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', []); mockRest.addHandler('destroy', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements/${toBeDeletedLicenseAgreementId}`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements/${toBeDeletedLicenseAgreementId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); }); return LicenseAgreementActionHelper.deleteLicenseAgreement(store.dispatch, { licenseAgreementId: toBeDeletedLicenseAgreementId, - licenseModelId: LICENSE_MODEL_ID + licenseModelId: LICENSE_MODEL_ID, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Add License Agreement', () => { const store = storeCreator(); deepFreeze(store.getState()); - const licenseAgreementPostRequest = { - name: 'name_ADDED_LA', - description: 'description_ADDED_LA', - licenseTerm: 'licenseTerm_ADDED_LA', - requirementsAndConstrains: 'req_and_constraints_ADDED_LA', - addedFeatureGroupsIds: [] - }; - deepFreeze(licenseAgreementPostRequest); - - const licenseAgreementToAdd = { - name: 'name_ADDED_LA', - description: 'description_ADDED_LA', - licenseTerm: 'licenseTerm_ADDED_LA', - requirementsAndConstrains: 'req_and_constraints_ADDED_LA', - featureGroupsIds: [] - }; - deepFreeze(licenseAgreementToAdd); + + const licenseAgreementToAdd = LicenseAgreementDispatchFactory.build(); + + const LicenseAgreementPostRequest = LicenseAgreementPostFactory.build( + pickBy(licenseAgreementToAdd, (val, key) => key !== 'featureGroupsIds') + ); + + deepFreeze(LicenseAgreementPostRequest); const licenseAgreementIdFromResponse = 'ADDED_ID'; - const licenseAgreementAfterAdd = { + const licenseAgreementAfterAdd = LicenseAgreementStoreFactory.build({ ...licenseAgreementToAdd, id: licenseAgreementIdFromResponse - }; + }); deepFreeze(licenseAgreementAfterAdd); const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementAfterAdd]); - mockRest.addHandler('create', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements`); - expect(data).to.deep.equal(licenseAgreementPostRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('post', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`); + expect(data).toEqual(LicenseAgreementPostRequest); + expect(options).toEqual(undefined); return { value: licenseAgreementIdFromResponse }; @@ -136,23 +107,15 @@ describe('License Agreement Module Tests', () => { return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, { licenseAgreement: licenseAgreementToAdd, - licenseModelId: LICENSE_MODEL_ID + licenseModelId: LICENSE_MODEL_ID, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Update License Agreement', () => { - const licenseAgreementList = [ - { - id: '0', - name: 'name0', - description: 'description0', - licenseTerm: 'licenseTerm0', - requirementsAndConstrains: 'req_and_constraints0', - featureGroupsIds: ['77'] - } - ]; + const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory, 1, {featureGroupsIds: ['77']}); const store = storeCreator({ licenseModel: { licenseAgreement: { @@ -162,43 +125,40 @@ describe('License Agreement Module Tests', () => { }); deepFreeze(store.getState()); - const toBeUpdatedLicenseAgreementId = licenseAgreementList[0].id; const previousLicenseAgreementData = licenseAgreementList[0]; + const toBeUpdatedLicenseAgreementId = previousLicenseAgreementData.id; + const oldFeatureGroupIds = previousLicenseAgreementData.featureGroupsIds; + + const newFeatureGroupsIds = ['update_id_1', 'update_id_2']; - const licenseAgreementUpdateData = { - ...licenseAgreementList[0], - name: 'name_UPDATED', - description: 'description_UPDATED', - licenseTerm: 'licenseTerm_UPDATED_LA', - requirementsAndConstrains: 'req_and_constraints_UPDATED_LA', - featureGroupsIds: ['update_id_1', 'update_id_2'] - }; + const licenseAgreementUpdateData = LicenseAgreementStoreFactory.build({ + id: toBeUpdatedLicenseAgreementId, + featureGroupsIds: newFeatureGroupsIds + }); deepFreeze(licenseAgreementUpdateData); - const licenseAgreementPutRequest = { - name: 'name_UPDATED', - description: 'description_UPDATED', - licenseTerm: 'licenseTerm_UPDATED_LA', - requirementsAndConstrains: 'req_and_constraints_UPDATED_LA', - addedFeatureGroupsIds: ['update_id_1', 'update_id_2'], - removedFeatureGroupsIds: ['77'] - }; - deepFreeze(licenseAgreementPutRequest); + const LicenseAgreementPutFactoryRequest = LicenseAgreementPutFactory.build({ + addedFeatureGroupsIds: newFeatureGroupsIds, + removedFeatureGroupsIds: oldFeatureGroupIds + }); + + deepFreeze(LicenseAgreementPutFactoryRequest); const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementUpdateData]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements/${toBeUpdatedLicenseAgreementId}`); - expect(data).to.deep.equal(licenseAgreementPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements/${toBeUpdatedLicenseAgreementId}`); + expect(data).toEqual(LicenseAgreementPutFactoryRequest); + expect(options).toEqual(undefined); }); return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, { licenseModelId: LICENSE_MODEL_ID, + version, previousLicenseAgreement: previousLicenseAgreementData, licenseAgreement: licenseAgreementUpdateData }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); diff --git a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js index 944bd44e49..dd09030f4f 100644 --- a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js +++ b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js @@ -1,44 +1,36 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; -import {cloneAndSet} from 'test-utils/Util.js'; +import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; +import {LicenseKeyGroupStoreFactory, LicenseKeyGroupPostFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js'; import LicenseKeyGroupsActionHelper from 'sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; describe('License Key Groups Module Tests', function () { const LICENSE_MODEL_ID = '555'; + const version = VersionControllerUtilsFactory.build().version; + it('Load License Key Group', () => { - const licenseKeyGroupsList = [ - { - name: 'lsk1', - description: 'string', - type: 'Unique', - operationalScope: {'choices': ['Data_Center'], 'other': ''}, - id: '0' - } - ]; + + const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory); + deepFreeze(licenseKeyGroupsList); const store = storeCreator(); deepFreeze(store.getState()); @@ -46,27 +38,21 @@ describe('License Key Groups Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', licenseKeyGroupsList); mockRest.addHandler('fetch', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: licenseKeyGroupsList}; }); - return LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); it('Delete License Key Group', () => { - const licenseKeyGroupsList = [ - { - name: 'lsk1', - description: 'string', - type: 'Unique', - operationalScope: {'choices': ['Data_Center'], 'other': ''}, - id: '0' - } - ]; + + const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory, 1); + deepFreeze(licenseKeyGroupsList); const store = storeCreator({ licenseModel: { @@ -76,20 +62,21 @@ describe('License Key Groups Module Tests', function () { } }); deepFreeze(store.getState()); - const toBeDeletedLicenseKeyGroupId = '0'; + const toBeDeletedLicenseKeyGroupId = licenseKeyGroupsList[0].id; const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', []); mockRest.addHandler('destroy', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups/${toBeDeletedLicenseKeyGroupId}`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${toBeDeletedLicenseKeyGroupId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); }); return LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(store.dispatch, { licenseKeyGroupId: toBeDeletedLicenseKeyGroupId, - licenseModelId: LICENSE_MODEL_ID + licenseModelId: LICENSE_MODEL_ID, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -98,56 +85,34 @@ describe('License Key Groups Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const licenseKeyGroupPostRequest = { - name: 'lsk1_ADDED', - description: 'string_ADDED', - type: 'Unique_ADDED', - operationalScope: {'choices': ['Data_Center'], 'other': ''} - }; - deepFreeze(licenseKeyGroupPostRequest); - - const licenseKeyGroupToAdd = { - ...licenseKeyGroupPostRequest - }; - - deepFreeze(licenseKeyGroupToAdd); - - const licenseKeyGroupIdFromResponse = 'ADDED_ID'; - const licenseKeyGroupAfterAdd = { - ...licenseKeyGroupToAdd, - id: licenseKeyGroupIdFromResponse - }; - deepFreeze(licenseKeyGroupAfterAdd); - - const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupAfterAdd]); - - mockRest.addHandler('create', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups`); - expect(data).to.deep.equal(licenseKeyGroupPostRequest); - expect(options).to.equal(undefined); + const LicenseKeyGroupPost = LicenseKeyGroupPostFactory.build(); + deepFreeze(LicenseKeyGroupPost); + + const LicenseKeyGroupStore = LicenseKeyGroupStoreFactory.build(); + deepFreeze(LicenseKeyGroupStore); + + const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [LicenseKeyGroupStore]); + + mockRest.addHandler('post', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`); + expect(data).toEqual(LicenseKeyGroupPost); + expect(options).toEqual(undefined); return { - value: licenseKeyGroupIdFromResponse + value: LicenseKeyGroupStore.id }; }); return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, { - licenseKeyGroup: licenseKeyGroupToAdd, - licenseModelId: LICENSE_MODEL_ID + licenseKeyGroup: LicenseKeyGroupPost, + licenseModelId: LICENSE_MODEL_ID, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Update License Key Group', () => { - const licenseKeyGroupsList = [ - { - name: 'lsk1', - description: 'string', - type: 'Unique', - operationalScope: {'choices': ['Data_Center'], 'other': ''}, - id: '0' - } - ]; + const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory, 1); deepFreeze(licenseKeyGroupsList); const store = storeCreator({ licenseModel: { @@ -160,37 +125,35 @@ describe('License Key Groups Module Tests', function () { const toBeUpdatedLicenseKeyGroupId = licenseKeyGroupsList[0].id; const previousLicenseKeyGroupData = licenseKeyGroupsList[0]; - const licenseKeyGroupUpdateData = { - ...licenseKeyGroupsList[0], + const licenseKeyGroupUpdatedData = LicenseKeyGroupPostFactory.build({ name: 'lsk1_UPDATE', description: 'string_UPDATE', - type: 'Unique', - operationalScope: {'choices': ['Data_Center'], 'other': ''} - }; - deepFreeze(licenseKeyGroupUpdateData); + id: toBeUpdatedLicenseKeyGroupId + }); + deepFreeze(licenseKeyGroupUpdatedData); - const licenseKeyGroupPutRequest = { + const licenseKeyGroupPutRequest = LicenseKeyGroupPostFactory.build({ name: 'lsk1_UPDATE', - description: 'string_UPDATE', - type: 'Unique', - operationalScope: {'choices': ['Data_Center'], 'other': ''} - }; + description: 'string_UPDATE' + }); + deepFreeze(licenseKeyGroupPutRequest); - const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupUpdateData]); + const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupUpdatedData]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups/${toBeUpdatedLicenseKeyGroupId}`); - expect(data).to.deep.equal(licenseKeyGroupPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${toBeUpdatedLicenseKeyGroupId}`); + expect(data).toEqual(licenseKeyGroupPutRequest); + expect(options).toEqual(undefined); }); return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, { previousLicenseKeyGroup: previousLicenseKeyGroupData, - licenseKeyGroup: licenseKeyGroupUpdateData, - licenseModelId: LICENSE_MODEL_ID + licenseKeyGroup: licenseKeyGroupUpdatedData, + licenseModelId: LICENSE_MODEL_ID, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); diff --git a/openecomp-ui/test/licenseModel/overview/listItems/EntitlementPool.test.js b/openecomp-ui/test/licenseModel/overview/listItems/EntitlementPool.test.js new file mode 100644 index 0000000000..6c4a05eb16 --- /dev/null +++ b/openecomp-ui/test/licenseModel/overview/listItems/EntitlementPool.test.js @@ -0,0 +1,31 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import EntitlementPool from 'src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx'; +import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js'; + +describe('Entitlement Pool List Item Module Tests', function () { + it('Entitlement Pool List Item should exist', () => { + expect(EntitlementPool).toBeTruthy(); + }); + it('renders Entitlement Pool List Item', () => { + const epData = EntitlementPoolListItemFactory.build(); + const itemView = TestUtils.renderIntoDocument( ); + expect(itemView).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/licenseModel/overview/listItems/FeatureGroup.test.js b/openecomp-ui/test/licenseModel/overview/listItems/FeatureGroup.test.js new file mode 100644 index 0000000000..10b7801889 --- /dev/null +++ b/openecomp-ui/test/licenseModel/overview/listItems/FeatureGroup.test.js @@ -0,0 +1,58 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import FeatureGroup from 'src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx'; +import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; +import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js'; +import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js'; + +describe('Feature Group List Item Module Tests', function () { + it('Feature Group List Item should exist', () => { + expect(FeatureGroup).toBeTruthy(); + }); + + it('renders Feature Group List Item Collapsed', () => { + const fgData = FeatureGroupListItemFactory.build(); + const itemView = TestUtils.renderIntoDocument( ); + expect(itemView).toBeTruthy(); + const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'down'); + expect(elem).toBeTruthy(); + }); + + it('renders Feature Group List Item Expanded', () => { + const fgData = FeatureGroupListItemFactory.build({isCollpased: false}); + const itemView = TestUtils.renderIntoDocument( ); + expect(itemView).toBeTruthy(); + const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'right'); + expect(elem).toBeTruthy(); + }); + + it('renders Feature Group List Item with Children Count', () => { + const children = [EntitlementPoolListItemFactory.build(), LicenseKeyGroupListItemFactory.build()]; + const fgData = FeatureGroupListItemFactory.build({children: children, isCollpased: false}); + const itemView = TestUtils.renderIntoDocument( ); + expect(itemView).toBeTruthy(); + let elem = scryRenderedDOMComponentsWithTestId(itemView,'vlm-list-ep-count-value'); + expect(elem).toBeTruthy(); + expect(elem[0].innerHTML).toBe('1'); + elem = scryRenderedDOMComponentsWithTestId(itemView,'vlm-list-lkg-count-value'); + expect(elem).toBeTruthy(); + expect(elem[0].innerHTML).toBe('1'); + }); +}); diff --git a/openecomp-ui/test/licenseModel/overview/listItems/LicenseAgreement.test.js b/openecomp-ui/test/licenseModel/overview/listItems/LicenseAgreement.test.js new file mode 100644 index 0000000000..608a76965f --- /dev/null +++ b/openecomp-ui/test/licenseModel/overview/listItems/LicenseAgreement.test.js @@ -0,0 +1,54 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import LicenseAgreement from 'src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx'; +import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; +import {LicenseAgreementListItemFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; +import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; + +describe('License Agreement List Item Module Tests', function () { + it('License Agreement List Item should exist', () => { + expect(LicenseAgreement).toBeTruthy(); + }); + + it('renders License Agreement List Item Collapsed', () => { + const laData = LicenseAgreementListItemFactory.build(); + const itemView = TestUtils.renderIntoDocument( ); + expect(itemView).toBeTruthy(); + const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'down'); + expect(elem).toBeTruthy(); + }); + + it('renders License Agreement List Item Expanded', () => { + const laData = LicenseAgreementListItemFactory.build({isCollpased: false}); + const itemView = TestUtils.renderIntoDocument( ); + expect(itemView).toBeTruthy(); + const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'right'); + expect(elem).toBeTruthy(); + }); + + it('renders License Agreement List Item with Children Count', () => { + const fgData = FeatureGroupListItemFactory.build(); + const laData = LicenseAgreementListItemFactory.build({children: [fgData]}); + const itemView = TestUtils.renderIntoDocument( ); + expect(itemView).toBeTruthy(); + const elem = scryRenderedDOMComponentsWithTestId(itemView,'vlm-list-fg-count-value'); + expect(elem).toBeTruthy(); + expect(elem[0].innerHTML).toBe('1'); + }); +}); diff --git a/openecomp-ui/test/licenseModel/overview/listItems/LicenseKeyGroup.test.js b/openecomp-ui/test/licenseModel/overview/listItems/LicenseKeyGroup.test.js new file mode 100644 index 0000000000..b9c097b0b1 --- /dev/null +++ b/openecomp-ui/test/licenseModel/overview/listItems/LicenseKeyGroup.test.js @@ -0,0 +1,31 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import LicenseKeyGroup from 'src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx'; +import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js'; + +describe('LicenseKeyGroup List Item Module Tests', function () { + it('LicenseKeyGroup List Item should exist', () => { + expect(LicenseKeyGroup).toBeTruthy(); + }); + it('renders LicenseKeyGroup List Item', () => { + const lkgData = LicenseKeyGroupListItemFactory.build(); + const itemView = TestUtils.renderIntoDocument( ); + expect(itemView).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/licenseModel/overview/summary/SummaryCountList.test.js b/openecomp-ui/test/licenseModel/overview/summary/SummaryCountList.test.js new file mode 100644 index 0000000000..27f7aa68fd --- /dev/null +++ b/openecomp-ui/test/licenseModel/overview/summary/SummaryCountList.test.js @@ -0,0 +1,87 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; + +import {mapStateToProps, SummaryCountList} from 'sdc-app/onboarding/licenseModel/overview/summary/SummaryCountList.js'; +import LicenseModelDescriptionEdit from 'sdc-app/onboarding/licenseModel/overview/summary/LicenseModelDescriptionEdit.jsx'; +import {overviewItems} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; +import {LicenseModelOverviewFactory, LicenseModelStoreFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; + +describe('License Model Overview Summary Count List module test', () => { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('mapper data return test',() => { + + var obj = { + licenseModel: LicenseModelOverviewFactory.build({ + entitlementPool: { + entitlementPoolsList: [] + }, + licenseAgreement: { + licenseAgreementList: [] + }, + featureGroup: { + featureGroupsList: [] + }, + licenseKeyGroup: { + licenseKeyGroupsList: [] + } + }) + }; + + let counts = [ + {name: overviewItems.LICENSE_AGREEMENTS, count: 0}, + {name: overviewItems.FEATURE_GROUPS, count: 0}, + {name: overviewItems.ENTITLEMENT_POOLS, count: 0}, + {name: overviewItems.LICENSE_KEY_GROUPS, count: 0}, + ]; + + var result = mapStateToProps(obj); + expect(result.isReadOnlyMode).toEqual(true); + expect(result.description).toEqual(obj.licenseModel.licenseModelEditor.data.description); + expect(result.counts).toEqual(counts); + }); + + it('jsx view test', () => { + + var counts = [ + {name: overviewItems.LICENSE_AGREEMENTS, count: 0}, + {name: overviewItems.FEATURE_GROUPS, count: 0}, + {name: overviewItems.ENTITLEMENT_POOLS, count: 0}, + {name: overviewItems.LICENSE_KEY_GROUPS, count: 0}, + ]; + + var view = TestUtils.renderIntoDocument(); + expect(view).toBeTruthy(); + }); + + it('description editor jsx view test', () => { + var data = LicenseModelStoreFactory.build(); + var genericFieldInfo = { + description: { + isValid : true + } + } + var view = TestUtils.renderIntoDocument(); + expect(view).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/licenseModel/overview/summary/VendorDataView.test.js b/openecomp-ui/test/licenseModel/overview/summary/VendorDataView.test.js new file mode 100644 index 0000000000..8fea3e4b90 --- /dev/null +++ b/openecomp-ui/test/licenseModel/overview/summary/VendorDataView.test.js @@ -0,0 +1,48 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps, VendorDataView} from 'sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js'; +import {LicenseModelOverviewFactory, LicenseModelStoreFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; + + +describe('License Model Overview Summary module test', () => { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('mapper data return test',() => { + + var state = { + licenseModel: LicenseModelOverviewFactory.build() + }; + + var props = mapStateToProps(state); + expect(props.isReadOnlyMode).toEqual(true); + expect(props.description).toEqual(null); + expect(props.data).toEqual(state.licenseModel.licenseModelEditor.data); + + }); + + it('jsx view test', () => { + var data = LicenseModelStoreFactory.build(); + var view = TestUtils.renderIntoDocument(); + expect(view).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/licenseModel/overview/test.js b/openecomp-ui/test/licenseModel/overview/test.js new file mode 100644 index 0000000000..c78c3e47b1 --- /dev/null +++ b/openecomp-ui/test/licenseModel/overview/test.js @@ -0,0 +1,355 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {mapStateToProps} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js'; +import {overviewEditorHeaders, selectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; + +import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import { EntitlementPoolStoreFactory as EntitlementPool, EntitlementPoolDataListFactory } from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js'; +import { FeatureGroupStoreFactory as FeatureGroup, FeatureGroupDataListFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {LicenseAgreementStoreFactory as LicenseAgreement, LicenseAgreementDataListFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; +import { LicenseKeyGroupStoreFactory as LicenseKeyGroup, LicenseKeyGroupDataListFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js'; + +describe('License Model Overview: ', function () { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + const VLM1 = LicenseModelOverviewFactory.build(); + + it('should mapper return vlm overview basic data', () => { + const state = { + licenseModel: VLM1 + }; + + var props = mapStateToProps(state); + expect(props.isReadOnlyMode).toEqual(true); + expect(props.isDisplayModal).toEqual(false); + expect(props.modalHeader).toEqual(undefined); + expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); + expect(props.licensingDataList).toEqual([]); + expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); + }); + + it('should mapper return overview data for show LA modal', () => { + const VLM1 = LicenseModelOverviewFactory.build({ + licenseAgreement: { + licenseAgreementEditor: { + data: LicenseAgreement.build() + } + } + }); + + var state = { + licenseModel: VLM1 + }; + + var props = mapStateToProps(state); + expect(props.isReadOnlyMode).toEqual(true); + expect(props.isDisplayModal).toEqual(true); + expect(props.modalHeader).toEqual(overviewEditorHeaders.LICENSE_AGREEMENT); + expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); + expect(props.licensingDataList).toEqual([]); + expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); + }); + + it('should mapper return overview data for show FG modal', () => { + + const VLM1 = LicenseModelOverviewFactory.build({ + featureGroup: { + featureGroupsList: [], + featureGroupEditor: { + data: FeatureGroup.build() + } + }, + entitlementPool: { + entitlementPoolsList: [] + }, + licenseKeyGroup: { + licenseKeyGroupsList: [] + }, + licenseModelOverview: { + selectedTab: selectedButton.NOT_IN_USE + } + }); + + var state = { + licenseModel: VLM1 + }; + + var props = mapStateToProps(state); + expect(props.isReadOnlyMode).toEqual(true); + expect(props.isDisplayModal).toEqual(true); + expect(props.modalHeader).toEqual(overviewEditorHeaders.FEATURE_GROUP); + expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); + expect(props.licensingDataList).toEqual([]); + expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE); + }); + + it('should mapper return overview data for show EP modal', () => { + const VLM1 = LicenseModelOverviewFactory.build({ + entitlementPool: { + entitlementPoolEditor: { + data: EntitlementPool.build() + } + } + }); + + var state = { + licenseModel: VLM1 + }; + + var props = mapStateToProps(state); + expect(props.isReadOnlyMode).toEqual(true); + expect(props.isDisplayModal).toEqual(true); + expect(props.modalHeader).toEqual(overviewEditorHeaders.ENTITLEMENT_POOL); + expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); + expect(props.licensingDataList).toEqual([]); + expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); + }); + + it('should mapper return overview data for show LKG modal', () => { + const VLM1 = LicenseModelOverviewFactory.build({ + licenseKeyGroup: { + licenseKeyGroupsList: [], + licenseKeyGroupsEditor: { + data: LicenseKeyGroup.build() + } + }, + entitlementPool: { + entitlementPoolsList: [] + }, + featureGroup: { + featureGroupsList: [] + }, + licenseModelOverview: { + selectedTab: selectedButton.NOT_IN_USE + } + }); + + var state = { + licenseModel: VLM1 + }; + + var props = mapStateToProps(state); + expect(props.isReadOnlyMode).toEqual(true); + expect(props.isDisplayModal).toEqual(true); + expect(props.modalHeader).toEqual(overviewEditorHeaders.LICENSE_KEY_GROUP); + expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); + expect(props.licensingDataList).toEqual([]); + expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE); + }); + + it('should mapper return overview data for Full-hierarchy list view', () => { + let EP1 = EntitlementPool.build(); + let LKG1 = LicenseKeyGroup.build(); + let FG1 = FeatureGroup.build({ + entitlementPoolsIds: [EP1.id], + licenseKeyGroupsIds: [LKG1.id] + }); + EP1.referencingFeatureGroups = [FG1.id]; + LKG1.referencingFeatureGroups = [FG1.id]; + let LA1 = LicenseAgreement.build({ + featureGroupsIds: [FG1.id] + }); + FG1.referencingLicenseAgreements = LA1.id; + let LA2 = LicenseAgreement.build(); + + const VLM1 = LicenseModelOverviewFactory.build({ + licenseAgreement: { + licenseAgreementList: [LA1, LA2] + }, + featureGroup: { + featureGroupsList: [FG1] + }, + entitlementPool: { + entitlementPoolsList: [EP1] + }, + licenseKeyGroup: { + licenseKeyGroupsList: [LKG1] + }, + }); + + const state = { + licenseModel: VLM1 + }; + + const expectedLicensingDataList = [ + LicenseAgreementDataListFactory.build({ + ...LA1, + children: [ + FeatureGroupDataListFactory.build({ + ...FG1, + children: [ + EntitlementPoolDataListFactory.build(EP1), + LicenseKeyGroupDataListFactory.build(LKG1) + ] + }) + ] + }), + LicenseAgreementDataListFactory.build(LA2) + ]; + + var props = mapStateToProps(state); + + expect(props.isReadOnlyMode).toEqual(true); + expect(props.isDisplayModal).toEqual(false); + expect(props.modalHeader).toEqual(undefined); + expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); + expect(props.licensingDataList).toEqual(expectedLicensingDataList); + expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); + }); + + it('should mapper return overview data for list view with 2 levels', () => { + let EP1 = EntitlementPool.build(); + let LKG1 = LicenseKeyGroup.build(); + let FG1 = FeatureGroup.build(); + let LA1 = LicenseAgreement.build({ + featureGroupsIds: [FG1.id] + }); + let LA2 = LicenseAgreement.build(); + FG1.referencingLicenseAgreements = [LA1.id]; + + const VLM1 = LicenseModelOverviewFactory.build({ + licenseAgreement: { + licenseAgreementList: [LA1, LA2] + }, + featureGroup: { + featureGroupsList: [FG1] + }, + entitlementPool: { + entitlementPoolsList: [EP1] + }, + licenseKeyGroup: { + licenseKeyGroupsList: [LKG1] + }, + }); + + const state = { + licenseModel: VLM1 + }; + + const expectedLicensingDataList = [ + LicenseAgreementDataListFactory.build({ + ...LA1, + children: [ + FeatureGroupDataListFactory.build(FG1) + ] + }), + LicenseAgreementDataListFactory.build(LA2) + ]; + + var props = mapStateToProps(state); + + expect(props.isReadOnlyMode).toEqual(true); + expect(props.isDisplayModal).toEqual(false); + expect(props.modalHeader).toEqual(undefined); + expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); + expect(props.licensingDataList).toEqual(expectedLicensingDataList); + expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW); + }); + + it('should mapper return overview data for Full NOT-IN-USE list view', () => { + let EP1 = EntitlementPool.build(); + let LKG1 = LicenseKeyGroup.build(); + let FG1 = FeatureGroup.build(); + + const VLM1 = LicenseModelOverviewFactory.build({ + licenseAgreement: { licenseAgreementList: [] }, + featureGroup: { + featureGroupsList: [FG1] + }, + entitlementPool: { + entitlementPoolsList: [EP1] + }, + licenseKeyGroup: { + licenseKeyGroupsList: [LKG1] + }, + licenseModelOverview: { + selectedTab: selectedButton.NOT_IN_USE + } + }); + + const state = { + licenseModel: VLM1 + }; + + const expectedLicensingDataList = [ + FeatureGroupDataListFactory.build(FG1), + EntitlementPoolDataListFactory.build(EP1), + LicenseKeyGroupDataListFactory.build(LKG1) + ]; + + var props = mapStateToProps(state); + + expect(props.isReadOnlyMode).toEqual(true); + expect(props.isDisplayModal).toEqual(false); + expect(props.modalHeader).toEqual(undefined); + expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); + expect(props.licensingDataList).toEqual(expectedLicensingDataList); + expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE); + }); + + it('should mapper return overview data for NOT-IN-USE list view (FG with children)', () => { + let EP1 = EntitlementPool.build(); + let LKG1 = LicenseKeyGroup.build(); + let FG1 = FeatureGroup.build({ + entitlementPoolsIds: [EP1.id], + licenseKeyGroupsIds: [LKG1.id] + }); + EP1.referencingFeatureGroups = [FG1.id]; + LKG1.referencingFeatureGroups = [FG1.id]; + + const VLM1 = LicenseModelOverviewFactory.build({ + licenseAgreement: { licenseAgreementList: [] }, + featureGroup: { + featureGroupsList: [FG1] + }, + entitlementPool: { + entitlementPoolsList: [EP1] + }, + licenseKeyGroup: { + licenseKeyGroupsList: [LKG1] + }, + licenseModelOverview: { + selectedTab: selectedButton.NOT_IN_USE + } + }); + + const state = { + licenseModel: VLM1 + }; + + const expectedLicensingDataList = [ + FeatureGroupDataListFactory.build({ + ...FG1, + children: [ + EntitlementPoolDataListFactory.build(EP1), + LicenseKeyGroupDataListFactory.build(LKG1)] + }) + ]; + + var props = mapStateToProps(state); + + expect(props.isReadOnlyMode).toEqual(true); + expect(props.isDisplayModal).toEqual(false); + expect(props.modalHeader).toEqual(undefined); + expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id); + expect(props.licensingDataList).toEqual(expectedLicensingDataList); + expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE); + }); +}); diff --git a/openecomp-ui/test/licenseModel/overview/views.test.js b/openecomp-ui/test/licenseModel/overview/views.test.js new file mode 100644 index 0000000000..4a38afccca --- /dev/null +++ b/openecomp-ui/test/licenseModel/overview/views.test.js @@ -0,0 +1,159 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; +import SummaryView from 'sdc-app/onboarding/licenseModel/overview/SummaryView.jsx'; +import LicenseModelOverviewView from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx'; +import VLMListView from 'sdc-app/onboarding/licenseModel/overview/VLMListView.jsx'; +import {selectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js'; + +import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js'; +import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js'; +import {LicenseAgreementListItemFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; + +describe('License Model Overview - View: ', function () { + + const lkgChild = LicenseKeyGroupListItemFactory.build(); + + const epChild = EntitlementPoolListItemFactory.build(); + + const baseFGData = FeatureGroupListItemFactory.build({isCollapsed: false}); + const baseLAData = LicenseAgreementListItemFactory.build({isCollapse: false}); + + it('should render SummaryView', () => { + var renderer = TestUtils.createRenderer(); + renderer.render( + + ); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); + + it('should render LicenseModelOverviewView', () => { + let fgData = {...baseFGData}; + fgData.children = Array.of(epChild, lkgChild); + let laData = {...baseLAData}; + laData.children = [fgData]; + + const params = { + licenseModelId: 'VLM1', + isDisplayModal: false, + modalHeader: undefined, + licensingDataList: [laData], + selectedTab: selectedButton.VLM_LIST_VIEW, + onTabSelect: () => {} + }; + var renderer = TestUtils.createRenderer(); + renderer.render( + + ); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); + + + it('should render empty VLMListView', () => { + const listview = TestUtils.renderIntoDocument( ); + expect(listview).toBeTruthy(); + const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list'); + expect(elem).toBeTruthy(); + expect(elem[0].children.length).toBe(0); + }); + + it('should render VLMListView with licenseAgreement', () => { + const listview = TestUtils.renderIntoDocument( ); + expect(listview).toBeTruthy(); + let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list'); + expect(elem).toBeTruthy(); + expect(elem[0].children.length).toBe(1); + elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-la-item'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('should render VLMListView with Feature Group', () => { + let laData = {...baseLAData}; + laData.children = [baseFGData]; + const listview = TestUtils.renderIntoDocument( ); + expect(listview).toBeTruthy(); + const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('should render VLMListView with Entitlement Pool', () => { + let fgData = {...baseFGData}; + fgData.children = [epChild]; + let laData = {...baseLAData}; + laData.children = [fgData]; + + const listview = TestUtils.renderIntoDocument( ); + expect(listview).toBeTruthy(); + const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('should render VLMListView with LicenseKeyGroup', () => { + let fgData = {...baseFGData}; + fgData.children = [lkgChild]; + let laData = {...baseLAData}; + laData.children = [fgData]; + + const listview = TestUtils.renderIntoDocument( ); + expect(listview).toBeTruthy(); + const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('should render VLMListView with all items', () => { + let fgData = {...baseFGData}; + fgData.children = Array.of(epChild, lkgChild); + let laData = {...baseLAData}; + laData.children = [fgData]; + + const listview = TestUtils.renderIntoDocument( ); + expect(listview).toBeTruthy(); + let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('should update collapsing item', () => { + let fgData = {...baseFGData}; + fgData.children = Array.of(epChild, lkgChild); + let laData = {...baseLAData}; + laData.children = [fgData]; + + var renderer = TestUtils.renderIntoDocument( + + ); + expect(renderer).toBeTruthy(); + + renderer.updateCollapsable(new Event('click'), 'LA1'); + expect(renderer.state['LA1']).toEqual(true); + }); +}); diff --git a/openecomp-ui/test/licenseModel/test.js b/openecomp-ui/test/licenseModel/test.js index c21d18f146..eac1297f3e 100644 --- a/openecomp-ui/test/licenseModel/test.js +++ b/openecomp-ui/test/licenseModel/test.js @@ -1,57 +1,40 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; -import {cloneAndSet} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import LicenseModelCreationActionHelper from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js'; +import {LicenseModelPostFactory, LicenseModelDispatchFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; + describe('License Model Module Tests', function () { it('Add License Model', () => { const store = storeCreator(); deepFreeze(store.getState()); - const licenseModelPostRequest = deepFreeze({ - vendorName: 'vlm1', - description: 'string', - iconRef: 'icon' - }); + const licenseModelPostRequest = LicenseModelPostFactory.build(); - const licenseModelToAdd = deepFreeze({ - ...licenseModelPostRequest - }); + const licenseModelToAdd = LicenseModelDispatchFactory.build(); const licenseModelIdFromResponse = 'ADDED_ID'; - const licenseModelAfterAdd = deepFreeze({ - ...licenseModelToAdd, - id: licenseModelIdFromResponse - }); - - const expectedStore = cloneAndSet(store.getState(), 'licenseModelList', [licenseModelAfterAdd]); - - mockRest.addHandler('create', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-license-models/'); - expect(data).to.deep.equal(licenseModelPostRequest); - expect(options).to.equal(undefined); + + mockRest.addHandler('post', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-license-models/'); + expect(data).toEqual(licenseModelPostRequest); + expect(options).toEqual(undefined); return { value: licenseModelIdFromResponse }; @@ -59,8 +42,8 @@ describe('License Model Module Tests', function () { return LicenseModelCreationActionHelper.createLicenseModel(store.dispatch, { licenseModel: licenseModelToAdd - }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + }).then((response) => { + expect(response.value).toEqual(licenseModelIdFromResponse); }); }); }); diff --git a/openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js b/openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js new file mode 100644 index 0000000000..7231fe4abc --- /dev/null +++ b/openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js @@ -0,0 +1,33 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; + +import SubmitErrorResponse from 'nfvo-components/SubmitErrorResponse.jsx'; +import {SubmitErrorMessageFactory} from 'test-utils/factories/SubnitErrorMessageFactorie.js'; + +describe('SubmitErrorResponse test: ', function () { + it('basic render test', () => { + let props = { + validationResponse: SubmitErrorMessageFactory.build() + }; + + let view = TestUtils.renderIntoDocument(); + expect(view).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap b/openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap new file mode 100644 index 0000000000..f7df9763da --- /dev/null +++ b/openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap @@ -0,0 +1,686 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Storyshots ListEditor regular 1`] = ` +
    +
    +
    + List Editor +
    +
    +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`Storyshots ListEditor two columns 1`] = ` +
    +
    +
    + List Editor +
    +
    +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`Storyshots ListEditor with add 1`] = ` +
    +
    +
    + List Editor +
    +
    +
    + + + Add + +
    +
    +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    +
    +
    +`; + +exports[`Storyshots ListEditor with delete 1`] = ` +
    +
    +
    + List Editor +
    +
    +
    + + + Add + +
    +
    +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`Storyshots ListEditor with edit 1`] = ` +
    +
    +
    + List Editor +
    +
    +
    + + + Add + +
    +
    +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`Storyshots ListEditor with edit and delete 1`] = ` +
    +
    +
    + List Editor +
    +
    +
    + + + Add + +
    +
    +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    + + + + +
    +
    + + + + +
    +
    +
    +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    + Lorum Ipsum +
    +
    +
    +
    +
    + + + + +
    +
    + + + + +
    +
    +
    +
    +
    +
    +`; + +exports[`Storyshots SVGIcon icon 1`] = ` +
    + + + + +
    +`; + +exports[`Storyshots SVGIcon icon with label 1`] = ` +
    + + + + + locked + +
    +`; + +exports[`Storyshots SVGIcon locked clickable 1`] = ` +
    + + + + +
    +`; diff --git a/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js b/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js new file mode 100644 index 0000000000..2f377a3539 --- /dev/null +++ b/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js @@ -0,0 +1,89 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import {mount} from 'enzyme'; +import {cloneAndSet} from 'test-utils/Util.js'; +import ActivityLogView, {ActivityListItem} from 'nfvo-components/activity-log/ActivityLogView.jsx'; +import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; +import ActivityLogActionHelper from 'nfvo-components/activity-log/ActivityLogActionHelper.js'; +import {mapStateToProps} from 'nfvo-components/activity-log/ActivityLog.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import mockRest from 'test-utils/MockRest.js'; +import {ActivityLogStoreFactory} from 'test-utils/factories/activity-log/ActivityLogFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +describe('Activity Log Module Tests', function () { + const LICENSE_MODEL_ID = '555'; + const version = VersionControllerUtilsFactory.build().version; + + it('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('Loads Activity Log and renders into jsx', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + let ActivityLogList = ActivityLogStoreFactory.buildList(1); + const expectedStore = cloneAndSet(store.getState(), 'licenseModel.activityLog', ActivityLogList); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/activity-logs/${LICENSE_MODEL_ID}/versions/${version.id}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: ActivityLogList}; + }); + + return ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: LICENSE_MODEL_ID, versionId: version.id}).then(() => { + const state = store.getState(); + expect(state).toEqual(expectedStore); + const props = mapStateToProps(state); + expect(props.activities).toEqual(ActivityLogList); + const wrapper = mount(); + expect(wrapper).toBeTruthy(); + }); + }); + + it('Tests Activity Log filter and sorting abilities', () => { + const firstDate = new Date(); + const secondDate = new Date(); + secondDate.setDate(firstDate.getDate() - 1); + + const firstTimestamp = firstDate.getTime(); + const secondTimestamp = secondDate.getTime(); + + let firstActivity = ActivityLogStoreFactory.build({user: 'first', timestamp: firstTimestamp}); + let secondActivity = ActivityLogStoreFactory.build({user: 'second', timestamp: secondTimestamp, status: {success: false, message: 'error'}}); + let props = mapStateToProps({licenseModel: {activityLog: [firstActivity, secondActivity]}}); + const wrapper = mount(); + expect(wrapper.find(ActivityListItem).length).toEqual(3); // Includes Header component + + const firstInstance = wrapper.find(ActivityListItem).at(1); + const firstInstanceProps = firstInstance.props(); + expect(firstInstanceProps.activity.timestamp).toEqual(secondTimestamp); // Default sorting is descending + + const header = wrapper.find(ActivityListItem).at(0); + header.props().onSort(); + const newFirstInstance = wrapper.find(ActivityListItem).at(1); + const newFirstInstanceProps = newFirstInstance.props(); + expect(newFirstInstanceProps.activity.timestamp).toEqual(firstTimestamp); + + const listEditor = wrapper.find(ListEditorView); + listEditor.props().onFilter('second'); + expect(wrapper.find(ActivityListItem).length).toEqual(2); + expect(wrapper.find(ActivityListItem).at(1).props().activity.user).toEqual('second'); + }); +}); diff --git a/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js b/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js new file mode 100644 index 0000000000..e61261e09a --- /dev/null +++ b/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js @@ -0,0 +1,52 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import TabulatedEditor from 'nfvo-components/editor/TabulatedEditor.jsx'; + +describe('Tabulated Editor test: ', function () { + + it('basic view test', () => { + let renderer = TestUtils.createRenderer(); + renderer.render( + + ); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + }); + + it('handle func test', () => { + let props = { + navigationBarProps: { + groups: [], + onNavigationItemClick: ()=>{} + }, + versionControllerProps: { + isCheckedOut: false, + version: {id: '0.1', label: '0.1'}, + viewableVersions: [{id: '0.1', label: '0.1'}], + onSubmit: ()=>{}, + onRevert: ()=>{} + } + }; + const view = TestUtils.renderIntoDocument(); + expect(view).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js index eaa06eedf4..c578178d35 100644 --- a/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js +++ b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js @@ -1,24 +1,19 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx'; @@ -32,42 +27,62 @@ describe('dualListBox Module Tests', function () { var renderer = TestUtils.createRenderer(); renderer.render({}}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('should render with available list and 4 control buttons', () => { var view = TestUtils.renderIntoDocument({}}/>); - expect(view).toExist(); + expect(view).toBeTruthy(); var results = TestUtils.scryRenderedDOMComponentsWithClass(view, 'dual-list-option'); expect(results.length).toBe(4); }); it('should add item to selected list', done => { - const newItemValue = 'new item'; - let onChange = (value)=> { - expect(value).toEqual(newItemValue); + const onChange = (values)=> { + expect(values).toEqual([ITEMS[2].id, ITEMS[0].id]); done(); }; - var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]}); - expect(view).toExist(); - view.refs = { - availableValues: {getValue(){return newItemValue;}} - }; - view.addToSelectedList(); + const document = TestUtils.renderIntoDocument( + ); + + const result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'select'); + const options = TestUtils.scryRenderedDOMComponentsWithTag(document, 'option'); + const listBox = TestUtils.findRenderedComponentWithType(document, DualListboxView); + expect(result).toBeTruthy(); + expect(options).toBeTruthy(); + expect(listBox).toBeTruthy(); + + TestUtils.Simulate.change(result[0], {target: {selectedOptions: [options[0]]}}); + expect(listBox.state.selectedValues).toEqual([ITEMS[0].id]); + + listBox.addToSelectedList(); }); it('should remove item from selected list', done => { - const selectedValuesList = ['a','b']; - let onChange = (value)=> { - expect(value).toEqual(selectedValuesList[1]); + const onChange = (values)=> { + expect(values).toEqual([ITEMS[0].id]); done(); }; - var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList}); - expect(view).toExist(); - view.refs = { - selectedValues: {getValue(){return ['a'];}} - }; - view.removeFromSelectedList(); + const document = TestUtils.renderIntoDocument( + ); + + const result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'select'); + const options = TestUtils.scryRenderedDOMComponentsWithTag(document, 'option'); + const listBox = TestUtils.findRenderedComponentWithType(document, DualListboxView); + expect(result).toBeTruthy(); + expect(options).toBeTruthy(); + expect(listBox).toBeTruthy(); + + TestUtils.Simulate.change(result[1], {target: {selectedOptions: [options[2]]}}); + expect(listBox.state.selectedValues).toEqual([ITEMS[1].id]); + + listBox.removeFromSelectedList(); }); it('should add all items to selected list', done => { @@ -76,7 +91,7 @@ describe('dualListBox Module Tests', function () { done(); }; var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]}); - expect(view).toExist(); + expect(view).toBeTruthy(); view.addAllToSelectedList(); }); @@ -86,7 +101,7 @@ describe('dualListBox Module Tests', function () { done(); }; var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]}); - expect(view).toExist(); + expect(view).toBeTruthy(); view.removeAllFromSelectedList(); }); diff --git a/openecomp-ui/test/nfvo-components/input/validation/input.test.js b/openecomp-ui/test/nfvo-components/input/validation/input.test.js new file mode 100644 index 0000000000..7743483603 --- /dev/null +++ b/openecomp-ui/test/nfvo-components/input/validation/input.test.js @@ -0,0 +1,141 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; +import Input from 'nfvo-components/input/validation/Input.jsx'; +import Overlay from 'react-bootstrap/lib/Overlay.js'; + +describe('Input', function () { + it('should render with type text', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].type).toBe('text'); + }); + + it('should render with type textarea', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].tagName.toLowerCase()).toBe('textarea'); + }); + + it('should render with type radio', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].type).toBe('radio'); + }); + + it('should render with type select', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].tagName.toLowerCase()).toBe('select'); + }); + + it('should render with type number', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].tagName.toLowerCase()).toBe('input'); + expect(elem[0].type).toBe('number'); + }); + + it('should render with type checkbox', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(elem[0].tagName.toLowerCase()).toBe('input'); + expect(elem[0].type).toBe('checkbox'); + }); + + it('should render error overlay when invalid', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = TestUtils.findRenderedComponentWithType(renderedOutput,Overlay); + expect(elem).toBeTruthy(); + expect(elem.props.show).toBe(true); + }); + + it('should not render error overlay when valid', () => { + let renderedOutput = TestUtils.renderIntoDocument(); + const elem = TestUtils.findRenderedComponentWithType(renderedOutput,Overlay); + expect(elem).toBeTruthy(); + expect(elem.props.show).toBe(false); + }); + + /*it('should return the value of a select', () => { + + }); + + it('should return the value of a checkbox', () => { + + }); + + it('should return the value of a radio', () => { + + }); + + it('should return the value of a text', () => { + + }); + + it('should return the value of a textarea', () => { + + });*/ + + /*it('should render and work as a group', () => { + let MockComp = React.createClass({ + render: function() { + return (
    + +
    ); + } + }); + let renderedOutput = TestUtils.renderIntoDocument(); + const radio1 = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest'); + expect(radio1).toBeTruthy(); + expect(radio1.length).toBe(1); + expect(radio1[0].type).toBe('radio'); + expect(radio1[0].value).toBe('0'); + const radio2 = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest1'); + expect(radio2).toBeTruthy(); + expect(radio2.length).toBe(1); + expect(radio2[0].type).toBe('radio'); + expect(radio2[0].value).toBe('1'); + TestUtils.Simulate.click( + radio2[0] + ); + TestUtils.Simulate.click( + radio1[0] + ); + console.log('radio1: ' + radio1[0].checked); + console.log('radio2: ' + radio2[0].checked); + expect(radio2[0].checked).toBe(false); + expect(radio1[0].checked).toBe(true); + + + });*/ + +}); diff --git a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js index a3b098f611..c1f823c3fc 100644 --- a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js +++ b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js @@ -1,25 +1,21 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; +import {mount} from 'enzyme'; import TestUtils from 'react-addons-test-utils'; import ListEditorView from 'src/nfvo-components/listEditor/ListEditorView.jsx'; import ListEditorItemView from 'src/nfvo-components/listEditor/ListEditorItemView.jsx'; @@ -28,11 +24,11 @@ describe('listEditor Module Tests', function () { it('list editor view should exist', () => { - expect(ListEditorView).toExist(); + expect(ListEditorView).toBeTruthy(); }); it('list editor item view should exist', () => { - expect(ListEditorItemView).toExist(); + expect(ListEditorItemView).toBeTruthy(); }); it('should render list and list item and call onEdit', done => { @@ -43,22 +39,18 @@ describe('listEditor Module Tests', function () { ); - expect(itemView).toExist(); - let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders'); + expect(itemView).toBeTruthy(); + let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders'); TestUtils.Simulate.click(sliderIcon); }); - it('should render list and list item and call onFilter', done => { - let itemView = TestUtils.renderIntoDocument( - {done();}}> - -
    -
    -
    + it('should render list and list item and call onFilter', () => { + let itemView = mount( + {}} children={[()]} /> ); - expect(itemView).toExist(); - let filterInput = TestUtils.findRenderedDOMComponentWithTag(itemView, 'input'); - TestUtils.Simulate.change(filterInput); + expect(itemView).toBeTruthy(); + let inputComponent = itemView.find('ExpandableInput'); + expect(inputComponent.length).toBe(1); }); it('should render READONLY list item and not call onEdit', done => { @@ -67,8 +59,8 @@ describe('listEditor Module Tests', function () {
    ); - expect(itemView).toExist(); - let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders'); + expect(itemView).toBeTruthy(); + let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders'); TestUtils.Simulate.click(sliderIcon); }); @@ -78,8 +70,8 @@ describe('listEditor Module Tests', function () {
    ); - expect(itemView).toExist(); - let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-trash-o'); + expect(itemView).toBeTruthy(); + let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'trash-o'); TestUtils.Simulate.click(sliderIcon); }); @@ -89,8 +81,8 @@ describe('listEditor Module Tests', function () {
    ); - expect(itemView).toExist(); - let sliderIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o'); - expect(sliderIcon).toEqual(0); + expect(itemView).toBeTruthy(); + let trashIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o'); + expect(trashIcon).toEqual([]); }); }); diff --git a/openecomp-ui/test/nfvo-components/modal/globalModal.test.js b/openecomp-ui/test/nfvo-components/modal/globalModal.test.js new file mode 100644 index 0000000000..efe43b6c37 --- /dev/null +++ b/openecomp-ui/test/nfvo-components/modal/globalModal.test.js @@ -0,0 +1,92 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 GlobalModal, {GlobalModalView, mapStateToProps} from 'src/nfvo-components/modal/GlobalModal.js'; +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import store from 'sdc-app/AppStore.js'; +import {actionTypes, typeEnum} from 'src/nfvo-components/modal/GlobalModalConstants.js'; + +const title = 'TITLE'; +const msg = 'message'; + +describe('Global Modal tests: ', function () { + it (' mapStateToProps exists', function () { + expect(mapStateToProps).toBeTruthy(); + }); + + it ('mapStateToProps should return show as true', () => { + let state = { + modal: { + type: '' + } + }; + let props = mapStateToProps(state); + expect(props.show).toEqual(true); + }); + + it('modal should show with default values', () => { + store.dispatch({ + type: actionTypes.GLOBAL_MODAL_SHOW, + data: { + title, + msg + } + }); + const modal = store.getState().modal; + expect(modal).toBeTruthy(); + expect(modal.title).toBe(title); + expect(modal.msg).toBe(msg); + }); + + it('global modal should show with type success with connected component', () => { + store.dispatch({type: actionTypes.GLOBAL_MODAL_SHOW, data: {title, msg}}); + + expect(store.getState().modal).toBeTruthy(); + + let renderer = TestUtils.createRenderer(); + renderer.render(); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + }); + + + it('global modal should show with type success with connected component and closed after', () => { + store.dispatch({type: actionTypes.GLOBAL_MODAL_SHOW, data: {title, msg}}); + + expect(store.getState().modal).toBeTruthy(); + + let renderer = TestUtils.createRenderer(); + renderer.render(); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + store.dispatch({type: actionTypes.GLOBAL_MODAL_CLOSE}); + expect(store.getState().modal).toBe(null); + }); + + + it('checking component default render', ()=> { + expect(window.document).toBeTruthy(); + let globalModalView = TestUtils.renderIntoDocument( + {}} /> + ); + expect(globalModalView).toBeTruthy(); + }); + +}); + diff --git a/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js b/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js deleted file mode 100644 index f84d38246d..0000000000 --- a/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js +++ /dev/null @@ -1,144 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import expect from 'expect'; -import React from 'react'; -import TestUtils from 'react-addons-test-utils'; -import store from 'sdc-app/AppStore.js'; -import ConnectedNotificationModal, {NotificationModal} from 'nfvo-components/notifications/NotificationModal.jsx'; -import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js'; - -const title = 'test title'; -const msg = 'test msg'; - -describe('Notification Modal Mapper and View Class: ', function () { - - it('notification should show with type error', done => { - store.dispatch({type: NotificationConstants.NOTIFY_ERROR, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('error'); - done(); - }, 0); - }); - - it('notification should show with type default', done => { - store.dispatch({type: NotificationConstants.NOTIFY_INFO, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('default'); - done(); - }, 0); - }); - - it('notification should show with type warning', done => { - store.dispatch({type: NotificationConstants.NOTIFY_WARNING, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('warning'); - done(); - }, 0); - }); - - it('notification should show with type success', done => { - store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('success'); - done(); - }, 0); - }); - - it('notification should show with type success with connected component', done => { - store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}}); - setTimeout(()=> { - expect(store.getState().notification).toExist(); - expect(store.getState().notification.type).toBe('success'); - let renderer = TestUtils.createRenderer(); - renderer.render(); - let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); - done(); - }, 0); - }); - - it('notification should hide with connected component', done => { - setTimeout(()=> { - expect(store.getState().notification).toNotExist(); - let renderer = TestUtils.createRenderer(); - renderer.render(); - let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); - done(); - }, 0); - store.dispatch({type: NotificationConstants.NOTIFY_CLOSE}); - }); - - it('notification should hide', done => { - store.dispatch({type: NotificationConstants.NOTIFY_CLOSE}); - setTimeout(()=> { - expect(store.getState().notification).toNotExist(); - done(); - }, 0); - }); - - it('NotificationModal should not render', ()=> { - let renderer = TestUtils.createRenderer(); - renderer.render(); - let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); - }); - - it('NotificationModal basic default render', ()=> { - expect(window.document).toExist(); - let document = TestUtils.renderIntoDocument( - {}}/> - ); - var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal primary'); - expect(result.length).toBeGreaterThan(0); - }); - - it('NotificationModal basic error render', ()=> { - expect(window.document).toExist(); - let document = TestUtils.renderIntoDocument( - {}}/> - ); - var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal danger'); - expect(result.length).toBeGreaterThan(0); - }); - - it('NotificationModal basic warning render', ()=> { - expect(window.document).toExist(); - let document = TestUtils.renderIntoDocument( - {}}/> - ); - var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal warning'); - expect(result.length).toBeGreaterThan(0); - }); - - it('NotificationModal basic success render', ()=> { - expect(window.document).toExist(); - let document = TestUtils.renderIntoDocument( - {}}/> - ); - var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal success'); - expect(result.length).toBeGreaterThan(0); - }); -}); diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js index 9ab18137cf..8f2b7e7e88 100644 --- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js +++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js @@ -1,43 +1,152 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; + import React from 'react'; + import TestUtils from 'react-addons-test-utils'; +import {mount} from 'enzyme'; import VersionController from 'nfvo-components/panel/versionController/VersionController.jsx'; -import {actionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import {actionsEnum, statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('versionController UI Component', () => { + let onSave, onClose, onVersionSwitching = onSave = onClose = () => {return Promise.resolve();}; + const versionData = VSPComponentsVersionControllerFactory.build(); + const isFormDataValid = true; + const viewableVersions = versionData.viewableVersions; + const version = versionData.version; + const props = {onSave, onClose, isFormDataValid, viewableVersions, version, onVersionSwitching}; it('function does exist', () => { var renderer = TestUtils.createRenderer(); - renderer.render(); + renderer.render(); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('validating checkin function', () => { - - let versionController = TestUtils.renderIntoDocument({return Promise.resolve();}}/>); + let versionController = TestUtils.renderIntoDocument(); let cb = action => expect(action).toBe(actionsEnum.CHECK_IN); versionController.checkin(cb); + }); + + it('validating checkout function', () => { + let versionController = TestUtils.renderIntoDocument(); + let cb = action => expect(action).toBe(actionsEnum.CHECK_OUT); + versionController.checkout(cb); + }); + + it('validating submit function', () => { + let versionController = TestUtils.renderIntoDocument(); + let cb = action => expect(action).toBe(actionsEnum.SUBMIT); + versionController.submit(cb); + }); + + it('validating revert function', () => { + let versionController = TestUtils.renderIntoDocument(); + let cb = action => expect(action).toBe(actionsEnum.UNDO_CHECK_OUT); + versionController.revertCheckout(cb); + }); + + it('does not show the save button when no onSave available', () => { + let noSaveProps = {...props, onSave: null }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-save-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(0); + }); + + it('does not show the submit button when no callVCAction available', () => { + let callVCActionProps = {...props, callVCAction: null}; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-submit-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(0); + }); + + it('does not show the revert button when no callVCAction available', () => { + let callVCActionProps = {...props, callVCAction: null}; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-revert-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(0); + }); + + it('Shows the save button when onSave available', () => { + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-save-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('Shows the submit button when callVCAction available', () => { + let callVCActionProps = { ...props, callVCAction: function(){} }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-submit-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('Shows the revert button when callVCAction available', () => { + let callVCActionProps = { ...props, callVCAction: function(){} }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-revert-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('Shows the checkin button', () => { + let callVCActionProps = { ...props, callVCAction: function(){} }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-checkout-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + }); + + it('Shows the checkout button', () => { + let callVCActionProps = { ...props, callVCAction: function(){} }; + let versionController = TestUtils.renderIntoDocument(); + let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-checkout-btn'); + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + + }); + + it('Doesn\'t show the checkin button for prev version', () => { + let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} }; + let versionController = mount(); + let elem = versionController.find('[data-test-id="vc-checkout-btn"]'); + let svgIcon = versionController.find('.version-controller-lock-closed'); + + expect(elem).toBeTruthy(); + expect(elem.length).toEqual(1); + expect(svgIcon.hasClass('disabled')).toBe(true); + }); + + it('Doesn\'t show the checkout button', () => { + let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} }; + let versionController = mount(); + let elem = versionController.find('[data-test-id="vc-checkout-btn"]'); + let svgIcon = versionController.find('.version-controller-lock-closed'); + + expect(elem).toBeTruthy(); + expect(elem.length).toBe(1); + expect(svgIcon.hasClass('disabled')).toBe(true); }); diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js index 0e4a92118e..d654e16ddf 100644 --- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js +++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js @@ -1,41 +1,38 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; -import deepFreeze from 'deep-freeze'; + import Configuration from 'sdc-app/config/Configuration.js'; import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js'; import {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; const status = 'testStatus'; +const {lockingUser: currentUser, viewableVersions: defaultVersions} = VersionControllerUtilsFactory.build(); describe('versionController UI Component', () => { it('function does exist', () => { - expect(VersionControllerUtils).toExist(); + expect(VersionControllerUtils).toBeTruthy(); }); it('validating getCheckOutStatusKindByUserID - without "UserID"', () => { var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status); expect(result.status).toBe(status); - expect(result.isCheckedOut).toBe(true); + expect(result.isCheckedOut).toBe(false); }); it('validating getCheckOutStatusKindByUserID - without "UserID" with locking user', () => { @@ -45,12 +42,11 @@ describe('versionController UI Component', () => { }); it('validating getCheckOutStatusKindByUserID - with "UserID" with configuration set', () => { - const userId = 'att'; - - Configuration.set('ATTUserID', userId); - var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, userId); - Configuration.set('ATTUserID', undefined); + const Uid = 'ecomp'; + Configuration.set('UserID', Uid); + var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, Uid); + Configuration.set('UserID', undefined); expect(result.status).toBe(status); expect(result.isCheckedOut).toBe(true); }); @@ -58,48 +54,31 @@ describe('versionController UI Component', () => { it('validating isCheckedOutByCurrentUser - when resource is not checked out', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Final' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build({status: statusEnum.SUBMIT_STATUS}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(false); }); it('validating isCheckedOutByCurrentUser - when resource is checked out', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'current' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build(); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(true); }); it('validating isCheckedOutByCurrentUser - when resource is checked out by another user', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'another' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build({lockingUser: 'another'}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(false); }); @@ -107,66 +86,43 @@ describe('versionController UI Component', () => { it('validating isReadOnly - when resource is not checked out', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Final' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build({status: statusEnum.SUBMIT_STATUS}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isReadOnly(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(true); }); it('validating isReadOnly - when resource is checked out', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'current' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build(); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isReadOnly(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(false); }); it('validating isReadOnly - when version of resource is not latest', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.2', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'current' - }); - - Configuration.set('ATTUserID', currentUser); + + const resource = VersionControllerUtilsFactory.build({version: defaultVersions[defaultVersions.length - 2]}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isReadOnly(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(true); }); it('validating isReadOnly - when resource is checked out by another user', () => { - const currentUser = 'current'; - const resource = deepFreeze({ - version: '0.6', - viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'], - status: 'Locked', - lockingUser: 'another' - }); - - Configuration.set('ATTUserID', currentUser); + const resource = VersionControllerUtilsFactory.build({lockingUser: 'another'}); + + Configuration.set('UserID', currentUser); const result = VersionControllerUtils.isReadOnly(resource); - Configuration.set('ATTUserID', undefined); + Configuration.set('UserID', undefined); expect(result).toBe(true); }); }); - diff --git a/openecomp-ui/test/nfvo-components/storyshots.test.js b/openecomp-ui/test/nfvo-components/storyshots.test.js new file mode 100644 index 0000000000..4d1bdbede0 --- /dev/null +++ b/openecomp-ui/test/nfvo-components/storyshots.test.js @@ -0,0 +1,2 @@ +import initStoryshots from 'storyshots'; +initStoryshots(); \ No newline at end of file diff --git a/openecomp-ui/test/onboard/onboardingCatalog/test.js b/openecomp-ui/test/onboard/onboardingCatalog/test.js new file mode 100644 index 0000000000..cc54e3199e --- /dev/null +++ b/openecomp-ui/test/onboard/onboardingCatalog/test.js @@ -0,0 +1,63 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {storeCreator} from 'sdc-app/AppStore.js'; +import {OnboardingCatalogStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js'; +import {LicenseModelStoreFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js'; +import {tabsMapping} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; + + +describe('Onboarding Catalog Module Tests', () => { + it('should return default state', () => { + const store = storeCreator(); + const expectedStore = OnboardingCatalogStoreFactory.build(); + expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore); + }); + + it('should change active tab to All', () => { + const store = storeCreator(); + const expectedStore = OnboardingCatalogStoreFactory.build({activeTab: tabsMapping.ALL}); + OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, tabsMapping.ALL); + expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore); + }); + + + it('should change VSP Overlay', () => { + const vendor = LicenseModelStoreFactory.build(); + const store = storeCreator(); + const expectedStore = OnboardingCatalogStoreFactory.build({vendorCatalog: {vspOverlay: vendor.id}}); + OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, vendor); + expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore); + }); + + it('should close VSP Overlay', () => { + const vendor = LicenseModelStoreFactory.build(); + const store = storeCreator(); + const expectedStore = OnboardingCatalogStoreFactory.build({vendorCatalog: {vspOverlay: null}}); + OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, vendor); + OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, null); + expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore); + }); + + it('should select vendor', () => { + const vendor = LicenseModelStoreFactory.build(); + const store = storeCreator(); + const expectedStore = OnboardingCatalogStoreFactory.build({vendorCatalog: {selectedVendor: vendor}}); + OnboardingCatalogActionHelper.onVendorSelect(store.dispatch, {vendor}); + expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore); + }); + +}); diff --git a/openecomp-ui/test/onboard/onboardingCatalog/views.test.js b/openecomp-ui/test/onboard/onboardingCatalog/views.test.js new file mode 100644 index 0000000000..fb038eb680 --- /dev/null +++ b/openecomp-ui/test/onboard/onboardingCatalog/views.test.js @@ -0,0 +1,143 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js'; +import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {mapStateToProps} from 'sdc-app/onboarding/onboard/Onboard.js'; +import OnboardingCatalogView from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx'; +import VendorItem from 'sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx'; +import VSPOverlay from 'sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx'; +import CatalogItemDetails from 'sdc-app/onboarding/onboard/CatalogItemDetails.jsx'; +import DetailsCatalogView from 'sdc-app/onboarding/onboard/DetailsCatalogView.jsx'; + +describe('OnBoarding Catalog test - View: ', function () { + + + it('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('mapStateToProps data test', () => { + + const licenseModelList = FinalizedLicenseModelFactory.buildList(3); + const softwareProductList = VSPEditorFactory.buildList(4); + const data = defaultStoreFactory.build({licenseModelList, softwareProductList}); + + var results = mapStateToProps(data); + expect(results.softwareProductList).toBeTruthy(); + expect(results.licenseModelList).toBeTruthy(); + expect(results.activeTab).toBeTruthy(); + expect(results.licenseModelList.length).toEqual(3); + }); + + it('licenseModelList creating algorithm test', () => { + + const finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3); + const licenseModelList = [...finalizedLicenseModelList]; + const finalizedSoftwareProductList = VSPEditorFactory.buildList(4 ,{vendorId: finalizedLicenseModelList[0].id}); + const softwareProductList = [...finalizedSoftwareProductList]; + const data = defaultStoreFactory.build({licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList}); + + var results = mapStateToProps(data); + expect(results.finalizedLicenseModelList[0].softwareProductList.length).toEqual(finalizedSoftwareProductList.length); + }); + + + it('Catalog view test', () => { + + const dummyFunc = () => {}; + const licenseModelList = FinalizedLicenseModelFactory.buildList(3); + const softwareProductList = VSPEditorFactory.buildList(4 ,{vendorId: licenseModelList[0].id}); + const data = defaultStoreFactory.build({licenseModelList, softwareProductList}); + + const func = { + onAddLicenseModelClick: dummyFunc, + onAddSoftwareProductClick: dummyFunc, + closeVspOverlay: dummyFunc, + onVspOverlayChange: dummyFunc, + onTabClick: dummyFunc, + onSearch: dummyFunc, + onSelectLicenseModel: dummyFunc, + onSelectSoftwareProduct: dummyFunc, + resetOnboardingCatalogStore: '' + }; + + let params = {...func, ...mapStateToProps(data)}; + let CatalogView = TestUtils.renderIntoDocument(); + expect(CatalogView).toBeTruthy(); + }); + + it('VendorItem view test', () => { + let vendor = FinalizedLicenseModelFactory.build(); + const dummyFunc = () => {}; + let params = { + softwareProductList: VSPEditorFactory.buildList(4 ,{vendorId: vendor.id}), + vendor, + onSelectVSP: dummyFunc, + shouldShowOverlay: false, + onVendorSelect: dummyFunc, + onAddVSP: dummyFunc, + onVSPIconClick: dummyFunc, + }; + + let VendorItemView = TestUtils.renderIntoDocument(); + expect(VendorItemView).toBeTruthy(); + }); + + + it('VSPOverlay view test', () => { + + let params = { + VSPList: VSPEditorFactory.buildList(10 ,{vendorId: '1'}), + onSelectVSP: () => {} + }; + + let VSPOverlayView = TestUtils.renderIntoDocument(
    ); + expect(VSPOverlayView).toBeTruthy(); + }); + + it('CatalogItemDetails view test', () => { + + let params = { + catalogItemData: FinalizedLicenseModelFactory.build(), + onSelect: () => {}, + catalogItemTypeClass: '' + }; + + let CatalogItemDetailsView = TestUtils.renderIntoDocument(
    ); + expect(CatalogItemDetailsView).toBeTruthy(); + }); + + it('DetailsCatalogView view test', () => { + + let params = { + VLMList: FinalizedLicenseModelFactory.buildList(3), + VSPList: VSPEditorFactory.buildList(4), + onSelectVLM: () => {}, + onSelectVSP: () => {}, + onAddVLM: () => {}, + onAddVSP: () => {}, + filter: '' + }; + + let AllCatalog = TestUtils.renderIntoDocument(); + expect(AllCatalog).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/onboard/test.js b/openecomp-ui/test/onboard/test.js new file mode 100644 index 0000000000..18bb042aea --- /dev/null +++ b/openecomp-ui/test/onboard/test.js @@ -0,0 +1,62 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 {storeCreator} from 'sdc-app/AppStore.js'; +import {OnboardStoreFactory} from 'test-utils/factories/onboard/OnboardFactories.js'; +import OnboardActionHelper from 'sdc-app/onboarding/onboard/OnboardActionHelper.js'; +import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js'; +import {tabsMapping as onboardTabsMapping} from 'sdc-app/onboarding/onboard/OnboardConstants.js'; +import {tabsMapping as onboardCatalogTabsMapping} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; + +describe('Onboard Module Tests', () => { + it('should return default state', () => { + const store = storeCreator(); + const expectedStore = OnboardStoreFactory.build(); + expect(store.getState().onboard).toEqual(expectedStore); + }); + + it('should change active tab to Catalog', () => { + const store = storeCreator(); + const expectedStore = OnboardStoreFactory.build({activeTab: onboardTabsMapping.CATALOG}); + OnboardActionHelper.changeActiveTab(store.dispatch, onboardTabsMapping.CATALOG); + expect(store.getState().onboard).toEqual(expectedStore); + }); + + it('should change searchValue', () => { + const store = storeCreator(); + const expectedStore = OnboardStoreFactory.build({searchValue: 'hello'}); + OnboardActionHelper.changeSearchValue(store.dispatch, 'hello'); + expect(store.getState().onboard).toEqual(expectedStore); + }); + + it('should clear searchValue', () => { + const store = storeCreator(); + const expectedStore = OnboardStoreFactory.build(); + OnboardActionHelper.changeSearchValue(store.dispatch, 'hello'); + OnboardActionHelper.clearSearchValue(store.dispatch); + expect(store.getState().onboard).toEqual(expectedStore); + }); + + it('should reset store', () => { + const store = storeCreator(); + const expectedStore = OnboardStoreFactory.build(); + OnboardActionHelper.changeSearchValue(store.dispatch, 'hello'); + OnboardActionHelper.changeActiveTab(store.dispatch, onboardTabsMapping.CATALOG); + OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, onboardCatalogTabsMapping.ALL); + OnboardActionHelper.resetOnboardStore(store.dispatch, 'hello'); + expect(store.getState().onboard).toEqual(expectedStore); + }); + +}); diff --git a/openecomp-ui/test/setup.test.js b/openecomp-ui/test/setup.test.js deleted file mode 100644 index 72f8b954b8..0000000000 --- a/openecomp-ui/test/setup.test.js +++ /dev/null @@ -1,25 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import mockRest from 'test-utils/MockRest.js'; - -beforeEach(function() { - mockRest.resetQueue(); -}); diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js index 839176c970..5dfe98f273 100644 --- a/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js +++ b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js @@ -1,198 +1,76 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; -import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js'; +import {VSPAttachmentTreeNodeWithChildrenFactory, VSPAttachmentDetailedError} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js'; +import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js'; import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import {tabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; - -describe('SoftwareProductAttachments Modal Mapper and View Classes', () => { - - it ('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); +describe('SoftwareProduct Attachments - View: ', function () { + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); }); + it('should mapper return default data', () => { - it ('mapStateToProps check data', () => { + let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build(); + let errorList = VSPAttachmentDetailedError.buildList(3); + let versionControllerData = VersionControllerUtilsFactory.build(); - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; - const atTree = { - 'children': [ - { - 'name': 'HEAT', - 'expanded': true, - 'type': 'heat', - 'children': [ - { - 'name': 'heat_zxeyCtMHhf2.yaml', - 'expanded': true, - 'type': 'heat', - 'errors': [ - { - 'level': 'WARNING', - 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' - } - ], - 'children': [ - { - 'name': 'heat_env_zxeyCtMHhf2.env', - 'type': 'env' - } - ] - } - ] - } - ] - }; - const errorList = [ - { - 'errorLevel': 'WARNING', - 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', - 'name': 'heat_zxeyCtMHhf2.yaml', - 'hasParent': false, - 'parentName': 'HEAT', - 'type': 'heat' + let softwareProductAttachments = { + heatSetup: {}, + heatValidation: { + attachmentsTree, + errorList }, - { - 'errorLevel': 'WARNING', - 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', - 'name': 'heat_zxeyCtMHhf2.yaml', - 'hasParent': false, - 'parentName': 'HEAT', - 'type': 'heat' - } - ]; - - var obj = { - softwareProduct: { - softwareProductEditor: { - data:currentSoftwareProduct - }, softwareProductAttachments: - { - attachmentsTree: atTree, - errorList: errorList - } - } + heatSetupCache: {}, + activeTab: tabsMapping.SETUP }; - - var results = mapStateToProps(obj); - expect(results.attachmentsTree).toExist(); - expect(results.errorList).toExist(); - expect(results.hoveredNode).toBe(undefined); - expect(results.selectedNode).toBe(undefined); + let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}}); + var result = mapStateToProps(data); + expect(result).toBeTruthy(); + expect(result.isValidationAvailable).toBe(false); }); + it('view test', () => { - it('function does exist', () => { + let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build(); + let errorList = VSPAttachmentDetailedError.buildList(3); + let versionControllerData = VersionControllerUtilsFactory.build(); - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; - const versionControllerData = { - version: currentSoftwareProduct.version, - viewableVersions:currentSoftwareProduct.viewableVersions, - status: currentSoftwareProduct.status, - isCheckedOut: true - }; - const atTree = { - 'children': [ - { - 'name': 'HEAT', - 'expanded': true, - 'type': 'heat', - 'children': [ - { - 'name': 'heat_zxeyCtMHhf2.yaml', - 'expanded': true, - 'type': 'heat', - 'errors': [ - { - 'level': 'WARNING', - 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' - } - ], - 'children': [ - { - 'name': 'heat_env_zxeyCtMHhf2.env', - 'type': 'env' - } - ] - } - ] - } - ] - }; - const errorList = [ - { - 'errorLevel': 'WARNING', - 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', - 'name': 'heat_zxeyCtMHhf2.yaml', - 'hasParent': false, - 'parentName': 'HEAT', - 'type': 'heat' + let softwareProductAttachments = { + heatSetup: {}, + heatValidation: { + attachmentsTree, + errorList }, - { - 'errorLevel': 'WARNING', - 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', - 'name': 'heat_zxeyCtMHhf2.yaml', - 'hasParent': false, - 'parentName': 'HEAT', - 'type': 'heat' - } - ]; - + shouldOpenValidationTab: false + }; + let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}}); + var params = mapStateToProps(data); var renderer = TestUtils.createRenderer(); - renderer.render(); + renderer.render(); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); }); diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js deleted file mode 100644 index 851560caa8..0000000000 --- a/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import expect from 'expect'; -import SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js'; -import {storeCreator} from 'sdc-app/AppStore.js'; -import deepFreeze from 'deep-freeze'; -import {actionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; - - - - - - -describe('SoftwareProductAttachments ActionHelper', () => { - - it('function does exist', () => { - expect(SoftwareProductAttachmentsActionHelper).toExist(); - }); - - it('toggleExpanded function check', () => { - - - const validationData = { - importStructure: { - HEAT: [ - { - fileName: 'hot-mog-0108-bs1271.yml', - env: { - fileName: 'hot-mog-0108-bs1271.env' - }, - errors: [ - { - 'level': 'WARNING', - 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]' - }, - { - 'level': 'WARNING', - 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]' - } - ] - } - ] - } - }; - - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: 'Locked', - lockingUser: 'cs0008', - validationData - }; - - - const store = storeCreator(); - deepFreeze(store.getState()); - deepFreeze(currentSoftwareProduct); - - store.dispatch({ - type:actionTypes.SOFTWARE_PRODUCT_LOADED, - response: currentSoftwareProduct - }); - - expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(true); - SoftwareProductAttachmentsActionHelper.toggleExpanded(store.dispatch, {path:[0]}); - expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(false); - }); - - it('onSelectNode & onUnselectNode function check', () => { - - - const validationData = { - importStructure: { - HEAT: [ - { - fileName: 'hot-mog-0108-bs1271.yml', - env: { - fileName: 'hot-mog-0108-bs1271.env' - }, - errors: [ - { - 'level': 'WARNING', - 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]' - }, - { - 'level': 'WARNING', - 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]' - } - ] - } - ] - } - }; - - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: 'Locked', - lockingUser: 'cs0008', - validationData - }; - - deepFreeze(currentSoftwareProduct); - - const store = storeCreator(); - deepFreeze(store.getState()); - - store.dispatch({ - type:actionTypes.SOFTWARE_PRODUCT_LOADED, - response: currentSoftwareProduct - }); - let expectedNodeName = 'name'; - expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined); - SoftwareProductAttachmentsActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName}); - expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(expectedNodeName); - SoftwareProductAttachmentsActionHelper.onUnselectNode(store.dispatch); - expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined); - }); - - -}); diff --git a/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js new file mode 100644 index 0000000000..80e9401f1a --- /dev/null +++ b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js @@ -0,0 +1,49 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; + +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetup.js'; +import HeatSetupView from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx'; +import {storeCreator} from 'sdc-app/AppStore.js'; + +describe('Heat Setup View test: ', function () { + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should mapper return basic data', () => { + + const store = storeCreator(); + + var result = mapStateToProps(store.getState()); + expect(result).toBeTruthy(); + expect(result.modules.length).toEqual(0); + expect(result.unassigned.length).toEqual(0); + expect(result.artifacts.length).toEqual(0); + expect(result.nested.length).toEqual(0); + }); + + it('view test', () => { + + const store = storeCreator(); + + var params = mapStateToProps(store.getState()); + + let heatSetupView = TestUtils.renderIntoDocument(); + expect(heatSetupView).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js new file mode 100644 index 0000000000..99bbfeac11 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js @@ -0,0 +1,142 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 HeatSetupActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import deepFreeze from 'deep-freeze'; +import {heatSetupManifest} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js'; +import {actionTypes as HeatSetupActions, fileTypes as HeatSetupFileTypes} from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js'; + +describe('Heat Setup Action Helper test', () => { + + it('function does exist', () => { + expect(HeatSetupActionHelper).toBeTruthy(); + }); + + it('manifest load test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.nested.length).toBe(manifest.nested.length); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned.length).toBe(manifest.unassigned.length); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts.length).toBe(manifest.artifacts.length); + + }); + + it('add module action test', () => { + const store = storeCreator(); + deepFreeze(store.getState()); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length); + HeatSetupActionHelper.addModule(store.dispatch); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length + 1); + + }); + + it('delete module action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + HeatSetupActionHelper.deleteModule(store.dispatch, manifest.modules[0].name); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length - 1); + + }); + + it('rename module action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + const newName = 'newName'; + HeatSetupActionHelper.renameModule(store.dispatch, {oldName: manifest.modules[0].name, newName}); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules[0].name).toBe(newName); + + }); + + it('change module type action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + const newValue = 'newvalue.env'; + HeatSetupActionHelper.changeModuleFileType(store.dispatch, + { + module: manifest.modules[0], + value: {value: newValue}, + type: HeatSetupFileTypes.ENV.label + }); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules[0].env).toBe(newValue); + }); + + it('change artifacts list action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + const artifacts = store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts; + const newArtifacts = [...artifacts, manifest.unassigned[0]].map(str => (typeof str === 'string' ? {value: str, label: str} : str));; + HeatSetupActionHelper.changeArtifactList(store.dispatch, newArtifacts); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts[1]).toBe(manifest.unassigned[0]); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned.length).toBe(manifest.unassigned.length - 1); + }); + + it('add All Unassigned Files To Artifacts action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + const artifacts = store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts; + const unassigned = store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned; + const newArtifacts = [...artifacts, ...unassigned]; + HeatSetupActionHelper.addAllUnassignedFilesToArtifacts(store.dispatch, true); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts).toEqual(newArtifacts); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned).toEqual([]); + }); + +}); diff --git a/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js new file mode 100644 index 0000000000..d8a5d1fad6 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js @@ -0,0 +1,144 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 HeatValidationActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import deepFreeze from 'deep-freeze'; +import {actionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import {nodeFilters} from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js'; + +describe('HeatValidationActionHelper ActionHelper', () => { + + it('function does exist', () => { + expect(HeatValidationActionHelper).toBeTruthy(); + }); + + it('toggleExpanded function check', () => { + + + const validationData = { + importStructure: { + HEAT: [ + { + fileName: 'hot-mog-0108-bs1271.yml', + env: { + fileName: 'hot-mog-0108-bs1271.env' + }, + errors: [ + { + 'level': 'WARNING', + 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]' + }, + { + 'level': 'WARNING', + 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]' + } + ] + } + ] + } + }; + + const currentSoftwareProduct = { + name: 'VSp', + description: 'dfdf', + vendorName: 'V1', + vendorId: '97B3E2525E0640ACACF87CE6B3753E80', + category: 'resourceNewCategory.application l4+', + subCategory: 'resourceNewCategory.application l4+.database', + id: 'D4774719D085414E9D5642D1ACD59D20', + version: '0.10', + viewableVersions: ['0.1', '0.2'], + status: 'Locked', + lockingUser: 'cs0008', + validationData + }; + + + const store = storeCreator(); + deepFreeze(store.getState()); + deepFreeze(currentSoftwareProduct); + + store.dispatch({ + type:actionTypes.SOFTWARE_PRODUCT_LOADED, + response: currentSoftwareProduct + }); + + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.attachmentsTree.children[0].expanded).toBe(true); + HeatValidationActionHelper.toggleExpanded(store.dispatch, {path:[0]}); + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.attachmentsTree.children[0].expanded).toBe(false); + }); + + it('onSelectNode & onUnselectNode function check', () => { + + + const validationData = { + importStructure: { + heat: [ + { + fileName: 'hot-mog-0108-bs1271.yml', + env: { + fileName: 'hot-mog-0108-bs1271.env' + }, + errors: [ + { + 'level': 'WARNING', + 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]' + }, + { + 'level': 'WARNING', + 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]' + } + ] + } + ] + } + }; + + const currentSoftwareProduct = { + name: 'VSp', + description: 'dfdf', + vendorName: 'V1', + vendorId: '97B3E2525E0640ACACF87CE6B3753E80', + category: 'resourceNewCategory.application l4+', + subCategory: 'resourceNewCategory.application l4+.database', + id: 'D4774719D085414E9D5642D1ACD59D20', + version: '0.10', + viewableVersions: ['0.1', '0.2'], + status: 'Locked', + lockingUser: 'cs0008', + validationData + }; + + deepFreeze(currentSoftwareProduct); + + const store = storeCreator(); + deepFreeze(store.getState()); + + store.dispatch({ + type:actionTypes.SOFTWARE_PRODUCT_LOADED, + response: currentSoftwareProduct + }); + let expectedNodeName = 'name'; + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(nodeFilters.ALL); + HeatValidationActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName}); + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(expectedNodeName); + HeatValidationActionHelper.onDeselectNode(store.dispatch); + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(nodeFilters.ALL); + }); + + +}); diff --git a/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js new file mode 100644 index 0000000000..a5ba297d2b --- /dev/null +++ b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js @@ -0,0 +1,184 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidation.js'; + +import HeatValidationView from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx'; +import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + + +describe('SoftwareProductAttachments Modal Mapper and View Classes', () => { + + it ('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + + it ('mapStateToProps check data', () => { + + const currentSoftwareProduct = { + name: 'VSp', + description: 'dfdf', + vendorName: 'V1', + vendorId: '97B3E2525E0640ACACF87CE6B3753E80', + category: 'resourceNewCategory.application l4+', + subCategory: 'resourceNewCategory.application l4+.database', + id: 'D4774719D085414E9D5642D1ACD59D20', + version: '0.10', + viewableVersions: ['0.1', '0.2'], + status: versionStatusEnum.CHECK_OUT_STATUS, + lockingUser: 'cs0008' + }; + const atTree = { + 'children': [ + { + 'name': 'HEAT', + 'expanded': true, + 'type': 'heat', + 'children': [ + { + 'name': 'heat_zxeyCtMHhf2.yaml', + 'expanded': true, + 'type': 'heat', + 'errors': [ + { + 'level': 'WARNING', + 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' + } + ], + 'children': [ + { + 'name': 'heat_env_zxeyCtMHhf2.env', + 'type': 'env' + } + ] + } + ] + } + ] + }; + const errorList = [ + { + 'errorLevel': 'WARNING', + 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', + 'name': 'heat_zxeyCtMHhf2.yaml', + 'hasParent': false, + 'parentName': 'HEAT', + 'type': 'heat' + }, + { + 'errorLevel': 'WARNING', + 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', + 'name': 'heat_zxeyCtMHhf2.yaml', + 'hasParent': false, + 'parentName': 'HEAT', + 'type': 'heat' + } + ]; + + var obj = { + softwareProduct: { + softwareProductEditor: { + data:currentSoftwareProduct + }, softwareProductAttachments: + { + heatValidation: { + attachmentsTree: atTree, + errorList: errorList + } + } + } + }; + + var results = mapStateToProps(obj); + expect(results.attachmentsTree).toBeTruthy(); + expect(results.errorList).toBeTruthy(); + expect(results.currentErrors).toBeTruthy(); + expect(results.currentWarnings).toBeTruthy(); + expect(results.selectedNode).toBe(undefined); + }); + + + it('function does exist', () => { + + const atTree = { + 'children': [ + { + 'name': 'HEAT', + 'expanded': true, + 'type': 'heat', + 'children': [ + { + 'name': 'heat_zxeyCtMHhf2.yaml', + 'expanded': true, + 'type': 'heat', + 'errors': [ + { + 'level': 'WARNING', + 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' + } + ], + 'children': [ + { + 'name': 'heat_env_zxeyCtMHhf2.env', + 'type': 'env' + } + ] + } + ] + } + ] + }; + const errorList = [ + { + 'errorLevel': 'WARNING', + 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', + 'name': 'heat_zxeyCtMHhf2.yaml', + 'hasParent': false, + 'parentName': 'HEAT', + 'type': 'heat' + }, + { + 'errorLevel': 'WARNING', + 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', + 'name': 'heat_zxeyCtMHhf2.yaml', + 'hasParent': false, + 'parentName': 'HEAT', + 'type': 'heat' + } + ]; + var currentErrors = []; + var currentWarnings = []; + var onSelect = () => { return null; } ; + var onDeSelect = () => { return null; } ; + var onToggle = () => { return null; } ; + + var renderer = TestUtils.createRenderer(); + renderer.render(); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/softwareProduct/components/compute/test.js b/openecomp-ui/test/softwareProduct/components/compute/test.js index 925de302b8..8d2d1fbb2f 100644 --- a/openecomp-ui/test/softwareProduct/components/compute/test.js +++ b/openecomp-ui/test/softwareProduct/components/compute/test.js @@ -1,24 +1,19 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; @@ -26,14 +21,18 @@ import {storeCreator} from 'sdc-app/AppStore.js'; import Configuration from 'sdc-app/config/Configuration.js'; import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; +import {default as VSPComponentsComputeFactory, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const vspComponentId = '111'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Compute Module Tests', function () { let restPrefix = ''; - before(function() { + beforeAll(function() { restPrefix = Configuration.get('restPrefix'); deepFreeze(restPrefix); }); @@ -42,28 +41,32 @@ describe('Software Product Components Compute Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const compute = VSPComponentsComputeFactory.build(); + const dataMap = VSPComponentsComputeDataMapFactory.build(); + const softwareProductComponentCompute = { - data: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}), - schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}) + data: JSON.stringify(compute), + schema: JSON.stringify(compute) }; deepFreeze(softwareProductComponentCompute); const softwareProductComponentComputeData = { - qdata: JSON.parse(softwareProductComponentCompute.data), - qschema: JSON.parse(softwareProductComponentCompute.schema) + qdata: compute, + dataMap, + qgenericFieldInfo: {} }; deepFreeze(softwareProductComponentComputeData); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentComputeData); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); expect(data).toEqual(undefined); expect(options).toEqual(undefined); return softwareProductComponentCompute; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); @@ -72,61 +75,33 @@ describe('Software Product Components Compute Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const compute = VSPComponentsComputeFactory.build(); + const softwareProductComponentQuestionnaire = { data: null, - schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}) + schema: JSON.stringify(compute) }; deepFreeze(softwareProductComponentQuestionnaire); const softwareProductComponentQuestionnaireData = { qdata: {}, - qschema: JSON.parse(softwareProductComponentQuestionnaire.schema) + dataMap: {}, + qgenericFieldInfo: {} }; deepFreeze(softwareProductComponentQuestionnaireData); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentQuestionnaireData); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); expect(data).toEqual(undefined); expect(options).toEqual(undefined); return softwareProductComponentQuestionnaire; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); - it('Update Software Products Components Compute', () => { - const store = storeCreator({ - softwareProduct: { - softwareProductComponents: { - componentEditor: { - qdata: { - numOfCPUs: 3, - fileSystemSizeGB: 999 - }, - qschema: { - type: 'object', - properties: { - numOfCPUs: {type: 'number'}, - fileSystemSizeGB: {type: 'number'} - } - } - } - } - } - }); - deepFreeze(store); - - const data = {numOfCPUs: 5, fileSystemSizeGB: 300}; - deepFreeze(data); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', data); - - SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(store.dispatch, {data}); - - expect(store.getState()).toEqual(expectedStore); - }); }); diff --git a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js index ce2152b29b..4f6512ad15 100644 --- a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js +++ b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js @@ -1,113 +1,73 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneral.js'; import SoftwareProductComponentsGeneralView from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +//import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('mapStateToProps data test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, softwareProductComponents: { componentEditor: { data: {}, - qdata: {}, - qschema: {} + qdata: {} } } - } + }) }; var results = mapStateToProps(obj); - expect(results.componentData).toExist(); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); + expect(results.componentData).toBeTruthy(); + expect(results.qdata).toBeTruthy(); }); it('VSP Components general view test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); const softwareProductComponents = { componentEditor: { data: {}, qdata: {}, - qschema: { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - general: { - type: 'object', - properties: {} - } - } - } + qschema: VSPQSchemaFactory.build() } }; - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); const componentData = { name: '', @@ -122,7 +82,7 @@ describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => { versionControllerData={versionControllerData} currentSoftwareProduct={currentSoftwareProduct}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); diff --git a/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js index 69a93b69e1..0ee9c76961 100644 --- a/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js +++ b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js @@ -1,110 +1,69 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js'; import SoftwareProductComponentLoadBalancingView from 'sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancingRefView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; +import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; describe('SoftwareProductComponentLoadBalancing Mapper and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('mapStateToProps data test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, softwareProductComponents: { componentEditor: { - qdata: {}, - qschema: {} + qdata: {} } } - } + }) }; var results = mapStateToProps(obj); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); + expect(results.qdata).toBeTruthy(); }); it('VSP Components LoadBalancing view test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); const softwareProductComponents = { componentEditor: { qdata: {}, - qschema: { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - general: { - type: 'object', - properties: {} - } - } - } + qschema: VSPQSchemaFactory.build() } }; - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); var renderer = TestUtils.createRenderer(); renderer.render( @@ -115,7 +74,7 @@ describe('SoftwareProductComponentLoadBalancing Mapper and View Classes', () => softwareProductId='123' componentId='321'/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js index 2f1ea12c01..24658f1b30 100644 --- a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js +++ b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js @@ -1,57 +1,53 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js'; import SoftwareProductComponentsMonitoringView from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx'; +import {VSPComponentsMonitoringViewFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +const version = VersionControllerUtilsFactory.build(); + describe('SoftwareProductComponentsMonitoring Module Tests', function () { it('should mapper exist', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('should return empty file names', () => { - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring: {}}}; + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring: {}}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(undefined); expect(results.pollFilename).toEqual(undefined); }); it('should return trap file name', () => { - const monitoring = { - trapFilename: '123' - }; - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}}; + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(monitoring.trapFilename); expect(results.pollFilename).toEqual(undefined); }); it('should return poll file names', () => { - const monitoring = { - pollFilename: '123' - }; - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}}; + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpPollFlag: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(undefined); expect(results.pollFilename).toEqual(monitoring.pollFilename); @@ -59,15 +55,12 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () { let renderer = TestUtils.createRenderer(); renderer.render(); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('should return both file names', () => { - const monitoring = { - trapFilename: '1234', - trapFilename: '123' - }; - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}}; + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(monitoring.trapFilename); expect(results.pollFilename).toEqual(monitoring.pollFilename); @@ -75,7 +68,7 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () { let renderer = TestUtils.createRenderer(); renderer.render(); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('should change state to dragging', done => { diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/test.js b/openecomp-ui/test/softwareProduct/components/monitoring/test.js index 172db653e9..dd0f850a89 100644 --- a/openecomp-ui/test/softwareProduct/components/monitoring/test.js +++ b/openecomp-ui/test/softwareProduct/components/monitoring/test.js @@ -1,31 +1,30 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import mockRest from 'test-utils/MockRest.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductComponentsMonitoringConstants from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js'; import SoftwareProductComponentsMonitoringActionHelper from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js'; +import {VSPComponentsMonitoringRestFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const componentId = '123'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Monitoring Module Tests', function () { @@ -38,18 +37,16 @@ describe('Software Product Components Monitoring Module Tests', function () { it('Fetch for existing files - no files', done => { - let emptyResult = Object.freeze({ - snmpTrap: undefined, - snmpPoll: undefined - }); + let emptyResult = VSPComponentsMonitoringRestFactory.build(); mockRest.addHandler('fetch', ({ baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return emptyResult; }); SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, + version, componentId }); setTimeout(()=> { @@ -62,18 +59,16 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Fetch for existing files - only snmp trap file exists', done => { - let response = Object.freeze({ - snmpTrap: 'asdfasdf', - snmpPoll: undefined - }); + let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true}); mockRest.addHandler('fetch', ({ baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return response; }); SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, + version, componentId }); setTimeout(()=> { @@ -85,18 +80,16 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Fetch for existing files - only snmp poll file exists', done => { - let response = Object.freeze({ - snmpPoll: 'asdfasdf', - snmpTrap: undefined - }); + let response = VSPComponentsMonitoringRestFactory.build({}, {snmpPollFlag: true}); mockRest.addHandler('fetch', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return response; }); SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, + version, componentId }); setTimeout(()=> { @@ -108,18 +101,16 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Fetch for existing files - both files exist', done => { - let response = Object.freeze({ - snmpPoll: 'asdfasdf', - snmpTrap: 'asdfgg' - }); + let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true}); mockRest.addHandler('fetch', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return response; }); SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, + version, componentId }); setTimeout(()=> { @@ -132,8 +123,8 @@ describe('Software Product Components Monitoring Module Tests', function () { it('Upload snmp trap file', done => { - mockRest.addHandler('create', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp-trap/upload`); + mockRest.addHandler('post', ({baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap/upload`); return {}; }); var debug = {hello: 'world'}; @@ -142,6 +133,7 @@ describe('Software Product Components Monitoring Module Tests', function () { formData.append('upload', file); SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, { softwareProductId, + version, componentId, formData, fileSize: file.size, @@ -156,8 +148,8 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Upload snmp poll file', done => { - mockRest.addHandler('create', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp/upload`); + mockRest.addHandler('post', ({baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp/upload`); return {}; }); var debug = {hello: 'world'}; @@ -166,6 +158,7 @@ describe('Software Product Components Monitoring Module Tests', function () { formData.append('upload', file); SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, { softwareProductId, + version, componentId, formData, fileSize: file.size, @@ -181,11 +174,12 @@ describe('Software Product Components Monitoring Module Tests', function () { it('Delete snmp trap file', done => { mockRest.addHandler('destroy', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp-trap`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap`); return {}; }); SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, { softwareProductId, + version, componentId, type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP }); @@ -198,11 +192,12 @@ describe('Software Product Components Monitoring Module Tests', function () { it('Delete snmp poll file', done => { mockRest.addHandler('destroy', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return {}; }); SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, { softwareProductId, + version, componentId, type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL }); diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js index c9760f7799..094b95a091 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js @@ -1,55 +1,42 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditor.js'; import SoftwareProductComponentsNICEditorView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorView.jsx'; - +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPComponentsNicFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNicFactoryQGenericFieldInfo, + VSPComponentsNicFactoryGenericFieldInfo, VSPComponentsNetworkDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('Software Product Component Network NIC Editor and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('mapStateToProps data test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, @@ -58,40 +45,42 @@ describe('Software Product Component Network NIC Editor and View Classes', () => nicEditor: { data: {}, qdata: {}, - qschema: {} + dataMap: {}, + qgenericFieldInfo: {}, + genericFieldInfo: {} } } } - } + }) }; var results = mapStateToProps(obj); - expect(results.currentSoftwareProduct).toExist(); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); - expect(results.data).toExist(); + expect(results.currentSoftwareProduct).toBeTruthy(); + expect(results.qdata).toBeTruthy(); + expect(results.dataMap).toBeTruthy(); + expect(results.genericFieldInfo).toBeTruthy(); + expect(results.qgenericFieldInfo).toBeTruthy(); + expect(results.data).toBeTruthy(); }); it('Software Product Component Network NIC Editor View Test', () => { - const data = { - name: '', - description: '', - networkName: '' + const props = { + data: VSPComponentsNicFactory.build(), + qdata: VSPComponentsNetworkQDataFactory.build(), + dataMap: VSPComponentsNetworkDataMapFactory.build(), + genericFieldInfo: VSPComponentsNicFactoryGenericFieldInfo.build(), + qgenericFieldInfo: VSPComponentsNicFactoryQGenericFieldInfo.build(), + isFormValid: true, + formReady: false, + protocols: [] }; - const qdata = {}; - const qschema = {}; - var renderer = TestUtils.createRenderer(); - renderer.render( - ); + renderer.render(); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); }); diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js index 520fde7403..d35659c93b 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js @@ -1,110 +1,75 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkList.js'; import SoftwareProductComponentsNetworkListView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsNicWithIdFactory, VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('Software Product Component Network Mapper and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('mapStateToProps data test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, softwareProductComponents: { componentEditor: { qdata: {}, - qschema: {}, - data: {} + data: {}, + dataMap: {}, + qgenericFieldInfo: {}, + isFormValid: true, + formReady: false }, network: { nicEditor: {}, nicList: [] } } - } + }) }; var results = mapStateToProps(obj); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); - expect(results.componentData).toExist(); + expect(results.qdata).toBeTruthy(); + expect(results.dataMap).toBeTruthy(); + expect(results.qgenericFieldInfo).toBeTruthy(); + expect(results.componentData).toBeTruthy(); }); it('Software Product Component Network List View Test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_IN_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); - const nicList = [ - { - name: 'name', - networkId: 'network', - id: '122', - networkName: 'nname' - } - ]; + const nicList = VSPComponentsNicWithIdFactory.buildList(1); var renderer = TestUtils.createRenderer(); renderer.render( @@ -115,7 +80,7 @@ describe('Software Product Component Network Mapper and View Classes', () => { componentId='321' nicList={nicList}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js index 8c23267c89..f5a10e23c9 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js @@ -1,33 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductComponentsNetworkActionHelper from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js'; +import {VSPComponentsNicFactory, VSPComponentsNetworkFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNetworkDataMapFactory, VSPComponentsNicFactoryGenericFieldInfo} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; +import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; +import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; + const softwareProductId = '123'; const componentId = '321'; const nicId = '111'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Network Action Helper Tests', function () { @@ -35,23 +35,7 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const NICList = [ - { - name:'oam01_port_0', - description:'bbbbbbb', - networkId:'A0E578751B284D518ED764D5378EA97C', - id:'96D3648338F94DAA9889E9FBB8E59895', - networkName:'csb_net' - }, - { - name:'oam01_port_1', - description:'bbbbbbb', - networkId:'378EA97CA0E578751B284D518ED764D5', - id:'8E5989596D3648338F94DAA9889E9FBB', - networkName:'csb_net_2' - } - - ]; + const NICList = VSPComponentsNicFactory.buildList(2); deepFreeze(NICList); @@ -60,14 +44,14 @@ describe('Software Product Components Network Action Helper Tests', function () const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network.nicList', NICList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: NICList}; }); - return SoftwareProductComponentsNetworkActionHelper.fetchNICsList(store.dispatch, {softwareProductId, componentId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsNetworkActionHelper.fetchNICsList(store.dispatch, {softwareProductId, version, componentId}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -76,12 +60,8 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const data = { - name: 'oam01_port_0', - description: 'bbbbbbb', - networkId: 'A0E578751B284D518ED764D5378EA97C', - networkName: 'csb_net' - }; + const data = VSPComponentsNicFactory.build(); + const genericFieldInfo = VSPComponentsNicFactoryGenericFieldInfo.build(); const nic = {id: '444'}; deepFreeze(data); @@ -91,20 +71,19 @@ describe('Software Product Components Network Action Helper Tests', function () deepFreeze(expectedData); - const network = { + const network = VSPComponentsNetworkFactory.build({ nicEditor: { - data: expectedData - }, - nicList: [] - }; + data: expectedData, + formName: forms.NIC_EDIT_FORM, + genericFieldInfo + } + }); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); SoftwareProductComponentsNetworkActionHelper.openNICEditor(store.dispatch, {nic, data}); - return setTimeout(() => { - expect(store.getState()).to.deep.equal(expectedStore); - }, 100); + expect(store.getState()).toEqual(expectedStore); }); it('close NICE editor', () => { @@ -112,41 +91,31 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const network = { - nicEditor: {}, - nicList: [] - }; + const network = VSPComponentsNetworkFactory.build(); deepFreeze(network); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); SoftwareProductComponentsNetworkActionHelper.closeNICEditor(store.dispatch); - return setTimeout(() => { - expect(store.getState()).to.deep.equal(expectedStore); - }, 100); + expect(store.getState()).toEqual(expectedStore); }); it('Load NIC data', () => { - const expectedData = { - description: 'bbbbbbb', - name: 'oam01_port_0', - networkId: 'A0E578751B284D518ED764D5378EA97C', - networkName: 'csb_net' - }; + const expectedData = VSPComponentsNicFactory.build(); deepFreeze(expectedData); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return (expectedData); }); - return SoftwareProductComponentsNetworkActionHelper.loadNICData({softwareProductId, componentId, nicId}).then((data) => { - expect(data).to.deep.equal(expectedData); + return SoftwareProductComponentsNetworkActionHelper.loadNICData({softwareProductId, version, componentId, nicId}).then((data) => { + expect(data).toEqual(expectedData); }); }); @@ -156,119 +125,47 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const qdata = { - protocols: { - protocolWithHighestTrafficProfile: 'UDP', - protocols: ['UDP'] - }, - ipConfiguration: { - ipv4Required: true - } - }; - - const qschema = { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - 'protocols': { - type: 'object', - properties: {} - } - } - }; + const qdata = VSPComponentsNetworkQDataFactory.build(); + const dataMap = VSPComponentsNetworkDataMapFactory.build(); + const qgenericFieldInfo = {}; + const qschema = VSPQSchemaFactory.build(); deepFreeze(qdata); + deepFreeze(dataMap); deepFreeze(qschema); - const network = { + const network = VSPComponentsNetworkFactory.build({ nicEditor: { qdata, - qschema - }, - nicList: [] - }; + dataMap, + qgenericFieldInfo + } + }); deepFreeze(network); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}/questionnaire`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}/questionnaire`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return ({data: JSON.stringify(qdata), schema: JSON.stringify(qschema)}); }); - return SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(store.dispatch, {softwareProductId, componentId, nicId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(store.dispatch, {softwareProductId, version, componentId, nicId}).then(() => { + expect(store.getState()).toEqual(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); - it('update NIC Data', () => { - const store = storeCreator(); - deepFreeze(store.getState()); - - const data = {test: '123'}; - deepFreeze(data); - - const network = { - nicEditor: { - data - }, - nicList: [] - }; - - deepFreeze(network); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); - - SoftwareProductComponentsNetworkActionHelper.updateNICData(store.dispatch, {deltaData:data}); - - return setTimeout(() => { - expect(store.getState()).to.deep.equal(expectedStore); - }, 100); - - }); - - it('update NIC Questionnaire', () => { - const store = storeCreator(); - deepFreeze(store.getState()); - - const qdata = { - test: '123' - }; - const network = { - nicEditor: { - qdata, - qschema: undefined - }, - nicList: [] - }; - deepFreeze(network); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); - - SoftwareProductComponentsNetworkActionHelper.updateNICQuestionnaire(store.dispatch, {data:qdata}); - - return setTimeout(() => { - expect(store.getState()).to.deep.equal(expectedStore); - }, 100); - - }); - it('save NIC Data And Questionnaire', () => { const store = storeCreator(); deepFreeze(store.getState()); - const qdata = { - qtest: '111' - }; - const data = { - name: '2222', - description: 'blabla', - networkId: '123445' - }; + const qdata = VSPComponentsNetworkQDataFactory.build(); + const data = VSPComponentsNicFactory.build(); const expectedData = {...data, id: nicId}; @@ -282,22 +179,22 @@ describe('Software Product Components Network Action Helper Tests', function () const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); deepFreeze(expectedStore); - mockRest.addHandler('save', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}/questionnaire`); - expect(data).to.deep.equal(qdata); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}/questionnaire`); + expect(data).toEqual(qdata); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - mockRest.addHandler('save', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}`); - expect(data).to.deep.equal(data); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`); + expect(data).toEqual(data); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - return SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(store.dispatch, {softwareProductId, componentId, qdata, data: expectedData}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(store.dispatch, {softwareProductId, version, componentId, qdata, data: expectedData}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); diff --git a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js new file mode 100644 index 0000000000..f3653fbcac --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js @@ -0,0 +1,57 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditor.js'; +import SoftwareProductComponentProcessesEditorView from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorView.jsx'; + +describe('Software Product Components Processes Editor Module Tests', function () { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should return empty data', () => { + + var state = { + softwareProduct: { + softwareProductComponents: { + componentProcesses: { + processesList: [], + processesEditor: {data: {}} + } + } + } + }; + + var results = mapStateToProps(state); + expect(results.data).toEqual({}); + expect(results.previousData).toEqual(undefined); + }); + + it('jsx view test', () => { + var view = TestUtils.renderIntoDocument( + {}} + onSubmit={() => {}} + onClose={() => {}}/>); + expect(view).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js new file mode 100644 index 0000000000..ac866727a6 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js @@ -0,0 +1,77 @@ +/*! +* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +* +* 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; + +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesList.js'; +import SoftwareProductComponentsProcessesView from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesListView.jsx'; + +import {VSPProcessStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; + +describe('SoftwareProductComponetsProcesses Mapper and View Classes', () => { + it('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('mapStateToProps data test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + + const processesList = VSPProcessStoreFactory.buildList(2); + + var state = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductComponents: { + componentProcesses: { + processesList, + processesEditor: { + data: {} + } + } + } + } + }; + var results = mapStateToProps(state); + expect(results.processesList.length).toBe(2); + }); + + it('view simple test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + const currentSoftwareProductComponent = VSPComponentsFactory.build(); + const processesList = VSPProcessStoreFactory.buildList(2); + + var renderer = TestUtils.createRenderer(); + renderer.render( + {}} + onEditProcessClick={() => {}} + onDeleteProcessClick={() => {}} + isDisplayEditor={false} + isReadOnlyMode={false}/> + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/components/processes/test.js b/openecomp-ui/test/softwareProduct/components/processes/test.js index 67427d3c05..02009e6542 100644 --- a/openecomp-ui/test/softwareProduct/components/processes/test.js +++ b/openecomp-ui/test/softwareProduct/components/processes/test.js @@ -1,51 +1,43 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; +import {buildFromExistingObject} from 'test-utils/Util.js'; import {cloneAndSet} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductComponentProcessesActionHelper from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js'; +import { + VSPProcessStoreWithArtifactNameFactory, + VSPProcessPostFactory, + VSPProcessStoreFactory, + VSPProcessPostFactoryWithType, + VSPProcessStoreFactoryWithType} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; + const softwareProductId = '123'; const componentId = '222'; +const versionId = '1'; +const version = {id: versionId, label: versionId}; + describe('Software Product Component Processes Module Tests', function () { it('Get Software Products Processes List', () => { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - }, - { - name: 'Pr1', - description: 'hjhj', - id: '2F47447D22DB4C53B020CA1E66201EF2', - artifactName: 'artifact' - } - ]; + const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(2); deepFreeze(softwareProductProcessesList); @@ -54,25 +46,20 @@ describe('Software Product Component Processes Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', softwareProductProcessesList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductProcessesList}; }); + - return SoftwareProductComponentProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, componentId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, componentId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); it('Delete Software Products Processes', () => { - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - } - ]; + let process = VSPProcessStoreWithArtifactNameFactory.build(); + const softwareProductProcessesList = [process]; deepFreeze(softwareProductProcessesList); const store = storeCreator({ @@ -83,15 +70,15 @@ describe('Software Product Component Processes Module Tests', function () { } }); - const processId = 'EBADF561B7FA4A788075E1840D0B5971'; + const processId = process.id; deepFreeze(store.getState()); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', []); mockRest.addHandler('destroy', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes/${processId}`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes/${processId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return { results: { returnCode: 'OK' @@ -101,9 +88,10 @@ describe('Software Product Component Processes Module Tests', function () { return SoftwareProductComponentProcessesActionHelper.deleteProcess(store.dispatch, { process: softwareProductProcessesList[0], - softwareProductId, componentId + softwareProductId, componentId, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -112,27 +100,18 @@ describe('Software Product Component Processes Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductPostRequest = { - name: 'Pr1', - description: 'string' - }; - const softwareProductProcessToAdd = { - name: 'Pr1', - description: 'string' - }; const softwareProductProcessFromResponse = 'ADDED_ID'; - const softwareProductProcessAfterAdd = { - ...softwareProductProcessToAdd, - id: softwareProductProcessFromResponse - }; + + const softwareProductProcessAfterAdd = VSPProcessStoreFactory.build({id: softwareProductProcessFromResponse}); + const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactory, softwareProductProcessAfterAdd); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [softwareProductProcessAfterAdd]); - mockRest.addHandler('create', ({data, options, baseUrl}) => { + mockRest.addHandler('post', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes`); - expect(data).to.deep.equal(softwareProductPostRequest); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); return { returnCode: 'OK', value: softwareProductProcessFromResponse @@ -143,23 +122,55 @@ describe('Software Product Component Processes Module Tests', function () { { softwareProductId, previousProcess: null, - process: softwareProductProcessToAdd, - componentId + process: softwareProductPostRequest, + componentId, + version } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); - it('Update Software Products Processes', () => { - const softwareProductProcessesList = [ + it('Add Software Products Processes with type', () => { + + const store = storeCreator(); + deepFreeze(store.getState()); + + const softwareProductPostRequest = VSPProcessPostFactoryWithType.build(); + + const softwareProductProcessAfterAdd = VSPProcessStoreFactoryWithType.build(softwareProductPostRequest); + const softwareProductProcessFromResponse = softwareProductProcessAfterAdd.id; + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [softwareProductProcessAfterAdd]); + + mockRest.addHandler('post', ({data, options, baseUrl}) => { + + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); + return { + returnCode: 'OK', + value: softwareProductProcessFromResponse + }; + }); + + return SoftwareProductComponentProcessesActionHelper.saveProcess(store.dispatch, { - name: 'Pr1', - description: 'string', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' + softwareProductId, + previousProcess: null, + process: softwareProductPostRequest, + componentId, + version } - ]; + ).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); + + it('Update Software Products Processes', () => { + let process = VSPProcessStoreWithArtifactNameFactory.build(); + + const softwareProductProcessesList = [process]; deepFreeze(softwareProductProcessesList); const store = storeCreator({ @@ -173,28 +184,30 @@ describe('Software Product Component Processes Module Tests', function () { }); deepFreeze(store.getState()); - const toBeUpdatedProcessId = softwareProductProcessesList[0].id; - const previousProcessData = softwareProductProcessesList[0]; - const processUpdateData = { - ...softwareProductProcessesList[0], + const toBeUpdatedProcessId = process.id; + const previousProcessData = process; + const processUpdateData = VSPProcessStoreWithArtifactNameFactory.build({ + ...process, name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + description: 'string_UPDATED', + type: 'Other' + }); deepFreeze(processUpdateData); - const processPutRequest = { + const processPutRequest = VSPProcessPostFactory.build({ name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + description: 'string_UPDATED', + type: 'Other' + }); deepFreeze(processPutRequest); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [processUpdateData]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes/${toBeUpdatedProcessId}`); - expect(data).to.deep.equal(processPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes/${toBeUpdatedProcessId}`); + expect(data).toEqual(processPutRequest); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); @@ -203,12 +216,12 @@ describe('Software Product Component Processes Module Tests', function () { softwareProductId: softwareProductId, componentId, previousProcess: previousProcessData, - process: processUpdateData + process: processUpdateData, + version } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); }); - diff --git a/openecomp-ui/test/softwareProduct/components/storage/test.js b/openecomp-ui/test/softwareProduct/components/storage/test.js index 87cad368be..138c4da7d6 100644 --- a/openecomp-ui/test/softwareProduct/components/storage/test.js +++ b/openecomp-ui/test/softwareProduct/components/storage/test.js @@ -1,24 +1,19 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; @@ -26,14 +21,18 @@ import {storeCreator} from 'sdc-app/AppStore.js'; import Configuration from 'sdc-app/config/Configuration.js'; import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; +import {default as VSPComponentsStorageFactory, VSPComponentsStorageDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsStorageFactory.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const vspComponentId = '111'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Storage Module Tests', function () { let restPrefix = ''; - before(function() { + beforeAll(function() { restPrefix = Configuration.get('restPrefix'); deepFreeze(restPrefix); }); @@ -42,28 +41,32 @@ describe('Software Product Components Storage Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const storage = VSPComponentsStorageFactory.build(); + const dataMap = VSPComponentsStorageDataMapFactory.build(); + const softwareProductComponentStorage = { - data: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}), - schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}) + data: JSON.stringify(storage), + schema: JSON.stringify(storage) }; deepFreeze(softwareProductComponentStorage); const softwareProductComponentStorageData = { - qdata: JSON.parse(softwareProductComponentStorage.data), - qschema: JSON.parse(softwareProductComponentStorage.schema) + qdata: storage, + dataMap: dataMap, + qgenericFieldInfo: {} }; deepFreeze(softwareProductComponentStorageData); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentStorageData); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); expect(data).toEqual(undefined); expect(options).toEqual(undefined); return softwareProductComponentStorage; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); @@ -72,61 +75,33 @@ describe('Software Product Components Storage Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const storage = VSPComponentsStorageFactory.build(); + const softwareProductComponentQuestionnaire = { data: null, - schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}) + schema: JSON.stringify(storage) }; deepFreeze(softwareProductComponentQuestionnaire); const softwareProductComponentQuestionnaireData = { qdata: {}, - qschema: JSON.parse(softwareProductComponentQuestionnaire.schema) + dataMap: {}, + qgenericFieldInfo: {} }; deepFreeze(softwareProductComponentQuestionnaireData); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentQuestionnaireData); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); expect(data).toEqual(undefined); expect(options).toEqual(undefined); return softwareProductComponentQuestionnaire; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); - it('Update Software Products Components Storage', () => { - const store = storeCreator({ - softwareProduct: { - softwareProductComponents: { - componentEditor: { - qdata: { - backupType: 'OnSite', - backupStorageSize: 30 - }, - qschema: { - type: 'object', - properties: { - backupType: {type: 'string'}, - backupStorageSize: {type: 'number'} - } - } - } - } - } - }); - deepFreeze(store); - - const data = {backupType: 'OffSite', backupStorageSize: 30}; - deepFreeze(data); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', data); - - SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(store.dispatch, {data}); - - expect(store.getState()).toEqual(expectedStore); - }); }); diff --git a/openecomp-ui/test/softwareProduct/components/test.js b/openecomp-ui/test/softwareProduct/components/test.js index 839e1b7cf7..b3994b1461 100644 --- a/openecomp-ui/test/softwareProduct/components/test.js +++ b/openecomp-ui/test/softwareProduct/components/test.js @@ -1,32 +1,30 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; +import {VSPComponentsFactory, VSPComponentsGeneralFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const vspComponentId = '321'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Module Tests', function () { it('Get Software Products Components List', () => { @@ -34,18 +32,8 @@ describe('Software Product Components Module Tests', function () { deepFreeze(store.getState()); const softwareProductComponentsList = [ - { - name: 'com.d2.resource.vfc.nodes.heat.sm_server', - displayName: 'sm_server', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971' - }, - { - name: 'com.d2.resource.vfc.nodes.heat.pd_server', - displayName: 'pd_server', - description: 'hjhj', - id: '2F47447D22DB4C53B020CA1E66201EF2' - } + VSPComponentsFactory.build({}, {componentName: 'sd', componentType: 'server'}), + VSPComponentsFactory.build({}, {componentName: 'pd', componentType: 'server'}) ]; deepFreeze(softwareProductComponentsList); @@ -55,14 +43,14 @@ describe('Software Product Components Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentsList', softwareProductComponentsList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductComponentsList}; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -70,27 +58,21 @@ describe('Software Product Components Module Tests', function () { const store = storeCreator(); const qdataUpdated = { - general: { - hypervisor: { - containerFeatureDescription: 'aaaUpdated', - drivers: 'bbbUpdated', - hypervisor: 'cccUpdated' - } - } + general: VSPComponentsGeneralFactory.build() }; const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', qdataUpdated); deepFreeze(expectedStore); - mockRest.addHandler('save', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`); - expect(data).to.deep.equal(qdataUpdated); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); + expect(data).toEqual(qdataUpdated); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId, qdata: qdataUpdated}).then(() => { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId, qdata: qdataUpdated}).then(() => { //TODO think should we add here something or not }); @@ -98,4 +80,3 @@ describe('Software Product Components Module Tests', function () { }); }); - diff --git a/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js new file mode 100644 index 0000000000..c7c55bdbaf --- /dev/null +++ b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js @@ -0,0 +1,105 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps, mapActionsToProps} from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js'; +import SoftwareProductCreationView from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx'; +import {SoftwareProductCreationFactory, SoftwareProductCreationFactoryWithSelectedVendor} from 'test-utils/factories/softwareProduct/SoftwareProductCreationFactories.js'; +import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; +import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; + +describe('Software Product Creation Module Tests', function() { + it ('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it ('should return empty data', () => { + let state = { + softwareProductList: [], + softwareProduct: { + softwareProductCreation: { + data: {} + } + } + }; + let props = mapStateToProps(state); + expect(props.data).toEqual({}); + }); + + it ('should return vsp names list', () => { + let state = { + softwareProductList: [{ + name: 'vsp1', + id: 'vsp1_id' + }, { + name: 'vsp2', + id: 'vsp2_id' + }], + softwareProduct: { + softwareProductCreation: { + data: {} + } + } + }; + let props = mapStateToProps(state); + expect(props.data).toEqual({}); + expect(props.VSPNames).toEqual({vsp1: 'vsp1_id', vsp2: 'vsp2_id'}); + }); + + it('simple jsx test', () => { + const store = storeCreator(); + let dispatch = store.dispatch; + + let state = { + softwareProductList: [], + softwareProduct: { + softwareProductCreation: SoftwareProductCreationFactory.build(), + softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2}) + }, + finalizedLicenseModelList: FinalizedLicenseModelFactory.buildList(3) + }; + let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch)); + var renderer = TestUtils.createRenderer(); + renderer.render( + + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); + + it('simple jsx test - with selected vendor', () => { + const store = storeCreator(); + let dispatch = store.dispatch; + let finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3); + let state = { + softwareProductList: [], + softwareProduct: { + softwareProductCreation: SoftwareProductCreationFactoryWithSelectedVendor.build({selectedVendorId: finalizedLicenseModelList[0].id}), + softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2}) + }, + finalizedLicenseModelList + }; + let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch)); + let renderer = TestUtils.createRenderer(); + renderer.render( + + ); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js new file mode 100644 index 0000000000..5325a58959 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js @@ -0,0 +1,210 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import {mount} from 'enzyme'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js'; +import { + SoftwareProductDependenciesResponseFactory, + SoftwareProductDependenciesStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductDependenciesFactories.js'; +import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import {cloneAndSet} from 'test-utils/Util.js'; +import mockRest from 'test-utils/MockRest.js'; + +import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; +import SoftwareProductDependenciesActionHelper from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js'; +import SoftwareProductDependenciesView from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; + +describe('Software Product Dependencies Module Tests', function () { + const softwareProductId = '555'; + const version = VersionControllerUtilsFactory.build().version; + + it('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('Get Software Product Dependencies List', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + + let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(2); + let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency)); + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: DependenciesListResponse}; + }); + + return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => { + const state = store.getState(); + const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies; + const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies; + let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id})); + + const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies); + + expect(state).toEqual(newExpectedStore); + }); + }); + + it('Update Software Product Dependencies List', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + + let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(3); + let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency)); + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: DependenciesListResponse}; + }); + + return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => { + + const state = store.getState(); + const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies; + const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies; + let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id})); + + let newDependency = SoftwareProductDependenciesStoreFactory.build(); + expectedStoreDependencies.push(newDependency); + + const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies); + + SoftwareProductDependenciesActionHelper.updateDependencyList(dispatch, {dependenciesList: expectedStoreDependencies}); + const newState = store.getState(); + expect(newState).toEqual(newExpectedStore); + }); + }); + + it('Add And Save Software Product Dependencies List', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + + let mockServerDependencies = []; + + SoftwareProductDependenciesActionHelper.addDependency(dispatch); + let state = store.getState(); + let dependencies = state.softwareProduct.softwareProductDependencies; + expect(dependencies.length).toEqual(1); + expect(dependencies[0].sourceId).toEqual(null); + expect(dependencies[0].targetId).toEqual(null); + + let newDependencies = SoftwareProductDependenciesStoreFactory.buildList(1); + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', newDependencies); + SoftwareProductDependenciesActionHelper.updateDependencyList(dispatch, {dependenciesList: newDependencies}); + + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual({componentDependencyModels: newDependencies.map(item => ({sourceId: item.sourceId, targetId: item.targetId, relationType: item.relationType}) )}); + expect(options).toEqual(undefined); + mockServerDependencies = [...data.componentDependencyModels]; + return {returnCode: 'OK'}; + }); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: mockServerDependencies}; + }); + + return SoftwareProductDependenciesActionHelper.saveDependencies(dispatch, {softwareProductId, version, dependenciesList: newDependencies}).then(() => { + return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}); + }).then(() => { + const state = store.getState(); + const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies; + const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies; + let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id})); + + const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies); + + expect(state).toEqual(newExpectedStore); + }); + }); + + it('Get Software Product Dependencies List with loop, and render to JSX', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + + let components = VSPComponentsFactory.buildList(2); + let vspEditor = VSPEditorFactory.build({id: softwareProductId, version}); + + let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(2); + let firstDependecy = DependenciesListResponse[0]; + let secondDependency = DependenciesListResponse[1]; + firstDependecy.sourceId = components[0].id; + secondDependency.sourceId = components[1].id; + firstDependecy.targetId = secondDependency.sourceId; + secondDependency.targetId = firstDependecy.sourceId; + + let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build({...dependency, hasCycle: true})); + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: DependenciesListResponse}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: components}; + }); + + return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); + }).then(() => { + const state = store.getState(); + state.softwareProduct.softwareProductEditor = {data: vspEditor}; + const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies; + const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies; + let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id})); + + const newExpectedStore = { + ...expectedStore, + softwareProduct: { + ...expectedStore.softwareProduct, + softwareProductDependencies: expectedStoreDependencies, + softwareProductEditor: {data: vspEditor}, + softwareProductComponents: { + ...expectedStore.softwareProduct.softwareProductComponents, + componentsList: components + } + } + }; + + expect(state).toEqual(newExpectedStore); + + const props = mapStateToProps(state); + expect(props.softwareProductDependencies).toEqual(expectedStoreDependencies); + const wrapper = mount(); + expect(wrapper).toBeTruthy(); + }); + }); +}); \ No newline at end of file diff --git a/openecomp-ui/test/softwareProduct/details/detailsView.test.js b/openecomp-ui/test/softwareProduct/details/detailsView.test.js index b6a8ca5d4e..37c5df5079 100644 --- a/openecomp-ui/test/softwareProduct/details/detailsView.test.js +++ b/openecomp-ui/test/softwareProduct/details/detailsView.test.js @@ -1,87 +1,93 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js'; import SoftwareProductDetailsView from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx'; -import {vspQschema as vspQuestionnaireSchema} from './vspQschema.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; +import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; +import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {SchemaGenericFieldInfoFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; +import {default as VspQdataFactory, VspDataMapFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js'; +import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; describe('Software Product Details: ', function () { - let currentSoftwareProduct = {}, categories = [], finalizedLicenseModelList, licenseAgreementList, featureGroupsList, vspQschema; + let currentSoftwareProduct = {}, currentSoftwareProductWithLicensingData = {}, softwareProductCategories = [], + finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qdata = {}, dataMap = {}, genericFieldInfo = {}, qGenericFieldInfo = {}; let dummyFunc = () => {}; - before(function() { - currentSoftwareProduct = { - id: 'D4774719D085414E9D5642D1ACD59D20', - name: 'VSP', - description: 'dfdf', - category: 'category1', - subCategory: 'category1.subCategory', - vendorId: 'VLM_ID1', - vendorName: 'VLM1', - licensingVersion: '1.0', - licensingData: {} + beforeAll(function() { + finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2); + currentSoftwareProduct = VSPEditorFactory.build({ + id: 'RTRTG454545', + vendorId: finalizedLicenseModelList[0].id, + vendorName: finalizedLicenseModelList[0].vendorName + }); + softwareProductCategories = CategoryWithSubFactory.buildList(2, {}, {quantity: 1}); + licenseAgreementList = LicenseAgreementStoreFactory.buildList(2); + featureGroupsList = FeatureGroupStoreFactory.buildList(2, {referencingLicenseAgreements: [licenseAgreementList[0].id]}); + qdata = VspQdataFactory.build(); + dataMap = VspDataMapFactory.build(); + currentSoftwareProductWithLicensingData = { + ...currentSoftwareProduct, + licensingData: { + licenseAgreement: licenseAgreementList[0].id, + featureGroups: [featureGroupsList[0].id] + } + }; + genericFieldInfo = { + 'name': { + isValid: true, + errorText: '', + validations: [{type: 'validateName', data: true}, {type: 'maxLength', data: 120}, { + type: 'required', + data: true + }] + }, + 'description': { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + } }; - categories = [{ - uniqueId: 'category1', - subcategories: [{ - uniqueId: 'subCategory' - }] - }, { - uniqueId: 'category2', - subcategories: [{ - uniqueId: 'subCategory2' - }] - }]; - finalizedLicenseModelList = [{ - id: 'VLM_ID1', - name: 'VLM1' - }]; - licenseAgreementList = [{id: 'LA_ID1'}, {id: 'LA_ID2'}]; - featureGroupsList = [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ]; - vspQschema = vspQuestionnaireSchema; + qGenericFieldInfo = SchemaGenericFieldInfoFactory.build(); }); it('should mapper exist', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('should mapper return vsp basic data', () => { + var obj = { softwareProduct: { softwareProductEditor: { - data: currentSoftwareProduct + data: currentSoftwareProduct, + genericFieldInfo }, - softwareProductCategories: categories, + softwareProductCategories, softwareProductQuestionnaire: { - qdata: {}, - qschema: vspQschema + qdata, + genericFieldInfo: qGenericFieldInfo, + dataMap } }, - finalizedLicenseModelList: finalizedLicenseModelList, + finalizedLicenseModelList, licenseModel: { licenseAgreement: { licenseAgreementList: [] @@ -96,35 +102,32 @@ describe('Software Product Details: ', function () { expect(result.currentSoftwareProduct).toEqual(currentSoftwareProduct); expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList); expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0); - expect(finalizedLicenseModelList).toInclude({ + expect(finalizedLicenseModelList[0]).toMatchObject({ id: result.currentSoftwareProduct.vendorId, - name: result.currentSoftwareProduct.vendorName + vendorName: result.currentSoftwareProduct.vendorName }); - expect(result.softwareProductCategories).toEqual(categories); + expect(result.softwareProductCategories).toEqual(softwareProductCategories); expect(result.licenseAgreementList).toEqual([]); expect(result.featureGroupsList).toEqual([]); - expect(result.qdata).toEqual({}); - expect(result.qschema).toEqual(vspQschema); + expect(result.qdata).toEqual(qdata); + expect(result.dataMap).toEqual(dataMap); + expect(result.isFormValid).toEqual(true); expect(result.isReadOnlyMode).toEqual(true); }); it('should mapper return vsp data with selected licenseAgreement and featureGroup', () => { - let vspWithLicensingData = { - ...currentSoftwareProduct, - licensingData: { - licenseAgreement: 'LA_ID1', - featureGroups: [{enum: 'FG_ID1', title: 'FG1'}] - } - }; + var obj = { softwareProduct: { softwareProductEditor: { - data: vspWithLicensingData + data: currentSoftwareProductWithLicensingData, + genericFieldInfo }, - softwareProductCategories: categories, + softwareProductCategories, softwareProductQuestionnaire: { - qdata: {}, - qschema: vspQschema + qdata, + genericFieldInfo: qGenericFieldInfo, + dataMap } }, finalizedLicenseModelList: finalizedLicenseModelList, @@ -139,51 +142,36 @@ describe('Software Product Details: ', function () { }; var result = mapStateToProps(obj); - expect(result.currentSoftwareProduct).toEqual(vspWithLicensingData); + expect(result.currentSoftwareProduct).toEqual(currentSoftwareProductWithLicensingData); expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList); expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0); - expect(result.finalizedLicenseModelList).toInclude({ + expect(result.finalizedLicenseModelList[0]).toMatchObject({ id: result.currentSoftwareProduct.vendorId, - name: result.currentSoftwareProduct.vendorName + vendorName: result.currentSoftwareProduct.vendorName }); - expect(result.softwareProductCategories).toEqual(categories); + expect(result.softwareProductCategories).toEqual(softwareProductCategories); expect(result.licenseAgreementList).toEqual(licenseAgreementList); - expect(result.licenseAgreementList).toInclude({id: result.currentSoftwareProduct.licensingData.licenseAgreement}); + expect(result.licenseAgreementList[0]).toMatchObject({...licenseAgreementList[0], id: result.currentSoftwareProduct.licensingData.licenseAgreement}); result.currentSoftwareProduct.licensingData.featureGroups.forEach(fg => { - expect(featureGroupsList).toInclude({ - id: fg.enum, - name: fg.title, - referencingLicenseAgreements: [result.currentSoftwareProduct.licensingData.licenseAgreement] - }); - expect(result.featureGroupsList).toInclude(fg); + expect(featureGroupsList[0]).toMatchObject({...featureGroupsList[0], id: fg}); }); - expect(result.qdata).toEqual({}); - expect(result.qschema).toEqual(vspQschema); + expect(result.qdata).toEqual(qdata); expect(result.isReadOnlyMode).toEqual(true); }); it('VSP Details view test', () => { + let params = { - currentSoftwareProduct: currentSoftwareProduct, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + currentSoftwareProduct, + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList, + genericFieldInfo, + qGenericFieldInfo, }; var renderer = TestUtils.createRenderer(); renderer.render( @@ -196,42 +184,26 @@ describe('Software Product Details: ', function () { onVendorParamChanged = {dummyFunc}/> ); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('in view: should change vendorId and update vsp licensing-version', done => { - let vspWithLicensingData = { - ...currentSoftwareProduct, - licensingData: { - licenseAgreement: 'LA_ID1', - featureGroups: [{enum: 'FG_ID1', title: 'FG1'}] - } - }; + let params = { - currentSoftwareProduct: vspWithLicensingData, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + currentSoftwareProduct: currentSoftwareProductWithLicensingData, + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onVendorChangedListener = (deltaData) => { - expect(deltaData.vendorId).toEqual('VLM_ID2'); - expect(deltaData.vendorName).toEqual('VLM2'); + expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id); + expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName); expect(deltaData.licensingVersion).toEqual(''); expect(deltaData.licensingData).toEqual({}); done(); @@ -241,7 +213,10 @@ describe('Software Product Details: ', function () { currentSoftwareProduct = {params.currentSoftwareProduct} softwareProductCategories = {params.softwareProductCategories} qdata = {params.qdata} - qschema = {params.qschema} + qGenericFieldInfo = {params.qGenericFieldInfo} + genericFieldInfo = {params.genericFieldInfo} + isFormValid={params.isFormValid} + dataMap={params.dataMap} finalizedLicenseModelList = {params.finalizedLicenseModelList} licenseAgreementList = {params.licenseAgreementList} featureGroupsList = {params.featureGroupsList} @@ -250,37 +225,27 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>); - expect(vspDetailsView).toExist(); - vspDetailsView.onVendorParamChanged({vendorId: 'VLM_ID2'}); + expect(vspDetailsView).toBeTruthy(); + vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id}); }); it('in view: should change licensing-version and update licensing data', done => { let params = { currentSoftwareProduct: currentSoftwareProduct, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onVendorChangedListener = (deltaData) => { - expect(deltaData.vendorId).toEqual('VLM_ID2'); - expect(deltaData.vendorName).toEqual('VLM2'); - expect(deltaData.licensingVersion).toEqual('2.0'); + expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id); + expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName); + expect(deltaData.licensingVersion).toEqual(finalizedLicenseModelList[1].viewableVersion[0]); expect(deltaData.licensingData).toEqual({}); done(); }; @@ -292,36 +257,26 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>); - expect(vspDetailsView).toExist(); - vspDetailsView.onVendorParamChanged({vendorId: 'VLM_ID2', licensingVersion: '2.0'}); + expect(vspDetailsView).toBeTruthy(); + vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id, licensingVersion: finalizedLicenseModelList[1].viewableVersion[0]}); }); it('in view: should change subcategory', done => { let params = { currentSoftwareProduct: currentSoftwareProduct, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onDataChangedListener = ({category, subCategory}) => { - expect(category).toEqual('category2'); - expect(subCategory).toEqual('subCategory2'); + expect(category).toEqual(softwareProductCategories[1].uniqueId); + expect(subCategory).toEqual(softwareProductCategories[1].subcategories[0].uniqueId); done(); }; @@ -332,45 +287,29 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {dummyFunc}/>); - expect(vspDetailsView).toExist(); - vspDetailsView.onSelectSubCategory('subCategory2'); + expect(vspDetailsView).toBeTruthy(); + vspDetailsView.onSelectSubCategory(softwareProductCategories[1].subcategories[0].uniqueId); }); it('in view: should change feature groups', done => { - let vspWithLicensingData = { - ...currentSoftwareProduct, - licensingData: { - licenseAgreement: 'LA_ID1', - featureGroups: [{enum: 'FG_ID1', title: 'FG1'}] - } - }; + let params = { - currentSoftwareProduct: vspWithLicensingData, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + currentSoftwareProduct: currentSoftwareProductWithLicensingData, + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onDataChangedListener = ({licensingData}) => { - expect(licensingData.licenseAgreement).toEqual('LA_ID1'); + expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[0].id); expect(licensingData.featureGroups).toEqual([ - {enum: 'FG_ID1', title: 'FG1'}, - {enum: 'FG_ID2', title: 'FG2'} + {enum: featureGroupsList[0].id, title: featureGroupsList[0].name}, + {enum: featureGroupsList[1].id, title: featureGroupsList[1].name} ]); done(); }; @@ -382,45 +321,29 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {dummyFunc}/>); - expect(vspDetailsView).toExist(); + expect(vspDetailsView).toBeTruthy(); vspDetailsView.onFeatureGroupsChanged({featureGroups: [ - {enum: 'FG_ID1', title: 'FG1'}, - {enum: 'FG_ID2', title: 'FG2'} + {enum: featureGroupsList[0].id, title: featureGroupsList[0].name}, + {enum: featureGroupsList[1].id, title: featureGroupsList[1].name} ]}); }); it('in view: should change license agreement', done => { - let vspWithLicensingData = { - ...currentSoftwareProduct, - licensingData: { - licenseAgreement: 'LA_ID1', - featureGroups: [{enum: 'FG_ID1', title: 'FG1'}] - } - }; + let params = { - currentSoftwareProduct: vspWithLicensingData, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + currentSoftwareProduct: currentSoftwareProductWithLicensingData, + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onDataChangedListener = ({licensingData}) => { - expect(licensingData.licenseAgreement).toEqual('LA_ID2'); + expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[1].id); expect(licensingData.featureGroups).toEqual([]); done(); }; @@ -432,7 +355,7 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {dummyFunc}/>); - expect(vspDetailsView).toExist(); - vspDetailsView.onLicensingDataChanged({licenseAgreement: 'LA_ID2', featureGroups: []}); + expect(vspDetailsView).toBeTruthy(); + vspDetailsView.onLicensingDataChanged({licenseAgreement: licenseAgreementList[1].id, featureGroups: []}); }); }); diff --git a/openecomp-ui/test/softwareProduct/details/test.js b/openecomp-ui/test/softwareProduct/details/test.js index 9803b1611d..df84d184ce 100644 --- a/openecomp-ui/test/softwareProduct/details/test.js +++ b/openecomp-ui/test/softwareProduct/details/test.js @@ -1,84 +1,65 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; -import {cloneAndSet} from 'test-utils/Util.js'; +import {cloneAndSet, buildFromExistingObject} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductCreationActionHelper from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js'; +import {forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; + +import {VSPEditorFactory, VSPEditorPostFactory, VSPEditorFactoryWithLicensingData, VSPEditorPostFactoryWithLicensingData} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {CategoryFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; +import {heatSetupManifest} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js'; + +import { FeatureGroupStoreFactory as FeatureGroup} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {LicenseAgreementStoreFactory as LicenseAgreement} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + describe('Software Product Module Tests', function () { it('Get Software Products List', () => { const store = storeCreator(); deepFreeze(store.getState()); - - const softwareProductList = [ - { - name: 'VSP1', - description: 'hjhj', - version: '0.1', - id: 'EBADF561B7FA4A788075E1840D0B5971', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '5259EDE4CC814DC9897BA6F69E2C971B', - vendorName: 'Vendor', - checkinStatus: 'CHECK_OUT', - licensingData: { - 'featureGroups': [] - } - }, - { - name: 'VSP2', - description: 'dfdfdfd', - version: '0.1', - id: '2F47447D22DB4C53B020CA1E66201EF2', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '5259EDE4CC814DC9897BA6F69E2C971B', - vendorName: 'Vendor', - checkinStatus: 'CHECK_OUT', - licensingData: { - featureGroups: [] - } - } - ]; - + const softwareProductList = VSPEditorFactory.buildList(2); deepFreeze(softwareProductList); - deepFreeze(store.getState()); - const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', softwareProductList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-software-products/'); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/'); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductList}; }); + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/?versionFilter=Final'); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + return SoftwareProductActionHelper.fetchSoftwareProductList(store.dispatch).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(store.dispatch); + }).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -86,62 +67,195 @@ describe('Software Product Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductPostRequest = deepFreeze({ - name: 'vsp1', - description: 'string', - vendorId: '1', - vendorName: 'Vendor', - icon: 'icon', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - licensingData: {} - }); + const softwareProductPostRequest = VSPEditorPostFactory.build(); + deepFreeze(softwareProductPostRequest); + const idFromResponse = '1'; + const expectedVSP = VSPEditorPostFactory.build({id: idFromResponse, vendorId: softwareProductPostRequest.vendorId}); + deepFreeze(expectedVSP); - const softwareProductToAdd = deepFreeze({ - ...softwareProductPostRequest + mockRest.addHandler('post', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/'); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); + return { + vspId: idFromResponse + }; }); - const softwareProductIdFromResponse = 'ADDED_ID'; - const softwareProductAfterAdd = deepFreeze({ - ...softwareProductToAdd, - id: softwareProductIdFromResponse + return SoftwareProductCreationActionHelper.createSoftwareProduct(store.dispatch, { + softwareProduct: softwareProductPostRequest + }).then((response) => { + expect(response.vspId).toEqual(idFromResponse); }); + }); + + it('Fetch Software Product with manifest', () => { + const store = storeCreator(); + deepFreeze(store.getState()); - const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductAfterAdd]); + const softwareProductPostRequest = VSPEditorPostFactory.build(); + deepFreeze(softwareProductPostRequest); + + const expectedGenericInfo = { + '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}] + } + }; + const expectedFormName = forms.VENDOR_SOFTWARE_PRODUCT_DETAILS; + + const idFromResponse = '1'; + const version = { id: '0.1', label: '0.1'}; + const expectedVSP = VSPEditorPostFactory.build({id: idFromResponse, vendorId: softwareProductPostRequest.vendorId}); + deepFreeze(expectedVSP); + let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductEditor.data', expectedVSP); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.genericFieldInfo', expectedGenericInfo); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.formName', expectedFormName); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductQuestionnaire', {qdata: {}, dataMap: {}, qgenericFieldInfo: {}}); + + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductAttachments.heatValidation', { + 'attachmentsTree': {}, + 'errorList': [], + 'selectedNode': 'All' + }); + let manifest = heatSetupManifest.build(); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductAttachments.heatSetup', manifest); - mockRest.addHandler('create', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-software-products/'); - expect(data).to.deep.equal(softwareProductPostRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('post', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/'); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); return { - vspId: softwareProductIdFromResponse + vspId: idFromResponse, + version }; }); + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return expectedVSP; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}/questionnaire`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {data: JSON.stringify({}), schema: JSON.stringify({})}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}/orchestration-template-candidate/manifest`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return manifest; + }); + return SoftwareProductCreationActionHelper.createSoftwareProduct(store.dispatch, { - softwareProduct: softwareProductToAdd + softwareProduct: softwareProductPostRequest + }).then(() => { + return SoftwareProductActionHelper.fetchSoftwareProduct(store.dispatch, {softwareProductId: idFromResponse, version}); }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(store.dispatch, {softwareProductId: idFromResponse, version}); + }).then(() => { + expect(store.getState()).toEqual(expectedStore); + let newName = 'newName'; + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.formReady', null); + ValidationHelper.dataChanged(store.dispatch, {deltaData: {'name': newName}, formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS}); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.data.name', newName); + expect(store.getState()).toEqual(expectedStore); }); }); + + it('Load and edit Software Product licensing data', () => { + const store = storeCreator(); + + const softwareProductPostRequest = VSPEditorPostFactory.build(); + deepFreeze(softwareProductPostRequest); + + const licenseModelId = softwareProductPostRequest.vendorId; + const LMVersion = VersionControllerUtilsFactory.build().version; + const secondLicenseModelId = 'secondLicenseModelId'; + + let FG1 = FeatureGroup.build(); + let LA1 = LicenseAgreement.build({ + featureGroupsIds: [FG1.id] + }); + + let FG2 = FeatureGroup.build(); + let LA2 = LicenseAgreement.build({ + featureGroupsIds: [FG2.id] + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/sdc1/feProxy/rest/v1/categories/resources/'); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return []; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-license-models/?versionFilter=Final'); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModelId}/versions/${LMVersion.id}/license-agreements`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: [LA1]}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModelId}/versions/${LMVersion.id}/feature-groups`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: [FG1]}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${secondLicenseModelId}/versions/${LMVersion.id}/license-agreements`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: [LA2]}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${secondLicenseModelId}/versions/${LMVersion.id}/feature-groups`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: [FG2]}; + }); + + return SoftwareProductActionHelper.loadSoftwareProductDetailsData(store.dispatch, {licenseModelId, licensingVersion: LMVersion}).then(() => { + let state = store.getState(); + expect(state.licenseModel.licenseAgreement.licenseAgreementList).toEqual([LA1]); + expect(state.licenseModel.featureGroup.featureGroupsList).toEqual([FG1]); + return SoftwareProductActionHelper.softwareProductEditorVendorChanged(store.dispatch, + {deltaData: {vendorId: secondLicenseModelId, licensingVersion: LMVersion}, + formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS}); + }).then(() => { + let state = store.getState(); + expect(state.licenseModel.licenseAgreement.licenseAgreementList).toEqual([LA2]); + expect(state.licenseModel.featureGroup.featureGroupsList).toEqual([FG2]); + }); + }); + it('Save Software product', () => { - const softwareProduct = { - name: 'VSP5', - id: '4730033D16C64E3CA556AB0AC4478218', - description: 'A software model for Fortigate.', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - licensingVersion: '1.0', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; + + const softwareProduct = VSPEditorFactoryWithLicensingData.build(); deepFreeze(softwareProduct); const store = storeCreator({ @@ -152,15 +266,20 @@ describe('Software Product Module Tests', function () { }); deepFreeze(store.getState()); - const toBeUpdatedSoftwareProductId = softwareProduct.id; - const softwareProductUpdateData = { - ...softwareProduct, + const dataForUpdate = { name: 'VSP5_UPDATED', description: 'A software model for Fortigate._UPDATED' }; + + const toBeUpdatedSoftwareProductId = softwareProduct.id; + let softwareProductUpdateData = VSPEditorPostFactoryWithLicensingData.build(dataForUpdate); + delete softwareProductUpdateData.version; + + const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId, version: softwareProduct.version}); + deepFreeze(softwareProductUpdateData); - const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductUpdateData]); + const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductPutRequest]); const questionnaireData = { general: { affinityData: { @@ -171,60 +290,30 @@ describe('Software Product Module Tests', function () { }; deepFreeze(questionnaireData); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - const expectedData = { - name: 'VSP5_UPDATED', - description: 'A software model for Fortigate._UPDATED', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - licensingVersion: '1.0', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}`); - expect(data).to.deep.equal(expectedData); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}`); + expect(data).toEqual(softwareProductUpdateData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/questionnaire`); - expect(data).to.deep.equal(questionnaireData); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}/questionnaire`); + expect(data).toEqual(questionnaireData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductActionHelper.updateSoftwareProduct(store.dispatch, { - softwareProduct: softwareProductUpdateData, + softwareProduct: softwareProductPutRequest, qdata: questionnaireData }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); + it('Save Software product data only', () => { - const softwareProduct = { - name: 'VSP5', - id: '4730033D16C64E3CA556AB0AC4478218', - description: 'A software model for Fortigate.', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - licensingVersion: '1.0', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; + + const softwareProduct = VSPEditorFactoryWithLicensingData.build(); deepFreeze(softwareProduct); const store = storeCreator({ @@ -236,61 +325,35 @@ describe('Software Product Module Tests', function () { deepFreeze(store.getState()); const expectedStore = store.getState(); - const toBeUpdatedSoftwareProductId = softwareProduct.id; - const softwareProductUpdateData = { - ...softwareProduct, + const dataForUpdate = { name: 'VSP5_UPDATED', description: 'A software model for Fortigate._UPDATED' }; + + const toBeUpdatedSoftwareProductId = softwareProduct.id; + let softwareProductUpdateData = VSPEditorPostFactoryWithLicensingData.build(dataForUpdate); + delete softwareProductUpdateData.version; + + const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId, version: softwareProduct.version}); + deepFreeze(softwareProductUpdateData); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - const expectedData = { - name: 'VSP5_UPDATED', - description: 'A software model for Fortigate._UPDATED', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - licensingVersion: '1.0', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}`); - expect(data).to.deep.equal(expectedData); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}`); + expect(data).toEqual(softwareProductUpdateData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductActionHelper.updateSoftwareProductData(store.dispatch, { - softwareProduct: softwareProductUpdateData + softwareProduct: softwareProductPutRequest }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Save Software product questionnaire only', () => { - const softwareProduct = { - name: 'VSP5', - id: '4730033D16C64E3CA556AB0AC4478218', - description: 'A software model for Fortigate.', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; + const softwareProduct = VSPEditorFactoryWithLicensingData.build(); deepFreeze(softwareProduct); const store = storeCreator({ @@ -313,71 +376,30 @@ describe('Software Product Module Tests', function () { }; deepFreeze(questionnaireData); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/questionnaire`); - expect(data).to.deep.equal(questionnaireData); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}/questionnaire`); + expect(data).toEqual(questionnaireData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductActionHelper.updateSoftwareProductQuestionnaire(store.dispatch, { softwareProductId: softwareProduct.id, + version: softwareProduct.version, qdata: questionnaireData }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Handle category without subcategories', () => { - const categories = deepFreeze([ - { - name: 'Resource Category 1', - normalizedName: 'resource category 1', - uniqueId: 'resourceNewCategory.resource category 1', - subcategories: [ - { - name: 'Sub Category for RC 1', - normalizedName: 'sub category for rc 1', - uniqueId: 'resourceNewCategory.resource category 1.sub category for rc 1' - }, - { - name: 'SC4RC2', - normalizedName: 'sc4rc2', - uniqueId: 'resourceNewCategory.resource category 1.sc4rc2' - }, - { - name: 'SC4RC1', - normalizedName: 'sc4rc1', - uniqueId: 'resourceNewCategory.resource category 1.sc4rc1' - } - ] - }, - { - name: 'Eeeeee', - normalizedName: 'eeeeee', - uniqueId: 'resourceNewCategory.eeeeee' - }, - { - name: 'Some Recource', - normalizedName: 'some recource', - uniqueId: 'resourceNewCategory.some recource', - subcategories: [ - { - name: 'Second Sub Category for S', - normalizedName: 'second sub category for s', - uniqueId: 'resourceNewCategory.some recource.second sub category for s' - }, - { - name: 'Sub Category for Some Rec', - normalizedName: 'sub category for some rec', - uniqueId: 'resourceNewCategory.some recource.sub category for some rec' - } - ] - } - ]); - const category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory('resourceNewCategory.some recource.sub category for some rec', categories); - expect(category).to.equal('resourceNewCategory.some recource'); + + const categories = CategoryFactory.buildList(3); + categories[0].subcategories = CategoryFactory.buildList(3); + categories[2].subcategories = CategoryFactory.buildList(3); + + const category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory(categories[2].subcategories[2].uniqueId, categories); + expect(category).toEqual(categories[2].uniqueId); }); }); - diff --git a/openecomp-ui/test/softwareProduct/details/vspQschema.js b/openecomp-ui/test/softwareProduct/details/vspQschema.js index 5612b19991..fb8ac6fd91 100644 --- a/openecomp-ui/test/softwareProduct/details/vspQschema.js +++ b/openecomp-ui/test/softwareProduct/details/vspQschema.js @@ -1,21 +1,17 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ export const vspQschema = { diff --git a/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js new file mode 100644 index 0000000000..f06ad61e4f --- /dev/null +++ b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js @@ -0,0 +1,177 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; + +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; +import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; +import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {default as SoftwareProductQSchemaFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; +import {default as VspQdataFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js'; +import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; +import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; + + +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js'; +import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx'; + + +describe('Software Product Landing Page: ', function () { + + let currentSoftwareProduct = {}, softwareProductCategories = [], + finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qschema, qdata = {}; + const dummyFunc = () => {}; + beforeAll(function() { + finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2); + currentSoftwareProduct = VSPEditorFactory.build({id:'RTRTG454545', vendorId: finalizedLicenseModelList[0].id, vendorName: finalizedLicenseModelList[0].name}); + softwareProductCategories = CategoryWithSubFactory.buildList(2,{},{quantity: 1}); + licenseAgreementList = LicenseAgreementStoreFactory.buildList(2); + featureGroupsList = FeatureGroupStoreFactory.buildList(2,{referencingLicenseAgreements:[licenseAgreementList[0].id]}); + qdata = VspQdataFactory.build(); + qschema = SoftwareProductQSchemaFactory.build(qdata); + + }); + + + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should mapper return vsp basic data', () => { + const obj = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductCategories, + softwareProductQuestionnaire: { + qdata, + qschema + }, + softwareProductComponents: { + componentsList:[] + } + }, + finalizedLicenseModelList, + licenseModel: { + licenseAgreement: { + licenseAgreementList + }, + featureGroup: { + featureGroupsList + } + } + }; + + const result = mapStateToProps(obj); + expect(result.currentSoftwareProduct).toBeTruthy(); + expect(result.isReadOnlyMode).toEqual(true); + + }); + + it('vsp landing basic view', () => { + + const params = { + currentSoftwareProduct, + isReadOnlyMode: false, + componentsList: VSPComponentsFactory.buildList(2) + }; + + let vspLandingView = TestUtils.renderIntoDocument(); + expect(vspLandingView).toBeTruthy(); + }); + + it('vsp landing handleOnDragEnter test ', () => { + + const params = { + currentSoftwareProduct, + isReadOnlyMode: false, + componentsList: VSPComponentsFactory.buildList(2) + }; + + let vspLandingView = TestUtils.renderIntoDocument(); + expect(vspLandingView).toBeTruthy(); + vspLandingView.handleOnDragEnter(false); + expect(vspLandingView.state.dragging).toEqual(true); + }); + + + it('vsp landing handleImportSubmit test ', () => { + + const params = { + currentSoftwareProduct, + isReadOnlyMode: false, + componentsList: VSPComponentsFactory.buildList(2), + onUploadConfirmation: dummyFunc, + onUpload: dummyFunc, + onInvalidFileSizeUpload: dummyFunc + }; + + let vspLandingView = TestUtils.renderIntoDocument(); + expect(vspLandingView).toBeTruthy(); + const files = [ + { + name: 'aaa', + size: 123 + } + ]; + + vspLandingView.handleImportSubmit(files, false); + expect(vspLandingView.state.dragging).toEqual(false); + expect(vspLandingView.state.fileName).toEqual(files[0].name); + const files1 = [ + { + name: 'bbb', + size: 0 + } + ]; + vspLandingView.handleImportSubmit(files1, false); + }); + + it('vsp landing handleImportSubmit with damaged file test ', () => { + + const params = { + currentSoftwareProduct, + isReadOnlyMode: false, + componentsList: VSPComponentsFactory.buildList(2), + onUploadConfirmation: dummyFunc, + onUpload: dummyFunc, + onInvalidFileSizeUpload: dummyFunc + }; + + let vspLandingView = TestUtils.renderIntoDocument(); + expect(vspLandingView).toBeTruthy(); + const files = [ + { + name: 'aaa', + size: 0 + } + ]; + + vspLandingView.handleImportSubmit(files, false); + expect(vspLandingView.state.dragging).toEqual(false); + expect(vspLandingView.state.fileName).toEqual(''); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js index a7f7b2b0c2..6ef6bcf02a 100644 --- a/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js +++ b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js @@ -1,63 +1,39 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 expect from 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworks.js'; import SoftwareProductNetworksView from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +//import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + +import VSPNetworkFactory from 'test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('SoftwareProductNetworks Mapper and View Classes', () => { it ('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it ('mapStateToProps data test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); - const networksList = [ - { - name:'dummy_net_1', - dhcp:true, - 'id':'7F60CD390458421DA588AF4AD217B93F' - }, - { - name:'dummy_net_2', - dhcp:true, - 'id':'AD217B93F7F60CD390458421DA588AF4' - } - ]; + const networksList = VSPNetworkFactory.buildList(2); var obj = { softwareProduct: { @@ -71,49 +47,21 @@ describe('SoftwareProductNetworks Mapper and View Classes', () => { } }; var results = mapStateToProps(obj); - expect(results.networksList,).toExist(); + expect(results.networksList).toBeTruthy(); }); it ('view simple test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); - const networksList = [ - { - name:'dummy_net_1', - dhcp:true, - 'id':'7F60CD390458421DA588AF4AD217B93F' - }, - { - name:'dummy_net_2', - dhcp:true, - 'id':'AD217B93F7F60CD390458421DA588AF4' - } - ]; + const networksList = VSPNetworkFactory.buildList(2); - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); var renderer = TestUtils.createRenderer(); renderer.render(); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); diff --git a/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js b/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js index 2920803c64..1475ae610e 100644 --- a/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js +++ b/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js @@ -1,62 +1,49 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductNetworksActionHelper from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +import VSPNetworkFactory from 'test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js'; const softwareProductId = '123'; describe('Software Product Networks ActionHelper Tests', function () { it('Get Software Products Networks List', () => { const store = storeCreator(); + const vcData = VersionControllerUtilsFactory.build(); deepFreeze(store.getState()); - const networksList = [ - { - name:'dummy_net_1', - dhcp:true, - 'id':'7F60CD390458421DA588AF4AD217B93F' - }, - { - name:'dummy_net_2', - dhcp:true, - 'id':'AD217B93F7F60CD390458421DA588AF4' - } - ]; + const networksList = VSPNetworkFactory.buildList(2); deepFreeze(networksList); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductNetworks.networksList', networksList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/networks`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${vcData.version.id}/networks`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: networksList}; }); - return SoftwareProductNetworksActionHelper.fetchNetworksList(store.dispatch, {softwareProductId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductNetworksActionHelper.fetchNetworksList(store.dispatch, {softwareProductId, version: vcData.version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); diff --git a/openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js b/openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js new file mode 100644 index 0000000000..b4df9bebd9 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js @@ -0,0 +1,62 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditor.js'; +import SoftwareProductProcessesEditorView from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorView.jsx'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; + +describe('Software Product Processes Editor Module Tests', function () { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should return empty data', () => { + + const currentSoftwareProduct = VSPEditorFactory.build(); + + var state = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductProcesses: + { + processesList: [], + processesEditor: {data: {}} + } + } + }; + + var results = mapStateToProps(state); + expect(results.data).toEqual({}); + expect(results.previousData).toEqual(undefined); + }); + + it('jsx view test', () => { + var view = TestUtils.renderIntoDocument( {}} + onSubmit={() => {}} + onClose={() => {}}/>); + expect(view).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js b/openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js new file mode 100644 index 0000000000..2d7da91cbb --- /dev/null +++ b/openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js @@ -0,0 +1,75 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcesses.js'; +import SoftwareProductProcessesView from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesView.jsx'; + +import {VSPProcessStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; + +describe('SoftwareProductProcesses Mapper and View Classes', () => { + it ('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it ('mapStateToProps data test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + + const processesList = VSPProcessStoreFactory.buildList(2); + + var obj = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductProcesses: + { + processesList, + processesEditor: {data: {}} + } + } + }; + var results = mapStateToProps(obj); + expect(results.processesList).toBeTruthy(); + }); + + it ('view simple test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + const processesList = VSPProcessStoreFactory.buildList(2); + + const versionControllerData = VSPComponentsVersionControllerFactory.build(); + + + var renderer = TestUtils.createRenderer(); + renderer.render( + {}} + onEditProcess={() => {}} + onDeleteProcess={() => {}} + isDisplayEditor={false} + isReadOnlyMode={false} /> + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + }); +}); diff --git a/openecomp-ui/test/softwareProduct/processes/test.js b/openecomp-ui/test/softwareProduct/processes/test.js index 73f22a7898..43110d2e55 100644 --- a/openecomp-ui/test/softwareProduct/processes/test.js +++ b/openecomp-ui/test/softwareProduct/processes/test.js @@ -1,38 +1,44 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import Configuration from 'sdc-app/config/Configuration.js'; import SoftwareProductProcessesActionHelper from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js'; +import { + VSPProcessPostFactory, + VSPProcessStoreFactory, + VSPProcessPostFactoryWithType, + VSPProcessStoreFactoryWithType, + VSPProcessStoreWithFormDataFactory, + VSPProcessPostWithFormDataFactory, + VSPProcessStoreWithArtifactNameFactory } from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; +import {buildFromExistingObject} from 'test-utils/Util.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; const softwareProductId = '123'; +const version = VSPEditorFactory.build().version; describe('Software Product Processes Module Tests', function () { let restPrefix = ''; - before(function() { + beforeAll(function() { restPrefix = Configuration.get('restPrefix'); deepFreeze(restPrefix); }); @@ -45,27 +51,18 @@ describe('Software Product Processes Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductPostRequest = { - name: 'Pr1', - description: 'string' - }; - const softwareProductProcessToAdd = { - name: 'Pr1', - description: 'string' - }; const softwareProductProcessFromResponse = 'ADDED_ID'; - const softwareProductProcessAfterAdd = { - ...softwareProductProcessToAdd, - id: softwareProductProcessFromResponse - }; + + const softwareProductProcessAfterAdd = VSPProcessStoreFactory.build({id: softwareProductProcessFromResponse}); + const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactory, softwareProductProcessAfterAdd); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]); - mockRest.addHandler('create', ({data, options, baseUrl}) => { + mockRest.addHandler('post', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`); - expect(data).to.deep.equal(softwareProductPostRequest); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); return { returnCode: 'OK', value: softwareProductProcessFromResponse @@ -74,64 +71,88 @@ describe('Software Product Processes Module Tests', function () { return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, { - softwareProductId: softwareProductId, + softwareProductId, + version, previousProcess: null, - process: softwareProductProcessToAdd + process: softwareProductPostRequest } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); - it('Add Software Products Processes with uploaded file', () => { + it('Add Software Products Processes with type', () => { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductPostRequest = { - name: 'Pr1', - description: 'string' - }; - const softwareProductProcessToAdd = { - name: 'Pr1', - description: 'string', - formData: { - name: 'new artifact name' - } - }; const softwareProductProcessFromResponse = 'ADDED_ID'; - const softwareProductProcessAfterAdd = { - ...softwareProductProcessToAdd, - id: softwareProductProcessFromResponse - }; + + const softwareProductProcessAfterAdd = VSPProcessStoreFactoryWithType.build({id: softwareProductProcessFromResponse}); + const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactoryWithType, softwareProductProcessAfterAdd); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]); - mockRest.addHandler('create', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`); - expect(data).to.deep.equal(softwareProductPostRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('post', ({data, options, baseUrl}) => { + + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); return { returnCode: 'OK', value: softwareProductProcessFromResponse }; }); - mockRest.addHandler('create', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${softwareProductProcessAfterAdd.id}/upload`); - expect(data).to.deep.equal(softwareProductProcessToAdd.formData); - expect(options).to.equal(undefined); + return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, + { + softwareProductId, + version, + previousProcess: null, + process: softwareProductPostRequest + } + ).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); + + it('Add Software Products Processes with uploaded file', () => { + + const store = storeCreator(); + deepFreeze(store.getState()); + + const softwareProductPostRequest = VSPProcessPostFactoryWithType.build(); + const softwareProductProcessToAdd = VSPProcessPostWithFormDataFactory.build(softwareProductPostRequest); + const softwareProductProcessAfterAdd = VSPProcessStoreWithFormDataFactory.build(); + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]); + + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); + return { + returnCode: 'OK', + value: softwareProductProcessAfterAdd.id + }; + }); + + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${softwareProductProcessAfterAdd.id}/upload`); + expect(data).toEqual(softwareProductProcessToAdd.formData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, { - softwareProductId: softwareProductId, + softwareProductId, + version, previousProcess: null, process: softwareProductProcessToAdd } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -139,14 +160,7 @@ describe('Software Product Processes Module Tests', function () { //** UPDATE //** it('Update Software Products Processes', () => { - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'string', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - } - ]; + const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(1); deepFreeze(softwareProductProcessesList); const store = storeCreator({ @@ -160,47 +174,47 @@ describe('Software Product Processes Module Tests', function () { const toBeUpdatedProcessId = softwareProductProcessesList[0].id; const previousProcessData = softwareProductProcessesList[0]; - const processUpdateData = { - ...softwareProductProcessesList[0], - name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + const processUpdateData = VSPProcessStoreWithArtifactNameFactory.build( + {...previousProcessData, + name: 'Pr1_UPDATED', + description: 'string_UPDATED', + type: 'Other' + } + ); + deepFreeze(processUpdateData); - const processPutRequest = { + const processPutRequest = VSPProcessPostFactory.build({ name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + description: 'string_UPDATED', + type: 'Other' + }); deepFreeze(processPutRequest); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [processUpdateData]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${toBeUpdatedProcessId}`); - expect(data).to.deep.equal(processPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${toBeUpdatedProcessId}`); + expect(data).toEqual(processPutRequest); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, { - softwareProductId: softwareProductId, + softwareProductId, + version, previousProcess: previousProcessData, process: processUpdateData } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Update Software Products Processes and uploaded file', () => { - const previousProcessData = { - id: 'EBADF561B7FA4A788075E1840D0B5971', - name: 'p1', - description: 'string', - artifactName: 'artifact' - }; + const previousProcessData = VSPProcessStoreWithArtifactNameFactory.build(); deepFreeze(previousProcessData); const store = storeCreator({ @@ -212,45 +226,47 @@ describe('Software Product Processes Module Tests', function () { }); deepFreeze(store.getState()); - const newProcessToUpdate = { + const newProcessToUpdate = VSPProcessStoreWithFormDataFactory.build({ ...previousProcessData, name: 'new name', formData: { name: 'new artifact name' } - }; + }); deepFreeze(newProcessToUpdate); - const newProcessToPutRequest = { + const newProcessToPutRequest = VSPProcessPostFactory.build({ name: newProcessToUpdate.name, - description: previousProcessData.description - }; + description: previousProcessData.description, + type: previousProcessData.type + }); deepFreeze(newProcessToPutRequest); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [newProcessToUpdate]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${previousProcessData.id}`); - expect(data).to.deep.equal(newProcessToPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${newProcessToUpdate.id}`); + expect(data).toEqual(newProcessToPutRequest); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - mockRest.addHandler('create', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${previousProcessData.id}/upload`); - expect(data).to.deep.equal(newProcessToUpdate.formData); - expect(options).to.equal(undefined); + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${newProcessToUpdate.id}/upload`); + expect(data).toEqual(newProcessToUpdate.formData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, { - softwareProductId: softwareProductId, + softwareProductId, + version, previousProcess: previousProcessData, process: newProcessToUpdate } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -261,20 +277,7 @@ describe('Software Product Processes Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - }, - { - name: 'Pr1', - description: 'hjhj', - id: '2F47447D22DB4C53B020CA1E66201EF2', - artifactName: 'artifact' - } - ]; + const softwareProductProcessesList = VSPProcessStoreFactory.buildList(2); deepFreeze(softwareProductProcessesList); @@ -283,14 +286,14 @@ describe('Software Product Processes Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', softwareProductProcessesList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductProcessesList}; }); - return SoftwareProductProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -298,33 +301,32 @@ describe('Software Product Processes Module Tests', function () { //** DELETE //** it('Delete Software Products Processes', () => { - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - } - ]; + const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(1); + const currentSoftwareProduct = VSPEditorFactory.build(); deepFreeze(softwareProductProcessesList); const store = storeCreator({ softwareProduct: { softwareProductProcesses: { processesList: softwareProductProcessesList + }, + softwareProductEditor: { + data: currentSoftwareProduct } } }); - const processId = 'EBADF561B7FA4A788075E1840D0B5971'; + const processId = softwareProductProcessesList[0].id; + const version = store.getState().softwareProduct.softwareProductEditor.data.version; + const versionId = version.id; deepFreeze(store.getState()); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', []); mockRest.addHandler('destroy', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${processId}`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/processes/${processId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return { results: { returnCode: 'OK' @@ -334,9 +336,10 @@ describe('Software Product Processes Module Tests', function () { return SoftwareProductProcessesActionHelper.deleteProcess(store.dispatch, { process: softwareProductProcessesList[0], - softwareProductId + softwareProductId, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -344,10 +347,7 @@ describe('Software Product Processes Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - let process = { - id: 'p_id', - name: 'p_name' - }; + let process = VSPProcessStoreFactory.build(); deepFreeze(process); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', process); @@ -355,7 +355,7 @@ describe('Software Product Processes Module Tests', function () { SoftwareProductProcessesActionHelper.openDeleteProcessesConfirm(store.dispatch, {process}); setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); done(); }, 100); }); @@ -369,7 +369,7 @@ describe('Software Product Processes Module Tests', function () { SoftwareProductProcessesActionHelper.hideDeleteConfirm(store.dispatch); setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); done(); }, 100); }); @@ -377,7 +377,7 @@ describe('Software Product Processes Module Tests', function () { //** //** CREATE/EDIT //** - it('Validating open Software Products Processes for create', done => { + it('Validating open Software Products Processes for create', () => { const store = storeCreator(); deepFreeze(store.getState()); @@ -387,28 +387,20 @@ describe('Software Product Processes Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process); SoftwareProductProcessesActionHelper.openEditor(store.dispatch); - - setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); - done(); - }, 100); + expect(store.getState().softwareProduct.softwareProductProcesses.processesEditor.data).toEqual(expectedStore.softwareProduct.softwareProductProcesses.processesEditor.data); }); - it('Validating close Software Products Processes from editing mode', done => { + it('Validating close Software Products Processes from editing mode', () => { const store = storeCreator(); deepFreeze(store.getState()); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor', {}); SoftwareProductProcessesActionHelper.closeEditor(store.dispatch); - - setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); - done(); - }, 100); + expect(store.getState()).toEqual(expectedStore); }); - it('Validating open Software Products Processes for editing', done => { + it('Validating open Software Products Processes for editing', () => { const store = storeCreator(); deepFreeze(store.getState()); @@ -418,42 +410,8 @@ describe('Software Product Processes Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process); SoftwareProductProcessesActionHelper.openEditor(store.dispatch, process); + expect(store.getState().softwareProduct.softwareProductProcesses.processesEditor.data).toEqual(expectedStore.softwareProduct.softwareProductProcesses.processesEditor.data); - setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); - done(); - }, 100); }); - it('Validating Software Products Processes dataChanged event', done => { - let process = {name: 'aa', description: 'xx'}; - deepFreeze(process); - - const store = storeCreator({ - softwareProduct: { - softwareProductProcesses: { - processesEditor: { - data: process - } - } - } - }); - deepFreeze(store.getState()); - - let deltaData = {name: 'bb'}; - deepFreeze(deltaData); - - let expectedProcess = {name: 'bb', description: 'xx'}; - deepFreeze(expectedProcess); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', expectedProcess); - - SoftwareProductProcessesActionHelper.processEditorDataChanged(store.dispatch, {deltaData}); - - setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); - done(); - }, 100); - }); }); - diff --git a/openecomp-ui/test/utils/errorResponseHandler.test.js b/openecomp-ui/test/utils/errorResponseHandler.test.js index fd9dec6a8d..40836f728a 100644 --- a/openecomp-ui/test/utils/errorResponseHandler.test.js +++ b/openecomp-ui/test/utils/errorResponseHandler.test.js @@ -1,28 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 deepFreeze from 'deep-freeze'; -import expect from 'expect'; + import {cloneAndSet} from '../../test-utils/Util.js'; import store from 'sdc-app/AppStore.js'; import errorResponseHandler from 'nfvo-utils/ErrorResponseHandler.js'; +import {typeEnum as modalType} from 'nfvo-components/modal/GlobalModalConstants.js'; describe('Error Response Handler Util', () => { @@ -44,15 +40,20 @@ describe('Error Response Handler Util', () => { }; deepFreeze(xhr); - const errorNotification = { - type: 'error', title: 'Error: SVC4122', msg: 'Error: Invalid data.', timeout: undefined, - validationResponse: undefined + const errorNotification = { + title: 'Error: SVC4122', + msg: 'Error: Invalid data.', + modalClassName: 'notification-modal', + type: modalType.ERROR }; - const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification); + + + + const expectedStore = cloneAndSet(store.getState(), 'modal', errorNotification); errorResponseHandler(xhr, textStatus, errorThrown); - setTimeout(function () { + setTimeout(function () { expect(store.getState()).toEqual(expectedStore); done(); }, 100); @@ -72,12 +73,15 @@ describe('Error Response Handler Util', () => { } }; deepFreeze(xhr); - - const errorNotification = { - type: 'error', title: 'Error: SVC4122', msg: 'Error: Invalid artifact type newType.', timeout: undefined, - validationResponse: undefined + + const errorNotification = { + title: 'Error: SVC4122', + msg: 'Error: Invalid artifact type newType.', + modalClassName: 'notification-modal', + type: modalType.ERROR }; - const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification); + + const expectedStore = cloneAndSet(store.getState(), 'modal', errorNotification); errorResponseHandler(xhr, textStatus, errorThrown); @@ -97,11 +101,14 @@ describe('Error Response Handler Util', () => { }; deepFreeze(xhr); - const errorNotification = { - type: 'error', title: 'AA', msg: 'Error: Invalid data.', timeout: undefined, - validationResponse: undefined + const errorNotification = { + title: 'AA', + msg: 'Error: Invalid data.', + modalClassName: 'notification-modal', + type: modalType.ERROR }; - const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification); + + const expectedStore = cloneAndSet(store.getState(), 'modal', errorNotification); errorResponseHandler(xhr, textStatus, errorThrown); @@ -118,12 +125,15 @@ describe('Error Response Handler Util', () => { responseText: 'Internal server error.' }; deepFreeze(xhr); - - const errorNotification = { - type: 'error', title: '500', msg: 'Internal server error.', timeout: undefined, - validationResponse: undefined + + const errorNotification = { + title: '500', + msg: 'Internal server error.', + modalClassName: 'notification-modal', + type: modalType.ERROR }; - const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification); + + const expectedStore = cloneAndSet(store.getState(), 'modal', errorNotification); errorResponseHandler(xhr, textStatus, errorThrown); diff --git a/openecomp-ui/test/utils/restApiUtil.test.js b/openecomp-ui/test/utils/restApiUtil.test.js deleted file mode 100644 index 2a5e69b02e..0000000000 --- a/openecomp-ui/test/utils/restApiUtil.test.js +++ /dev/null @@ -1,149 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -import expect from 'expect'; -import $ from 'jquery'; -import RestAPIUtil, {makeQueryParams} from 'src/nfvo-utils/RestAPIUtil'; - -const URL = 'http://bla.ble.blu/'; - -describe('RestAPIUtil Util class', () => { - - beforeEach(()=> { - $.ajax = (options) => options; - }); - - it('RestAPIUtil does exist', () => { - expect(RestAPIUtil).toExist(); - }); - - it('RestAPIUtil makeQueryParams does exist', () => { - expect(makeQueryParams).toExist(); - }); - - it('RestAPIUtil makeQueryParams params', () => { - const pageStart = 1, pageSize = 25; - const response = makeQueryParams({pagination: {pageStart, pageSize}}); - expect(response.pageStart).toBe(pageStart); - expect(response.pageSize).toBe(pageSize); - }); - - it('normal basic fetch', () => { - const response = RestAPIUtil.fetch(URL); - expect(response).toExist(); - }); - - it('no url', function () { - expect(function () { - RestAPIUtil.fetch(); - }).toThrow(/url/); - }); - - it('fetch with pagination', () => { - const pageStart = 1, pageSize = 25; - const response = RestAPIUtil.fetch(URL, {pagination: {pageStart, pageSize}}); - expect(response.pagination).toExist(); - expect(response.url).toInclude(`?pageStart=${pageStart}&pageSize=${pageSize}`); - }); - - it('fetch with sorting', () => { - const sortField = 'name', sortDir = 'ASCENDING'; - const response = RestAPIUtil.fetch(URL, {sorting: {sortField, sortDir}}); - expect(response.sorting).toExist(); - expect(response.url).toInclude(`?sortField=${sortField}&sortDir=${sortDir}`); - }); - - it('fetch with filtering', () => { - const baseFilter = [ - { - criterionValue: 'service', - fieldName: 'Brand', - operator: 'EQUALS', - type: 'STRING' - }, - { - criterionValue: 'resource', - fieldName: 'Brand', - operator: 'EQUALS', - type: 'STRING' - } - ]; - const response = RestAPIUtil.fetch(URL, {filtering: {filterCriteria: baseFilter, logicalRelation: 'OR'}}); - expect(response.filtering).toExist(); - expect(response.url).toInclude('?filter='); - }); - - it('fetch with qParams', () => { - const response = RestAPIUtil.fetch(URL, {qParams: {pageStart: 1, pageSize: 10}}); - expect(response.qParams).toExist(); - }); - - it('fetch with url on options', () => { - const response = RestAPIUtil.fetch(URL, {url:'12345', qParams: {pageStart: 1, pageSize: 10}}); - expect(response.qParams).toExist(); - }); - - it('fetch with url path param', () => { - let someData = 'data'; - const response = RestAPIUtil.fetch(`${URL}{someData}/`, {params: {someData}}); - expect(response.url).toInclude(`/${someData}/`); - }); - - it('fetch with url undefined path param', () => { - const response = RestAPIUtil.fetch(`${URL}{someData}/`, {params: {someData: undefined}}); - expect(response.url).toInclude('/undefined/'); - }); - - it('normal basic create', () => { - const response = RestAPIUtil.create(URL); - expect(response).toExist(); - }); - - it('create with FormData', () => { - let formData = new FormData(); - formData.append('username', 'Chris'); - const response = RestAPIUtil.create(URL, formData); - expect(response).toExist(); - }); - - it('create with FormData with md5', () => { - let formData = new FormData(); - formData.append('username', 'Chris'); - const response = RestAPIUtil.create(URL, formData, {md5: true}); - expect(response).toExist(); - }); - - it('create with file', () => { - let progressCallback = () => {}; - const response = RestAPIUtil.create(URL, {}, {progressCallback, fileSize: 123}); - expect(response).toExist(); - }); - - it('normal basic save', () => { - const response = RestAPIUtil.save(URL); - expect(response).toExist(); - }); - - it('normal basic delete', () => { - const response = RestAPIUtil.destroy(URL); - expect(response).toExist(); - }); - -}); diff --git a/openecomp-ui/test/utils/uuid.test.js b/openecomp-ui/test/utils/uuid.test.js index cd55baadea..21ac2712de 100644 --- a/openecomp-ui/test/utils/uuid.test.js +++ b/openecomp-ui/test/utils/uuid.test.js @@ -1,50 +1,45 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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 uuid from 'src/nfvo-utils/UUID.js'; -import expect from 'expect'; + describe('UUID', () => { it('function does exist', () => { - expect(uuid).toExist(); + expect(uuid).toBeTruthy(); }); it('generate UUID synchronously', () => { let result = uuid(undefined, true); - expect(result).toExist(); + expect(result).toBeTruthy(); }); it('generate UUID synchronously with number', () => { let result = uuid(5, true); - expect(result).toExist(); + expect(result).toBeTruthy(); }); it('generate UUID synchronously with number', () => { let result = uuid(1, true); - expect(result).toExist(); + expect(result).toBeTruthy(); }); it('generate UUID asynchronously', done => { uuid().then(result => { - expect(result).toExist(); + expect(result).toBeTruthy(); done(); }); }); diff --git a/openecomp-ui/test/utils/validator.test.js b/openecomp-ui/test/utils/validator.test.js new file mode 100644 index 0000000000..4062fa2d07 --- /dev/null +++ b/openecomp-ui/test/utils/validator.test.js @@ -0,0 +1,69 @@ +/*! + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * + * 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 Validator from 'src/nfvo-utils/Validator.js'; + + +describe('Validator ', () => { + + it('class does exist', () => { + expect(Validator).toBeTruthy(); + }); + + it('returns global validation functions', () => { + expect(Validator.globalValidationFunctions).toBeTruthy(); + }); + + it('returns global validation messages', () => { + expect(Validator.globalValidationMessagingFunctions).toBeTruthy(); + }); + + it('validates data per specific types list', () => { + const types = ['required', 'maxLength', 'minLength', 'pattern', 'numeric', 'maximum', 'minimum', + 'alphanumeric', 'alphanumericWithSpaces', 'validateName', 'validateVendorName', 'freeEnglishText', 'email', 'ip', 'url', 'maximumExclusive', 'minimumExclusive']; + + for (let i = 0; i < types.length; i++) { + expect(Validator.globalValidationFunctions[types[i]]).toBeTruthy(); + } + }); + + it('gives validation messages per specific types list', () => { + const types = ['required', 'maxLength', 'minLength', 'pattern', 'numeric', 'maximum', 'minimum', + 'alphanumeric', 'alphanumericWithSpaces', 'validateName', 'validateVendorName', 'freeEnglishText', 'email', 'ip', 'url', 'maximumExclusive', 'minimumExclusive']; + + for (let i = 0; i < types.length; i++) { + expect(Validator.globalValidationFunctions[types[i]]).toBeTruthy(); + } + }); + + it('returns a validation response of {isValid, errorText} when validating only by validator.js', () => { + const result = Validator.validateItem('a', null, 'required'); + const keys = Object.keys(result); + expect(keys.length).toBe(2); + expect(keys).toContain('isValid'); + expect(keys).toContain('errorText'); + }); + + it('returns a validation response of {isValid, errorText} when validating with custom functions', () => { + const errorText = 'ran custom validation'; + const result = Validator.validate('myfield','a', [{type: 'required', data: null}], {}, { 'myfield' : () => { return { isValid: false, errorText};} }); + const keys = Object.keys(result); + expect(keys.length).toBe(2); + expect(keys).toContain('isValid'); + expect(keys).toContain('errorText'); + expect(result.errorText).toBe(errorText); + }); + +}); diff --git a/openecomp-ui/tests.webpack.js b/openecomp-ui/tests.webpack.js deleted file mode 100644 index 10b54fed83..0000000000 --- a/openecomp-ui/tests.webpack.js +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - -var testContext = require.context('./test', true, /.test\.js$/); -testContext.keys().forEach(testContext); - -var utilsContext = require.context('./src/nfvo-utils', true, /\.js$/); -utilsContext.keys().forEach(utilsContext); - -var componentsContext = require.context('./src/nfvo-components', true, /\.(js|jsx)$/); -componentsContext.keys().forEach(componentsContext); - -var flowsCodeContext = require.context('./src/sdc-app/flows', true, /\.(js|jsx)$/); -flowsCodeContext.keys().forEach(flowsCodeContext); - -var onBoardingCodeContext = require.context('./src/sdc-app/onboarding', true, /\.(js|jsx)$/); -onBoardingCodeContext.keys().forEach(onBoardingCodeContext); - diff --git a/openecomp-ui/tools/gulp/deployment/gulpfile.js b/openecomp-ui/tools/gulp/deployment/gulpfile.js index 99389108bb..bf127e6d19 100644 --- a/openecomp-ui/tools/gulp/deployment/gulpfile.js +++ b/openecomp-ui/tools/gulp/deployment/gulpfile.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ - var gulp = require('gulp'); var i18nUpdateTask = require('./tools/gulp/tasks/i18nUpdate'); diff --git a/openecomp-ui/tools/gulp/deployment/package.json b/openecomp-ui/tools/gulp/deployment/package.json index 3bad0374bf..5f049057fc 100644 --- a/openecomp-ui/tools/gulp/deployment/package.json +++ b/openecomp-ui/tools/gulp/deployment/package.json @@ -10,7 +10,7 @@ "gulp-replace": "^0.5.4", "prompt": "^0.2.14" }, - "author": "ECOMP", + "author": "OPENECOMP", "license": "LicenseRef-LICENSE", "scripts": { "start": "gulp run", diff --git a/openecomp-ui/tools/gulp/deployment/tools/gulp/tasks/i18nUpdate.js b/openecomp-ui/tools/gulp/deployment/tools/gulp/tasks/i18nUpdate.js index a3cae5b018..d35ae2dafc 100644 --- a/openecomp-ui/tools/gulp/deployment/tools/gulp/tasks/i18nUpdate.js +++ b/openecomp-ui/tools/gulp/deployment/tools/gulp/tasks/i18nUpdate.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ - var gulp, replace, rename, fs, prompt, Promise; function mergePromptOptions(options) { @@ -168,4 +163,4 @@ function update(options) { -module.exports = update; +module.exports = update; \ No newline at end of file diff --git a/openecomp-ui/tools/gulp/tasks/i18n.js b/openecomp-ui/tools/gulp/tasks/i18n.js index 38b2a02dcc..a17e8466b7 100644 --- a/openecomp-ui/tools/gulp/tasks/i18n.js +++ b/openecomp-ui/tools/gulp/tasks/i18n.js @@ -1,23 +1,18 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ - var gulp = require('gulp'); var fs = require('fs'); var replace = require('gulp-replace'); @@ -26,19 +21,17 @@ var mkdirp = require('mkdirp'); /** * - * @param options.outputPath * @param options.localesPath * @param options.lang = options.lang * * @returns {string} */ function composeLocalesDirPath(options) { - return options.outputPath + options.localesPath + options.lang; + return options.localesPath + options.lang; } /** * - * @param options.outputPath * @param options.localesPath * @param options.lang * @@ -50,11 +43,9 @@ function composeLocaleFilePath(options) { /** - * @param options - * @param options.outputPath + * * @param options.localesPath * @param options.lang = options.lang - * */ function ensureLocalesDir(options) { @@ -68,7 +59,6 @@ function ensureLocalesDir(options) { } }); }); - } /** @@ -106,8 +96,8 @@ function i18nTask(options) { else resolve(); }); }).on('error', function (err) { - reject(err); - }); + reject(err); + }); }); }); } diff --git a/openecomp-ui/tools/gulp/tasks/prod.js b/openecomp-ui/tools/gulp/tasks/prod.js index d66b841d2a..cb6e251430 100644 --- a/openecomp-ui/tools/gulp/tasks/prod.js +++ b/openecomp-ui/tools/gulp/tasks/prod.js @@ -1,30 +1,27 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ +'use strict'; -var gulp, replace, Promise, webpack, webpackProductionConfig; +let gulp, replace, Promise, webpack, webpackProductionConfig; -var supportedLanguages = ['en']; +const supportedLanguages = ['en']; function start(options) { - var promises = [buildIndex(options)]; + let promises = [buildIndex(options)]; supportedLanguages.forEach(function (lang) { promises.push(bundleJS(options, lang)); }); @@ -33,7 +30,7 @@ function start(options) { function bundleJS(options, lang) { return new Promise(function (resolve, reject) { - var prodConfig = webpackProductionConfig; + let prodConfig = webpackProductionConfig; prodConfig.resolve.alias.i18nJson = options.outDir + '/i18n/' + lang + '/locale.json'; prodConfig.output.filename = jsFileByLang(options.outFileName, lang); webpack(prodConfig, function (err, stats) { @@ -54,9 +51,9 @@ function buildIndex(options) { return new Promise(function (resolve, reject) { - var stream = gulp.src(options.outDir + '/index.html'); - - stream.pipe(replace(/\/\/(.|[\r\n])*?/g, ''))//in script occurrences. + // gulp.src returns a stream object + gulp.src(options.outDir + '/index.html') + .pipe(replace(/\/\/(.|[\r\n])*?/g, ''))//in script occurrences. .pipe(replace(/(.|[\r\n])*?/g, ''))//out of script occurrences. .pipe(replace(/)?/g, '')) .pipe(replace(/\/\/(.|[\r\n])*?/g, supportedLanguages.map(function (val) { @@ -84,12 +81,21 @@ function jsFileByLang(fileName, lang) { * @param options.outFileName optional */ function prodTask(options) { - gulp = require('gulp'); replace = require('gulp-replace'); Promise = require('bluebird'); webpack = require('webpack'); - webpackProductionConfig = options.webpackProductionConfig; + + webpackProductionConfig = require('../../../webpack.production'); + webpackProductionConfig.module.rules = webpackProductionConfig.module.rules.filter(rule => ((rule.enforce !== 'pre') || (rule.enforce === 'pre' && rule.loader !== 'source-map-loader'))); + webpackProductionConfig.module.rules.forEach(loader => { + if (loader.use && loader.use[0].loader === 'style-loader') { + loader.use = loader.use.map(loaderObj => loaderObj.loader.replace('?sourceMap', '')); + } + }); + + + webpackProductionConfig.module.rules.push({test: /config.json$/, use: [{loader:'config-json-loader'}]}); return start({ outFileName: options.outFileName || '[name].js', diff --git a/openecomp-ui/tools/webpack/config-json-loader/index.js b/openecomp-ui/tools/webpack/config-json-loader/index.js index bf34533f67..a0d28db125 100644 --- a/openecomp-ui/tools/webpack/config-json-loader/index.js +++ b/openecomp-ui/tools/webpack/config-json-loader/index.js @@ -1,26 +1,22 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * 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 - * + * + * 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. - * ============LICENSE_END========================================================= + * 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. */ module.exports = function(content) { - var config = JSON.parse(content); var build = process.env.BUILD_NUMBER || '0'; + var config = JSON.parse(content); config.build = build; - return JSON.stringify(config); + return "module.exports = " + JSON.stringify(config, undefined, "\t") + ";"; }; diff --git a/openecomp-ui/webapp-onboarding/WEB-INF/jetty-web.xml b/openecomp-ui/webapp-onboarding/WEB-INF/jetty-web.xml index 0a9d33a940..f729e20095 100644 --- a/openecomp-ui/webapp-onboarding/WEB-INF/jetty-web.xml +++ b/openecomp-ui/webapp-onboarding/WEB-INF/jetty-web.xml @@ -4,5 +4,5 @@ "http://www.eclipse.org/jetty/configure_9_0.dtd"> - /onboarding + /contextapp diff --git a/openecomp-ui/webpack.common.js b/openecomp-ui/webpack.common.js new file mode 100644 index 0000000000..01f6d98b21 --- /dev/null +++ b/openecomp-ui/webpack.common.js @@ -0,0 +1,44 @@ +'use strict'; + +let path = require('path'); + +let localDevConfig = {}; +try { + localDevConfig = require('./devConfig'); +} catch (e) {} +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/locale.json', + '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/, enforce: 'pre'}, + {test: /\.(js|jsx)$/, use: [ + {loader : 'react-hot-loader'}, + {loader : 'babel-loader'}, + {loader : 'eslint-loader'}], exclude: /node_modules/}, + {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: [] +}; diff --git a/openecomp-ui/webpack.config.js b/openecomp-ui/webpack.config.js index 2cccba8f0f..c723a7a86c 100644 --- a/openecomp-ui/webpack.config.js +++ b/openecomp-ui/webpack.config.js @@ -1,66 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - */ - 'use strict'; -var path = require('path'); -var webpack = require('webpack'); +const path = require('path'); +const webpack = require('webpack'); +const proxyServer = require('./proxy-server'); -var localDevConfig = {}; +let localDevConfig = {}; try { localDevConfig = require('./devConfig'); -} catch(e) {} -var devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig); -var devPort = process.env.PORT || devConfig.port; -var latestProgress = 0; +} catch (e) {} +let devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig); +let devPort = process.env.PORT || devConfig.port; -module.exports = { - devtool: 'eval-source-map', - entry: { - bundle: [ - 'sdc-app/sdc.app.jsx', - `webpack-dev-server/client?http://localhost:${devPort}`, - 'webpack/hot/only-dev-server' - ], - 'punch-outs': [ - 'sdc-app/punch-outs.js', - `webpack-dev-server/client?http://localhost:${devPort}`, - 'webpack/hot/only-dev-server' - ], - 'heat-validation': [ - 'sdc-app/heatValidation.app.jsx', - `webpack-dev-server/client?http://localhost:${devPort}`, - 'webpack/hot/only-dev-server' - ] - }, - resolve: { - root: [path.resolve('.')], - alias: { - i18nJson: 'nfvo-utils/i18n/locale.json', - 'nfvo-utils': 'src/nfvo-utils', - 'nfvo-components': 'src/nfvo-components', - 'sdc-app': 'src/sdc-app' +let webpackCommon = require('./webpack.common'); + +function getEntrySources(sources) { + for (let i in sources) { + if (sources.hasOwnProperty(i)) { + sources[i].push('webpack-dev-server/client?http://localhost:' + devPort); + sources[i].push('webpack/hot/only-dev-server'); } - }, + } + return sources; +} + +let webpackDevConfig = Object.assign({}, webpackCommon, { + entry: getEntrySources(devConfig.bundles), + devtool: 'eval-source-map', output: { - path: path.join(__dirname, 'dist/dev'), + path: path.join(__dirname, 'dist'), publicPath: `http://localhost:${devPort}/onboarding/`, filename: '[name].js' }, @@ -68,36 +35,14 @@ module.exports = { port: devPort, historyApiFallback: true, publicPath: `http://localhost:${devPort}/onboarding/`, - contentBase: path.join(__dirname, 'dist/dev'), + contentBase: path.join(__dirname, 'dist'), hot: true, - progress: true, inline: true, - debug: true, stats: { - colors: true - } - }, - module: { - preLoaders: [ - {test: /\.(js|jsx)$/, loader: 'source-map-loader', exclude: /node_modules/} - ], - loaders: [ - {test: /\.(js|jsx)$/, loaders: ['react-hot', 'babel-loader', 'eslint-loader'], exclude: /node_modules/}, - {test: /\.(css|scss)$/, loaders: ['style', 'css?sourceMap', 'sass?sourceMap']}, - - // 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'}, - - {test: /\.json$/, loaders: ['json']}, - {test: /\.html$/, loaders: ['html']} - ] - }, - eslint: { - configFile: './.eslintrc', - emitError: true, - emitWarning: true + colors: true, + exclude: ['node_modules'] + }, + setup: proxyServer }, plugins: [ new webpack.DefinePlugin({ @@ -105,18 +50,17 @@ module.exports = { DEBUG: true }), new webpack.HotModuleReplacementPlugin(), - new webpack.ProgressPlugin(function (percentage, msg) { - if (percentage == 0) { - latestProgress = 0; - console.log(); //new line - } - var progressVal = (percentage * 100).toFixed(0); - if (progressVal > latestProgress) { - latestProgress = progressVal - //process.stdout.clearLine(); - process.stdout.write(msg + ' ' + progressVal + '%\r'); + new webpack.LoaderOptionsPlugin({ + options: { + eslint: { + configFile: './.eslintrc', + emitError: true, + emitWarning: true + }, + context: '/' } }) ] +}); -}; +module.exports = webpackDevConfig; diff --git a/openecomp-ui/webpack.production.js b/openecomp-ui/webpack.production.js new file mode 100644 index 0000000000..1bb9420d33 --- /dev/null +++ b/openecomp-ui/webpack.production.js @@ -0,0 +1,45 @@ +'use strict'; + +let path = require('path'); +let webpack = require('webpack'); + +let webpackCommon = require('./webpack.common'); + +let webpackDevConfig = Object.assign({}, webpackCommon, { + 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 + } + } + }) + ] +}); + +module.exports = webpackDevConfig; -- cgit