Skip to content

Commit

Permalink
Merge pull request #514 from AllenBW/enhancement/adds-migration-sched…
Browse files Browse the repository at this point in the history
…uling-to-completed-list

[#515]Adds migration scheduling to complete mapping list
(cherry picked from commit 5e21f6d)

https://bugzilla.redhat.com/show_bug.cgi?id=1608351
  • Loading branch information
michaelkro authored and simaishi committed Jul 31, 2018
1 parent b1d626e commit ca38810
Show file tree
Hide file tree
Showing 9 changed files with 386 additions and 276 deletions.
6 changes: 3 additions & 3 deletions app/javascript/react/screens/App/Overview/Overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class Overview extends React.Component {
isRejectedDatastores,
toggleScheduleMigrationModal,
scheduleMigrationModal,
scheduleMigrationPlanId,
scheduleMigrationPlan,
scheduleMigration
} = this.props;

Expand Down Expand Up @@ -324,7 +324,7 @@ class Overview extends React.Component {
addNotificationAction={addNotificationAction}
toggleScheduleMigrationModal={toggleScheduleMigrationModal}
scheduleMigrationModal={scheduleMigrationModal}
scheduleMigrationPlanId={scheduleMigrationPlanId}
scheduleMigrationPlan={scheduleMigrationPlan}
scheduleMigration={scheduleMigration}
/>
)}
Expand Down Expand Up @@ -452,7 +452,7 @@ Overview.propTypes = {
fetchDatastoresAction: PropTypes.func,
toggleScheduleMigrationModal: PropTypes.func,
scheduleMigrationModal: PropTypes.bool,
scheduleMigrationPlanId: PropTypes.string,
scheduleMigrationPlan: PropTypes.object,
scheduleMigration: PropTypes.func
};
export default Overview;
26 changes: 18 additions & 8 deletions app/javascript/react/screens/App/Overview/OverviewActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,31 +233,41 @@ export const archiveTransformationPlanAction = (url, id) => {
return _archiveTransformationPlanActionCreator(uri.toString());
};

export const toggleScheduleMigrationModal = planId => ({
export const toggleScheduleMigrationModal = plan => ({
type: V2V_TOGGLE_SCHEDULE_MIGRATION_MODAL,
payload: planId
payload: plan
});

export const scheduleMigration = payload => dispatch =>
dispatch({
type: V2V_SCHEDULE_MIGRATION,
payload: new Promise((resolve, reject) => {
let url = `/api/service_templates/${payload.planId}`;
const {
scheduleTime,
plan: { id: planId }
} = payload;
const scheduleId = (payload.plan.schedules && payload.plan.schedules[0].id) || null;
let url = `/api/service_templates/${planId}`;
let body = {
action: 'order',
resource: {
schedule_time: payload.scheduleTime
schedule_time: scheduleTime
}
};
if (payload.scheduleId) {
url = `${url}/schedules/${payload.scheduleId}`;
body = { action: 'delete' };
if (scheduleId) {
url = `${url}/schedules/${scheduleId}`;
body = scheduleTime
? {
action: 'edit',
resource: { run_at: { ...payload.plan.schedules[0].run_at, start_time: scheduleTime } }
}
: { action: 'delete' };
}
return API.post(url, body)
.then(response => {
resolve(response);
let msg = __('Migration successfully unscheduled');
if (payload.scheduleTime) {
if (scheduleTime) {
msg = sprintf(
__('Migration successfully scheduled for %s'),
formatDateTime(response.data.run_at.start_time)
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/react/screens/App/Overview/OverviewReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const initialState = Immutable({
isFetchingNetworks: false,
isRejectedNetworks: false,
scheduleMigrationModal: false,
scheduleMigrationPlanId: null,
scheduleMigrationPlan: {},
isSchedulingMigration: false,
isRejectedSchedulingMigration: false,
errorSchedulingMigration: false
Expand Down Expand Up @@ -343,10 +343,10 @@ export default (state = initialState, action) => {
case V2V_TOGGLE_SCHEDULE_MIGRATION_MODAL:
if (action.payload !== undefined) {
return state
.set('scheduleMigrationPlanId', action.payload.planId)
.set('scheduleMigrationPlan', action.payload.plan)
.set('scheduleMigrationModal', !state.scheduleMigrationModal);
}
return state.set('scheduleMigrationPlanId', null).set('scheduleMigrationModal', !state.scheduleMigrationModal);
return state.set('scheduleMigrationPlan', null).set('scheduleMigrationModal', !state.scheduleMigrationModal);
case `${V2V_SCHEDULE_MIGRATION}_PENDING`:
return state.set('isSchedulingMigration', true).set('isRejectedSchedulingMigration', false);
case `${V2V_SCHEDULE_MIGRATION}_FULFILLED`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Migrations = ({
addNotificationAction,
toggleScheduleMigrationModal,
scheduleMigrationModal,
scheduleMigrationPlanId,
scheduleMigrationPlan,
scheduleMigration
}) => {
const filterOptions = [
Expand Down Expand Up @@ -112,7 +112,7 @@ const Migrations = ({
hideConfirmModalAction={hideConfirmModalAction}
toggleScheduleMigrationModal={toggleScheduleMigrationModal}
scheduleMigrationModal={scheduleMigrationModal}
scheduleMigrationPlanId={scheduleMigrationPlanId}
scheduleMigrationPlan={scheduleMigrationPlan}
scheduleMigration={scheduleMigration}
fetchTransformationPlansAction={fetchTransformationPlansAction}
fetchTransformationPlansUrl={fetchTransformationPlansUrl}
Expand Down Expand Up @@ -141,6 +141,10 @@ const Migrations = ({
fetchTransformationPlansAction={fetchTransformationPlansAction}
fetchTransformationPlansUrl={fetchTransformationPlansUrl}
addNotificationAction={addNotificationAction}
toggleScheduleMigrationModal={toggleScheduleMigrationModal}
scheduleMigrationModal={scheduleMigrationModal}
scheduleMigrationPlan={scheduleMigrationPlan}
scheduleMigration={scheduleMigration}
/>
)}
{activeFilter === MIGRATIONS_FILTERS.archived && (
Expand Down Expand Up @@ -184,7 +188,7 @@ Migrations.propTypes = {
addNotificationAction: PropTypes.func,
toggleScheduleMigrationModal: PropTypes.func,
scheduleMigrationModal: PropTypes.bool,
scheduleMigrationPlanId: PropTypes.string,
scheduleMigrationPlan: PropTypes.object,
scheduleMigration: PropTypes.func
};
Migrations.defaultProps = {
Expand Down
Loading

0 comments on commit ca38810

Please sign in to comment.