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

Display the Transformation mapping info in the Plan list immediately when the list loads #696

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions app/javascript/react/screens/App/Overview/Overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ class Overview extends React.Component {
scheduleMigrationModal,
scheduleMigrationPlan,
scheduleMigration,
plansMutatedWithMappingInfo,
showPlanWizardEditModeAction,
fetchTransformationMappingsUrl,
fetchTransformationMappingsAction
Expand Down Expand Up @@ -355,7 +354,6 @@ class Overview extends React.Component {
scheduleMigrationModal={scheduleMigrationModal}
scheduleMigrationPlan={scheduleMigrationPlan}
scheduleMigration={scheduleMigration}
plansMutatedWithMappingInfo={plansMutatedWithMappingInfo}
showPlanWizardEditModeAction={showPlanWizardEditModeAction}
fetchTransformationMappingsUrl={fetchTransformationMappingsUrl}
fetchTransformationMappingsAction={fetchTransformationMappingsAction}
Expand Down Expand Up @@ -509,7 +507,6 @@ Overview.propTypes = {
fetchServiceTemplateAnsiblePlaybooksUrl: PropTypes.string,
serviceTemplatePlaybooks: PropTypes.array,
redirectTo: PropTypes.func.isRequired,
plansMutatedWithMappingInfo: PropTypes.bool,
showMappingWizardEditModeAction: PropTypes.func
};

Expand All @@ -526,7 +523,7 @@ Overview.defaultProps = {
"filter[]=type='ServiceTemplateTransformationPlan'" +
'&filter[]=active=true' +
'&expand=resources,schedules' +
'&attributes=name,description,miq_requests,options,created_at' +
'&attributes=name,description,miq_requests,options,created_at,transformation_mapping' +
'&sort_by=updated_at' +
'&sort_order=desc',
fetchServiceTemplateAnsiblePlaybooksUrl:
Expand All @@ -539,7 +536,7 @@ Overview.defaultProps = {
"filter[]=type='ServiceTemplateTransformationPlan'" +
'&filter[]=archived=true' +
'&expand=resources' +
'&attributes=name,description,miq_requests,options,created_at' +
'&attributes=name,description,miq_requests,options,created_at,transformation_mapping' +
'&sort_by=updated_at' +
'&sort_order=desc',
fetchClustersUrl:
Expand Down
4 changes: 1 addition & 3 deletions app/javascript/react/screens/App/Overview/OverviewReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ export const initialState = Immutable({
serviceTemplatePlaybooks: [],
isFetchingServiceTemplatePlaybooks: false,
isRejectedServiceTemplatePlaybooks: false,
errorServiceTemplatePlaybooks: null,
plansMutatedWithMappingInfo: false
errorServiceTemplatePlaybooks: null
});

export default (state = initialState, action) => {
Expand Down Expand Up @@ -216,7 +215,6 @@ export default (state = initialState, action) => {
.set('transformationPlans', planTransmutation(action.payload.data.resources, state.transformationMappings))
.set('isFetchingTransformationPlans', false)
.set('isRejectedTransformationPlans', false)
.set('plansMutatedWithMappingInfo', !state.isFetchingTransformationMappings)
.set('errorTransformationPlans', null);
}
case `${FETCH_V2V_TRANSFORMATION_PLANS}_REJECTED`:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ describe('fetching transformation plans', () => {

expect(state).toEqual({
...initialStateWithInfraMapping,
isFetchingTransformationPlans: true,
plansMutatedWithMappingInfo: false
isFetchingTransformationPlans: true
});
});

Expand All @@ -41,8 +40,7 @@ describe('fetching transformation plans', () => {

expect(state).toEqual({
...initialStateWithInfraMapping,
transformationPlans: payload.data.resources,
plansMutatedWithMappingInfo: true
transformationPlans: payload.data.resources
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const Migrations = ({
scheduleMigrationModal,
scheduleMigrationPlan,
scheduleMigration,
plansMutatedWithMappingInfo,
showPlanWizardEditModeAction,
fetchTransformationMappingsUrl,
fetchTransformationMappingsAction,
Expand Down Expand Up @@ -126,7 +125,6 @@ const Migrations = ({
scheduleMigration={scheduleMigration}
fetchTransformationPlansAction={fetchTransformationPlansAction}
fetchTransformationPlansUrl={fetchTransformationPlansUrl}
plansMutatedWithMappingInfo={plansMutatedWithMappingInfo}
deleteTransformationPlanAction={deleteTransformationPlanAction}
deleteTransformationPlanUrl={deleteTransformationPlanUrl}
showPlanWizardEditModeAction={showPlanWizardEditModeAction}
Expand Down Expand Up @@ -165,7 +163,6 @@ const Migrations = ({
scheduleMigrationModal={scheduleMigrationModal}
scheduleMigrationPlan={scheduleMigrationPlan}
scheduleMigration={scheduleMigration}
plansMutatedWithMappingInfo={plansMutatedWithMappingInfo}
fetchTransformationMappingsAction={fetchTransformationMappingsAction}
fetchTransformationMappingsUrl={fetchTransformationMappingsUrl}
showEditPlanNameModalAction={showEditPlanNameModalAction}
Expand All @@ -178,7 +175,6 @@ const Migrations = ({
redirectTo={redirectTo}
loading={isFetchingArchivedTransformationPlans}
archived
plansMutatedWithMappingInfo={plansMutatedWithMappingInfo}
showConfirmModalAction={showConfirmModalAction}
hideConfirmModalAction={hideConfirmModalAction}
addNotificationAction={addNotificationAction}
Expand Down Expand Up @@ -229,7 +225,6 @@ Migrations.propTypes = {
scheduleMigrationModal: PropTypes.bool,
scheduleMigrationPlan: PropTypes.object,
scheduleMigration: PropTypes.func,
plansMutatedWithMappingInfo: PropTypes.bool,
showPlanWizardEditModeAction: PropTypes.func,
fetchTransformationMappingsAction: PropTypes.func,
fetchTransformationMappingsUrl: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class MigrationsCompletedList extends React.Component {
scheduleMigrationModal,
scheduleMigrationPlan,
scheduleMigration,
plansMutatedWithMappingInfo,
fetchTransformationMappingsAction,
fetchTransformationMappingsUrl,
showEditPlanNameModalAction
Expand Down Expand Up @@ -240,22 +239,14 @@ class MigrationsCompletedList extends React.Component {
<strong>{Object.keys(tasks).length} </strong>
{__('VMs successfully migrated.')}
</ListView.InfoItem>,
plansMutatedWithMappingInfo &&
isMissingMapping && (
<ListView.InfoItem key={`${plan.id}-infraMappingWarning`}>
<Icon type="pf" name="warning-triangle-o" />{' '}
{__('Infrastucture mapping does not exist.')}
</ListView.InfoItem>
),
plansMutatedWithMappingInfo &&
!isMissingMapping && (
<ListView.InfoItem key={`${plan.id}-infraMappingName`}>
{plan.infraMappingName}
</ListView.InfoItem>
),
!plansMutatedWithMappingInfo && (
isMissingMapping && (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

<ListView.InfoItem key={`${plan.id}-infraMappingWarning`}>
<Icon type="pf" name="warning-triangle-o" /> {__('Infrastucture mapping does not exist.')}
</ListView.InfoItem>
),
!isMissingMapping && (
<ListView.InfoItem key={`${plan.id}-infraMappingName`}>
{__('Loading Infrastructure Mapping info...')}
{plan.infraMappingName}
</ListView.InfoItem>
),
<ListView.InfoItem key={`${plan.id}-elapsed`}>
Expand Down Expand Up @@ -394,7 +385,6 @@ MigrationsCompletedList.propTypes = {
scheduleMigrationModal: PropTypes.bool,
scheduleMigrationPlan: PropTypes.object,
scheduleMigration: PropTypes.func,
plansMutatedWithMappingInfo: PropTypes.bool,
fetchTransformationMappingsAction: PropTypes.func,
fetchTransformationMappingsUrl: PropTypes.string,
showEditPlanNameModalAction: PropTypes.func
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class MigrationsNotStartedList extends React.Component {
scheduleMigration,
fetchTransformationPlansAction,
fetchTransformationPlansUrl,
plansMutatedWithMappingInfo,
deleteTransformationPlanAction,
deleteTransformationPlanUrl,
showPlanWizardEditModeAction,
Expand Down Expand Up @@ -167,22 +166,14 @@ class MigrationsNotStartedList extends React.Component {
<Icon type="pf" name="virtual-machine" />
<strong>{plan.options.config_info.actions.length}</strong> {__('VMs')}
</ListView.InfoItem>,
plansMutatedWithMappingInfo &&
isMissingMapping && (
<ListView.InfoItem key={`${plan.id}-infraMappingWarning`}>
<Icon type="pf" name="warning-triangle-o" />{' '}
{__('Infrastucture mapping does not exist.')}
</ListView.InfoItem>
),
plansMutatedWithMappingInfo &&
!isMissingMapping && (
<ListView.InfoItem key={`${plan.id}-infraMappingName`}>
{plan.infraMappingName}
</ListView.InfoItem>
),
!plansMutatedWithMappingInfo && (
isMissingMapping && (
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

<ListView.InfoItem key={`${plan.id}-infraMappingWarning`}>
<Icon type="pf" name="warning-triangle-o" /> {__('Infrastucture mapping does not exist.')}
</ListView.InfoItem>
),
!isMissingMapping && (
<ListView.InfoItem key={`${plan.id}-infraMappingName`}>
{__('Loading Infrastructure Mapping info...')}
{plan.infraMappingName}
</ListView.InfoItem>
),
migrationScheduled && (
Expand Down Expand Up @@ -242,7 +233,6 @@ MigrationsNotStartedList.propTypes = {
scheduleMigration: PropTypes.func,
fetchTransformationPlansAction: PropTypes.func,
fetchTransformationPlansUrl: PropTypes.string,
plansMutatedWithMappingInfo: PropTypes.bool,
deleteTransformationPlanAction: PropTypes.func,
deleteTransformationPlanUrl: PropTypes.string,
showPlanWizardEditModeAction: PropTypes.func,
Expand Down
5 changes: 1 addition & 4 deletions app/javascript/react/screens/App/Overview/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import getMostRecentRequest from '../common/getMostRecentRequest';

export const planTransmutation = (plans = [], mappings = []) =>
plans.map(plan => {
const infraMappingName = mappings.find(
mapping => mapping.id === plan.options.config_info.transformation_mapping_id
);
const request = getMostRecentRequest(plan.miq_requests);
return {
...plan,
infraMappingName: infraMappingName ? infraMappingName.name : null,
infraMappingName: plan.transformation_mapping && plan.transformation_mapping.name,
status: request ? request.status : null,
configVmLength: plan.options.config_info.actions.length,
scheduleTime: plan.schedules ? new Date(plan.schedules[0].run_at.start_time).getTime() : null
Expand Down