UI Action Handler Changes, Misc Fixes

This commit is contained in:
Qstick
2017-11-26 15:09:45 -05:00
parent 7825319d89
commit cd5b658196
193 changed files with 6992 additions and 6341 deletions
@@ -5,51 +5,47 @@ import { set } from '../baseActions';
const abortCurrentRequests = {};
export function createCancelTestProviderHandler(section) {
return function(payload) {
return function(dispatch, getState) {
if (abortCurrentRequests[section]) {
abortCurrentRequests[section]();
abortCurrentRequests[section] = null;
}
};
return function(getState, payload, dispatch) {
if (abortCurrentRequests[section]) {
abortCurrentRequests[section]();
abortCurrentRequests[section] = null;
}
};
}
function createTestProviderHandler(section, url, getFromState) {
return function(payload) {
return function(dispatch, getState) {
dispatch(set({ section, isTesting: true }));
function createTestProviderHandler(section, url) {
return function(getState, payload, dispatch) {
dispatch(set({ section, isTesting: true }));
const testData = getProviderState(payload, getState, getFromState);
const testData = getProviderState(payload, getState, section);
const ajaxOptions = {
url: `${url}/test`,
method: 'POST',
contentType: 'application/json',
dataType: 'json',
data: JSON.stringify(testData)
};
const { request, abortRequest } = createAjaxRequest(ajaxOptions);
abortCurrentRequests[section] = abortRequest;
request.done((data) => {
dispatch(set({
section,
isTesting: false,
saveError: null
}));
});
request.fail((xhr) => {
dispatch(set({
section,
isTesting: false,
saveError: xhr.aborted ? null : xhr
}));
});
const ajaxOptions = {
url: `${url}/test`,
method: 'POST',
contentType: 'application/json',
dataType: 'json',
data: JSON.stringify(testData)
};
const { request, abortRequest } = createAjaxRequest(ajaxOptions);
abortCurrentRequests[section] = abortRequest;
request.done((data) => {
dispatch(set({
section,
isTesting: false,
saveError: null
}));
});
request.fail((xhr) => {
dispatch(set({
section,
isTesting: false,
saveError: xhr.aborted ? null : xhr
}));
});
};
}