generated from RedHatInsights/frontend-starter-app
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(OCPADVISOR-71): Show upgrade risks table #547
Merged
gkarat
merged 11 commits into
RedHatInsights:master
from
gkarat:ocpadvisor-71-upgrade-risks-tab
Apr 18, 2023
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
457d59e
Build initial table
gkarat 6b6407a
Register upgrade-risks-prediction endpoint
gkarat fe675ce
Connect table to response data
gkarat 6fd0049
Add required intl messages
gkarat 49985ab
Add empty states
gkarat e60e24a
Use empty states to treat edge cases
gkarat ff52e31
Treat 503 error code separately
gkarat e369f82
Write cypress tests for UpgradeRisksTable
gkarat 04c790b
Use v2 for upgrade-risks-prediction
gkarat 93102c9
Fix test
gkarat 1ac57f8
Fix table borders
gkarat 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
35 changes: 35 additions & 0 deletions
35
...aggregator/v1/clusters/41c30565-b4c9-49f2-a4ce-3277ad22b258/upgrade-risks-prediction.json
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"status": "ok", | ||
"upgrade_recommendation": { | ||
"upgrade_risks_predictors": { | ||
"alerts": [ | ||
{ | ||
"name": "ClusterOperatorDown", | ||
"namespace": "openshift-monitoring", | ||
"severity": "critical" | ||
}, | ||
{ | ||
"name": "PostDisruptionBudgetLimit", | ||
"namespace": "openshift-etcd", | ||
"severity": "warning" | ||
}, | ||
{ | ||
"name": "Cluster operators", | ||
"namespace": "openshift-kube-apiserver", | ||
"severity": "info" | ||
} | ||
], | ||
"operator_conditions": [ | ||
{ | ||
"name": "Version", | ||
"condition": "failing" | ||
}, | ||
{ | ||
"name": "Node-tuning", | ||
"condition": "degraded", | ||
"reason": "Multiple tasks failed" | ||
} | ||
] | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { Flex, Icon } from '@patternfly/react-core'; | ||
import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon'; | ||
import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon'; | ||
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; | ||
import { | ||
TableComposable, | ||
Tbody, | ||
Td, | ||
Th, | ||
Thead, | ||
Tr, | ||
} from '@patternfly/react-table'; | ||
import React from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { useGetUpgradeRisksQuery } from '../../Services/SmartProxy'; | ||
|
||
export const ALERTS_SEVERITY_ICONS = { | ||
critical: ( | ||
<Icon status="danger"> | ||
<ExclamationCircleIcon /> | ||
</Icon> | ||
), | ||
warning: ( | ||
<Icon status="warning"> | ||
<ExclamationTriangleIcon /> | ||
</Icon> | ||
), | ||
info: ( | ||
<Icon status="info"> | ||
<InfoCircleIcon /> | ||
</Icon> | ||
), | ||
}; | ||
|
||
export const ALERTS_SEVERITY_LABEL = { | ||
critical: ( | ||
<Flex alignItems={{ default: 'alignItemsCenter' }}> | ||
{ALERTS_SEVERITY_ICONS['critical']} <b>Critical</b> | ||
</Flex> | ||
), | ||
warning: ( | ||
<Flex alignItems={{ default: 'alignItemsCenter' }}> | ||
{ALERTS_SEVERITY_ICONS['warning']} <b>Warning</b> | ||
</Flex> | ||
), | ||
info: ( | ||
<Flex alignItems={{ default: 'alignItemsCenter' }}> | ||
{ALERTS_SEVERITY_ICONS['info']} <b>Info</b> | ||
</Flex> | ||
), | ||
}; | ||
|
||
export const ALERTS_SEVERITY_ORDER = ['critical', 'warning', 'info']; | ||
|
||
const AlertsList = () => { | ||
const { clusterId } = useParams(); | ||
const { data } = useGetUpgradeRisksQuery({ id: clusterId }); | ||
const { alerts = [] } = | ||
data?.upgrade_recommendation?.upgrade_risks_predictors || {}; | ||
|
||
return ( | ||
<TableComposable | ||
aria-label="Alerts firing table" | ||
variant="compact" | ||
borders={false} | ||
> | ||
<Thead> | ||
<Tr> | ||
<Th width={50}>Name</Th> | ||
<Th width={25}>Status</Th> | ||
<Th width={25}>Namespace</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
{alerts.map(({ name, namespace, severity }) => ( | ||
<Tr key={name}> | ||
<Td className="alerts__name">{name}</Td> | ||
<Td className="alerts__severity"> | ||
{ALERTS_SEVERITY_LABEL[severity]} | ||
</Td> | ||
<Td className="alerts__namespace">{namespace}</Td> | ||
</Tr> | ||
))} | ||
</Tbody> | ||
</TableComposable> | ||
); | ||
}; | ||
|
||
export default AlertsList; |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import { | ||
TableComposable, | ||
Tbody, | ||
Td, | ||
Th, | ||
Thead, | ||
Tr, | ||
} from '@patternfly/react-table'; | ||
import { useParams } from 'react-router-dom'; | ||
import { useGetUpgradeRisksQuery } from '../../Services/SmartProxy'; | ||
import { Flex, Icon } from '@patternfly/react-core'; | ||
import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon'; | ||
|
||
export const CLUSTER_OPERATOR_LABEL = { | ||
degraded: 'Degraded', | ||
failing: 'Failing', | ||
available: 'Not Available', | ||
upgradeable: 'Not Upgradeable', | ||
}; | ||
|
||
const ClusterOperatorsList = () => { | ||
const { clusterId } = useParams(); | ||
const { data } = useGetUpgradeRisksQuery({ id: clusterId }); | ||
const { operator_conditions: conditions = [] } = | ||
data?.upgrade_recommendation?.upgrade_risks_predictors || {}; | ||
|
||
return ( | ||
<TableComposable | ||
aria-label="Cluster operators firing table" | ||
variant="compact" | ||
borders={false} | ||
> | ||
<Thead> | ||
<Tr> | ||
<Th width={50}>Name</Th> | ||
<Th width={25}>Status</Th> | ||
<Th width={25}>Message</Th> | ||
</Tr> | ||
</Thead> | ||
<Tbody> | ||
{conditions.map(({ name, condition, reason }) => ( | ||
<Tr key={name}> | ||
<Td class="operators__name">{name}</Td> | ||
<Td class="operators__status"> | ||
<Flex alignItems={{ default: 'alignItemsCenter' }}> | ||
<Icon status="warning"> | ||
<ExclamationTriangleIcon /> | ||
</Icon> | ||
<b>{CLUSTER_OPERATOR_LABEL[condition]}</b> | ||
</Flex> | ||
</Td> | ||
<Td class="operators__message">{reason || '-'}</Td> | ||
</Tr> | ||
))} | ||
</Tbody> | ||
</TableComposable> | ||
); | ||
}; | ||
|
||
export default ClusterOperatorsList; |
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.
When comparing to the mocks I see a few links/icons that arent shown here.

Your version:
mock version:

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.
good catch. there is no final agreement on the docs URL, so I'd wait for folks first to decide and then will add it via separate PR most probably