Skip to content

Commit d0c1472

Browse files
raswondersezr-ondrej
authored andcommitted
fix: use NoEntitiesFound as empty state for consistency
1 parent a3afe05 commit d0c1472

File tree

3 files changed

+17
-40
lines changed

3 files changed

+17
-40
lines changed
Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types';
32
import {
43
Button,
54
EmptyState,
@@ -10,23 +9,25 @@ import {
109
} from '@patternfly/react-core';
1110
import { SearchIcon } from '@patternfly/react-icons';
1211

13-
/**
14-
* Empty state stable when no systems (or other entities) are found.
15-
* @param {object} props props object
16-
* @param {string} props.entities entities count (systems, workspaces, etc.)
17-
* @param {Function} props.onClearAll on clear all function
18-
* @param {boolean} props.showIcon if true, the icon is shown
19-
* @returns {React.node} React node with empty state
20-
*/
21-
const NoEntitiesFound = ({ entities, onClearAll, showIcon }) => (
12+
interface NoEntitiesFoundProps {
13+
entities?: string;
14+
onClearAll?: () => void;
15+
showIcon?: boolean;
16+
}
17+
18+
const NoEntitiesFound: React.FC<NoEntitiesFoundProps> = ({
19+
entities = 'systems',
20+
onClearAll,
21+
showIcon = true,
22+
}) => (
2223
<EmptyState
2324
headingLevel="h5"
2425
titleText={<>{`No matching ${entities} found`}</>}
2526
variant={EmptyStateVariant.full}
2627
data-ouia-component-id="empty-state"
2728
data-ouia-component-type="PF6/EmptyState"
2829
data-ouia-safe={true}
29-
icon={showIcon && SearchIcon}
30+
icon={showIcon ? SearchIcon : undefined}
3031
>
3132
<EmptyStateBody>
3233
To continue, edit your filter settings and try again
@@ -43,15 +44,4 @@ const NoEntitiesFound = ({ entities, onClearAll, showIcon }) => (
4344
</EmptyState>
4445
);
4546

46-
NoEntitiesFound.propTypes = {
47-
entities: PropTypes.string,
48-
onClearAll: PropTypes.func,
49-
showIcon: PropTypes.bool,
50-
};
51-
52-
NoEntitiesFound.defaultProps = {
53-
entities: 'systems',
54-
showIcon: true,
55-
};
56-
5747
export default NoEntitiesFound;

src/components/SystemsViewTable/SystemsViewTable.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
import { type System, useSystemsQuery } from './hooks/useSystemsQuery';
2727
import { ErrorState } from '@redhat-cloud-services/frontend-components/ErrorState';
2828
import SkeletonTable from '@patternfly/react-component-groups/dist/dynamic/SkeletonTable';
29-
import { EmptySystemsState } from './components/EmptySystemsState';
29+
import NoEntitiesFound from '../InventoryTable/NoEntitiesFound';
3030

3131
const PER_PAGE = 50;
3232
const INITIAL_PAGE = 1;
@@ -44,7 +44,7 @@ const SystemsViewTable: React.FC = () => {
4444
});
4545
const { selected, onSelect, isSelected, setSelected } = selection;
4646

47-
const { data, total, isLoading, isError, error } = useSystemsQuery({
47+
const { data, total, isLoading, isError } = useSystemsQuery({
4848
page: pagination.page,
4949
perPage: pagination.perPage,
5050
});
@@ -178,16 +178,16 @@ const SystemsViewTable: React.FC = () => {
178178
bodyStates={{
179179
loading: (
180180
<SkeletonTable
181-
ouiaId="loading-systems-state"
181+
ouiaId="loading-state"
182182
isSelectable
183183
rowsCount={pagination.perPage}
184184
columns={columns}
185185
/>
186186
),
187-
empty: <EmptySystemsState />,
187+
empty: <NoEntitiesFound />,
188188
error: (
189189
<ErrorState
190-
ouiaId="error-systems-state"
190+
ouiaId="error-state"
191191
titleText="Unable to load data"
192192
bodyText="There was an error retrieving data. Check your connection and reload the page."
193193
/>

src/components/SystemsViewTable/components/EmptySystemsState.tsx

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

0 commit comments

Comments
 (0)