2 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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 RestAPIUtil from 'nfvo-utils/RestAPIUtil.js';
17 import Configuration from 'sdc-app/config/Configuration.js';
18 import { actionTypes } from './SoftwareProductComponentProcessesConstants.js';
20 function baseUrl(softwareProductId, version, componentId) {
21 const restPrefix = Configuration.get('restPrefix');
22 return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${
24 }/components/${componentId}/processes`;
27 function fetchProcessesList({ softwareProductId, version, componentId }) {
28 return RestAPIUtil.fetch(
29 `${baseUrl(softwareProductId, version, componentId)}`
33 function deleteProcess({ softwareProductId, version, componentId, processId }) {
34 return RestAPIUtil.destroy(
35 `${baseUrl(softwareProductId, version, componentId)}/${processId}`
39 function putProcess({ softwareProductId, version, componentId, process }) {
40 return RestAPIUtil.put(
41 `${baseUrl(softwareProductId, version, componentId)}/${process.id}`,
44 description: process.description,
45 type: process.type === '' ? null : process.type
50 function postProcess({ softwareProductId, version, componentId, process }) {
51 return RestAPIUtil.post(
52 `${baseUrl(softwareProductId, version, componentId)}`,
55 description: process.description,
56 type: process.type === '' ? null : process.type
61 function uploadFileToProcess({
68 return RestAPIUtil.post(
73 )}/${processId}/upload`,
78 const SoftwareProductComponentProcessesActionHelper = {
79 fetchProcessesList(dispatch, { softwareProductId, version, componentId }) {
81 type: actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES,
85 return fetchProcessesList({
91 type: actionTypes.FETCH_SOFTWARE_PRODUCT_COMPONENTS_PROCESSES,
92 processesList: response.results
99 { process, softwareProductId, version, componentId }
101 return deleteProcess({
104 processId: process.id,
108 type: actionTypes.DELETE_SOFTWARE_PRODUCT_COMPONENTS_PROCESS,
109 processId: process.id
116 { softwareProductId, version, componentId, previousProcess, process }
118 if (previousProcess) {
127 process.formData.name !== previousProcess.artifactName
129 uploadFileToProcess({
132 processId: process.id,
133 formData: process.formData,
138 type: actionTypes.EDIT_SOFTWARE_PRODUCT_COMPONENTS_PROCESS,
148 }).then(response => {
149 if (process.formData) {
150 uploadFileToProcess({
153 processId: response.value,
154 formData: process.formData,
159 type: actionTypes.ADD_SOFTWARE_PRODUCT_COMPONENTS_PROCESS,
169 hideDeleteConfirm(dispatch) {
172 actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM,
173 processToDelete: false
177 openDeleteProcessesConfirm(dispatch, { process }) {
180 actionTypes.SOFTWARE_PRODUCT_PROCESS_DELETE_COMPONENTS_CONFIRM,
181 processToDelete: process
185 openEditor(dispatch, process = {}) {
187 type: actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_OPEN,
191 closeEditor(dispatch) {
193 type: actionTypes.SOFTWARE_PRODUCT_PROCESS_COMPONENTS_EDITOR_CLOSE
198 export default SoftwareProductComponentProcessesActionHelper;