From d411d156ac1960f059eb94ec5d7da8fa1a9edb86 Mon Sep 17 00:00:00 2001 From: miriame Date: Tue, 2 Jan 2018 15:35:55 +0200 Subject: select item from workspace- skipping versions page Change-Id: Iebd3bb33703c2d47265ba133f7b74ec961ba8b2f Issue-ID: SDC-864 Signed-off-by: miriame --- .../src/sdc-app/common/helpers/ScreensHelper.js | 8 +-- .../src/sdc-app/onboarding/OnboardingPunchOut.jsx | 24 ++++---- .../src/sdc-app/onboarding/onboard/Onboard.js | 17 ++---- .../onboarding/onboard/OnboardActionHelper.js | 66 +++++++++++++++++++++- .../onboardingCatalog/OnboardingCatalogView.jsx | 9 +-- .../onboarding/onboard/workspace/WorkspaceView.jsx | 5 +- .../userNotifications/UserNotifications.jsx | 4 +- .../versionsPage/VersionsPageActionHelper.js | 1 + 8 files changed, 98 insertions(+), 36 deletions(-) (limited to 'openecomp-ui/src/sdc-app') diff --git a/openecomp-ui/src/sdc-app/common/helpers/ScreensHelper.js b/openecomp-ui/src/sdc-app/common/helpers/ScreensHelper.js index d8fa02664f..ecee47d8b0 100644 --- a/openecomp-ui/src/sdc-app/common/helpers/ScreensHelper.js +++ b/openecomp-ui/src/sdc-app/common/helpers/ScreensHelper.js @@ -277,13 +277,13 @@ const ScreensHelper = { } }, - loadLandingScreen(dispatch, {previousScreenName, props: {licenseModelId, softwareProductId, version}}) { - const screenType = this.getScreenType(previousScreenName); - let screen = screenType === screenTypes.SOFTWARE_PRODUCT ? + loadLandingScreen(dispatch, {previousScreenName, screenType, props: {licenseModelId, softwareProductId, version}}) { + let selectedScreenType = screenType ? screenType : this.getScreenType(previousScreenName); + let screen = selectedScreenType === screenTypes.SOFTWARE_PRODUCT ? enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE : enums.SCREEN.LICENSE_MODEL_OVERVIEW; let props = {licenseModelId, softwareProductId, version}; - return this.loadScreen(dispatch, {screen, screenType, props}); + return this.loadScreen(dispatch, {screen, screenType: selectedScreenType, props}); } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx index 905712003a..06c95b0b2f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx @@ -19,6 +19,7 @@ import ReactDOM from 'react-dom'; import {connect} from 'react-redux'; import isEqual from 'lodash/isEqual.js'; import objectValues from 'lodash/values.js'; +import lodashUnionBy from 'lodash/unionBy.js'; import i18n from 'nfvo-utils/i18n/i18n.js'; import Application from 'sdc-app/Application.jsx'; @@ -233,8 +234,11 @@ export default class OnboardingPunchOut { handleData(data) { let {breadcrumbs: {selectedKeys = []} = {}} = data; let dispatch = action => store.dispatch(action); - let {currentScreen, users: {usersList}, softwareProductList, licenseModelList, softwareProduct: {softwareProductEditor: {data: vspData = {}}, + let {currentScreen, users: {usersList}, softwareProductList, finalizedSoftwareProductList, licenseModelList, finalizedLicenseModelList, + softwareProduct: {softwareProductEditor: {data: vspData = {}}, softwareProductComponents = {}, softwareProductQuestionnaire = {}}} = store.getState(); + const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList]; + const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList]; let {props: {version, isReadOnlyMode}, screen} = currentScreen; let {componentEditor: {data: componentData = {}, qdata: componentQData = {}}} = softwareProductComponents; @@ -269,15 +273,15 @@ export default class OnboardingPunchOut { } else if (selectedKeys.length === 1 || selectedKeys[1] === enums.BREADCRUMS.LICENSE_MODEL) { let [licenseModelId, , licenseModelScreen] = selectedKeys; - let licenseModel = licenseModelList.find(vlm => vlm.id === licenseModelId); + let licenseModel = wholeLicenseModelList.find(vlm => vlm.id === licenseModelId); ScreensHelper.loadScreen(dispatch, {screen: licenseModelScreen, screenType: screenTypes.LICENSE_MODEL, props: {licenseModelId, version, licenseModel, usersList}}); } else if (selectedKeys.length <= 4 && selectedKeys[1] === enums.BREADCRUMS.SOFTWARE_PRODUCT) { let [licenseModelId, , softwareProductId, softwareProductScreen] = selectedKeys; let softwareProduct = softwareProductId ? - softwareProductList.find(({id}) => id === softwareProductId) : - softwareProductList.find(({vendorId}) => vendorId === licenseModelId); + wholeSoftwareProductList.find(({id}) => id === softwareProductId) : + wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); if (!softwareProductId) { softwareProductId = softwareProduct.id; } @@ -298,8 +302,8 @@ export default class OnboardingPunchOut { } 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); + wholeSoftwareProductList.find(({id}) => id === softwareProductId) : + wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); if (!softwareProductId) { softwareProductId = softwareProduct.id; } @@ -309,8 +313,8 @@ export default class OnboardingPunchOut { } 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); + wholeSoftwareProductList.find(({id}) => id === softwareProductId) : + wholeSoftwareProductList.find(({vendorId}) => vendorId === licenseModelId); if (!softwareProductId) { softwareProductId = softwareProduct.id; } @@ -337,8 +341,8 @@ export default class OnboardingPunchOut { {versionsList: {itemType, itemId}}, softwareProduct: {softwareProductEditor: {data: currentSoftwareProduct = {onboardingMethod: ''}}, softwareProductComponents: {componentsList}}} = store.getState(); - const wholeSoftwareProductList = [...softwareProductList, ...finalizedSoftwareProductList]; - const wholeLicenseModelList = [...licenseModelList, ...finalizedLicenseModelList]; + const wholeSoftwareProductList = lodashUnionBy(softwareProductList, finalizedSoftwareProductList, 'id'); + const wholeLicenseModelList = lodashUnionBy(licenseModelList, finalizedLicenseModelList, 'id'); let breadcrumbsData = {itemType, itemId, currentScreen, wholeLicenseModelList, wholeSoftwareProductList, currentSoftwareProduct, componentsList}; if (currentScreen.forceBreadCrumbsUpdate || !isEqual(breadcrumbsData, this.prevBreadcrumbsData) || this.breadcrumbsPrefixSelected) { diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js b/openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js index 3422920b3a..a308e1ec5e 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/Onboard.js @@ -21,8 +21,6 @@ import OnboardActionHelper from './OnboardActionHelper.js'; import LicenseModelCreationActionHelper from '../licenseModel/creation/LicenseModelCreationActionHelper.js'; import SoftwareProductCreationActionHelper from '../softwareProduct/creation/SoftwareProductCreationActionHelper.js'; import sortByStringProperty from 'nfvo-utils/sortByStringProperty.js'; -import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; -import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; export const mapStateToProps = ({ @@ -91,18 +89,11 @@ export const mapStateToProps = ({ const mapActionsToProps = (dispatch) => { return { - onSelectLicenseModel({id: licenseModelId, name}, users) { - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.VERSIONS_PAGE, screenType: screenTypes.LICENSE_MODEL, - props: {licenseModelId, licenseModel: {name}, usersList: users} - }); + onSelectLicenseModel({id: licenseModelId, name}, users, tab) { + OnboardActionHelper.loadVLMScreen(dispatch, {id: licenseModelId, name}, users, tab); }, - onSelectSoftwareProduct(softwareProduct, users) { - let {id: softwareProductId, vendorId: licenseModelId, licensingVersion, name} = softwareProduct; - ScreensHelper.loadScreen(dispatch, { - screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, - props: {softwareProductId, softwareProduct: {name, vendorId: licenseModelId, licensingVersion}, usersList: users} - }); + onSelectSoftwareProduct(softwareProduct, users, tab) { + OnboardActionHelper.loadVSPScreen(dispatch, softwareProduct, users, tab); }, onAddSoftwareProductClick: (vendorId) => SoftwareProductCreationActionHelper.open(dispatch, vendorId), onAddLicenseModelClick: () => LicenseModelCreationActionHelper.open(dispatch), diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js index 6ebb40878f..892056855f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/OnboardActionHelper.js @@ -13,7 +13,13 @@ * or implied. See the License for the specific language governing * permissions and limitations under the License. */ -import {actionTypes} from './OnboardConstants.js'; +import {tabsMapping, actionTypes} from './OnboardConstants.js'; +import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js'; +import {enums, screenTypes} from 'sdc-app/onboarding/OnboardingConstants.js'; +import VersionsPageActionHelper from 'sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js'; +import {catalogItemStatuses} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js'; +import {itemTypes} from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js'; +import PermissionsActionHelper from 'sdc-app/onboarding/permissions/PermissionsActionHelper.js'; const OnboardActionHelper = { resetOnboardStore(dispatch) { @@ -39,6 +45,64 @@ const OnboardActionHelper = { type: actionTypes.CHANGE_SEARCH_VALUE, searchValue: '' }); + }, + + loadVLMScreen(dispatch, {id: licenseModelId, name}, users, tab) { + if (tab === tabsMapping.WORKSPACE) { + VersionsPageActionHelper.fetchVersions(dispatch, {itemId: licenseModelId, itemType: itemTypes.LICENSE_MODEL}).then(({results})=> { + results = results.filter((version) => version.status === catalogItemStatuses.DRAFT); + if (results.length !== 1) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.VERSIONS_PAGE, screenType: screenTypes.LICENSE_MODEL, + props: {licenseModelId, licenseModel: {name}, usersList: users} + }); + } + else { + PermissionsActionHelper.fetchItemUsers(dispatch, {itemId: licenseModelId, allUsers: users}).then(() => + ScreensHelper.loadLandingScreen(dispatch, {screenType: screenTypes.LICENSE_MODEL, props: {licenseModelId, version: results[0]}}) + ); + } + }); + } + if (tab === tabsMapping.CATALOG) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.VERSIONS_PAGE, screenType: screenTypes.LICENSE_MODEL, + props: {licenseModelId, licenseModel: {name}, usersList: users} + }); + } + }, + loadVSPScreen(dispatch, softwareProduct, users, tab) { + let {id: softwareProductId, vendorId: licenseModelId, licensingVersion, name} = softwareProduct; + if (tab === tabsMapping.WORKSPACE) { + VersionsPageActionHelper.fetchVersions(dispatch,{itemId: softwareProductId, itemType: itemTypes.SOFTWARE_PRODUCT}).then(({results})=> { + results = results.filter((version) => version.status === catalogItemStatuses.DRAFT); + if (results.length !== 1) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + softwareProduct: {name, vendorId: licenseModelId, licensingVersion}, + usersList: users + } + }); + } + else { + PermissionsActionHelper.fetchItemUsers(dispatch, {itemId: softwareProductId, allUsers: users}).then(() => + ScreensHelper.loadLandingScreen(dispatch, {screenType: screenTypes.SOFTWARE_PRODUCT, props: {softwareProductId, licenseModelId, version: results[0]}}) + ); + } + }); + } + if (tab === tabsMapping.CATALOG) { + ScreensHelper.loadScreen(dispatch, { + screen: enums.SCREEN.SOFTWARE_PRODUCT_VERSIONS_PAGE, screenType: screenTypes.SOFTWARE_PRODUCT, + props: { + softwareProductId, + softwareProduct: {name, vendorId: licenseModelId, licensingVersion}, + usersList: users + } + }); + } } }; diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx index 1004472ec3..60a5aaeef0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx @@ -19,6 +19,7 @@ import classnames from 'classnames'; import DetailsCatalogView from 'sdc-app/onboarding/onboard/DetailsCatalogView.jsx'; import VendorCatalogView from './VendorCatalogView.jsx'; import { tabsMapping} from './OnboardingCatalogConstants.js'; +import {tabsMapping as WCTabsMapping} from 'sdc-app/onboarding/onboard/OnboardConstants.js'; const CatalogHeaderTabs = ({onTabPress, activeTab}) => (
@@ -58,8 +59,8 @@ class OnboardingCatalogView extends React.Component { users={users} onAddVLM={onAddLicenseModelClick} onAddVSP={onAddSoftwareProductClick} - onSelectVLM={onSelectLicenseModel} - onSelectVSP={onSelectSoftwareProduct} + onSelectVLM={(item, users) => onSelectLicenseModel(item, users, WCTabsMapping.CATALOG)} + onSelectVSP={(item, users) => onSelectSoftwareProduct(item, users, WCTabsMapping.CATALOG)} filter={searchValue} onMigrate={onMigrate}/> ); @@ -71,8 +72,8 @@ class OnboardingCatalogView extends React.Component { users={users} onAddVSP={onAddSoftwareProductClick} onAddVLM={onAddLicenseModelClick} - onSelectVSP={onSelectSoftwareProduct} - onSelectVLM={onSelectLicenseModel} + onSelectVSP={(item, users) => onSelectSoftwareProduct(item, users, WCTabsMapping.CATALOG)} + onSelectVLM={(item, users) => onSelectLicenseModel(item, users, WCTabsMapping.CATALOG)} vspOverlay={vspOverlay} onVendorSelect={onVendorSelect} selectedVendor={selectedVendor} diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx index 523bbb2c8e..a937c11d85 100644 --- a/openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/onboard/workspace/WorkspaceView.jsx @@ -16,6 +16,7 @@ import React from 'react'; import DetailsCatalogView from '../DetailsCatalogView.jsx'; import i18n from 'nfvo-utils/i18n/i18n.js'; +import {tabsMapping} from 'sdc-app/onboarding/onboard/OnboardConstants.js'; const WorkspaceView = (props) => { let { @@ -34,8 +35,8 @@ const WorkspaceView = (props) => { users={users} onAddVLM={onAddLicenseModelClick} onAddVSP={onAddSoftwareProductClick} - onSelectVLM={onSelectLicenseModel} - onSelectVSP={onSelectSoftwareProduct} + onSelectVLM={(item, users) => onSelectLicenseModel(item, users, tabsMapping.WORKSPACE)} + onSelectVSP={(item, users) => onSelectSoftwareProduct(item, users, tabsMapping.WORKSPACE)} onMigrate={onMigrate} filter={searchValue} />
diff --git a/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotifications.jsx b/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotifications.jsx index c01424ee1b..635dfa701f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotifications.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/userNotifications/UserNotifications.jsx @@ -54,7 +54,7 @@ const Notification = ({notification, users, onActionClicked, getNotificationType
onActionClicked(notification)}> - {eventType === notificationType.PERMISSION_CHANGED ? i18n('Accept') : i18n('Sync')} + {eventType === notificationType.PERMISSION_CHANGED ? i18n('OK') : i18n('Sync')}
@@ -128,4 +128,4 @@ class UserNotifications extends React.Component { } } -export default UserNotifications; +export default UserNotifications; \ No newline at end of file diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js index 52868293e2..edf30fe4ef 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js @@ -32,6 +32,7 @@ const VersionsPageActionHelper = { itemType, itemId }); + return Promise.resolve(response); }); }, -- cgit 1.2.3-korg