Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 5 commits into from
Mar 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -163,20 +163,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 @@ -197,7 +197,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 @@ -220,7 +226,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