-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
feat(explore): Implement data table empty states #18679
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ import { | |
import Collapse from 'src/components/Collapse'; | ||
import Tabs from 'src/components/Tabs'; | ||
import Loading from 'src/components/Loading'; | ||
import { EmptyStateMedium } from 'src/components/EmptyState'; | ||
import TableView, { EmptyWrapperType } from 'src/components/TableView'; | ||
import { getChartDataRequest } from 'src/chart/chartAction'; | ||
import { getClientErrorObject } from 'src/utils/getClientErrorObject'; | ||
|
@@ -120,6 +121,7 @@ interface DataTableProps { | |
isLoading: boolean; | ||
error: string | undefined; | ||
errorMessage: React.ReactElement | undefined; | ||
type: 'results' | 'samples'; | ||
} | ||
|
||
const DataTable = ({ | ||
|
@@ -132,6 +134,7 @@ const DataTable = ({ | |
isLoading, | ||
error, | ||
errorMessage, | ||
type, | ||
}: DataTableProps) => { | ||
// this is to preserve the order of the columns, even if there are integer values, | ||
// while also only grabbing the first column's keys | ||
|
@@ -152,14 +155,19 @@ const DataTable = ({ | |
} | ||
if (data) { | ||
if (data.length === 0) { | ||
return <span>No data</span>; | ||
return ( | ||
<EmptyStateMedium | ||
image="document.svg" | ||
title={t(`No ${type} were returned for this query`)} | ||
/> | ||
); | ||
} | ||
return ( | ||
<TableView | ||
columns={columns} | ||
data={filteredData} | ||
pageSize={DATA_TABLE_PAGE_SIZE} | ||
noDataText={t('No data')} | ||
noDataText={t('No results')} | ||
emptyWrapperType={EmptyWrapperType.Small} | ||
className="table-condensed" | ||
isPaginationSticky | ||
|
@@ -169,7 +177,12 @@ const DataTable = ({ | |
); | ||
} | ||
if (errorMessage) { | ||
return <Error>{errorMessage}</Error>; | ||
return ( | ||
<EmptyStateMedium | ||
image="document.svg" | ||
title={t(`Run a query to display ${type}`)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
/> | ||
); | ||
} | ||
return null; | ||
}; | ||
|
@@ -420,6 +433,7 @@ export const DataTablesPane = ({ | |
filterText={filterText} | ||
error={error[RESULT_TYPES.results]} | ||
errorMessage={errorMessage} | ||
type={RESULT_TYPES.results} | ||
/> | ||
</Tabs.TabPane> | ||
<Tabs.TabPane | ||
|
@@ -436,6 +450,7 @@ export const DataTablesPane = ({ | |
filterText={filterText} | ||
error={error[RESULT_TYPES.samples]} | ||
errorMessage={errorMessage} | ||
type={RESULT_TYPES.samples} | ||
/> | ||
</Tabs.TabPane> | ||
</Tabs> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to translate this like this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, we probably need to translate these like this to make sure the translators have the necessary context to fully translate the type strings:
I think this getting this right is pretty important, as these will be very visible fixtures in the application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done