eschutho commented on a change in pull request #11861: URL: https://github.com/apache/incubator-superset/pull/11861#discussion_r534390078
########## File path: superset-frontend/src/SqlLab/components/SaveDatasetModal.tsx ########## @@ -0,0 +1,183 @@ +/** + * 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, { useState, FunctionComponent } from 'react'; +import { Radio, AutoComplete, Input } from 'src/common/components'; +import StyledModal from 'src/common/components/Modal'; +import Button from 'src/components/Button'; +import { styled } from '@superset-ui/core'; +import { RadioChangeEvent } from 'antd/lib/radio'; + +interface SaveDatasetModalProps { + visible: boolean; + onOk: () => void; + onHide: () => void; + handleDatasetNameChange: (e: { target: { value: any } }) => void; + userDatasetsOwned: Array<Record<string, any>>; + handleSaveDatasetRadioBtnState: (e: RadioChangeEvent) => void; + saveDatasetRadioBtnState: number; + overwriteDataSet: boolean; + handleOverwriteCancel: () => void; + handleOverwriteDataset: () => void; + handleOverwriteDatasetOption: ( + data: string, + option: Record<string, any>, + ) => void; + defaultCreateDatasetValue: string; +} + +const Styles = styled.div` + .smd-input { + margin-left: 45px; + width: 290px; + } + .smd-autocomplete { + margin-left: 8px; + width: 290px; + } + .smd-radio { + display: block; + height: 30px; + margin: 10px 0px; + line-height: 30px; + } +`; + +// eslint-disable-next-line no-empty-pattern +export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({ + visible, + onOk, + onHide, + handleDatasetNameChange, + userDatasetsOwned, + handleSaveDatasetRadioBtnState, + saveDatasetRadioBtnState, + overwriteDataSet, + handleOverwriteCancel, + handleOverwriteDataset, + handleOverwriteDatasetOption, + defaultCreateDatasetValue, +}) => { + const [options, setOptions] = useState< + { + value: string; + dataSetId: number; + }[] + >([]); + + const onSearch = (searchText: any) => { + setOptions( + !searchText + ? [] + : userDatasetsOwned.map(d => ({ + value: d.dataSetName, + dataSetId: d.dataSetId, + })), + ); + }; + + const filterAutocompleteOption = ( + inputValue: string, + option: { [key: string]: any } | any, Review comment: yeah, exactly, `any` basically undoes the `{ [key: string]: any }` validation. If you want to allow someone to pass an array, then cool, but if you want to allow null or undefined, that would be better to be explicit that those are the types that you expect. ---------------------------------------------------------------- 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]
