This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #474 from priley86/duplicate-plans
[#451] duplicate plan name validation (cherry picked from commit 8bf1179) https://bugzilla.redhat.com/show_bug.cgi?id=1608768
- Loading branch information
1 parent
17e475e
commit 594bd65
Showing
15 changed files
with
131 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
app/javascript/react/screens/App/Overview/screens/PlanWizard/PlanWizardConstants.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export const V2V_SET_PLANS_BODY = 'V2V_SET_PLANS_BODY'; | ||
export const V2V_SET_PLAN_SCHEDULE = 'V2V_SET_PLAN_SCHEDULE'; | ||
export const V2V_PLAN_WIZARD_SHOW_ALERT = 'V2V_PLAN_WIZARD_SHOW_ALERT'; | ||
export const V2V_PLAN_WIZARD_HIDE_ALERT = 'V2V_PLAN_WIZARD_HIDE_ALERT'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...react/screens/App/Overview/screens/PlanWizard/components/PlanWizardGeneralStep/helpers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export const asyncValidate = (values, dispatch, props) => | ||
new Promise((resolve, reject) => { | ||
const { name: newPlanName } = values; | ||
const { transformationPlans, archivedTransformationPlans } = props; | ||
const existingTransformationPlanNames = transformationPlans.reduce( | ||
(names, plan) => [...names, plan.name.trim()], | ||
[] | ||
); | ||
const existingArchivedPlanNames = archivedTransformationPlans.reduce( | ||
(names, plan) => [...names, plan.name.trim()], | ||
[] | ||
); | ||
|
||
const allPlanNames = [...existingTransformationPlanNames, ...existingArchivedPlanNames]; | ||
const duplicateName = allPlanNames.find(existingPlanName => existingPlanName === newPlanName.trim()); | ||
|
||
if (duplicateName) { | ||
props.showAlertAction(sprintf(__('Name %s already exists'), newPlanName)); | ||
const error = { name: 'Please enter a unique name' }; | ||
reject(error); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
|
||
export const onChange = (values, dispatch, props) => { | ||
if (props.valid) { | ||
props.hideAlertAction(); | ||
} | ||
}; |
10 changes: 9 additions & 1 deletion
10
...t/react/screens/App/Overview/screens/PlanWizard/components/PlanWizardGeneralStep/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
import { connect } from 'react-redux'; | ||
import PlanWizardGeneralStep from './PlanWizardGeneralStep'; | ||
import { showAlertAction, hideAlertAction } from '../../PlanWizardActions'; | ||
|
||
const mapStateToProps = ({ overview }) => ({ | ||
transformationMappings: overview.transformationMappings, | ||
transformationPlans: overview.transformationPlans, | ||
archivedTransformationPlans: overview.archivedTransformationPlans, | ||
initialValues: { | ||
infrastructure_mapping: overview.planWizardId, | ||
vm_choice_radio: 'vms_via_discovery' | ||
} | ||
}); | ||
|
||
export default connect(mapStateToProps)(PlanWizardGeneralStep); | ||
const actions = { showAlertAction, hideAlertAction }; | ||
|
||
export default connect( | ||
mapStateToProps, | ||
actions | ||
)(PlanWizardGeneralStep); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters