From a7cbcde9bf1e9edad8a139480e24b51d4dfcf031 Mon Sep 17 00:00:00 2001 From: Geido <60598000+geido@users.noreply.github.com> Date: Mon, 19 Jul 2021 20:39:01 +0200 Subject: [PATCH] fix: Edit physical dataset from the Edit Dataset modal (#15770) * Remove unnecessary onChange * Remove confliciting onChange * Revert unnecessary change * Enhance and fix tests --- .../DatabaseSelector/DatabaseSelector.test.tsx | 6 +++--- .../src/components/DatabaseSelector/index.tsx | 8 ++++---- .../src/components/TableSelector/index.tsx | 10 +++++----- .../src/views/CRUD/data/dataset/AddDatasetModal.tsx | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx index 32c2bce0b..0d812824d 100644 --- a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx +++ b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx @@ -38,7 +38,7 @@ const createProps = () => ({ onDbChange: jest.fn(), onSchemaChange: jest.fn(), onSchemasLoad: jest.fn(), - onChange: jest.fn(), + onUpdate: jest.fn(), }); beforeEach(() => { @@ -161,7 +161,7 @@ test('Refresh should work', async () => { expect(props.onDbChange).toBeCalledTimes(0); expect(props.onSchemaChange).toBeCalledTimes(0); expect(props.onSchemasLoad).toBeCalledTimes(1); - expect(props.onChange).toBeCalledTimes(0); + expect(props.onUpdate).toBeCalledTimes(0); }); userEvent.click(screen.getByRole('button')); @@ -174,7 +174,7 @@ test('Refresh should work', async () => { expect(props.onDbChange).toBeCalledTimes(1); expect(props.onSchemaChange).toBeCalledTimes(1); expect(props.onSchemasLoad).toBeCalledTimes(2); - expect(props.onChange).toBeCalledTimes(1); + expect(props.onUpdate).toBeCalledTimes(1); }); }); diff --git a/superset-frontend/src/components/DatabaseSelector/index.tsx b/superset-frontend/src/components/DatabaseSelector/index.tsx index 75103aac3..0282e4a4a 100644 --- a/superset-frontend/src/components/DatabaseSelector/index.tsx +++ b/superset-frontend/src/components/DatabaseSelector/index.tsx @@ -72,7 +72,7 @@ interface DatabaseSelectorProps { readOnly?: boolean; schema?: string; sqlLabMode?: boolean; - onChange?: ({ + onUpdate?: ({ dbId, schema, }: { @@ -89,7 +89,7 @@ export default function DatabaseSelector({ getTableList, handleError, isDatabaseSelectEnabled = true, - onChange, + onUpdate, onDbChange, onSchemaChange, onSchemasLoad, @@ -143,8 +143,8 @@ export default function DatabaseSelector({ function onSelectChange({ dbId, schema }: { dbId: number; schema?: string }) { setCurrentDbId(dbId); setCurrentSchema(schema); - if (onChange) { - onChange({ dbId, schema, tableName: undefined }); + if (onUpdate) { + onUpdate({ dbId, schema, tableName: undefined }); } } diff --git a/superset-frontend/src/components/TableSelector/index.tsx b/superset-frontend/src/components/TableSelector/index.tsx index 94c53cdcd..c437b1e59 100644 --- a/superset-frontend/src/components/TableSelector/index.tsx +++ b/superset-frontend/src/components/TableSelector/index.tsx @@ -90,7 +90,7 @@ interface TableSelectorProps { getDbList?: (arg0: any) => {}; handleError: (msg: string) => void; isDatabaseSelectEnabled?: boolean; - onChange?: ({ + onUpdate?: ({ dbId, schema, }: { @@ -117,7 +117,7 @@ const TableSelector: FunctionComponent = ({ getDbList, handleError, isDatabaseSelectEnabled = true, - onChange, + onUpdate, onDbChange, onSchemaChange, onSchemasLoad, @@ -198,8 +198,8 @@ const TableSelector: FunctionComponent = ({ }) { setCurrentTableName(tableName); setCurrentSchema(schema); - if (onChange) { - onChange({ dbId, schema, tableName }); + if (onUpdate) { + onUpdate({ dbId, schema, tableName }); } } @@ -299,7 +299,7 @@ const TableSelector: FunctionComponent = ({ getDbList={getDbList} getTableList={fetchTables} handleError={handleError} - onChange={onSelectionChange} + onUpdate={onSelectionChange} onDbChange={readOnly ? undefined : onDbChange} onSchemaChange={readOnly ? undefined : onSchemaChange} onSchemasLoad={onSchemasLoad} diff --git a/superset-frontend/src/views/CRUD/data/dataset/AddDatasetModal.tsx b/superset-frontend/src/views/CRUD/data/dataset/AddDatasetModal.tsx index ea184acce..ec6eaa231 100644 --- a/superset-frontend/src/views/CRUD/data/dataset/AddDatasetModal.tsx +++ b/superset-frontend/src/views/CRUD/data/dataset/AddDatasetModal.tsx @@ -108,7 +108,7 @@ const DatasetModal: FunctionComponent = ({ dbId={datasourceId} formMode handleError={addDangerToast} - onChange={onChange} + onUpdate={onChange} schema={currentSchema} tableName={currentTableName} />