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
Files
13
 
import { useMemo, useContext } from "react";
 
import { apiContext } from "../../../api/DeployApi";
import { Grid, Box, Stack, Typography } from "@mui/material";
import { Grid, Box, Stack, Typography } from "@mui/material";
import { KeyValueTable } from "@ess-ics/ce-ui-common";
import {
 
KeyValueTable,
 
useAPIMethod,
 
AlertBannerList
 
} from "@ess-ics/ce-ui-common";
import { IOCStatus } from "../IOCTable/IOCStatus";
import { IOCStatus } from "../IOCTable/IOCStatus";
import AccessControl from "../../auth/AccessControl";
import AccessControl from "../../auth/AccessControl";
@@ -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
Loading