@cccsaurora/howler-ui 2.18.0-dev.736 → 2.18.0-dev.739
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 +0 -2
- package/api/index.js +2 -4
- package/api/search/facet/hit.d.ts +3 -1
- package/api/search/facet/index.d.ts +1 -3
- package/api/search/index.d.ts +1 -2
- package/api/search/index.js +1 -2
- package/commons/components/leftnav/LeftNavDrawer.js +1 -1
- package/components/app/App.js +7 -39
- package/components/app/hooks/useMatchers.d.ts +1 -1
- package/components/app/hooks/useMatchers.js +11 -23
- 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/HitProvider.d.ts +22 -0
- package/components/app/providers/{RecordProvider.js → HitProvider.js} +41 -41
- package/components/app/providers/{RecordSearchProvider.d.ts → HitSearchProvider.d.ts} +6 -6
- package/components/app/providers/{RecordSearchProvider.js → HitSearchProvider.js} +17 -12
- package/components/app/providers/{RecordSearchProvider.test.js → HitSearchProvider.test.js} +70 -51
- package/components/app/providers/ModalProvider.d.ts +0 -1
- package/components/app/providers/ParameterProvider.d.ts +2 -9
- package/components/app/providers/ParameterProvider.js +240 -165
- package/components/app/providers/ParameterProvider.test.js +94 -346
- package/components/app/providers/UserListProvider.js +8 -28
- package/components/elements/PluginTypography.d.ts +1 -2
- package/components/elements/PluginTypography.js +2 -3
- package/components/elements/UserList.d.ts +2 -5
- package/components/elements/UserList.js +8 -18
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/display/ChipPopper.d.ts +1 -1
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +0 -2
- package/components/elements/display/icons/BundleButton.d.ts +6 -0
- package/components/elements/display/icons/BundleButton.js +32 -0
- package/components/elements/hit/HitActions.js +4 -4
- package/components/elements/hit/HitBanner.d.ts +0 -1
- package/components/elements/hit/HitBanner.js +49 -29
- package/components/elements/hit/HitCard.d.ts +0 -2
- package/components/elements/hit/HitCard.js +7 -7
- package/components/elements/{record/RecordComments.d.ts → hit/HitComments.d.ts} +4 -5
- package/components/elements/{record/RecordComments.js → hit/HitComments.js} +28 -29
- package/components/elements/{ObjectDetails.js → hit/HitDetails.js} +17 -17
- package/components/elements/hit/HitLabels.js +2 -2
- package/components/elements/hit/HitOutline.d.ts +0 -1
- package/components/elements/hit/HitOutline.js +3 -3
- package/components/elements/hit/{HitPreview.d.ts → HitQuickSearch.d.ts} +3 -3
- package/components/elements/hit/{HitPreview.js → HitQuickSearch.js} +4 -10
- package/components/elements/hit/HitRelated.d.ts +6 -0
- package/components/elements/hit/HitRelated.js +7 -0
- package/components/elements/hit/HitSummary.d.ts +1 -2
- package/components/elements/hit/HitSummary.js +5 -6
- package/components/elements/{record/RecordWorklog.d.ts → hit/HitWorklog.d.ts} +3 -4
- package/components/elements/{record/RecordWorklog.js → hit/HitWorklog.js} +13 -15
- package/components/elements/hit/aggregate/HitGraph.js +8 -8
- package/components/elements/hit/outlines/DefaultOutline.js +1 -1
- package/components/elements/view/ViewTitle.d.ts +0 -1
- package/components/elements/view/ViewTitle.js +2 -9
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +4 -4
- package/components/hooks/{useRecordSelection.d.ts → useHitSelection.d.ts} +2 -2
- package/components/hooks/{useRecordSelection.js → useHitSelection.js} +33 -12
- package/components/hooks/useMyPreferences.js +1 -10
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +1 -4
- package/components/hooks/useMyTheme.js +2 -9
- package/components/hooks/useParamState.test.js +4 -3
- 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/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/BundleDocumentation.d.ts +3 -0
- package/components/routes/help/BundleDocumentation.js +12 -0
- package/components/routes/help/HitBannerDocumentation.js +0 -1
- package/components/routes/help/HitDocumentation.js +3 -1
- package/components/routes/help/markdown/en/bundles.md.js +1 -0
- package/components/routes/help/markdown/fr/bundles.md.js +1 -0
- package/components/routes/hits/search/BundleParentMenu.d.ts +6 -0
- package/components/routes/hits/search/BundleParentMenu.js +32 -0
- package/components/routes/hits/search/BundleScroller.d.ts +2 -0
- package/components/routes/hits/search/BundleScroller.js +6 -0
- package/components/routes/hits/search/{RecordBrowser.js → HitBrowser.js} +9 -9
- package/components/{elements/record/RecordContextMenu.d.ts → routes/hits/search/HitContextMenu.d.ts} +3 -3
- package/components/routes/hits/search/HitContextMenu.js +227 -0
- package/components/{elements/record/RecordContextMenu.test.js → routes/hits/search/HitContextMenu.test.js} +39 -94
- package/components/routes/hits/search/{RecordQuery.d.ts → HitQuery.d.ts} +2 -2
- package/components/routes/hits/search/{RecordQuery.js → HitQuery.js} +6 -6
- package/components/routes/hits/search/InformationPane.d.ts +0 -1
- package/components/routes/hits/search/InformationPane.js +60 -47
- package/components/routes/hits/search/LayoutSettings.js +3 -3
- package/components/routes/hits/search/QuerySettings.js +1 -2
- package/components/routes/hits/search/QuerySettings.test.js +9 -14
- package/components/routes/hits/search/SearchPane.js +49 -26
- 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 +4 -5
- package/components/routes/hits/search/grid/EnhancedCell.d.ts +1 -2
- package/components/routes/hits/search/grid/EnhancedCell.js +2 -2
- package/components/routes/hits/search/grid/HitGrid.js +18 -20
- package/components/routes/hits/search/grid/{RecordRow.d.ts → HitRow.d.ts} +2 -3
- package/components/routes/hits/search/grid/{RecordRow.js → HitRow.js} +8 -10
- package/components/routes/hits/view/HitViewer.js +13 -12
- package/components/routes/home/ViewCard.js +41 -47
- package/components/{elements/MarkdownEditor.js → routes/overviews/OverviewEditor.js} +3 -3
- package/components/routes/overviews/OverviewViewer.js +2 -2
- package/components/routes/views/ViewComposer.js +19 -46
- package/locales/en/translation.json +3 -89
- package/locales/fr/translation.json +3 -87
- package/models/WithMetadata.d.ts +1 -2
- package/models/entities/generated/{ThreatEnrichment.d.ts → Enrichment.d.ts} +1 -1
- package/models/entities/generated/Hit.d.ts +0 -1
- package/models/entities/generated/Howler.d.ts +4 -0
- package/models/entities/generated/Rule.d.ts +10 -2
- package/models/entities/generated/Threat.d.ts +2 -2
- package/models/entities/generated/View.d.ts +0 -1
- package/package.json +103 -120
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +1 -2
- package/tests/mocks.d.ts +1 -11
- package/tests/mocks.js +7 -12
- package/tests/server-handlers.js +1 -6
- package/tests/server.d.ts +1 -1
- package/tests/utils.d.ts +0 -4
- package/tests/utils.js +0 -20
- package/utils/constants.d.ts +3 -3
- package/utils/hitFunctions.d.ts +1 -2
- package/utils/hitFunctions.js +4 -4
- package/utils/viewUtils.js +0 -3
- package/api/search/case.d.ts +0 -4
- package/api/search/case.js +0 -8
- package/api/v2/case/index.d.ts +0 -8
- package/api/v2/case/index.js +0 -20
- package/api/v2/case/items.d.ts +0 -6
- package/api/v2/case/items.js +0 -18
- package/api/v2/index.d.ts +0 -4
- package/api/v2/index.js +0 -6
- package/api/v2/search/facet.d.ts +0 -3
- package/api/v2/search/facet.js +0 -12
- package/api/v2/search/index.d.ts +0 -5
- package/api/v2/search/index.js +0 -24
- package/components/app/providers/RecordProvider.d.ts +0 -23
- package/components/elements/ContextMenu.d.ts +0 -56
- package/components/elements/ContextMenu.js +0 -109
- package/components/elements/ContextMenu.test.js +0 -215
- package/components/elements/ObjectDetails.d.ts +0 -6
- package/components/elements/case/CaseCard.d.ts +0 -12
- package/components/elements/case/CaseCard.js +0 -42
- package/components/elements/case/CasePreview.d.ts +0 -6
- package/components/elements/case/CasePreview.js +0 -17
- package/components/elements/case/StatusIcon.d.ts +0 -5
- package/components/elements/case/StatusIcon.js +0 -13
- package/components/elements/hit/elements/AnalyticLink.d.ts +0 -9
- package/components/elements/hit/elements/AnalyticLink.js +0 -22
- package/components/elements/hit/related/RelatedRecords.js +0 -63
- package/components/elements/observable/ObservableCard.d.ts +0 -6
- package/components/elements/observable/ObservableCard.js +0 -22
- package/components/elements/observable/ObservablePreview.d.ts +0 -6
- package/components/elements/observable/ObservablePreview.js +0 -12
- package/components/elements/record/RecordContextMenu.js +0 -247
- package/components/elements/record/RecordContextMenu.test.d.ts +0 -1
- package/components/elements/record/RecordRelated.d.ts +0 -7
- package/components/elements/record/RecordRelated.js +0 -34
- package/components/hooks/useRelatedRecords.d.ts +0 -13
- package/components/hooks/useRelatedRecords.js +0 -32
- package/components/routes/cases/CaseViewer.d.ts +0 -2
- package/components/routes/cases/CaseViewer.js +0 -22
- package/components/routes/cases/Cases.d.ts +0 -2
- package/components/routes/cases/Cases.js +0 -101
- package/components/routes/cases/constants.d.ts +0 -5
- package/components/routes/cases/constants.js +0 -5
- package/components/routes/cases/detail/AlertPanel.d.ts +0 -6
- package/components/routes/cases/detail/AlertPanel.js +0 -33
- package/components/routes/cases/detail/CaseAssets.d.ts +0 -11
- package/components/routes/cases/detail/CaseAssets.js +0 -104
- package/components/routes/cases/detail/CaseAssets.test.d.ts +0 -1
- package/components/routes/cases/detail/CaseAssets.test.js +0 -167
- package/components/routes/cases/detail/CaseDashboard.d.ts +0 -7
- package/components/routes/cases/detail/CaseDashboard.js +0 -66
- package/components/routes/cases/detail/CaseDetails.d.ts +0 -6
- package/components/routes/cases/detail/CaseDetails.js +0 -61
- package/components/routes/cases/detail/CaseOverview.d.ts +0 -7
- package/components/routes/cases/detail/CaseOverview.js +0 -43
- package/components/routes/cases/detail/CaseSidebar.d.ts +0 -8
- package/components/routes/cases/detail/CaseSidebar.js +0 -107
- package/components/routes/cases/detail/CaseSidebar.test.d.ts +0 -1
- package/components/routes/cases/detail/CaseSidebar.test.js +0 -246
- package/components/routes/cases/detail/CaseTask.d.ts +0 -11
- package/components/routes/cases/detail/CaseTask.js +0 -57
- package/components/routes/cases/detail/CaseTimeline.d.ts +0 -12
- package/components/routes/cases/detail/CaseTimeline.js +0 -106
- package/components/routes/cases/detail/CaseTimeline.test.d.ts +0 -1
- package/components/routes/cases/detail/CaseTimeline.test.js +0 -227
- package/components/routes/cases/detail/ItemPage.d.ts +0 -6
- package/components/routes/cases/detail/ItemPage.js +0 -99
- package/components/routes/cases/detail/RelatedCasePanel.d.ts +0 -6
- package/components/routes/cases/detail/RelatedCasePanel.js +0 -34
- package/components/routes/cases/detail/TaskPanel.d.ts +0 -7
- package/components/routes/cases/detail/TaskPanel.js +0 -52
- package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +0 -11
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +0 -24
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +0 -6
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +0 -26
- package/components/routes/cases/detail/assets/Asset.d.ts +0 -14
- package/components/routes/cases/detail/assets/Asset.js +0 -12
- package/components/routes/cases/detail/assets/Asset.test.d.ts +0 -1
- package/components/routes/cases/detail/assets/Asset.test.js +0 -72
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +0 -20
- package/components/routes/cases/detail/sidebar/CaseFolder.js +0 -83
- package/components/routes/cases/detail/sidebar/CaseFolder.test.d.ts +0 -1
- package/components/routes/cases/detail/sidebar/CaseFolder.test.js +0 -295
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.d.ts +0 -34
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.js +0 -103
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.d.ts +0 -1
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.js +0 -363
- package/components/routes/cases/detail/sidebar/FolderEntry.d.ts +0 -25
- package/components/routes/cases/detail/sidebar/FolderEntry.js +0 -88
- package/components/routes/cases/detail/sidebar/FolderEntry.test.d.ts +0 -1
- package/components/routes/cases/detail/sidebar/FolderEntry.test.js +0 -206
- package/components/routes/cases/detail/sidebar/RootDropZone.d.ts +0 -5
- package/components/routes/cases/detail/sidebar/RootDropZone.js +0 -33
- package/components/routes/cases/detail/sidebar/types.d.ts +0 -9
- package/components/routes/cases/detail/sidebar/utils.d.ts +0 -3
- package/components/routes/cases/detail/sidebar/utils.js +0 -29
- package/components/routes/cases/detail/sidebar/utils.test.d.ts +0 -1
- package/components/routes/cases/detail/sidebar/utils.test.js +0 -82
- package/components/routes/cases/hooks/useCase.d.ts +0 -13
- package/components/routes/cases/hooks/useCase.js +0 -51
- package/components/routes/cases/modals/AddToCaseModal.d.ts +0 -7
- package/components/routes/cases/modals/AddToCaseModal.js +0 -62
- package/components/routes/cases/modals/RenameItemModal.d.ts +0 -9
- package/components/routes/cases/modals/RenameItemModal.js +0 -48
- package/components/routes/cases/modals/ResolveModal.d.ts +0 -7
- package/components/routes/cases/modals/ResolveModal.js +0 -115
- package/components/routes/cases/modals/ResolveModal.test.d.ts +0 -1
- package/components/routes/cases/modals/ResolveModal.test.js +0 -384
- package/components/routes/hits/search/shared/IndexPicker.d.ts +0 -2
- package/components/routes/hits/search/shared/IndexPicker.js +0 -20
- package/components/routes/observables/ObservableViewer.d.ts +0 -7
- package/components/routes/observables/ObservableViewer.js +0 -27
- package/models/entities/generated/AttachmentsFile.d.ts +0 -12
- package/models/entities/generated/Case.d.ts +0 -28
- package/models/entities/generated/DestinationOriginal.d.ts +0 -19
- package/models/entities/generated/EmailAttachment.d.ts +0 -8
- package/models/entities/generated/EmailParent.d.ts +0 -19
- package/models/entities/generated/Enrichments.d.ts +0 -7
- package/models/entities/generated/EnrichmentsIndicator.d.ts +0 -21
- package/models/entities/generated/HttpResponse.d.ts +0 -11
- package/models/entities/generated/Item.d.ts +0 -9
- package/models/entities/generated/Observable.d.ts +0 -85
- package/models/entities/generated/ObservableCloud.d.ts +0 -20
- package/models/entities/generated/ObservableDestination.d.ts +0 -23
- package/models/entities/generated/ObservableEmail.d.ts +0 -30
- package/models/entities/generated/ObservableFile.d.ts +0 -36
- package/models/entities/generated/ObservableHowler.d.ts +0 -43
- package/models/entities/generated/ObservableHttp.d.ts +0 -11
- package/models/entities/generated/ObservableObserver.d.ts +0 -21
- package/models/entities/generated/ObservableOrganization.d.ts +0 -7
- package/models/entities/generated/ObservableProcess.d.ts +0 -34
- package/models/entities/generated/ObservableSource.d.ts +0 -23
- package/models/entities/generated/ObservableThreat.d.ts +0 -21
- package/models/entities/generated/ObservableTls.d.ts +0 -12
- package/models/entities/generated/ObserverIngress.d.ts +0 -9
- package/models/entities/generated/Task.d.ts +0 -10
- package/utils/typeUtils.d.ts +0 -7
- package/utils/typeUtils.js +0 -27
- /package/components/app/providers/{RecordSearchProvider.test.d.ts → HitSearchProvider.test.d.ts} +0 -0
- /package/components/elements/hit/{related/RelatedRecords.d.ts → HitDetails.d.ts} +0 -0
- /package/components/routes/hits/search/{RecordBrowser.d.ts → HitBrowser.d.ts} +0 -0
- /package/components/{elements/ContextMenu.test.d.ts → routes/hits/search/HitContextMenu.test.d.ts} +0 -0
- /package/components/{elements/MarkdownEditor.d.ts → routes/overviews/OverviewEditor.d.ts} +0 -0
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { KeyboardArrowDown, OpenInNew } from '@mui/icons-material';
|
|
3
|
-
import { Accordion, AccordionDetails, AccordionSummary, Autocomplete, Box, Button, Checkbox, Chip, CircularProgress, Divider, IconButton, LinearProgress, Skeleton, Stack, TextField, Typography } from '@mui/material';
|
|
4
|
-
import api from '@cccsaurora/howler-ui/api';
|
|
5
|
-
import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
|
|
6
|
-
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
7
|
-
import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
|
|
8
|
-
import AnalyticLink from '@cccsaurora/howler-ui/components/elements/hit/elements/AnalyticLink';
|
|
9
|
-
import EscalationChip from '@cccsaurora/howler-ui/components/elements/hit/elements/EscalationChip';
|
|
10
|
-
import HitCard from '@cccsaurora/howler-ui/components/elements/hit/HitCard';
|
|
11
|
-
import { HitLayout } from '@cccsaurora/howler-ui/components/elements/hit/HitLayout';
|
|
12
|
-
import useHitActions from '@cccsaurora/howler-ui/components/hooks/useHitActions';
|
|
13
|
-
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
14
|
-
import { isNil, uniq } from 'lodash-es';
|
|
15
|
-
import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
16
|
-
import { useTranslation } from 'react-i18next';
|
|
17
|
-
import { Link } from 'react-router-dom';
|
|
18
|
-
import { useContextSelector } from 'use-context-selector';
|
|
19
|
-
import useCase from '../hooks/useCase';
|
|
20
|
-
const HitEntry = ({ hit, checked, onChange }) => {
|
|
21
|
-
if (!hit) {
|
|
22
|
-
return _jsx(Skeleton, { variant: "rounded", height: "40px", width: "100%" });
|
|
23
|
-
}
|
|
24
|
-
return (_jsxs(Accordion, { sx: { flexShrink: 0, px: 0, py: 0 }, children: [_jsx(AccordionSummary, { expandIcon: _jsx(KeyboardArrowDown, {}), sx: {
|
|
25
|
-
px: 1,
|
|
26
|
-
py: 0,
|
|
27
|
-
minHeight: '48px !important',
|
|
28
|
-
'& > *': {
|
|
29
|
-
margin: '0 !important'
|
|
30
|
-
}
|
|
31
|
-
}, children: _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, pr: 1, width: "100%", children: [!isNil(checked) && (_jsx(Checkbox, { size: "small", checked: checked, onClick: e => {
|
|
32
|
-
onChange?.();
|
|
33
|
-
e.preventDefault();
|
|
34
|
-
e.stopPropagation();
|
|
35
|
-
} })), _jsx(AnalyticLink, { hit: hit, compressed: true, alignSelf: "center" }), _jsx(EscalationChip, { hit: hit, layout: HitLayout.DENSE }), _jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, size: "small", color: "primary" }), _jsx("div", { style: { flex: 1 } }), _jsx(IconButton, { size: "small", component: Link, to: `/hits/${hit.howler.id}`, children: _jsx(OpenInNew, { fontSize: "small" }) })] }) }), _jsx(AccordionDetails, { children: _jsx(HitCard, { id: hit.howler.id, layout: HitLayout.NORMAL, elevation: 0 }) })] }, hit.howler.id));
|
|
36
|
-
};
|
|
37
|
-
const ResolveModal = ({ case: _case, onConfirm }) => {
|
|
38
|
-
const { t } = useTranslation();
|
|
39
|
-
const { dispatchApi } = useMyApi();
|
|
40
|
-
const { close } = useContext(ModalContext);
|
|
41
|
-
const { config } = useContext(ApiConfigContext);
|
|
42
|
-
const { update: updateCase } = useCase({ case: _case });
|
|
43
|
-
const [loading, setLoading] = useState(true);
|
|
44
|
-
const [rationale, setRationale] = useState('');
|
|
45
|
-
const [assessment, setAssessment] = useState(null);
|
|
46
|
-
const [selectedHitIds, setSelectedHitIds] = useState(new Set());
|
|
47
|
-
const hitIds = useMemo(() => uniq((_case?.items ?? [])
|
|
48
|
-
.filter(item => item.type === 'hit')
|
|
49
|
-
.map(item => item.value)
|
|
50
|
-
.filter(Boolean)), [_case?.items]);
|
|
51
|
-
const loadRecords = useContextSelector(RecordContext, ctx => ctx.loadRecords);
|
|
52
|
-
const records = useContextSelector(RecordContext, ctx => ctx.records);
|
|
53
|
-
const hits = useMemo(() => hitIds.map(id => records[id]).filter(Boolean), [hitIds, records]);
|
|
54
|
-
const selectedHits = useMemo(() => hits.filter(hit => selectedHitIds.has(hit.howler.id)), [hits, selectedHitIds]);
|
|
55
|
-
const { assess } = useHitActions(selectedHits);
|
|
56
|
-
const unresolvedHits = useMemo(() => hitIds.filter(id => {
|
|
57
|
-
const record = records[id];
|
|
58
|
-
if (!record) {
|
|
59
|
-
// Treat missing records as unresolved until they are loaded
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
return record.howler.status !== 'resolved';
|
|
63
|
-
}), [hitIds, records]);
|
|
64
|
-
const handleConfirm = async () => {
|
|
65
|
-
setLoading(true);
|
|
66
|
-
try {
|
|
67
|
-
await assess(assessment, true, rationale);
|
|
68
|
-
setSelectedHitIds(new Set());
|
|
69
|
-
}
|
|
70
|
-
finally {
|
|
71
|
-
setLoading(false);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
const handleToggleHit = useCallback((hitId) => {
|
|
75
|
-
setSelectedHitIds(prev => {
|
|
76
|
-
const next = new Set(prev);
|
|
77
|
-
if (next.has(hitId)) {
|
|
78
|
-
next.delete(hitId);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
next.add(hitId);
|
|
82
|
-
}
|
|
83
|
-
return next;
|
|
84
|
-
});
|
|
85
|
-
}, []);
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
(async () => {
|
|
88
|
-
try {
|
|
89
|
-
const result = await dispatchApi(api.search.hit.post({
|
|
90
|
-
query: `howler.id:(${hitIds.join(' OR ')})`,
|
|
91
|
-
metadata: ['analytic']
|
|
92
|
-
}));
|
|
93
|
-
loadRecords(result.items);
|
|
94
|
-
}
|
|
95
|
-
finally {
|
|
96
|
-
setLoading(false);
|
|
97
|
-
}
|
|
98
|
-
})();
|
|
99
|
-
}, [dispatchApi, hitIds, loadRecords]);
|
|
100
|
-
useEffect(() => {
|
|
101
|
-
if (loading || unresolvedHits.length > 0) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
updateCase({ status: 'resolved' }).then(() => {
|
|
105
|
-
onConfirm();
|
|
106
|
-
close();
|
|
107
|
-
});
|
|
108
|
-
}, [close, loading, onConfirm, unresolvedHits.length, updateCase]);
|
|
109
|
-
return (_jsxs(Stack, { spacing: 2, p: 2, alignItems: "start", sx: { minWidth: 'min(1000px, 60vw)', maxHeight: '100%', height: '100%' }, children: [_jsx(Typography, { variant: "h4", children: t('modal.cases.resolve') }), _jsx(Typography, { children: t('modal.cases.resolve.description') }), _jsxs(Stack, { spacing: 1, overflow: "auto", width: "100%", flex: 1, children: [_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Box, { flex: 1, children: _jsx(TextField, { size: "small", fullWidth: true, placeholder: t('modal.rationale.label'), "aria-label": t('modal.rationale.label'), value: rationale, onChange: ev => setRationale(ev.target.value) }) }), _jsx(Box, { flex: 1, children: _jsx(Autocomplete, { size: "small", value: assessment, onChange: (_ev, _assessment) => setAssessment(_assessment), options: config.lookups['howler.assessment'], disablePortal: true, renderInput: params => (_jsx(TextField, { ...params, placeholder: t('hit.details.actions.assessment'), "aria-label": t('hit.details.actions.assessment'), fullWidth: true })) }) })] }), _jsxs(Stack, { position: "relative", children: [_jsx(Divider, {}), _jsx(LinearProgress, { sx: { opacity: +loading } })] }), hits
|
|
110
|
-
.filter(hit => unresolvedHits.includes(hit.howler.id))
|
|
111
|
-
.map(hit => (_jsx(HitEntry, { hit: hit, checked: selectedHitIds.has(hit.howler.id), onChange: () => handleToggleHit(hit.howler.id) }, hit.howler.id))), _jsxs(Accordion, { variant: "outlined", children: [_jsx(AccordionSummary, { expandIcon: _jsx(KeyboardArrowDown, {}), children: t('modal.cases.alerts.resolved') }), _jsx(AccordionDetails, { children: _jsx(Stack, { spacing: 1, children: hits
|
|
112
|
-
.filter(hit => !unresolvedHits.includes(hit.howler.id))
|
|
113
|
-
.map(hit => (_jsx(HitEntry, { hit: hit }, hit.howler.id))) }) })] })] }), _jsxs(Stack, { direction: "row", spacing: 1, alignSelf: "end", children: [_jsx(Button, { variant: "outlined", color: "error", onClick: close, children: t('cancel') }), _jsx(Button, { variant: "outlined", color: "success", disabled: loading || !assessment || !rationale || selectedHitIds.size === 0, startIcon: loading ? _jsx(CircularProgress, { size: 16, color: "inherit" }) : undefined, onClick: handleConfirm, children: t('confirm') })] })] }));
|
|
114
|
-
};
|
|
115
|
-
export default ResolveModal;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,384 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/// <reference types="vitest" />
|
|
3
|
-
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
4
|
-
import userEvent, {} from '@testing-library/user-event';
|
|
5
|
-
import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
|
|
6
|
-
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
7
|
-
import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
|
|
8
|
-
import i18n from '@cccsaurora/howler-ui/i18n';
|
|
9
|
-
import {} from 'react';
|
|
10
|
-
import { I18nextProvider } from 'react-i18next';
|
|
11
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
12
|
-
import { createMockCase, createMockHit } from '@cccsaurora/howler-ui/tests/utils';
|
|
13
|
-
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
14
|
-
import ResolveModal from './ResolveModal';
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
// Hoisted mocks
|
|
17
|
-
// ---------------------------------------------------------------------------
|
|
18
|
-
const mockAssess = vi.hoisted(() => vi.fn().mockResolvedValue(undefined));
|
|
19
|
-
const mockDispatchApi = vi.hoisted(() => vi.fn());
|
|
20
|
-
const mockUpdateCase = vi.hoisted(() => vi.fn().mockResolvedValue(undefined));
|
|
21
|
-
const mockClose = vi.hoisted(() => vi.fn());
|
|
22
|
-
const mockLoadRecords = vi.hoisted(() => vi.fn());
|
|
23
|
-
vi.mock('components/hooks/useMyApi', () => ({
|
|
24
|
-
default: () => ({ dispatchApi: mockDispatchApi })
|
|
25
|
-
}));
|
|
26
|
-
vi.mock('components/hooks/useHitActions', () => ({
|
|
27
|
-
default: () => ({ assess: mockAssess })
|
|
28
|
-
}));
|
|
29
|
-
vi.mock('../hooks/useCase', () => ({
|
|
30
|
-
default: () => ({ update: mockUpdateCase })
|
|
31
|
-
}));
|
|
32
|
-
vi.mock('components/elements/hit/elements/AnalyticLink', () => ({
|
|
33
|
-
default: ({ hit }) => _jsx("span", { "data-testid": `analytic-${hit.howler.id}`, children: hit.howler.analytic })
|
|
34
|
-
}));
|
|
35
|
-
vi.mock('components/elements/hit/elements/EscalationChip', () => ({
|
|
36
|
-
default: () => null
|
|
37
|
-
}));
|
|
38
|
-
vi.mock('components/elements/hit/HitCard', () => ({
|
|
39
|
-
default: ({ id }) => _jsx("div", { children: `HitCard:${id}` })
|
|
40
|
-
}));
|
|
41
|
-
vi.mock('api', () => ({
|
|
42
|
-
default: {
|
|
43
|
-
search: {
|
|
44
|
-
hit: {
|
|
45
|
-
post: (params) => params
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}));
|
|
50
|
-
vi.mock('commons/components/app/hooks/useAppUser', () => ({
|
|
51
|
-
useAppUser: () => ({ user: { username: 'test-user' } })
|
|
52
|
-
}));
|
|
53
|
-
// ---------------------------------------------------------------------------
|
|
54
|
-
// Fixtures
|
|
55
|
-
// ---------------------------------------------------------------------------
|
|
56
|
-
const mockConfig = {
|
|
57
|
-
lookups: {
|
|
58
|
-
'howler.assessment': ['legitimate', 'false_positive', 'non_issue']
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
const makeUnresolvedHit = (id) => createMockHit({ howler: { id, status: 'open', analytic: `analytic-${id}` } });
|
|
62
|
-
const makeResolvedHit = (id) => createMockHit({ howler: { id, status: 'resolved', analytic: `analytic-${id}` } });
|
|
63
|
-
const HIT_1 = makeUnresolvedHit('hit-1');
|
|
64
|
-
const HIT_2 = makeUnresolvedHit('hit-2');
|
|
65
|
-
const HIT_RESOLVED = makeResolvedHit('hit-resolved');
|
|
66
|
-
const caseWithHits = (hitIds) => createMockCase({
|
|
67
|
-
case_id: 'case-1',
|
|
68
|
-
items: hitIds.map(id => ({ type: 'hit', value: id }))
|
|
69
|
-
});
|
|
70
|
-
// ---------------------------------------------------------------------------
|
|
71
|
-
// Wrapper factory
|
|
72
|
-
// ---------------------------------------------------------------------------
|
|
73
|
-
const createWrapper = (records = {}) => {
|
|
74
|
-
const Wrapper = ({ children }) => (_jsx(I18nextProvider, { i18n: i18n, children: _jsx(ModalContext.Provider, { value: { close: mockClose, open: vi.fn(), setContent: vi.fn() }, children: _jsx(ApiConfigContext.Provider, { value: { config: mockConfig, setConfig: vi.fn() }, children: _jsx(RecordContext.Provider, { value: { records, loadRecords: mockLoadRecords }, children: _jsx(MemoryRouter, { children: children }) }) }) }) }));
|
|
75
|
-
return Wrapper;
|
|
76
|
-
};
|
|
77
|
-
// ---------------------------------------------------------------------------
|
|
78
|
-
// Helpers
|
|
79
|
-
// ---------------------------------------------------------------------------
|
|
80
|
-
/**
|
|
81
|
-
* Clicks a MUI Checkbox — operates on the ButtonBase parent of the hidden input
|
|
82
|
-
* so that user-event's special checkbox-input code path is bypassed and the
|
|
83
|
-
* component's own onClick handler fires correctly.
|
|
84
|
-
*/
|
|
85
|
-
const clickCheckbox = (checkbox) => {
|
|
86
|
-
fireEvent.click(checkbox.parentElement);
|
|
87
|
-
};
|
|
88
|
-
/** Fills in assessment and rationale so the confirm button becomes enabled. */
|
|
89
|
-
const fillForm = async (user, assessment = 'legitimate', rationale = 'Test rationale') => {
|
|
90
|
-
const rationaleInput = screen.getByPlaceholderText(i18n.t('modal.rationale.label'));
|
|
91
|
-
await user.clear(rationaleInput);
|
|
92
|
-
await user.type(rationaleInput, rationale);
|
|
93
|
-
// Typing into the combobox triggers MUI Autocomplete's onInputChange which
|
|
94
|
-
// opens the listbox — a plain click does not reliably open it in jsdom.
|
|
95
|
-
// The combobox has no accessible label (only a placeholder), so we query by
|
|
96
|
-
// role alone — there is exactly one combobox in the modal.
|
|
97
|
-
const assessmentInput = screen.getByRole('combobox');
|
|
98
|
-
await user.type(assessmentInput, assessment.slice(0, 3));
|
|
99
|
-
const option = await screen.findByRole('option', { name: assessment });
|
|
100
|
-
await user.click(option);
|
|
101
|
-
};
|
|
102
|
-
// ---------------------------------------------------------------------------
|
|
103
|
-
// Tests
|
|
104
|
-
// ---------------------------------------------------------------------------
|
|
105
|
-
describe('ResolveModal', () => {
|
|
106
|
-
let user;
|
|
107
|
-
let mockOnConfirm;
|
|
108
|
-
beforeEach(() => {
|
|
109
|
-
user = userEvent.setup();
|
|
110
|
-
mockOnConfirm = vi.fn();
|
|
111
|
-
vi.clearAllMocks();
|
|
112
|
-
// Default: resolve immediately with an empty items list
|
|
113
|
-
mockDispatchApi.mockResolvedValue({ items: [] });
|
|
114
|
-
});
|
|
115
|
-
// -------------------------------------------------------------------------
|
|
116
|
-
// Initial render
|
|
117
|
-
// -------------------------------------------------------------------------
|
|
118
|
-
describe('initial render', () => {
|
|
119
|
-
it('shows the modal title', () => {
|
|
120
|
-
render(_jsx(ResolveModal, { case: caseWithHits([]), onConfirm: mockOnConfirm }), {
|
|
121
|
-
wrapper: createWrapper()
|
|
122
|
-
});
|
|
123
|
-
expect(screen.getByText(i18n.t('modal.cases.resolve'))).toBeInTheDocument();
|
|
124
|
-
});
|
|
125
|
-
it('shows the modal description', () => {
|
|
126
|
-
render(_jsx(ResolveModal, { case: caseWithHits([]), onConfirm: mockOnConfirm }), {
|
|
127
|
-
wrapper: createWrapper()
|
|
128
|
-
});
|
|
129
|
-
expect(screen.getByText(i18n.t('modal.cases.resolve.description'))).toBeInTheDocument();
|
|
130
|
-
});
|
|
131
|
-
it('renders a cancel button', () => {
|
|
132
|
-
render(_jsx(ResolveModal, { case: caseWithHits([]), onConfirm: mockOnConfirm }), {
|
|
133
|
-
wrapper: createWrapper()
|
|
134
|
-
});
|
|
135
|
-
expect(screen.getByRole('button', { name: i18n.t('cancel') })).toBeInTheDocument();
|
|
136
|
-
});
|
|
137
|
-
it('renders a confirm button', () => {
|
|
138
|
-
render(_jsx(ResolveModal, { case: caseWithHits([]), onConfirm: mockOnConfirm }), {
|
|
139
|
-
wrapper: createWrapper()
|
|
140
|
-
});
|
|
141
|
-
expect(screen.getByRole('button', { name: i18n.t('confirm') })).toBeInTheDocument();
|
|
142
|
-
});
|
|
143
|
-
it('shows the "Resolved Alerts" accordion', () => {
|
|
144
|
-
render(_jsx(ResolveModal, { case: caseWithHits([]), onConfirm: mockOnConfirm }), {
|
|
145
|
-
wrapper: createWrapper()
|
|
146
|
-
});
|
|
147
|
-
expect(screen.getByText(i18n.t('modal.cases.alerts.resolved'))).toBeInTheDocument();
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
// -------------------------------------------------------------------------
|
|
151
|
-
// Loading state
|
|
152
|
-
// -------------------------------------------------------------------------
|
|
153
|
-
describe('loading state', () => {
|
|
154
|
-
it('shows a LinearProgress while the API call is pending', () => {
|
|
155
|
-
mockDispatchApi.mockReturnValue(new Promise(() => { })); // never resolves
|
|
156
|
-
const { container } = render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
157
|
-
wrapper: createWrapper()
|
|
158
|
-
});
|
|
159
|
-
const progress = container.querySelector('.MuiLinearProgress-root');
|
|
160
|
-
expect(progress).toBeInTheDocument();
|
|
161
|
-
// opacity is 1 while loading
|
|
162
|
-
expect(progress).toHaveStyle({ opacity: '1' });
|
|
163
|
-
});
|
|
164
|
-
it('disables the confirm button while loading', () => {
|
|
165
|
-
mockDispatchApi.mockReturnValue(new Promise(() => { }));
|
|
166
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
167
|
-
wrapper: createWrapper()
|
|
168
|
-
});
|
|
169
|
-
expect(screen.getByRole('button', { name: i18n.t('confirm') })).toBeDisabled();
|
|
170
|
-
});
|
|
171
|
-
it('shows a CircularProgress inside the confirm button while loading', () => {
|
|
172
|
-
mockDispatchApi.mockReturnValue(new Promise(() => { }));
|
|
173
|
-
const { container } = render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
174
|
-
wrapper: createWrapper()
|
|
175
|
-
});
|
|
176
|
-
expect(container.querySelector('.MuiCircularProgress-root')).toBeInTheDocument();
|
|
177
|
-
});
|
|
178
|
-
it('fades out the LinearProgress after loading completes', async () => {
|
|
179
|
-
const { container } = render(_jsx(ResolveModal, { case: caseWithHits([]), onConfirm: mockOnConfirm }), {
|
|
180
|
-
wrapper: createWrapper()
|
|
181
|
-
});
|
|
182
|
-
await waitFor(() => {
|
|
183
|
-
const progress = container.querySelector('.MuiLinearProgress-root');
|
|
184
|
-
expect(progress).toHaveStyle({ opacity: '0' });
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
// -------------------------------------------------------------------------
|
|
189
|
-
// Hit rendering
|
|
190
|
-
// -------------------------------------------------------------------------
|
|
191
|
-
describe('hit rendering', () => {
|
|
192
|
-
it('renders unresolved hits with checkboxes after loading', async () => {
|
|
193
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1', 'hit-2']), onConfirm: mockOnConfirm }), {
|
|
194
|
-
wrapper: createWrapper({ 'hit-1': HIT_1, 'hit-2': HIT_2 })
|
|
195
|
-
});
|
|
196
|
-
await waitFor(() => {
|
|
197
|
-
expect(screen.getAllByRole('checkbox')).toHaveLength(2);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
it('does not show a checkbox for resolved hits', async () => {
|
|
201
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1', 'hit-resolved']), onConfirm: mockOnConfirm }), {
|
|
202
|
-
wrapper: createWrapper({ 'hit-1': HIT_1, 'hit-resolved': HIT_RESOLVED })
|
|
203
|
-
});
|
|
204
|
-
await waitFor(() => {
|
|
205
|
-
// only the single unresolved hit gets a checkbox
|
|
206
|
-
expect(screen.getAllByRole('checkbox')).toHaveLength(1);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
it('calls loadRecords with the API search results', async () => {
|
|
210
|
-
const items = [HIT_1];
|
|
211
|
-
mockDispatchApi.mockResolvedValueOnce({ items });
|
|
212
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
213
|
-
wrapper: createWrapper()
|
|
214
|
-
});
|
|
215
|
-
await waitFor(() => {
|
|
216
|
-
expect(mockLoadRecords).toHaveBeenCalledWith(items);
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
// -------------------------------------------------------------------------
|
|
221
|
-
// Confirm button disabled states
|
|
222
|
-
// -------------------------------------------------------------------------
|
|
223
|
-
describe('confirm button enablement', () => {
|
|
224
|
-
it('is disabled when no hits are selected', async () => {
|
|
225
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
226
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
227
|
-
});
|
|
228
|
-
// Wait for the hit to load (checkbox appears) but don't select it
|
|
229
|
-
await screen.findAllByRole('checkbox');
|
|
230
|
-
await fillForm(user);
|
|
231
|
-
// No hit selected → selectedHitIds.size === 0 → button still disabled
|
|
232
|
-
expect(screen.getByRole('button', { name: i18n.t('confirm') })).toBeDisabled();
|
|
233
|
-
});
|
|
234
|
-
it('is disabled when assessment is missing', async () => {
|
|
235
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
236
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
237
|
-
});
|
|
238
|
-
const [checkbox] = await screen.findAllByRole('checkbox');
|
|
239
|
-
clickCheckbox(checkbox);
|
|
240
|
-
await waitFor(() => expect(checkbox).toBeChecked());
|
|
241
|
-
const rationaleInput = screen.getByPlaceholderText(i18n.t('modal.rationale.label'));
|
|
242
|
-
await user.type(rationaleInput, 'some reason');
|
|
243
|
-
// no assessment chosen → still disabled
|
|
244
|
-
expect(screen.getByRole('button', { name: i18n.t('confirm') })).toBeDisabled();
|
|
245
|
-
});
|
|
246
|
-
it('is disabled when rationale is empty', async () => {
|
|
247
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
248
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
249
|
-
});
|
|
250
|
-
const [checkbox] = await screen.findAllByRole('checkbox');
|
|
251
|
-
clickCheckbox(checkbox);
|
|
252
|
-
await waitFor(() => expect(checkbox).toBeChecked());
|
|
253
|
-
// fill only assessment, no rationale
|
|
254
|
-
const assessmentInput = screen.getByRole('combobox');
|
|
255
|
-
await user.type(assessmentInput, 'leg');
|
|
256
|
-
const option = await screen.findByRole('option', { name: 'legitimate' });
|
|
257
|
-
await user.click(option);
|
|
258
|
-
expect(screen.getByRole('button', { name: i18n.t('confirm') })).toBeDisabled();
|
|
259
|
-
});
|
|
260
|
-
it('is enabled when a hit is selected + assessment + rationale are provided', async () => {
|
|
261
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
262
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
263
|
-
});
|
|
264
|
-
const [checkbox] = await screen.findAllByRole('checkbox');
|
|
265
|
-
clickCheckbox(checkbox);
|
|
266
|
-
await waitFor(() => expect(checkbox).toBeChecked());
|
|
267
|
-
await fillForm(user);
|
|
268
|
-
expect(screen.getByRole('button', { name: i18n.t('confirm') })).toBeEnabled();
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
// -------------------------------------------------------------------------
|
|
272
|
-
// Checkbox / selection toggling
|
|
273
|
-
// -------------------------------------------------------------------------
|
|
274
|
-
describe('hit selection', () => {
|
|
275
|
-
it('checks a hit when its checkbox is clicked', async () => {
|
|
276
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
277
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
278
|
-
});
|
|
279
|
-
const [checkbox] = await screen.findAllByRole('checkbox');
|
|
280
|
-
expect(checkbox).not.toBeChecked();
|
|
281
|
-
clickCheckbox(checkbox);
|
|
282
|
-
await waitFor(() => expect(checkbox).toBeChecked());
|
|
283
|
-
});
|
|
284
|
-
it('unchecks a hit when its checkbox is clicked a second time', async () => {
|
|
285
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
286
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
287
|
-
});
|
|
288
|
-
const [checkbox] = await screen.findAllByRole('checkbox');
|
|
289
|
-
clickCheckbox(checkbox);
|
|
290
|
-
await waitFor(() => expect(checkbox).toBeChecked());
|
|
291
|
-
clickCheckbox(checkbox);
|
|
292
|
-
await waitFor(() => expect(checkbox).not.toBeChecked());
|
|
293
|
-
});
|
|
294
|
-
it('tracks each hit independently when there are multiple', async () => {
|
|
295
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1', 'hit-2']), onConfirm: mockOnConfirm }), {
|
|
296
|
-
wrapper: createWrapper({ 'hit-1': HIT_1, 'hit-2': HIT_2 })
|
|
297
|
-
});
|
|
298
|
-
const checkboxes = await screen.findAllByRole('checkbox');
|
|
299
|
-
expect(checkboxes).toHaveLength(2);
|
|
300
|
-
clickCheckbox(checkboxes[0]);
|
|
301
|
-
await waitFor(() => {
|
|
302
|
-
expect(checkboxes[0]).toBeChecked();
|
|
303
|
-
expect(checkboxes[1]).not.toBeChecked();
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
// -------------------------------------------------------------------------
|
|
308
|
-
// Confirm action
|
|
309
|
-
// -------------------------------------------------------------------------
|
|
310
|
-
describe('confirm action', () => {
|
|
311
|
-
it('calls assess with the chosen assessment, true, and rationale', async () => {
|
|
312
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
313
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
314
|
-
});
|
|
315
|
-
const [checkbox] = await screen.findAllByRole('checkbox');
|
|
316
|
-
clickCheckbox(checkbox);
|
|
317
|
-
await waitFor(() => expect(checkbox).toBeChecked());
|
|
318
|
-
await fillForm(user, 'legitimate', 'My rationale');
|
|
319
|
-
await user.click(screen.getByRole('button', { name: i18n.t('confirm') }));
|
|
320
|
-
await waitFor(() => {
|
|
321
|
-
expect(mockAssess).toHaveBeenCalledWith('legitimate', true, 'My rationale');
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
it('clears the selection after confirm completes', async () => {
|
|
325
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
326
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
327
|
-
});
|
|
328
|
-
const [checkbox] = await screen.findAllByRole('checkbox');
|
|
329
|
-
clickCheckbox(checkbox);
|
|
330
|
-
await waitFor(() => expect(checkbox).toBeChecked());
|
|
331
|
-
await fillForm(user);
|
|
332
|
-
await user.click(screen.getByRole('button', { name: i18n.t('confirm') }));
|
|
333
|
-
await waitFor(() => {
|
|
334
|
-
expect(checkbox).not.toBeChecked();
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
// -------------------------------------------------------------------------
|
|
339
|
-
// Cancel button
|
|
340
|
-
// -------------------------------------------------------------------------
|
|
341
|
-
describe('cancel button', () => {
|
|
342
|
-
it('calls close() when cancel is clicked', async () => {
|
|
343
|
-
// Use a case with an unresolved hit so the auto-resolve effect does not fire
|
|
344
|
-
// and call close() before we even click cancel.
|
|
345
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
346
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
347
|
-
});
|
|
348
|
-
// Wait for loading to finish so no unexpected state transitions happen mid-click
|
|
349
|
-
await screen.findAllByRole('checkbox');
|
|
350
|
-
await user.click(screen.getByRole('button', { name: i18n.t('cancel') }));
|
|
351
|
-
expect(mockClose).toHaveBeenCalledTimes(1);
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
// -------------------------------------------------------------------------
|
|
355
|
-
// Auto-resolve when all hits are already resolved
|
|
356
|
-
// -------------------------------------------------------------------------
|
|
357
|
-
describe('auto-resolve', () => {
|
|
358
|
-
it('calls updateCase, onConfirm, and close when no unresolved hits remain after loading', async () => {
|
|
359
|
-
// All hits in the case are already resolved
|
|
360
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-resolved']), onConfirm: mockOnConfirm }), {
|
|
361
|
-
wrapper: createWrapper({ 'hit-resolved': HIT_RESOLVED })
|
|
362
|
-
});
|
|
363
|
-
// dispatchApi resolves → loading becomes false → unresolvedHits.length === 0 → auto-close
|
|
364
|
-
await waitFor(() => {
|
|
365
|
-
expect(mockUpdateCase).toHaveBeenCalledWith({ status: 'resolved' });
|
|
366
|
-
});
|
|
367
|
-
await waitFor(() => {
|
|
368
|
-
expect(mockOnConfirm).toHaveBeenCalledTimes(1);
|
|
369
|
-
expect(mockClose).toHaveBeenCalledTimes(1);
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
it('does NOT auto-resolve while hits are still unresolved', async () => {
|
|
373
|
-
render(_jsx(ResolveModal, { case: caseWithHits(['hit-1']), onConfirm: mockOnConfirm }), {
|
|
374
|
-
wrapper: createWrapper({ 'hit-1': HIT_1 })
|
|
375
|
-
});
|
|
376
|
-
// Wait for loading to complete: the unresolved hit's checkbox appears once the
|
|
377
|
-
// dispatchApi call settles and the LinearProgress opacity drops to 0.
|
|
378
|
-
await screen.findAllByRole('checkbox');
|
|
379
|
-
// Should not have auto-resolved
|
|
380
|
-
expect(mockUpdateCase).not.toHaveBeenCalled();
|
|
381
|
-
expect(mockClose).not.toHaveBeenCalled();
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
});
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { FilterList } from '@mui/icons-material';
|
|
3
|
-
import { Autocomplete, TextField } from '@mui/material';
|
|
4
|
-
import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
|
|
5
|
-
import ChipPopper from '@cccsaurora/howler-ui/components/elements/display/ChipPopper';
|
|
6
|
-
import { memo } from 'react';
|
|
7
|
-
import { useTranslation } from 'react-i18next';
|
|
8
|
-
import { useContextSelector } from 'use-context-selector';
|
|
9
|
-
const FILTER_OPTIONS = [
|
|
10
|
-
{ label: 'hit.search.index.hit', value: 'hit' },
|
|
11
|
-
{ label: 'hit.search.index.observable', value: 'observable' }
|
|
12
|
-
];
|
|
13
|
-
const IndexPicker = () => {
|
|
14
|
-
const { t } = useTranslation();
|
|
15
|
-
const indexes = useContextSelector(ParameterContext, ctx => ctx.indexes);
|
|
16
|
-
const setIndexes = useContextSelector(ParameterContext, ctx => ctx.setIndexes);
|
|
17
|
-
const selectedOptions = FILTER_OPTIONS.filter(opt => indexes.includes(opt.value));
|
|
18
|
-
return (_jsx(ChipPopper, { icon: _jsx(FilterList, { fontSize: "small" }), label: selectedOptions.map(opt => t(opt.label)).join(', '), minWidth: "225px", slotProps: { chip: { size: 'small' } }, children: _jsx(Autocomplete, { size: "small", multiple: true, options: FILTER_OPTIONS, value: selectedOptions, onChange: (_ev, values) => values.length > 0 && setIndexes(values.map(val => val.value)), isOptionEqualToValue: (opt, val) => opt.value === val.value, getOptionLabel: opt => t(opt.label), renderInput: params => _jsx(TextField, { ...params }) }) }));
|
|
19
|
-
};
|
|
20
|
-
export default memo(IndexPicker);
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Box, Skeleton } from '@mui/material';
|
|
3
|
-
import api from '@cccsaurora/howler-ui/api';
|
|
4
|
-
import ObjectDetails from '@cccsaurora/howler-ui/components/elements/ObjectDetails';
|
|
5
|
-
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
6
|
-
import { useEffect, useState } from 'react';
|
|
7
|
-
const ObservableViewer = ({ observable: provided, observableId }) => {
|
|
8
|
-
const { dispatchApi } = useMyApi();
|
|
9
|
-
const [observable, setObservable] = useState(null);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (provided) {
|
|
12
|
-
setObservable(provided);
|
|
13
|
-
}
|
|
14
|
-
}, [provided]);
|
|
15
|
-
useEffect(() => {
|
|
16
|
-
if (observableId) {
|
|
17
|
-
dispatchApi(api.v2.search.post('observable', { query: `howler.id:${observableId}`, rows: 1 }), {
|
|
18
|
-
throwError: false
|
|
19
|
-
}).then(res => setObservable(res.items[0]));
|
|
20
|
-
}
|
|
21
|
-
}, [dispatchApi, observableId]);
|
|
22
|
-
if (!observable) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
return _jsx(Box, { p: 1, children: observable ? _jsx(ObjectDetails, { obj: observable }) : _jsx(Skeleton, { height: 120 }) });
|
|
26
|
-
};
|
|
27
|
-
export default ObservableViewer;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { FileHash } from './FileHash';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* NOTE: This is an auto-generated file. Don't edit this manually.
|
|
5
|
-
*/
|
|
6
|
-
export interface AttachmentsFile {
|
|
7
|
-
extension?: string;
|
|
8
|
-
hash?: FileHash;
|
|
9
|
-
mime_type?: string;
|
|
10
|
-
name?: string;
|
|
11
|
-
size?: number;
|
|
12
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Enrichments } from './Enrichments';
|
|
2
|
-
import type { Item } from './Item';
|
|
3
|
-
import type { Rule } from './Rule';
|
|
4
|
-
import type { Task } from './Task';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* NOTE: This is an auto-generated file. Don't edit this manually.
|
|
8
|
-
*/
|
|
9
|
-
export interface Case {
|
|
10
|
-
case_id?: string;
|
|
11
|
-
created?: string;
|
|
12
|
-
end?: string;
|
|
13
|
-
enrichments?: Enrichments;
|
|
14
|
-
escalation?: string;
|
|
15
|
-
indicators?: string[];
|
|
16
|
-
items?: Item[];
|
|
17
|
-
overview?: string;
|
|
18
|
-
participants?: string[];
|
|
19
|
-
rules?: Rule[];
|
|
20
|
-
status?: string;
|
|
21
|
-
start?: string;
|
|
22
|
-
summary?: string;
|
|
23
|
-
targets?: string[];
|
|
24
|
-
tasks?: Task[];
|
|
25
|
-
threats?: string[];
|
|
26
|
-
title?: string;
|
|
27
|
-
updated?: string;
|
|
28
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AutonomousSystems } from './AutonomousSystems';
|
|
2
|
-
import type { Geo } from './Geo';
|
|
3
|
-
import type { Nat } from './Nat';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* NOTE: This is an auto-generated file. Don't edit this manually.
|
|
7
|
-
*/
|
|
8
|
-
export interface DestinationOriginal {
|
|
9
|
-
address?: string;
|
|
10
|
-
autonomous_systems?: AutonomousSystems;
|
|
11
|
-
bytes?: number;
|
|
12
|
-
domain?: string;
|
|
13
|
-
geo?: Geo;
|
|
14
|
-
ip?: string;
|
|
15
|
-
mac?: string;
|
|
16
|
-
nat?: Nat;
|
|
17
|
-
packets?: number;
|
|
18
|
-
port?: number;
|
|
19
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Bcc } from './Bcc';
|
|
2
|
-
import type { Cc } from './Cc';
|
|
3
|
-
import type { From } from './From';
|
|
4
|
-
import type { To } from './To';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* NOTE: This is an auto-generated file. Don't edit this manually.
|
|
8
|
-
*/
|
|
9
|
-
export interface EmailParent {
|
|
10
|
-
bcc?: Bcc;
|
|
11
|
-
cc?: Cc;
|
|
12
|
-
destination?: string;
|
|
13
|
-
from?: From;
|
|
14
|
-
message_id?: string;
|
|
15
|
-
origination_timestamp?: string;
|
|
16
|
-
source?: string;
|
|
17
|
-
subject?: string;
|
|
18
|
-
to?: To;
|
|
19
|
-
}
|