Skip to content

Commit 62ce18c

Browse files
authored
fix: Migrated battery to severity. (#365)
fix: Updated to migrate Battery component to Severity component.
1 parent 02a9d81 commit 62ce18c

27 files changed

+546
-13561
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const MyComponentExample: React.FunctionComponent = () => (
112112
<MyComponent customLabel="My label">
113113
);
114114
115-
export default BatteryLowExample;
115+
export default MyComponentExample;
116116
```
117117

118118
### Sub-components:

cypress/component/Severity.cy.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react';
2+
import Severity, { SeverityType } from '../../packages/module/dist/dynamic/Severity';
3+
4+
const severities = [
5+
{ type: SeverityType.critical, label: 'Critical severity', ouiaId: 'Severity-critical' },
6+
{ type: SeverityType.important, label: 'Important severity', ouiaId: 'Severity-important' },
7+
{ type: SeverityType.moderate, label: 'Moderate severity', ouiaId: 'Severity-moderate' },
8+
{ type: SeverityType.minor, label: 'Minor severity', ouiaId: 'Severity-minor' },
9+
{ type: SeverityType.none, label: 'No severity', ouiaId: 'Severity-none' },
10+
{ type: SeverityType.undefined, label: 'Undefined severity', ouiaId: 'Severity-undefined' }
11+
];
12+
13+
describe('Severity', () => {
14+
severities.map(({ type, label, ouiaId }) => {
15+
it(`renders Severity with ${type} severity`, () => {
16+
cy.mount(<Severity severity={type} label={label} ouiaId={ouiaId} />);
17+
cy.get(`[data-ouia-component-id="${ouiaId}"]`).should('exist');
18+
cy.get(`[data-ouia-component-id="${ouiaId}"]`).should('have.attr', 'title', label);
19+
cy.get('span').contains(label);
20+
});
21+
});
22+
23+
it('hides label when labelHidden is true', () => {
24+
cy.mount(<Severity severity={SeverityType.important} label="Important severity" labelHidden />);
25+
cy.contains('Important severity').should('not.exist');
26+
});
27+
});

migration.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ The guide should be applicable when migrating from frontend-components **version
1010
1111
**SOLUTION:** use the `className` property if you need a custom color
1212
13-
14-
## Battery
15-
16-
- No action required
17-
18-
1913
## ErrorState
2014
2115
- The default error description *“If the problem persists, contact [Red Hat Support](https://access.redhat.com/support) or check our [status page](https://status.redhat.com) for known outages.”* has been removed.
@@ -55,7 +49,10 @@ The guide should be applicable when migrating from frontend-components **version
5549
5650
**SOLUTION:** handle `/beta` in your URL on your own and pass a final URL using the new `toLandingPageUrl` property
5751
58-
52+
​## Severity
53+
54+
- No action required
55+
5956
## SkeletonTable
6057
6158
- No action required

packages/module/patternfly-docs/content/extensions/component-groups/examples/Battery/Battery.md

Lines changed: 0 additions & 72 deletions
This file was deleted.

packages/module/patternfly-docs/content/extensions/component-groups/examples/Battery/BatteryCriticalExample.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/module/patternfly-docs/content/extensions/component-groups/examples/Battery/BatteryDefaultExample.tsx

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/module/patternfly-docs/content/extensions/component-groups/examples/Battery/BatteryHighExample.tsx

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/module/patternfly-docs/content/extensions/component-groups/examples/Battery/BatteryLowExample.tsx

Lines changed: 0 additions & 4 deletions
This file was deleted.

packages/module/patternfly-docs/content/extensions/component-groups/examples/Battery/BatteryMediumExample.tsx

Lines changed: 0 additions & 4 deletions
This file was deleted.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
# Sidenav top-level section
3+
# should be the same for all markdown files
4+
section: Component groups
5+
subsection: Status and state indicators
6+
# Sidenav secondary level section
7+
# should be the same for all markdown files
8+
id: Severity
9+
# Tab (react | react-demos | html | html-demos | design-guidelines | accessibility)
10+
source: react
11+
# If you use typescript, the name of the interface to display props for
12+
# These are found through the sourceProps function provided in patternfly-docs.source.js
13+
propComponents: ['Severity']
14+
sourceLink: https://github.com/patternfly/react-component-groups/blob/main/packages/module/patternfly-docs/content/extensions/component-groups/examples/Severity/Severity.md
15+
---
16+
17+
import Severity, { SeverityType } from '@patternfly/react-component-groups/dist/dynamic/Severity';
18+
19+
The **severity** component generates an icon with an optional label, which corresponds to a level `minor`, `moderate`, `important` or `critical`. Each level corresponds with a severity level and respective color:
20+
21+
| Severity level | Meaning | Style |
22+
| --- | --- | --- |
23+
| Level 1 | Minor severity (best case scenario) | Dark grey icon |
24+
| Level 2 | Moderate severity | Yellow icon |
25+
| Level 3 | Important severity | Orange icon |
26+
| Level 4 | Critical severity (worst case scenario) | Red icon |
27+
28+
To specify the severity risk level, you can pass a predefined enum or text value into the `severity` property that corresponds to the appropriate severity level.
29+
30+
To add an optional label, add the `label` property to the `<Severity>` component.
31+
32+
## Examples
33+
34+
### Undefined variant
35+
36+
The default style for the severity component appears when any value besides "none", "low", "medium", "high", or "critical" is passed to `Severity`.
37+
38+
```js file="./SeverityUndefinedExample.tsx"
39+
40+
```
41+
### None severity
42+
43+
To style no severity, pass "none" or `SeverityType.none` to `severity`.
44+
45+
```js file="./SeverityNoneExample.tsx"
46+
47+
```
48+
49+
### Minor severity
50+
51+
To style a minor severity, pass "minor" or `SeverityType.minor` to `severity`.
52+
53+
```js file="./SeverityMinorExample.tsx"
54+
55+
```
56+
57+
### Moderate severity
58+
59+
To style a moderate severity, pass "moderate", or `SeverityType.moderate` to `severity`.
60+
61+
```js file="./SeverityModerateExample.tsx"
62+
63+
```
64+
65+
### Important severity
66+
67+
To style an important severity, pass "important", or `SeverityType.important` to `severity`.
68+
69+
```js file="./SeverityImportantExample.tsx"
70+
71+
```
72+
73+
### Critical severity
74+
75+
To style a critical severity, pass "critical" or `SeverityType.critical` to `severity`.
76+
77+
```js file="./SeverityCriticalExample.tsx"
78+
79+
```

0 commit comments

Comments
 (0)