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

Commit

Permalink
POST to edit a plan instead of PUT
Browse files Browse the repository at this point in the history
  • Loading branch information
mturley committed Sep 21, 2018
1 parent 6d513bc commit 7fb7fbd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ class PlanWizardResultsStep extends React.Component {
const {
postPlansUrl,
postMigrationPlansAction,
putPlansUrl,
putMigrationPlansAction,
editPlansUrl,
editMigrationPlansAction,
plansBody,
planSchedule,
editingPlan
} = this.props;
if (!editingPlan) {
postMigrationPlansAction(postPlansUrl, plansBody, planSchedule);
} else {
putMigrationPlansAction(putPlansUrl, editingPlan.id, plansBody, planSchedule);
editMigrationPlansAction(editPlansUrl, editingPlan.id, plansBody, planSchedule);
}
}
renderSpinner = (title, message) => (
Expand Down Expand Up @@ -94,9 +94,9 @@ class PlanWizardResultsStep extends React.Component {
}
PlanWizardResultsStep.propTypes = {
postPlansUrl: PropTypes.string,
putPlansUrl: PropTypes.string,
editPlansUrl: PropTypes.string,
postMigrationPlansAction: PropTypes.func,
putMigrationPlansAction: PropTypes.func,
editMigrationPlansAction: PropTypes.func,
plansBody: PropTypes.object,
planSchedule: PropTypes.string,
isPostingPlans: PropTypes.bool,
Expand All @@ -112,9 +112,9 @@ PlanWizardResultsStep.propTypes = {
};
PlanWizardResultsStep.defaultProps = {
postPlansUrl: '/api/service_templates',
putPlansUrl: '/api/service_templates',
editPlansUrl: '/api/service_templates',
postMigrationPlansAction: noop,
putMigrationPlansAction: noop,
editMigrationPlansAction: noop,
plansBody: {},
planSchedule: '',
isPostingPlans: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ const _postMigrationPlansActionCreator = (url, migrationPlans, planSchedule) =>
export const postMigrationPlansAction = (url, migrationPlans, planSchedule) =>
_postMigrationPlansActionCreator(url, migrationPlans, planSchedule);

const _putMigrationPlansActionCreator = (url, planId, migrationPlans, planSchedule) => dispatch =>
dispatch({
const _editMigrationPlansActionCreator = (url, planId, migrationPlans, planSchedule) => dispatch => {
const body = {
action: 'edit',
resource: { ...migrationPlans }
};
return dispatch({
type: PUT_V2V_MIGRATION_PLANS,
payload: new Promise((resolve, reject) => {
API.put(`${url}/${planId}`, migrationPlans)
API.post(`${url}/${planId}`, body)
.then(response => {
resolve(response);
if (planSchedule === 'migration_plan_now') {
Expand All @@ -54,6 +58,7 @@ const _putMigrationPlansActionCreator = (url, planId, migrationPlans, planSchedu
.catch(e => reject(e));
})
});
};

export const putMigrationPlansAction = (url, planId, migrationPlans, planSchedule) =>
_putMigrationPlansActionCreator(url, planId, migrationPlans, planSchedule);
export const editMigrationPlansAction = (url, planId, migrationPlans, planSchedule) =>
_editMigrationPlansActionCreator(url, planId, migrationPlans, planSchedule);

0 comments on commit 7fb7fbd

Please sign in to comment.