This is an automated email from the ASF dual-hosted git repository. tai pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push: new 619fbc9 fix: remove -1,-1 from owners request in charts, dashboards list and propertiesModal (#9989) 619fbc9 is described below commit 619fbc9557a18b231be212c5a4faefc254e63f04 Author: ʈᵃᵢ <tdupree...@gmail.com> AuthorDate: Thu Jun 4 15:31:42 2020 -0700 fix: remove -1,-1 from owners request in charts, dashboards list and propertiesModal (#9989) --- superset-frontend/src/components/ListView/Filters.tsx | 11 ++--------- superset-frontend/src/explore/components/PropertiesModal.tsx | 2 -- superset-frontend/src/views/chartList/ChartList.tsx | 11 ++++++++--- superset-frontend/src/views/dashboardList/DashboardList.tsx | 11 ++++++++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/superset-frontend/src/components/ListView/Filters.tsx b/superset-frontend/src/components/ListView/Filters.tsx index 69421d5..18380ee 100644 --- a/superset-frontend/src/components/ListView/Filters.tsx +++ b/superset-frontend/src/components/ListView/Filters.tsx @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -import React, { useState, useRef } from 'react'; +import React, { useState } from 'react'; import styled from '@superset-ui/style'; import { withTheme } from 'emotion-theming'; @@ -97,9 +97,6 @@ function SelectFilter({ }; const options = [clearFilterSelect, ...selects]; - const optionsCache: React.MutableRefObject<SelectOption[] | null> = useRef( - null, - ); const [selectedOption, setSelectedOption] = useState(clearFilterSelect); const onChange = (selected: SelectOption | null) => { @@ -110,11 +107,8 @@ function SelectFilter({ setSelectedOption(selected); }; const fetchAndFormatSelects = async (inputValue: string) => { - // only include clear filter when filter value exists + // only include clear filter when filter value does not exist let result = inputValue ? [] : [clearFilterSelect]; - // only call fetch once - // TODO: allow real async search with `inputValue` - if (optionsCache.current) return optionsCache.current; if (fetchSelects) { const selectValues = await fetchSelects(inputValue); // update matching option at initial load @@ -124,7 +118,6 @@ function SelectFilter({ } result = [...result, ...selectValues]; } - optionsCache.current = result; return result; }; diff --git a/superset-frontend/src/explore/components/PropertiesModal.tsx b/superset-frontend/src/explore/components/PropertiesModal.tsx index 622d5cf..b24b013 100644 --- a/superset-frontend/src/explore/components/PropertiesModal.tsx +++ b/superset-frontend/src/explore/components/PropertiesModal.tsx @@ -122,8 +122,6 @@ function PropertiesModal({ slice, onHide, onSave }: InternalProps) { const loadOptions = (input = '') => { const query = rison.encode({ filter: input, - page_index: -1, - page_size: -1, }); return SupersetClient.get({ endpoint: `/api/v1/chart/related/owners?q=${query}`, diff --git a/superset-frontend/src/views/chartList/ChartList.tsx b/superset-frontend/src/views/chartList/ChartList.tsx index 8fed532..569049d 100644 --- a/superset-frontend/src/views/chartList/ChartList.tsx +++ b/superset-frontend/src/views/chartList/ChartList.tsx @@ -364,13 +364,17 @@ class ChartList extends React.PureComponent<Props, State> { }); }; - fetchOwners = async (filterValue = '', pageIndex = -1, pageSize = -1) => { + fetchOwners = async ( + filterValue = '', + pageIndex?: number, + pageSize?: number, + ) => { const resource = '/api/v1/chart/related/owners'; try { const queryParams = rison.encode({ - page: pageIndex, - page_size: pageSize, + ...(pageIndex ? { page: pageIndex } : {}), + ...(pageSize ? { page_ize: pageSize } : {}), ...(filterValue ? { filter: filterValue } : {}), }); const { json = {} } = await SupersetClient.get({ @@ -384,6 +388,7 @@ class ChartList extends React.PureComponent<Props, State> { }), ); } catch (e) { + console.error(e); this.props.addDangerToast( t( 'An error occurred while fetching chart owner values: %s', diff --git a/superset-frontend/src/views/dashboardList/DashboardList.tsx b/superset-frontend/src/views/dashboardList/DashboardList.tsx index 829c6e3..0260895 100644 --- a/superset-frontend/src/views/dashboardList/DashboardList.tsx +++ b/superset-frontend/src/views/dashboardList/DashboardList.tsx @@ -389,13 +389,17 @@ class DashboardList extends React.PureComponent<Props, State> { }); }; - fetchOwners = async (filterValue = '', pageIndex = -1, pageSize = -1) => { + fetchOwners = async ( + filterValue = '', + pageIndex?: number, + pageSize?: number, + ) => { const resource = '/api/v1/dashboard/related/owners'; try { const queryParams = rison.encode({ - page: pageIndex, - page_size: pageSize, + ...(pageIndex ? { page: pageIndex } : {}), + ...(pageSize ? { page_ize: pageSize } : {}), ...(filterValue ? { filter: filterValue } : {}), }); const { json = {} } = await SupersetClient.get({ @@ -409,6 +413,7 @@ class DashboardList extends React.PureComponent<Props, State> { }), ); } catch (e) { + console.error(e); this.props.addDangerToast( t( 'An error occurred while fetching chart owner values: %s',