You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/05/24 09:25:42 UTC
[GitHub] [superset] simcha90 commented on a change in pull request #14710: feat(native-filters): add search all filter options
simcha90 commented on a change in pull request #14710:
URL: https://github.com/apache/superset/pull/14710#discussion_r637811109
##########
File path: superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
##########
@@ -18,31 +18,87 @@
*/
import {
AppSection,
+ DataMask,
ensureIsArray,
+ ExtraFormData,
GenericDataType,
+ JsonObject,
smartDateDetailedFormatter,
t,
tn,
} from '@superset-ui/core';
-import React, { useEffect, useState } from 'react';
+import React, { useEffect, useReducer, useState } from 'react';
import { Select } from 'src/common/components';
-import { FIRST_VALUE, PluginFilterSelectProps, SelectValue } from './types';
+import { debounce } from 'lodash';
+import { SLOW_DEBOUNCE } from 'src/constants';
+import { PluginFilterSelectProps, SelectValue } from './types';
import { StyledSelect, Styles } from '../common';
import { getDataRecordFormatter, getSelectExtraFormData } from '../../utils';
const { Option } = Select;
+const debouncedOwnStateFunc = debounce(
+ (dispatch: { (action: DataMaskAction): void }, val: string) => {
+ dispatch({
+ type: 'ownState',
+ ownState: {
+ search: val,
+ },
+ });
+ },
+ SLOW_DEBOUNCE,
+);
+
+type DataMaskAction =
+ | { type: 'ownState'; ownState: JsonObject }
+ | {
+ type: 'filterState';
+ extraFormData: ExtraFormData;
+ filterState: { value: SelectValue };
+ };
+
+function reducer(state: DataMask, action: DataMaskAction): DataMask {
+ switch (action.type) {
+ case 'ownState':
+ return {
+ ...state,
Review comment:
may be try to use here Immer, it should reduce code
--
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:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org