Skip to content
Snippets Groups Projects

CE-3061: Update ioc alerts and status separately

Merged Johanna Szepanski requested to merge CE-3061-update-IOC-alerts-async into develop
3 files
+ 63
20
Compare changes
  • Side-by-side
  • Inline
Files
3
import { Grid, Box } from "@mui/material";
import { useMemo, useContext } from "react";
import { KeyValueTable } from "@ess-ics/ce-ui-common";
import { apiContext } from "../../../api/DeployApi";
import { IOCBadge } from "../IOCBadge";
import { Grid, Box, Stack, Typography } from "@mui/material";
 
import {
 
KeyValueTable,
 
useAPIMethod,
 
AlertBannerList
 
} from "@ess-ics/ce-ui-common";
 
import { IOCStatus } from "../IOCTable/IOCStatus";
import AccessControl from "../../auth/AccessControl";
import AccessControl from "../../auth/AccessControl";
export function diff(o1, o2) {
export function diff(o1, o2) {
@@ -26,9 +32,22 @@ const defaultSubset = ({
@@ -26,9 +32,22 @@ const defaultSubset = ({
version
version
}) => ({ name, description, host, active, status, git, version });
}) => ({ name, description, host, active, status, git, version });
export function IOCDetails({ ioc, getSubset = defaultSubset, alert, buttons }) {
export function IOCDetails({ ioc, getSubset = defaultSubset, buttons }) {
ioc = { ...ioc };
ioc = { ...ioc };
const subset = getSubset(ioc);
const subset = getSubset(ioc);
 
const client = useContext(apiContext);
 
 
const alertParams = useMemo(
 
() => ({
 
ioc_id: ioc.id
 
}),
 
[ioc.id]
 
);
 
 
const { value: alert } = useAPIMethod({
 
fcn: client.apis.IOCs.fetchIocAlerts,
 
params: alertParams
 
});
return (
return (
<>
<>
@@ -36,14 +55,11 @@ export function IOCDetails({ ioc, getSubset = defaultSubset, alert, buttons }) {
@@ -36,14 +55,11 @@ export function IOCDetails({ ioc, getSubset = defaultSubset, alert, buttons }) {
container
container
spacing={1}
spacing={1}
>
>
{alert && (
{alert && alert.alerts.length > 0 ? (
<Grid
<Box sx={{ mt: (theme) => theme.spacing(2), width: "100%" }}>
item
<AlertBannerList alerts={alert.alerts} />
xs={12}
</Box>
>
) : null}
{alert}
</Grid>
)}
{buttons && (
{buttons && (
<Grid
<Grid
item
item
@@ -71,10 +87,41 @@ export function IOCDetails({ ioc, getSubset = defaultSubset, alert, buttons }) {
@@ -71,10 +87,41 @@ export function IOCDetails({ ioc, getSubset = defaultSubset, alert, buttons }) {
item
item
xs={12}
xs={12}
>
>
<IOCBadge
<Stack
ioc={ioc}
flexDirection="row"
sx={{ mt: 2.5 }}
alignItems="center"
/>
justifyContent="flex-start"
 
>
 
<Box
 
sx={{
 
marginRight: (theme) => theme.spacing(4),
 
marginLeft: (theme) => theme.spacing(6)
 
}}
 
>
 
<IOCStatus
 
id={ioc.id}
 
hideAlerts
 
/>
 
</Box>
 
<Box sx={{ flex: 1 }}>
 
<Typography
 
noWrap
 
variant="subtitle1"
 
component="p"
 
color="textPrimary"
 
>
 
{ioc.namingName ?? ioc.name}
 
</Typography>
 
<Typography
 
noWrap
 
component="p"
 
variant="subtitle2"
 
>
 
{ioc.activeDeployment?.host?.fqdn || "---"}
 
</Typography>
 
</Box>
 
</Stack>
 
<KeyValueTable
<KeyValueTable
obj={subset}
obj={subset}
variant="overline"
variant="overline"
Loading