Skip to content

Commit ebd2e79

Browse files
refactor(EmptyState): migrate to ts
1 parent 490b17b commit ebd2e79

File tree

5 files changed

+22
-25
lines changed

5 files changed

+22
-25
lines changed

src/components/EmptyState/EmptyState.js src/components/EmptyState/EmptyState.tsx

+11-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import PropTypes from 'prop-types';
1+
import {ReactNode} from 'react';
22
import cn from 'bem-cn-lite';
3+
34
import Icon from '../Icon/Icon';
45

56
import './EmptyState.scss';
@@ -12,7 +13,15 @@ const sizes = {
1213
l: 350,
1314
};
1415

15-
export default function EmptyState({image, title, description, actions, size}) {
16+
interface EmptyStateProps {
17+
title: string;
18+
image?: ReactNode;
19+
description?: ReactNode;
20+
actions?: ReactNode[];
21+
size?: keyof typeof sizes;
22+
}
23+
24+
export const EmptyState = ({image, title, description, actions, size = 'm'}: EmptyStateProps) => {
1625
return (
1726
<div className={block({size})}>
1827
<div className={block('wrapper', {size})}>
@@ -35,16 +44,4 @@ export default function EmptyState({image, title, description, actions, size}) {
3544
</div>
3645
</div>
3746
);
38-
}
39-
40-
EmptyState.propTypes = {
41-
title: PropTypes.string.isRequired,
42-
image: PropTypes.node,
43-
description: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
44-
actions: PropTypes.arrayOf(PropTypes.node),
45-
size: PropTypes.string,
46-
};
47-
48-
EmptyState.defaultProps = {
49-
size: 'm',
5047
};

src/components/EmptyState/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './EmptyState';

src/components/Errors/403/AccessDenied.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import EmptyState from '../../EmptyState/EmptyState';
1+
import {EmptyState} from '../../EmptyState';
22
import {Illustration} from '../../Illustration';
33

44
import i18n from '../i18n';

src/containers/Storage/EmptyFilter/EmptyFilter.tsx

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import {Button} from '@gravity-ui/uikit';
22

3-
import EmptyState from '../../../components/EmptyState/EmptyState';
3+
import {EmptyState} from '../../../components/EmptyState';
44
import {Illustration} from '../../../components/Illustration';
55

66
import i18n from './i18n';
@@ -22,13 +22,12 @@ export const EmptyFilter = ({
2222
image={<Illustration name="thumbsUp" />}
2323
title={title}
2424
description={message}
25-
actions={onShowAll && [
26-
<Button
27-
key="show-all"
28-
onClick={onShowAll}
29-
>
30-
{showAll}
31-
</Button>
32-
]}
25+
actions={
26+
onShowAll && [
27+
<Button key="show-all" onClick={onShowAll}>
28+
{showAll}
29+
</Button>,
30+
]
31+
}
3332
/>
3433
);

src/containers/Tablet/Tablet.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import InfoViewer from '../../components/InfoViewer/InfoViewer';
1414
import EntityStatus from '../../components/EntityStatus/EntityStatus';
1515
import {Tag} from '../../components/Tag';
1616
import Icon from '../../components/Icon/Icon';
17-
import EmptyState from '../../components/EmptyState/EmptyState';
17+
import {EmptyState} from '../../components/EmptyState';
1818
import {Link as ExternalLink, Button, Loader} from '@gravity-ui/uikit';
1919
import DataTable from '@gravity-ui/react-data-table';
2020
import CriticalActionDialog from '../../components/CriticalActionDialog/CriticalActionDialog';

0 commit comments

Comments
 (0)