Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

[Abandoned][#370] Cancel Migration Plan / Cancel Mike's Plans #509

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions app/javascript/react/screens/App/Plan/Plan.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions app/javascript/react/screens/App/Plan/PlanActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
// *****************************************************************************
Expand Down
5 changes: 4 additions & 1 deletion app/javascript/react/screens/App/Plan/PlanConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = {};
Expand All @@ -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 };
2 changes: 2 additions & 0 deletions app/javascript/react/screens/App/Plan/PlanReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -28,6 +29,7 @@ export const initialState = Immutable({
errorPlan: null,
plan: {},
planArchived: false,
planCancelled: false,
isQueryingVms: false,
isRejectedVms: false,
errorVms: null,
Expand Down
15 changes: 13 additions & 2 deletions app/javascript/react/screens/App/Plan/__test__/PlanActions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down