2 * Copyright © 2016-2018 European Support Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * permissions and limitations under the License.
16 import ItemsHelper from '../../common/helpers/ItemsHelper.js';
17 import { actionTypes } from './VersionsPageConstants.js';
18 import { itemTypes } from './VersionsPageConstants.js';
19 import { modalContentMapper } from 'sdc-app/common/modal/ModalContentMapper.js';
20 import { actionTypes as modalActionTypes } from 'nfvo-components/modal/GlobalModalConstants.js';
21 import i18n from 'nfvo-utils/i18n/i18n.js';
22 import ScreensHelper from 'sdc-app/common/helpers/ScreensHelper.js';
27 } from 'sdc-app/onboarding/OnboardingConstants.js';
28 import { notificationActions } from 'nfvo-components/notification/NotificationsConstants.js';
30 const VersionsPageActionHelper = {
31 fetchVersions(dispatch, { itemType, itemId }) {
32 return ItemsHelper.fetchVersions({ itemId }).then(response => {
34 type: actionTypes.VERSIONS_LOADED,
35 versions: response.results,
39 return Promise.resolve(response);
43 selectVersion(dispatch, { version }) {
45 type: actionTypes.SELECT_VERSION,
50 selectNone(dispatch) {
51 dispatch({ type: actionTypes.SELECT_NONE });
54 onNavigateToVersion(dispatch, { version, itemId, itemType }) {
56 case itemTypes.LICENSE_MODEL:
57 ScreensHelper.loadScreen(dispatch, {
58 screen: enums.SCREEN.LICENSE_MODEL_OVERVIEW,
59 screenType: screenTypes.LICENSE_MODEL,
60 props: { licenseModelId: itemId, version }
63 case itemTypes.SOFTWARE_PRODUCT:
64 ScreensHelper.loadScreen(dispatch, {
65 screen: enums.SCREEN.SOFTWARE_PRODUCT_LANDING_PAGE,
66 screenType: screenTypes.SOFTWARE_PRODUCT,
67 props: { softwareProductId: itemId, version }
73 openTree(dispatch, treeProps) {
75 type: modalActionTypes.GLOBAL_MODAL_SHOW,
77 modalComponentName: modalContentMapper.VERSION_TREE,
78 modalComponentProps: treeProps,
81 type: modalActionTypes.GLOBAL_MODAL_CLOSE
83 bodyClassName: 'versions-tree-modal',
84 cancelButtonText: i18n('Close'),
85 title: i18n('Version Tree')
90 selectVersionFromModal(dispatch, { version }) {
92 type: modalActionTypes.GLOBAL_MODAL_CLOSE
94 this.selectVersion(dispatch, { version });
97 async archiveItem(dispatch, itemId) {
98 await ItemsHelper.archiveItem(itemId);
99 dispatch(onboardingActions.updateItemArchivedStatus(true));
101 notificationActions.showSuccess({
102 message: i18n('Item successfully archived')
107 async restoreItemFromArchive(dispatch, itemId) {
108 await ItemsHelper.restoreItem(itemId);
109 dispatch(onboardingActions.updateItemArchivedStatus(false));
111 notificationActions.showSuccess({
112 message: i18n('Item successfully restored')
118 export default VersionsPageActionHelper;