@cccsaurora/howler-ui 2.18.0-dev.648 → 2.18.0-dev.674
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 +34 -7
- package/components/app/hooks/useMatchers.js +2 -2
- package/components/app/hooks/useMatchers.test.js +22 -22
- package/components/app/hooks/useTitle.js +3 -3
- package/components/app/providers/FavouritesProvider.js +2 -2
- 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/app/providers/RecordProvider.d.ts +23 -0
- package/components/app/providers/{HitProvider.js → RecordProvider.js} +41 -41
- package/components/app/providers/{HitSearchProvider.d.ts → RecordSearchProvider.d.ts} +6 -6
- package/components/app/providers/{HitSearchProvider.js → RecordSearchProvider.js} +12 -17
- package/components/app/providers/{HitSearchProvider.test.js → RecordSearchProvider.test.js} +51 -70
- package/components/elements/ContextMenu.d.ts +56 -0
- package/components/elements/ContextMenu.js +109 -0
- package/components/elements/ContextMenu.test.js +215 -0
- 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 -1
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +1 -0
- package/components/elements/hit/HitActions.js +4 -4
- package/components/elements/hit/HitBanner.js +28 -48
- package/components/elements/hit/HitCard.js +5 -5
- package/components/elements/hit/HitLabels.js +2 -2
- 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/HitSummary.d.ts +2 -1
- package/components/elements/hit/HitSummary.js +6 -5
- package/components/elements/hit/aggregate/HitGraph.js +8 -8
- 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 +6 -0
- package/components/elements/observable/ObservableCard.js +23 -0
- package/components/elements/observable/ObservablePreview.d.ts +6 -0
- package/components/elements/observable/ObservablePreview.js +12 -0
- package/components/elements/{hit/HitComments.d.ts → record/RecordComments.d.ts} +5 -4
- package/components/elements/{hit/HitComments.js → record/RecordComments.js} +29 -28
- package/components/{routes/hits/search/HitContextMenu.d.ts → elements/record/RecordContextMenu.d.ts} +3 -3
- package/components/elements/record/RecordContextMenu.js +235 -0
- package/components/elements/record/RecordContextMenu.test.d.ts +1 -0
- package/components/{routes/hits/search/HitContextMenu.test.js → elements/record/RecordContextMenu.test.js} +39 -39
- package/components/elements/record/RecordRelated.d.ts +7 -0
- package/components/elements/record/RecordRelated.js +34 -0
- package/components/elements/{hit/HitWorklog.d.ts → record/RecordWorklog.d.ts} +4 -3
- package/components/elements/{hit/HitWorklog.js → record/RecordWorklog.js} +15 -13
- package/components/elements/view/ViewTitle.js +1 -1
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +4 -4
- package/components/hooks/useLocalStorage.test.d.ts +1 -0
- package/components/hooks/useLocalStorage.test.js +137 -0
- 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/useParamState.d.ts +6 -0
- package/components/hooks/useParamState.js +48 -0
- package/components/hooks/useParamState.test.d.ts +1 -0
- package/components/hooks/useParamState.test.js +166 -0
- package/components/hooks/{useHitSelection.d.ts → useRecordSelection.d.ts} +2 -2
- package/components/hooks/{useHitSelection.js → useRecordSelection.js} +12 -33
- package/components/hooks/useRelatedRecords.d.ts +13 -0
- package/components/hooks/useRelatedRecords.js +32 -0
- package/components/routes/action/edit/ActionEditor.js +2 -2
- package/components/routes/action/view/ActionSearch.js +1 -1
- package/components/routes/advanced/QueryBuilder.js +1 -1
- package/components/routes/advanced/QueryEditor.js +3 -3
- package/components/routes/advanced/historyCompletionProvider.js +3 -3
- 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 +22 -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 +33 -0
- package/components/routes/cases/detail/CaseAssets.d.ts +12 -0
- package/components/routes/cases/detail/CaseAssets.js +101 -0
- package/components/routes/cases/detail/CaseAssets.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseAssets.test.js +163 -0
- package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
- package/components/routes/cases/detail/CaseDashboard.js +51 -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 +61 -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 +99 -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/assets/Asset.d.ts +14 -0
- package/components/routes/cases/detail/assets/Asset.js +12 -0
- package/components/routes/cases/detail/assets/Asset.test.d.ts +1 -0
- package/components/routes/cases/detail/assets/Asset.test.js +72 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +13 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.js +131 -0
- package/components/routes/cases/detail/sidebar/types.d.ts +3 -0
- package/components/routes/cases/detail/sidebar/utils.d.ts +3 -0
- package/components/routes/cases/detail/sidebar/utils.js +25 -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/dossiers/DossierEditor.js +2 -2
- package/components/routes/dossiers/DossierEditor.test.js +1 -1
- package/components/routes/help/ApiDocumentation.js +1 -1
- package/components/routes/help/HitBannerDocumentation.js +1 -0
- package/components/routes/help/HitDocumentation.js +1 -3
- package/components/routes/hits/search/InformationPane.d.ts +1 -0
- package/components/routes/hits/search/InformationPane.js +47 -60
- package/components/routes/hits/search/LayoutSettings.js +3 -3
- package/components/routes/hits/search/QuerySettings.js +2 -1
- package/components/routes/hits/search/QuerySettings.test.js +14 -9
- package/components/routes/hits/search/{HitBrowser.js → RecordBrowser.js} +9 -9
- package/components/routes/hits/search/{HitQuery.d.ts → RecordQuery.d.ts} +2 -2
- package/components/routes/hits/search/{HitQuery.js → RecordQuery.js} +6 -6
- package/components/routes/hits/search/SearchPane.js +26 -49
- package/components/routes/hits/search/ViewLink.js +3 -3
- package/components/routes/hits/search/ViewLink.test.js +8 -8
- package/components/routes/hits/search/grid/AddColumnModal.js +5 -4
- package/components/routes/hits/search/grid/EnhancedCell.d.ts +2 -1
- package/components/routes/hits/search/grid/EnhancedCell.js +2 -2
- package/components/routes/hits/search/grid/HitGrid.js +20 -18
- package/components/routes/hits/search/grid/{HitRow.d.ts → RecordRow.d.ts} +3 -2
- package/components/routes/hits/search/grid/{HitRow.js → RecordRow.js} +10 -8
- 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 +12 -13
- package/components/routes/home/ViewCard.js +4 -4
- 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/components/routes/views/ViewComposer.js +4 -4
- package/locales/en/translation.json +65 -3
- package/locales/fr/translation.json +63 -3
- 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/Hit.d.ts +1 -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 +85 -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 +43 -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 +18 -1
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +2 -1
- package/tests/utils.d.ts +2 -0
- package/tests/utils.js +8 -0
- package/utils/constants.d.ts +3 -3
- package/utils/hitFunctions.d.ts +2 -1
- package/utils/hitFunctions.js +4 -4
- package/utils/typeUtils.d.ts +7 -0
- package/utils/typeUtils.js +27 -0
- package/components/app/providers/HitProvider.d.ts +0 -22
- package/components/elements/display/icons/BundleButton.d.ts +0 -6
- package/components/elements/display/icons/BundleButton.js +0 -32
- package/components/elements/hit/HitRelated.d.ts +0 -6
- package/components/elements/hit/HitRelated.js +0 -7
- 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/hits/search/BundleScroller.d.ts +0 -2
- package/components/routes/hits/search/BundleScroller.js +0 -6
- package/components/routes/hits/search/HitContextMenu.js +0 -227
- /package/components/app/providers/{HitSearchProvider.test.d.ts → RecordSearchProvider.test.d.ts} +0 -0
- /package/components/{routes/hits/search/HitContextMenu.test.d.ts → elements/ContextMenu.test.d.ts} +0 -0
- /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
- /package/components/routes/hits/search/{HitBrowser.d.ts → RecordBrowser.d.ts} +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Circle, Dashboard, Dataset } from '@mui/icons-material';
|
|
3
|
+
import { alpha, Box, Card, Chip, Divider, Skeleton, Stack, Typography, useTheme } from '@mui/material';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import {} from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
8
|
+
import { ESCALATION_COLOR_MAP } from '../constants';
|
|
9
|
+
import CaseFolder from './sidebar/CaseFolder';
|
|
10
|
+
const CaseSidebar = ({ case: _case }) => {
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const location = useLocation();
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
return (_jsxs(Box, { sx: {
|
|
15
|
+
flex: 1,
|
|
16
|
+
maxWidth: '350px',
|
|
17
|
+
maxHeight: 'calc(100vh - 64px)',
|
|
18
|
+
display: 'flex',
|
|
19
|
+
flexDirection: 'column'
|
|
20
|
+
}, children: [_jsxs(Card, { sx: { borderRadius: 0, px: 2, py: 1 }, children: [_case?.title ? _jsx(Typography, { variant: "body1", children: _case.title }) : _jsx(Skeleton, { height: 24 }), _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", divider: _jsx(Circle, { color: "disabled", sx: { fontSize: '8px' } }), children: [_jsxs(Typography, { variant: "caption", color: "textSecondary", children: [t('started'), ": ", _case?.created ? dayjs(_case.created).toString() : _jsx(Skeleton, { height: 14 })] }), _case?.escalation ? (_jsx(Chip, { color: ESCALATION_COLOR_MAP[_case.escalation], label: t(_case.escalation) })) : (_jsx(Skeleton, { height: 24 }))] })] }), _jsxs(Stack, { direction: "row", alignItems: "center", sx: [
|
|
21
|
+
{
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
px: 1,
|
|
24
|
+
py: 1,
|
|
25
|
+
transition: theme.transitions.create('background', { duration: 100 }),
|
|
26
|
+
color: `${theme.palette.text.primary} !important`,
|
|
27
|
+
textDecoration: 'none',
|
|
28
|
+
background: 'transparent',
|
|
29
|
+
borderRight: `thin solid ${theme.palette.divider}`,
|
|
30
|
+
'&:hover': {
|
|
31
|
+
background: alpha(theme.palette.grey[600], 0.25)
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
location.pathname === `/cases/${_case?.case_id}` && {
|
|
35
|
+
background: alpha(theme.palette.grey[600], 0.15),
|
|
36
|
+
borderRight: `3px solid ${theme.palette.primary.main}`
|
|
37
|
+
}
|
|
38
|
+
], component: Link, to: `/cases/${_case?.case_id}`, children: [_jsx(Dashboard, {}), _jsx(Typography, { sx: { userSelect: 'none', pl: 0.5, textWrap: 'nowrap' }, children: t('page.cases.dashboard') })] }), _jsxs(Stack, { direction: "row", alignItems: "center", sx: [
|
|
39
|
+
{
|
|
40
|
+
cursor: 'pointer',
|
|
41
|
+
px: 1,
|
|
42
|
+
py: 1,
|
|
43
|
+
transition: theme.transitions.create('background', { duration: 100 }),
|
|
44
|
+
color: `${theme.palette.text.primary} !important`,
|
|
45
|
+
textDecoration: 'none',
|
|
46
|
+
background: 'transparent',
|
|
47
|
+
borderRight: `thin solid ${theme.palette.divider}`,
|
|
48
|
+
'&:hover': {
|
|
49
|
+
background: alpha(theme.palette.grey[600], 0.25)
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
location.pathname === `/cases/${_case?.case_id}/assets` && {
|
|
53
|
+
background: alpha(theme.palette.grey[600], 0.15),
|
|
54
|
+
borderRight: `3px solid ${theme.palette.primary.main}`
|
|
55
|
+
}
|
|
56
|
+
], component: Link, to: `/cases/${_case?.case_id}/assets`, children: [_jsx(Dataset, {}), _jsx(Typography, { sx: { userSelect: 'none', pl: 0.5, textWrap: 'nowrap' }, children: t('page.cases.assets') })] }), _jsx(Divider, {}), _case && (_jsx(Box, { flex: 1, overflow: "auto", width: "100%", sx: {
|
|
57
|
+
position: 'relative',
|
|
58
|
+
borderRight: `thin solid ${theme.palette.divider}`
|
|
59
|
+
}, children: _jsx(Box, { position: "absolute", sx: { left: 0, right: 0 }, children: _jsx(CaseFolder, { case: _case }) }) }))] }));
|
|
60
|
+
};
|
|
61
|
+
export default CaseSidebar;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Task } from '@cccsaurora/howler-ui/models/entities/generated/Task';
|
|
2
|
+
import { type FC } from 'react';
|
|
3
|
+
declare const CaseTask: FC<{
|
|
4
|
+
task?: Task;
|
|
5
|
+
paths: string[];
|
|
6
|
+
onDelete?: () => Promise<void>;
|
|
7
|
+
onEdit: (task?: Partial<Task>) => Promise<void>;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
newTask?: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
export default CaseTask;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check, Close, Delete, Edit } from '@mui/icons-material';
|
|
3
|
+
import { Autocomplete, Card, Checkbox, Chip, IconButton, LinearProgress, Stack, TextField, Tooltip, Typography } from '@mui/material';
|
|
4
|
+
import UserList from '@cccsaurora/howler-ui/components/elements/UserList';
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { Link } from 'react-router-dom';
|
|
8
|
+
const CaseTask = ({ task, onEdit, onDelete, paths, newTask = false }) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const [loading, setLoading] = useState(false);
|
|
11
|
+
const [editing, setEditing] = useState(newTask);
|
|
12
|
+
const [summary, setSummary] = useState(task?.summary || '');
|
|
13
|
+
const [path, setPath] = useState(task?.path ?? null);
|
|
14
|
+
const [assignment, setAssignment] = useState(task?.assignment);
|
|
15
|
+
const [complete, setComplete] = useState(task?.complete ?? false);
|
|
16
|
+
const dirty = summary !== task?.summary || path !== task?.path || complete !== task?.complete || assignment !== task?.assignment;
|
|
17
|
+
const onSubmit = async () => {
|
|
18
|
+
if (dirty && editing) {
|
|
19
|
+
setLoading(true);
|
|
20
|
+
await onEdit({ summary, path: !path ? null : path, assignment, complete });
|
|
21
|
+
setLoading(false);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!editing && task?.assignment !== assignment) {
|
|
26
|
+
setLoading(true);
|
|
27
|
+
onEdit({ assignment }).finally(() => setLoading(false));
|
|
28
|
+
}
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
}, [assignment]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!editing && task?.complete !== complete) {
|
|
33
|
+
setLoading(true);
|
|
34
|
+
onEdit({ complete }).finally(() => setLoading(false));
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, [complete]);
|
|
38
|
+
return (_jsxs(Card, { sx: { pl: 0.5, pr: 1, py: 0.5, position: 'relative' }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [_jsx(Checkbox, { disabled: loading, color: "success", checked: complete, size: "small", onChange: (_ev, _complete) => setComplete(_complete) }), editing ? (_jsx(TextField, { disabled: loading, value: summary, onChange: e => setSummary(e.target.value), size: "small", fullWidth: true, sx: { minWidth: '40%' } })) : (_jsx(Typography, { sx: [complete && { textDecoration: 'line-through' }], children: task?.summary || summary })), !editing && path && _jsx(Chip, { clickable: true, component: Link, to: path, label: path }), editing && (_jsx(Autocomplete, { disabled: loading, value: path, options: paths, onChange: (_ev, value) => setPath(value), fullWidth: true, renderInput: params => _jsx(TextField, { ...params, size: "small" }) })), _jsx(UserList, { disabled: loading, userIds: [assignment], onChange: ([_assigment]) => setAssignment(_assigment), i18nLabel: "route.cases.task.set.assignment", avatarHeight: 24 }), _jsx("div", { style: { flex: 1 } }), editing && !newTask && (_jsx(Tooltip, { title: t('route.cases.task.delete'), children: _jsx(IconButton, { size: "small", color: "error", onClick: () => {
|
|
39
|
+
setLoading(true);
|
|
40
|
+
onDelete().then(() => setLoading(false));
|
|
41
|
+
}, disabled: loading, children: _jsx(Delete, { fontSize: "small" }) }) })), _jsx(Tooltip, { title: t(editing ? 'route.cases.task.edit.save' : 'route.cases.task.edit'), children: _jsx("span", { children: _jsx(IconButton, { size: "small", color: editing ? 'success' : 'default', onClick: async () => {
|
|
42
|
+
if (!editing) {
|
|
43
|
+
setEditing(true);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await onSubmit();
|
|
47
|
+
setEditing(false);
|
|
48
|
+
}, disabled: (!dirty && editing) || loading || !summary, children: editing ? _jsx(Check, { fontSize: "small" }) : _jsx(Edit, { fontSize: "small" }) }) }) }), editing && (_jsx(Tooltip, { title: t('route.cases.task.edit.cancel'), children: _jsx(IconButton, { size: "small", onClick: () => {
|
|
49
|
+
if (newTask) {
|
|
50
|
+
onDelete();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
setEditing(false);
|
|
54
|
+
}
|
|
55
|
+
}, disabled: loading, children: _jsx(Close, { fontSize: "small" }) }) }))] }), loading && _jsx(LinearProgress, { sx: { left: 0, bottom: 0, right: 0, position: 'absolute' } })] }));
|
|
56
|
+
};
|
|
57
|
+
export default CaseTask;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
3
|
+
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
4
|
+
import NotFoundPage from '@cccsaurora/howler-ui/components/routes/404';
|
|
5
|
+
import InformationPane from '@cccsaurora/howler-ui/components/routes/hits/search/InformationPane';
|
|
6
|
+
import ObservableViewer from '@cccsaurora/howler-ui/components/routes/observables/ObservableViewer';
|
|
7
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { useOutletContext, useParams } from 'react-router-dom';
|
|
9
|
+
import useCase from '../hooks/useCase';
|
|
10
|
+
import CaseDashboard from './CaseDashboard';
|
|
11
|
+
const ItemPage = ({ case: providedCase }) => {
|
|
12
|
+
const params = useParams();
|
|
13
|
+
const routeCase = useOutletContext();
|
|
14
|
+
const { case: fetchedCase } = useCase({ caseId: !providedCase && !routeCase ? params.id : undefined });
|
|
15
|
+
const _case = providedCase ?? routeCase ?? fetchedCase;
|
|
16
|
+
const { dispatchApi } = useMyApi();
|
|
17
|
+
const [item, setItem] = useState(null);
|
|
18
|
+
const [loading, setLoading] = useState(true);
|
|
19
|
+
// When rendered as a child route, the wildcard segment is in params['*'].
|
|
20
|
+
// When rendered directly with a case prop, fall back to parsing the pathname.
|
|
21
|
+
const subPath = params['*'] ?? '';
|
|
22
|
+
const normalizedSubPath = useMemo(() => subPath.replace(/^\/+|\/+$/g, ''), [subPath]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
let cancelled = false;
|
|
25
|
+
const resolveItem = async () => {
|
|
26
|
+
setLoading(true);
|
|
27
|
+
if (!normalizedSubPath) {
|
|
28
|
+
if (!cancelled) {
|
|
29
|
+
setItem(null);
|
|
30
|
+
setLoading(false);
|
|
31
|
+
}
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let currentCase = _case;
|
|
35
|
+
let remainingPath = normalizedSubPath;
|
|
36
|
+
while (currentCase && remainingPath) {
|
|
37
|
+
const currentRemainingPath = remainingPath;
|
|
38
|
+
const matchedNestedCase = currentCase.items
|
|
39
|
+
.filter(_item => _item?.path &&
|
|
40
|
+
_item?.type?.toLowerCase() === 'case' &&
|
|
41
|
+
(currentRemainingPath === _item.path || currentRemainingPath.startsWith(`${_item.path}/`)))
|
|
42
|
+
.sort((a, b) => (b.path?.length || 0) - (a.path?.length || 0))[0];
|
|
43
|
+
if (!matchedNestedCase) {
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
if (currentRemainingPath === matchedNestedCase.path) {
|
|
47
|
+
if (!cancelled) {
|
|
48
|
+
setItem(matchedNestedCase);
|
|
49
|
+
setLoading(false);
|
|
50
|
+
}
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (!matchedNestedCase.id) {
|
|
54
|
+
if (!cancelled) {
|
|
55
|
+
setItem(null);
|
|
56
|
+
setLoading(false);
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const nextCase = await dispatchApi(api.v2.case.get(matchedNestedCase.id), { throwError: false });
|
|
61
|
+
if (!nextCase) {
|
|
62
|
+
if (!cancelled) {
|
|
63
|
+
setItem(null);
|
|
64
|
+
setLoading(false);
|
|
65
|
+
}
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
remainingPath = currentRemainingPath.slice((matchedNestedCase.path?.length || 0) + 1);
|
|
69
|
+
currentCase = nextCase;
|
|
70
|
+
}
|
|
71
|
+
const resolvedItem = currentCase?.items?.find(_item => _item.path === remainingPath);
|
|
72
|
+
if (!cancelled) {
|
|
73
|
+
setItem(resolvedItem || null);
|
|
74
|
+
setLoading(false);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
resolveItem();
|
|
78
|
+
return () => {
|
|
79
|
+
cancelled = true;
|
|
80
|
+
};
|
|
81
|
+
}, [_case, dispatchApi, normalizedSubPath]);
|
|
82
|
+
if (loading) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
if (!item) {
|
|
86
|
+
return _jsx(NotFoundPage, {});
|
|
87
|
+
}
|
|
88
|
+
if (item.type === 'hit') {
|
|
89
|
+
return _jsx(InformationPane, { selected: item.id });
|
|
90
|
+
}
|
|
91
|
+
if (item.type === 'observable') {
|
|
92
|
+
return _jsx(ObservableViewer, { observableId: item.id });
|
|
93
|
+
}
|
|
94
|
+
if (item.type === 'case') {
|
|
95
|
+
return _jsx(CaseDashboard, { caseId: item.id });
|
|
96
|
+
}
|
|
97
|
+
return _jsx("h1", { children: JSON.stringify(item) });
|
|
98
|
+
};
|
|
99
|
+
export default ItemPage;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Divider, Pagination, Skeleton, Stack, Typography, useTheme } from '@mui/material';
|
|
3
|
+
import { chunk, uniq } from 'lodash-es';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { Link } from 'react-router-dom';
|
|
7
|
+
import CaseCard from '../../../elements/case/CaseCard';
|
|
8
|
+
const RelatedCasePanel = ({ case: _case }) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const [casePage, setCasePage] = useState(1);
|
|
12
|
+
const casePages = useMemo(() => chunk(uniq((_case?.items ?? []).filter(item => item.type === 'case')), 5), [_case?.items]);
|
|
13
|
+
if (!_case) {
|
|
14
|
+
return _jsx(Skeleton, { height: 240 });
|
|
15
|
+
}
|
|
16
|
+
return (_jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", children: [_jsx(Typography, { flex: 1, variant: "h4", children: t('page.cases.dashboard.cases') }), _jsx(Pagination, { count: casePages.length, page: casePage, onChange: (_, page) => setCasePage(page) })] }), _jsx(Divider, {}), casePages[casePage - 1]?.map(item => (_jsxs(Box, { position: "relative", children: [_jsx(CaseCard, { caseId: item.id }), _jsx(Box, { component: Link, to: item.path, sx: {
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
top: 0,
|
|
19
|
+
left: 0,
|
|
20
|
+
width: '100%',
|
|
21
|
+
height: '100%',
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
zIndex: 100,
|
|
24
|
+
borderRadius: '4px',
|
|
25
|
+
'&:hover': {
|
|
26
|
+
background: theme.palette.divider,
|
|
27
|
+
border: `thin solid ${theme.palette.primary.light}`
|
|
28
|
+
}
|
|
29
|
+
} })] }, item.id)))] }));
|
|
30
|
+
};
|
|
31
|
+
export default RelatedCasePanel;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Add } from '@mui/icons-material';
|
|
3
|
+
import { Divider, Skeleton, Stack, Typography } from '@mui/material';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import CaseTask from './CaseTask';
|
|
7
|
+
const TaskPanel = ({ case: _case, updateCase }) => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
const [addingTask, setAddingTask] = useState(false);
|
|
10
|
+
const onEdit = (task) => async (newTask) => {
|
|
11
|
+
if (task) {
|
|
12
|
+
await updateCase({
|
|
13
|
+
tasks: _case.tasks.map(_task => {
|
|
14
|
+
if (_task.id !== task.id) {
|
|
15
|
+
return _task;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
..._task,
|
|
19
|
+
...newTask
|
|
20
|
+
};
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
await updateCase({
|
|
26
|
+
tasks: [..._case.tasks, newTask]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
if (!_case) {
|
|
31
|
+
return _jsx(Skeleton, { height: 240 });
|
|
32
|
+
}
|
|
33
|
+
return (_jsxs(Stack, { spacing: 1, children: [_jsx(Typography, { flex: 1, variant: "h4", children: t('page.cases.dashboard.tasks') }), _jsx(Divider, {}), _case.tasks.map(task => (_jsx(CaseTask, { task: task, paths: _case.items.map(item => item.path), onEdit: onEdit(task), onDelete: () => updateCase({ tasks: _case.tasks.filter(_task => _task.id !== task.id) }) }, task.id))), addingTask && (_jsx(CaseTask, { newTask: true, paths: _case.items.map(item => item.path), onEdit: async (task) => {
|
|
34
|
+
await onEdit()(task);
|
|
35
|
+
setAddingTask(false);
|
|
36
|
+
}, onDelete: async () => setAddingTask(false) })), _jsxs(Stack, { onClick: () => setAddingTask(true), direction: "row", spacing: 2, sx: theme => ({
|
|
37
|
+
borderStyle: 'dashed',
|
|
38
|
+
borderColor: theme.palette.text.secondary,
|
|
39
|
+
borderWidth: '0.15rem',
|
|
40
|
+
borderRadius: '0.15rem',
|
|
41
|
+
opacity: 0.3,
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
padding: 1,
|
|
45
|
+
transition: theme.transitions.create('opacity'),
|
|
46
|
+
'&:hover': {
|
|
47
|
+
opacity: 1,
|
|
48
|
+
cursor: 'pointer'
|
|
49
|
+
}
|
|
50
|
+
}), children: [_jsx(Add, {}), _jsx(Typography, { children: t('page.cases.dashboard.tasks.add') })] })] }));
|
|
51
|
+
};
|
|
52
|
+
export default TaskPanel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
|
|
2
|
+
import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
|
|
3
|
+
import { type FC } from 'react';
|
|
4
|
+
declare const CaseAggregate: FC<{
|
|
5
|
+
icon?: string;
|
|
6
|
+
iconColor?: string;
|
|
7
|
+
field?: string;
|
|
8
|
+
records?: Partial<Hit | Observable>[];
|
|
9
|
+
title?: string;
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
}>;
|
|
12
|
+
export default CaseAggregate;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from '@iconify/react';
|
|
3
|
+
import { Card, CardContent, Skeleton, Stack, styled, Tooltip, tooltipClasses, Typography, useTheme } from '@mui/material';
|
|
4
|
+
import { get, isEmpty, uniq } from 'lodash-es';
|
|
5
|
+
import {} from 'react';
|
|
6
|
+
const NoMaxWidthTooltip = styled(({ className, ...props }) => (_jsx(Tooltip, { ...props, classes: { popper: className } })))({
|
|
7
|
+
[`& .${tooltipClasses.tooltip}`]: {
|
|
8
|
+
maxWidth: 'none'
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const CaseAggregate = ({ icon, iconColor, field, records, title, subtitle }) => {
|
|
12
|
+
const theme = useTheme();
|
|
13
|
+
if (!title && (!records || !field)) {
|
|
14
|
+
return _jsx(Skeleton, { height: 120 });
|
|
15
|
+
}
|
|
16
|
+
const values = uniq(records?.map(_record => get(_record, field)).flat());
|
|
17
|
+
return (_jsx(Card, { sx: { height: '100%' }, children: _jsx(CardContent, { children: _jsxs(Stack, { alignItems: "center", spacing: 1, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [icon && _jsx(Icon, { fontSize: "96px", icon: icon, color: iconColor || theme.palette.grey[700] }), _jsx(NoMaxWidthTooltip, { title: !isEmpty(values) && (_jsx(Stack, { spacing: 0.5, children: values.map(value => (_jsx("span", { children: value }, value))) })), children: _jsxs(Typography, { variant: "h3", children: [values.length, !isEmpty(values) && !!title && ' - ', title] }) })] }), _jsx(Typography, { color: "textSecondary", children: subtitle })] }) }) }));
|
|
18
|
+
};
|
|
19
|
+
export default CaseAggregate;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Chip, Grid, Skeleton } from '@mui/material';
|
|
3
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
4
|
+
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
5
|
+
import { uniq } from 'lodash-es';
|
|
6
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
7
|
+
import useCase from '../../hooks/useCase';
|
|
8
|
+
const SourceAggregate = ({ case: providedCase }) => {
|
|
9
|
+
const { dispatchApi } = useMyApi();
|
|
10
|
+
const { case: _case } = useCase({ case: providedCase });
|
|
11
|
+
const [analytics, setAnalytics] = useState([]);
|
|
12
|
+
const hitIds = useMemo(() => _case?.items.filter(item => item.type === 'hit').map(item => item.id), [_case?.items]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
dispatchApi(api.v2.search.post('hit', { query: `howler.id:(${hitIds.join(' OR ')})`, fl: 'howler.analytic' }))
|
|
15
|
+
.then(response => response?.items.map(hit => hit.howler.analytic) ?? [])
|
|
16
|
+
.then(_analytics => setAnalytics(uniq(_analytics)));
|
|
17
|
+
api.v2.search.facet.post(['hit', 'observable'], {
|
|
18
|
+
query: `howler.id:(${hitIds.join(' OR ')})`,
|
|
19
|
+
fields: ['howler.analytic']
|
|
20
|
+
});
|
|
21
|
+
}, [dispatchApi, hitIds]);
|
|
22
|
+
if (!_case) {
|
|
23
|
+
return _jsx(Skeleton, { height: 12, variant: "rounded" });
|
|
24
|
+
}
|
|
25
|
+
return (_jsx(Grid, { container: true, spacing: 1, children: analytics.map(_analytic => (_jsx(Grid, { item: true, children: _jsx(Chip, { size: "small", label: _analytic }) }, _analytic))) }));
|
|
26
|
+
};
|
|
27
|
+
export default SourceAggregate;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Case } from '@cccsaurora/howler-ui/models/entities/generated/Case';
|
|
2
|
+
import type { FC } from 'react';
|
|
3
|
+
export type AssetType = 'hash' | 'hosts' | 'ip' | 'user' | 'ids' | 'id' | 'uri' | 'signature';
|
|
4
|
+
export interface AssetEntry {
|
|
5
|
+
type: AssetType;
|
|
6
|
+
value: string;
|
|
7
|
+
/** IDs of the hits/observables this asset was seen in */
|
|
8
|
+
seenIn: string[];
|
|
9
|
+
}
|
|
10
|
+
declare const Asset: FC<{
|
|
11
|
+
asset: AssetEntry;
|
|
12
|
+
case: Case;
|
|
13
|
+
}>;
|
|
14
|
+
export default Asset;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, CardContent, Chip, Stack, Typography } from '@mui/material';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { Link } from 'react-router-dom';
|
|
5
|
+
const Asset = ({ asset, case: _case }) => {
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
return (_jsx(Card, { sx: { height: '100%' }, children: _jsx(CardContent, { children: _jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [_jsx(Chip, { size: "small", label: t(`page.cases.assets.type.${asset.type}`), color: "primary", variant: "outlined" }), _jsx(Typography, { variant: "body2", sx: { wordBreak: 'break-all', fontFamily: 'monospace' }, children: asset.value })] }), asset.seenIn.length > 0 && (_jsxs(Stack, { spacing: 0.5, children: [_jsx(Typography, { variant: "caption", color: "text.secondary", children: t('page.cases.assets.seen_in') }), _jsx(Stack, { direction: "row", flexWrap: "wrap", gap: 0.5, children: asset.seenIn.map(id => {
|
|
8
|
+
const entry = _case.items.find(item => item.id === id);
|
|
9
|
+
return (_jsx(Chip, { clickable: true, size: "small", label: entry.path, variant: "outlined", component: Link, to: `/cases/${_case.case_id}/${entry.path}` }, id));
|
|
10
|
+
}) })] }))] }) }) }));
|
|
11
|
+
};
|
|
12
|
+
export default Asset;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
5
|
+
import { createMockCase } from '@cccsaurora/howler-ui/tests/utils';
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
import Asset, {} from './Asset';
|
|
8
|
+
const makeAsset = (overrides = {}) => ({
|
|
9
|
+
type: 'ip',
|
|
10
|
+
value: '192.168.1.1',
|
|
11
|
+
seenIn: [],
|
|
12
|
+
...overrides
|
|
13
|
+
});
|
|
14
|
+
describe('Asset', () => {
|
|
15
|
+
describe('type chip', () => {
|
|
16
|
+
it('renders the correct label for each type', () => {
|
|
17
|
+
const cases = ['hash', 'hosts', 'ip', 'user', 'ids', 'id', 'uri', 'signature'];
|
|
18
|
+
for (const type of cases) {
|
|
19
|
+
const { unmount } = render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ type, value: 'x' }), case: createMockCase() }) }));
|
|
20
|
+
expect(screen.getByText(`page.cases.assets.type.${type}`)).toBeTruthy();
|
|
21
|
+
unmount();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('value display', () => {
|
|
26
|
+
it('renders the asset value', () => {
|
|
27
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ value: '10.0.0.1' }), case: createMockCase() }) }));
|
|
28
|
+
expect(screen.getByText('10.0.0.1')).toBeTruthy();
|
|
29
|
+
});
|
|
30
|
+
it('renders long hash values without truncation', () => {
|
|
31
|
+
const hash = 'a'.repeat(64);
|
|
32
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ type: 'hash', value: hash }), case: createMockCase() }) }));
|
|
33
|
+
expect(screen.getByText(hash)).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe('seen-in chips', () => {
|
|
37
|
+
it('renders nothing when seenIn is empty', () => {
|
|
38
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ seenIn: [] }), case: createMockCase() }) }));
|
|
39
|
+
expect(screen.queryByText('page.cases.assets.seen_in')).toBeNull();
|
|
40
|
+
});
|
|
41
|
+
it('renders "Seen in" label when seenIn has entries', () => {
|
|
42
|
+
const _case = createMockCase({
|
|
43
|
+
items: [{ id: 'hit-001', path: 'alerts/test-analytic (hit-001)', type: 'hit', value: 'hit-001' }]
|
|
44
|
+
});
|
|
45
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ seenIn: ['hit-001'] }), case: _case }) }));
|
|
46
|
+
expect(screen.getByText('page.cases.assets.seen_in')).toBeTruthy();
|
|
47
|
+
});
|
|
48
|
+
it('renders a chip labelled with entry.path for each seenIn id', () => {
|
|
49
|
+
const _case = createMockCase({
|
|
50
|
+
items: [
|
|
51
|
+
{ id: 'hit-001', path: 'alerts/my-analytic (hit-001)', type: 'hit', value: 'hit-001' },
|
|
52
|
+
{ id: 'obs-002', path: 'observables/obs-002', type: 'observable', value: 'obs-002' },
|
|
53
|
+
{ id: 'hit-003', path: 'alerts/other-analytic (hit-003)', type: 'hit', value: 'hit-003' }
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ seenIn: ['hit-001', 'obs-002', 'hit-003'] }), case: _case }) }));
|
|
57
|
+
expect(screen.getByText('alerts/my-analytic (hit-001)')).toBeTruthy();
|
|
58
|
+
expect(screen.getByText('observables/obs-002')).toBeTruthy();
|
|
59
|
+
expect(screen.getByText('alerts/other-analytic (hit-003)')).toBeTruthy();
|
|
60
|
+
});
|
|
61
|
+
it('links each chip to /cases/:case_id/:path', () => {
|
|
62
|
+
const _case = createMockCase({
|
|
63
|
+
case_id: 'case-abc',
|
|
64
|
+
items: [{ id: 'hit-001', path: 'alerts/my-analytic (hit-001)', type: 'hit', value: 'hit-001' }]
|
|
65
|
+
});
|
|
66
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ seenIn: ['hit-001'] }), case: _case }) }));
|
|
67
|
+
const link = screen.getByText('alerts/my-analytic (hit-001)').closest('a');
|
|
68
|
+
expect(link).not.toBeNull();
|
|
69
|
+
expect(link?.getAttribute('href')).toBe('/cases/case-abc/alerts/my-analytic (hit-001)');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Case } from '@cccsaurora/howler-ui/models/entities/generated/Case';
|
|
2
|
+
import { type FC } from 'react';
|
|
3
|
+
import type { Tree } from './types';
|
|
4
|
+
interface CaseFolderProps {
|
|
5
|
+
case: Case;
|
|
6
|
+
folder?: Tree;
|
|
7
|
+
name?: string;
|
|
8
|
+
step?: number;
|
|
9
|
+
rootCaseId?: string;
|
|
10
|
+
pathPrefix?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const CaseFolder: FC<CaseFolderProps>;
|
|
13
|
+
export default CaseFolder;
|