Skip to content

Commit

Permalink
fix: Edit physical dataset from the Edit Dataset modal (apache#15770)
Browse files Browse the repository at this point in the history
* Remove unnecessary onChange

* Remove confliciting onChange

* Revert unnecessary change

* Enhance and fix tests
  • Loading branch information
geido authored and cccs-RyanS committed Dec 17, 2021
1 parent 4b7ad7f commit c34ff49
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
Expand Up @@ -38,7 +38,7 @@ const createProps = () => ({
onDbChange: jest.fn(),
onSchemaChange: jest.fn(),
onSchemasLoad: jest.fn(),
onChange: jest.fn(),
onUpdate: jest.fn(),
});

beforeEach(() => {
Expand Down Expand Up @@ -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'));
Expand All @@ -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);
});
});

Expand Down
8 changes: 4 additions & 4 deletions superset-frontend/src/components/DatabaseSelector/index.tsx
Expand Up @@ -72,7 +72,7 @@ interface DatabaseSelectorProps {
readOnly?: boolean;
schema?: string;
sqlLabMode?: boolean;
onChange?: ({
onUpdate?: ({
dbId,
schema,
}: {
Expand All @@ -89,7 +89,7 @@ export default function DatabaseSelector({
getTableList,
handleError,
isDatabaseSelectEnabled = true,
onChange,
onUpdate,
onDbChange,
onSchemaChange,
onSchemasLoad,
Expand Down Expand Up @@ -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 });
}
}

Expand Down
10 changes: 5 additions & 5 deletions superset-frontend/src/components/TableSelector/index.tsx
Expand Up @@ -90,7 +90,7 @@ interface TableSelectorProps {
getDbList?: (arg0: any) => {};
handleError: (msg: string) => void;
isDatabaseSelectEnabled?: boolean;
onChange?: ({
onUpdate?: ({
dbId,
schema,
}: {
Expand All @@ -117,7 +117,7 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
getDbList,
handleError,
isDatabaseSelectEnabled = true,
onChange,
onUpdate,
onDbChange,
onSchemaChange,
onSchemasLoad,
Expand Down Expand Up @@ -198,8 +198,8 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
}) {
setCurrentTableName(tableName);
setCurrentSchema(schema);
if (onChange) {
onChange({ dbId, schema, tableName });
if (onUpdate) {
onUpdate({ dbId, schema, tableName });
}
}

Expand Down Expand Up @@ -299,7 +299,7 @@ const TableSelector: FunctionComponent<TableSelectorProps> = ({
getDbList={getDbList}
getTableList={fetchTables}
handleError={handleError}
onChange={onSelectionChange}
onUpdate={onSelectionChange}
onDbChange={readOnly ? undefined : onDbChange}
onSchemaChange={readOnly ? undefined : onSchemaChange}
onSchemasLoad={onSchemasLoad}
Expand Down
Expand Up @@ -108,7 +108,7 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({
dbId={datasourceId}
formMode
handleError={addDangerToast}
onChange={onChange}
onUpdate={onChange}
schema={currentSchema}
tableName={currentTableName}
/>
Expand Down

0 comments on commit c34ff49

Please sign in to comment.