New: Command line arguments for Custom Scripts are no longer supported

This commit is contained in:
Mark McDowall
2019-06-29 15:33:49 -07:00
committed by ta264
parent b8b8f064c7
commit b9d240924f
15 changed files with 170 additions and 126 deletions
@@ -0,0 +1,78 @@
import { createAction } from 'redux-actions';
import requestAction from 'Utilities/requestAction';
import updateSectionState from 'Utilities/State/updateSectionState';
import { createThunk, handleThunks } from 'Store/thunks';
import createHandleActions from './Creators/createHandleActions';
import { set } from './baseActions';
//
// Variables
export const section = 'providerOptions';
//
// State
export const defaultState = {
items: [],
isFetching: false,
isPopulated: false,
error: false
};
//
// Actions Types
export const FETCH_OPTIONS = 'devices/fetchOptions';
export const CLEAR_OPTIONS = 'devices/clearOptions';
//
// Action Creators
export const fetchOptions = createThunk(FETCH_OPTIONS);
export const clearOptions = createAction(CLEAR_OPTIONS);
//
// Action Handlers
export const actionHandlers = handleThunks({
[FETCH_OPTIONS]: function(getState, payload, dispatch) {
dispatch(set({
section,
isFetching: true
}));
const promise = requestAction(payload);
promise.done((data) => {
dispatch(set({
section,
isFetching: false,
isPopulated: true,
error: null,
items: data.options || []
}));
});
promise.fail((xhr) => {
dispatch(set({
section,
isFetching: false,
isPopulated: false,
error: xhr
}));
});
}
});
//
// Reducers
export const reducers = createHandleActions({
[CLEAR_OPTIONS]: function(state) {
return updateSectionState(state, section, defaultState);
}
}, defaultState, section);