Skip to content

Commit 7b7efd1

Browse files
authored
condition label doc (#70)
1 parent ec98e81 commit 7b7efd1

File tree

4 files changed

+92
-6
lines changed

4 files changed

+92
-6
lines changed

src/components/status/ConditionLabel/ConditionLabel.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Examples
1+
Simple example
22

33
```js
44
<ConditionLabel
@@ -8,3 +8,45 @@ Examples
88
type={'Ready'}
99
/>
1010
```
11+
12+
13+
Showcase
14+
15+
```js
16+
import { TableComposable, Caption, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
17+
18+
<TableComposable>
19+
<Caption>Virtual Machines list</Caption>
20+
<Thead>
21+
<Tr>
22+
<Th>Name</Th>
23+
<Th>Conditions</Th>
24+
</Tr>
25+
</Thead>
26+
<Tbody>
27+
<Tr>
28+
<Td>Virtual Machine 1</Td>
29+
<Td>
30+
<ConditionLabel
31+
message={'success'}
32+
reason={'ready'}
33+
status={'true'}
34+
type={'Ready'}
35+
/>
36+
</Td>
37+
</Tr>
38+
39+
<Tr>
40+
<Td>Virtual Machine 2</Td>
41+
<Td>
42+
<ConditionLabel
43+
message={'no vmi found'}
44+
reason={'no_vmi'}
45+
status={'true'}
46+
type={'Failure'}
47+
/>
48+
</Td>
49+
</Tr>
50+
</Tbody>
51+
</TableComposable>
52+
```

src/components/status/ConditionLabel/ConditionLabel.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,29 @@ import * as React from 'react';
33
import { Label, Popover, PopoverPosition } from '@patternfly/react-core';
44

55
export interface k8sStatusConditions {
6+
/**
7+
* Type indicate which type of condition is.
8+
*/
69
type: string;
10+
/**
11+
* Status is the high level overview of how the resource is doing. It contains information available to controllers and users.
12+
*/
713
status?: string;
14+
/**
15+
* A machine-readable description of the cause of the error. If this value is empty there is no information available.
16+
*/
817
reason?: string;
18+
/**
19+
* A human-readable description of the cause of the error. This field may be presented as-is to a reader.
20+
*/
921
message?: string;
1022
}
1123

1224
/**
13-
* ConditionLabel renders a k8sStatusConditions
25+
* ConditionLabel renders a k8sStatusConditions.
26+
* Usefull to give information of what the resouce is doing without taking up much space into the interface.
27+
*
28+
* On mouse click it creates a popover to explain the state in a more disursive way.
1429
*/
1530
export const ConditionLabel: React.FC<k8sStatusConditions> = React.memo((condition) => {
1631
const preventLabelLink = React.useCallback((e) => e.preventDefault(), []);

src/components/status/ConditionLabelList/ConditionLabelList.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,25 @@ Examples
1717
]}
1818
/>
1919
```
20+
21+
Showcase
22+
```js
23+
<div>
24+
<span>Virtual Machine 1 </span>
25+
<ConditionLabelList conditions={[
26+
{
27+
message: 'no vmi found',
28+
reason: 'no_vmi',
29+
status: 'true',
30+
type: 'Failure',
31+
},
32+
{
33+
message: 'success',
34+
reason: 'ready',
35+
status: 'true',
36+
type: 'Ready',
37+
},
38+
]}
39+
/>
40+
</div>
41+
```

src/components/status/ConditionLabelList/ConditionLabelList.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,22 @@ import * as React from 'react';
22

33
import { LabelGroup } from '@patternfly/react-core';
44

5-
import { ConditionLabel, k8sStatusConditions } from '../ConditionLabel';
5+
import { ConditionLabel } from '../ConditionLabel';
6+
import { k8sStatusConditions } from '../ConditionLabel/ConditionLabel';
67

7-
/**
8-
* VirtualMachineCondition renders a list of a k8s resource conditions
9-
* */
108
export interface ConditionLabelListProps {
9+
/**
10+
* Array of k8s status conditions.
11+
* k8s status conditions are similar to [KubeVirt Condition](https://kubevirt.io/api-reference/master/definitions.html#_v1_kubevirtcondition) but can represent also different kind of conditions
12+
*/
1113
conditions: k8sStatusConditions[];
1214
}
1315

16+
/**
17+
* ConditionLabelList renders a list of a k8s resource conditions.
18+
*
19+
* This component can me usefull to give an in dept clues of what the resourse is doing.
20+
* */
1421
export const ConditionLabelList: React.FC<ConditionLabelListProps> = React.memo(
1522
({ conditions }) => {
1623
return (

0 commit comments

Comments
 (0)