Skip to content

Commit

Permalink
Merge branch 'main' into HJ-92_persist-monitor-execution
Browse files Browse the repository at this point in the history
  • Loading branch information
thingscouldbeworse committed Feb 4, 2025
2 parents abc44dc + df9aecd commit ac56917
Show file tree
Hide file tree
Showing 24 changed files with 734 additions and 286 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ Changes can also be flagged with a GitHub label for tracking purposes. The URL o

## [Unreleased](https://github.com/ethyca/fides/compare/2.54.0...main)

### Changed
- Added frequency field to DataHubSchema integration config [#5716](https://github.com/ethyca/fides/pull/5716)

### Fixed
- Fixed `fides annotate dataset` command enters incorrect value on the `direction` field. [#5727](https://github.com/ethyca/fides/pull/5727)
- Fixed Bigquery flakey tests. [#5713](https://github.com/ethyca/fides/pull/5713)
- Fixed breadcrumb navigation issues in data catalog view [#5717](https://github.com/ethyca/fides/pull/5717)

## [2.53.0](https://github.com/ethyca/fides/compare/2.53.0...2.54.0)

Expand Down
2 changes: 2 additions & 0 deletions clients/admin-ui/cypress/e2e/action-center.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ describe("Action center", () => {
const monitorKey = result
.attr("data-testid")
.replace("monitor-result-", "");
// property icon
cy.wrap(result).find(".ant-list-item-meta-avatar").should("exist");
// linked title
cy.wrap(result)
.contains("assets detected")
Expand Down
2 changes: 1 addition & 1 deletion clients/admin-ui/cypress/e2e/data-catalog.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe("data catalog", () => {
beforeEach(() => {
stubStagedResourceActions();
cy.visit(
`${DATA_CATALOG_ROUTE}/bigquery_system/monitor.project.test_dataset_1`,
`${DATA_CATALOG_ROUTE}/bigquery_system/projects/monitor.project/monitor.project.test_dataset_1`,
);
});

Expand Down
16 changes: 16 additions & 0 deletions clients/admin-ui/src/features/common/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
getKeysFromMap,
getOptionsFromMap,
getPII,
getWebsiteIconUrl,
} from "~/features/common/utils";

// TODO: add tests for the other utils functions
Expand Down Expand Up @@ -84,3 +85,18 @@ describe(getOptionsFromMap.name, () => {
expect(result).toEqual([]);
});
});

describe(getWebsiteIconUrl.name, () => {
it("should return the icon URL", () => {
const result = getWebsiteIconUrl("example.com");
expect(result).toEqual(
"https://cdn.brandfetch.io/example.com/icon/theme/light/fallback/404/h/24/w/24?c=1idbRjELpikqQ1PLiqb",
);
});
it("should return the icon URL with a custom size", () => {
const result = getWebsiteIconUrl("example.com", 56);
expect(result).toEqual(
"https://cdn.brandfetch.io/example.com/icon/theme/light/fallback/404/h/56/w/56?c=1idbRjELpikqQ1PLiqb",
);
});
});
4 changes: 2 additions & 2 deletions clients/admin-ui/src/features/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ export const getOptionsFromMap = <T = string>(
value: key,
}));

export const getWebsiteIconUrl = (hostname: string) => {
return `https://icons.duckduckgo.com/ip3/${hostname}.ico`;
export const getWebsiteIconUrl = (domain: string, size = 24) => {
return `https://cdn.brandfetch.io/${domain}/icon/theme/light/fallback/404/h/${size}/w/${size}?c=1idbRjELpikqQ1PLiqb`;
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import {
useReactTable,
} from "@tanstack/react-table";
import { Box, Flex } from "fidesui";
import { useRouter } from "next/router";
import { useEffect, useMemo, useState } from "react";

import { DATA_CATALOG_ROUTE } from "~/features/common/nav/v2/routes";
import {
FidesTableV2,
PaginationBar,
Expand All @@ -24,11 +22,7 @@ import { SearchInput } from "~/features/data-discovery-and-detection/SearchInput
import { StagedResourceType } from "~/features/data-discovery-and-detection/types/StagedResourceType";
import { findResourceType } from "~/features/data-discovery-and-detection/utils/findResourceType";
import resourceHasChildren from "~/features/data-discovery-and-detection/utils/resourceHasChildren";
import {
DiffStatus,
StagedResourceAPIResponse,
SystemResponse,
} from "~/types/api";
import { DiffStatus, StagedResourceAPIResponse } from "~/types/api";

// everything except muted
const DIFF_STATUS_FILTERS = [
Expand All @@ -53,13 +47,11 @@ const EMPTY_RESPONSE = {

const CatalogResourcesTable = ({
resourceUrn,
system,
onRowClick,
}: {
resourceUrn: string;
system: SystemResponse;
onRowClick: (row: StagedResourceAPIResponse) => void;
}) => {
const router = useRouter();

const {
PAGE_SIZES,
pageSize,
Expand Down Expand Up @@ -135,9 +127,7 @@ const CatalogResourcesTable = ({
tableInstance={tableInstance}
emptyTableNotice={<EmptyCatalogTableNotice />}
getRowIsClickable={(row) => resourceHasChildren(row)}
onRowClick={(row) =>
router.push(`${DATA_CATALOG_ROUTE}/${system.fides_key}/${row.urn}`)
}
onRowClick={onRowClick}
/>
<PaginationBar
totalRows={totalRows || 0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const EMPTY_RESPONSE = {

const columnHelper = createColumnHelper<SystemWithMonitorKeys>();

const SystemsTable = () => {
const CatalogSystemsTable = () => {
const [rowSelectionState, setRowSelectionState] = useState<RowSelectionState>(
{},
);
Expand Down Expand Up @@ -92,7 +92,7 @@ const SystemsTable = () => {
"monitor_config_ids",
);

const url = `${DATA_CATALOG_ROUTE}/${row.fides_key}${hasProjects ? "/projects" : ""}?${queryString}`;
const url = `${DATA_CATALOG_ROUTE}/${row.fides_key}/${hasProjects ? "projects" : "resources"}?${queryString}`;
router.push(url);
};

Expand Down Expand Up @@ -183,4 +183,4 @@ const SystemsTable = () => {
);
};

export default SystemsTable;
export default CatalogSystemsTable;
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import {
parseResourceBreadcrumbsNoProject,
parseResourceBreadcrumbsWithProject,
} from "~/features/data-catalog/utils/urnParsing";

const URL_PREFIX = "/url-prefix";

describe(parseResourceBreadcrumbsWithProject.name, () => {
const URN = "monitor.project.dataset.table.field";
const EXPECTED_TITLES = ["project", "dataset", "table", "field"];
const EXPECTED_HREFS = [
"/url-prefix/monitor.project",
"/url-prefix/monitor.project/monitor.project.dataset",
"/url-prefix/monitor.project/monitor.project.dataset.table",
undefined,
];

it("should return no breadcrumbs without a URN", () => {
const result = parseResourceBreadcrumbsWithProject(undefined, URL_PREFIX);
expect(result).toEqual([]);
});

it("should return no breadcrumbs with a short URN", () => {
const result = parseResourceBreadcrumbsWithProject("monitor", URL_PREFIX);
expect(result).toEqual([]);
});

it("should return the correct breadcrumbs when URN is provided", () => {
const result = parseResourceBreadcrumbsWithProject(URN, URL_PREFIX);
result.forEach((breadcrumb, idx) => {
expect(breadcrumb.title).toEqual(EXPECTED_TITLES[idx]);
expect(breadcrumb.href).toEqual(EXPECTED_HREFS[idx]);
});
});
});

describe(parseResourceBreadcrumbsNoProject.name, () => {
const URN = "monitor.dataset.table.field";
const EXPECTED_TITLES = ["dataset", "table", "field"];
const EXPECTED_HREFS = [
"/url-prefix/monitor.dataset",
"/url-prefix/monitor.dataset.table",
undefined,
];

it("should return no breadcrumbs without a URN", () => {
const result = parseResourceBreadcrumbsNoProject(undefined, URL_PREFIX);
expect(result).toEqual([]);
});

it("should return no breadcrumbs with a short URN", () => {
const result = parseResourceBreadcrumbsNoProject("monitor", URL_PREFIX);
expect(result).toEqual([]);
});

it("should return the correct breadcrumbs when URN is provided", () => {
const result = parseResourceBreadcrumbsNoProject(URN, URL_PREFIX);
result.forEach((breadcrumb, idx) => {
expect(breadcrumb.title).toEqual(EXPECTED_TITLES[idx]);
expect(breadcrumb.href).toEqual(EXPECTED_HREFS[idx]);
});
});
});
80 changes: 80 additions & 0 deletions clients/admin-ui/src/features/data-catalog/utils/urnParsing.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { Icons } from "fidesui";

import { NextBreadcrumbProps } from "~/features/common/nav/v2/NextBreadcrumb";

const URN_SEPARATOR = ".";

export const getProjectName = (urn: string) => {
const urnParts = urn.split(URN_SEPARATOR);
return urnParts[1];
};

const RESOURCE_ICONS = [
<Icons.Layers key="layers" />,
<Icons.Table key="table" />,
<Icons.ShowDataCards key="field" style={{ transform: "rotate(-90deg)" }} />,
];

export const parseResourceBreadcrumbsWithProject = (
urn: string | undefined,
urlPrefix: string,
) => {
if (!urn) {
return [];
}
const urnParts = urn.split(URN_SEPARATOR);
if (urnParts.length < 2) {
return [];
}
const projectUrn = urnParts.splice(0, 2).join(URN_SEPARATOR);
const subResourceUrns: NextBreadcrumbProps["items"] = [];

urnParts.reduce((prev, current, idx) => {
const isLast = idx === urnParts.length - 1;
const next = `${prev}${URN_SEPARATOR}${current}`;
subResourceUrns.push({
title: current,
href: !isLast ? `${urlPrefix}/${projectUrn}/${next}` : undefined,
icon: RESOURCE_ICONS[idx],
});
return next;
}, projectUrn);

return [
{
title: getProjectName(projectUrn),
href: `${urlPrefix}/${projectUrn}`,
icon: <Icons.Db2Database />,
},
...subResourceUrns,
];
};

export const parseResourceBreadcrumbsNoProject = (
urn: string | undefined,
urlPrefix: string,
) => {
if (!urn) {
return [];
}

const urnParts = urn.split(URN_SEPARATOR);
if (urnParts.length < 2) {
return [];
}
const monitorId = urnParts.shift();
const subResourceUrns: NextBreadcrumbProps["items"] = [];

urnParts.reduce((prev, current, idx) => {
const isLast = idx === urnParts.length - 1;
const next = `${prev}${URN_SEPARATOR}${current}`;
subResourceUrns.push({
title: current,
href: !isLast ? `${urlPrefix}/${next}` : undefined,
icon: RESOURCE_ICONS[idx],
});
return next;
}, monitorId);

return subResourceUrns;
};
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,23 @@ export const MonitorResult = ({
<List.Item data-testid={`monitor-result-${key}`} {...props}>
<Skeleton avatar title={false} loading={showSkeleton} active>
<List.Item.Meta
avatar={!!iconUrl && <Avatar src={iconUrl} size="small" />}
avatar={
<Avatar
src={iconUrl}
size="small"
icon={<Icons.Wikis />}
style={{
backgroundColor: "transparent",
color: "var(--ant-color-text)",
}}
/>
}
title={
<NextLink
href={`${ACTION_CENTER_ROUTE}/${key}`}
className="whitespace-nowrap"
>
{`${totalUpdates} assets detected${property ? `on ${property}` : ""}`}
{`${totalUpdates} assets detected${property ? ` on ${property}` : ""}`}
{!!warning && (
<Tooltip
title={typeof warning === "string" ? warning : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,29 @@ const actionCenterApi = baseApi.injectEndpoints({
invalidatesTags: ["Discovery Monitor Results"],
}),
addMonitorResultAssets: build.mutation<any, { urnList?: string[] }>({
query: (params) => ({
method: "POST",
url: `/plus/discovery-monitor/promote`,
params: {
staged_resource_urns: params.urnList,
},
}),
query: (params) => {
const queryParams = new URLSearchParams();
params.urnList?.forEach((urn) =>
queryParams.append("staged_resource_urns", urn),
);
return {
method: "POST",
url: `/plus/discovery-monitor/promote?${queryParams}`,
};
},
invalidatesTags: ["Discovery Monitor Results"],
}),
ignoreMonitorResultAssets: build.mutation<any, { urnList?: string[] }>({
query: (params) => ({
method: "POST",
url: `/plus/discovery-monitor/mute`,
params: {
staged_resource_urns: params.urnList,
},
}),
query: (params) => {
const queryParams = new URLSearchParams();
params.urnList?.forEach((urn) =>
queryParams.append("staged_resource_urns", urn),
);
return {
method: "POST",
url: `/plus/discovery-monitor/mute?${queryParams}`,
};
},
invalidatesTags: ["Discovery Monitor Results"],
}),
updateAssetsSystem: build.mutation<
Expand Down
Loading

0 comments on commit ac56917

Please sign in to comment.