Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Improve the data apps monitor page empty entries view (#85211)

Timofey Kachalovf984c16b5f91
diff --git a/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/components/AiAnalyticsSectionLayout/AiAnalyticsSectionLayout.tsx b/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/components/AiAnalyticsSectionLayout/AiAnalyticsSectionLayout.tsx
index cecc54c9976..a4f147cea51 100644
--- a/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/components/AiAnalyticsSectionLayout/AiAnalyticsSectionLayout.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/components/AiAnalyticsSectionLayout/AiAnalyticsSectionLayout.tsx
@@ -11,12 +11,12 @@ import { Flex, Loader, Stack } from "metabase/ui";
type AiAnalyticsSectionLayoutProps = {
children: ReactNode;
- emptyState: ReactNode;
+ emptyState?: ReactNode;
error: unknown;
filters: ReactNode;
isInitialLoading: boolean;
isTableRoute: boolean;
- showEmpty: boolean;
+ showEmpty?: boolean;
tabs?: PillTab[];
filtersAction?: ReactNode;
title: string;
@@ -85,10 +85,10 @@ export function AiAnalyticsSectionLayout({
type RouteContentProps = {
children: ReactNode;
- emptyState: ReactNode;
+ emptyState?: ReactNode;
error: unknown;
isInitialLoading: boolean;
- showEmpty: boolean;
+ showEmpty?: boolean;
};
export function RouteContent({
diff --git a/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/data-apps-analytics/components/DataAppsAnalyticsPage.tsx b/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/data-apps-analytics/components/DataAppsAnalyticsPage.tsx
index 17c9e9f9bc1..7dd01425409 100644
--- a/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/data-apps-analytics/components/DataAppsAnalyticsPage.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/data-apps-analytics/components/DataAppsAnalyticsPage.tsx
@@ -1,7 +1,6 @@
import { useMemo } from "react";
import { t } from "ttag";
-import { EmptyState } from "metabase/common/components/EmptyState";
import { useUrlState } from "metabase/common/hooks/use-url-state";
import { useLocation } from "metabase/router";
import { useSetting } from "metabase/settings";
@@ -78,9 +77,7 @@ export function DataAppsAnalyticsPage() {
: null,
[provider, table, filters],
);
- const { isInitialLoading, isRefetching, hasData, count, error } =
- useHasData(countQuery);
- const showEmpty = !isInitialLoading && !isRefetching && !hasData;
+ const { isInitialLoading, count, error } = useHasData(countQuery);
return (
<AiAnalyticsSectionLayout
@@ -120,17 +117,9 @@ export function DataAppsAnalyticsPage() {
}
/>
}
- emptyState={
- <EmptyState
- icon="audit"
- title={t`No data app activity`}
- message={t`Questions and actions that data apps run will show up here. Try widening the date range or check back once people start using your data apps.`}
- />
- }
error={error ?? audit.error ?? missingColumnsError}
isInitialLoading={isInitialLoading}
isTableRoute
- showEmpty={showEmpty}
>
<DataAppLogTable
provider={provider}
diff --git a/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/data-apps-analytics/components/DataAppsAnalyticsPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/data-apps-analytics/components/DataAppsAnalyticsPage.unit.spec.tsx
index fbc120b5e72..3513c4647ef 100644
--- a/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/data-apps-analytics/components/DataAppsAnalyticsPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/monitor/ai-auditing/data-apps-analytics/components/DataAppsAnalyticsPage.unit.spec.tsx
@@ -171,6 +171,16 @@ const logDataset: Dataset = createMockDataset({
running_time: 1,
});
+/** At most `total` of the log's records, so the rows agree with the count. */
+const createLogDataset = (total: number): Dataset => {
+ const rows = logDataset.data.rows.slice(0, total);
+ return {
+ ...logDataset,
+ data: { ...logDataset.data, rows },
+ row_count: rows.length,
+ };
+};
+
const createCountDataset = (total: number): Dataset =>
createMockDataset({
data: createMockDatasetData({
@@ -264,7 +274,7 @@ function setup({
}
return failingRequest === "rows"
? createFailure("Rows failed")
- : logDataset;
+ : createLogDataset(total);
},
{ name: "dataset" },
);
@@ -683,15 +693,15 @@ describe("DataAppsAnalyticsPage", () => {
});
});
- it("shows an empty state, keeping the filters, when there is no data app activity", async () => {
+ it("shows an empty list, keeping the filters, when there is no data app activity", async () => {
setup({ total: 0 });
- expect(await screen.findByText("No data app activity")).toBeInTheDocument();
+ const table = await screen.findByTestId("data-app-log-table");
+ expect(
+ await within(table).findByText("No activity found"),
+ ).toBeInTheDocument();
expect(screen.getByTestId("data-app-filter-select")).toBeInTheDocument();
expect(screen.getByTestId("entity-type-filter-select")).toBeInTheDocument();
- expect(
- screen.queryByRole("treegrid", { name: "Data app activity" }),
- ).not.toBeInTheDocument();
});
it("shows the error when counting the records fails", async () => {