Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/add-perses-links.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@cloudoperators/juno-app-supernova": minor
---

Add Perses and PersesGlobal dashboard links to alert details
102 changes: 102 additions & 0 deletions apps/supernova/src/components/alerts/shared/AlertLinks.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from "react"
import { render, screen } from "@testing-library/react"
import AlertLinks from "./AlertLinks"

describe("AlertLinks", () => {
describe("Perses regional dashboard link", () => {
it("renders when both persesDashboard and region labels are present", () => {
const alert = {
labels: {
persesDashboard: "observability/dashboards/blackbox-overview",
region: "region-1",
},
}
render(<AlertLinks alert={alert} />)
const link = screen.getByText("Perses")
expect(link).toBeInTheDocument()
expect(link).toHaveAttribute(
"href",
"https://perses.region-1.cloud.sap/projects/observability/dashboards/blackbox-overview"
)
expect(link).toHaveAttribute("target", "_blank")
expect(link).toHaveAttribute("rel", "noopener noreferrer")
})

it("does not render when persesDashboard is present but region is missing", () => {
const alert = {
labels: {
persesDashboard: "observability/dashboards/blackbox-overview",
},
}
render(<AlertLinks alert={alert} />)
expect(screen.queryByText("Perses")).not.toBeInTheDocument()
})

it("does not render when region is present but persesDashboard is missing", () => {
const alert = {
labels: {
region: "region-1",
},
}
render(<AlertLinks alert={alert} />)
expect(screen.queryByText("Perses")).not.toBeInTheDocument()
})
})

describe("Perses Global dashboard link", () => {
it("renders when persesGlobalDashboard label is present", () => {
const alert = {
labels: {
persesGlobalDashboard: "observability/dashboards/global-sci-logs",
},
}
render(<AlertLinks alert={alert} />)
const link = screen.getByText("Perses Global")
expect(link).toBeInTheDocument()
expect(link).toHaveAttribute(
"href",
"https://perses.global.cloud.sap/projects/observability/dashboards/global-sci-logs"
)
expect(link).toHaveAttribute("target", "_blank")
expect(link).toHaveAttribute("rel", "noopener noreferrer")
})

it("does not render when persesGlobalDashboard label is missing", () => {
const alert = {
labels: {},
}
render(<AlertLinks alert={alert} />)
expect(screen.queryByText("Perses Global")).not.toBeInTheDocument()
})
})

describe("both Perses links together", () => {
it("renders both links when both labels are present", () => {
const alert = {
labels: {
persesDashboard: "compute/dashboards/nova-health",
persesGlobalDashboard: "observability/dashboards/global-sci-logs",
region: "region-1",
},
}
render(<AlertLinks alert={alert} />)
const regionalLink = screen.getByText("Perses")
const globalLink = screen.getByText("Perses Global")
expect(regionalLink).toBeInTheDocument()
expect(regionalLink).toHaveAttribute(
"href",
"https://perses.region-1.cloud.sap/projects/compute/dashboards/nova-health"
)
expect(globalLink).toBeInTheDocument()
expect(globalLink).toHaveAttribute(
"href",
"https://perses.global.cloud.sap/projects/observability/dashboards/global-sci-logs"
)
})
})
})
22 changes: 22 additions & 0 deletions apps/supernova/src/components/alerts/shared/AlertLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,28 @@ const AlertLinks = ({ alert, className }: any) => {
Logs
</a>
)}
{alert?.labels?.persesDashboard && alert?.labels?.region && (
<a
className="underline"
href={`https://perses.${alert?.labels?.region}.cloud.sap/projects/${alert?.labels?.persesDashboard}`}
Comment thread
ibakshay marked this conversation as resolved.
target="_blank"
Comment thread
ibakshay marked this conversation as resolved.
rel="noopener noreferrer"
onClick={(e) => e.stopPropagation()}
>
Perses
</a>
)}
{alert?.labels?.persesGlobalDashboard && (
<a
className="underline"
href={`https://perses.global.cloud.sap/projects/${alert?.labels?.persesGlobalDashboard}`}
target="_blank"
Comment thread
ibakshay marked this conversation as resolved.
rel="noopener noreferrer"
onClick={(e) => e.stopPropagation()}
>
Perses Global
</a>
)}
{alert?.labels?.dashboard && (
<a
className="underline"
Expand Down
Loading