Skip to content

Commit 9d6bf62

Browse files
committed
fix(StaleDataWarning): rename CullingInfo to StaleDataWarning; fix wording
1 parent fdf0487 commit 9d6bf62

File tree

8 files changed

+62
-62
lines changed

8 files changed

+62
-62
lines changed

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

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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: Stale Data Warning
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: ['StaleDataWarning']
14+
sourceLink: https://github.com/patternfly/react-component-groups/blob/main/packages/module/patternfly-docs/content/extensions/component-groups/examples/StaleDataWarning/StaleDataWarning.md
15+
---
16+
17+
import StaleDataWarning from '@patternfly/react-component-groups/dist/dynamic/StaleDataWarning';
18+
19+
A **Stale Data Warning** component displays a warning status when an object is stale and planned for removal. Additional warning details can be displayed as a tooltip or text label.
20+
21+
## Examples
22+
23+
### Basic stale data warning example
24+
25+
A basic stale data warning component displays a warning icon with additional details in a tooltip, including a timeline for data removal.
26+
27+
```js file="./StaleDataWarningExample.tsx"
28+
29+
```
30+
31+
### Stale data warning with customized props
32+
33+
Instead of sharing details in a tooltip, you can place a short message beside the icon. You can still utilize all properties of the [Tooltip component](/components/tooltip), with the exception of `content`.
34+
35+
```js file="./StaleDataWarningCustomExample.tsx"
36+
37+
```
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import CullingInformation from '@patternfly/react-component-groups/dist/dynamic/CullingInfo';
2+
import StaleDataWarning from '@patternfly/react-component-groups/dist/dynamic/StaleDataWarning';
33
import { Stack, StackItem } from '@patternfly/react-core';
44

55

