diff options
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/versionsPage')
3 files changed, 44 insertions, 6 deletions
diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js index 61c0d0a88f..b7d5417e33 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.js @@ -20,6 +20,9 @@ import VersionsPageCreationActionHelper from './creation/VersionsPageCreationAct import PermissionsActionHelper from '../permissions/PermissionsActionHelper.js'; import { onboardingMethod as onboardingMethodType } from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; import VersionsPageView from './VersionsPage.jsx'; +import { actionTypes as ModalActionTypes } from 'nfvo-components/modal/GlobalModalConstants'; +import i18n from 'nfvo-utils/i18n/i18n'; +import { itemTypes } from 'sdc-app/onboarding/versionsPage/VersionsPageConstants'; export const mapStateToProps = ({ users: { userInfo }, @@ -99,8 +102,29 @@ export const mapActionsToProps = ( onArchive: () => VersionsPageActionHelper.archiveItem(dispatch, itemId), onRestore: () => VersionsPageActionHelper.restoreItemFromArchive(dispatch, itemId), - onDelete: () => - VersionsPageActionHelper.deleteItemFromArchive(dispatch, itemId) + onDelete: () => { + let confirmMsgCode; + if (itemType === itemTypes.LICENSE_MODEL) { + confirmMsgCode = 'vlm.delete.archived.warning'; + } else if (itemType === itemTypes.SOFTWARE_PRODUCT) { + confirmMsgCode = 'vsp.delete.archived.warning'; + } + dispatch({ + type: ModalActionTypes.GLOBAL_MODAL_WARNING, + data: { + msg: i18n(confirmMsgCode), + confirmationButtonText: i18n('button.proceed.label'), + title: i18n('WARNING'), + + onConfirmed: () => + VersionsPageActionHelper.deleteArchivedItem( + dispatch, + itemId, + itemType + ) + } + }); + } }; }; diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx index 95c7530063..e5bff51e9f 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPage.jsx @@ -28,7 +28,6 @@ const ArchiveRestoreButton = ({ deleteAction }) => ( <div className="deprecate-btn-wrapper"> - , {isArchived ? ( <div> <Button diff --git a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js index 6ade7ff251..506d5947c0 100644 --- a/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/versionsPage/VersionsPageActionHelper.js @@ -26,6 +26,7 @@ import { } from 'sdc-app/onboarding/OnboardingConstants.js'; import { notificationActions } from 'nfvo-components/notification/NotificationsConstants.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper'; +import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper'; const VersionsPageActionHelper = { fetchVersions(dispatch, { itemType, itemId }) { @@ -114,14 +115,28 @@ const VersionsPageActionHelper = { ); }, - async deleteItemFromArchive(dispatch, itemId) { - await SoftwareProductActionHelper.softwareProductDelete(itemId); + async deleteArchivedItem(dispatch, itemId, itemType) { + let successMsgCode; + if (itemType === itemTypes.LICENSE_MODEL) { + await LicenseModelActionHelper.deleteLicenseModel(itemId); + successMsgCode = 'vlm.delete.success'; + } else if (itemType === itemTypes.SOFTWARE_PRODUCT) { + await SoftwareProductActionHelper.softwareProductDelete(itemId); + successMsgCode = 'vsp.delete.success'; + } else { + console.error( + `Invalid item type "${itemType}". Expecting one of ${ + itemTypes.LICENSE_MODEL + } or ${itemTypes.SOFTWARE_PRODUCT}` + ); + return; + } await ScreensHelper.loadScreen(dispatch, { screen: enums.SCREEN.ONBOARDING_CATALOG }); dispatch( notificationActions.showSuccess({ - message: i18n('Item successfully deleted') + message: i18n(successMsgCode) }) ); } |