michael-s-molina commented on code in PR #20466: URL: https://github.com/apache/superset/pull/20466#discussion_r906098957
########## superset-frontend/src/components/Select/AsyncSelect.tsx: ########## @@ -0,0 +1,739 @@ +/** + * 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 React, { + forwardRef, + ReactElement, + ReactNode, + RefObject, + UIEvent, + useEffect, + useMemo, + useState, + useRef, + useCallback, +} from 'react'; +import { ensureIsArray, styled, t } from '@superset-ui/core'; +import AntdSelect, { + SelectProps as AntdSelectProps, + SelectValue as AntdSelectValue, + LabeledValue as AntdLabeledValue, +} from 'antd/lib/select'; +import { DownOutlined, SearchOutlined } from '@ant-design/icons'; +import { Spin } from 'antd'; +import debounce from 'lodash/debounce'; +import { isEqual } from 'lodash'; +import Icons from 'src/components/Icons'; +import { getClientErrorObject } from 'src/utils/getClientErrorObject'; +import { SLOW_DEBOUNCE } from 'src/constants'; +import { rankedSearchCompare } from 'src/utils/rankedSearchCompare'; +import { getValue, hasOption, isLabeledValue } from './utils'; + +const { Option } = AntdSelect; + +type AntdSelectAllProps = AntdSelectProps<AntdSelectValue>; + +type PickedSelectProps = Pick< + AntdSelectAllProps, + | 'allowClear' + | 'autoFocus' + | 'disabled' + | 'filterOption' + | 'labelInValue' + | 'loading' + | 'notFoundContent' + | 'onChange' + | 'onClear' + | 'onFocus' + | 'onBlur' + | 'onDropdownVisibleChange' + | 'placeholder' + | 'showSearch' + | 'tokenSeparators' + | 'value' +>; + +export type OptionsType = Exclude<AntdSelectAllProps['options'], undefined>; + +export type OptionsTypePage = { + data: OptionsType; + totalCount: number; +}; + +export type OptionsPagePromise = ( + search: string, + page: number, + pageSize: number, +) => Promise<OptionsTypePage>; + +export type AsyncSelectRef = HTMLInputElement & { clearCache: () => void }; + + Review Comment: ```suggestion ``` ########## superset-frontend/src/components/Datasource/DatasourceEditor.jsx: ########## @@ -47,6 +47,7 @@ import Icons from 'src/components/Icons'; import CollectionTable from './CollectionTable'; import Fieldset from './Fieldset'; import Field from './Field'; +import AsyncSelect from '../AsyncSelect'; Review Comment: ```suggestion ``` ########## superset-frontend/src/components/Select/Select.test.tsx: ########## @@ -413,26 +413,26 @@ test('adds the null option when selected in multiple mode', async () => { expect(values[1]).toHaveTextContent(NULL_OPTION.label); }); -test('static - renders the select with default props', () => { Review Comment: `RefObject` and `SelectRef` imports are not being used. ########## superset-frontend/src/components/Select/Select.stories.tsx: ########## @@ -19,6 +19,7 @@ import React, { ReactNode, useState, useCallback, useRef } from 'react'; import Button from 'src/components/Button'; import ControlHeader from 'src/explore/components/ControlHeader'; +import AsyncSelect, { AsyncSelectProps, AsyncSelectRef } from './AsyncSelect'; Review Comment: You need to remove the old `SelectRef` import to prevent the import warning. ########## superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx: ########## @@ -58,6 +58,7 @@ import { import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls'; import { AlertReportCronScheduler } from './components/AlertReportCronScheduler'; import { NotificationMethod } from './components/NotificationMethod'; +import { AsyncSelect } from 'src/components'; Review Comment: There's another import above from `src/components`. To fix the lint error: `import { AntdCheckbox, AsyncSelect } from 'src/components';` -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
