aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js')
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js117
1 files changed, 52 insertions, 65 deletions
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js
index e53b2ecafe..9b3c9eaa73 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js
@@ -1,56 +1,51 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
import RestAPIUtil from 'nfvo-utils/RestAPIUtil.js';
import Configuration from 'sdc-app/config/Configuration.js';
-import {actionTypes} from './SoftwareProductComponentsConstants.js';
+import {actionTypes, COMPONENTS_QUESTIONNAIRE, forms} from './SoftwareProductComponentsConstants.js';
+import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
-function baseUrl(softwareProductId) {
+function baseUrl(softwareProductId, version) {
+ const versionId = version.id;
const restPrefix = Configuration.get('restPrefix');
- return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components`;
+ return `${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components`;
}
function fetchSoftwareProductComponents(softwareProductId, version) {
- let versionQuery = version ? `?version=${version}` : '';
- return RestAPIUtil.fetch(`${baseUrl(softwareProductId)}${versionQuery}`);
+ return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}`);
}
-function putSoftwareProductComponentQuestionnaire(softwareProductId, vspComponentId, vspComponent) {
- return RestAPIUtil.save(`${baseUrl(softwareProductId)}/${vspComponentId}/questionnaire`, vspComponent);
+function putSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId, vspComponent) {
+ return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${vspComponentId}/questionnaire`, vspComponent);
}
-function fetchSoftwareProductComponentQuestionnaire(softwareProductId, vspComponentId, version){
- let versionQuery = version ? `?version=${version}` : '';
- return RestAPIUtil.fetch(`${baseUrl(softwareProductId)}/${vspComponentId}/questionnaire${versionQuery}`);
+function fetchSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId){
+ return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}/${vspComponentId}/questionnaire`);
}
-function fetchSoftwareProductComponent(softwareProductId, vspComponentId, version){
- let versionQuery = version ? `?version=${version}` : '';
- return RestAPIUtil.fetch(`${baseUrl(softwareProductId)}/${vspComponentId}${versionQuery}`);
+function fetchSoftwareProductComponent(softwareProductId, version, vspComponentId){
+ return RestAPIUtil.fetch(`${baseUrl(softwareProductId, version)}/${vspComponentId}`);
}
-function putSoftwareProductComponent(softwareProductId, vspComponentId, vspComponent) {
- return RestAPIUtil.save(`${baseUrl(softwareProductId)}/${vspComponentId}`, {
+function putSoftwareProductComponent(softwareProductId, version, vspComponentId, vspComponent) {
+ return RestAPIUtil.put(`${baseUrl(softwareProductId, version)}/${vspComponentId}`, {
name: vspComponent.name,
displayName: vspComponent.displayName,
+ vfcCode: vspComponent.vfcCode,
description: vspComponent.description
});
}
@@ -65,27 +60,19 @@ const SoftwareProductComponentsActionHelper = {
});
},
- componentDataChanged(dispatch, {deltaData}) {
- dispatch({
- type: actionTypes.COMPONENT_DATA_CHANGED,
- deltaData
- });
- },
-
-
- updateSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId, componentData, qdata}) {
+ updateSoftwareProductComponent(dispatch, {softwareProductId, version, vspComponentId, componentData, qdata}) {
return Promise.all([
- SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId, qdata}),
- SoftwareProductComponentsActionHelper.updateSoftwareProductComponentData(dispatch, {softwareProductId, vspComponentId, componentData})
+ SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId, qdata}),
+ SoftwareProductComponentsActionHelper.updateSoftwareProductComponentData(dispatch, {softwareProductId, version, vspComponentId, componentData})
]);
},
- updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId, qdata}) {
- return putSoftwareProductComponentQuestionnaire(softwareProductId, vspComponentId, qdata);
+ updateSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId, qdata}) {
+ return putSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId, qdata);
},
- updateSoftwareProductComponentData(dispatch, {softwareProductId, vspComponentId, componentData}) {
- return putSoftwareProductComponent(softwareProductId, vspComponentId, componentData).then(() => dispatch({
+ updateSoftwareProductComponentData(dispatch, {softwareProductId, version, vspComponentId, componentData}) {
+ return putSoftwareProductComponent(softwareProductId, version, vspComponentId, componentData).then(() => dispatch({
type: actionTypes.COMPONENTS_LIST_EDIT,
component: {
id: vspComponentId,
@@ -94,36 +81,36 @@ const SoftwareProductComponentsActionHelper = {
}));
},
-
- fetchSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, vspComponentId, version}) {
- return fetchSoftwareProductComponentQuestionnaire(softwareProductId, vspComponentId, version).then(response => {
- dispatch({
- type: actionTypes.COMPONENT_QUESTIONNAIRE_UPDATE,
- payload: {
- qdata: response.data ? JSON.parse(response.data) : {},
- qschema: JSON.parse(response.schema)
- }
- });
+ fetchSoftwareProductComponentQuestionnaire(dispatch, {softwareProductId, version, vspComponentId}) {
+ return fetchSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId).then(response => {
+ ValidationHelper.qDataLoaded(dispatch, {qName: COMPONENTS_QUESTIONNAIRE, response: {qdata: response.data ? JSON.parse(response.data) : {},
+ qschema: JSON.parse(response.schema)}});
});
},
- fetchSoftwareProductComponent(dispatch, {softwareProductId, vspComponentId, version}) {
- return fetchSoftwareProductComponent(softwareProductId, vspComponentId, version).then(response => {
- dispatch({
- type: actionTypes.COMPONENT_UPDATE,
- component: response.data
- });
+ fetchSoftwareProductComponent(dispatch, {softwareProductId, version, vspComponentId}) {
+ dispatch({
+ type: actionTypes.COMPONENT_LOAD
});
+ return Promise.all([
+ fetchSoftwareProductComponent(softwareProductId, version, vspComponentId).then(response => {
+ ValidationHelper.dataChanged(dispatch,{deltaData: response.data, formName: forms.ALL_SPC_FORMS});
+ return response;
+ }),
+ fetchSoftwareProductComponentQuestionnaire(softwareProductId, version, vspComponentId).then(response => {
+ ValidationHelper.qDataLoaded(dispatch, {qName: COMPONENTS_QUESTIONNAIRE, response: {qdata: response.data ? JSON.parse(response.data) : {},
+ qschema: JSON.parse(response.schema)}});
+ })
+ ]);
},
- componentQuestionnaireUpdated(dispatch, {data}) {
+
+ clearComponentsStore(dispatch) {
dispatch({
- type: actionTypes.COMPONENT_QUESTIONNAIRE_UPDATE,
- payload: {
- qdata: data
- }
+ type: actionTypes.COMPONENTS_LIST_UPDATE,
+ componentsList: []
});
- },
+ }
};
export default SoftwareProductComponentsActionHelper;