Skip to content

Commit

Permalink
fix(dashboard): make to show the correct owned objects (apache#19223)
Browse files Browse the repository at this point in the history
* fix(dashboard): make to show the correct owned objects

* fix(dashboard): make to filter is reusable

* fix(homepage): make sure the type Array<Filters>
  • Loading branch information
prosdev0107 authored and michael_hoffman committed Mar 23, 2022
1 parent 091c2db commit 4a07d47
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 19 deletions.
23 changes: 10 additions & 13 deletions superset-frontend/src/views/CRUD/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,17 @@ export const getEditedObjects = (userId: string | number) => {
export const getUserOwnedObjects = (
userId: string | number,
resource: string,
) => {
const filters = {
created: [
{
col: 'created_by',
opr: 'rel_o_m',
value: `${userId}`,
},
],
};
return SupersetClient.get({
endpoint: `/api/v1/${resource}/?q=${getParams(filters.created)}`,
filters: Array<Filters> = [
{
col: 'created_by',
opr: 'rel_o_m',
value: `${userId}`,
},
],
) =>
SupersetClient.get({
endpoint: `/api/v1/${resource}/?q=${getParams(filters)}`,
}).then(res => res.json?.result);
};

export const getRecentAcitivtyObjs = (
userId: string | number,
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/views/CRUD/welcome/ChartTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ function ChartTable({

if (filterName === 'Mine') {
filters.push({
id: 'created_by',
operator: 'rel_o_m',
id: 'owners',
operator: 'rel_m_m',
value: `${user?.userId}`,
});
} else if (filterName === 'Favorite') {
Expand Down
4 changes: 2 additions & 2 deletions superset-frontend/src/views/CRUD/welcome/DashboardTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ function DashboardTable({
const filters = [];
if (filterName === 'Mine') {
filters.push({
id: 'created_by',
operator: 'rel_o_m',
id: 'owners',
operator: 'rel_m_m',
value: `${user?.userId}`,
});
} else if (filterName === 'Favorite') {
Expand Down
10 changes: 8 additions & 2 deletions superset-frontend/src/views/CRUD/welcome/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,13 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
);

// Sets other activity data in parallel with recents api call

const ownSavedQueryFilters = [
{
col: 'owners',
opr: 'rel_m_m',
value: `${id}`,
},
];
getUserOwnedObjects(id, 'dashboard')
.then(r => {
setDashboardData(r);
Expand All @@ -225,7 +231,7 @@ function Welcome({ user, addDangerToast }: WelcomeProps) {
setLoadedCount(loadedCount => loadedCount + 1);
addDangerToast(t('There was an issues fetching your chart: %s', err));
});
getUserOwnedObjects(id, 'saved_query')
getUserOwnedObjects(id, 'saved_query', ownSavedQueryFilters)
.then(r => {
setQueryData(r);
setLoadedCount(loadedCount => loadedCount + 1);
Expand Down

0 comments on commit 4a07d47

Please sign in to comment.