fix(dashboard): make to show the correct owned objects (#19223)

* fix(dashboard): make to show the correct owned objects

* fix(dashboard): make to filter is reusable

* fix(homepage): make sure the type Array<Filters>
This commit is contained in:
smileydev 2022-03-21 17:51:10 -04:00 committed by GitHub
parent 54f1b35161
commit 29cba2b00c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 19 deletions

View File

@ -164,20 +164,17 @@ export const getEditedObjects = (userId: string | number) => {
export const getUserOwnedObjects = ( export const getUserOwnedObjects = (
userId: string | number, userId: string | number,
resource: string, resource: string,
) => { filters: Array<Filters> = [
const filters = { {
created: [ col: 'created_by',
{ opr: 'rel_o_m',
col: 'created_by', value: `${userId}`,
opr: 'rel_o_m', },
value: `${userId}`, ],
}, ) =>
], SupersetClient.get({
}; endpoint: `/api/v1/${resource}/?q=${getParams(filters)}`,
return SupersetClient.get({
endpoint: `/api/v1/${resource}/?q=${getParams(filters.created)}`,
}).then(res => res.json?.result); }).then(res => res.json?.result);
};
export const getRecentAcitivtyObjs = ( export const getRecentAcitivtyObjs = (
userId: string | number, userId: string | number,

View File

@ -126,8 +126,8 @@ function ChartTable({
if (filterName === 'Mine') { if (filterName === 'Mine') {
filters.push({ filters.push({
id: 'created_by', id: 'owners',
operator: 'rel_o_m', operator: 'rel_m_m',
value: `${user?.userId}`, value: `${user?.userId}`,
}); });
} else if (filterName === 'Favorite') { } else if (filterName === 'Favorite') {

View File

@ -136,8 +136,8 @@ function DashboardTable({
const filters = []; const filters = [];
if (filterName === 'Mine') { if (filterName === 'Mine') {
filters.push({ filters.push({
id: 'created_by', id: 'owners',
operator: 'rel_o_m', operator: 'rel_m_m',
value: `${user?.userId}`, value: `${user?.userId}`,
}); });
} else if (filterName === 'Favorite') { } else if (filterName === 'Favorite') {

View File

@ -202,7 +202,13 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
); );
// Sets other activity data in parallel with recents api call // Sets other activity data in parallel with recents api call
const ownSavedQueryFilters = [
{
col: 'owners',
opr: 'rel_m_m',
value: `${id}`,
},
];
getUserOwnedObjects(id, 'dashboard') getUserOwnedObjects(id, 'dashboard')
.then(r => { .then(r => {
setDashboardData(r); setDashboardData(r);
@ -225,7 +231,7 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
setLoadedCount(loadedCount => loadedCount + 1); setLoadedCount(loadedCount => loadedCount + 1);
addDangerToast(t('There was an issues fetching your chart: %s', err)); addDangerToast(t('There was an issues fetching your chart: %s', err));
}); });
getUserOwnedObjects(id, 'saved_query') getUserOwnedObjects(id, 'saved_query', ownSavedQueryFilters)
.then(r => { .then(r => {
setQueryData(r); setQueryData(r);
setLoadedCount(loadedCount => loadedCount + 1); setLoadedCount(loadedCount => loadedCount + 1);