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 or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import { actionTypes } from './HeatSetupConstants.js';
17 import isEqual from 'lodash/isEqual.js';
18 import cloneDeep from 'lodash/cloneDeep.js';
19 import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';
22 toggleVolFilesDisplay(dispatch, data) {
23 dispatch({ type: actionTypes.TOGGLE_VOL_DISPLAY, data });
26 addModule(dispatch, isBase) {
27 dispatch({ type: actionTypes.ADD_MODULE, data: { isBase } });
30 deleteModule(dispatch, moduleName) {
31 dispatch({ type: actionTypes.REMOVE_MODULE, data: { moduleName } });
34 renameModule(dispatch, { oldName, newName }) {
36 type: actionTypes.RENAME_MODULE,
37 data: { oldName, newName }
41 changeModuleFileType(dispatch, { module, value, type }) {
43 value = { value: '' };
46 type: actionTypes.FILE_ASSIGN_CHANGED,
47 data: { module, value, type }
51 changeArtifactList(dispatch, artifacts) {
53 type: actionTypes.ARTIFACT_LIST_CHANGE,
54 data: { artifacts: artifacts.map(artifact => artifact.value) }
58 processAndValidateHeat(
60 { softwareProductId, heatData, heatDataCache, isReadOnlyMode, version }
62 return isEqual({ ...heatData, softwareProductId }, heatDataCache) ||
65 : SoftwareProductActionHelper.updateSoftwareProductHeatCandidate(
67 { softwareProductId, heatCandidate: heatData, version }
70 SoftwareProductActionHelper.processAndValidateHeatCandidate(
72 { softwareProductId, version }
77 type: actionTypes.FILL_HEAT_SETUP_CACHE,
78 payload: { ...cloneDeep(heatData), softwareProductId }
83 addAllUnassignedFilesToArtifacts(dispatch) {
84 dispatch({ type: actionTypes.ADD_ALL_UNASSIGNED_TO_ARTIFACTS });
87 heatSetupLeaveConfirmation() {
88 return Promise.resolve();
91 /*heatSetupLeaveConfirmation(dispatch, {softwareProductId, heatSetup, heatSetupCache}) {
92 return new Promise((resolve, reject) => {
93 if (isEqual({...heatSetup, softwareProductId}, heatSetupCache)) {
97 type: modalActionTypes.GLOBAL_MODAL_WARNING,
99 msg: i18n(`You have uploaded a new HEAT. If you navigate away or Check-in without proceeding to validation,
100 Old HEAT zip file will be in use. new HEAT will be ignored. Do you want to continue?`),
101 confirmationButtonText: i18n('Continue'),
102 onConfirmed: () => resolve(),
103 onDeclined: () => reject()