Skip to content

Commit

Permalink
Merge branch 'main' into jpople/ha-369/edit-consent-category
Browse files Browse the repository at this point in the history
  • Loading branch information
jpople committed Feb 7, 2025
2 parents bb550fc + c9ea54c commit 31d7341
Show file tree
Hide file tree
Showing 7 changed files with 256 additions and 49 deletions.
40 changes: 38 additions & 2 deletions clients/admin-ui/cypress/e2e/action-center.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,9 @@ describe("Action center", () => {
cy.getByTestId("row-0-col-actions").within(() => {
cy.getByTestId("ignore-btn").click({ force: true });
});
cy.wait("@ignoreMonitorResultUncategorizedSystem");
cy.wait("@ignoreMonitorResultSystem").then((interception) => {
expect(interception.request.url).to.contain("[undefined]");
});
cy.getByTestId("success-alert").should(
"contain",
"108 uncategorized assets have been ignored and will not appear in future scans.",
Expand All @@ -208,8 +210,42 @@ describe("Action center", () => {
"10 assets from Google Tag Manager have been ignored and will not appear in future scans.",
);
});
it("shouldn't allow bulk add when uncategorized system is selected", () => {
cy.getByTestId("row-0-col-select").find("label").click();
cy.getByTestId("selected-count").should("contain", "1 selected");
cy.getByTestId("bulk-actions-menu").click();
cy.getByTestId("bulk-add").should("be.disabled");
});
it("should bulk add results from categorized systems", () => {
cy.getByTestId("bulk-actions-menu").should("be.disabled");
cy.getByTestId("row-1-col-select").find("label").click();
cy.getByTestId("row-2-col-select").find("label").click();
cy.getByTestId("selected-count").should("contain", "2 selected");
cy.getByTestId("bulk-actions-menu").should("not.be.disabled");
cy.getByTestId("bulk-actions-menu").click();
cy.getByTestId("bulk-add").click();
cy.wait("@addMonitorResultSystem");
cy.getByTestId("success-alert").should(
"contain",
"16 assets have been added to the system inventory.",
);
});
it("should bulk ignore results from all systems", () => {
cy.getByTestId("row-0-col-select").find("label").click();
cy.getByTestId("row-1-col-select").find("label").click();
cy.getByTestId("row-2-col-select").find("label").click();
cy.getByTestId("selected-count").should("contain", "3 selected");
cy.getByTestId("bulk-actions-menu").should("not.be.disabled");
cy.getByTestId("bulk-actions-menu").click();
cy.getByTestId("bulk-ignore").click();
cy.wait("@ignoreMonitorResultSystem");
cy.getByTestId("success-alert").should(
"contain",
"124 assets have been ignored and will not appear in future scans.",
);
});
it("should navigate to table view on row click", () => {
cy.getByTestId("row-1").click();
cy.getByTestId("row-1-col-system_name").click();
cy.url().should(
"contain",
"system_key-8fe42cdb-af2e-4b9e-9b38-f75673180b88",
Expand Down
7 changes: 0 additions & 7 deletions clients/admin-ui/cypress/support/stubs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -551,13 +551,6 @@ export const stubActionCenter = () => {
cy.intercept("POST", "/api/v1/plus/discovery-monitor/*/mute*", {
response: 200,
}).as("ignoreMonitorResultSystem");
cy.intercept(
"POST",
"/api/v1/plus/discovery-monitor/*/mute?resolved_system_id=%5Bundefined%5D",
{
response: 200,
},
).as("ignoreMonitorResultUncategorizedSystem");
cy.intercept("POST", "/api/v1/plus/discovery-monitor/*/promote*", {
response: 200,
}).as("addMonitorResultSystem");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { baseApi } from "~/features/common/api.slice";
import { getQueryParamsFromArray } from "~/features/common/utils";
import { PaginationQueryParams } from "~/types/common/PaginationQueryParams";

import {
Expand All @@ -8,6 +9,11 @@ import {
MonitorSystemAggregatePaginatedResponse,
} from "./types";

interface MonitorResultSystemQueryParams {
monitor_config_key: string;
resolved_system_ids: string[];
}

const actionCenterApi = baseApi.injectEndpoints({
endpoints: (build) => ({
getAggregateMonitorResults: build.query<
Expand Down Expand Up @@ -57,30 +63,36 @@ const actionCenterApi = baseApi.injectEndpoints({
}),
providesTags: () => ["Discovery Monitor Results"],
}),
addMonitorResultSystem: build.mutation<
addMonitorResultSystems: build.mutation<
any,
{ monitor_config_key?: string; resolved_system_id?: string }
MonitorResultSystemQueryParams
>({
query: (params) => ({
method: "POST",
url: `/plus/discovery-monitor/${params.monitor_config_key}/promote`,
params: {
resolved_system_id: params.resolved_system_id,
},
}),
query: ({ monitor_config_key, resolved_system_ids }) => {
const params = getQueryParamsFromArray(
resolved_system_ids,
"resolved_system_ids",
);
return {
method: "POST",
url: `/plus/discovery-monitor/${monitor_config_key}/promote?${params}`,
};
},
invalidatesTags: ["Discovery Monitor Results"],
}),
ignoreMonitorResultSystem: build.mutation<
ignoreMonitorResultSystems: build.mutation<
any,
{ monitor_config_key?: string; resolved_system_id?: string }
MonitorResultSystemQueryParams
>({
query: (params) => ({
method: "POST",
url: `/plus/discovery-monitor/${params.monitor_config_key}/mute`,
params: {
resolved_system_id: params.resolved_system_id,
},
}),
query: ({ monitor_config_key, resolved_system_ids }) => {
const params = getQueryParamsFromArray(
resolved_system_ids,
"resolved_system_ids",
);
return {
method: "POST",
url: `/plus/discovery-monitor/${monitor_config_key}/mute?${params}`,
};
},
invalidatesTags: ["Discovery Monitor Results"],
}),
addMonitorResultAssets: build.mutation<any, { urnList?: string[] }>({
Expand Down Expand Up @@ -163,8 +175,8 @@ export const {
useGetAggregateMonitorResultsQuery,
useGetDiscoveredSystemAggregateQuery,
useGetDiscoveredAssetsQuery,
useAddMonitorResultSystemMutation,
useIgnoreMonitorResultSystemMutation,
useAddMonitorResultSystemsMutation,
useIgnoreMonitorResultSystemsMutation,
useAddMonitorResultAssetsMutation,
useIgnoreMonitorResultAssetsMutation,
useUpdateAssetsSystemMutation,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { ColumnDef, createColumnHelper } from "@tanstack/react-table";

import { DefaultCell } from "~/features/common/table/v2";
import {
DefaultCell,
IndeterminateCheckboxCell,
} from "~/features/common/table/v2";
import DiscoveredSystemDataUseCell from "~/features/data-discovery-and-detection/action-center/tables/cells/DiscoveredSystemDataUseCell";

import { DiscoveredSystemActionsCell } from "../tables/cells/DiscoveredSystemAggregateActionsCell";
Expand All @@ -11,6 +14,28 @@ export const useDiscoveredSystemAggregateColumns = (monitorId: string) => {
const columnHelper = createColumnHelper<MonitorSystemAggregate>();

const columns: ColumnDef<MonitorSystemAggregate, any>[] = [
columnHelper.display({
id: "select",
cell: ({ row }) => (
<IndeterminateCheckboxCell
isChecked={row.getIsSelected()}
onChange={row.getToggleSelectedHandler()}
dataTestId={`select-${row.original.name || row.id}`}
/>
),
header: ({ table }) => (
<IndeterminateCheckboxCell
isChecked={table.getIsAllPageRowsSelected()}
isIndeterminate={table.getIsSomeRowsSelected()}
onChange={table.getToggleAllRowsSelectedHandler()}
dataTestId="select-all-rows"
/>
),
maxSize: 40,
meta: {
disableRowClick: true,
},
}),
columnHelper.accessor((row) => row.name, {
id: "system_name",
cell: (props) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import {
} from "~/features/common/table/v2";
import {
useAddMonitorResultAssetsMutation,
useAddMonitorResultSystemMutation,
useAddMonitorResultSystemsMutation,
useGetDiscoveredAssetsQuery,
useIgnoreMonitorResultAssetsMutation,
useUpdateAssetsMutation,
Expand Down Expand Up @@ -71,8 +71,8 @@ export const DiscoveredAssetsTable = ({
useAddMonitorResultAssetsMutation();
const [ignoreMonitorResultAssetsMutation, { isLoading: isIgnoringResults }] =
useIgnoreMonitorResultAssetsMutation();
const [addMonitorResultSystemMutation, { isLoading: isAddingAllResults }] =
useAddMonitorResultSystemMutation();
const [addMonitorResultSystemsMutation, { isLoading: isAddingAllResults }] =
useAddMonitorResultSystemsMutation();
const [updateAssetsSystemMutation, { isLoading: isBulkUpdatingSystem }] =
useUpdateAssetsSystemMutation();
const [updateAssetsMutation, { isLoading: isBulkAddingDataUses }] =
Expand Down Expand Up @@ -224,9 +224,9 @@ export const DiscoveredAssetsTable = ({

const handleAddAll = async () => {
const assetCount = data?.items.length || 0;
const result = await addMonitorResultSystemMutation({
const result = await addMonitorResultSystemsMutation({
monitor_config_key: monitorId,
resolved_system_id: systemId,
resolved_system_ids: [systemId],
});

if (isErrorResult(result)) {
Expand Down
Loading

0 comments on commit 31d7341

Please sign in to comment.