Skip to content

Commit

Permalink
[WIP][ManageIQ#786] Handle denied state of a plan request
Browse files Browse the repository at this point in the history
  • Loading branch information
mturley committed Nov 19, 2018
1 parent f85e64d commit cb06944
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Card, Grid, noop } from 'patternfly-react';

const InProgressCard = ({ title, children, onClick, ...props }) => (
const InProgressCard = ({ title, children, footer, onClick, ...props }) => (
<Grid.Col sm={12} md={6} lg={4}>
<Card
id={`${Array.isArray(title.props.children) ? title.props.children[1] : title.props.children}-progress-card`}
Expand All @@ -12,19 +12,22 @@ const InProgressCard = ({ title, children, onClick, ...props }) => (
>
<Card.Heading>{title}</Card.Heading>
<Card.Body>{children}</Card.Body>
{footer}
</Card>
</Grid.Col>
);

InProgressCard.propTypes = {
title: PropTypes.node,
children: PropTypes.node,
footer: PropTypes.node,
onClick: PropTypes.func
};

InProgressCard.defaultProps = {
title: '',
children: null,
footer: null,
onClick: noop
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import React from 'react';
import PropTypes from 'prop-types';
import numeral from 'numeral';
import { EmptyState, Icon, OverlayTrigger, Popover, Tooltip, UtilizationBar, Spinner } from 'patternfly-react';
import {
EmptyState,
Icon,
OverlayTrigger,
Popover,
Tooltip,
UtilizationBar,
Spinner,
Card,
Button
} from 'patternfly-react';
import InProgressCard from './InProgressCard';
import InProgressWithDetailCard from './InProgressWithDetailCard';
import TickingIsoElapsedTime from '../../../../../../components/dates/TickingIsoElapsedTime';
Expand Down Expand Up @@ -36,6 +46,36 @@ const MigrationsInProgressCard = ({
);
}

// TODO: remove plan.name condition here
if (mostRecentRequest.approval_state === 'denied' || plan.name === 'test-denied-state') {
const cardEmptyState = (
<EmptyState>
<EmptyState.Icon type="pf" name="error-circle-o" />
<EmptyState.Info style={{ marginTop: 10 }}>
{__('Unable to start migration because no conversion host is configured.')}{' '}
<a href="https://access.redhat.com/documentation/en-us/red_hat_infrastructure_migration_solution/1.0/html/infrastructure_migration_solution_guide/installation#rhv_conversion_hosts">
{__('See the product documentation for information on configuring conversion hosts.')}
</a>
</EmptyState.Info>
</EmptyState>
);
const cardFooter = (
<Card.Footer style={{ position: 'relative', top: '-2px' }}>
<Button
style={{ position: 'relative', top: '-5px' }}
onClick={() => alert('TODO: handle cancel')}
>
{__('Cancel Migration')}
</Button>
</Card.Footer>
);
return (
<InProgressCard title={<h3 className="card-pf-title">{plan.name}</h3>} footer={cardFooter}>
{cardEmptyState}
</InProgressCard>
);
}

// UX business rule: reflect failed immediately if any single task has failed
// in the most recent request
let failed = false;
Expand Down

0 comments on commit cb06944

Please sign in to comment.