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: Empty state refactor #31860

Merged
merged 3 commits into from
Jan 22, 2025
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
118 changes: 24 additions & 94 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useEffect, useMemo, useState } from 'react';
import { shallowEqual, useSelector } from 'react-redux';
import { useInView } from 'react-intersection-observer';
import { omit } from 'lodash';
import { EmptyStateMedium } from 'src/components/EmptyState';
import { EmptyState } from 'src/components/EmptyState';
import {
t,
styled,
Expand Down Expand Up @@ -143,8 +143,9 @@ const QueryHistory = ({
</>
) : (
<StyledEmptyStateWrapper>
<EmptyStateMedium
<EmptyState
title={t('Run a query to display query history')}
size="medium"
image="document.svg"
/>
</StyledEmptyStateWrapper>
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/SqlLab/components/SouthPane/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import { FC } from 'react';
import { shallowEqual, useSelector } from 'react-redux';
import Alert from 'src/components/Alert';
import { EmptyStateMedium } from 'src/components/EmptyState';
import { EmptyState } from 'src/components/EmptyState';
import { FeatureFlag, styled, t, isFeatureEnabled } from '@superset-ui/core';

import { SqlLabRootState } from 'src/SqlLab/types';
Expand Down Expand Up @@ -67,7 +67,7 @@ const Results: FC<Props> = ({
) {
return (
<StyledEmptyStateWrapper>
<EmptyStateMedium
<EmptyState
title={t('Run a query to display results')}
image="document.svg"
/>
Expand Down
5 changes: 3 additions & 2 deletions superset-frontend/src/SqlLab/components/SqlEditor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ import {
LocalStorageKeys,
setItem,
} from 'src/utils/localStorageHelpers';
import { EmptyStateBig } from 'src/components/EmptyState';
import { EmptyState } from 'src/components/EmptyState';
import Alert from 'src/components/Alert';
import getBootstrapData from 'src/utils/getBootstrapData';
import useLogAction from 'src/logger/useLogAction';
Expand Down Expand Up @@ -967,8 +967,9 @@ const SqlEditor: FC<Props> = ({
<Skeleton active />
</div>
) : showEmptyState && !hasSqlStatement ? (
<EmptyStateBig
<EmptyState
image="vector.svg"
size="large"
title={t('Select a database to write a query')}
description={t(
'Choose one of the available databases from the panel on the left.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { TableSelectorMultiple } from 'src/components/TableSelector';
import { IconTooltip } from 'src/components/IconTooltip';
import useQueryEditor from 'src/SqlLab/hooks/useQueryEditor';
import type { DatabaseObject } from 'src/components/DatabaseSelector';
import { emptyStateComponent } from 'src/components/EmptyState';
import { EmptyState } from 'src/components/EmptyState';
import {
getItem,
LocalStorageKeys,
Expand Down Expand Up @@ -113,7 +113,7 @@ const SqlEditorLeftBar = ({
'schema',
]);

const [emptyResultsWithSearch, setEmptyResultsWithSearch] = useState(false);
const [_emptyResultsWithSearch, setEmptyResultsWithSearch] = useState(false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we actually need this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need setEmptyResultsWithSearch, and are flushing position 1 of the array. Code is a bit cryptic to me here. Not sure why we need setEmptyResultsWithSearch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's meant to be flushed, I could put it in a _ to make it more clear (and keep the spread operator) or hard reference useState(false)[1], WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that we need this. It looks that originally the PR that introduced this was just meant to show some alternate text. I did some testing and I could not see anything breaking with just removing this entirely.

const [userSelectedDb, setUserSelected] = useState<DatabaseObject | null>(
null,
);
Expand Down Expand Up @@ -249,7 +249,7 @@ const SqlEditorLeftBar = ({
<LeftBarStyles data-test="sql-editor-left-bar">
<TableSelectorMultiple
onEmptyResults={onEmptyResults}
emptyState={emptyStateComponent(emptyResultsWithSearch)}
emptyState={<EmptyState />}
database={userSelectedDb}
getDbList={handleDbList}
handleError={handleError}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { Logger } from 'src/logger/LogUtils';
import { Tooltip } from 'src/components/Tooltip';
import { detectOS } from 'src/utils/common';
import * as Actions from 'src/SqlLab/actions/sqlLab';
import { EmptyStateBig } from 'src/components/EmptyState';
import { EmptyState } from 'src/components/EmptyState';
import getBootstrapData from 'src/utils/getBootstrapData';
import { locationContext } from 'src/pages/SqlLab/LocationContext';
import SqlEditor from '../SqlEditor';
Expand Down Expand Up @@ -255,8 +255,9 @@ class TabbedSqlEditors extends PureComponent<TabbedSqlEditorsProps> {
tab={emptyTab}
closable={false}
>
<EmptyStateBig
<EmptyState
image="empty_sql_chart.svg"
size="large"
description={t('Add a new tab to create SQL Query')}
/>
</EditableTabs.TabPane>
Expand Down
6 changes: 3 additions & 3 deletions superset-frontend/src/assets/images/chart.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions superset-frontend/src/assets/images/document.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading