Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b7a4265
feat(datasets): reuse SQL Lab table browser for dataset creation
Haseeb702 Nov 15, 2026
78e2e75
Merge Apache Superset master into feat/bulk-import-ui-phase-1
Haseeb702 Nov 15, 2026
2ec8269
fix(datasets): updated tests for table browser
Haseeb702 Nov 18, 2026
4350314
feat(datasets): modified datasource selector ui
Haseeb702 Nov 18, 2026
d1e7d04
test(datasets): improve new code test coverage
Haseeb702 Nov 18, 2026
b9e642e
test(datasets): add test for table pin controls
Haseeb702 Nov 19, 2026
7495c1c
chore: merge upstream master into dataset UI branch
Haseeb702 Nov 19, 2026
0e3b536
fix(datasets): fixed left panel clipping
Haseeb702 Nov 24, 2026
47613f4
fix(datasets): removed white opacity caching and allow only 1 table d…
Haseeb702 Nov 24, 2026
114894b
Merge branch 'master' into feat/bulk-import-ui-phase-1
Haseeb702 Nov 24, 2026
5730f34
Merge branch 'master' into feat/bulk-import-ui-phase-1
Haseeb702 Nov 25, 2026
449dfe0
fix(datasets): addressed AI review bot comments
Haseeb702 Nov 25, 2026
aaf2912
fix(datasets): fixed pre commit for ci run
Haseeb702 Nov 25, 2026
9537baf
fix(datasets): added '' to SQL Lab path and added back table marker
Haseeb702 Nov 26, 2026
aa48039
Merge branch 'master' into feat/bulk-import-ui-phase-1
Haseeb702 Nov 26, 2026
a75a2e2
fix(datasets): added callbacks back to trigger
Haseeb702 Nov 27, 2026
f675eea
fix(datasets): preserve table search filter when selecting table from…
Haseeb702 Nov 27, 2026
456a111
fix(datasets): sync selected table state with table browser tree
Haseeb702 Nov 27, 2026
16ba244
fix(datasets): skip node.select() in table preview mode
Haseeb702 Nov 27, 2026
95ceb3f
fix(datasets): fix pre commit ci error
Haseeb702 Nov 27, 2026
0177a11
fix(datasets): fixed test cases for frontend ci
Haseeb702 Nov 27, 2026
9847e3b
fix(datasets): fixed test cases for frontend ci
Haseeb702 Nov 27, 2026
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
53 changes: 30 additions & 23 deletions superset-frontend/playwright/pages/CreateDatasetPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { Page } from '@playwright/test';
import { expect, Page } from '@playwright/test';
import { Button, Select } from '../components/core';
import { gotoWithRetry } from '../helpers/navigation';

Expand All @@ -33,8 +33,6 @@ export class CreateDatasetPage {
*/
private static readonly SELECTORS = {
DATABASE: '[data-test="select-database"]',
SCHEMA: '[data-test="Select schema"]',
TABLE: '[data-test="Select table or type to search tables"]',
} as const;

constructor(page: Page) {
Expand All @@ -48,20 +46,6 @@ export class CreateDatasetPage {
return new Select(this.page, CreateDatasetPage.SELECTORS.DATABASE);
}

/**
* Gets the schema selector using data-test attribute
*/
getSchemaSelect(): Select {
return new Select(this.page, CreateDatasetPage.SELECTORS.SCHEMA);
}

/**
* Gets the table selector using data-test attribute
*/
getTableSelect(): Select {
return new Select(this.page, CreateDatasetPage.SELECTORS.TABLE);
}

/**
* Gets the create and explore button
*/
Expand All @@ -80,27 +64,48 @@ export class CreateDatasetPage {
}

/**
* Select a database from the dropdown
* Select a database through the connection/schema popover
* @param databaseName - The name of the database to select
*/
async selectDatabase(databaseName: string): Promise<void> {
await this.page.getByTestId('database-selector-trigger').click();
await this.getDatabaseSelect().selectOption(databaseName);
const popover = this.page.getByRole('group', {
name: 'Select Database and Schema',
});
await popover.getByRole('button', { name: 'Select', exact: true }).click();
await expect(popover).toBeHidden();
}

/**
* Select a schema from the dropdown
* Expand a schema in the table browser
* @param schemaName - The name of the schema to select
*/
async selectSchema(schemaName: string): Promise<void> {
await this.getSchemaSelect().selectOption(schemaName);
await this.page.getByTestId('database-selector-trigger').click();
const dialog = this.page.getByRole('group', {
name: 'Select Database and Schema',
});
await new Select(
this.page,
dialog.getByRole('combobox', { name: /^Select schema/ }),
).selectOption(schemaName);
await dialog.getByRole('button', { name: 'Select', exact: true }).click();
await expect(dialog).toBeHidden();
}

/**
* Select a table from the dropdown
* Filter the table browser and select a table
* @param tableName - The name of the table to select
*/
async selectTable(tableName: string): Promise<void> {
await this.getTableSelect().selectOption(tableName);
await this.page
.getByPlaceholder('Enter a part of the object name')
.fill(tableName);
await this.page
.getByRole('treeitem')
.getByText(tableName, { exact: true })
.click();
}

/**
Expand Down Expand Up @@ -134,6 +139,8 @@ export class CreateDatasetPage {
* Wait for the page to load
*/
async waitForPageLoad(): Promise<void> {
await this.getDatabaseSelect().element.waitFor({ state: 'visible' });
await this.page
.getByTestId('database-selector-trigger')
.waitFor({ state: 'visible' });
}
}
149 changes: 8 additions & 141 deletions superset-frontend/src/SqlLab/components/SqlEditorLeftBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
import { useCallback, useState } from 'react';
import { useCallback } from 'react';
import { useAppDispatch } from 'src/SqlLab/hooks/useAppDispatch';

import { resetState } from 'src/SqlLab/actions/sqlLab';
import {
Button,
EmptyState,
Flex,
Icons,
Popover,
Typography,
} from '@superset-ui/core/components';
import { Button, Icons } from '@superset-ui/core/components';
import { t } from '@apache-superset/core/translation';
import { styled, css } from '@apache-superset/core/theme';
import type { SchemaOption, CatalogOption } from 'src/hooks/apiResources';
import { DatabaseSelector, type DatabaseObject } from 'src/components';
import { DatabaseSelectorPopover } from 'src/components/DatabaseSelector';
import { EMPTY_STATE_QE_ID } from 'src/SqlLab/hooks/useQueryEditor';

import useDatabaseSelector from '../SqlEditorTopBar/useDatabaseSelector';
Expand Down Expand Up @@ -70,145 +62,20 @@ const SqlEditorLeftBar = ({
}: SqlEditorLeftBarProps) => {
const activeQEId = queryEditorId || EMPTY_STATE_QE_ID;
const dbSelectorProps = useDatabaseSelector(activeQEId);
const { db, catalog, schema, onDbChange, onCatalogChange, onSchemaChange } =
dbSelectorProps;

const dispatch = useAppDispatch();
const shouldShowReset = window.location.search === '?reset=1';

// Modal state for Database/Catalog/Schema selector
const [selectorModalOpen, setSelectorModalOpen] = useState(false);
const [modalDb, setModalDb] = useState<DatabaseObject | undefined>(undefined);
const [modalCatalog, setModalCatalog] = useState<
CatalogOption | null | undefined
>(undefined);
const [modalSchema, setModalSchema] = useState<SchemaOption | undefined>(
undefined,
);

const openSelectorModal = useCallback(() => {
setModalDb(db ?? undefined);
setModalCatalog(
catalog ? { label: catalog, value: catalog, title: catalog } : undefined,
);
setModalSchema(
schema ? { label: schema, value: schema, title: schema } : undefined,
);
setSelectorModalOpen(true);
}, [db, catalog, schema]);

const closeSelectorModal = useCallback(() => {
setSelectorModalOpen(false);
}, []);

const handleModalOk = useCallback(() => {
if (modalDb && modalDb.id !== db?.id) {
onDbChange?.(modalDb);
}
if (modalCatalog?.value !== catalog) {
onCatalogChange?.(modalCatalog?.value);
}
if (modalSchema?.value !== schema) {
onSchemaChange?.(modalSchema?.value ?? '');
}
setSelectorModalOpen(false);
}, [
modalDb,
modalCatalog,
modalSchema,
db,
catalog,
schema,
onDbChange,
onCatalogChange,
onSchemaChange,
]);

const handleResetState = useCallback(() => {
dispatch(resetState());
}, [dispatch]);

const popoverContent = (
<Flex
vertical
gap="middle"
data-test="DatabaseSelector"
css={css`
min-width: 500px;
max-width: 500px;
`}
>
<Typography.Title level={5} style={{ margin: 0 }}>
{t('Select Database and Schema')}
</Typography.Title>
<DatabaseSelector
key={modalDb ? modalDb.id : 'no-db'}
db={modalDb}
emptyState={<EmptyState />}
getDbList={dbSelectorProps.getDbList}
handleError={dbSelectorProps.handleError}
onDbChange={setModalDb}
onCatalogChange={cat =>
setModalCatalog(
cat ? { label: cat, value: cat, title: cat } : undefined,
)
}
catalog={modalCatalog?.value}
onSchemaChange={sch =>
setModalSchema(
sch ? { label: sch, value: sch, title: sch } : undefined,
)
}
schema={modalSchema?.value}
sqlLabMode={false}
filterBySqlLab
/>
<Flex justify="flex-end" gap="small">
<Button
buttonStyle="tertiary"
onClick={e => {
e?.stopPropagation();
closeSelectorModal();
}}
>
{t('Cancel')}
</Button>
<Button
type="primary"
onClick={e => {
e?.stopPropagation();
handleModalOk();
}}
>
{t('Select')}
</Button>
</Flex>
</Flex>
);

const dbSelectorTrigger = (
<Popover
content={popoverContent}
open={selectorModalOpen}
onOpenChange={open => !open && closeSelectorModal()}
placement="bottomLeft"
trigger="click"
>
{/* Wrap in a span so the Popover can attach a ref without relying
on findDOMNode (deprecated in React 18+). */}
<span>
<DatabaseSelector
key={`db-selector-${db ? db.id : 'no-db'}:${catalog ?? 'no-catalog'}:${
schema ?? 'no-schema'
}`}
{...dbSelectorProps}
emptyState={<EmptyState />}
sqlLabMode
compactMode={collapsed}
onOpenModal={openSelectorModal}
/>
</span>
</Popover>
<DatabaseSelectorPopover
{...dbSelectorProps}
compactMode={collapsed}
filterBySqlLab
/>
);

if (collapsed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,30 @@ test('dispatches queryEditorSetSchema action on onSchemaChange', () => {
);
});

test('dispatches empty string schema when onSchemaChange receives undefined', () => {
const store = mockStore(createInitialState());
const { result } = renderHook(
() => useDatabaseSelector(defaultQueryEditor.id),
{
wrapper: createWrapper({
useRedux: true,
store,
}),
},
);

act(() => {
result.current.onSchemaChange(undefined);
});

expect(store.getActions()).toContainEqual(
expect.objectContaining({
type: 'QUERY_EDITOR_SET_SCHEMA',
schema: '',
}),
);
});

test('dispatches setDatabases action on getDbList', () => {
const store = mockStore(createInitialState());
const { result } = renderHook(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ export default function useDatabaseSelector(queryEditorId: string) {
);

const handleSchemaChange = useCallback(
(schema: string) => {
(schema?: string) => {
if (queryEditor) {
dispatch(queryEditorSetSchema(queryEditor, schema));
dispatch(queryEditorSetSchema(queryEditor, schema ?? ''));
}
},
[dispatch, queryEditor],
Expand Down
Loading
Loading