X-Git-Url: https://gerrit.onap.org/r/gitweb?p=aai%2Fsparky-fe.git;a=blobdiff_plain;f=src%2Fapp%2FcontextHandler%2FContextHandlerActions.js;h=f3ede6db2068975f533a2f917adcb59475d4b26e;hp=889020ac8a7851bfbb98041ac8da0efa440bcd09;hb=947af7d0e262bc2be903ff1ee766a252d9d3ddb3;hpb=a38f3d6bb17a478d08016e49d6c2a667ac483d4a diff --git a/src/app/contextHandler/ContextHandlerActions.js b/src/app/contextHandler/ContextHandlerActions.js index 889020a..f3ede6d 100644 --- a/src/app/contextHandler/ContextHandlerActions.js +++ b/src/app/contextHandler/ContextHandlerActions.js @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * org.onap.aai * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017 Amdocs + * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. + * Copyright © 2017-2018 Amdocs * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,10 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. */ - import { POST, POST_HEADER, @@ -65,17 +62,22 @@ function getExternalParamValues(urlParams) { } function createSubscriptionPayloadEvent(payload) { - return { - type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND, - data: payload - }; -} -function createSubscriptionIsEmptyEvent() { - return { - type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY, - data: {} - }; + let event = undefined; + + if (payload.subscriptionEnabled) { + event = { + type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND, + data: payload + }; + } else { + event = { + type: contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY, + data: {} + }; + } + + return event; } function fetchSubscriptionPayload(fetchRequestCallback) { @@ -86,33 +88,30 @@ function fetchSubscriptionPayload(fetchRequestCallback) { return Promise.reject(new Error(response.status)); } else { // assume 200 status - return response; + return response.json(); } } ).then( (results)=> { dispatch(createSubscriptionPayloadEvent(results)); - } ).catch( - (e) => { - if(e.name === 'EmptyResponseException'){ - dispatch(getClearGlobalMessageEvent()); - dispatch(createSubscriptionIsEmptyEvent()); - } else{ - dispatch(getSetGlobalMessageEvent(SUBSCRIPTION_FAILED_MESSAGE , MESSAGE_LEVEL_WARNING)); - } + () => { + dispatch(getSetGlobalMessageEvent(SUBSCRIPTION_FAILED_MESSAGE , MESSAGE_LEVEL_WARNING)); } ); }; } + export function getSubscriptionPayload() { let externalfetchRequest = - () => networkCall.getRequest(SUBSCRIPTION_PAYLOAD_URL, GET); + () => networkCall.getRequest(SUBSCRIPTION_PAYLOAD_URL, GET); + return dispatch => { dispatch(fetchSubscriptionPayload(externalfetchRequest)); }; } + function validateExternalParams(externalURLParams) { if(externalURLParams.view && externalURLParams.entityId && externalURLParams.entityType) { return true; @@ -121,7 +120,6 @@ function validateExternalParams(externalURLParams) { } - function createSuggestionFoundEvent(suggestion) { return { type: contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND,