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.
Add Advanced Options Step to Plan Wizard
* Stub actions/reducer for fetching playbooks * Copy and modify VMsStep table * Copy and modify BootstrapSelect
- Loading branch information
1 parent
0a0fcc7
commit 65fb429
Showing
25 changed files
with
1,260 additions
and
22 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
1 change: 1 addition & 0 deletions
1
app/javascript/react/screens/App/Overview/screens/PlanWizard/PlanWizard.scss
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 @@ | ||
@import './components/PlanWizardAdvancedOptionsStep/PlanWizardAdvancedOptionsStep.scss'; |
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
49 changes: 49 additions & 0 deletions
49
...Wizard/components/PlanWizardAdvancedOptionsStep/PlanWizardAdvancedOptionsStep.fixtures.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,49 @@ | ||
// ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook | ||
|
||
export const playbooks = [ | ||
{ | ||
id: '1', | ||
manager_id: '2', | ||
manager_ref: 'openshift/cloudforms-automation/project-quota.yml', | ||
name: 'openshift/cloudforms-automation/project-quota.yml', | ||
description: 'This is an ansible playbook', | ||
variables: null, | ||
created_at: 'Thu, 18 Jan 2018 17:22:22 UTC +00:00', | ||
updated_at: 'Thu, 18 Jan 2018 17:22:22 UTC +00:00', | ||
survey_spec: null, | ||
inventory_root_group_id: null, | ||
type: 'ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook', | ||
parent_id: null, | ||
configuration_script_source_id: '21' | ||
}, | ||
{ | ||
id: '10', | ||
manager_id: '2', | ||
manager_ref: 'plays/first.yml', | ||
name: 'plays/first.yml', | ||
description: 'This is also an ansible playbook', | ||
variables: null, | ||
created_at: 'Fri, 06 Oct 2017 17:03:07 UTC +00:00', | ||
updated_at: 'Fri, 06 Oct 2017 17:03:07 UTC +00:00', | ||
survey_spec: null, | ||
inventory_root_group_id: null, | ||
type: 'ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook', | ||
parent_id: null, | ||
configuration_script_source_id: '1' | ||
}, | ||
{ | ||
id: '15', | ||
manager_id: '2', | ||
manager_ref: 'plays/post.yml', | ||
name: 'plays/post.yml', | ||
description: 'Yet another, ansible playbook', | ||
variables: null, | ||
created_at: 'Fri, 06 Oct 2017 17:03:07 UTC +00:00', | ||
updated_at: 'Fri, 06 Oct 2017 17:03:07 UTC +00:00', | ||
survey_spec: null, | ||
inventory_root_group_id: null, | ||
type: 'ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook', | ||
parent_id: null, | ||
configuration_script_source_id: '1' | ||
} | ||
]; |
97 changes: 97 additions & 0 deletions
97
...eens/PlanWizard/components/PlanWizardAdvancedOptionsStep/PlanWizardAdvancedOptionsStep.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,97 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Field, reduxForm } from 'redux-form'; | ||
import { Form } from 'patternfly-react'; | ||
|
||
import PlanWizardAdvancedOptionsStepTable from './components/PlanWizardAdvancedOptionsStepTable/PlanWizardAdvancedOptionsStepTable'; | ||
import { PlaybooksBootstrapSelect } from './components/PlaybooksBootstrapSelect'; | ||
|
||
class PlanWizardAdvancedOptionsStep extends Component { | ||
state = { | ||
preMigrationPlaybook: '', | ||
postMigrationPlaybook: '' | ||
}; | ||
|
||
componentDidMount() { | ||
const { getPlaybooksActionCreator } = this.props; | ||
getPlaybooksActionCreator(); | ||
} | ||
|
||
selectPreMigrationPlaybook = event => { | ||
this.setState({ preMigrationPlaybook: event.target.value }); | ||
}; | ||
|
||
selectPostMigrationPlaybook = event => { | ||
this.setState({ postMigrationPlaybook: event.target.value }); | ||
}; | ||
|
||
render() { | ||
const { | ||
valid_vms, | ||
selectedVms, | ||
playbooks, | ||
isFetchingPlaybooks, | ||
dirty | ||
} = this.props; | ||
const { preMigrationPlaybook, postMigrationPlaybook } = this.state; | ||
const vms = valid_vms.filter(vm => selectedVms.includes(vm.id)); | ||
|
||
return ( | ||
<React.Fragment> | ||
{!isFetchingPlaybooks && ( | ||
<Form className="playbook-selects"> | ||
<Field | ||
name="preMigrationPlaybook" | ||
component={PlaybooksBootstrapSelect} | ||
options={playbooks} | ||
option_key="id" | ||
option_value="name" | ||
label={__('Select pre-migration playbook service (optional)')} | ||
onChange={this.selectPreMigrationPlaybook} | ||
/> | ||
<Field | ||
name="postMigrationPlaybook" | ||
component={PlaybooksBootstrapSelect} | ||
options={playbooks} | ||
option_key="id" | ||
option_value="name" | ||
label={__('Select post-migration playbook service (optional)')} | ||
onChange={this.selectPostMigrationPlaybook} | ||
/> | ||
</Form> | ||
)} | ||
{dirty && ( | ||
<Field | ||
name="playbookVms" | ||
component={PlanWizardAdvancedOptionsStepTable} | ||
rows={vms} | ||
preMigrationPlaybook={preMigrationPlaybook} | ||
postMigrationPlaybook={postMigrationPlaybook} | ||
/> | ||
)} | ||
</React.Fragment> | ||
); | ||
} | ||
} | ||
|
||
PlanWizardAdvancedOptionsStep.propTypes = { | ||
valid_vms: PropTypes.array, | ||
selectedVms: PropTypes.array, | ||
playbooks: PropTypes.array, | ||
isFetchingPlaybooks: PropTypes.bool, | ||
getPlaybooksActionCreator: PropTypes.func, | ||
dirty: PropTypes.bool | ||
}; | ||
|
||
export default reduxForm({ | ||
form: 'planWizardAdvancedOptionsStep', | ||
initialValues: { | ||
playbookVms: { | ||
preMigration: [], | ||
postMigration: [] | ||
}, | ||
preMigrationPlaybook: '', | ||
postMigrationPlaybook: '' | ||
}, | ||
destroyOnUnmount: false | ||
})(PlanWizardAdvancedOptionsStep); |
28 changes: 28 additions & 0 deletions
28
...ns/PlanWizard/components/PlanWizardAdvancedOptionsStep/PlanWizardAdvancedOptionsStep.scss
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,28 @@ | ||
.table-view-pf-select.with-label { | ||
width: 110px; | ||
} | ||
|
||
.table-view-pf-select-content { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
|
||
.table-view-pf-footer { | ||
background: #f5f5f5; | ||
&-count { | ||
font-weight: 600; | ||
white-space: pre; | ||
} | ||
} | ||
|
||
.bootstrap-select.btn-group.form-control.preMigrationPlaybook_select, | ||
.bootstrap-select.btn-group.form-control.postMigrationPlaybook_select { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.playbook-services-toolbar .toolbar-pf { | ||
background: #f5f5f5; | ||
border: 1px solid #d1d1d1; | ||
border-bottom: none; | ||
} |
9 changes: 9 additions & 0 deletions
9
...anWizard/components/PlanWizardAdvancedOptionsStep/PlanWizardAdvancedOptionsStepActions.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,9 @@ | ||
import { FETCH_V2V_PLAYBOOKS } from './PlanWizardAdvancedOptionsStepConstants'; | ||
|
||
import { playbooks } from './PlanWizardAdvancedOptionsStep.fixtures'; | ||
|
||
export const getPlaybooksActionCreator = () => dispatch => | ||
dispatch({ | ||
type: FETCH_V2V_PLAYBOOKS, | ||
payload: Promise.resolve({ data: playbooks }) | ||
}); |
1 change: 1 addition & 0 deletions
1
...Wizard/components/PlanWizardAdvancedOptionsStep/PlanWizardAdvancedOptionsStepConstants.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 @@ | ||
export const FETCH_V2V_PLAYBOOKS = 'FETCH_V2V_PLAYBOOKS'; |
Oops, something went wrong.