From 930a600b89710e1f34d63e88c62c26cdbc7fe687 Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Thu, 17 Mar 2022 16:37:30 -0400 Subject: [PATCH 1/8] add database search --- .../src/dashboard/actions/sliceEntities.js | 182 ++++++++++-------- .../src/dashboard/components/SliceAdder.jsx | 26 ++- .../src/dashboard/containers/SliceAdder.jsx | 4 +- 3 files changed, 128 insertions(+), 84 deletions(-) diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js b/superset-frontend/src/dashboard/actions/sliceEntities.js index 8fc85c9161ffd..f2d4c27b2ae42 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.js @@ -45,86 +45,112 @@ export function fetchAllSlices(userId, excludeFilterBox = false) { const { sliceEntities } = getState(); if (sliceEntities.lastUpdated === 0) { dispatch(fetchAllSlicesStarted()); - - return SupersetClient.get({ - endpoint: `/api/v1/chart/?q=${rison.encode({ - columns: [ - 'changed_on_delta_humanized', - 'changed_on_utc', - 'datasource_id', - 'datasource_type', - 'datasource_url', - 'datasource_name_text', - 'description_markeddown', - 'description', - 'id', - 'params', - 'slice_name', - 'url', - 'viz_type', - ], - filters: [{ col: 'owners', opr: 'rel_m_m', value: userId }], - page_size: FETCH_SLICES_PAGE_SIZE, - order_column: 'changed_on_delta_humanized', - order_direction: 'desc', - })}`, - }) - .then(({ json }) => { - const slices = {}; - let { result } = json; - // disable add filter_box viz to dashboard - if (excludeFilterBox) { - result = result.filter(slice => slice.viz_type !== 'filter_box'); - } - result.forEach(slice => { - let form_data = JSON.parse(slice.params); - form_data = { - ...form_data, - // force using datasource stored in relational table prop - datasource: - getDatasourceParameter( - slice.datasource_id, - slice.datasource_type, - ) || form_data.datasource, - }; - slices[slice.id] = { - slice_id: slice.id, - slice_url: slice.url, - slice_name: slice.slice_name, - form_data, - datasource_name: slice.datasource_name_text, - datasource_url: slice.datasource_url, - datasource_id: slice.datasource_id, - datasource_type: slice.datasource_type, - changed_on: new Date(slice.changed_on_utc).getTime(), - description: slice.description, - description_markdown: slice.description_markeddown, - viz_type: slice.viz_type, - modified: slice.changed_on_delta_humanized, - changed_on_humanized: slice.changed_on_delta_humanized, - }; - }); - - return dispatch(setAllSlices(slices)); - }) - .catch( - errorResponse => - console.log(errorResponse) || - getClientErrorObject(errorResponse).then(({ error }) => { - dispatch( - fetchAllSlicesFailed( - error || t('Could not fetch all saved charts'), - ), - ); - dispatch( - addDangerToast( - t('Sorry there was an error fetching saved charts: ') + error, - ), - ); - }), - ); + return fetchSlices(userId, excludeFilterBox, dispatch, undefined); } return dispatch(setAllSlices(sliceEntities.slices)); }; } + +export function fetchSortedSlices(userId, excludeFilterBox = false, order_column) { + return (dispatch) => { + dispatch(fetchAllSlicesStarted()); + return fetchSlices(userId, excludeFilterBox, dispatch, undefined, order_column); + } +} + +export function fetchFilteredSlices(userId, excludeFilterBox = false, filter_value) { + return (dispatch, getState) => { + dispatch(fetchAllSlicesStarted()); + const { sliceEntities } = getState(); + return fetchSlices(userId, excludeFilterBox, dispatch, filter_value, undefined, sliceEntities.slices); + } +} + +function fetchSlices(userId, excludeFilterBox, dispatch, filter_value, sortColumn = 'changed_on_delta_humanized', slices = {}) { + const additional_filters = filter_value ? [ + { col: 'slice_name', opr: 'sw', value: filter_value }, + { col: 'viz_type', opr: 'sw', value: filter_value }, + { col: 'datasource_name', opr: 'sw', value: filter_value }, + ] : []; + + return SupersetClient.get({ + endpoint: `/api/v1/chart/?q=${rison.encode({ + columns: [ + 'changed_on_delta_humanized', + 'changed_on_utc', + 'datasource_id', + 'datasource_type', + 'datasource_url', + 'datasource_name_text', + 'description_markeddown', + 'description', + 'id', + 'params', + 'slice_name', + 'url', + 'viz_type', + ], + filters: [ + { col: 'owners', opr: 'rel_m_m', value: userId }, + ...additional_filters + ], + page_size: FETCH_SLICES_PAGE_SIZE, + order_column: sortColumn == 'changed_on' ? 'changed_on_delta_humanized' : sortColumn, + order_direction: sortColumn == 'changed_on' ? 'desc' : 'asc', + })}`, + }) + .then(({ json }) => { + let { result } = json; + // disable add filter_box viz to dashboard + if (excludeFilterBox) { + result = result.filter(slice => slice.viz_type !== 'filter_box'); + } + result.forEach(slice => { + let form_data = JSON.parse(slice.params); + form_data = { + ...form_data, + // force using datasource stored in relational table prop + datasource: + getDatasourceParameter( + slice.datasource_id, + slice.datasource_type, + ) || form_data.datasource, + }; + slices[slice.id] = { + slice_id: slice.id, + slice_url: slice.url, + slice_name: slice.slice_name, + form_data, + datasource_name: slice.datasource_name_text, + datasource_url: slice.datasource_url, + datasource_id: slice.datasource_id, + datasource_type: slice.datasource_type, + changed_on: new Date(slice.changed_on_utc).getTime(), + description: slice.description, + description_markdown: slice.description_markeddown, + viz_type: slice.viz_type, + modified: slice.changed_on_delta_humanized, + changed_on_humanized: slice.changed_on_delta_humanized, + }; + }); + + return dispatch(setAllSlices(slices)); + }) + .catch( + errorResponse => + console.log(errorResponse) || + getClientErrorObject(errorResponse).then(({ error }) => { + dispatch( + fetchAllSlicesFailed( + error || t('Could not fetch all saved charts'), + ), + ); + dispatch( + addDangerToast( + t('Sorry there was an error fetching saved charts: ') + error, + ), + ); + }), + ); +} \ No newline at end of file diff --git a/superset-frontend/src/dashboard/components/SliceAdder.jsx b/superset-frontend/src/dashboard/components/SliceAdder.jsx index 8c2fc920e9b20..dbe359a521457 100644 --- a/superset-frontend/src/dashboard/components/SliceAdder.jsx +++ b/superset-frontend/src/dashboard/components/SliceAdder.jsx @@ -38,6 +38,7 @@ import { FILTER_BOX_MIGRATION_STATES } from 'src/explore/constants'; import AddSliceCard from './AddSliceCard'; import AddSliceDragPreview from './dnd/AddSliceDragPreview'; import DragDroppable from './dnd/DragDroppable'; +import _ from 'lodash'; const propTypes = { fetchAllSlices: PropTypes.func.isRequired, @@ -112,7 +113,6 @@ class SliceAdder extends React.Component { this.rowRenderer = this.rowRenderer.bind(this); this.searchUpdated = this.searchUpdated.bind(this); this.handleKeyPress = this.handleKeyPress.bind(this); - this.handleChange = this.handleChange.bind(this); this.handleSelect = this.handleSelect.bind(this); } @@ -162,9 +162,17 @@ class SliceAdder extends React.Component { } } - handleChange(ev) { - this.searchUpdated(ev.target.value); - } + handleChange = _.debounce((value) => { + this.searchUpdated(value); + + const { userId, filterboxMigrationState } = this.props; + this.slicesRequest = this.props.fetchFilteredSlices( + userId, + isFeatureEnabled(FeatureFlag.ENABLE_FILTER_BOX_MIGRATION) && + filterboxMigrationState !== FILTER_BOX_MIGRATION_STATES.SNOOZED, + value, + ); + }, 300) searchUpdated(searchTerm) { this.setState(prevState => ({ @@ -184,6 +192,14 @@ class SliceAdder extends React.Component { sortBy, ), })); + + const { userId, filterboxMigrationState } = this.props; + this.slicesRequest = this.props.fetchSortedSlices( + userId, + isFeatureEnabled(FeatureFlag.ENABLE_FILTER_BOX_MIGRATION) && + filterboxMigrationState !== FILTER_BOX_MIGRATION_STATES.SNOOZED, + sortBy, + ); } rowRenderer({ key, index, style }) { @@ -244,7 +260,7 @@ class SliceAdder extends React.Component { this.handleChange(ev.target.value)} onKeyPress={this.handleKeyPress} data-test="dashboard-charts-filter-search-input" /> diff --git a/superset-frontend/src/dashboard/containers/SliceAdder.jsx b/superset-frontend/src/dashboard/containers/SliceAdder.jsx index 8c02a4a360e7f..01b50ec2b26c5 100644 --- a/superset-frontend/src/dashboard/containers/SliceAdder.jsx +++ b/superset-frontend/src/dashboard/containers/SliceAdder.jsx @@ -19,7 +19,7 @@ import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import { fetchAllSlices } from '../actions/sliceEntities'; +import { fetchAllSlices, fetchSortedSlices, fetchFilteredSlices } from '../actions/sliceEntities'; import SliceAdder from '../components/SliceAdder'; function mapStateToProps( @@ -43,6 +43,8 @@ function mapDispatchToProps(dispatch) { return bindActionCreators( { fetchAllSlices, + fetchSortedSlices, + fetchFilteredSlices, }, dispatch, ); From 44e68a716b91bcea865735609cabc85460b1a0b0 Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Fri, 18 Mar 2022 14:00:09 -0400 Subject: [PATCH 2/8] resolve lint issue --- .../src/dashboard/actions/sliceEntities.js | 96 +++++++++++++------ 1 file changed, 66 insertions(+), 30 deletions(-) diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js b/superset-frontend/src/dashboard/actions/sliceEntities.js index f2d4c27b2ae42..d6291ff10d067 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.js @@ -39,35 +39,14 @@ export function fetchAllSlicesFailed(error) { return { type: FETCH_ALL_SLICES_FAILED, payload: { error } }; } -const FETCH_SLICES_PAGE_SIZE = 200; -export function fetchAllSlices(userId, excludeFilterBox = false) { - return (dispatch, getState) => { - const { sliceEntities } = getState(); - if (sliceEntities.lastUpdated === 0) { - dispatch(fetchAllSlicesStarted()); - return fetchSlices(userId, excludeFilterBox, dispatch, undefined); - } - - return dispatch(setAllSlices(sliceEntities.slices)); - }; -} - -export function fetchSortedSlices(userId, excludeFilterBox = false, order_column) { - return (dispatch) => { - dispatch(fetchAllSlicesStarted()); - return fetchSlices(userId, excludeFilterBox, dispatch, undefined, order_column); - } -} - -export function fetchFilteredSlices(userId, excludeFilterBox = false, filter_value) { - return (dispatch, getState) => { - dispatch(fetchAllSlicesStarted()); - const { sliceEntities } = getState(); - return fetchSlices(userId, excludeFilterBox, dispatch, filter_value, undefined, sliceEntities.slices); - } -} - -function fetchSlices(userId, excludeFilterBox, dispatch, filter_value, sortColumn = 'changed_on_delta_humanized', slices = {}) { +function fetchSlices( + userId, + excludeFilterBox, + dispatch, + filter_value, + sortColumn = 'changed_on_delta_humanized', + slices = {} +) { const additional_filters = filter_value ? [ { col: 'slice_name', opr: 'sw', value: filter_value }, { col: 'viz_type', opr: 'sw', value: filter_value }, @@ -153,4 +132,61 @@ function fetchSlices(userId, excludeFilterBox, dispatch, filter_value, sortColum ); }), ); -} \ No newline at end of file +} + +const FETCH_SLICES_PAGE_SIZE = 200; +export function fetchAllSlices( + userId, + excludeFilterBox = false +) { + return (dispatch, getState) => { + const { sliceEntities } = getState(); + if (sliceEntities.lastUpdated === 0) { + dispatch(fetchAllSlicesStarted()); + return fetchSlices( + userId, + excludeFilterBox, + dispatch, + undefined + ); + } + + return dispatch(setAllSlices(sliceEntities.slices)); + }; +} + +export function fetchSortedSlices( + userId, + excludeFilterBox = false, + order_column +) { + return dispatch => { + dispatch(fetchAllSlicesStarted()); + return fetchSlices( + userId, + excludeFilterBox, + dispatch, + undefined, + order_column + ); + } +} + +export function fetchFilteredSlices( + userId, + excludeFilterBox = false, + filter_value +) { + return (dispatch, getState) => { + dispatch(fetchAllSlicesStarted()); + const { sliceEntities } = getState(); + return fetchSlices( + userId, + excludeFilterBox, + dispatch, + filter_value, + undefined, + sliceEntities.slices + ); + } +} From def0b326f690c7271b03dc66da771f67097f6a76 Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Wed, 4 May 2022 16:47:40 -0400 Subject: [PATCH 3/8] add test for sliceEntities actions --- .../src/dashboard/actions/sliceEntities.js | 82 +++++++++--------- .../dashboard/actions/sliceEntities.test.js | 84 +++++++++++++++++++ 2 files changed, 122 insertions(+), 44 deletions(-) create mode 100644 superset-frontend/src/dashboard/actions/sliceEntities.test.js diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js b/superset-frontend/src/dashboard/actions/sliceEntities.js index d6291ff10d067..666b9947e0b2f 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.js @@ -25,6 +25,8 @@ import { getDatasourceParameter } from 'src/modules/utils'; import { getClientErrorObject } from 'src/utils/getClientErrorObject'; export const SET_ALL_SLICES = 'SET_ALL_SLICES'; +const FETCH_SLICES_PAGE_SIZE = 200; + export function setAllSlices(slices) { return { type: SET_ALL_SLICES, payload: { slices } }; } @@ -39,19 +41,23 @@ export function fetchAllSlicesFailed(error) { return { type: FETCH_ALL_SLICES_FAILED, payload: { error } }; } -function fetchSlices( +export function fetchSlices( userId, excludeFilterBox, dispatch, filter_value, sortColumn = 'changed_on_delta_humanized', - slices = {} + slices = {}, ) { - const additional_filters = filter_value ? [ - { col: 'slice_name', opr: 'sw', value: filter_value }, - { col: 'viz_type', opr: 'sw', value: filter_value }, - { col: 'datasource_name', opr: 'sw', value: filter_value }, - ] : []; + const additional_filters = filter_value + ? [ + { col: 'slice_name', opr: 'sw', value: filter_value }, + { col: 'viz_type', opr: 'sw', value: filter_value }, + { col: 'datasource_name', opr: 'sw', value: filter_value }, + ] + : []; + + const cloneSlices = { ...slices }; return SupersetClient.get({ endpoint: `/api/v1/chart/?q=${rison.encode({ @@ -72,11 +78,12 @@ function fetchSlices( ], filters: [ { col: 'owners', opr: 'rel_m_m', value: userId }, - ...additional_filters + ...additional_filters, ], page_size: FETCH_SLICES_PAGE_SIZE, - order_column: sortColumn == 'changed_on' ? 'changed_on_delta_humanized' : sortColumn, - order_direction: sortColumn == 'changed_on' ? 'desc' : 'asc', + order_column: + sortColumn === 'changed_on' ? 'changed_on_delta_humanized' : sortColumn, + order_direction: sortColumn === 'changed_on' ? 'desc' : 'asc', })}`, }) .then(({ json }) => { @@ -96,7 +103,7 @@ function fetchSlices( slice.datasource_type, ) || form_data.datasource, }; - slices[slice.id] = { + cloneSlices[slice.id] = { slice_id: slice.id, slice_url: slice.url, slice_name: slice.slice_name, @@ -114,41 +121,28 @@ function fetchSlices( }; }); - return dispatch(setAllSlices(slices)); + return dispatch(setAllSlices(cloneSlices)); }) - .catch( - errorResponse => - console.log(errorResponse) || - getClientErrorObject(errorResponse).then(({ error }) => { - dispatch( - fetchAllSlicesFailed( - error || t('Could not fetch all saved charts'), - ), - ); - dispatch( - addDangerToast( - t('Sorry there was an error fetching saved charts: ') + error, - ), - ); - }), + .catch(errorResponse => + getClientErrorObject(errorResponse).then(({ error }) => { + dispatch( + fetchAllSlicesFailed(error || t('Could not fetch all saved charts')), + ); + dispatch( + addDangerToast( + t('Sorry there was an error fetching saved charts: ') + error, + ), + ); + }), ); } -const FETCH_SLICES_PAGE_SIZE = 200; -export function fetchAllSlices( - userId, - excludeFilterBox = false -) { +export function fetchAllSlices(userId, excludeFilterBox = false) { return (dispatch, getState) => { const { sliceEntities } = getState(); if (sliceEntities.lastUpdated === 0) { dispatch(fetchAllSlicesStarted()); - return fetchSlices( - userId, - excludeFilterBox, - dispatch, - undefined - ); + return fetchSlices(userId, excludeFilterBox, dispatch, undefined); } return dispatch(setAllSlices(sliceEntities.slices)); @@ -158,7 +152,7 @@ export function fetchAllSlices( export function fetchSortedSlices( userId, excludeFilterBox = false, - order_column + order_column, ) { return dispatch => { dispatch(fetchAllSlicesStarted()); @@ -167,15 +161,15 @@ export function fetchSortedSlices( excludeFilterBox, dispatch, undefined, - order_column + order_column, ); - } + }; } export function fetchFilteredSlices( userId, excludeFilterBox = false, - filter_value + filter_value, ) { return (dispatch, getState) => { dispatch(fetchAllSlicesStarted()); @@ -186,7 +180,7 @@ export function fetchFilteredSlices( dispatch, filter_value, undefined, - sliceEntities.slices + sliceEntities.slices, ); - } + }; } diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.test.js b/superset-frontend/src/dashboard/actions/sliceEntities.test.js new file mode 100644 index 0000000000000..2925afcbb66e5 --- /dev/null +++ b/superset-frontend/src/dashboard/actions/sliceEntities.test.js @@ -0,0 +1,84 @@ +import sinon from 'sinon'; +import { SupersetClient } from '@superset-ui/core'; + +import { + FETCH_ALL_SLICES_STARTED, + fetchSortedSlices, + fetchFilteredSlices, + fetchAllSlices, +} from './sliceEntities'; + +describe('slice entity actions', () => { + const mockState = { + sliceEntities: { slices: {} }, + isLoading: true, + errorMessage: null, + lastUpdated: 0, + }; + + function setup(stateOverrides) { + const state = { ...mockState, ...stateOverrides }; + const getState = sinon.spy(() => state); + const dispatch = sinon.spy(); + + return { getState, dispatch, state }; + } + + let spy; + + beforeEach(() => { + spy = sinon.spy(SupersetClient); + }); + + afterEach(() => { + sinon.restore(); + }); + + describe('fetchSortedSlices', () => { + it('should dispatch an fetchAllSlicesStarted action', async () => { + const { dispatch } = setup(); + const thunk1 = fetchSortedSlices('userId', false, 'orderColumn'); + await thunk1(dispatch); + expect(dispatch.getCall(0).args[0]).toEqual({ + type: FETCH_ALL_SLICES_STARTED, + }); + expect(spy.get.callCount).toBe(1); + }); + }); + + describe('fetchFilteredSlices', () => { + it('should dispatch an fetchAllSlicesStarted action', async () => { + const { dispatch, getState } = setup(); + const thunk1 = fetchFilteredSlices('userId', false, 'filter_value'); + await thunk1(dispatch, getState); + expect(dispatch.getCall(0).args[0]).toEqual({ + type: FETCH_ALL_SLICES_STARTED, + }); + expect(spy.get.callCount).toBe(1); + }); + }); + + describe('fetchAllSlices', () => { + it('should not trigger fetchSlices when sliceEntities lastUpdate is not 0', async () => { + const { dispatch, getState } = setup({ + sliceEntities: { slices: {}, lastUpdated: 1 }, + }); + + const thunk1 = fetchAllSlices('userId', false, 'filter_value'); + await thunk1(dispatch, getState); + + expect(spy.get.callCount).toBe(0); + }); + + it('should trigger fetchSlices when sliceEntities lastUpdate is 0', async () => { + const { dispatch, getState } = setup({ + sliceEntities: { slices: {}, lastUpdated: 0 }, + }); + + const thunk1 = fetchAllSlices('userId', false, 'filter_value'); + await thunk1(dispatch, getState); + + expect(spy.get.callCount).toBe(1); + }); + }); +}); From c3474a1e40d9390d727b80e8df9385e214302d02 Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Thu, 5 May 2022 17:00:53 -0400 Subject: [PATCH 4/8] fix lint issue --- superset-frontend/src/dashboard/components/SliceAdder.jsx | 8 ++++---- superset-frontend/src/dashboard/containers/SliceAdder.jsx | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/superset-frontend/src/dashboard/components/SliceAdder.jsx b/superset-frontend/src/dashboard/components/SliceAdder.jsx index dbe359a521457..c665d4d157ee0 100644 --- a/superset-frontend/src/dashboard/components/SliceAdder.jsx +++ b/superset-frontend/src/dashboard/components/SliceAdder.jsx @@ -35,10 +35,10 @@ import { } from 'src/dashboard/util/constants'; import { slicePropShape } from 'src/dashboard/util/propShapes'; import { FILTER_BOX_MIGRATION_STATES } from 'src/explore/constants'; +import _ from 'lodash'; import AddSliceCard from './AddSliceCard'; import AddSliceDragPreview from './dnd/AddSliceDragPreview'; import DragDroppable from './dnd/DragDroppable'; -import _ from 'lodash'; const propTypes = { fetchAllSlices: PropTypes.func.isRequired, @@ -162,7 +162,7 @@ class SliceAdder extends React.Component { } } - handleChange = _.debounce((value) => { + handleChange = _.debounce(value => { this.searchUpdated(value); const { userId, filterboxMigrationState } = this.props; @@ -172,7 +172,7 @@ class SliceAdder extends React.Component { filterboxMigrationState !== FILTER_BOX_MIGRATION_STATES.SNOOZED, value, ); - }, 300) + }, 300); searchUpdated(searchTerm) { this.setState(prevState => ({ @@ -260,7 +260,7 @@ class SliceAdder extends React.Component { this.handleChange(ev.target.value)} + onChange={ev => this.handleChange(ev.target.value)} onKeyPress={this.handleKeyPress} data-test="dashboard-charts-filter-search-input" /> diff --git a/superset-frontend/src/dashboard/containers/SliceAdder.jsx b/superset-frontend/src/dashboard/containers/SliceAdder.jsx index 01b50ec2b26c5..2db7e93f7394d 100644 --- a/superset-frontend/src/dashboard/containers/SliceAdder.jsx +++ b/superset-frontend/src/dashboard/containers/SliceAdder.jsx @@ -19,7 +19,11 @@ import { bindActionCreators } from 'redux'; import { connect } from 'react-redux'; -import { fetchAllSlices, fetchSortedSlices, fetchFilteredSlices } from '../actions/sliceEntities'; +import { + fetchAllSlices, + fetchSortedSlices, + fetchFilteredSlices, +} from '../actions/sliceEntities'; import SliceAdder from '../components/SliceAdder'; function mapStateToProps( From 622528a640428d9dd1ca35eae7ea7c79a1c0c7aa Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Thu, 5 May 2022 17:03:42 -0400 Subject: [PATCH 5/8] add licence into test --- .../dashboard/actions/sliceEntities.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.test.js b/superset-frontend/src/dashboard/actions/sliceEntities.test.js index 2925afcbb66e5..0fe9365fc9d1c 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.test.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.test.js @@ -1,3 +1,21 @@ +/** + * 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 sinon from 'sinon'; import { SupersetClient } from '@superset-ui/core'; From 2ba3b0db75bc62ba8b868106793a7b8d3fb73f0b Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Thu, 12 May 2022 15:27:03 -0400 Subject: [PATCH 6/8] fix pipeline broken --- superset-frontend/src/dashboard/components/SliceAdder.test.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/superset-frontend/src/dashboard/components/SliceAdder.test.jsx b/superset-frontend/src/dashboard/components/SliceAdder.test.jsx index 16703d0505ce5..7bfd971cb7f1a 100644 --- a/superset-frontend/src/dashboard/components/SliceAdder.test.jsx +++ b/superset-frontend/src/dashboard/components/SliceAdder.test.jsx @@ -36,6 +36,7 @@ describe('SliceAdder', () => { const props = { ...mockSliceEntities, fetchAllSlices: () => {}, + fetchSortedSlices: () => {}, selectedSliceIds: [127, 128], userId: '1', height: 100, From 1b2e8f4c03dfc93f3fde7f60f979274457da93a3 Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Tue, 28 Jun 2022 15:24:23 -0400 Subject: [PATCH 7/8] fix sort by recent --- superset-frontend/src/dashboard/actions/sliceEntities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js b/superset-frontend/src/dashboard/actions/sliceEntities.js index b8352a33c04b8..cd7f01776a26c 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.js @@ -49,7 +49,7 @@ export function fetchSlices( excludeFilterBox, dispatch, filter_value, - sortColumn = 'changed_on_delta_humanized', + sortColumn = 'changed_on', slices = {}, ) { const additional_filters = filter_value From 1bd41051bb2ab69e881712e41f756be2629f69cb Mon Sep 17 00:00:00 2001 From: SpiderMan Date: Fri, 1 Jul 2022 13:35:14 -0400 Subject: [PATCH 8/8] resolve comment --- superset-frontend/src/dashboard/actions/sliceEntities.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/superset-frontend/src/dashboard/actions/sliceEntities.js b/superset-frontend/src/dashboard/actions/sliceEntities.js index cd7f01776a26c..176b84fa2b8cb 100644 --- a/superset-frontend/src/dashboard/actions/sliceEntities.js +++ b/superset-frontend/src/dashboard/actions/sliceEntities.js @@ -53,11 +53,7 @@ export function fetchSlices( slices = {}, ) { const additional_filters = filter_value - ? [ - { col: 'slice_name', opr: 'sw', value: filter_value }, - { col: 'viz_type', opr: 'sw', value: filter_value }, - { col: 'datasource_name', opr: 'sw', value: filter_value }, - ] + ? [{ col: 'slice_name', opr: 'chart_all_text', value: filter_value }] : []; const cloneSlices = { ...slices };