Skip to content

Commit

Permalink
refactor(supernova): change MessageProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
TilmanHaupt committed Dec 19, 2024
1 parent 2bb2d9e commit 9cdf509
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 91 deletions.
6 changes: 4 additions & 2 deletions apps/supernova/src/AppContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import React, { useEffect } from "react"
import { useActions, Messages } from "@cloudoperators/juno-messages-provider"
import { useActions, Messages, MessagesProvider } from "@cloudoperators/juno-messages-provider"
import { Container, Stack, Spinner } from "@cloudoperators/juno-ui-components"
import {
useAlertsUpdatedAt,
Expand Down Expand Up @@ -66,7 +66,9 @@ const AppContent = () => {

{activeSelectedTab === "alerts" && (
<>
<AlertDetail />
<MessagesProvider>
<AlertDetail />
</MessagesProvider>
<RegionsList />
{isAlertsLoading ? (
<Stack gap="2">
Expand Down
176 changes: 87 additions & 89 deletions apps/supernova/src/components/alerts/AlertDetail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import CreateSilence from "../silences/CreateSilence"
import AlertStatus from "./AlertStatus"
import AlertRegion from "./shared/AlertRegion"
import AlertSilences from "./AlertSilences"
import { MessagesProvider, Messages } from "@cloudoperators/juno-messages-provider"
import { Messages } from "@cloudoperators/juno-messages-provider"
import { useBoundQuery } from "../../hooks/useBoundQuery"

const AlertDetail = () => {
Expand All @@ -48,98 +48,96 @@ const AlertDetail = () => {
const { isLoading: isAlertsLoading } = useBoundQuery("alerts")

return (
<MessagesProvider>
<Panel
heading={
<Stack gap="2">
<AlertIcon severity={alert?.labels?.severity} />
<span>{alert?.annotations?.summary || "Not found"}</span>
</Stack>
}
opened={!!alertID}
onClose={onPanelClose}
size="large"
>
<Messages className="pb-6 absolute" />
<PanelBody>
<Tabs>
<TabList>
<Tab>Details</Tab>
<Tab>Raw Data</Tab>
</TabList>
<TabPanel>
<Container px={false} py>
{!alert ? (
isAlertsLoading ? (
<Stack gap="2">
<span>Loading</span>
<Spinner variant="primary" />
</Stack>
) : (
"Not found - the alert is probably not firing at the moment"
)
<Panel
heading={
<Stack gap="2">
<AlertIcon severity={alert?.labels?.severity} />
<span>{alert?.annotations?.summary || "Not found"}</span>
</Stack>
}
opened={!!alertID}
onClose={onPanelClose}
size="large"
>
<Messages className="pb-6 absolute" />
<PanelBody>
<Tabs>
<TabList>
<Tab>Details</Tab>
<Tab>Raw Data</Tab>
</TabList>
<TabPanel>
<Container px={false} py>
{!alert ? (
isAlertsLoading ? (
<Stack gap="2">
<span>Loading</span>
<Spinner variant="primary" />
</Stack>
) : (
<>
<DataGrid columns={2}>
<DataGridRow>
<DataGridHeadCell>Status</DataGridHeadCell>
<DataGridCell>
<AlertStatus alert={alert} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Firing Since</DataGridHeadCell>
<DataGridCell>
<AlertTimestamp startTimestamp={alert?.startsAt} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Service</DataGridHeadCell>
<DataGridCell>{alert?.labels?.service}</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Region</DataGridHeadCell>
<DataGridCell>
<AlertRegion region={alert?.labels?.region} cluster={alert?.labels?.cluster} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Description</DataGridHeadCell>
<DataGridCell>
<AlertDescription description={alert?.annotations?.description} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Links</DataGridHeadCell>
<DataGridCell>
<AlertLinks alert={alert} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Labels</DataGridHeadCell>
<DataGridCell>
<AlertLabels alert={alert} showAll={true} />
</DataGridCell>
</DataGridRow>
</DataGrid>
"Not found - the alert is probably not firing at the moment"
)
) : (
<>
<DataGrid columns={2}>
<DataGridRow>
<DataGridHeadCell>Status</DataGridHeadCell>
<DataGridCell>
<AlertStatus alert={alert} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Firing Since</DataGridHeadCell>
<DataGridCell>
<AlertTimestamp startTimestamp={alert?.startsAt} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Service</DataGridHeadCell>
<DataGridCell>{alert?.labels?.service}</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Region</DataGridHeadCell>
<DataGridCell>
<AlertRegion region={alert?.labels?.region} cluster={alert?.labels?.cluster} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Description</DataGridHeadCell>
<DataGridCell>
<AlertDescription description={alert?.annotations?.description} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Links</DataGridHeadCell>
<DataGridCell>
<AlertLinks alert={alert} />
</DataGridCell>
</DataGridRow>
<DataGridRow>
<DataGridHeadCell>Labels</DataGridHeadCell>
<DataGridCell>
<AlertLabels alert={alert} showAll={true} />
</DataGridCell>
</DataGridRow>
</DataGrid>

<AlertSilences alert={alert} />
</>
)}
</Container>
</TabPanel>
<AlertSilences alert={alert} />
</>
)}
</Container>
</TabPanel>

<TabPanel>
<Container px={false} py>
<CodeBlock>{alert && <JsonViewer data={alert} expanded={true} />}</CodeBlock>
</Container>
</TabPanel>
</Tabs>
</PanelBody>
<TabPanel>
<Container px={false} py>
<CodeBlock>{alert && <JsonViewer data={alert} expanded={true} />}</CodeBlock>
</Container>
</TabPanel>
</Tabs>
</PanelBody>

<PanelFooter>{alert && <CreateSilence alert={alert} variant="primary" />}</PanelFooter>
</Panel>
</MessagesProvider>
<PanelFooter>{alert && <CreateSilence alert={alert} variant="primary" />}</PanelFooter>
</Panel>
)
}

Expand Down

0 comments on commit 9cdf509

Please sign in to comment.