mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
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:
parent
54f1b35161
commit
29cba2b00c
@ -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,
|
||||
|
@ -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') {
|
||||
|
@ -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') {
|
||||
|
@ -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);
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user