@cccsaurora/howler-ui 2.18.0-dev.732 → 2.18.0-dev.736
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/facet/hit.d.ts +1 -3
- package/api/search/facet/index.d.ts +3 -1
- package/api/search/index.d.ts +2 -1
- package/api/search/index.js +2 -1
- package/api/v2/case/index.d.ts +8 -0
- package/api/v2/case/index.js +20 -0
- package/api/v2/case/items.d.ts +6 -0
- package/api/v2/case/items.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 +39 -7
- package/components/app/hooks/useMatchers.d.ts +1 -1
- package/components/app/hooks/useMatchers.js +23 -11
- 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/ModalProvider.d.ts +1 -0
- package/components/app/providers/ParameterProvider.d.ts +9 -2
- package/components/app/providers/ParameterProvider.js +165 -240
- package/components/app/providers/ParameterProvider.test.js +346 -94
- 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/app/providers/UserListProvider.js +28 -8
- 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 +18 -8
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/case/CaseCard.d.ts +12 -0
- package/components/elements/case/CaseCard.js +42 -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 +2 -0
- package/components/elements/hit/HitActions.js +4 -4
- package/components/elements/hit/HitBanner.d.ts +1 -0
- package/components/elements/hit/HitBanner.js +29 -49
- package/components/elements/hit/HitCard.d.ts +2 -0
- package/components/elements/hit/HitCard.js +7 -7
- package/components/elements/hit/HitLabels.js +2 -2
- package/components/elements/hit/HitOutline.d.ts +1 -0
- package/components/elements/hit/HitOutline.js +3 -3
- package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
- package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +10 -4
- package/components/elements/hit/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 +9 -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 +22 -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 +247 -0
- package/components/elements/record/RecordContextMenu.test.d.ts +1 -0
- package/components/{routes/hits/search/HitContextMenu.test.js → elements/record/RecordContextMenu.test.js} +94 -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.d.ts +1 -0
- package/components/elements/view/ViewTitle.js +9 -2
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +4 -4
- 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.test.js +3 -4
- 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 +11 -0
- package/components/routes/cases/detail/CaseAssets.js +104 -0
- package/components/routes/cases/detail/CaseAssets.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseAssets.test.js +167 -0
- package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
- package/components/routes/cases/detail/CaseDashboard.js +66 -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 +8 -0
- package/components/routes/cases/detail/CaseSidebar.js +107 -0
- package/components/routes/cases/detail/CaseSidebar.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseSidebar.test.js +246 -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/CaseTimeline.d.ts +12 -0
- package/components/routes/cases/detail/CaseTimeline.js +106 -0
- package/components/routes/cases/detail/CaseTimeline.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseTimeline.test.js +227 -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 +34 -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 +11 -0
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +24 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +6 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +26 -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 +20 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.js +83 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.test.js +295 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.d.ts +34 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.js +103 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.js +363 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.d.ts +25 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.js +88 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/FolderEntry.test.js +206 -0
- package/components/routes/cases/detail/sidebar/RootDropZone.d.ts +5 -0
- package/components/routes/cases/detail/sidebar/RootDropZone.js +33 -0
- package/components/routes/cases/detail/sidebar/types.d.ts +9 -0
- package/components/routes/cases/detail/sidebar/utils.d.ts +3 -0
- package/components/routes/cases/detail/sidebar/utils.js +29 -0
- package/components/routes/cases/detail/sidebar/utils.test.d.ts +1 -0
- package/components/routes/cases/detail/sidebar/utils.test.js +82 -0
- package/components/routes/cases/hooks/useCase.d.ts +13 -0
- package/components/routes/cases/hooks/useCase.js +51 -0
- package/components/routes/cases/modals/AddToCaseModal.d.ts +7 -0
- package/components/routes/cases/modals/AddToCaseModal.js +62 -0
- package/components/routes/cases/modals/RenameItemModal.d.ts +9 -0
- package/components/routes/cases/modals/RenameItemModal.js +48 -0
- package/components/routes/cases/modals/ResolveModal.d.ts +7 -0
- package/components/routes/cases/modals/ResolveModal.js +115 -0
- package/components/routes/cases/modals/ResolveModal.test.d.ts +1 -0
- package/components/routes/cases/modals/ResolveModal.test.js +384 -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 +47 -41
- 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 +46 -19
- package/locales/en/translation.json +89 -3
- package/locales/fr/translation.json +87 -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/models/entities/generated/View.d.ts +1 -0
- package/package.json +114 -97
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +2 -1
- package/tests/mocks.d.ts +11 -1
- package/tests/mocks.js +12 -7
- package/tests/server-handlers.js +6 -1
- package/tests/utils.d.ts +4 -0
- package/tests/utils.js +20 -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/utils/viewUtils.js +3 -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
|
@@ -10,12 +10,13 @@ import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
|
10
10
|
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
11
11
|
import { useTranslation } from 'react-i18next';
|
|
12
12
|
import { useNavigate } from 'react-router-dom';
|
|
13
|
+
import { isHit } from '@cccsaurora/howler-ui/utils/typeUtils';
|
|
13
14
|
import { compareTimestamp, sortByTimestamp } from '@cccsaurora/howler-ui/utils/utils';
|
|
14
15
|
import Comment from '../Comment';
|
|
15
16
|
import HowlerAvatar from '../display/HowlerAvatar';
|
|
16
17
|
import TypingIndicator from '../display/TypingIndicator';
|
|
17
18
|
const MAX_LENGTH = 5000;
|
|
18
|
-
const
|
|
19
|
+
const RecordComments = ({ record, users }) => {
|
|
19
20
|
const { user } = useAppUser();
|
|
20
21
|
const { t } = useTranslation();
|
|
21
22
|
const navigate = useNavigate();
|
|
@@ -28,7 +29,7 @@ const HitComments = ({ hit, users }) => {
|
|
|
28
29
|
const [length, setLength] = useState(0);
|
|
29
30
|
const [analyticId, setAnalyticId] = useState();
|
|
30
31
|
const [analyticComments, setAnalyticComments] = useState([]);
|
|
31
|
-
const [comments, setComments] = useState(sortByTimestamp(
|
|
32
|
+
const [comments, setComments] = useState(sortByTimestamp(record?.howler?.comment));
|
|
32
33
|
const input = useRef();
|
|
33
34
|
/**
|
|
34
35
|
* Set the list of typers based on updates from the websocket
|
|
@@ -50,20 +51,20 @@ const HitComments = ({ hit, users }) => {
|
|
|
50
51
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
52
|
}, [handler]);
|
|
52
53
|
useEffect(() => {
|
|
53
|
-
if (
|
|
54
|
-
getMatchingAnalytic(
|
|
54
|
+
if (isHit(record) && record.howler.analytic) {
|
|
55
|
+
getMatchingAnalytic(record).then(analytic => {
|
|
55
56
|
setAnalyticId(analytic?.analytic_id);
|
|
56
57
|
setAnalyticComments(sortByTimestamp(analytic?.comment ?? []));
|
|
57
58
|
});
|
|
58
59
|
}
|
|
59
60
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
60
|
-
}, [getMatchingAnalytic,
|
|
61
|
+
}, [getMatchingAnalytic, record]);
|
|
61
62
|
const onSubmit = useCallback(async () => {
|
|
62
|
-
if (!input.current?.value || !
|
|
63
|
+
if (!input.current?.value || !record || input.current.value.length > MAX_LENGTH)
|
|
63
64
|
return;
|
|
64
65
|
setLoading(true);
|
|
65
66
|
try {
|
|
66
|
-
const result = await dispatchApi(api.hit.comments.post(
|
|
67
|
+
const result = await dispatchApi(api.hit.comments.post(record.howler.id, input.current.value), {
|
|
67
68
|
showError: true,
|
|
68
69
|
throwError: true,
|
|
69
70
|
logError: false
|
|
@@ -75,23 +76,23 @@ const HitComments = ({ hit, users }) => {
|
|
|
75
76
|
finally {
|
|
76
77
|
setLoading(false);
|
|
77
78
|
}
|
|
78
|
-
}, [dispatchApi,
|
|
79
|
+
}, [dispatchApi, record]);
|
|
79
80
|
/**
|
|
80
81
|
* Emit a typing event when textbox is focused
|
|
81
82
|
*/
|
|
82
83
|
const onFocus = useCallback(() => emit({
|
|
83
84
|
broadcast: true,
|
|
84
85
|
action: 'typing',
|
|
85
|
-
id:
|
|
86
|
-
}), [emit,
|
|
86
|
+
id: record?.howler?.id
|
|
87
|
+
}), [emit, record?.howler?.id]);
|
|
87
88
|
/**
|
|
88
89
|
* Emit a stop typing event when textbox is blurred
|
|
89
90
|
*/
|
|
90
91
|
const onBlur = useCallback(() => emit({
|
|
91
92
|
broadcast: true,
|
|
92
93
|
action: 'stop_typing',
|
|
93
|
-
id:
|
|
94
|
-
}), [emit,
|
|
94
|
+
id: record?.howler?.id
|
|
95
|
+
}), [emit, record?.howler?.id]);
|
|
95
96
|
const onClear = useCallback(() => {
|
|
96
97
|
input.current.value = '';
|
|
97
98
|
setShowClear(false);
|
|
@@ -108,16 +109,16 @@ const HitComments = ({ hit, users }) => {
|
|
|
108
109
|
}, [loading, onSubmit]);
|
|
109
110
|
const checkLength = useCallback(() => setLength(input.current?.value.length), []);
|
|
110
111
|
const handleDelete = useCallback(async (commentId) => {
|
|
111
|
-
await dispatchApi(api.hit.comments.del(
|
|
112
|
+
await dispatchApi(api.hit.comments.del(record.howler.id, [commentId]), { throwError: true, showError: true });
|
|
112
113
|
setComments(comments.filter(cmt => cmt.id !== commentId));
|
|
113
|
-
}, [comments, dispatchApi,
|
|
114
|
+
}, [comments, dispatchApi, record?.howler?.id]);
|
|
114
115
|
const handleEdit = useCallback(async (commentId, editValue) => {
|
|
115
|
-
await dispatchApi(api.hit.comments.put(
|
|
116
|
+
await dispatchApi(api.hit.comments.put(record.howler.id, commentId, editValue), {
|
|
116
117
|
throwError: true,
|
|
117
118
|
showError: true
|
|
118
119
|
});
|
|
119
120
|
setComments(comments.map(cmt => (cmt.id !== commentId ? cmt : { ...cmt, value: editValue })));
|
|
120
|
-
}, [comments, dispatchApi,
|
|
121
|
+
}, [comments, dispatchApi, record?.howler?.id]);
|
|
121
122
|
const handleQuote = useCallback((value) => {
|
|
122
123
|
if (input.current) {
|
|
123
124
|
// We use trimStart here so there isn't a bunch of newlines at the beginning of the comment
|
|
@@ -135,27 +136,27 @@ const HitComments = ({ hit, users }) => {
|
|
|
135
136
|
}, []);
|
|
136
137
|
const handleReact = useCallback(async (commentId, type) => {
|
|
137
138
|
if (type) {
|
|
138
|
-
await dispatchApi(api.hit.comments.react.put(
|
|
139
|
+
await dispatchApi(api.hit.comments.react.put(record.howler.id, commentId, type));
|
|
139
140
|
setComments(comments.map(cmt => cmt.id !== commentId ? cmt : { ...cmt, reactions: { ...(cmt?.reactions ?? {}), [user.username]: type } }));
|
|
140
141
|
}
|
|
141
142
|
else {
|
|
142
|
-
await dispatchApi(api.hit.comments.react.del(
|
|
143
|
+
await dispatchApi(api.hit.comments.react.del(record.howler.id, commentId));
|
|
143
144
|
setComments(comments.map(cmt => cmt.id !== commentId
|
|
144
145
|
? cmt
|
|
145
146
|
: { ...cmt, reactions: { ...(cmt?.reactions ?? {}), [user.username]: undefined } }));
|
|
146
147
|
}
|
|
147
|
-
}, [comments, dispatchApi,
|
|
148
|
+
}, [comments, dispatchApi, record?.howler.id, user.username]);
|
|
148
149
|
/**
|
|
149
150
|
* Handle loading the comments when the hit changes
|
|
150
151
|
*/
|
|
151
152
|
useEffect(() => {
|
|
152
|
-
if (
|
|
153
|
-
setComments(
|
|
153
|
+
if (record?.howler?.comment) {
|
|
154
|
+
setComments(record?.howler?.comment.slice().sort((a, b) => compareTimestamp(b.timestamp, a.timestamp)));
|
|
154
155
|
}
|
|
155
|
-
else if (!
|
|
156
|
+
else if (!record) {
|
|
156
157
|
setComments([]);
|
|
157
158
|
}
|
|
158
|
-
}, [
|
|
159
|
+
}, [record]);
|
|
159
160
|
/**
|
|
160
161
|
* This is the comments for the analytic associated with the hit. We show this at the start of the comment
|
|
161
162
|
* list, as if they've been pinned
|
|
@@ -164,13 +165,13 @@ const HitComments = ({ hit, users }) => {
|
|
|
164
165
|
if (analyticComments.length < 1) {
|
|
165
166
|
return null;
|
|
166
167
|
}
|
|
167
|
-
const displayedComments = analyticComments.filter(c => !c.detection || c.detection ===
|
|
168
|
+
const displayedComments = analyticComments.filter(c => !c.detection || c.detection === record?.howler.detection);
|
|
168
169
|
return (_jsxs(Accordion, { variant: "outlined", children: [_jsx(AccordionSummary, { expandIcon: _jsx(KeyboardArrowDown, { fontSize: "small" }), children: _jsx(Typography, { variant: "body1", children: t('comments.analytic', { count: displayedComments.length }) }) }), _jsx(AccordionDetails, { children: _jsx(Stack, { spacing: 1, children: displayedComments.map(c => (_jsx(Comment, { comment: c, extra: _jsx(Chip, { size: "small", variant: "outlined", onClick: () => navigate('/analytics' +
|
|
169
170
|
(analyticId
|
|
170
171
|
? `/${analyticId}?tab=comments` + (c.detection ? `&filter=${c.detection}` : '')
|
|
171
|
-
: '')), sx: theme => ({ marginLeft: '0 !important', mr: `${theme.spacing(2)} !important` }), label: `${
|
|
172
|
-
}, [analyticComments, analyticId,
|
|
172
|
+
: '')), sx: theme => ({ marginLeft: '0 !important', mr: `${theme.spacing(2)} !important` }), label: `${record?.howler?.analytic ?? 'Analytic'}${c.detection ? ' - ' + c.detection : ''}` }), users: users }, c.id))) }) })] }));
|
|
173
|
+
}, [analyticComments, analyticId, record?.howler.analytic, record?.howler.detection, navigate, t, users]);
|
|
173
174
|
const renderedComments = useMemo(() => comments.map(c => (_jsx(Comment, { comment: c, users: users, handleDelete: () => handleDelete(c.id), handleEdit: value => handleEdit(c.id, value), handleReact: type => handleReact(c.id, type), handleQuote: () => handleQuote(c.value) }, c.id))), [comments, handleDelete, handleEdit, handleQuote, handleReact, users]);
|
|
174
|
-
return (_jsxs(Stack, { sx: { py: 1, pr: 1 }, spacing: 1, children: [
|
|
175
|
+
return (_jsxs(Stack, { sx: { py: 1, pr: 1 }, spacing: 1, children: [record && renderedAnalyticComments, _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(HowlerAvatar, { userId: user.username }), _jsx(TextField, { inputProps: { sx: theme => ({ fontSize: theme.typography.body2.fontSize }) }, InputLabelProps: { shrink: false }, placeholder: t('comments.add'), onKeyDown: checkForSubmit, onChangeCapture: checkLength, inputRef: input, onFocus: onFocus, onBlur: onBlur, error: length > MAX_LENGTH, fullWidth: true, multiline: true })] }), _jsxs(Stack, { direction: "row", alignItems: "center", children: [typers.length > 0 && (_jsxs(_Fragment, { children: [_jsx(AvatarGroup, { componentsProps: { additionalAvatar: { sx: { height: 24, width: 24, fontSize: '12px' } } }, children: typers.map(typer => (_jsx(HowlerAvatar, { userId: typer, sx: { height: 24, width: 24 } }, typer))) }), _jsx(TypingIndicator, {})] })), _jsx(FlexOne, {}), length > 0.9 * MAX_LENGTH && (_jsxs(Typography, { variant: "caption", sx: [{ opacity: 0.7, mr: 1 }, length > MAX_LENGTH && { color: 'error.main' }], children: [length, "/", MAX_LENGTH] })), showClear && (_jsx(IconButton, { size: "small", onClick: onClear, disabled: loading, children: _jsx(Clear, { fontSize: "small" }) })), _jsx(IconButton, { size: "small", onClick: onSubmit, disabled: loading || length > MAX_LENGTH, children: _jsx(Send, { fontSize: "small" }) })] }), record ? (renderedComments) : (_jsxs(_Fragment, { children: [_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Skeleton, { width: 40, height: 40, variant: "circular" }), _jsx(Skeleton, { width: "100%", height: 80, variant: "rounded" })] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Skeleton, { width: 40, height: 40, variant: "circular" }), _jsx(Skeleton, { width: "100%", height: 100, variant: "rounded" })] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Skeleton, { width: 40, height: 40, variant: "circular" }), _jsx(Skeleton, { width: "100%", height: 80, variant: "rounded" })] })] }))] }));
|
|
175
176
|
};
|
|
176
|
-
export default
|
|
177
|
+
export default RecordComments;
|
package/components/{routes/hits/search/HitContextMenu.d.ts → elements/record/RecordContextMenu.d.ts}
RENAMED
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
/**
|
|
4
4
|
* Props for the HitContextMenu component
|
|
5
5
|
*/
|
|
6
|
-
interface
|
|
6
|
+
interface RecordContextMenuProps {
|
|
7
7
|
/**
|
|
8
8
|
* Function to extract the hit ID from a mouse event
|
|
9
9
|
*/
|
|
@@ -18,5 +18,5 @@ interface HitContextMenuProps {
|
|
|
18
18
|
* Provides quick access to common hit actions including assessment, voting,
|
|
19
19
|
* transitions, and exclusion filters based on template fields.
|
|
20
20
|
*/
|
|
21
|
-
declare const
|
|
22
|
-
export default
|
|
21
|
+
declare const RecordContextMenu: FC<PropsWithChildren<RecordContextMenuProps>>;
|
|
22
|
+
export default RecordContextMenu;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AddCircleOutline, Assignment, CreateNewFolder, Edit, HowToVote, OpenInNew, QueryStats, RemoveCircleOutline, SettingsSuggest, Terminal } from '@mui/icons-material';
|
|
3
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
4
|
+
import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
|
|
5
|
+
import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
|
|
6
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
7
|
+
import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
|
|
8
|
+
import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
|
|
9
|
+
import ContextMenu, {} from '@cccsaurora/howler-ui/components/elements/ContextMenu';
|
|
10
|
+
import { TOP_ROW, VOTE_OPTIONS } from '@cccsaurora/howler-ui/components/elements/hit/actions/SharedComponents';
|
|
11
|
+
import useHitActions from '@cccsaurora/howler-ui/components/hooks/useHitActions';
|
|
12
|
+
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
13
|
+
import useMyActionFunctions from '@cccsaurora/howler-ui/components/routes/action/useMyActionFunctions';
|
|
14
|
+
import AddToCaseModal from '@cccsaurora/howler-ui/components/routes/cases/modals/AddToCaseModal';
|
|
15
|
+
import { capitalize, get, groupBy, isEmpty, toString } from 'lodash-es';
|
|
16
|
+
import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
|
|
17
|
+
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
|
18
|
+
import { useTranslation } from 'react-i18next';
|
|
19
|
+
import { usePluginStore } from 'react-pluggable';
|
|
20
|
+
import { useContextSelector } from 'use-context-selector';
|
|
21
|
+
import { DEFAULT_QUERY } from '@cccsaurora/howler-ui/utils/constants';
|
|
22
|
+
import { sanitizeLuceneQuery } from '@cccsaurora/howler-ui/utils/stringUtils';
|
|
23
|
+
import { isHit } from '@cccsaurora/howler-ui/utils/typeUtils';
|
|
24
|
+
/**
|
|
25
|
+
* Order in which action types should be displayed in the context menu
|
|
26
|
+
*/
|
|
27
|
+
const ORDER = ['assessment', 'vote', 'action'];
|
|
28
|
+
/**
|
|
29
|
+
* Icon mapping for different action types
|
|
30
|
+
*/
|
|
31
|
+
const ICON_MAP = {
|
|
32
|
+
assessment: _jsx(Assignment, {}),
|
|
33
|
+
vote: _jsx(HowToVote, {}),
|
|
34
|
+
action: _jsx(Edit, {})
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Context menu component for hit operations.
|
|
38
|
+
* Provides quick access to common hit actions including assessment, voting,
|
|
39
|
+
* transitions, and exclusion filters based on template fields.
|
|
40
|
+
*/
|
|
41
|
+
const RecordContextMenu = ({ children, getSelectedId, Component }) => {
|
|
42
|
+
const { t } = useTranslation();
|
|
43
|
+
const { dispatchApi } = useMyApi();
|
|
44
|
+
const { executeAction } = useMyActionFunctions();
|
|
45
|
+
const { config } = useContext(ApiConfigContext);
|
|
46
|
+
const { showModal } = useContext(ModalContext);
|
|
47
|
+
const pluginStore = usePluginStore();
|
|
48
|
+
const { getMatchingAnalytic, getMatchingTemplate } = useMatchers();
|
|
49
|
+
const query = useContextSelector(ParameterContext, ctx => ctx?.query);
|
|
50
|
+
const setQuery = useContextSelector(ParameterContext, ctx => ctx?.setQuery);
|
|
51
|
+
const [id, setId] = useState(null);
|
|
52
|
+
const record = useContextSelector(RecordContext, ctx => ctx.records[id]);
|
|
53
|
+
const selectedRecords = useContextSelector(RecordContext, ctx => ctx.selectedRecords);
|
|
54
|
+
const [analytic, setAnalytic] = useState(null);
|
|
55
|
+
const [template, setTemplate] = useState(null);
|
|
56
|
+
const [actions, setActions] = useState([]);
|
|
57
|
+
const records = useMemo(() => selectedRecords.some(_record => _record.howler.id === record?.howler.id)
|
|
58
|
+
? selectedRecords
|
|
59
|
+
: record
|
|
60
|
+
? [record]
|
|
61
|
+
: [], [record, selectedRecords]);
|
|
62
|
+
const hits = useMemo(() => records.filter(isHit), [records]);
|
|
63
|
+
const { availableTransitions, canVote, canAssess, assess, vote } = useHitActions(hits);
|
|
64
|
+
/**
|
|
65
|
+
* Called by ContextMenu after the menu is positioned and opened.
|
|
66
|
+
* Identifies the clicked record and fetches available actions.
|
|
67
|
+
*/
|
|
68
|
+
const onOpen = useCallback(async (event) => {
|
|
69
|
+
const _id = getSelectedId(event);
|
|
70
|
+
setId(_id);
|
|
71
|
+
const _actions = (await dispatchApi(api.search.action.post({ query: 'action_id:*' }), { throwError: false }))
|
|
72
|
+
?.items;
|
|
73
|
+
if (_actions) {
|
|
74
|
+
setActions(_actions);
|
|
75
|
+
}
|
|
76
|
+
}, [dispatchApi, getSelectedId]);
|
|
77
|
+
const rowStatus = useMemo(() => ({
|
|
78
|
+
assessment: canAssess,
|
|
79
|
+
vote: canVote
|
|
80
|
+
}), [canAssess, canVote]);
|
|
81
|
+
const pluginActions = howlerPluginStore.plugins.flatMap(plugin => pluginStore.executeFunction(`${plugin}.actions`, records));
|
|
82
|
+
/**
|
|
83
|
+
* Generates grouped action entries for the context menu.
|
|
84
|
+
* Combines transitions, plugin actions, votes, and assessments based on permissions.
|
|
85
|
+
*/
|
|
86
|
+
const entries = useMemo(() => {
|
|
87
|
+
let _actions = [...availableTransitions, ...pluginActions];
|
|
88
|
+
if (canVote) {
|
|
89
|
+
_actions = [
|
|
90
|
+
..._actions,
|
|
91
|
+
...VOTE_OPTIONS.map(option => ({ ...option, actionFunction: () => vote(option.name.toLowerCase()) }))
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
if (config.lookups?.['howler.assessment'] && canAssess) {
|
|
95
|
+
_actions = [
|
|
96
|
+
..._actions,
|
|
97
|
+
...config.lookups['howler.assessment']
|
|
98
|
+
.filter(_assessment => analytic?.triage_settings?.valid_assessments
|
|
99
|
+
? analytic.triage_settings?.valid_assessments.includes(_assessment)
|
|
100
|
+
: true)
|
|
101
|
+
.sort((a, b) => +TOP_ROW.includes(b) - +TOP_ROW.includes(a))
|
|
102
|
+
.map(assessment => ({
|
|
103
|
+
type: 'assessment',
|
|
104
|
+
name: assessment,
|
|
105
|
+
actionFunction: async () => {
|
|
106
|
+
await assess(assessment, analytic?.triage_settings?.skip_rationale);
|
|
107
|
+
}
|
|
108
|
+
}))
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
return Object.entries(groupBy(_actions, 'type')).sort(([a], [b]) => ORDER.indexOf(a) - ORDER.indexOf(b));
|
|
112
|
+
}, [analytic, assess, availableTransitions, canAssess, canVote, config.lookups, vote, pluginActions]);
|
|
113
|
+
// Load analytic and template data when a hit is selected
|
|
114
|
+
useEffect(() => {
|
|
115
|
+
if (!record?.howler.analytic) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
getMatchingAnalytic(record).then(setAnalytic);
|
|
119
|
+
getMatchingTemplate(record).then(setTemplate);
|
|
120
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
121
|
+
}, [record]);
|
|
122
|
+
/**
|
|
123
|
+
* Builds the declarative items structure for the ContextMenu component.
|
|
124
|
+
*/
|
|
125
|
+
const items = useMemo(() => {
|
|
126
|
+
const result = [
|
|
127
|
+
{
|
|
128
|
+
kind: 'item',
|
|
129
|
+
id: 'open-record',
|
|
130
|
+
icon: _jsx(OpenInNew, {}),
|
|
131
|
+
label: t(`${record?.__index ?? 'hit'}.open`),
|
|
132
|
+
disabled: !record,
|
|
133
|
+
to: `/${record?.__index}s/${record?.howler.id}`
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
if (isHit(record)) {
|
|
137
|
+
result.push({
|
|
138
|
+
kind: 'item',
|
|
139
|
+
id: 'open-analytic',
|
|
140
|
+
icon: _jsx(QueryStats, {}),
|
|
141
|
+
label: t('analytic.open'),
|
|
142
|
+
disabled: !analytic,
|
|
143
|
+
to: `/analytics/${analytic?.analytic_id}`
|
|
144
|
+
});
|
|
145
|
+
result.push({ kind: 'divider', id: 'actions-divider' });
|
|
146
|
+
for (const [type, typeItems] of entries) {
|
|
147
|
+
result.push({
|
|
148
|
+
kind: 'submenu',
|
|
149
|
+
id: type,
|
|
150
|
+
icon: ICON_MAP[type] ?? _jsx(Terminal, {}),
|
|
151
|
+
label: t(`hit.details.actions.${type}`),
|
|
152
|
+
disabled: rowStatus[type] === false,
|
|
153
|
+
items: typeItems.map(a => ({
|
|
154
|
+
key: a.name,
|
|
155
|
+
label: a.i18nKey ? t(a.i18nKey) : capitalize(a.name),
|
|
156
|
+
onClick: a.actionFunction
|
|
157
|
+
}))
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
result.push({
|
|
161
|
+
kind: 'submenu',
|
|
162
|
+
id: 'actions',
|
|
163
|
+
icon: _jsx(SettingsSuggest, {}),
|
|
164
|
+
label: t('route.actions.change'),
|
|
165
|
+
disabled: actions.length < 1,
|
|
166
|
+
items: actions.map(action => ({
|
|
167
|
+
key: action.action_id,
|
|
168
|
+
label: action.name,
|
|
169
|
+
onClick: () => executeAction(action.action_id, `howler.id:${record?.howler.id}`)
|
|
170
|
+
}))
|
|
171
|
+
});
|
|
172
|
+
if (!isEmpty(template?.keys ?? []) && setQuery) {
|
|
173
|
+
result.push({ kind: 'divider', id: 'filter-divider' });
|
|
174
|
+
result.push({
|
|
175
|
+
kind: 'submenu',
|
|
176
|
+
id: 'excludes',
|
|
177
|
+
icon: _jsx(RemoveCircleOutline, {}),
|
|
178
|
+
label: t('hit.panel.exclude'),
|
|
179
|
+
items: (template?.keys ?? []).flatMap(key => {
|
|
180
|
+
let newQuery = '';
|
|
181
|
+
if (query !== DEFAULT_QUERY) {
|
|
182
|
+
newQuery = `(${query}) AND `;
|
|
183
|
+
}
|
|
184
|
+
const value = get(record, key);
|
|
185
|
+
if (!value) {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
else if (Array.isArray(value)) {
|
|
189
|
+
const sanitizedValues = value
|
|
190
|
+
.map(toString)
|
|
191
|
+
.filter(val => !!val)
|
|
192
|
+
.map(val => `"${sanitizeLuceneQuery(val)}"`);
|
|
193
|
+
if (sanitizedValues.length < 1) {
|
|
194
|
+
return [];
|
|
195
|
+
}
|
|
196
|
+
newQuery += `-${key}:(${sanitizedValues.join(' OR ')})`;
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
newQuery += `-${key}:"${sanitizeLuceneQuery(value.toString())}"`;
|
|
200
|
+
}
|
|
201
|
+
return [{ key, label: key, onClick: () => setQuery(newQuery) }];
|
|
202
|
+
})
|
|
203
|
+
});
|
|
204
|
+
result.push({
|
|
205
|
+
kind: 'submenu',
|
|
206
|
+
id: 'includes',
|
|
207
|
+
icon: _jsx(AddCircleOutline, {}),
|
|
208
|
+
label: t('hit.panel.include'),
|
|
209
|
+
items: (template?.keys ?? []).flatMap(key => {
|
|
210
|
+
let newQuery = `(${query}) AND `;
|
|
211
|
+
const value = get(record, key);
|
|
212
|
+
if (!value) {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
else if (Array.isArray(value)) {
|
|
216
|
+
const sanitizedValues = value
|
|
217
|
+
.map(toString)
|
|
218
|
+
.filter(val => !!val)
|
|
219
|
+
.map(val => `"${sanitizeLuceneQuery(val)}"`);
|
|
220
|
+
if (sanitizedValues.length < 1) {
|
|
221
|
+
return [];
|
|
222
|
+
}
|
|
223
|
+
newQuery += `${key}:(${sanitizedValues.join(' OR ')})`;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
newQuery += `${key}:"${sanitizeLuceneQuery(value.toString())}"`;
|
|
227
|
+
}
|
|
228
|
+
return [{ key, label: key, onClick: () => setQuery(newQuery) }];
|
|
229
|
+
})
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
result.push({ kind: 'divider', id: 'add-to-case-divider' });
|
|
234
|
+
result.push({
|
|
235
|
+
kind: 'item',
|
|
236
|
+
id: 'add-to-case',
|
|
237
|
+
icon: _jsx(CreateNewFolder, {}),
|
|
238
|
+
label: t('modal.cases.add_to_case'),
|
|
239
|
+
disabled: !record,
|
|
240
|
+
onClick: () => showModal(_jsx(AddToCaseModal, { records: records }))
|
|
241
|
+
});
|
|
242
|
+
return result;
|
|
243
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
244
|
+
}, [record, analytic, template, entries, rowStatus, actions, query, t, setQuery, executeAction, showModal, records]);
|
|
245
|
+
return (_jsx(ContextMenu, { id: "contextMenu", Component: Component, onOpen: onOpen, onClose: () => setAnalytic(null), items: items, children: children }));
|
|
246
|
+
};
|
|
247
|
+
export default RecordContextMenu;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|