Skip to content

Commit

Permalink
fix: dashboard list api for selects redux changes fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
omerfbolat authored and Muhammed-baban committed Jan 19, 2024
1 parent 4a5a5fe commit bcbb308
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
22 changes: 8 additions & 14 deletions superset-frontend/src/components/DvtSidebar/dvtSidebarData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
30 changes: 23 additions & 7 deletions superset-frontend/src/pages/DvtDashboardList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -82,6 +83,7 @@ const headerData = [

function DvtDashboardList() {
const history = useHistory<{ from: string }>();
const dashboardSelector = useAppSelector(state => state.dvtSidebar.dashboard);

const [selectedRows, setSelectedRows] = useState<any[]>([]);
const [currentPage, setCurrentPage] = useState<number>(1);
Expand All @@ -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}),`;
}

Expand Down

0 comments on commit bcbb308

Please sign in to comment.