From bcbb308ad562c5f07ce1d3d7cdc39830b7f77cd7 Mon Sep 17 00:00:00 2001 From: omerfbolat Date: Fri, 19 Jan 2024 10:52:07 +0300 Subject: [PATCH] fix: dashboard list api for selects redux changes fixed --- .../components/DvtSidebar/dvtSidebarData.ts | 22 +++++--------- .../src/pages/DvtDashboardList/index.tsx | 30 ++++++++++++++----- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/superset-frontend/src/components/DvtSidebar/dvtSidebarData.ts b/superset-frontend/src/components/DvtSidebar/dvtSidebarData.ts index 55582acfdb9cc..eea9c1bcfe517 100644 --- a/superset-frontend/src/components/DvtSidebar/dvtSidebarData.ts +++ b/superset-frontend/src/components/DvtSidebar/dvtSidebarData.ts @@ -450,41 +450,35 @@ const DvtSidebarData: SidebarDataProps[] = [ pathname: '/dashboard/list/', data: [ { - values: [ - { label: 'Failed', value: 'failed' }, - { label: 'Success', value: 'success' }, - ], + values: [], placeholder: 'Owner', name: 'owner', }, { - values: [ - { label: 'Failed', value: 'failed' }, - { label: 'Success', value: 'success' }, - ], + values: [], placeholder: 'Created by', name: 'createdBy', }, { values: [ - { label: 'Failed', value: 'failed' }, - { label: 'Success', value: 'success' }, + { label: 'Published', value: '!t' }, + { label: 'Draft', value: '!f' }, ], placeholder: 'Status', name: 'status', }, { values: [ - { label: 'Failed', value: 'failed' }, - { label: 'Success', value: 'success' }, + { label: 'Yes', value: '!t' }, + { label: 'No', value: '!f' }, ], placeholder: 'Favorite', name: 'favorite', }, { values: [ - { label: 'Failed', value: 'failed' }, - { label: 'Success', value: 'success' }, + { label: 'Yes', value: '!t' }, + { label: 'No', value: '!f' }, ], placeholder: 'Certified', name: 'certified', diff --git a/superset-frontend/src/pages/DvtDashboardList/index.tsx b/superset-frontend/src/pages/DvtDashboardList/index.tsx index b7ab6e8bd10f0..09b36e79fc46b 100644 --- a/superset-frontend/src/pages/DvtDashboardList/index.tsx +++ b/superset-frontend/src/pages/DvtDashboardList/index.tsx @@ -19,6 +19,7 @@ import React, { useEffect, useState } from 'react'; import { useHistory } from 'react-router-dom'; +import { useAppSelector } from 'src/hooks/useAppSelector'; import useFetch from 'src/hooks/useFetch'; import DvtButton from 'src/components/DvtButton'; import DvtPagination from 'src/components/DvtPagination'; @@ -82,6 +83,7 @@ const headerData = [ function DvtDashboardList() { const history = useHistory<{ from: string }>(); + const dashboardSelector = useAppSelector(state => state.dvtSidebar.dashboard); const [selectedRows, setSelectedRows] = useState([]); const [currentPage, setCurrentPage] = useState(1); @@ -91,22 +93,36 @@ function DvtDashboardList() { const searchApiUrl = () => { const filterData = [ { col: 'dashboard_title', opr: 'title_or_slug', value: '' }, - { col: 'owners', opr: 'rel_m_m', value: '' }, - { col: 'created_by', opr: 'rel_m_m', value: '' }, - { col: 'published', opr: 'eq', value: '' }, - { col: 'id', opr: 'dashboard_is_favorite', value: '' }, - { col: 'id', opr: 'dashboard_is_certified', value: '' }, + { col: 'owners', opr: 'rel_m_m', value: dashboardSelector.owner?.value }, + { + col: 'created_by', + opr: 'rel_o_m', + value: dashboardSelector.createdBy?.value, + }, + { col: 'published', opr: 'eq', value: dashboardSelector.status?.value }, + { + col: 'id', + opr: 'dashboard_is_favorite', + value: dashboardSelector.favorite?.value, + }, + { + col: 'id', + opr: 'dashboard_is_certified', + value: dashboardSelector.certified?.value, + }, ]; let filters = ''; const sort = 'order_column:changed_on_delta_humanized,order_direction:desc'; + const withoutValues = [undefined, null, '']; + const filteredData = filterData - .filter(item => item.value !== '') + .filter(item => !withoutValues.includes(item.value)) .map(item => `(col:${item.col},opr:${item.opr},value:${item.value})`) .join(','); - if (filterData.filter(item => item.value !== '').length) { + if (filterData.filter(item => !withoutValues.includes(item.value)).length) { filters = `filters:!(${filteredData}),`; }