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
[#786] Handle denied state of a plan request (no conversion hosts configured) #798
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e79794a
Handle denied state of a plan request in the in-progress view (with t…
mturley 293ad42
Handle denied state in the Plans Completed view
mturley 327cb25
Handle denied state in the aggregate status card
mturley 3d143c0
Handle denied state in the Plan request details page (and lint fixes)
mturley db8647b
Add error message about conversion hosts to denied Plan request detai…
mturley 8fb05e6
Open docs link in a new tab
mturley 4c04f74
Change wording of error to be more accurate with respect to timing
mturley 70bd78b
Filter denied requests into views properly, implement acknowledge den…
mturley 6511982
Move to Completed Plans view after acknowledging denial
mturley 0100026
Don't block button during polling
mturley 7b6d4ea
Update snapshot
mturley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,37 @@ | ||
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'; | ||
import getMostRecentRequest from '../../../common/getMostRecentRequest'; | ||
import getMostRecentVMTasksFromRequests from './helpers/getMostRecentVMTasksFromRequests'; | ||
import getPlaybookName from './helpers/getPlaybookName'; | ||
import { PLAN_JOB_STATES } from '../../../../../../data/models/plans'; | ||
import { DOCS_URL_CONFIGURE_CONVERSION_HOSTS } from '../../../Plan/PlanConstants'; | ||
import { MIGRATIONS_FILTERS } from '../../OverviewConstants'; | ||
|
||
const MigrationsInProgressCard = ({ | ||
plan, | ||
serviceTemplatePlaybooks, | ||
allRequestsWithTasks, | ||
reloadCard, | ||
handleClick | ||
handleClick, | ||
fetchTransformationPlansUrl, | ||
acknowledgeDeniedPlanRequestAction, | ||
isEditingPlanRequest, | ||
setMigrationsFilterAction | ||
}) => { | ||
const requestsOfAssociatedPlan = allRequestsWithTasks.filter(request => request.source_id === plan.id); | ||
const mostRecentRequest = requestsOfAssociatedPlan.length > 0 && getMostRecentRequest(requestsOfAssociatedPlan); | ||
|
@@ -36,6 +52,41 @@ const MigrationsInProgressCard = ({ | |
); | ||
} | ||
|
||
if (mostRecentRequest.approval_state === 'denied') { | ||
const cardEmptyState = ( | ||
<EmptyState> | ||
<EmptyState.Icon type="pf" name="error-circle-o" /> | ||
<EmptyState.Info style={{ marginTop: 10 }}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar blocks of code found in 2 locations. Consider refactoring. |
||
{__('Unable to migrate VMs because no conversion host was configured at the time of the attempted migration.') /* prettier-ignore */}{' '} | ||
<a href={DOCS_URL_CONFIGURE_CONVERSION_HOSTS} target="_blank" rel="noopener noreferrer"> | ||
{__('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={() => | ||
acknowledgeDeniedPlanRequestAction({ | ||
plansUrl: fetchTransformationPlansUrl, | ||
planRequest: mostRecentRequest | ||
}).then(() => setMigrationsFilterAction(MIGRATIONS_FILTERS.completed)) | ||
} | ||
disabled={isEditingPlanRequest} | ||
> | ||
{__('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; | ||
|
@@ -243,7 +294,11 @@ MigrationsInProgressCard.propTypes = { | |
serviceTemplatePlaybooks: PropTypes.array, | ||
allRequestsWithTasks: PropTypes.array, | ||
reloadCard: PropTypes.bool, | ||
handleClick: PropTypes.func | ||
handleClick: PropTypes.func, | ||
fetchTransformationPlansUrl: PropTypes.string, | ||
acknowledgeDeniedPlanRequestAction: PropTypes.func, | ||
isEditingPlanRequest: PropTypes.bool, | ||
setMigrationsFilterAction: PropTypes.func | ||
}; | ||
|
||
export default MigrationsInProgressCard; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Methinks we can remove the
approval_state === 'denied'
check here