Skip to content

Commit

Permalink
Merge pull request #55 from jtomasek/writing-image-step-fix
Browse files Browse the repository at this point in the history
Fix Writing image progress step
  • Loading branch information
Jiri Tomasek authored Jun 30, 2020
2 parents 4e59910 + fb4b7a5 commit e9c684a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/components/clusterDetail/ClusterProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Cluster, Host } from '../../api/types';
import { Progress, ProgressVariant, ProgressMeasureLocation } from '@patternfly/react-core';
import { CLUSTER_STATUS_LABELS } from '../../config/constants';
import { getHostInstallationSteps } from '../hosts/HostStatus';
import { getHostInstallationStepNumber } from '../hosts/HostProgress';

const getProgressVariant = (status: Cluster['status']) => {
switch (status) {
Expand Down Expand Up @@ -37,7 +38,7 @@ const getProgressPercent = (hosts: Host[] = []) => {
if (['installed', 'error'].includes(host.status)) {
return steps + hostInstallationSteps.length;
} else {
return steps + (hostInstallationSteps.indexOf(host.statusInfo) + 1);
return steps + getHostInstallationStepNumber(hostInstallationSteps, host.statusInfo);
}
}, 0);
return (completedSteps / totalSteps) * 100;
Expand Down
5 changes: 4 additions & 1 deletion src/components/hosts/HostProgress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import {
ProgressSize,
} from '@patternfly/react-core';

export const getHostInstallationStepNumber = (steps: string[], currentStep: string) =>
steps.findIndex((s) => currentStep.match(s)) + 1;

const getProgressVariant = (status: Host['status']) => {
switch (status) {
case 'error':
Expand All @@ -32,7 +35,7 @@ type HostProgressProps = {

const HostProgress: React.FC<HostProgressProps> = ({ status, progressInfo }) => {
const { steps, currentStep } = progressInfo;
const currentStepNumber = steps.indexOf(currentStep) + 1;
const currentStepNumber = getHostInstallationStepNumber(steps, currentStep);

return (
<Progress
Expand Down
7 changes: 5 additions & 2 deletions src/components/hosts/HostStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
UnknownIcon,
} from '@patternfly/react-icons';
import { Host } from '../../api/types';
import HostProgress from './HostProgress';
import HostProgress, { getHostInstallationStepNumber } from './HostProgress';
import { HOST_STATUS_LABELS, HOST_STATUS_DETAILS } from '../../config/constants';

import './HostStatus.css';
Expand Down Expand Up @@ -80,7 +80,10 @@ const HostStatus: React.FC<HostStatusProps> = ({ host }) => {
currentStep: statusInfo || 'Starting Installation',
};

const currentStepNumber = progressInfo.steps.indexOf(progressInfo.currentStep) + 1;
const currentStepNumber = getHostInstallationStepNumber(
progressInfo.steps,
progressInfo.currentStep,
);
const bodyContent = React.useMemo(
() => (
<div>
Expand Down

0 comments on commit e9c684a

Please sign in to comment.