From c078bab9a65eeb0fe6dd6b64f637d54f28d2f99c Mon Sep 17 00:00:00 2001 From: Mike Turley Date: Fri, 13 Jul 2018 19:15:55 -0400 Subject: [PATCH 1/2] Add cancel plan action --- app/javascript/react/screens/App/Plan/PlanActions.js | 8 ++++++++ app/javascript/react/screens/App/Plan/PlanConstants.js | 5 ++++- app/javascript/react/screens/App/Plan/PlanReducer.js | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/javascript/react/screens/App/Plan/PlanActions.js b/app/javascript/react/screens/App/Plan/PlanActions.js index 0fc874dbee..2fd260a3d6 100644 --- a/app/javascript/react/screens/App/Plan/PlanActions.js +++ b/app/javascript/react/screens/App/Plan/PlanActions.js @@ -7,6 +7,7 @@ import { FETCH_V2V_PLAN, FETCH_V2V_ALL_REQUESTS_WITH_TASKS_FOR_PLAN, QUERY_V2V_PLAN_VMS, + CANCEL_V2V_PLAN, // TODO MARKER MJT RESET_PLAN_STATE, FETCH_V2V_MIGRATION_TASK_LOG, DOWNLOAD_LOG_CLICKED, @@ -79,6 +80,13 @@ export const fetchPlanAction = (url, id) => { return _getPlanActionCreator(uri.toString()); }; +// ***************************************************************************** +// * CANCEL_V2V_PLAN +// ***************************************************************************** +export const cancelPlanAction = () => ({ + type: CANCEL_V2V_PLAN +}); + // ***************************************************************************** // * RESET_PLAN_STATE // ***************************************************************************** diff --git a/app/javascript/react/screens/App/Plan/PlanConstants.js b/app/javascript/react/screens/App/Plan/PlanConstants.js index a1b6460400..965e41fde4 100644 --- a/app/javascript/react/screens/App/Plan/PlanConstants.js +++ b/app/javascript/react/screens/App/Plan/PlanConstants.js @@ -2,6 +2,7 @@ export const FETCH_V2V_PLAN_REQUEST = 'FETCH_V2V_PLAN_REQUEST'; export const FETCH_V2V_PLAN = 'FETCH_V2V_PLAN'; export const FETCH_V2V_ALL_REQUESTS_WITH_TASKS_FOR_PLAN = 'FETCH_V2V_ALL_REQUESTS_WITH_TASKS_FOR_PLAN'; export const QUERY_V2V_PLAN_VMS = 'QUERY_V2V_PLAN_VMS'; +export const CANCEL_V2V_PLAN = 'CANCEL_V2V_PLAN'; export const RESET_PLAN_STATE = 'RESET_PLAN_STATE'; export const FETCH_V2V_MIGRATION_TASK_LOG = 'FETCH_V2V_MIGRATION_TASK_LOG'; export const DOWNLOAD_LOG_CLICKED = 'DOWNLOAD_LOG_CLICKED'; @@ -26,7 +27,8 @@ export const STATUS_MESSAGE_KEYS = { VALIDATING: 'Validating', VM_MIGRATIONS_COMPLETED: 'VM Transformations completed', VM_MIGRATED: 'Virtual machine migrated', - VM_MIGRATIONS_FAILED: 'VM Transformations failed' + VM_MIGRATIONS_FAILED: 'VM Transformations failed', + CANCELLED: 'Migration plan cancelled' }; const STATUS_MESSAGES = {}; @@ -49,5 +51,6 @@ STATUS_MESSAGES[STATUS_MESSAGE_KEYS.VALIDATING] = __('Validating'); STATUS_MESSAGES[STATUS_MESSAGE_KEYS.VM_MIGRATIONS_COMPLETED] = __('VM migrations completed'); STATUS_MESSAGES[STATUS_MESSAGE_KEYS.VM_MIGRATED] = __('Virtual machine migrated'); STATUS_MESSAGES[STATUS_MESSAGE_KEYS.VM_MIGRATIONS_FAILED] = __('VM migrations failed'); +STATUS_MESSAGES[STATUS_MESSAGE_KEYS.CANCELLED] = __('Migration plan cancelled'); export { STATUS_MESSAGES as V2V_MIGRATION_STATUS_MESSAGES }; diff --git a/app/javascript/react/screens/App/Plan/PlanReducer.js b/app/javascript/react/screens/App/Plan/PlanReducer.js index ae4d4cda23..8c45fb88c7 100644 --- a/app/javascript/react/screens/App/Plan/PlanReducer.js +++ b/app/javascript/react/screens/App/Plan/PlanReducer.js @@ -8,6 +8,7 @@ import { FETCH_V2V_PLAN, FETCH_V2V_ALL_REQUESTS_WITH_TASKS_FOR_PLAN, QUERY_V2V_PLAN_VMS, + CANCEL_V2V_PLAN, RESET_PLAN_STATE, FETCH_V2V_MIGRATION_TASK_LOG, DOWNLOAD_LOG_CLICKED, @@ -28,6 +29,7 @@ export const initialState = Immutable({ errorPlan: null, plan: {}, planArchived: false, + planCancelled: false, isQueryingVms: false, isRejectedVms: false, errorVms: null, From 9822485b40eaafbda613bb6340cddaf411bd9189 Mon Sep 17 00:00:00 2001 From: Mike Turley Date: Wed, 18 Jul 2018 13:40:39 -0400 Subject: [PATCH 2/2] WIP Cancel Plan --- app/javascript/react/screens/App/Plan/Plan.js | 11 +++++++++++ .../screens/App/Plan/__test__/PlanActions.test.js | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/javascript/react/screens/App/Plan/Plan.js b/app/javascript/react/screens/App/Plan/Plan.js index 0b07e45ad1..5d7068448a 100644 --- a/app/javascript/react/screens/App/Plan/Plan.js +++ b/app/javascript/react/screens/App/Plan/Plan.js @@ -97,7 +97,17 @@ class Plan extends React.Component { } }; + cancelPlan = () => { + const { dispatch, cancelPlanAction } = this.props; + dispatch(cancelPlanAction()); + }; + render() { + + //////////////////////////////////////////////////////////////////////////////// + // TODO render a cancel button that dispatches this.props.cancelPlanAction(); // + //////////////////////////////////////////////////////////////////////////////// + const { planName, planArchived, @@ -215,6 +225,7 @@ Plan.propTypes = { queryPlanVmsAction: PropTypes.func, isQueryingVms: PropTypes.bool, isRejectedVms: PropTypes.bool, + cancelPlanAction: PropTypes.func, resetPlanStateAction: PropTypes.func, downloadLogAction: PropTypes.func, downloadLogInProgressTaskIds: PropTypes.array diff --git a/app/javascript/react/screens/App/Plan/__test__/PlanActions.test.js b/app/javascript/react/screens/App/Plan/__test__/PlanActions.test.js index d68179d008..78abb23a13 100644 --- a/app/javascript/react/screens/App/Plan/__test__/PlanActions.test.js +++ b/app/javascript/react/screens/App/Plan/__test__/PlanActions.test.js @@ -3,9 +3,9 @@ import thunk from 'redux-thunk'; import promiseMiddleware from 'redux-promise-middleware'; import { mockRequest, mockReset } from '../../../../../common/mockRequests'; -import { _getPlanActionCreator, fetchPlanAction, resetPlanStateAction } from '../PlanActions'; +import { _getPlanActionCreator, fetchPlanAction, resetPlanStateAction, cancelPlanAction } from '../PlanActions'; import { requestPlanData } from '../plan.fixtures'; -import { FETCH_V2V_PLAN, RESET_PLAN_STATE } from '../PlanConstants'; +import { FETCH_V2V_PLAN, RESET_PLAN_STATE, CANCEL_V2V_PLAN } from '../PlanConstants'; const middlewares = [thunk, promiseMiddleware()]; const mockStore = configureMockStore(middlewares); @@ -58,6 +58,17 @@ describe('FETCH_V2V_PLAN', () => { }); }); +describe('cancelPlanAction', () => { + test('sets up the CANCEL_V2V_PLAN action object', () => { + const action = cancelPlanAction(); + + expect(action).toEqual({ + type: CANCEL_V2V_PLAN + }); + }); +}); + + describe('resetPlanStateAction', () => { test('sets up the RESET_PLAN_STATE action object', () => { const action = resetPlanStateAction();