|
1 | 1 | import * as React from 'react';
|
2 | 2 |
|
3 |
| -import { V1VirtualMachineCondition } from '@kubevirt-ui/kubevirt-api/kubevirt'; |
4 | 3 | import { Label, Popover, PopoverPosition } from '@patternfly/react-core';
|
5 | 4 |
|
6 |
| -export const VMStatusConditionLabel: React.FC<V1VirtualMachineCondition> = React.memo( |
7 |
| - (condition) => { |
8 |
| - const preventLabelLink = React.useCallback((e) => e.preventDefault(), []); |
| 5 | +interface k8sStatusConditions { |
| 6 | + type: string; |
| 7 | + status?: string; |
| 8 | + reason?: string; |
| 9 | + message?: string; |
| 10 | +} |
9 | 11 |
|
10 |
| - const getBodyContent = React.useCallback( |
11 |
| - () => <div>{condition?.message}</div>, |
12 |
| - [condition?.message], |
13 |
| - ); |
| 12 | +/** |
| 13 | + * ConditionLabel renders a k8sStatusConditions |
| 14 | + */ |
| 15 | +export const ConditionLabel: React.FC<k8sStatusConditions> = React.memo((condition) => { |
| 16 | + const preventLabelLink = React.useCallback((e) => e.preventDefault(), []); |
14 | 17 |
|
15 |
| - return ( |
16 |
| - <Popover |
17 |
| - position={PopoverPosition.top} |
18 |
| - aria-label="Condition Popover" |
19 |
| - bodyContent={getBodyContent} |
20 |
| - > |
21 |
| - <Label color="grey" isTruncated href="#" onClick={preventLabelLink}> |
22 |
| - {condition?.reason}={condition?.status} |
23 |
| - </Label> |
24 |
| - </Popover> |
25 |
| - ); |
26 |
| - }, |
27 |
| -); |
28 |
| -VMStatusConditionLabel.displayName = 'VMStatusConditionLabel'; |
| 18 | + const getBodyContent = React.useCallback( |
| 19 | + () => <div>{condition?.message}</div>, |
| 20 | + [condition?.message], |
| 21 | + ); |
| 22 | + |
| 23 | + return ( |
| 24 | + <Popover |
| 25 | + position={PopoverPosition.top} |
| 26 | + aria-label="Condition Popover" |
| 27 | + bodyContent={getBodyContent} |
| 28 | + > |
| 29 | + <Label color="grey" isTruncated href="#" onClick={preventLabelLink}> |
| 30 | + {condition?.reason}={condition?.status} |
| 31 | + </Label> |
| 32 | + </Popover> |
| 33 | + ); |
| 34 | +}); |
| 35 | +ConditionLabel.displayName = 'ConditionLabel'; |
0 commit comments