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

Commit

Permalink
Remove alert from EditPlanNameModal, replace validation text
Browse files Browse the repository at this point in the history
  • Loading branch information
mturley committed Oct 4, 2018
1 parent 573db0d commit 1a24622
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 81 deletions.
1 change: 0 additions & 1 deletion app/javascript/react/screens/App/Overview/Overview.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
@import 'components/ModalWizard/ModalWizard.scss';
@import 'components/AggregateCards/AggregateCards.scss';
@import 'components/OverviewEmptyState/OverviewEmptyState.scss';
@import 'components/EditPlanNameModal/EditPlanNameModal.scss';

hr {
margin-top: 10px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
import {
V2V_EDIT_PLAN_TITLE_SHOW_ALERT,
V2V_EDIT_PLAN_TITLE_HIDE_ALERT,
V2V_POST_EDIT_PLAN_TITLE
} from './EditPlanNameConstants';
import { V2V_POST_EDIT_PLAN_NAME } from './EditPlanNameConstants';
import API from '../../../../../../common/API';

export { fetchTransformationPlansAction } from '../../OverviewActions';

export const showAlertAction = (alertText, alertType = 'error') => dispatch => {
dispatch({
type: V2V_EDIT_PLAN_TITLE_SHOW_ALERT,
payload: { alertText, alertType }
});
};

export const hideAlertAction = () => dispatch => {
dispatch({
type: V2V_EDIT_PLAN_TITLE_HIDE_ALERT
});
};

const _editMigrationPlansActionCreator = (url, planId, migrationPlans) => dispatch => {
const body = {
action: 'edit',
resource: { ...migrationPlans }
};
return dispatch({
type: V2V_POST_EDIT_PLAN_TITLE,
type: V2V_POST_EDIT_PLAN_NAME,
payload: API.post(`${url}/${planId}`, body)
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
export const V2V_EDIT_PLAN_TITLE_SHOW_ALERT = 'V2V_EDIT_PLAN_TITLE_SHOW_ALERT';
export const V2V_EDIT_PLAN_TITLE_HIDE_ALERT = 'V2V_EDIT_PLAN_TITLE_HIDE_ALERT';
export const V2V_POST_EDIT_PLAN_TITLE = 'V2V_POST_EDIT_PLAN_TITLE';
export const V2V_POST_EDIT_PLAN_NAME = 'V2V_POST_EDIT_PLAN_NAME';
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import { Field, reduxForm } from 'redux-form';
import { required } from 'redux-form-validators';
import { Modal, Button, Form, Alert, Spinner, noop } from 'patternfly-react';
import { Modal, Button, Form, Spinner, noop } from 'patternfly-react';
import { FormField } from '../../../common/forms/FormField';
import { validation } from '../../../../../../common/constants';
import { asyncValidate, onChange } from '../../screens/PlanWizard/components/PlanWizardGeneralStep/helpers';
Expand Down Expand Up @@ -38,20 +37,9 @@ class EditPlanNameModal extends React.Component {
};

render() {
const {
editPlanNameModalVisible,
hideEditPlanNameModalAction,
editPlanNameModal,
alertType,
alertText,
hideAlertAction,
savingPlan
} = this.props;
const { editPlanNameModalVisible, hideEditPlanNameModalAction, editPlanNameModal, savingPlan } = this.props;

const disableConfirmButton = savingPlan || !!editPlanNameModal.syncErrors || !!editPlanNameModal.asyncErrors;
const alertClasses = cx('modal-alert--alert', {
'is-visible': alertText
});

const formBody = (
<Form horizontal>
Expand Down Expand Up @@ -95,14 +83,7 @@ class EditPlanNameModal extends React.Component {
<Modal.CloseButton onClick={hideEditPlanNameModalAction} />
<Modal.Title>{__('Edit Migration Plan')}</Modal.Title>
</Modal.Header>
<Modal.Body>
{!savingPlan ? formBody : spinner}
<div className="modal-alert">
<Alert className={alertClasses} type={alertType} onDismiss={hideAlertAction}>
{alertText}
</Alert>
</div>
</Modal.Body>
<Modal.Body>{!savingPlan ? formBody : spinner}</Modal.Body>
<Modal.Footer>
<Button bsStyle="default" className="btn-cancel" onClick={hideEditPlanNameModalAction}>
{__('Cancel')}
Expand All @@ -120,9 +101,6 @@ EditPlanNameModal.propTypes = {
editPlanNameModalVisible: PropTypes.bool,
hideEditPlanNameModalAction: PropTypes.func,
editPlanNameModal: PropTypes.object,
alertType: PropTypes.string,
alertText: PropTypes.string,
hideAlertAction: PropTypes.func,
editingPlan: PropTypes.object,
editMigrationPlansAction: PropTypes.func,
editMigrationPlansUrl: PropTypes.string,
Expand All @@ -136,9 +114,6 @@ EditPlanNameModal.defaultProps = {
editPlanNameModalVisible: false,
hideEditPlanNameModalAction: noop,
editPlanNameModal: {},
alertType: 'error',
alertText: '',
hideAlertAction: noop,
editMigrationPlansUrl: '/api/service_templates'
};

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Immutable from 'seamless-immutable';
import {
V2V_EDIT_PLAN_TITLE_SHOW_ALERT,
V2V_EDIT_PLAN_TITLE_HIDE_ALERT,
V2V_POST_EDIT_PLAN_TITLE
V2V_POST_EDIT_PLAN_NAME
} from './EditPlanNameConstants';

const initialState = Immutable({
Expand All @@ -18,17 +18,17 @@ export default (state = initialState, action) => {
return Immutable.merge(state, action.payload);
case V2V_EDIT_PLAN_TITLE_HIDE_ALERT:
return state.set('alertText', '');
case `${V2V_POST_EDIT_PLAN_TITLE}_PENDING`:
case `${V2V_POST_EDIT_PLAN_NAME}_PENDING`:
return state
.set('savingPlan', true)
.set('savingPlanRejected', false)
.set('savingPlanError', null);
case `${V2V_POST_EDIT_PLAN_TITLE}_FULFILLED`:
case `${V2V_POST_EDIT_PLAN_NAME}_FULFILLED`:
return state
.set('savingPlan', false)
.set('savingPlanRejected', false)
.set('savingPlanError', null);
case `${V2V_POST_EDIT_PLAN_TITLE}_REJECTED`:
case `${V2V_POST_EDIT_PLAN_NAME}_REJECTED`:
return state
.set('savingPlan', false)
.set('savingPlanRejected', true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const asyncValidate = (values, dispatch, props) =>

if (duplicateName && !duplicateIsEditingMappingName) {
props.showAlertAction(sprintf(__('Infrastructure mapping %s already exists'), newTransformationName));
const error = { name: __('Please enter a unique name') };
const error = { name: __('Mapping name already exists. Enter a unique name.') };
reject(error);
} else {
resolve();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const asyncValidate = (values, dispatch, props) =>
const duplicateIsEditingPlanName = editingPlan && duplicateName === editingPlan.name;

if (duplicateName && !duplicateIsEditingPlanName) {
props.showAlertAction(sprintf(__('Name %s already exists'), newPlanName));
const error = { name: 'Please enter a unique name' };
if (props.showAlertAction) props.showAlertAction(sprintf(__('Name %s already exists'), newPlanName));
const error = { name: 'Plan name already exists. Enter a unique name.' };
reject(error);
} else {
resolve();
Expand All @@ -26,6 +26,6 @@ export const asyncValidate = (values, dispatch, props) =>

export const onChange = (values, dispatch, props) => {
if (props.valid) {
props.hideAlertAction();
if (props.hideAlertAction) props.hideAlertAction();
}
};

0 comments on commit 1a24622

Please sign in to comment.