This is an automated email from the ASF dual-hosted git repository.
beto pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 296ff17f19 fix: preventing save button from flickering in SQL Lab
(#25106)
296ff17f19 is described below
commit 296ff17f196084dbfe1fc5745c2f0e429325aa11
Author: Jack <[email protected]>
AuthorDate: Tue Sep 26 13:41:28 2023 -0500
fix: preventing save button from flickering in SQL Lab (#25106)
---
.../SqlLab/components/SaveQuery/SaveQuery.test.tsx | 21 ++++++++++++++++++++-
.../src/SqlLab/components/SaveQuery/index.tsx | 12 ++++++++----
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git
a/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx
b/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx
index f321a54ec4..54b81df960 100644
--- a/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveQuery/SaveQuery.test.tsx
@@ -27,7 +27,7 @@ import { initialState, databases } from 'src/SqlLab/fixtures';
const mockedProps = {
queryEditorId: '123',
animation: false,
- database: databases.result[0],
+ database: { ...databases.result[0], allows_virtual_table_explore: false },
onUpdate: () => {},
onSave: () => {},
saveQueryWarning: null,
@@ -61,6 +61,25 @@ const middlewares = [thunk];
const mockStore = configureStore(middlewares);
describe('SavedQuery', () => {
+ it('doesnt render save button when allows_virtual_table_explore is
undefined', async () => {
+ const noRenderProps = {
+ ...mockedProps,
+ database: {
+ ...mockedProps.database,
+ allows_virtual_table_explore: undefined,
+ },
+ };
+ render(<SaveQuery {...noRenderProps} />, {
+ useRedux: true,
+ store: mockStore(mockState),
+ });
+ expect(() => {
+ screen.getByRole('button', { name: /save/i });
+ }).toThrow(
+ 'Unable to find an accessible element with the role "button" and name
`/save/i`',
+ );
+ });
+
it('renders a non-split save button when allows_virtual_table_explore is not
enabled', () => {
render(<SaveQuery {...mockedProps} />, {
useRedux: true,
diff --git a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
index 4071b9e2d7..6ed0f4c668 100644
--- a/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
+++ b/superset-frontend/src/SqlLab/components/SaveQuery/index.tsx
@@ -98,6 +98,8 @@ const SaveQuery = ({
const [showSaveDatasetModal, setShowSaveDatasetModal] = useState(false);
const isSaved = !!query.remoteId;
const canExploreDatabase = !!database?.allows_virtual_table_explore;
+ const shouldShowSaveButton =
+ database?.allows_virtual_table_explore !== undefined;
const overlayMenu = (
<Menu>
@@ -180,10 +182,12 @@ const SaveQuery = ({
return (
<Styles className="SaveQuery">
- <SaveDatasetActionButton
- setShowSave={setShowSave}
- overlayMenu={canExploreDatabase ? overlayMenu : null}
- />
+ {shouldShowSaveButton && (
+ <SaveDatasetActionButton
+ setShowSave={setShowSave}
+ overlayMenu={canExploreDatabase ? overlayMenu : null}
+ />
+ )}
<SaveDatasetModal
visible={showSaveDatasetModal}
onHide={() => setShowSaveDatasetModal(false)}