@@ -10,23 +10,23 @@ export const CustomizedRenderExample: React.FunctionComponent = () => {
1010
return <>
1111
<Stack>
1212
<StackItem>
13-
<CullingInformation
13+
<StaleDataWarning
1414
stale={staleDate}
1515
currDate={new Date()}
1616
culled={cullingDate}
1717
staleWarning={warningDate}
1818
render={({ msg }) => (<React.Fragment>{msg}</React.Fragment>)}>
19-
</CullingInformation>
19+
</StaleDataWarning>
2020
</StackItem>
2121

2222
<StackItem>
23-
<CullingInformation
23+
<StaleDataWarning
2424
stale={staleDate}
2525
currDate={new Date()}
2626
culled={new Date('Fri Feb 07 2024')}
2727
staleWarning={new Date('Mon Feb 03 2024')}
28-
render={() => (<React.Fragment>This is an error message. Item is past due</React.Fragment>)}>
29-
</CullingInformation>
28+
render={() => (<React.Fragment>This is an error message where the item is overdue</React.Fragment>)}>
29+
</StaleDataWarning>
3030
</StackItem>
3131
</Stack>
3232

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import CullingInformation from '@patternfly/react-component-groups/dist/dynamic/CullingInfo';
2+
import StaleDataWarning from '@patternfly/react-component-groups/dist/dynamic/StaleDataWarning';
33
import { Stack, StackItem } from '@patternfly/react-core';
44

55
export const BasicExample: React.FunctionComponent = () => {
@@ -9,22 +9,22 @@ export const BasicExample: React.FunctionComponent = () => {
99
return <>
1010
<Stack>
1111
<StackItem>
12-
<CullingInformation
12+
<StaleDataWarning
1313
stale={staleDate}
1414
currDate={new Date()}
1515
culled={cullingDate}
1616
staleWarning={warningDate}>
17-
</CullingInformation>
17+
</StaleDataWarning>
1818
</StackItem>
1919

2020
<StackItem>
21-
<CullingInformation
21+
<StaleDataWarning
2222
stale={staleDate}
2323
currDate={new Date()}
2424
culled={new Date('Fri Feb 17 2024')}
2525
staleWarning={new Date('Mon Feb 5 2024')}
2626
>
27-
</CullingInformation>
27+
</StaleDataWarning>
2828
</StackItem>
2929
</Stack>
3030

packages/module/src/CullingInfo/index.ts

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

packages/module/src/CullingInfo/CullingInfo.tsx renamed to packages/module/src/StaleDataWarning/StaleDataWarning.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { createUseStyles } from 'react-jss';
77
type Render = (config: { msg: string }) => React.ReactElement<any, any> | null;
88
type CullingDate = string | number | Date;
99

10-
interface CullingInfo {
10+
interface StaleDataInfo {
1111
isWarn?: boolean;
1212
isError?: boolean;
1313
msg: string;
@@ -18,7 +18,7 @@ const minutes: number = seconds * 60;
1818
const hours: number = minutes * 60;
1919
const days: number = hours * 24;
2020

21-
type CalculateTooltip = (culled: CullingDate, warning: CullingDate, currDate: CullingDate) => CullingInfo;
21+
type CalculateTooltip = (culled: CullingDate, warning: CullingDate, currDate: CullingDate) => StaleDataInfo;
2222

2323
const useStyles = createUseStyles({
2424
inventoryCullingWarning: {
@@ -36,7 +36,7 @@ const useStyles = createUseStyles({
3636
});
3737

3838
/** extends TooltipProps */
39-
export interface CullingInformation extends Omit<TooltipProps, 'content'> {
39+
export interface StaleDataWarningProps extends Omit<TooltipProps, 'content'> {
4040
/** Option to add custom css classes */
4141
className?: string;
4242
/** Warning date for when object becomes stale */
@@ -57,7 +57,7 @@ export interface CullingInformation extends Omit<TooltipProps, 'content'> {
5757
"aria-label"?: string;
5858
}
5959

60-
const CullingInformation: React.FunctionComponent<CullingInformation> = ({
60+
const StaleDataWarning: React.FunctionComponent<StaleDataWarningProps> = ({
6161
culled = new Date(0),
6262
className,
6363
staleWarning = new Date(0),
@@ -98,7 +98,7 @@ const CullingInformation: React.FunctionComponent<CullingInformation> = ({
9898
: children || null;
9999
}
100100

101-
const { isWarn, isError, msg }: CullingInfo = calculateTooltip(culled, staleWarning, currDate);
101+
const { isWarn, isError, msg }: StaleDataInfo = calculateTooltip(culled, staleWarning, currDate);
102102
if (render) {
103103
return (
104104
<span
@@ -119,12 +119,12 @@ const CullingInformation: React.FunctionComponent<CullingInformation> = ({
119119

120120
return (
121121
<>
122-
{isError && <Tooltip {...props} content={<div>{msg}</div>}><Button variant="plain" icon={<Icon status="warning"><ExclamationTriangleIcon/></Icon>} aria-label={ariaLabel || "Warning"} /></Tooltip>}
123-
{isWarn && <Tooltip {...props} content={<div>{msg}</div>}><Button variant="plain" icon={<Icon status="danger"><ExclamationCircleIcon/></Icon>} aria-label={ariaLabel || "Danger"} /></Tooltip>}
124-
{children}
122+
{isError && <Tooltip {...props} content={<div>{msg}</div>}><Button variant="plain" icon={<Icon status="warning"><ExclamationTriangleIcon/></Icon>} aria-label={ariaLabel || "Warning"} /></Tooltip>}
123+
{isWarn && <Tooltip {...props} content={<div>{msg}</div>}><Button variant="plain" icon={<Icon status="danger"><ExclamationCircleIcon/></Icon>} aria-label={ariaLabel || "Danger"} /></Tooltip>}
124+
{children}
125125
</>
126126
);
127127
};
128128

129-
export default CullingInformation;
129+
export default StaleDataWarning;
130130

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default } from './StaleDataWarning';
2+
export * from './StaleDataWarning';

packages/module/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export * from './UnauthorizedAccess';
1212
export { default as TagCount } from './TagCount';
1313
export * from './TagCount';
1414

15+
export { default as StaleDataWarning } from './StaleDataWarning';
16+
export * from './StaleDataWarning';
17+
1518
export { default as SkeletonTableHead } from './SkeletonTableHead';
1619
export * from './SkeletonTableHead';
1720

@@ -66,9 +69,6 @@ export * from './ErrorStack';
6669
export { default as ErrorBoundary } from './ErrorBoundary';
6770
export * from './ErrorBoundary';
6871

69-
export { default as CullingInfo } from './CullingInfo';
70-
export * from './CullingInfo';
71-
7272
export { default as ColumnManagementModal } from './ColumnManagementModal';
7373
export * from './ColumnManagementModal';
7474

0 commit comments

Comments
 (0)