villebro commented on a change in pull request #13340: URL: https://github.com/apache/superset/pull/13340#discussion_r587756311
########## File path: superset-frontend/src/explore/components/controls/DndColumnSelectControl/DndFilterSelect.tsx ########## @@ -0,0 +1,334 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with work for additional information + * regarding copyright ownership. The ASF licenses file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React, { useEffect, useMemo, useState } from 'react'; +import { logging, SupersetClient } from '@superset-ui/core'; +import { ColumnMeta, Metric } from '@superset-ui/chart-controls'; +import { Tooltip } from 'src/common/components/Tooltip'; +import { OPERATORS } from 'src/explore/constants'; +import { OptionSortType } from 'src/explore/types'; +import { DndFilterSelectProps, FilterOptionValueType } from './types'; +import AdhocFilterPopoverTrigger from '../FilterControl/AdhocFilterPopoverTrigger'; +import OptionWrapper from './components/OptionWrapper'; +import DndSelectLabel from './DndSelectLabel'; +import AdhocFilter, { + CLAUSES, + EXPRESSION_TYPES, +} from '../FilterControl/AdhocFilter'; +import AdhocMetric from '../MetricControl/AdhocMetric'; +import { + DatasourcePanelDndItem, + DndItemValue, +} from '../../DatasourcePanel/types'; +import { DndItemType } from '../../DndItemType'; + +const isDictionaryForAdhocFilter = (value: FilterOptionValueType) => + value && !(value instanceof AdhocFilter) && value.expressionType; Review comment: I assume checking for value here isn't necessary as `value` is always an object (=always truthy)? ########## File path: superset-frontend/src/explore/components/DndItemType.ts ########## @@ -16,7 +16,25 @@ * specific language governing permissions and limitations * under the License. */ -export const OPTION_TYPES = { - metric: 'metric', - filter: 'filter', -}; + +/** + * All possible draggable items for the chart controls. + */ +export enum DndItemType { + // an existing column in table + column = 'column', + // a selected column option in ColumnSelectControl + columnOption = 'columnOption', + // an adhoc column option in ColumnSelectControl + adhocColumnOption = 'adhocColumn', + + // a saved metric + metric = 'metric', + // a selected saved metric in MetricsControl + metricOption = 'metricOption', + // an adhoc metric option in MetricsControl + adhocMetricOption = 'adhocMetric', + + // an adhoc filter option + filterOption = 'filterOption', +} Review comment: nit: I believe the common convention is to use PascalCase for enum names: https://www.typescriptlang.org/docs/handbook/enums.html ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
