From e8441f31116c156130e4c2ee50346c4723139284 Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Thu, 2 Nov 2017 23:32:02 +0100 Subject: [PATCH] Cleanup error messages for strategies --- frontend/src/component/strategies/add-strategy.jsx | 1 - frontend/src/store/strategy/actions.js | 10 +++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/frontend/src/component/strategies/add-strategy.jsx b/frontend/src/component/strategies/add-strategy.jsx index 7647c66bae..107aebf960 100644 --- a/frontend/src/component/strategies/add-strategy.jsx +++ b/frontend/src/component/strategies/add-strategy.jsx @@ -128,7 +128,6 @@ class AddStrategy extends Component { name="name" required disabled={editmode} - pattern="^[0-9a-zA-Z\.\-\_]+$" onChange={({ target }) => setValue('name', trim(target.value))} value={input.name} /> diff --git a/frontend/src/store/strategy/actions.js b/frontend/src/store/strategy/actions.js index 6e7bc16781..ef35480b5d 100644 --- a/frontend/src/store/strategy/actions.js +++ b/frontend/src/store/strategy/actions.js @@ -11,16 +11,12 @@ export const RECEIVE_STRATEGIES = 'RECEIVE_STRATEGIES'; export const ERROR_RECEIVE_STRATEGIES = 'ERROR_RECEIVE_STRATEGIES'; export const ERROR_CREATING_STRATEGY = 'ERROR_CREATING_STRATEGY'; export const ERROR_UPDATING_STRATEGY = 'ERROR_UPDATING_STRATEGY'; +export const ERROR_REMOVING_STRATEGY = 'ERROR_REMOVING_STRATEGY'; const addStrategy = strategy => ({ type: ADD_STRATEGY, strategy }); const createRemoveStrategy = strategy => ({ type: REMOVE_STRATEGY, strategy }); const updatedStrategy = strategy => ({ type: UPDATE_STRATEGY, strategy }); -const errorCreatingStrategy = statusCode => ({ - type: ERROR_CREATING_STRATEGY, - statusCode, -}); - const startRequest = () => ({ type: REQUEST_STRATEGIES }); const receiveStrategies = json => ({ @@ -62,7 +58,7 @@ export function createStrategy(strategy) { return api .create(strategy) .then(() => dispatch(addStrategy(strategy))) - .catch(error => dispatch(errorCreatingStrategy(error))); + .catch(dispatchAndThrow(dispatch, ERROR_CREATING_STRATEGY)); }; } @@ -82,7 +78,7 @@ export function removeStrategy(strategy) { api .remove(strategy) .then(() => dispatch(createRemoveStrategy(strategy))) - .catch(error => dispatch(errorCreatingStrategy(error))); + .catch(dispatchAndThrow(dispatch, ERROR_REMOVING_STRATEGY)); } export function getApplicationsWithStrategy(strategyName) {