Skip to content

Commit

Permalink
Behave the same as 1.8.4 on a new migration plan
Browse files Browse the repository at this point in the history
The loading behavior was modified in 1.8.5 and
the grid loading was not behaving the same as
1.8.4 when creating a new direct volume migration
plan. The spinner was not covering the grid and
the grid was showing the empty state.

Instead revert to covering the entire grid. And
only show the validating spinner when the grid
selection changed.

Signed-off-by: Alexander Wels <[email protected]>
  • Loading branch information
awels committed Oct 17, 2024
1 parent f78ff94 commit 7c97ee6
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
41 changes: 40 additions & 1 deletion src/app/home/pages/PlansPage/components/Wizard/VolumesForm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { StatusIcon } from '@konveyor/lib-ui';
import { Grid, GridItem } from '@patternfly/react-core';
import {
Alert,
Bullseye,
EmptyState,
Grid,
GridItem,
Spinner,
Title,
} from '@patternfly/react-core';
import { useFormikContext } from 'formik';
import { isEmpty } from 'lodash';
import React, { useEffect } from 'react';
Expand Down Expand Up @@ -85,6 +93,11 @@ const VolumesForm: React.FunctionComponent<IOtherProps> = (props) => {
};
});
}
const selectedPVs = mappedPVs
.filter((pv) => pv.selection.action !== 'skip')
.map((pv) => pv.name);
setFieldValue('selectedPVs', selectedPVs);

//Set initial PVs from pv discovery
setFieldValue('persistentVolumes', mappedPVs);
}
Expand All @@ -101,6 +114,32 @@ const VolumesForm: React.FunctionComponent<IOtherProps> = (props) => {
</Grid>
);
}
if (
!planState.currentPlan?.spec.persistentVolumes ||
planState.currentPlan.spec.persistentVolumes?.length == 0
) {
return (
<Bullseye>
<EmptyState variant="large">
<div className="pf-c-empty-state__icon">
<Spinner size="xl" />
</div>
<Title headingLevel="h2" size="xl">
Discovering persistent volumes attached to source projects...
</Title>
</EmptyState>
</Bullseye>
);
}
if (planState.currentPlanStatus.state === 'Critical') {
return (
<Bullseye>
<EmptyState variant="large">
<Alert variant="danger" isInline title={planState.currentPlanStatus.errorMessage} />
</EmptyState>
</Bullseye>
);
}
return (
<VolumesTable
isEdit={props.isEdit}
Expand Down
16 changes: 9 additions & 7 deletions src/app/home/pages/PlansPage/components/Wizard/VolumesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -460,17 +460,19 @@ const VolumesTable: React.FunctionComponent<IVolumesTableProps> = ({
: 'Choose to move or copy persistent volumes associated with selected namespaces.'}
</Text>
</TextContent>
{planState.currentPlanStatus.state === 'Critical' && !planState.currentPlan.spec.refresh ? (
{planState.currentPlanStatus?.state === 'Critical' &&
!planState.currentPlan?.spec.refresh ? (
<Bullseye>
<EmptyState variant="large">
<Alert variant="danger" isInline title={planState.currentPlanStatus.errorMessage} />
</EmptyState>
</Bullseye>
) : null}
{planState.isFetchingPVResources ||
planState.isPollingStatus ||
planState.currentPlanStatus.state === 'Pending' ||
planState.currentPlan.spec.refresh ? (
{planState.currentPlan?.spec.persistentVolumes?.length > 0 &&
(planState.isFetchingPVResources ||
planState.isPollingStatus ||
planState.currentPlanStatus.state === 'Pending' ||
planState.currentPlan.spec.refresh) ? (
<Bullseye>
<EmptyState variant="large">
<Spinner size="md" />
Expand All @@ -481,7 +483,7 @@ const VolumesTable: React.FunctionComponent<IVolumesTableProps> = ({
</Bullseye>
) : null}
</GridItem>
{isSCC && values.persistentVolumes.length === 0 ? (
{isSCC && values.persistentVolumes.length === 0 && planState.currentPlan?.spec.refresh ? (
<GridItem>
<Alert
variant="danger"
Expand All @@ -498,7 +500,7 @@ const VolumesTable: React.FunctionComponent<IVolumesTableProps> = ({
</Alert>
</GridItem>
) : null}
{isSCC && storageClasses.length < 2 ? (
{isSCC && storageClasses.length < 2 && planState.currentPlan?.spec.refresh ? (
<GridItem>
<Alert
variant="danger"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ const WizardComponent = (props: IOtherProps) => {

const onMove: WizardStepFunctionType = ({ id, name }, { prevId, prevName }) => {
dispatch(PlanActions.pvUpdatePollStop());
if (stepIdReached < id) {
if (stepIdReached < (id as number)) {
setStepIdReached(id as number);
}

Expand Down Expand Up @@ -348,7 +348,7 @@ const WizardComponent = (props: IOtherProps) => {
!isFetchingPVList &&
currentPlanStatus.state !== 'Pending' &&
currentPlanStatus.state !== 'Critical' &&
!planState.currentPlan.spec.refresh &&
!planState.currentPlan?.spec.refresh &&
(values.migrationType.value !== 'scc' ||
(values.selectedPVs.length > 0 && storageClasses.length > 1))
);
Expand Down

0 comments on commit 7c97ee6

Please sign in to comment.