fix: Edit physical dataset from the Edit Dataset modal (#15770)
* Remove unnecessary onChange
* Remove confliciting onChange
* Revert unnecessary change
* Enhance and fix tests
(cherry picked from commit a7cbcde9bf1e9edad8a139480e24b51d4dfcf031)
diff --git a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx
index 32c2bce..0d81282 100644
--- a/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx
+++ b/superset-frontend/src/components/DatabaseSelector/DatabaseSelector.test.tsx
@@ -38,7 +38,7 @@
onDbChange: jest.fn(),
onSchemaChange: jest.fn(),
onSchemasLoad: jest.fn(),
- onChange: jest.fn(),
+ onUpdate: jest.fn(),
});
beforeEach(() => {
@@ -161,7 +161,7 @@
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 @@
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 75103aa..0282e4a 100644
--- a/superset-frontend/src/components/DatabaseSelector/index.tsx
+++ b/superset-frontend/src/components/DatabaseSelector/index.tsx
@@ -72,7 +72,7 @@
readOnly?: boolean;
schema?: string;
sqlLabMode?: boolean;
- onChange?: ({
+ onUpdate?: ({
dbId,
schema,
}: {
@@ -89,7 +89,7 @@
getTableList,
handleError,
isDatabaseSelectEnabled = true,
- onChange,
+ onUpdate,
onDbChange,
onSchemaChange,
onSchemasLoad,
@@ -143,8 +143,8 @@
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 94c53cd..c437b1e 100644
--- a/superset-frontend/src/components/TableSelector/index.tsx
+++ b/superset-frontend/src/components/TableSelector/index.tsx
@@ -90,7 +90,7 @@
getDbList?: (arg0: any) => {};
handleError: (msg: string) => void;
isDatabaseSelectEnabled?: boolean;
- onChange?: ({
+ onUpdate?: ({
dbId,
schema,
}: {
@@ -117,7 +117,7 @@
getDbList,
handleError,
isDatabaseSelectEnabled = true,
- onChange,
+ onUpdate,
onDbChange,
onSchemaChange,
onSchemasLoad,
@@ -198,8 +198,8 @@
}) {
setCurrentTableName(tableName);
setCurrentSchema(schema);
- if (onChange) {
- onChange({ dbId, schema, tableName });
+ if (onUpdate) {
+ onUpdate({ dbId, schema, tableName });
}
}
@@ -299,7 +299,7 @@
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 ea184ac..ec6eaa2 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 @@
dbId={datasourceId}
formMode
handleError={addDangerToast}
- onChange={onChange}
+ onUpdate={onChange}
schema={currentSchema}
tableName={currentTableName}
/>