mirror of
https://github.com/apache/superset.git
synced 2024-09-16 02:29:39 -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 = (
|
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,
|
||||||
|
@ -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') {
|
||||||
|
@ -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') {
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user