eschutho commented on code in PR #19855: URL: https://github.com/apache/superset/pull/19855#discussion_r863282371
########## superset-frontend/src/SqlLab/components/SaveDatasetModal/index.tsx: ########## @@ -74,96 +79,290 @@ const Styles = styled.div` } `; +const updateDataset = async ( + dbId: number, + datasetId: number, + sql: string, + columns: Array<Record<string, any>>, + owners: [number], + overrideColumns: boolean, +) => { + const endpoint = `api/v1/dataset/${datasetId}?override_columns=${overrideColumns}`; + const headers = { 'Content-Type': 'application/json' }; + const body = JSON.stringify({ + sql, + columns, + owners, + database_id: dbId, + }); + + const data: JsonResponse = await SupersetClient.put({ + endpoint, + headers, + body, + }); + return data.json.result; +}; + // eslint-disable-next-line no-empty-pattern export const SaveDatasetModal: FunctionComponent<SaveDatasetModalProps> = ({ visible, - onOk, onHide, - handleDatasetNameChange, - handleSaveDatasetRadioBtnState, - saveDatasetRadioBtnState, - shouldOverwriteDataset, - handleOverwriteCancel, - handleOverwriteDataset, - handleOverwriteDatasetOption, - defaultCreateDatasetValue, - disableSaveAndExploreBtn, - handleSaveDatasetModalSearch, - filterAutocompleteOption, - userDatasetOptions, - onChangeAutoComplete, -}) => ( - <StyledModal - show={visible} - title="Save or Overwrite Dataset" - onHide={onHide} - footer={ - <> - {!shouldOverwriteDataset && ( - <Button - disabled={disableSaveAndExploreBtn} - buttonStyle="primary" - onClick={onOk} - > - {t('Save & Explore')} - </Button> - )} - {shouldOverwriteDataset && ( - <> - <Button onClick={handleOverwriteCancel}>Back</Button> + buttonTextOnSave, + buttonTextOnOverwrite, + modalDescription, + datasource, + user, + query, + actions, +}) => { + const getDefaultDatasetName = () => + `${query?.tab || datasource?.sl_dataset?.query.tab} ${moment().format( + 'MM/DD/YYYY HH:mm:ss', + )}`; + + const [newSaveDatasetName, setNewSaveDatasetName] = useState( + getDefaultDatasetName(), + ); + const [saveDatasetRadioBtnState, setSaveDatasetRadioBtnState] = useState( Review Comment: might be more explicit to name this as to what the radio button does, too. -- 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: notifications-unsubscr...@superset.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org