summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/MainScreenHeader.jsx3
-rw-r--r--src/app/MainScreenWrapperReducer.js2
-rw-r--r--src/app/contextHandler/ContextHandlerActions.js40
-rw-r--r--src/app/contextHandler/ContextHandlerConstants.js2
-rw-r--r--src/app/networking/NetworkCalls.js21
5 files changed, 27 insertions, 41 deletions
diff --git a/src/app/MainScreenHeader.jsx b/src/app/MainScreenHeader.jsx
index 49952f7..912a5ad 100644
--- a/src/app/MainScreenHeader.jsx
+++ b/src/app/MainScreenHeader.jsx
@@ -135,6 +135,7 @@ class MainScreenHeader extends Component {
return false;
}
}
+
isValidExternalURL(url) {
if(decodeURIComponent(url).indexOf('&') > 0 ) {
return true;
@@ -142,6 +143,7 @@ class MainScreenHeader extends Component {
return false;
}
}
+
componentWillMount() {
this.props.onGetSubscriptionPayload();
if(this.props.match.params.externalUrl !== undefined &&
@@ -149,6 +151,7 @@ class MainScreenHeader extends Component {
this.props.onExternalUrlRequest(this.props.match.params.externalUrl);
}
}
+
componentWillReceiveProps(nextProps) {
if (this.props.location &&
this.props.location.pathname !==
diff --git a/src/app/MainScreenWrapperReducer.js b/src/app/MainScreenWrapperReducer.js
index 6dd7dbf..79bb05d 100644
--- a/src/app/MainScreenWrapperReducer.js
+++ b/src/app/MainScreenWrapperReducer.js
@@ -71,7 +71,7 @@ export default (state = {}, action) => {
case contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_FOUND:
return {
...state,
- subscriptionPayload: action.data,
+ subscriptionPayload: action.data.subscriptionDetails,
subscriptionEnabled: true
};
case contextHandlerActionTypes.SUBSCRIPTION_PAYLOAD_EMPTY:
diff --git a/src/app/contextHandler/ContextHandlerActions.js b/src/app/contextHandler/ContextHandlerActions.js
index 889020a..0fe43ff 100644
--- a/src/app/contextHandler/ContextHandlerActions.js
+++ b/src/app/contextHandler/ContextHandlerActions.js
@@ -65,17 +65,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,26 +91,21 @@ 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);
@@ -113,6 +113,7 @@ export function getSubscriptionPayload() {
dispatch(fetchSubscriptionPayload(externalfetchRequest));
};
}
+
function validateExternalParams(externalURLParams) {
if(externalURLParams.view && externalURLParams.entityId && externalURLParams.entityType) {
return true;
@@ -121,7 +122,6 @@ function validateExternalParams(externalURLParams) {
}
-
function createSuggestionFoundEvent(suggestion) {
return {
type: contextHandlerActionTypes.SINGLE_SUGGESTION_FOUND,
diff --git a/src/app/contextHandler/ContextHandlerConstants.js b/src/app/contextHandler/ContextHandlerConstants.js
index 6229968..9abbb31 100644
--- a/src/app/contextHandler/ContextHandlerConstants.js
+++ b/src/app/contextHandler/ContextHandlerConstants.js
@@ -39,7 +39,7 @@ export const FAILED_REQUEST = 'Failed to pull result for the request.';
export const ZERO_RESULT = 'No result has been found for this request.';
export const MULTIPLE_RESULT = 'Multiple results were found for this request so none got selected.';
export const SUBSCRIPTION_FAILED_MESSAGE = 'Failed to fetch subscription payload.';
-export const SUBSCRIPTION_PAYLOAD_URL = BASE_URL + '/subscription/getsubscription';
+export const SUBSCRIPTION_PAYLOAD_URL = BASE_URL + '/rest/subscription/getsubscription';
diff --git a/src/app/networking/NetworkCalls.js b/src/app/networking/NetworkCalls.js
index b6c96b7..003e69d 100644
--- a/src/app/networking/NetworkCalls.js
+++ b/src/app/networking/NetworkCalls.js
@@ -21,9 +21,6 @@
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
*/
-function EmptyResponseException(){
- this.name = 'EmptyResponseException';
-}
function fetchRequest(URL, POST, POST_HEADER, BODY) {
return fetch(URL, {
credentials: 'same-origin',
@@ -44,27 +41,13 @@ function fetchRequestObj(URL, POST, POST_HEADER, BODY) {
});
}
-function processResponse(response){
- if(response.status === 204){
- throw new EmptyResponseException();
- }
- return response.json();
-}
function getRequest(URL, GET) {
return fetch(URL, {
credentials: 'same-origin',
method: GET
- }).then(
- (response) => {
- try{
- response.json();
- } catch (e){
- response.isValidJson = false;
- }
- return processResponse(response);
- }
- );
+ });
}
+
module.exports = {
fetchRequest: fetchRequest,
fetchRequestObj: fetchRequestObj,