rusackas commented on a change in pull request #10936: URL: https://github.com/apache/incubator-superset/pull/10936#discussion_r513081767
########## File path: superset-frontend/src/dashboard/components/FiltersBadge/selectors.ts ########## @@ -0,0 +1,161 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this 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 { isNil, get } from 'lodash'; +import { getChartIdsInFilterScope } from '../../util/activeDashboardFilters'; +import { TIME_FILTER_MAP } from '../../../visualizations/FilterBox/FilterBox'; + +export enum IndicatorStatus { + Unset = 'UNSET', + Applied = 'APPLIED', + Incompatible = 'INCOMPATIBLE', +} + +const TIME_GRANULARITY_FIELDS = new Set([ + TIME_FILTER_MAP.granularity, + TIME_FILTER_MAP.time_grain_sqla, +]); + +// As of 2020-09-28, the DatasourceMeta type in superset-ui is incorrect. +// Should patch it here until the DatasourceMeta type is updated. +type Datasource = { + time_grain_sqla?: [string, string][]; + granularity?: [string, string][]; +}; + +type Filter = { + chartId: number; + columns: { [key: string]: string | string[] }; + scopes: { [key: string]: any }; + labels: { [key: string]: string }; + isDateFilter: boolean; + directPathToFilter: string[]; + datasourceId: string; +}; + +const selectIndicatorValue = ( + columnKey: string, + filter: Filter, + datasource: Datasource, +): string[] => { + const values = filter.columns[columnKey]; + const arrValues = Array.isArray(values) ? values : [values]; + + if ( + isNil(values) || Review comment: ```suggestion values === null || ``` Doesn't seem like we need to bring lodash to the party for [just that](https://github.com/lodash/lodash/blob/ddfd9b11a0126db2302cb70ec9973b66baec0975/lodash.js#L11973). ---------------------------------------------------------------- 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]
