From bb2af9959becb594c698a73aa2203a52ec472a73 Mon Sep 17 00:00:00 2001 From: AAfghahi Date: Tue, 13 Sep 2022 22:42:50 -0400 Subject: [PATCH] lint errors --- .../CRUD/data/dataset/AddDataset/Footer/index.tsx | 13 ++++++++----- .../data/dataset/AddDataset/LeftPanel/index.tsx | 11 ++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/Footer/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/Footer/index.tsx index 9ae6ea08cff38..f9a32f32d1ea8 100644 --- a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/Footer/index.tsx +++ b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/Footer/index.tsx @@ -22,7 +22,6 @@ import { t } from '@superset-ui/core'; import { useSingleViewResource } from 'src/views/CRUD/hooks'; import { logEvent } from 'src/logger/actions'; import withToasts from 'src/components/MessageToasts/withToasts'; -import { DatasetObject } from '../types'; import { LOG_ACTIONS_DATASET_CREATION_EMPTY_CANCELLATION, LOG_ACTIONS_DATASET_CREATION_DATABASE_CANCELLATION, @@ -30,6 +29,7 @@ import { LOG_ACTIONS_DATASET_CREATION_TABLE_CANCELLATION, LOG_ACTIONS_DATASET_CREATION_SUCCESS, } from 'src/logger/LogUtils'; +import { DatasetObject } from '../types'; const INPUT_FIELDS = ['db', 'schema', 'table_name']; const LOG_ACTIONS = [ @@ -53,12 +53,14 @@ function Footer({ url, datasetObject, addDangerToast }: FooterProps) { ); const createLogAction = (dataset: Partial) => { + let totalCount = 0; const value = Object.keys(dataset).reduce((total, key) => { if (INPUT_FIELDS.includes(key) && dataset[key]) { - total++; + totalCount += 1; } - return total; + return totalCount; }, 0); + return LOG_ACTIONS[value]; }; const goToPreviousUrl = () => { @@ -68,9 +70,10 @@ function Footer({ url, datasetObject, addDangerToast }: FooterProps) { }; const cancelButtonOnClick = () => { - if (datasetObject) { + if (!datasetObject) { + logEvent(LOG_ACTIONS_DATASET_CREATION_EMPTY_CANCELLATION, {}); + } else { const logAction = createLogAction(datasetObject); - console.log(logAction); logEvent(logAction, datasetObject); } goToPreviousUrl(); diff --git a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx index 4623ef92dc542..03cc6ddacbd96 100644 --- a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx +++ b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx @@ -31,11 +31,12 @@ import { TableOption } from 'src/components/TableSelector'; import RefreshLabel from 'src/components/RefreshLabel'; import { Table } from 'src/hooks/apiResources'; import Loading from 'src/components/Loading'; -import DatabaseSelector from 'src/components/DatabaseSelector'; +import DatabaseSelector, { + DatabaseObject, +} from 'src/components/DatabaseSelector'; import { debounce } from 'lodash'; import { EmptyStateMedium } from 'src/components/EmptyState'; import { useToasts } from 'src/components/MessageToasts/withToasts'; -import { DatabaseObject } from 'src/components/DatabaseSelector'; import { DatasetActionType } from '../types'; interface LeftPanelProps { @@ -141,7 +142,7 @@ export default function LeftPanel({ const { addDangerToast } = useToasts(); const setDatabase = (db: Partial) => { - setDataset({ type: DatasetActionType.selectDatabase, payload: { db: db } }); + setDataset({ type: DatasetActionType.selectDatabase, payload: { db } }); setSelectedTable(null); setResetTables(true); }; @@ -194,7 +195,7 @@ export default function LeftPanel({ useEffect(() => { if (loadTables) { const endpoint = encodeURI( - `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`, + `/superset/tables/${dbId}/${encodedSchema}/undefined/`, ); getTablesList(endpoint); } @@ -236,7 +237,7 @@ export default function LeftPanel({ onSchemaChange={setSchema} /> {loadTables && !refresh && Loader('Table loading')} - {schema && loadTables && !tableOptions.length && !searchVal && ( + {schema && !loadTables && !tableOptions.length && !searchVal && (