Skip to content

Commit

Permalink
fix: Unable to add dataset (apache#16925)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Sep 30, 2021
1 parent 7f330c9 commit c5d23fb
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { FunctionComponent, useState } from 'react';
import React, { FunctionComponent, useState, useEffect } from 'react';
import { styled, t } from '@superset-ui/core';
import { useSingleViewResource } from 'src/views/CRUD/hooks';
import { isEmpty, isNil } from 'lodash';
Expand Down Expand Up @@ -60,27 +60,24 @@ const DatasetModal: FunctionComponent<DatasetModalProps> = ({
addDangerToast,
);

const setSaveButtonState = () => {
useEffect(() => {
setDisableSave(isNil(datasourceId) || isEmpty(currentTableName));
};
}, [currentTableName, datasourceId]);

const onDbChange = (db: {
id: number;
database_name: string;
backend: string;
}) => {
setDatasourceId(db.id);
setSaveButtonState();
};

const onSchemaChange = (schema?: string) => {
setSchema(schema);
setSaveButtonState();
};

const onTableChange = (tableName: string) => {
setTableName(tableName);
setSaveButtonState();
};

const onSave = () => {
Expand Down

0 comments on commit c5d23fb

Please sign in to comment.