Skip to content

Commit a2e3a42

Browse files
committed
monitor_type query parameter in /aggregate-results (#6885)
1 parent f635ff8 commit a2e3a42

File tree

5 files changed

+49
-21
lines changed

5 files changed

+49
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Changes can also be flagged with a GitHub label for tracking purposes. The URL o
3131
- Added beta feature flag for LLM classifier [#6880](https://github.com/ethyca/fides/pull/6880)
3232

3333
### Changed
34-
- Updated border radius on our design system theme [#6512](https://github.com/ethyca/fides/pull/6813)
34+
- Updated border radius on our design system theme [#6512](https://github.com/ethyca/fides/pull/6512)
3535
- Simplified data category selection logic in monitor field list items by replacing `user_assigned_data_categories` with unified `preferred_data_categories` field [#6817](https://github.com/ethyca/fides/pull/6817)
3636
- Custom fields are now shown in the list view of the new request manager [#6849](https://github.com/ethyca/fides/pull/6849)
3737
- Improved action center filters with tree-based UI and nested data categories [#6855](https://github.com/ethyca/fides/pull/6855)

clients/admin-ui/src/features/data-discovery-and-detection/action-center/action-center.slice.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import {
3939
MonitorAggregatedResults,
4040
MonitorSummaryPaginatedResponse,
4141
} from "./types";
42-
import { getMonitorType } from "./utils/getMonitorType";
42+
import { getMonitorType, MONITOR_TYPES } from "./utils/getMonitorType";
4343

4444
interface MonitorResultSystemQueryParams {
4545
monitor_config_key: string;
@@ -57,12 +57,29 @@ const actionCenterApi = baseApi.injectEndpoints({
5757
endpoints: (build) => ({
5858
getAggregateMonitorResults: build.query<
5959
MonitorSummaryPaginatedResponse,
60-
SearchQueryParams & PaginationQueryParams
60+
SearchQueryParams &
61+
PaginationQueryParams & {
62+
monitor_type?: MONITOR_TYPES[]; // defaults to all monitor types if not provided
63+
}
6164
>({
62-
query: ({ page = 1, size = 20, search }) => ({
63-
url: `/plus/discovery-monitor/aggregate-results`,
64-
params: { page, size, search, diff_status: "addition" },
65-
}),
65+
query: ({ page = 1, size = 20, search, monitor_type }) => {
66+
const params: SearchQueryParams &
67+
PaginationQueryParams & { diff_status: string } = {
68+
page,
69+
size,
70+
search,
71+
diff_status: "addition",
72+
};
73+
74+
const urlParams = buildArrayQueryParams({
75+
monitor_type,
76+
});
77+
78+
return {
79+
url: `/plus/discovery-monitor/aggregate-results?${urlParams.toString()}`,
80+
params,
81+
};
82+
},
6683
transformResponse: (
6784
response: PaginatedResponse<MonitorAggregatedResults>,
6885
) => ({

clients/admin-ui/src/features/data-discovery-and-detection/action-center/components/InProgressMonitorTasksList.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ export const InProgressMonitorTasksList = () => {
152152
showSizeChanger={{
153153
suffixIcon: <Icons.ChevronDown />,
154154
}}
155+
hideOnSinglePage={
156+
// if we're on the smallest page size, and there's only one page, hide the pagination
157+
paginationProps.pageSize?.toString() ===
158+
paginationProps.pageSizeOptions?.[0]
159+
}
155160
/>
156161
</Flex>
157162
);

clients/admin-ui/src/features/data-discovery-and-detection/action-center/fields/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,11 @@ const ActionCenterFields: NextPage = () => {
427427
suffixIcon: <Icons.ChevronDown />,
428428
}}
429429
total={fieldsDataResponse?.total || 0}
430+
hideOnSinglePage={
431+
// if we're on the smallest page size, and there's only one page, hide the pagination
432+
paginationProps.pageSize?.toString() ===
433+
paginationProps.pageSizeOptions?.[0]
434+
}
430435
/>
431436
</Flex>
432437
</Splitter.Panel>

clients/admin-ui/src/pages/data-discovery/action-center/index.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,18 @@ const ActionCenterPage = () => {
3636
const { webMonitor: webMonitorEnabled, llmClassifier: llmClassifierEnabled } =
3737
flags;
3838

39+
// Build monitor_type filter based on enabled feature flags
40+
const monitorTypes: MONITOR_TYPES[] = [
41+
...(webMonitorEnabled ? [MONITOR_TYPES.WEBSITE] : []),
42+
...(llmClassifierEnabled ? [MONITOR_TYPES.DATASTORE] : []),
43+
];
44+
3945
const { data, isError, isLoading, isFetching } =
4046
useGetAggregateMonitorResultsQuery({
4147
page: pageIndex,
4248
size: pageSize,
4349
search: searchQuery,
50+
monitor_type: monitorTypes.length > 0 ? monitorTypes : undefined,
4451
});
4552

4653
useEffect(() => {
@@ -58,21 +65,10 @@ const ActionCenterPage = () => {
5865
}
5966
}, [isError, toast]);
6067

61-
/*
62-
* Filtering paginated results can lead to odd behaviors
63-
* Either key should be constructed on the FE to display result, or BE should provide this functionality via the api
64-
*/
6568
const results =
66-
data?.items
67-
?.flatMap((monitor) =>
68-
!!monitor.key && typeof monitor.key !== "undefined" ? [monitor] : [],
69-
)
70-
.filter((monitor) => {
71-
const isWebsite = monitor.monitorType === MONITOR_TYPES.WEBSITE;
72-
// Show website monitors only if webMonitor flag is enabled
73-
// Show non-website monitors only if llmClassifier flag is enabled
74-
return isWebsite ? webMonitorEnabled : llmClassifierEnabled;
75-
}) || [];
69+
data?.items?.flatMap((monitor) =>
70+
!!monitor.key && typeof monitor.key !== "undefined" ? [monitor] : [],
71+
) || [];
7672

7773
const loadingResults = isFetching
7874
? Array.from({ length: pageSize }, (_, index) => ({
@@ -193,6 +189,11 @@ const ActionCenterPage = () => {
193189
showSizeChanger={{
194190
suffixIcon: <Icons.ChevronDown />,
195191
}}
192+
hideOnSinglePage={
193+
// if we're on the smallest page size, and there's only one page, hide the pagination
194+
paginationProps.pageSize?.toString() ===
195+
paginationProps.pageSizeOptions?.[0]
196+
}
196197
/>
197198
</Flex>
198199
)}

0 commit comments

Comments
 (0)