Skip to content

Commit

Permalink
lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Sep 14, 2022
1 parent abce71f commit bb2af99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ 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,
LOG_ACTIONS_DATASET_CREATION_SCHEMA_CANCELLATION,
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 = [
Expand All @@ -53,12 +53,14 @@ function Footer({ url, datasetObject, addDangerToast }: FooterProps) {
);

const createLogAction = (dataset: Partial<DatasetObject>) => {
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 = () => {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -141,7 +142,7 @@ export default function LeftPanel({
const { addDangerToast } = useToasts();

const setDatabase = (db: Partial<DatabaseObject>) => {
setDataset({ type: DatasetActionType.selectDatabase, payload: { db: db } });
setDataset({ type: DatasetActionType.selectDatabase, payload: { db } });
setSelectedTable(null);
setResetTables(true);
};
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 && (
<div className="emptystate">
<EmptyStateMedium
image="empty-table.svg"
Expand Down

0 comments on commit bb2af99

Please sign in to comment.