@cccsaurora/howler-ui 2.17.0-dev.563 → 2.17.0-dev.600
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.d.ts +2 -0
- package/api/index.js +4 -2
- package/api/search/case.d.ts +4 -0
- package/api/search/case.js +8 -0
- package/api/search/index.d.ts +2 -1
- package/api/search/index.js +2 -1
- package/api/v2/case/index.d.ts +6 -0
- package/api/v2/case/index.js +18 -0
- package/api/v2/index.d.ts +4 -0
- package/api/v2/index.js +6 -0
- package/api/v2/search/facet.d.ts +3 -0
- package/api/v2/search/facet.js +12 -0
- package/api/v2/search/index.d.ts +5 -0
- package/api/v2/search/index.js +24 -0
- package/commons/components/leftnav/LeftNavDrawer.js +1 -1
- package/components/app/App.js +14 -0
- package/components/app/providers/FavouritesProvider.js +2 -2
- package/components/app/providers/HitSearchProvider.d.ts +0 -1
- package/components/app/providers/HitSearchProvider.js +6 -11
- package/components/app/providers/HitSearchProvider.test.js +11 -32
- package/components/app/providers/ParameterProvider.d.ts +9 -2
- package/components/app/providers/ParameterProvider.js +165 -240
- package/components/app/providers/ParameterProvider.test.js +307 -14
- package/components/{routes/overviews/OverviewEditor.js → elements/MarkdownEditor.js} +3 -3
- package/components/elements/ObjectDetails.d.ts +6 -0
- package/components/elements/{hit/HitDetails.js → ObjectDetails.js} +17 -17
- package/components/elements/PluginTypography.d.ts +2 -1
- package/components/elements/PluginTypography.js +3 -2
- package/components/elements/UserList.d.ts +5 -2
- package/components/elements/UserList.js +14 -5
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/case/CaseCard.d.ts +8 -0
- package/components/elements/case/CaseCard.js +39 -0
- package/components/elements/case/CasePreview.d.ts +6 -0
- package/components/elements/case/CasePreview.js +17 -0
- package/components/elements/case/StatusIcon.d.ts +5 -0
- package/components/elements/case/StatusIcon.js +13 -0
- package/components/elements/display/ChipPopper.d.ts +1 -0
- package/components/elements/display/ChipPopper.js +2 -2
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +1 -0
- package/components/elements/hit/HitBanner.js +28 -48
- package/components/elements/hit/HitCard.js +1 -1
- package/components/elements/hit/HitLinks.js +5 -3
- package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
- package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +10 -4
- package/components/elements/hit/HitRelated.d.ts +1 -1
- package/components/elements/hit/HitRelated.js +30 -3
- package/components/elements/hit/elements/AnalyticLink.d.ts +8 -0
- package/components/elements/hit/elements/AnalyticLink.js +22 -0
- package/components/elements/hit/outlines/DefaultOutline.js +1 -1
- package/components/elements/hit/related/RelatedRecords.js +63 -0
- package/components/elements/observable/ObservableCard.d.ts +5 -0
- package/components/elements/observable/ObservableCard.js +7 -0
- package/components/elements/observable/ObservablePreview.d.ts +6 -0
- package/components/elements/observable/ObservablePreview.js +12 -0
- package/components/elements/view/ViewTitle.js +1 -1
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +2 -2
- package/components/hooks/useHitSelection.js +3 -24
- package/components/hooks/useMyPreferences.js +10 -1
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +4 -1
- package/components/hooks/useMyTheme.js +9 -2
- package/components/hooks/useRelatedRecords.d.ts +13 -0
- package/components/hooks/useRelatedRecords.js +32 -0
- package/components/routes/action/view/ActionSearch.js +1 -1
- package/components/routes/advanced/QueryBuilder.js +1 -1
- package/components/routes/analytics/AnalyticDetails.js +2 -2
- package/components/routes/analytics/AnalyticSearch.js +1 -1
- package/components/routes/cases/CaseViewer.d.ts +2 -0
- package/components/routes/cases/CaseViewer.js +24 -0
- package/components/routes/cases/Cases.d.ts +2 -0
- package/components/routes/cases/Cases.js +101 -0
- package/components/routes/cases/constants.d.ts +5 -0
- package/components/routes/cases/constants.js +5 -0
- package/components/routes/cases/detail/AlertPanel.d.ts +6 -0
- package/components/routes/cases/detail/AlertPanel.js +32 -0
- package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
- package/components/routes/cases/detail/CaseDashboard.js +49 -0
- package/components/routes/cases/detail/CaseDetails.d.ts +6 -0
- package/components/routes/cases/detail/CaseDetails.js +61 -0
- package/components/routes/cases/detail/CaseOverview.d.ts +7 -0
- package/components/routes/cases/detail/CaseOverview.js +43 -0
- package/components/routes/cases/detail/CaseSidebar.d.ts +6 -0
- package/components/routes/cases/detail/CaseSidebar.js +36 -0
- package/components/routes/cases/detail/CaseTask.d.ts +11 -0
- package/components/routes/cases/detail/CaseTask.js +57 -0
- package/components/routes/cases/detail/ItemPage.d.ts +6 -0
- package/components/routes/cases/detail/ItemPage.js +93 -0
- package/components/routes/cases/detail/RelatedCasePanel.d.ts +6 -0
- package/components/routes/cases/detail/RelatedCasePanel.js +31 -0
- package/components/routes/cases/detail/TaskPanel.d.ts +7 -0
- package/components/routes/cases/detail/TaskPanel.js +52 -0
- package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +12 -0
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +19 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +6 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +27 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +12 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.js +179 -0
- package/components/routes/cases/detail/sidebar/types.d.ts +3 -0
- package/components/routes/cases/hooks/useCase.d.ts +13 -0
- package/components/routes/cases/hooks/useCase.js +38 -0
- package/components/routes/cases/modals/ResolveModal.d.ts +7 -0
- package/components/routes/cases/modals/ResolveModal.js +59 -0
- package/components/routes/help/ApiDocumentation.js +1 -1
- package/components/routes/help/HitDocumentation.js +1 -3
- package/components/routes/hits/search/HitContextMenu.js +3 -2
- package/components/routes/hits/search/InformationPane.d.ts +1 -0
- package/components/routes/hits/search/InformationPane.js +6 -28
- package/components/routes/hits/search/QuerySettings.js +2 -1
- package/components/routes/hits/search/QuerySettings.test.js +14 -9
- package/components/routes/hits/search/SearchPane.js +7 -32
- package/components/routes/hits/search/ViewLink.js +1 -1
- package/components/routes/hits/search/grid/EnhancedCell.js +1 -1
- package/components/routes/hits/search/shared/IndexPicker.d.ts +2 -0
- package/components/routes/hits/search/shared/IndexPicker.js +20 -0
- package/components/routes/hits/view/HitViewer.js +3 -4
- package/components/routes/home/ViewCard.js +1 -1
- package/components/routes/observables/ObservableViewer.d.ts +7 -0
- package/components/routes/observables/ObservableViewer.js +27 -0
- package/components/routes/overviews/OverviewViewer.js +2 -2
- package/locales/en/translation.json +437 -398
- package/locales/fr/translation.json +442 -408
- package/models/WithMetadata.d.ts +2 -1
- package/models/entities/generated/AttachmentsFile.d.ts +12 -0
- package/models/entities/generated/Case.d.ts +28 -0
- package/models/entities/generated/DestinationOriginal.d.ts +19 -0
- package/models/entities/generated/EmailAttachment.d.ts +8 -0
- package/models/entities/generated/EmailParent.d.ts +19 -0
- package/models/entities/generated/Enrichments.d.ts +7 -0
- package/models/entities/generated/EnrichmentsIndicator.d.ts +21 -0
- package/models/entities/generated/Howler.d.ts +0 -4
- package/models/entities/generated/HttpResponse.d.ts +11 -0
- package/models/entities/generated/Item.d.ts +9 -0
- package/models/entities/generated/Observable.d.ts +84 -0
- package/models/entities/generated/ObservableCloud.d.ts +20 -0
- package/models/entities/generated/ObservableDestination.d.ts +23 -0
- package/models/entities/generated/ObservableEmail.d.ts +30 -0
- package/models/entities/generated/ObservableFile.d.ts +36 -0
- package/models/entities/generated/ObservableHowler.d.ts +44 -0
- package/models/entities/generated/ObservableHttp.d.ts +11 -0
- package/models/entities/generated/ObservableObserver.d.ts +21 -0
- package/models/entities/generated/ObservableOrganization.d.ts +7 -0
- package/models/entities/generated/ObservableProcess.d.ts +34 -0
- package/models/entities/generated/ObservableSource.d.ts +23 -0
- package/models/entities/generated/ObservableThreat.d.ts +21 -0
- package/models/entities/generated/ObservableTls.d.ts +12 -0
- package/models/entities/generated/ObserverIngress.d.ts +9 -0
- package/models/entities/generated/Rule.d.ts +2 -10
- package/models/entities/generated/Task.d.ts +10 -0
- package/models/entities/generated/Threat.d.ts +2 -2
- package/models/entities/generated/{Enrichment.d.ts → ThreatEnrichment.d.ts} +1 -1
- package/package.json +16 -1
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +2 -1
- package/utils/constants.d.ts +3 -3
- package/utils/typeUtils.d.ts +7 -0
- package/utils/typeUtils.js +18 -0
- package/components/elements/display/icons/BundleButton.d.ts +0 -6
- package/components/elements/display/icons/BundleButton.js +0 -32
- package/components/routes/help/BundleDocumentation.d.ts +0 -3
- package/components/routes/help/BundleDocumentation.js +0 -12
- package/components/routes/help/markdown/en/bundles.md.js +0 -1
- package/components/routes/help/markdown/fr/bundles.md.js +0 -1
- package/components/routes/hits/search/BundleParentMenu.d.ts +0 -6
- package/components/routes/hits/search/BundleParentMenu.js +0 -32
- /package/components/{routes/overviews/OverviewEditor.d.ts → elements/MarkdownEditor.d.ts} +0 -0
- /package/components/elements/hit/{HitDetails.d.ts → related/RelatedRecords.d.ts} +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { CheckCircleOutline, HourglassBottom, RadioButtonUnchecked, UpdateOutlined } from '@mui/icons-material';
|
|
3
|
+
import { Card, Chip, Divider, Grid, Skeleton, Stack, Tooltip, Typography, useTheme } from '@mui/material';
|
|
4
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
5
|
+
import StatusIcon from '@cccsaurora/howler-ui/components/elements/case/StatusIcon';
|
|
6
|
+
import HowlerAvatar from '@cccsaurora/howler-ui/components/elements/display/HowlerAvatar';
|
|
7
|
+
import PluginChip from '@cccsaurora/howler-ui/components/elements/PluginChip';
|
|
8
|
+
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
9
|
+
import dayjs from 'dayjs';
|
|
10
|
+
import { countBy } from 'lodash-es';
|
|
11
|
+
import { useEffect, useState } from 'react';
|
|
12
|
+
import { useTranslation } from 'react-i18next';
|
|
13
|
+
import { twitterShort } from '@cccsaurora/howler-ui/utils/utils';
|
|
14
|
+
const STATUS_COLORS = {
|
|
15
|
+
resolved: 'success'
|
|
16
|
+
};
|
|
17
|
+
const CaseCard = ({ case: providedCase, caseId, className }) => {
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
const { dispatchApi } = useMyApi();
|
|
20
|
+
const theme = useTheme();
|
|
21
|
+
const [_case, setCase] = useState(providedCase);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (providedCase) {
|
|
24
|
+
setCase(providedCase);
|
|
25
|
+
}
|
|
26
|
+
}, [providedCase]);
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (caseId) {
|
|
29
|
+
dispatchApi(api.v2.case.get(caseId), { throwError: false }).then(setCase);
|
|
30
|
+
}
|
|
31
|
+
}, [caseId, dispatchApi]);
|
|
32
|
+
if (!_case) {
|
|
33
|
+
return _jsx(Skeleton, { variant: "rounded", height: 250, sx: { mb: 1 }, className: className });
|
|
34
|
+
}
|
|
35
|
+
return (_jsx(Card, { variant: "outlined", sx: { p: 1, mb: 1, borderColor: theme.palette[STATUS_COLORS[_case.status]]?.main }, className: className, children: _jsx(Stack, { direction: "row", alignItems: "start", spacing: 1, children: _jsxs(Stack, { sx: { flex: 1 }, spacing: 1, children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { variant: "h6", display: "flex", alignItems: "start", children: _case.title }), _jsx(StatusIcon, { status: _case.status }), _jsx("div", { style: { flex: 1 } }), _case.start && _case.end && (_jsx(Tooltip, { title: dayjs(_case.updated).toString(), children: _jsx(Chip, { icon: _jsx(HourglassBottom, { fontSize: "small" }), size: "small", label: twitterShort(_case.start) + ' - ' + twitterShort(_case.end) }) })), _jsx(Tooltip, { title: dayjs(_case.updated).toString(), children: _jsx(Chip, { icon: _jsx(UpdateOutlined, { fontSize: "small" }), size: "small", label: twitterShort(_case.updated) }) })] }), _jsx(Typography, { variant: "caption", color: "textSecondary", children: _case.summary.trim().split('\n')[0] }), _case.participants?.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Divider, { flexItem: true }), _jsx(Stack, { direction: "row", spacing: 1, children: _case.participants?.map(participant => (_jsx(HowlerAvatar, { sx: { height: '20px', width: '20px' }, userId: participant }, participant))) })] })), _jsx(Divider, { flexItem: true }), _jsxs(Grid, { container: true, spacing: 1, children: [_case.targets?.map(indicator => (_jsx(Grid, { item: true, children: _jsx(PluginChip, { size: "small", color: "primary", context: "casecard", variant: "outlined", value: indicator, label: indicator }) }, indicator))), _case.targets?.length > 0 && (_case.indicators?.length > 0 || _case.threats?.length > 0) && (_jsx(Grid, { item: true, children: _jsx(Divider, { orientation: "vertical" }) })), _case.indicators?.map(indicator => (_jsx(Grid, { item: true, children: _jsx(PluginChip, { variant: "outlined", context: "casecard", value: indicator, label: indicator }) }, indicator))), _case.indicators?.length > 0 && _case.threats?.length > 0 && (_jsx(Grid, { item: true, children: _jsx(Divider, { orientation: "vertical" }) })), _case.threats?.map(indicator => (_jsx(Grid, { item: true, children: _jsx(PluginChip, { size: "small", color: "warning", variant: "outlined", context: "casecard", value: indicator, label: indicator }) }, indicator)))] }), _case.tasks?.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Divider, { flexItem: true }), _jsxs(Stack, { spacing: 0.5, alignItems: "start", children: [_case.tasks.some(task => task.complete) && (_jsx(Chip, { size: "small", color: "success", icon: _jsx(CheckCircleOutline, {}), label: `${countBy(_case.tasks, task => task.complete).true} ${t('complete')}` })), _case.tasks
|
|
36
|
+
.filter(task => !task.complete)
|
|
37
|
+
.map(task => (_jsx(Chip, { icon: _jsx(RadioButtonUnchecked, {}), label: task.summary }, task.id)))] })] }))] }) }) }, _case.case_id));
|
|
38
|
+
};
|
|
39
|
+
export default CaseCard;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CheckCircleOutline, HourglassBottom, RadioButtonUnchecked, UpdateOutlined } from '@mui/icons-material';
|
|
3
|
+
import { Chip, Stack, Tooltip, Typography, useTheme } from '@mui/material';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import { countBy } from 'lodash-es';
|
|
6
|
+
import { memo } from 'react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
import { twitterShort } from '@cccsaurora/howler-ui/utils/utils';
|
|
9
|
+
import HowlerAvatar from '../display/HowlerAvatar';
|
|
10
|
+
import StatusIcon from './StatusIcon';
|
|
11
|
+
const CasePreview = ({ case: _case }) => {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
const taskCounts = countBy(_case.tasks, task => task.complete);
|
|
15
|
+
return (_jsxs(Stack, { flex: 1, spacing: 1, sx: { overflow: 'hidden', borderBottom: `thin solid ${theme.palette.divider}`, pb: 1, mb: 0 }, children: [_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Stack, { spacing: 1, children: [_jsx(Typography, { variant: "body1", fontWeight: "bold", children: _case.title }), _jsx(Typography, { variant: "caption", color: "textSecondary", children: _case.summary.trim().split('\n')[0] })] }), _jsx(StatusIcon, { status: _case.status }), _jsx("div", { style: { flex: 1 } }), _jsxs(Stack, { spacing: 1, alignItems: "end", children: [_case.start && _case.end && (_jsx(Tooltip, { title: dayjs(_case.updated).toString(), children: _jsx(Chip, { icon: _jsx(HourglassBottom, { fontSize: "small" }), size: "small", label: twitterShort(_case.start) + ' - ' + twitterShort(_case.end) }) })), _jsx(Tooltip, { title: dayjs(_case.updated).toString(), children: _jsx(Chip, { icon: _jsx(UpdateOutlined, { fontSize: "small" }), size: "small", label: twitterShort(_case.updated) }) })] })] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_case.participants?.length > 0 && (_jsx(Stack, { direction: "row", spacing: 1, children: _case.participants?.map(participant => (_jsx(HowlerAvatar, { sx: { height: '24px', width: '24px' }, userId: participant }, participant))) })), _jsx(Chip, { color: "success", icon: _jsx(CheckCircleOutline, {}), label: `${taskCounts.true ?? 0} ${t('complete')}` }), _jsx(Chip, { icon: _jsx(RadioButtonUnchecked, {}), label: `${taskCounts.false ?? 0} ${t('incomplete')}` })] })] }));
|
|
16
|
+
};
|
|
17
|
+
export default memo(CasePreview);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Check, HourglassBottom, Pause, Troubleshoot } from '@mui/icons-material';
|
|
3
|
+
import { Tooltip } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
const StatusIcon = ({ status }) => {
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
return (_jsx(Tooltip, { title: t(`page.cases.status.${status}`), children: {
|
|
8
|
+
'in-progress': _jsx(HourglassBottom, { color: "warning" }),
|
|
9
|
+
'on-hold': _jsx(Pause, { color: "disabled" }),
|
|
10
|
+
resolved: _jsx(Check, { color: "success" })
|
|
11
|
+
}[status] ?? _jsx(Troubleshoot, { color: "primary" }) }));
|
|
12
|
+
};
|
|
13
|
+
export default StatusIcon;
|
|
@@ -15,6 +15,7 @@ interface ChipPopperProps {
|
|
|
15
15
|
onToggle?: (show: boolean) => void;
|
|
16
16
|
onDelete?: (event?: any) => void;
|
|
17
17
|
toggleOnDelete?: boolean;
|
|
18
|
+
disablePortal?: boolean;
|
|
18
19
|
closeOnClick?: boolean;
|
|
19
20
|
}
|
|
20
21
|
declare const _default: import("react").NamedExoticComponent<ChipPopperProps>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Chip, ClickAwayListener, Collapse, Paper, Popper } from '@mui/material';
|
|
3
3
|
import { memo, useRef, useState } from 'react';
|
|
4
|
-
const ChipPopper = ({ icon, deleteIcon, label, children, minWidth, placement = 'bottom-start', onToggle, onDelete, toggleOnDelete = false, closeOnClick = false, slotProps = {} }) => {
|
|
4
|
+
const ChipPopper = ({ icon, deleteIcon, label, children, minWidth, placement = 'bottom-start', onToggle, onDelete, toggleOnDelete = false, closeOnClick = false, disablePortal = true, slotProps = {} }) => {
|
|
5
5
|
const [show, setShow] = useState(false);
|
|
6
6
|
const anchorEl = useRef(null);
|
|
7
7
|
const handleToggle = (newShow) => {
|
|
@@ -19,7 +19,7 @@ const ChipPopper = ({ icon, deleteIcon, label, children, minWidth, placement = '
|
|
|
19
19
|
}),
|
|
20
20
|
show && { borderBottomLeftRadius: '0', borderBottomRightRadius: '0' },
|
|
21
21
|
...(Array.isArray(slotProps.chip?.sx) ? slotProps.chip.sx : [slotProps.chip?.sx])
|
|
22
|
-
], ...(slotProps.chip ?? {}) }), _jsx(Popper, { placement: placement, anchorEl: anchorEl.current, disablePortal:
|
|
22
|
+
], ...(slotProps.chip ?? {}) }), _jsx(Popper, { placement: placement, anchorEl: anchorEl.current, disablePortal: disablePortal, open: true, sx: {
|
|
23
23
|
minWidth: Math.max(typeof minWidth === 'number' ? minWidth : parseInt(minWidth?.replace('px', '')) || 0, anchorEl.current?.clientWidth || 0),
|
|
24
24
|
zIndex: 1
|
|
25
25
|
}, children: _jsx(Collapse, { in: show, unmountOnExit: true, onClick: () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Card } from '@mui/material';
|
|
3
3
|
import { memo } from 'react';
|
|
4
|
-
const HowlerCard = props =>
|
|
4
|
+
const HowlerCard = props => _jsx(Card, { elevation: props.variant !== 'outlined' ? 1 : 0, ...props });
|
|
5
5
|
export default memo(HowlerCard);
|
|
@@ -15,6 +15,7 @@ const Modal = () => {
|
|
|
15
15
|
left: '50%',
|
|
16
16
|
maxWidth: options.maxWidth || '1200px',
|
|
17
17
|
maxHeight: options.maxHeight || '400px',
|
|
18
|
+
height: '100%',
|
|
18
19
|
transform: 'translate(-50%, -50%)',
|
|
19
20
|
backgroundColor: 'background.paper',
|
|
20
21
|
borderRadius: theme.shape.borderRadius,
|
|
@@ -1,38 +1,34 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Chip, Divider, Grid, Stack, Tooltip, Typography, avatarClasses, iconButtonClasses, useTheme } from '@mui/material';
|
|
3
|
-
import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
|
|
4
3
|
import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
|
|
5
4
|
import { uniq } from 'lodash-es';
|
|
6
5
|
import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
|
|
7
|
-
import { useCallback, useContext,
|
|
6
|
+
import { useCallback, useContext, useMemo } from 'react';
|
|
8
7
|
import { Trans, useTranslation } from 'react-i18next';
|
|
9
8
|
import { usePluginStore } from 'react-pluggable';
|
|
10
|
-
import { Link } from 'react-router-dom';
|
|
11
9
|
import { ESCALATION_COLORS, PROVIDER_COLORS } from '@cccsaurora/howler-ui/utils/constants';
|
|
12
10
|
import { stringToColor } from '@cccsaurora/howler-ui/utils/utils';
|
|
13
11
|
import PluginTypography from '../PluginTypography';
|
|
12
|
+
import AnalyticLink from './elements/AnalyticLink';
|
|
14
13
|
import Assigned from './elements/Assigned';
|
|
15
14
|
import EscalationChip from './elements/EscalationChip';
|
|
16
15
|
import HitTimestamp from './elements/HitTimestamp';
|
|
17
16
|
import HitBannerTooltip from './HitBannerTooltip';
|
|
18
17
|
import { HitLayout } from './HitLayout';
|
|
18
|
+
import RelatedRecords from './related/RelatedRecords';
|
|
19
19
|
const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
|
|
20
20
|
const { t } = useTranslation();
|
|
21
21
|
const { config } = useContext(ApiConfigContext);
|
|
22
22
|
const theme = useTheme();
|
|
23
23
|
const pluginStore = usePluginStore();
|
|
24
|
-
const { getMatchingAnalytic } = useMatchers();
|
|
25
|
-
const [analyticId, setAnalyticId] = useState();
|
|
26
24
|
const compressed = useMemo(() => layout === HitLayout.DENSE, [layout]);
|
|
27
25
|
const textVariant = useMemo(() => (layout === HitLayout.COMFY ? 'body1' : 'caption'), [layout]);
|
|
28
|
-
|
|
29
|
-
if (!hit?.
|
|
30
|
-
return;
|
|
26
|
+
const providerColor = useMemo(() => {
|
|
27
|
+
if (!hit?.event.provider) {
|
|
28
|
+
return PROVIDER_COLORS.unknown;
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}, [hit?.howler.analytic]);
|
|
35
|
-
const providerColor = useMemo(() => PROVIDER_COLORS[hit.event?.provider ?? 'unknown'] ?? stringToColor(hit.event.provider), [hit.event?.provider]);
|
|
30
|
+
return PROVIDER_COLORS[hit?.event.provider] ?? stringToColor(hit?.event.provider);
|
|
31
|
+
}, [hit?.event.provider]);
|
|
36
32
|
const mitreId = useMemo(() => {
|
|
37
33
|
if (hit.threat?.framework?.toLowerCase().startsWith('mitre')) {
|
|
38
34
|
return;
|
|
@@ -52,35 +48,23 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
|
|
|
52
48
|
}
|
|
53
49
|
return `/api/static/mitre/${mitreId}.svg`;
|
|
54
50
|
}, [mitreId]);
|
|
55
|
-
const leftBox = useMemo(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
p: compressed ? 0.5 : 1,
|
|
73
|
-
pt: 2,
|
|
74
|
-
pl: 1
|
|
75
|
-
}, display: "flex", flexDirection: "column", children: [_jsx(Typography, { variant: compressed ? 'caption' : 'body1', style: { wordBreak: 'break-all' }, children: hit.organization?.name ?? _jsx(Trans, { i18nKey: "unknown" }) }), iconUrl && (_jsx(Box, { sx: {
|
|
76
|
-
width: '40px',
|
|
77
|
-
height: '40px',
|
|
78
|
-
mask: `url("${iconUrl}")`,
|
|
79
|
-
maskSize: 'cover',
|
|
80
|
-
background: theme.palette.getContrastText(providerColor)
|
|
81
|
-
} }))] }) }));
|
|
82
|
-
}
|
|
83
|
-
}, [compressed, hit, iconUrl, providerColor, theme.palette, theme.shape.borderRadius]);
|
|
51
|
+
const leftBox = useMemo(() => (_jsx(HitBannerTooltip, { hit: hit, children: _jsxs(Box, { sx: {
|
|
52
|
+
gridColumn: { xs: 'span 3', sm: 'span 1' },
|
|
53
|
+
minWidth: '90px',
|
|
54
|
+
backgroundColor: providerColor,
|
|
55
|
+
color: theme.palette.getContrastText(providerColor),
|
|
56
|
+
alignSelf: 'start',
|
|
57
|
+
borderRadius: theme.shape.borderRadius,
|
|
58
|
+
p: compressed ? 0.5 : 1,
|
|
59
|
+
pt: 2,
|
|
60
|
+
pl: 1
|
|
61
|
+
}, display: "flex", flexDirection: "column", children: [_jsx(Typography, { variant: compressed ? 'caption' : 'body1', style: { wordBreak: 'break-all' }, children: hit.organization?.name ?? _jsx(Trans, { i18nKey: "unknown" }) }), iconUrl && (_jsx(Box, { sx: {
|
|
62
|
+
width: '40px',
|
|
63
|
+
height: '40px',
|
|
64
|
+
mask: `url("${iconUrl}")`,
|
|
65
|
+
maskSize: 'cover',
|
|
66
|
+
background: theme.palette.getContrastText(providerColor)
|
|
67
|
+
} }))] }) })), [compressed, hit, iconUrl, providerColor, theme.palette, theme.shape.borderRadius]);
|
|
84
68
|
/**
|
|
85
69
|
* The tooltips are necessary only when in the most compressed format
|
|
86
70
|
*/
|
|
@@ -88,7 +72,7 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
|
|
|
88
72
|
const _children = (_jsxs(Stack, { direction: "row", spacing: 1, flex: 1, children: [_jsxs(Typography, { variant: textVariant, noWrap: compressed, textOverflow: compressed ? 'ellipsis' : 'wrap', ...typographyProps, sx: [
|
|
89
73
|
{ display: 'flex', flexDirection: 'row' },
|
|
90
74
|
...(Array.isArray(typographyProps?.sx) ? typographyProps?.sx : [typographyProps?.sx])
|
|
91
|
-
], children: [t(i18nKey), ":"] }), (Array.isArray(value) ? value : [value]).map(val => (_jsx(PluginTypography, { component: "span", context: "banner", variant: textVariant, noWrap: compressed, textOverflow: compressed ? 'ellipsis' : 'wrap', ...typographyProps, value: val, field: field,
|
|
75
|
+
], children: [t(i18nKey), ":"] }), (Array.isArray(value) ? value : [value]).map(val => (_jsx(PluginTypography, { component: "span", context: "banner", variant: textVariant, noWrap: compressed, textOverflow: compressed ? 'ellipsis' : 'wrap', ...typographyProps, value: val, field: field, obj: hit }, val)))] }));
|
|
92
76
|
return compressed ? (_jsx(Tooltip, { title: Array.isArray(value) ? (_jsx("div", { children: value.map(_indicator => (_jsx("p", { style: { margin: 0, padding: 0 }, children: _indicator }, _indicator))) })) : (value), children: _children })) : (_children);
|
|
93
77
|
}, [compressed, hit, t, textVariant]);
|
|
94
78
|
return (_jsxs(Box, { display: "grid", gridTemplateColumns: "minmax(0, auto) minmax(0, 1fr) minmax(0, auto)", alignItems: "stretch", sx: { width: '100%', ml: 0, overflow: 'hidden' }, children: [leftBox, _jsxs(Stack, { sx: {
|
|
@@ -98,11 +82,7 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
|
|
|
98
82
|
}, spacing: layout !== HitLayout.COMFY ? 1 : 2, divider: _jsx(Divider, { orientation: "horizontal", sx: [
|
|
99
83
|
layout !== HitLayout.COMFY && { marginTop: '4px !important' },
|
|
100
84
|
{ mr: `${theme.spacing(-1)} !important` }
|
|
101
|
-
] }), children: [_jsxs(Typography, { variant:
|
|
102
|
-
e.stopPropagation();
|
|
103
|
-
}, onClick: e => {
|
|
104
|
-
e.stopPropagation();
|
|
105
|
-
}, children: hit.howler.analytic })) : (hit.howler.analytic), hit.howler.detection && ': ', hit.howler.detection] }), hit.howler?.rationale && (_jsxs(Typography, { flex: 1, variant: textVariant, color: ESCALATION_COLORS[hit.howler.escalation] + '.main', sx: { fontWeight: 'bold' }, children: [t('hit.header.rationale'), ": ", hit.howler.rationale] })), hit.howler?.outline && (_jsxs(_Fragment, { children: [_jsxs(Grid, { container: true, spacing: layout !== HitLayout.COMFY ? 1 : 2, sx: { ml: `${theme.spacing(-1)} !important` }, children: [hit.howler.outline.threat && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.threat", value: hit.howler.outline.threat, field: "howler.outline.threat" }) })), hit.howler.outline.target && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.target", value: hit.howler.outline.target, field: "howler.outline.target" }) }))] }), hit.howler.outline.indicators?.length > 0 && (_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Typography, { component: "span", variant: textVariant, children: [t('hit.header.indicators'), ":"] }), _jsx(Grid, { container: true, spacing: 0.5, sx: { mt: `${theme.spacing(-0.5)} !important`, ml: `${theme.spacing(0.25)} !important` }, children: uniq(hit.howler.outline.indicators).map((_indicator, index) => {
|
|
85
|
+
] }), children: [_jsx(AnalyticLink, { hit: hit }), hit.howler?.rationale && (_jsxs(Typography, { flex: 1, variant: textVariant, color: ESCALATION_COLORS[hit.howler.escalation] + '.main', sx: { fontWeight: 'bold' }, children: [t('hit.header.rationale'), ": ", hit.howler.rationale] })), hit.howler?.outline && (_jsxs(_Fragment, { children: [_jsxs(Grid, { container: true, spacing: layout !== HitLayout.COMFY ? 1 : 2, sx: { ml: `${theme.spacing(-1)} !important` }, children: [hit.howler.outline.threat && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.threat", value: hit.howler.outline.threat, field: "howler.outline.threat" }) })), hit.howler.outline.target && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.target", value: hit.howler.outline.target, field: "howler.outline.target" }) }))] }), hit.howler.outline.indicators?.length > 0 && (_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Typography, { component: "span", variant: textVariant, children: [t('hit.header.indicators'), ":"] }), _jsx(Grid, { container: true, spacing: 0.5, sx: { mt: `${theme.spacing(-0.5)} !important`, ml: `${theme.spacing(0.25)} !important` }, children: uniq(hit.howler.outline.indicators).map((_indicator, index) => {
|
|
106
86
|
return (_jsx(Grid, { item: true, children: _jsxs(Stack, { direction: "row", children: [_jsx(PluginTypography, { context: "indicators", variant: textVariant, value: _indicator, children: _indicator }), index < hit.howler.outline.indicators.length - 1 && (_jsx(Typography, { variant: textVariant, children: ',' }))] }) }, _indicator));
|
|
107
87
|
}) })] })), hit.howler.outline.summary && (_jsx(Wrapper, { i18nKey: "hit.header.summary", value: hit.howler.outline.summary, paragraph: true, textOverflow: "wrap", sx: [compressed && { marginTop: `0 !important` }], field: "howler.outline.summary" }))] }))] }), _jsxs(Stack, { direction: "column", spacing: layout !== HitLayout.COMFY ? 0.5 : 1, alignSelf: "stretch", sx: [
|
|
108
88
|
{ minWidth: 0, alignItems: { sm: 'end', md: 'start' }, flex: 1, pl: 1 },
|
|
@@ -116,6 +96,6 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
|
|
|
116
96
|
width: theme.spacing(3)
|
|
117
97
|
}
|
|
118
98
|
}
|
|
119
|
-
], children: [_jsx(HitTimestamp, { hit: hit, layout: layout }), showAssigned && _jsx(Assigned, { hit: hit, layout: layout }), _jsxs(Stack, { direction: "row", spacing: layout !== HitLayout.COMFY ? 0.5 : 1, children: [_jsx(EscalationChip, { hit: hit, layout: layout }), ['in-progress', 'on-hold'].includes(hit.howler.status) && (_jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status,
|
|
99
|
+
], children: [_jsx(HitTimestamp, { hit: hit, layout: layout }), showAssigned && _jsx(Assigned, { hit: hit, layout: layout }), _jsxs(Stack, { direction: "row", spacing: layout !== HitLayout.COMFY ? 0.5 : 1, children: [_jsx(EscalationChip, { hit: hit, layout: layout }), ['in-progress', 'on-hold'].includes(hit.howler.status) && (_jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, color: "primary" }))] }), hit.howler.related && _jsx(RelatedRecords, { hit: hit }), howlerPluginStore.plugins.flatMap(plugin => pluginStore.executeFunction(`${plugin}.status`, { hit, layout }))] })] }));
|
|
120
100
|
};
|
|
121
101
|
export default HitBanner;
|
|
@@ -19,6 +19,6 @@ const HitCard = ({ id, layout, readOnly = true }) => {
|
|
|
19
19
|
if (!hit) {
|
|
20
20
|
return _jsx(Skeleton, { variant: "rounded", height: "200px" });
|
|
21
21
|
}
|
|
22
|
-
return (_jsx(HowlerCard, { tabIndex: 0, sx: { position: 'relative' }, children: _jsxs(CardContent, { children: [_jsx(HitBanner, { hit: hit, layout: layout }), _jsx(HitOutline, { hit: hit, layout: layout }), _jsx(HitLabels, { hit: hit, readOnly: readOnly })] }) }));
|
|
22
|
+
return (_jsx(HowlerCard, { id: hit?.howler.id, tabIndex: 0, sx: { position: 'relative' }, children: _jsxs(CardContent, { children: [_jsx(HitBanner, { hit: hit, layout: layout }), _jsx(HitOutline, { hit: hit, layout: layout }), _jsx(HitLabels, { hit: hit, readOnly: readOnly })] }) }));
|
|
23
23
|
};
|
|
24
24
|
export default memo(HitCard);
|
|
@@ -3,15 +3,17 @@ import { Grid, gridClasses } from '@mui/material';
|
|
|
3
3
|
import HitNotebooks from '@cccsaurora/howler-ui/components/elements/hit/HitNotebooks';
|
|
4
4
|
import PivotLink from '@cccsaurora/howler-ui/components/elements/hit/related/PivotLink';
|
|
5
5
|
import RelatedLink from '@cccsaurora/howler-ui/components/elements/hit/related/RelatedLink';
|
|
6
|
-
import { uniqBy } from 'lodash-es';
|
|
6
|
+
import { sortBy, uniqBy } from 'lodash-es';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
7
8
|
const HitLinks = ({ hit, analytic, dossiers = [] }) => {
|
|
9
|
+
const { i18n } = useTranslation();
|
|
8
10
|
return ((hit?.howler?.links?.length > 0 ||
|
|
9
11
|
analytic?.notebooks?.length > 0 ||
|
|
10
12
|
dossiers.filter(_dossier => _dossier.pivots?.length > 0).length > 0) && (_jsxs(Grid, { container: true, spacing: 1, pr: 2, sx: { [`& .${gridClasses.item}`]: { display: 'flex' } }, children: [hit?.howler?.links?.length > 0 &&
|
|
11
13
|
uniqBy(hit.howler.links, 'href')
|
|
12
14
|
.slice(0, 3)
|
|
13
|
-
.map(l => (_jsx(Grid, { item: true, children: _jsx(RelatedLink, { compact: true, ...l }) }, l.href))), dossiers.flatMap(_dossier =>
|
|
15
|
+
.map(l => (_jsx(Grid, { item: true, children: _jsx(RelatedLink, { compact: true, ...l }) }, l.href))), sortBy(dossiers.flatMap(_dossier => _dossier.pivots ?? []), `label.${i18n.language}`).map((_pivot, index) => (
|
|
14
16
|
// eslint-disable-next-line react/no-array-index-key
|
|
15
|
-
_jsx(Grid, { item: true, children: _jsx(PivotLink, { pivot: _pivot, hit: hit, compact: true }) },
|
|
17
|
+
_jsx(Grid, { item: true, children: _jsx(PivotLink, { pivot: _pivot, hit: hit, compact: true }) }, _pivot.value + index))), analytic?.notebooks?.length > 0 && (_jsx(Grid, { item: true, children: _jsx(HitNotebooks, { analytic: analytic, hit: hit, compact: true }) }))] })));
|
|
16
18
|
};
|
|
17
19
|
export default HitLinks;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { AppSearchItemRendererOption } from '@cccsaurora/howler-ui/commons/components/app/AppSearchService';
|
|
2
2
|
import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
|
|
3
|
-
type
|
|
3
|
+
type PreviewProps = {
|
|
4
4
|
hit: Hit;
|
|
5
|
-
options
|
|
5
|
+
options?: AppSearchItemRendererOption<Hit>;
|
|
6
6
|
};
|
|
7
|
-
declare const _default: import("react").NamedExoticComponent<
|
|
7
|
+
declare const _default: import("react").NamedExoticComponent<PreviewProps>;
|
|
8
8
|
export default _default;
|
|
@@ -4,12 +4,18 @@ import { memo, useMemo } from 'react';
|
|
|
4
4
|
import { Trans, useTranslation } from 'react-i18next';
|
|
5
5
|
import { ESCALATION_COLORS, PROVIDER_COLORS, STATUS_COLORS } from '@cccsaurora/howler-ui/utils/constants';
|
|
6
6
|
import { formatDate, stringToColor } from '@cccsaurora/howler-ui/utils/utils';
|
|
7
|
-
const
|
|
7
|
+
const HitPreview = ({ hit, options }) => {
|
|
8
8
|
const { t } = useTranslation();
|
|
9
9
|
const theme = useTheme();
|
|
10
10
|
const isUnderLg = useMediaQuery(theme.breakpoints.down('lg'));
|
|
11
11
|
const providerColor = useMemo(() => PROVIDER_COLORS[hit.event?.provider ?? 'unknown'] ?? stringToColor(hit.event.provider), [hit.event?.provider]);
|
|
12
|
-
return (_jsxs(Box, { sx: {
|
|
12
|
+
return (_jsxs(Box, { sx: {
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
borderBottom: `thin solid ${theme.palette.divider}`,
|
|
15
|
+
pb: 1,
|
|
16
|
+
mb: 0,
|
|
17
|
+
gap: theme.spacing(1)
|
|
18
|
+
}, display: "grid", gridTemplateColumns: "minmax(0, 1fr) minmax(0, auto)", children: [_jsxs(Stack, { flexGrow: 1, gridColumn: options?.state.mode === 'inline' ? 'span 2' : '', children: [_jsxs(Typography, { variant: "body1", fontWeight: "bold", children: [hit.howler.analytic, hit.howler.detection && ': ', hit.howler.detection] }), options?.state.mode !== 'inline' && hit.howler?.outline && (_jsx(Tooltip, { placement: isUnderLg ? 'bottom' : 'left', componentsProps: {
|
|
13
19
|
tooltip: {
|
|
14
20
|
sx: {
|
|
15
21
|
fontSize: 12,
|
|
@@ -17,7 +23,7 @@ const HitQuickSearch = ({ hit, options }) => {
|
|
|
17
23
|
color: theme.palette.getContrastText(theme.palette.background.paper)
|
|
18
24
|
}
|
|
19
25
|
}
|
|
20
|
-
}, title: _jsxs(Stack, { divider: _jsx(Divider, { sx: { my: 0.5 } }), children: [_jsxs("div", { children: [_jsx(Trans, { i18nKey: "hit.header.threat" }), ": ", hit.howler.outline.threat] }), _jsxs("div", { children: [_jsx(Trans, { i18nKey: "hit.header.target" }), ": ", hit.howler.outline.target] }), _jsx("div", { children: hit.howler.outline.indicators.join(', ') })] }), children: _jsxs(Stack, { direction: { xs: 'column', sm: 'column' }, flex: 1, children: [_jsxs(Typography, { variant: "caption", textOverflow: "ellipsis", sx: { wordBreak: 'break-all', overflow: 'hidden' }, children: [_jsx(Trans, { i18nKey: "hit.header.threat" }), ": ", hit.howler.outline.threat] }), _jsxs(Typography, { variant: "caption", textOverflow: "ellipsis", sx: { wordBreak: 'break-all', overflow: 'hidden' }, children: [_jsx(Trans, { i18nKey: "hit.header.target" }), ": ", hit.howler.outline.target] })
|
|
26
|
+
}, title: _jsxs(Stack, { divider: _jsx(Divider, { sx: { my: 0.5 } }), children: [_jsxs("div", { children: [_jsx(Trans, { i18nKey: "hit.header.threat" }), ": ", hit.howler.outline.threat] }), _jsxs("div", { children: [_jsx(Trans, { i18nKey: "hit.header.target" }), ": ", hit.howler.outline.target] }), _jsx("div", { children: hit.howler.outline.indicators.join(', ') })] }), children: _jsxs(Stack, { direction: { xs: 'column', sm: 'column' }, flex: 1, children: [_jsxs(Typography, { variant: "caption", textOverflow: "ellipsis", sx: { wordBreak: 'break-all', overflow: 'hidden' }, children: [_jsx(Trans, { i18nKey: "hit.header.threat" }), ": ", hit.howler.outline.threat] }), _jsxs(Typography, { variant: "caption", textOverflow: "ellipsis", sx: { wordBreak: 'break-all', overflow: 'hidden' }, children: [_jsx(Trans, { i18nKey: "hit.header.target" }), ": ", hit.howler.outline.target] })] }) }))] }), _jsxs(Stack, { alignItems: options?.state.mode === 'fullscreen' ? 'end' : 'start', spacing: 0.5, children: [options?.state.mode === 'fullscreen' && _jsx(Chip, { label: formatDate(hit.timestamp), size: "small" }), _jsxs(Stack, { direction: "row", spacing: 0.5, children: [options?.state.mode === 'inline' && _jsx(Chip, { label: formatDate(hit.timestamp), size: "small" }), _jsx(Chip, { sx: {
|
|
21
27
|
backgroundColor: providerColor,
|
|
22
28
|
color: theme.palette.getContrastText(providerColor)
|
|
23
29
|
}, label: hit.organization?.name ?? _jsx(Trans, { i18nKey: "unknown" }), size: "small" }), _jsx(Chip, { label: hit.howler.escalation, size: "small", color: ESCALATION_COLORS[hit.howler.escalation] })] }), _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(Chip, { sx: {
|
|
@@ -28,4 +34,4 @@ const HitQuickSearch = ({ hit, options }) => {
|
|
|
28
34
|
? hit?.howler.assignment
|
|
29
35
|
: t('app.drawer.hit.assignment.unassigned.name'), size: "small" }), _jsx(Chip, { label: hit.howler.status, size: "small", color: STATUS_COLORS[hit.howler.status] })] })] })] }));
|
|
30
36
|
};
|
|
31
|
-
export default memo(
|
|
37
|
+
export default memo(HitPreview);
|
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Stack, Tab, Tabs, useTheme } from '@mui/material';
|
|
3
|
+
import ObservableCard from '@cccsaurora/howler-ui/components/elements/observable/ObservableCard';
|
|
4
|
+
import useRelatedRecords from '@cccsaurora/howler-ui/components/hooks/useRelatedRecords';
|
|
5
|
+
import { groupBy } from 'lodash-es';
|
|
6
|
+
import { useMemo, useState } from 'react';
|
|
7
|
+
import { useTranslation } from 'react-i18next';
|
|
8
|
+
import { Link } from 'react-router-dom';
|
|
9
|
+
import { isCase, isHit, isObservable } from '@cccsaurora/howler-ui/utils/typeUtils';
|
|
10
|
+
import CaseCard from '../case/CaseCard';
|
|
11
|
+
import HitCard from './HitCard';
|
|
12
|
+
import { HitLayout } from './HitLayout';
|
|
3
13
|
import RelatedLink from './related/RelatedLink';
|
|
4
14
|
const HitRelated = ({ hit }) => {
|
|
5
|
-
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
const { t } = useTranslation();
|
|
17
|
+
const related = useMemo(() => hit?.howler.related ?? [], [hit?.howler.related]);
|
|
18
|
+
const records = useRelatedRecords(related, related.length > 0);
|
|
19
|
+
const groups = groupBy(records, '__index');
|
|
20
|
+
const hasLinks = (hit?.howler.links?.length ?? 0) > 0;
|
|
21
|
+
const tabs = [
|
|
22
|
+
hasLinks && 'links',
|
|
23
|
+
groups.hit?.length > 0 && 'hit',
|
|
24
|
+
groups.case?.length > 0 && 'case',
|
|
25
|
+
groups.observable?.length > 0 && 'observable'
|
|
26
|
+
].filter(Boolean);
|
|
27
|
+
const [activeTab, setActiveTab] = useState(false);
|
|
28
|
+
const currentTab = activeTab !== false && tabs.includes(activeTab) ? activeTab : (tabs[0] ?? false);
|
|
29
|
+
if (!hit) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return (_jsxs(Box, { sx: { borderTop: `thin solid ${theme.palette.divider}`, height: '100%', flex: 1, mr: 2, pb: 2 }, children: [_jsxs(Tabs, { value: currentTab, onChange: (_, v) => setActiveTab(v), variant: "scrollable", scrollButtons: "auto", children: [hasLinks && _jsx(Tab, { value: "links", label: t('hit.related.tab.links') }), groups.hit?.length > 0 && _jsx(Tab, { value: "hit", label: t('hit.related.tab.hit') }), groups.case?.length > 0 && _jsx(Tab, { value: "case", label: t('hit.related.tab.case') }), groups.observable?.length > 0 && _jsx(Tab, { value: "observable", label: t('hit.related.tab.observable') })] }), currentTab === 'links' && (_jsx(Box, { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))", gap: 1, pt: 1, children: hit.howler.links.map(l => (_jsx(RelatedLink, { ...l }, l.title + l.href))) })), currentTab === 'hit' && (_jsx(Stack, { spacing: 1, pt: 1, children: records.filter(isHit).map(h => (_jsx(Link, { to: `/hits/${h.howler.id}`, target: "_blank", rel: "noopener noreferrer", style: { textDecoration: 'none' }, children: _jsx(HitCard, { id: h.howler.id, layout: HitLayout.NORMAL }) }, h.howler.id))) })), currentTab === 'case' && (_jsx(Stack, { spacing: 1, pt: 1, children: records.filter(isCase).map(c => (_jsx(Link, { to: `/cases/${c.case_id}`, target: "_blank", rel: "noopener noreferrer", style: { textDecoration: 'none' }, children: _jsx(CaseCard, { case: c }) }, c.case_id))) })), currentTab === 'observable' && (_jsx(Stack, { spacing: 1, pt: 1, children: records.filter(isObservable).map(o => (_jsx(Link, { to: `/observables/${o.howler.id}`, target: "_blank", rel: "noopener noreferrer", style: { textDecoration: 'none' }, children: _jsx(ObservableCard, { observable: o }) }, o.howler.id))) }))] }));
|
|
6
33
|
};
|
|
7
34
|
export default HitRelated;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import { Link } from 'react-router-dom';
|
|
6
|
+
const AnalyticLink = ({ hit, compressed, alignSelf = 'start' }) => {
|
|
7
|
+
const { getMatchingAnalytic } = useMatchers();
|
|
8
|
+
const [analyticId, setAnalyticId] = useState();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!hit?.howler.analytic) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
getMatchingAnalytic(hit).then(analytic => setAnalyticId(analytic?.analytic_id));
|
|
14
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
|
+
}, [hit?.howler.analytic]);
|
|
16
|
+
return (_jsxs(Typography, { variant: compressed ? 'body1' : 'h6', fontWeight: compressed && 'bold', sx: { alignSelf, '& a': { color: 'text.primary' } }, children: [analyticId ? (_jsx(Link, { to: `/analytics/${analyticId}`, onAuxClick: e => {
|
|
17
|
+
e.stopPropagation();
|
|
18
|
+
}, onClick: e => {
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
}, children: hit.howler.analytic })) : (hit.howler.analytic), hit.howler.detection && ': ', hit.howler.detection] }));
|
|
21
|
+
};
|
|
22
|
+
export default AnalyticLink;
|
|
@@ -41,7 +41,7 @@ const DefaultOutline = ({ hit, fields, template, layout = HitLayout.NORMAL, read
|
|
|
41
41
|
if (!displayedData) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
|
-
return (_jsxs(React.Fragment, { children: [_jsx(Tooltip, { title: (config.indexes.hit[field]?.description ?? t('none')).split('\n')[0], children: _jsxs(Typography, { variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', fontWeight: "bold", children: [field, ":"] }) }), _jsx(PluginTypography, { context: "outline", variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', whiteSpace: "normal", sx: { width: '100%', wordBreak: 'break-all' }, value: displayedData, field: field,
|
|
44
|
+
return (_jsxs(React.Fragment, { children: [_jsx(Tooltip, { title: (config.indexes.hit[field]?.description ?? t('none')).split('\n')[0], children: _jsxs(Typography, { variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', fontWeight: "bold", children: [field, ":"] }) }), _jsx(PluginTypography, { context: "outline", variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', whiteSpace: "normal", sx: { width: '100%', wordBreak: 'break-all' }, value: displayedData, field: field, obj: hit, children: displayedData })] }, field));
|
|
45
45
|
})] }));
|
|
46
46
|
};
|
|
47
47
|
export default memo(DefaultOutline);
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Link as LinkIcon } from '@mui/icons-material';
|
|
3
|
+
import { alpha, Box, Chip, Divider, Stack, useTheme } from '@mui/material';
|
|
4
|
+
import CasePreview from '@cccsaurora/howler-ui/components/elements/case/CasePreview';
|
|
5
|
+
import ChipPopper from '@cccsaurora/howler-ui/components/elements/display/ChipPopper';
|
|
6
|
+
import ObservablePreview from '@cccsaurora/howler-ui/components/elements/observable/ObservablePreview';
|
|
7
|
+
import useRelatedRecords from '@cccsaurora/howler-ui/components/hooks/useRelatedRecords';
|
|
8
|
+
import { identity, uniq } from 'lodash-es';
|
|
9
|
+
import { memo, useMemo, useState } from 'react';
|
|
10
|
+
import { useTranslation } from 'react-i18next';
|
|
11
|
+
import { Link } from 'react-router-dom';
|
|
12
|
+
import { isCase, isHit, isObservable } from '@cccsaurora/howler-ui/utils/typeUtils';
|
|
13
|
+
import HitPreview from '../HitPreview';
|
|
14
|
+
const RecordLink = ({ to, ariaLabel, children }) => {
|
|
15
|
+
const theme = useTheme();
|
|
16
|
+
return (_jsxs(Box, { p: 1, flex: 1, position: "relative", sx: {
|
|
17
|
+
'& > a': {
|
|
18
|
+
backgroundColor: 'transparent',
|
|
19
|
+
transition: theme.transitions.create('background-color', {
|
|
20
|
+
duration: theme.transitions.duration.shortest
|
|
21
|
+
}),
|
|
22
|
+
'&:hover': {
|
|
23
|
+
backgroundColor: alpha('#555', 0.5)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}, children: [_jsx(Link, { to: to, style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 }, target: "_blank", rel: "noopener noreferrer", "aria-label": ariaLabel }), children] }));
|
|
27
|
+
};
|
|
28
|
+
const RelatedRecords = ({ hit }) => {
|
|
29
|
+
const { t } = useTranslation();
|
|
30
|
+
const [open, setOpen] = useState(false);
|
|
31
|
+
const [filter, setFilter] = useState(null);
|
|
32
|
+
const related = useMemo(() => hit?.howler.related ?? [], [hit?.howler.related]);
|
|
33
|
+
const records = useRelatedRecords(related, open);
|
|
34
|
+
return (_jsxs(ChipPopper
|
|
35
|
+
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
36
|
+
, {
|
|
37
|
+
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
38
|
+
icon: _jsx(LinkIcon, {}), label: _jsx("span", { style: { cursor: 'pointer' }, children: t('hit.header.related', { count: related.length }) }), slotProps: {
|
|
39
|
+
chip: { disabled: related.length < 1 },
|
|
40
|
+
paper: {
|
|
41
|
+
elevation: 4,
|
|
42
|
+
onAuxClick: ev => ev.stopPropagation()
|
|
43
|
+
}
|
|
44
|
+
}, disablePortal: false, placement: "bottom-end", onToggle: _open => setOpen(_open), children: [_jsx(Stack, { direction: "row", spacing: 1, mb: 1, justifyContent: "end", children: uniq(records.map(record => record.__index))
|
|
45
|
+
.filter(identity)
|
|
46
|
+
.map(_type => (_jsx(Chip, { color: _type === filter ? 'primary' : 'default', label: _type, onClick: () => setFilter(current => (current === _type ? null : _type)) }, _type))) }), _jsxs(Stack, { maxWidth: "40vw", maxHeight: "70vh", sx: { overflowY: 'auto' }, children: [_jsx(Divider, {}), records
|
|
47
|
+
.filter(record => !filter || record.__index === filter)
|
|
48
|
+
.map(entry => {
|
|
49
|
+
if (isHit(entry)) {
|
|
50
|
+
const key = entry.howler.id;
|
|
51
|
+
return (_jsx(RecordLink, { to: `/hits/${key}`, ariaLabel: t('hit.header.view.hit', { id: key }), children: _jsx(HitPreview, { hit: entry }) }, key));
|
|
52
|
+
}
|
|
53
|
+
else if (isCase(entry)) {
|
|
54
|
+
const key = entry.case_id;
|
|
55
|
+
return (_jsx(RecordLink, { to: `/cases/${key}`, ariaLabel: t('hit.header.view.case', { id: key }), children: _jsx(CasePreview, { case: entry }) }, key));
|
|
56
|
+
}
|
|
57
|
+
else if (isObservable(entry)) {
|
|
58
|
+
const key = entry.howler.id;
|
|
59
|
+
return (_jsx(RecordLink, { to: `/observables/${key}`, ariaLabel: t('hit.header.view.observable', { id: key }), children: _jsx(ObservablePreview, { observable: entry }) }, key));
|
|
60
|
+
}
|
|
61
|
+
})] })] }));
|
|
62
|
+
};
|
|
63
|
+
export default memo(RelatedRecords);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { CardContent } from '@mui/material';
|
|
3
|
+
import HowlerCard from '@cccsaurora/howler-ui/components/elements/display/HowlerCard';
|
|
4
|
+
import { memo } from 'react';
|
|
5
|
+
import ObservablePreview from './ObservablePreview';
|
|
6
|
+
const ObservableCard = ({ observable }) => (_jsx(HowlerCard, { sx: { position: 'relative' }, children: _jsx(CardContent, { children: _jsx(ObservablePreview, { observable: observable }) }) }));
|
|
7
|
+
export default memo(ObservableCard);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { OpenInNew } from '@mui/icons-material';
|
|
3
|
+
import { Chip, IconButton, Stack, Typography, useTheme } from '@mui/material';
|
|
4
|
+
import { memo } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { Link } from 'react-router-dom';
|
|
7
|
+
const ObservablePreview = ({ observable }) => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
return (_jsx(Stack, { flex: 1, spacing: 1, sx: { overflow: 'hidden', borderBottom: `thin solid ${theme.palette.divider}`, pb: 1, mb: 0 }, children: _jsxs(Stack, { children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { variant: "body1", fontWeight: "bold", children: observable.event.provider }), _jsx("div", { style: { flex: 1 } }), _jsx(Chip, { label: observable.event.kind }), observable.event.reference && (_jsx(IconButton, { size: "small", component: Link, to: observable.event.reference, sx: { opacity: 1 }, target: "_blank", rel: "noopener noreferrer", children: _jsx(OpenInNew, { fontSize: "small" }) }))] }), observable.event.type && (_jsxs(Typography, { variant: "caption", children: [t('event.type'), " - ", observable.event.type.join(', ')] })), observable.event.module && (_jsxs(Typography, { variant: "caption", children: [t('event.module'), " - ", observable.event.module] }))] }) }));
|
|
11
|
+
};
|
|
12
|
+
export default memo(ObservablePreview);
|
|
@@ -21,5 +21,5 @@ export const ViewTitle = ({ title, type, query, sort, span }) => {
|
|
|
21
21
|
readonly: _jsx(Lock, { fontSize: "small" }),
|
|
22
22
|
global: _jsx(Language, { fontSize: "small" }),
|
|
23
23
|
personal: _jsx(Person, { fontSize: "small" })
|
|
24
|
-
}[type] }), _jsx(Typography, { variant: "body1", children: t(title) })] }), _jsx(Typography, { variant: "caption", children: _jsx("code", { children: query }) }), (sort || span) && (_jsxs(Stack, { direction: "row", sx: { mt: 1 }, spacing: 1, children: [sort?.split(',').map(_sort => (_jsx(Chip, { size: "small", label: _sort.split(' ')[0], icon: _sort.endsWith('desc') ? _jsx(ArrowDownward, {}) : _jsx(ArrowUpward, {}) }, _sort.split(' ')[0]))), spanLabel && _jsx(Chip, {
|
|
24
|
+
}[type] }), _jsx(Typography, { variant: "body1", children: t(title) })] }), _jsx(Typography, { variant: "caption", children: _jsx("code", { children: query }) }), (sort || span) && (_jsxs(Stack, { direction: "row", sx: { mt: 1 }, spacing: 1, children: [sort?.split(',').map(_sort => (_jsx(Chip, { size: "small", label: _sort.split(' ')[0], icon: _sort.endsWith('desc') ? _jsx(ArrowDownward, {}) : _jsx(ArrowUpward, {}) }, _sort.split(' ')[0]))), spanLabel && _jsx(Chip, { label: spanLabel })] }))] }));
|
|
25
25
|
};
|
|
@@ -7,7 +7,7 @@ declare const useHitActions: (_hits: Hit | Hit[]) => {
|
|
|
7
7
|
canAssess: boolean;
|
|
8
8
|
loading: boolean;
|
|
9
9
|
manage: (transition: string) => Promise<void>;
|
|
10
|
-
assess: (assessment: string, skipRationale?: boolean) => Promise<void>;
|
|
10
|
+
assess: (assessment: string, skipRationale?: boolean, providedRationale?: any) => Promise<void>;
|
|
11
11
|
vote: (v: string) => Promise<void>;
|
|
12
12
|
selectedVote: string;
|
|
13
13
|
};
|
|
@@ -90,9 +90,9 @@ const useHitActions = (_hits) => {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
}, [dispatchApi, hits, selectedVote, updateHit, user.email]);
|
|
93
|
-
const assess = useCallback(async (assessment, skipRationale = false) => {
|
|
93
|
+
const assess = useCallback(async (assessment, skipRationale = false, providedRationale = null) => {
|
|
94
94
|
const rationale = skipRationale
|
|
95
|
-
? t('rationale.default', { assessment })
|
|
95
|
+
? (providedRationale ?? t('rationale.default', { assessment }))
|
|
96
96
|
: await new Promise(res => {
|
|
97
97
|
showModal(_jsx(RationaleModal, { hits: hits, onSubmit: _rationale => {
|
|
98
98
|
res(_rationale);
|