fix(ui): restore View Resource action in findings drawer

Reapplies the View Resource link that was inadvertently dropped while
removing this PR's overlap with #10847. That feature is already on master
and removing it here would have regressed the findings drawer.

Restores buildResourceDetailHref, the resourceDetailHref binding, the
JSX action below the resource actions menu, and the original positive
assertion in the drawer test.
This commit is contained in:
Hugo P.Brito
2026-05-06 09:34:20 +01:00
parent 64df3a22c0
commit 4dbb7c7bb7
2 changed files with 42 additions and 3 deletions
@@ -408,7 +408,7 @@ const mockFinding: ResourceDrawerFinding = {
};
describe("ResourceDetailDrawerContent — resource navigation", () => {
it("should not render resource navigation from the recommendation drawer", () => {
it("should render a View Resource link below the resource actions menu", () => {
// Given
render(
<ResourceDetailDrawerContent
@@ -425,10 +425,25 @@ describe("ResourceDetailDrawerContent — resource navigation", () => {
/>,
);
// When
const viewResourceLink = screen.getByRole("link", {
name: "View Resource",
});
const resourceActionsMenu = screen.getByRole("menu", {
name: "Resource actions",
});
// Then
expect(viewResourceLink).toHaveAttribute(
"href",
"/resources?resourceId=res-1",
);
expect(viewResourceLink).toHaveAttribute("target", "_blank");
expect(viewResourceLink).toHaveAttribute("rel", "noopener noreferrer");
expect(
screen.queryByRole("link", { name: "View Resource" }),
).not.toBeInTheDocument();
resourceActionsMenu.compareDocumentPosition(viewResourceLink) &
Node.DOCUMENT_POSITION_FOLLOWING,
).not.toBe(0);
});
});
const mockResourceRow: FindingResourceRow = {
@@ -304,6 +304,12 @@ function buildComplianceDetailHref({
return `/compliance/${encodeURIComponent(framework)}?${params.toString()}`;
}
function buildResourceDetailHref(resourceId: string): string {
const params = new URLSearchParams();
params.set("resourceId", resourceId);
return `/resources?${params.toString()}`;
}
interface ResourceDetailDrawerContentProps {
isLoading: boolean;
isNavigating: boolean;
@@ -421,6 +427,9 @@ export function ResourceDetailDrawerContent({
const nativeIacConfig = resolveNativeIacConfig(providerType);
const showOverviewCheckMetaContent = showCheckMetaContent;
const showOverviewFindingContent = Boolean(f);
const resourceDetailHref = f?.resourceId
? buildResourceDetailHref(f.resourceId)
: null;
const findingRecommendationUrl = f?.remediation.recommendation.url;
const checkRecommendationUrl = checkMeta.remediation.recommendation.url;
const recommendationUrl = isNonEmptyString(findingRecommendationUrl)
@@ -775,6 +784,21 @@ export function ResourceDetailDrawerContent({
)}
</div>
</div>
{resourceDetailHref && (
<div className="border-border-neutral-secondary flex justify-end border-t pt-3">
<Button variant="link" size="link-sm" asChild>
<Link
href={resourceDetailHref}
target="_blank"
rel="noopener noreferrer"
>
View Resource
<ExternalLink className="size-3" />
</Link>
</Button>
</div>
)}
</>
)}