Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(storage-browser): remove loading indicator and empty message fr… #5949

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from 'react';

import { EmptyMessage } from '../../components/EmptyMessage';
import { LoadingIndicator } from '../../components/LoadingIndicator';
import { Table } from '../../components/Table';
import { SortHeader } from './headers/SortHeader';
import { TextHeader } from './headers/TextHeader';
Expand All @@ -21,13 +19,11 @@ export interface DataTableRow {
export interface DataTableProps {
headers: WithKey<DataTableHeader>[];
rows: WithKey<DataTableRow>[];
isLoading?: boolean;
}

export const DataTable = ({
headers,
rows,
isLoading,
}: DataTableProps): React.JSX.Element => {
const mappedHeaders = headers.map(({ key, content, type }) => {
switch (type) {
Expand Down Expand Up @@ -92,14 +88,5 @@ export const DataTable = ({
}),
}));

return (
<>
<Table headers={mappedHeaders} rows={mappedRows} />
{isLoading ? (
<LoadingIndicator />
) : mappedRows.length ? null : (
<EmptyMessage>No data available</EmptyMessage>
)}
</>
);
return <Table headers={mappedHeaders} rows={mappedRows} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -101,35 +101,4 @@ describe('DataTable', () => {
expect(row2DataCell2).toHaveTextContent('row-2-number');
expect(row2DataCell3).toHaveTextContent('row-2-text');
});

it('displays a loading indicator when loading', () => {
const { container } = render(
<DataTable headers={[]} rows={[]} isLoading />
);

const table = screen.queryByRole('table');
const svg = container.querySelector('svg');

expect(table).toBeInTheDocument();
expect(svg).toBeInTheDocument();
});

it('displays a an empty message if there is no row data', () => {
const { container } = render(
<DataTable
headers={[{ key: 'header', type: 'text', content: {} }]}
rows={[]}
/>
);

const table = screen.queryByRole('table');
const tableHeaders = screen.getAllByRole('columnheader');
const svg = container.querySelector('svg');
const emptyMessage = screen.getByText('No data available');

expect(table).toBeInTheDocument();
expect(tableHeaders).toHaveLength(1);
expect(emptyMessage).toBeInTheDocument();
expect(svg).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ interface TableData {
| TruncatedSortHeader
)[];
rows: DataTableProps['rows'];
isLoading?: boolean;
}

export interface ControlsContext {
Expand Down
Loading