fixed: Dashboard services UI error #12003 (#12098)

* fixed: Dashboard services UI error #12003

* fetch count for data modal tab
This commit is contained in:
Shailesh Parmar 2023-06-23 09:32:53 +05:30 committed by GitHub
parent 0ceb856aeb
commit 3ef5568ac0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 22 deletions

View File

@ -61,7 +61,11 @@ import {
import React, { FunctionComponent, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Link, useHistory, useParams } from 'react-router-dom';
import { getDashboards, getDataModels } from 'rest/dashboardAPI';
import {
getDashboards,
getDataModels,
ListDataModelParams,
} from 'rest/dashboardAPI';
import { getDatabases } from 'rest/databaseAPI';
import {
deleteIngestionPipelineById,
@ -511,15 +515,15 @@ const ServicePage: FunctionComponent = () => {
}
};
const fetchDashboardsDataModel = async (paging?: PagingWithoutTotal) => {
const fetchDashboardsDataModel = async (params?: ListDataModelParams) => {
setIsServiceLoading(true);
try {
const { data, paging: resPaging } = await getDataModels(
serviceFQN,
'owner,tags,followers',
paging,
include
);
const { data, paging: resPaging } = await getDataModels({
service: serviceFQN,
fields: 'owner,tags,followers',
include,
...params,
});
setDataModel(data);
setDataModelPaging(resPaging);
} catch (error) {
@ -602,10 +606,11 @@ const ServicePage: FunctionComponent = () => {
break;
}
case ServiceCategory.DASHBOARD_SERVICES: {
if (!isDataModel) {
if (isDataModel) {
fetchDashboardsDataModel({ ...paging });
} else {
fetchDashboards(paging);
}
fetchDashboardsDataModel(paging);
break;
}
@ -709,6 +714,16 @@ const ServicePage: FunctionComponent = () => {
getOtherDetails(undefined, activeTab === EntityTabs.DATA_Model);
}, [activeTab, showDeleted]);
useEffect(() => {
// fetch count for data modal tab, its need only when its dashboard page and data modal tab is not active
if (
serviceCategory === ServiceCategory.DASHBOARD_SERVICES &&
activeTab !== EntityTabs.DATA_Model
) {
fetchDashboardsDataModel({ limit: 0 });
}
}, []);
useEffect(() => {
if (servicePermission.ViewAll || servicePermission.ViewBasic) {
setIsLoading(true);

View File

@ -23,6 +23,15 @@ import { Paging } from '../generated/type/paging';
import { getURLWithQueryFields } from '../utils/APIUtils';
import APIClient from './index';
export type ListDataModelParams = {
service?: string;
fields?: string;
after?: string;
before?: string;
include?: Include;
limit?: number;
};
export const getDashboardVersions = async (id: string) => {
const url = `/dashboards/${id}/versions`;
@ -133,21 +142,11 @@ export const restoreDashboard = async (id: string) => {
return response.data;
};
export const getDataModels = async (
service: string,
fields: string,
paging?: PagingWithoutTotal,
include: Include = Include.NonDeleted
) => {
export const getDataModels = async (params?: ListDataModelParams) => {
const response = await APIClient.get<PagingResponse<ServicePageData[]>>(
`/dashboard/datamodels`,
{
params: {
service,
fields,
...paging,
include,
},
params,
}
);