@cccsaurora/howler-ui 2.18.0-dev.704 → 2.18.0-dev.705

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.
Files changed (245) hide show
  1. package/api/index.d.ts +2 -0
  2. package/api/index.js +4 -2
  3. package/api/search/case.d.ts +4 -0
  4. package/api/search/case.js +8 -0
  5. package/api/search/index.d.ts +2 -1
  6. package/api/search/index.js +2 -1
  7. package/api/v2/case/index.d.ts +8 -0
  8. package/api/v2/case/index.js +20 -0
  9. package/api/v2/case/items.d.ts +6 -0
  10. package/api/v2/case/items.js +18 -0
  11. package/api/v2/index.d.ts +4 -0
  12. package/api/v2/index.js +6 -0
  13. package/api/v2/search/facet.d.ts +3 -0
  14. package/api/v2/search/facet.js +12 -0
  15. package/api/v2/search/index.d.ts +5 -0
  16. package/api/v2/search/index.js +24 -0
  17. package/commons/components/leftnav/LeftNavDrawer.js +1 -1
  18. package/components/app/App.js +34 -7
  19. package/components/app/hooks/useMatchers.js +2 -2
  20. package/components/app/hooks/useMatchers.test.js +22 -22
  21. package/components/app/hooks/useTitle.js +3 -3
  22. package/components/app/providers/FavouritesProvider.js +2 -2
  23. package/components/app/providers/ModalProvider.d.ts +1 -0
  24. package/components/app/providers/ParameterProvider.d.ts +9 -2
  25. package/components/app/providers/ParameterProvider.js +165 -240
  26. package/components/app/providers/ParameterProvider.test.js +307 -14
  27. package/components/app/providers/RecordProvider.d.ts +23 -0
  28. package/components/app/providers/{HitProvider.js → RecordProvider.js} +41 -41
  29. package/components/app/providers/{HitSearchProvider.d.ts → RecordSearchProvider.d.ts} +6 -6
  30. package/components/app/providers/{HitSearchProvider.js → RecordSearchProvider.js} +12 -17
  31. package/components/app/providers/{HitSearchProvider.test.js → RecordSearchProvider.test.js} +51 -70
  32. package/components/elements/ContextMenu.d.ts +56 -0
  33. package/components/elements/ContextMenu.js +109 -0
  34. package/components/elements/ContextMenu.test.js +215 -0
  35. package/components/{routes/overviews/OverviewEditor.js → elements/MarkdownEditor.js} +3 -3
  36. package/components/elements/ObjectDetails.d.ts +6 -0
  37. package/components/elements/{hit/HitDetails.js → ObjectDetails.js} +17 -17
  38. package/components/elements/PluginTypography.d.ts +2 -1
  39. package/components/elements/PluginTypography.js +3 -2
  40. package/components/elements/UserList.d.ts +5 -2
  41. package/components/elements/UserList.js +14 -5
  42. package/components/elements/addons/search/phrase/Phrase.js +1 -1
  43. package/components/elements/case/CaseCard.d.ts +12 -0
  44. package/components/elements/case/CaseCard.js +42 -0
  45. package/components/elements/case/CasePreview.d.ts +6 -0
  46. package/components/elements/case/CasePreview.js +17 -0
  47. package/components/elements/case/StatusIcon.d.ts +5 -0
  48. package/components/elements/case/StatusIcon.js +13 -0
  49. package/components/elements/display/ChipPopper.d.ts +1 -1
  50. package/components/elements/display/HowlerCard.js +1 -1
  51. package/components/elements/display/Modal.js +2 -0
  52. package/components/elements/hit/HitActions.js +4 -4
  53. package/components/elements/hit/HitBanner.js +28 -48
  54. package/components/elements/hit/HitCard.js +5 -5
  55. package/components/elements/hit/HitLabels.js +2 -2
  56. package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
  57. package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +10 -4
  58. package/components/elements/hit/HitSummary.d.ts +2 -1
  59. package/components/elements/hit/HitSummary.js +6 -5
  60. package/components/elements/hit/aggregate/HitGraph.js +8 -8
  61. package/components/elements/hit/elements/AnalyticLink.d.ts +8 -0
  62. package/components/elements/hit/elements/AnalyticLink.js +22 -0
  63. package/components/elements/hit/outlines/DefaultOutline.js +1 -1
  64. package/components/elements/hit/related/RelatedRecords.js +63 -0
  65. package/components/elements/observable/ObservableCard.d.ts +6 -0
  66. package/components/elements/observable/ObservableCard.js +23 -0
  67. package/components/elements/observable/ObservablePreview.d.ts +6 -0
  68. package/components/elements/observable/ObservablePreview.js +12 -0
  69. package/components/elements/{hit/HitComments.d.ts → record/RecordComments.d.ts} +5 -4
  70. package/components/elements/{hit/HitComments.js → record/RecordComments.js} +29 -28
  71. package/components/{routes/hits/search/HitContextMenu.d.ts → elements/record/RecordContextMenu.d.ts} +3 -3
  72. package/components/elements/record/RecordContextMenu.js +247 -0
  73. package/components/elements/record/RecordContextMenu.test.d.ts +1 -0
  74. package/components/{routes/hits/search/HitContextMenu.test.js → elements/record/RecordContextMenu.test.js} +94 -39
  75. package/components/elements/record/RecordRelated.d.ts +7 -0
  76. package/components/elements/record/RecordRelated.js +34 -0
  77. package/components/elements/{hit/HitWorklog.d.ts → record/RecordWorklog.d.ts} +4 -3
  78. package/components/elements/{hit/HitWorklog.js → record/RecordWorklog.js} +15 -13
  79. package/components/elements/view/ViewTitle.d.ts +1 -0
  80. package/components/elements/view/ViewTitle.js +9 -2
  81. package/components/hooks/useHitActions.d.ts +1 -1
  82. package/components/hooks/useHitActions.js +4 -4
  83. package/components/hooks/useMyPreferences.js +10 -1
  84. package/components/hooks/useMySearch.js +2 -2
  85. package/components/hooks/useMySitemap.js +4 -1
  86. package/components/hooks/useMyTheme.js +9 -2
  87. package/components/hooks/useParamState.test.js +3 -4
  88. package/components/hooks/{useHitSelection.d.ts → useRecordSelection.d.ts} +2 -2
  89. package/components/hooks/{useHitSelection.js → useRecordSelection.js} +12 -33
  90. package/components/hooks/useRelatedRecords.d.ts +13 -0
  91. package/components/hooks/useRelatedRecords.js +32 -0
  92. package/components/routes/action/edit/ActionEditor.js +2 -2
  93. package/components/routes/action/view/ActionSearch.js +1 -1
  94. package/components/routes/advanced/QueryBuilder.js +1 -1
  95. package/components/routes/advanced/QueryEditor.js +3 -3
  96. package/components/routes/advanced/historyCompletionProvider.js +3 -3
  97. package/components/routes/analytics/AnalyticDetails.js +2 -2
  98. package/components/routes/analytics/AnalyticSearch.js +1 -1
  99. package/components/routes/cases/CaseViewer.d.ts +2 -0
  100. package/components/routes/cases/CaseViewer.js +22 -0
  101. package/components/routes/cases/Cases.d.ts +2 -0
  102. package/components/routes/cases/Cases.js +101 -0
  103. package/components/routes/cases/constants.d.ts +5 -0
  104. package/components/routes/cases/constants.js +5 -0
  105. package/components/routes/cases/detail/AlertPanel.d.ts +6 -0
  106. package/components/routes/cases/detail/AlertPanel.js +33 -0
  107. package/components/routes/cases/detail/CaseAssets.d.ts +12 -0
  108. package/components/routes/cases/detail/CaseAssets.js +104 -0
  109. package/components/routes/cases/detail/CaseAssets.test.d.ts +1 -0
  110. package/components/routes/cases/detail/CaseAssets.test.js +167 -0
  111. package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
  112. package/components/routes/cases/detail/CaseDashboard.js +54 -0
  113. package/components/routes/cases/detail/CaseDetails.d.ts +6 -0
  114. package/components/routes/cases/detail/CaseDetails.js +61 -0
  115. package/components/routes/cases/detail/CaseOverview.d.ts +7 -0
  116. package/components/routes/cases/detail/CaseOverview.js +43 -0
  117. package/components/routes/cases/detail/CaseSidebar.d.ts +8 -0
  118. package/components/routes/cases/detail/CaseSidebar.js +61 -0
  119. package/components/routes/cases/detail/CaseTask.d.ts +11 -0
  120. package/components/routes/cases/detail/CaseTask.js +57 -0
  121. package/components/routes/cases/detail/ItemPage.d.ts +6 -0
  122. package/components/routes/cases/detail/ItemPage.js +99 -0
  123. package/components/routes/cases/detail/RelatedCasePanel.d.ts +6 -0
  124. package/components/routes/cases/detail/RelatedCasePanel.js +31 -0
  125. package/components/routes/cases/detail/TaskPanel.d.ts +7 -0
  126. package/components/routes/cases/detail/TaskPanel.js +52 -0
  127. package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +12 -0
  128. package/components/routes/cases/detail/aggregates/CaseAggregate.js +19 -0
  129. package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +6 -0
  130. package/components/routes/cases/detail/aggregates/SourceAggregate.js +30 -0
  131. package/components/routes/cases/detail/assets/Asset.d.ts +14 -0
  132. package/components/routes/cases/detail/assets/Asset.js +12 -0
  133. package/components/routes/cases/detail/assets/Asset.test.d.ts +1 -0
  134. package/components/routes/cases/detail/assets/Asset.test.js +72 -0
  135. package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +14 -0
  136. package/components/routes/cases/detail/sidebar/CaseFolder.js +133 -0
  137. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.d.ts +34 -0
  138. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.js +105 -0
  139. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.d.ts +1 -0
  140. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.js +351 -0
  141. package/components/routes/cases/detail/sidebar/types.d.ts +3 -0
  142. package/components/routes/cases/detail/sidebar/utils.d.ts +3 -0
  143. package/components/routes/cases/detail/sidebar/utils.js +25 -0
  144. package/components/routes/cases/hooks/useCase.d.ts +13 -0
  145. package/components/routes/cases/hooks/useCase.js +51 -0
  146. package/components/routes/cases/modals/AddToCaseModal.d.ts +7 -0
  147. package/components/routes/cases/modals/AddToCaseModal.js +62 -0
  148. package/components/routes/cases/modals/RenameItemModal.d.ts +9 -0
  149. package/components/routes/cases/modals/RenameItemModal.js +48 -0
  150. package/components/routes/cases/modals/ResolveModal.d.ts +7 -0
  151. package/components/routes/cases/modals/ResolveModal.js +62 -0
  152. package/components/routes/dossiers/DossierEditor.js +2 -2
  153. package/components/routes/dossiers/DossierEditor.test.js +1 -1
  154. package/components/routes/help/ApiDocumentation.js +1 -1
  155. package/components/routes/help/HitBannerDocumentation.js +1 -0
  156. package/components/routes/help/HitDocumentation.js +1 -3
  157. package/components/routes/hits/search/InformationPane.d.ts +1 -0
  158. package/components/routes/hits/search/InformationPane.js +47 -60
  159. package/components/routes/hits/search/LayoutSettings.js +3 -3
  160. package/components/routes/hits/search/QuerySettings.js +2 -1
  161. package/components/routes/hits/search/QuerySettings.test.js +14 -9
  162. package/components/routes/hits/search/{HitBrowser.js → RecordBrowser.js} +9 -9
  163. package/components/routes/hits/search/{HitQuery.d.ts → RecordQuery.d.ts} +2 -2
  164. package/components/routes/hits/search/{HitQuery.js → RecordQuery.js} +6 -6
  165. package/components/routes/hits/search/SearchPane.js +26 -49
  166. package/components/routes/hits/search/ViewLink.js +3 -3
  167. package/components/routes/hits/search/ViewLink.test.js +8 -8
  168. package/components/routes/hits/search/grid/AddColumnModal.js +5 -4
  169. package/components/routes/hits/search/grid/EnhancedCell.d.ts +2 -1
  170. package/components/routes/hits/search/grid/EnhancedCell.js +2 -2
  171. package/components/routes/hits/search/grid/HitGrid.js +20 -18
  172. package/components/routes/hits/search/grid/{HitRow.d.ts → RecordRow.d.ts} +3 -2
  173. package/components/routes/hits/search/grid/{HitRow.js → RecordRow.js} +10 -8
  174. package/components/routes/hits/search/shared/IndexPicker.d.ts +2 -0
  175. package/components/routes/hits/search/shared/IndexPicker.js +20 -0
  176. package/components/routes/hits/view/HitViewer.js +12 -13
  177. package/components/routes/home/ViewCard.js +47 -41
  178. package/components/routes/observables/ObservableViewer.d.ts +7 -0
  179. package/components/routes/observables/ObservableViewer.js +27 -0
  180. package/components/routes/overviews/OverviewViewer.js +2 -2
  181. package/components/routes/views/ViewComposer.js +46 -19
  182. package/locales/en/translation.json +80 -3
  183. package/locales/fr/translation.json +78 -3
  184. package/models/WithMetadata.d.ts +2 -1
  185. package/models/entities/generated/AttachmentsFile.d.ts +12 -0
  186. package/models/entities/generated/Case.d.ts +28 -0
  187. package/models/entities/generated/DestinationOriginal.d.ts +19 -0
  188. package/models/entities/generated/EmailAttachment.d.ts +8 -0
  189. package/models/entities/generated/EmailParent.d.ts +19 -0
  190. package/models/entities/generated/Enrichments.d.ts +7 -0
  191. package/models/entities/generated/EnrichmentsIndicator.d.ts +21 -0
  192. package/models/entities/generated/Hit.d.ts +1 -0
  193. package/models/entities/generated/Howler.d.ts +0 -4
  194. package/models/entities/generated/HttpResponse.d.ts +11 -0
  195. package/models/entities/generated/Item.d.ts +9 -0
  196. package/models/entities/generated/Observable.d.ts +85 -0
  197. package/models/entities/generated/ObservableCloud.d.ts +20 -0
  198. package/models/entities/generated/ObservableDestination.d.ts +23 -0
  199. package/models/entities/generated/ObservableEmail.d.ts +30 -0
  200. package/models/entities/generated/ObservableFile.d.ts +36 -0
  201. package/models/entities/generated/ObservableHowler.d.ts +43 -0
  202. package/models/entities/generated/ObservableHttp.d.ts +11 -0
  203. package/models/entities/generated/ObservableObserver.d.ts +21 -0
  204. package/models/entities/generated/ObservableOrganization.d.ts +7 -0
  205. package/models/entities/generated/ObservableProcess.d.ts +34 -0
  206. package/models/entities/generated/ObservableSource.d.ts +23 -0
  207. package/models/entities/generated/ObservableThreat.d.ts +21 -0
  208. package/models/entities/generated/ObservableTls.d.ts +12 -0
  209. package/models/entities/generated/ObserverIngress.d.ts +9 -0
  210. package/models/entities/generated/Rule.d.ts +2 -10
  211. package/models/entities/generated/Task.d.ts +10 -0
  212. package/models/entities/generated/Threat.d.ts +2 -2
  213. package/models/entities/generated/{Enrichment.d.ts → ThreatEnrichment.d.ts} +1 -1
  214. package/models/entities/generated/View.d.ts +1 -0
  215. package/package.json +18 -1
  216. package/plugins/clue/components/ClueTypography.js +2 -2
  217. package/plugins/clue/utils.d.ts +2 -1
  218. package/tests/server-handlers.js +6 -1
  219. package/tests/utils.d.ts +4 -0
  220. package/tests/utils.js +20 -0
  221. package/utils/constants.d.ts +3 -3
  222. package/utils/hitFunctions.d.ts +2 -1
  223. package/utils/hitFunctions.js +4 -4
  224. package/utils/typeUtils.d.ts +7 -0
  225. package/utils/typeUtils.js +27 -0
  226. package/utils/viewUtils.js +3 -0
  227. package/components/app/providers/HitProvider.d.ts +0 -22
  228. package/components/elements/display/icons/BundleButton.d.ts +0 -6
  229. package/components/elements/display/icons/BundleButton.js +0 -32
  230. package/components/elements/hit/HitRelated.d.ts +0 -6
  231. package/components/elements/hit/HitRelated.js +0 -7
  232. package/components/routes/help/BundleDocumentation.d.ts +0 -3
  233. package/components/routes/help/BundleDocumentation.js +0 -12
  234. package/components/routes/help/markdown/en/bundles.md.js +0 -1
  235. package/components/routes/help/markdown/fr/bundles.md.js +0 -1
  236. package/components/routes/hits/search/BundleParentMenu.d.ts +0 -6
  237. package/components/routes/hits/search/BundleParentMenu.js +0 -32
  238. package/components/routes/hits/search/BundleScroller.d.ts +0 -2
  239. package/components/routes/hits/search/BundleScroller.js +0 -6
  240. package/components/routes/hits/search/HitContextMenu.js +0 -227
  241. /package/components/app/providers/{HitSearchProvider.test.d.ts → RecordSearchProvider.test.d.ts} +0 -0
  242. /package/components/{routes/hits/search/HitContextMenu.test.d.ts → elements/ContextMenu.test.d.ts} +0 -0
  243. /package/components/{routes/overviews/OverviewEditor.d.ts → elements/MarkdownEditor.d.ts} +0 -0
  244. /package/components/elements/hit/{HitDetails.d.ts → related/RelatedRecords.d.ts} +0 -0
  245. /package/components/routes/hits/search/{HitBrowser.d.ts → RecordBrowser.d.ts} +0 -0
@@ -1,38 +1,34 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { Box, Chip, Divider, Grid, Stack, Tooltip, Typography, avatarClasses, iconButtonClasses, useTheme } from '@mui/material';
3
- import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
4
3
  import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
5
4
  import { uniq } from 'lodash-es';
6
5
  import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
7
- import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
6
+ import { useCallback, useContext, useMemo } from 'react';
8
7
  import { Trans, useTranslation } from 'react-i18next';
9
8
  import { usePluginStore } from 'react-pluggable';
10
- import { Link } from 'react-router-dom';
11
9
  import { ESCALATION_COLORS, PROVIDER_COLORS } from '@cccsaurora/howler-ui/utils/constants';
12
10
  import { stringToColor } from '@cccsaurora/howler-ui/utils/utils';
13
11
  import PluginTypography from '../PluginTypography';
12
+ import AnalyticLink from './elements/AnalyticLink';
14
13
  import Assigned from './elements/Assigned';
15
14
  import EscalationChip from './elements/EscalationChip';
16
15
  import HitTimestamp from './elements/HitTimestamp';
17
16
  import HitBannerTooltip from './HitBannerTooltip';
18
17
  import { HitLayout } from './HitLayout';
18
+ import RelatedRecords from './related/RelatedRecords';
19
19
  const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
20
20
  const { t } = useTranslation();
21
21
  const { config } = useContext(ApiConfigContext);
22
22
  const theme = useTheme();
23
23
  const pluginStore = usePluginStore();
24
- const { getMatchingAnalytic } = useMatchers();
25
- const [analyticId, setAnalyticId] = useState();
26
24
  const compressed = useMemo(() => layout === HitLayout.DENSE, [layout]);
27
25
  const textVariant = useMemo(() => (layout === HitLayout.COMFY ? 'body1' : 'caption'), [layout]);
28
- useEffect(() => {
29
- if (!hit?.howler.analytic) {
30
- return;
26
+ const providerColor = useMemo(() => {
27
+ if (!hit?.event.provider) {
28
+ return PROVIDER_COLORS.unknown;
31
29
  }
32
- getMatchingAnalytic(hit).then(analytic => setAnalyticId(analytic?.analytic_id));
33
- // eslint-disable-next-line react-hooks/exhaustive-deps
34
- }, [hit?.howler.analytic]);
35
- const providerColor = useMemo(() => PROVIDER_COLORS[hit.event?.provider ?? 'unknown'] ?? stringToColor(hit.event.provider), [hit.event?.provider]);
30
+ return PROVIDER_COLORS[hit?.event.provider] ?? stringToColor(hit?.event.provider);
31
+ }, [hit?.event.provider]);
36
32
  const mitreId = useMemo(() => {
37
33
  if (hit.threat?.framework?.toLowerCase().startsWith('mitre')) {
38
34
  return;
@@ -52,35 +48,23 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
52
48
  }
53
49
  return `/api/static/mitre/${mitreId}.svg`;
54
50
  }, [mitreId]);
55
- const leftBox = useMemo(() => {
56
- if (hit.howler.is_bundle) {
57
- return (_jsx(Box, { sx: {
58
- alignSelf: 'stretch',
59
- backgroundColor: providerColor,
60
- borderRadius: theme.shape.borderRadius,
61
- minWidth: '15px'
62
- } }));
63
- }
64
- else {
65
- return (_jsx(HitBannerTooltip, { hit: hit, children: _jsxs(Box, { sx: {
66
- gridColumn: { xs: 'span 3', sm: 'span 1' },
67
- minWidth: '90px',
68
- backgroundColor: providerColor,
69
- color: theme.palette.getContrastText(providerColor),
70
- alignSelf: 'start',
71
- borderRadius: theme.shape.borderRadius,
72
- p: compressed ? 0.5 : 1,
73
- pt: 2,
74
- pl: 1
75
- }, display: "flex", flexDirection: "column", children: [_jsx(Typography, { variant: compressed ? 'caption' : 'body1', style: { wordBreak: 'break-all' }, children: hit.organization?.name ?? _jsx(Trans, { i18nKey: "unknown" }) }), iconUrl && (_jsx(Box, { sx: {
76
- width: '40px',
77
- height: '40px',
78
- mask: `url("${iconUrl}")`,
79
- maskSize: 'cover',
80
- background: theme.palette.getContrastText(providerColor)
81
- } }))] }) }));
82
- }
83
- }, [compressed, hit, iconUrl, providerColor, theme.palette, theme.shape.borderRadius]);
51
+ const leftBox = useMemo(() => (_jsx(HitBannerTooltip, { hit: hit, children: _jsxs(Box, { sx: {
52
+ gridColumn: { xs: 'span 3', sm: 'span 1' },
53
+ minWidth: '90px',
54
+ backgroundColor: providerColor,
55
+ color: theme.palette.getContrastText(providerColor),
56
+ alignSelf: 'start',
57
+ borderRadius: theme.shape.borderRadius,
58
+ p: compressed ? 0.5 : 1,
59
+ pt: 2,
60
+ pl: 1
61
+ }, display: "flex", flexDirection: "column", children: [_jsx(Typography, { variant: compressed ? 'caption' : 'body1', style: { wordBreak: 'break-all' }, children: hit.organization?.name ?? _jsx(Trans, { i18nKey: "unknown" }) }), iconUrl && (_jsx(Box, { sx: {
62
+ width: '40px',
63
+ height: '40px',
64
+ mask: `url("${iconUrl}")`,
65
+ maskSize: 'cover',
66
+ background: theme.palette.getContrastText(providerColor)
67
+ } }))] }) })), [compressed, hit, iconUrl, providerColor, theme.palette, theme.shape.borderRadius]);
84
68
  /**
85
69
  * The tooltips are necessary only when in the most compressed format
86
70
  */
@@ -88,7 +72,7 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
88
72
  const _children = (_jsxs(Stack, { direction: "row", spacing: 1, flex: 1, children: [_jsxs(Typography, { variant: textVariant, noWrap: compressed, textOverflow: compressed ? 'ellipsis' : 'wrap', ...typographyProps, sx: [
89
73
  { display: 'flex', flexDirection: 'row' },
90
74
  ...(Array.isArray(typographyProps?.sx) ? typographyProps?.sx : [typographyProps?.sx])
91
- ], children: [t(i18nKey), ":"] }), (Array.isArray(value) ? value : [value]).map(val => (_jsx(PluginTypography, { component: "span", context: "banner", variant: textVariant, noWrap: compressed, textOverflow: compressed ? 'ellipsis' : 'wrap', ...typographyProps, value: val, field: field, hit: hit }, val)))] }));
75
+ ], children: [t(i18nKey), ":"] }), (Array.isArray(value) ? value : [value]).map(val => (_jsx(PluginTypography, { component: "span", context: "banner", variant: textVariant, noWrap: compressed, textOverflow: compressed ? 'ellipsis' : 'wrap', ...typographyProps, value: val, field: field, obj: hit }, val)))] }));
92
76
  return compressed ? (_jsx(Tooltip, { title: Array.isArray(value) ? (_jsx("div", { children: value.map(_indicator => (_jsx("p", { style: { margin: 0, padding: 0 }, children: _indicator }, _indicator))) })) : (value), children: _children })) : (_children);
93
77
  }, [compressed, hit, t, textVariant]);
94
78
  return (_jsxs(Box, { display: "grid", gridTemplateColumns: "minmax(0, auto) minmax(0, 1fr) minmax(0, auto)", alignItems: "stretch", sx: { width: '100%', ml: 0, overflow: 'hidden' }, children: [leftBox, _jsxs(Stack, { sx: {
@@ -98,11 +82,7 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
98
82
  }, spacing: layout !== HitLayout.COMFY ? 1 : 2, divider: _jsx(Divider, { orientation: "horizontal", sx: [
99
83
  layout !== HitLayout.COMFY && { marginTop: '4px !important' },
100
84
  { mr: `${theme.spacing(-1)} !important` }
101
- ] }), children: [_jsxs(Typography, { variant: compressed ? 'body1' : 'h6', fontWeight: compressed && 'bold', sx: { alignSelf: 'start', '& a': { color: 'text.primary' } }, children: [analyticId ? (_jsx(Link, { to: `/analytics/${analyticId}`, onAuxClick: e => {
102
- e.stopPropagation();
103
- }, onClick: e => {
104
- e.stopPropagation();
105
- }, children: hit.howler.analytic })) : (hit.howler.analytic), hit.howler.detection && ': ', hit.howler.detection] }), hit.howler?.rationale && (_jsxs(Typography, { flex: 1, variant: textVariant, color: ESCALATION_COLORS[hit.howler.escalation] + '.main', sx: { fontWeight: 'bold' }, children: [t('hit.header.rationale'), ": ", hit.howler.rationale] })), hit.howler?.outline && (_jsxs(_Fragment, { children: [_jsxs(Grid, { container: true, spacing: layout !== HitLayout.COMFY ? 1 : 2, sx: { ml: `${theme.spacing(-1)} !important` }, children: [hit.howler.outline.threat && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.threat", value: hit.howler.outline.threat, field: "howler.outline.threat" }) })), hit.howler.outline.target && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.target", value: hit.howler.outline.target, field: "howler.outline.target" }) }))] }), hit.howler.outline.indicators?.length > 0 && (_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Typography, { component: "span", variant: textVariant, children: [t('hit.header.indicators'), ":"] }), _jsx(Grid, { container: true, spacing: 0.5, sx: { mt: `${theme.spacing(-0.5)} !important`, ml: `${theme.spacing(0.25)} !important` }, children: uniq(hit.howler.outline.indicators).map((_indicator, index) => {
85
+ ] }), children: [_jsx(AnalyticLink, { hit: hit }), hit.howler?.rationale && (_jsxs(Typography, { flex: 1, variant: textVariant, color: ESCALATION_COLORS[hit.howler.escalation] + '.main', sx: { fontWeight: 'bold' }, children: [t('hit.header.rationale'), ": ", hit.howler.rationale] })), hit.howler?.outline && (_jsxs(_Fragment, { children: [_jsxs(Grid, { container: true, spacing: layout !== HitLayout.COMFY ? 1 : 2, sx: { ml: `${theme.spacing(-1)} !important` }, children: [hit.howler.outline.threat && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.threat", value: hit.howler.outline.threat, field: "howler.outline.threat" }) })), hit.howler.outline.target && (_jsx(Grid, { item: true, children: _jsx(Wrapper, { i18nKey: "hit.header.target", value: hit.howler.outline.target, field: "howler.outline.target" }) }))] }), hit.howler.outline.indicators?.length > 0 && (_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Typography, { component: "span", variant: textVariant, children: [t('hit.header.indicators'), ":"] }), _jsx(Grid, { container: true, spacing: 0.5, sx: { mt: `${theme.spacing(-0.5)} !important`, ml: `${theme.spacing(0.25)} !important` }, children: uniq(hit.howler.outline.indicators).map((_indicator, index) => {
106
86
  return (_jsx(Grid, { item: true, children: _jsxs(Stack, { direction: "row", children: [_jsx(PluginTypography, { context: "indicators", variant: textVariant, value: _indicator, children: _indicator }), index < hit.howler.outline.indicators.length - 1 && (_jsx(Typography, { variant: textVariant, children: ',' }))] }) }, _indicator));
107
87
  }) })] })), hit.howler.outline.summary && (_jsx(Wrapper, { i18nKey: "hit.header.summary", value: hit.howler.outline.summary, paragraph: true, textOverflow: "wrap", sx: [compressed && { marginTop: `0 !important` }], field: "howler.outline.summary" }))] }))] }), _jsxs(Stack, { direction: "column", spacing: layout !== HitLayout.COMFY ? 0.5 : 1, alignSelf: "stretch", sx: [
108
88
  { minWidth: 0, alignItems: { sm: 'end', md: 'start' }, flex: 1, pl: 1 },
@@ -116,6 +96,6 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
116
96
  width: theme.spacing(3)
117
97
  }
118
98
  }
119
- ], children: [_jsx(HitTimestamp, { hit: hit, layout: layout }), showAssigned && _jsx(Assigned, { hit: hit, layout: layout }), _jsxs(Stack, { direction: "row", spacing: layout !== HitLayout.COMFY ? 0.5 : 1, children: [_jsx(EscalationChip, { hit: hit, layout: layout }), ['in-progress', 'on-hold'].includes(hit.howler.status) && (_jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, size: layout !== HitLayout.COMFY ? 'small' : 'medium', color: "primary" })), hit.howler.is_bundle && (_jsx(Chip, { size: layout !== HitLayout.COMFY ? 'small' : 'medium', label: t('hit.header.bundlesize', { hits: hit.howler.hits.length }) }))] }), howlerPluginStore.plugins.flatMap(plugin => pluginStore.executeFunction(`${plugin}.status`, { hit, layout }))] })] }));
99
+ ], children: [_jsx(HitTimestamp, { hit: hit, layout: layout }), showAssigned && _jsx(Assigned, { hit: hit, layout: layout }), _jsxs(Stack, { direction: "row", spacing: layout !== HitLayout.COMFY ? 0.5 : 1, children: [_jsx(EscalationChip, { hit: hit, layout: layout }), ['in-progress', 'on-hold'].includes(hit.howler.status) && (_jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, color: "primary" }))] }), hit.howler.related && _jsx(RelatedRecords, { hit: hit }), howlerPluginStore.plugins.flatMap(plugin => pluginStore.executeFunction(`${plugin}.status`, { hit, layout }))] })] }));
120
100
  };
121
101
  export default HitBanner;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { CardContent, Skeleton } from '@mui/material';
3
- import { HitContext } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
3
+ import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
4
4
  import { memo, useEffect } from 'react';
5
5
  import { useContextSelector } from 'use-context-selector';
6
6
  import HowlerCard from '../display/HowlerCard';
@@ -8,17 +8,17 @@ import HitBanner from './HitBanner';
8
8
  import HitLabels from './HitLabels';
9
9
  import HitOutline from './HitOutline';
10
10
  const HitCard = ({ id, layout, readOnly = true }) => {
11
- const getHit = useContextSelector(HitContext, ctx => ctx.getHit);
12
- const hit = useContextSelector(HitContext, ctx => ctx.hits[id]);
11
+ const getRecord = useContextSelector(RecordContext, ctx => ctx.getRecord);
12
+ const hit = useContextSelector(RecordContext, ctx => ctx.records[id]);
13
13
  useEffect(() => {
14
14
  if (!hit) {
15
- getHit(id);
15
+ getRecord(id);
16
16
  }
17
17
  // eslint-disable-next-line react-hooks/exhaustive-deps
18
18
  }, [id]);
19
19
  if (!hit) {
20
20
  return _jsx(Skeleton, { variant: "rounded", height: "200px" });
21
21
  }
22
- return (_jsx(HowlerCard, { tabIndex: 0, sx: { position: 'relative' }, children: _jsxs(CardContent, { children: [_jsx(HitBanner, { hit: hit, layout: layout }), _jsx(HitOutline, { hit: hit, layout: layout }), _jsx(HitLabels, { hit: hit, readOnly: readOnly })] }) }));
22
+ return (_jsx(HowlerCard, { id: hit?.howler.id, tabIndex: 0, sx: { position: 'relative' }, children: _jsxs(CardContent, { children: [_jsx(HitBanner, { hit: hit, layout: layout }), _jsx(HitOutline, { hit: hit, layout: layout }), _jsx(HitLabels, { hit: hit, readOnly: readOnly })] }) }));
23
23
  };
24
24
  export default memo(HitCard);
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Add, Check, Edit } from '@mui/icons-material';
3
3
  import { Backdrop, Box, Button, Chip, CircularProgress, Drawer, FormControl, FormHelperText, IconButton, InputAdornment, InputLabel, ListItemIcon, ListItemText, MenuItem, Select, Stack, TextField, Tooltip, Typography } from '@mui/material';
4
4
  import api from '@cccsaurora/howler-ui/api';
5
- import { HitContext } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
5
+ import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
6
6
  import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
7
7
  import { memo, useCallback, useEffect, useState } from 'react';
8
8
  import { Trans, useTranslation } from 'react-i18next';
@@ -44,7 +44,7 @@ const NewLabelForm = ({ handleSubmit }) => {
44
44
  const HitLabels = ({ hit, readOnly = false }) => {
45
45
  const { dispatchApi } = useMyApi();
46
46
  const { t } = useTranslation();
47
- const updateHit = useContextSelector(HitContext, ctx => ctx.updateHit);
47
+ const updateHit = useContextSelector(RecordContext, ctx => ctx.updateRecord);
48
48
  const [openDrawer, setOpenDrawer] = useState(false);
49
49
  const [loading, setLoading] = useState(false);
50
50
  const [labels, setLabels] = useState(Object.entries(hit.howler.labels).flatMap(([key, category]) => {
@@ -1,8 +1,8 @@
1
1
  import type { AppSearchItemRendererOption } from '@cccsaurora/howler-ui/commons/components/app/AppSearchService';
2
2
  import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
3
- type QuickSearchProps = {
3
+ type PreviewProps = {
4
4
  hit: Hit;
5
- options: AppSearchItemRendererOption<Hit>;
5
+ options?: AppSearchItemRendererOption<Hit>;
6
6
  };
7
- declare const _default: import("react").NamedExoticComponent<QuickSearchProps>;
7
+ declare const _default: import("react").NamedExoticComponent<PreviewProps>;
8
8
  export default _default;
@@ -4,12 +4,18 @@ import { memo, useMemo } from 'react';
4
4
  import { Trans, useTranslation } from 'react-i18next';
5
5
  import { ESCALATION_COLORS, PROVIDER_COLORS, STATUS_COLORS } from '@cccsaurora/howler-ui/utils/constants';
6
6
  import { formatDate, stringToColor } from '@cccsaurora/howler-ui/utils/utils';
7
- const HitQuickSearch = ({ hit, options }) => {
7
+ const HitPreview = ({ hit, options }) => {
8
8
  const { t } = useTranslation();
9
9
  const theme = useTheme();
10
10
  const isUnderLg = useMediaQuery(theme.breakpoints.down('lg'));
11
11
  const providerColor = useMemo(() => PROVIDER_COLORS[hit.event?.provider ?? 'unknown'] ?? stringToColor(hit.event.provider), [hit.event?.provider]);
12
- return (_jsxs(Box, { sx: { overflow: 'hidden', borderBottom: `thin solid ${theme.palette.divider}`, pb: 1, mb: 0 }, display: "grid", gridTemplateColumns: "minmax(0, 1fr) minmax(0, auto)", children: [_jsxs(Stack, { flexGrow: 1, gridColumn: options.state.mode === 'inline' ? 'span 2' : '', children: [_jsxs(Typography, { variant: "body1", fontWeight: "bold", children: [hit.howler.analytic, hit.howler.detection && ': ', hit.howler.detection] }), options.state.mode !== 'inline' && hit.howler?.outline && (_jsx(Tooltip, { placement: isUnderLg ? 'bottom' : 'left', componentsProps: {
12
+ return (_jsxs(Box, { sx: {
13
+ overflow: 'hidden',
14
+ borderBottom: `thin solid ${theme.palette.divider}`,
15
+ pb: 1,
16
+ mb: 0,
17
+ gap: theme.spacing(1)
18
+ }, display: "grid", gridTemplateColumns: "minmax(0, 1fr) minmax(0, auto)", children: [_jsxs(Stack, { flexGrow: 1, gridColumn: options?.state.mode === 'inline' ? 'span 2' : '', children: [_jsxs(Typography, { variant: "body1", fontWeight: "bold", children: [hit.howler.analytic, hit.howler.detection && ': ', hit.howler.detection] }), options?.state.mode !== 'inline' && hit.howler?.outline && (_jsx(Tooltip, { placement: isUnderLg ? 'bottom' : 'left', componentsProps: {
13
19
  tooltip: {
14
20
  sx: {
15
21
  fontSize: 12,
@@ -17,7 +23,7 @@ const HitQuickSearch = ({ hit, options }) => {
17
23
  color: theme.palette.getContrastText(theme.palette.background.paper)
18
24
  }
19
25
  }
20
- }, title: _jsxs(Stack, { divider: _jsx(Divider, { sx: { my: 0.5 } }), children: [_jsxs("div", { children: [_jsx(Trans, { i18nKey: "hit.header.threat" }), ": ", hit.howler.outline.threat] }), _jsxs("div", { children: [_jsx(Trans, { i18nKey: "hit.header.target" }), ": ", hit.howler.outline.target] }), _jsx("div", { children: hit.howler.outline.indicators.join(', ') })] }), children: _jsxs(Stack, { direction: { xs: 'column', sm: 'column' }, flex: 1, children: [_jsxs(Typography, { variant: "caption", textOverflow: "ellipsis", sx: { wordBreak: 'break-all', overflow: 'hidden' }, children: [_jsx(Trans, { i18nKey: "hit.header.threat" }), ": ", hit.howler.outline.threat] }), _jsxs(Typography, { variant: "caption", textOverflow: "ellipsis", sx: { wordBreak: 'break-all', overflow: 'hidden' }, children: [_jsx(Trans, { i18nKey: "hit.header.target" }), ": ", hit.howler.outline.target] }), _jsxs(Typography, { variant: "caption", textOverflow: "ellipsis", sx: { wordBreak: 'break-all', overflow: 'hidden' }, children: [_jsx(Trans, { i18nKey: "hit.header.indicators" }), ": ", hit.howler.outline.indicators.map(i => i).join(', ')] })] }) }))] }), _jsxs(Stack, { alignItems: options.state.mode === 'fullscreen' ? 'end' : 'start', spacing: 0.5, children: [options.state.mode === 'fullscreen' && _jsx(Chip, { label: formatDate(hit.timestamp), size: "small" }), _jsxs(Stack, { direction: "row", spacing: 0.5, children: [options.state.mode === 'inline' && _jsx(Chip, { label: formatDate(hit.timestamp), size: "small" }), _jsx(Chip, { sx: {
26
+ }, title: _jsxs(Stack, { divider: _jsx(Divider, { sx: { my: 0.5 } }), children: [_jsxs("div", { children: [_jsx(Trans, { i18nKey: "hit.header.threat" }), ": ", hit.howler.outline.threat] }), _jsxs("div", { children: [_jsx(Trans, { i18nKey: "hit.header.target" }), ": ", hit.howler.outline.target] }), _jsx("div", { children: hit.howler.outline.indicators.join(', ') })] }), children: _jsxs(Stack, { direction: { xs: 'column', sm: 'column' }, flex: 1, children: [_jsxs(Typography, { variant: "caption", textOverflow: "ellipsis", sx: { wordBreak: 'break-all', overflow: 'hidden' }, children: [_jsx(Trans, { i18nKey: "hit.header.threat" }), ": ", hit.howler.outline.threat] }), _jsxs(Typography, { variant: "caption", textOverflow: "ellipsis", sx: { wordBreak: 'break-all', overflow: 'hidden' }, children: [_jsx(Trans, { i18nKey: "hit.header.target" }), ": ", hit.howler.outline.target] })] }) }))] }), _jsxs(Stack, { alignItems: options?.state.mode === 'fullscreen' ? 'end' : 'start', spacing: 0.5, children: [options?.state.mode === 'fullscreen' && _jsx(Chip, { label: formatDate(hit.timestamp), size: "small" }), _jsxs(Stack, { direction: "row", spacing: 0.5, children: [options?.state.mode === 'inline' && _jsx(Chip, { label: formatDate(hit.timestamp), size: "small" }), _jsx(Chip, { sx: {
21
27
  backgroundColor: providerColor,
22
28
  color: theme.palette.getContrastText(providerColor)
23
29
  }, label: hit.organization?.name ?? _jsx(Trans, { i18nKey: "unknown" }), size: "small" }), _jsx(Chip, { label: hit.howler.escalation, size: "small", color: ESCALATION_COLORS[hit.howler.escalation] })] }), _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(Chip, { sx: {
@@ -28,4 +34,4 @@ const HitQuickSearch = ({ hit, options }) => {
28
34
  ? hit?.howler.assignment
29
35
  : t('app.drawer.hit.assignment.unassigned.name'), size: "small" }), _jsx(Chip, { label: hit.howler.status, size: "small", color: STATUS_COLORS[hit.howler.status] })] })] })] }));
30
36
  };
31
- export default memo(HitQuickSearch);
37
+ export default memo(HitPreview);
@@ -1,8 +1,9 @@
1
1
  import type { HowlerSearchResponse } from '@cccsaurora/howler-ui/api/search';
2
2
  import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
3
+ import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
3
4
  import type { WithMetadata } from '@cccsaurora/howler-ui/models/WithMetadata';
4
5
  declare const _default: import("react").NamedExoticComponent<{
5
- response?: HowlerSearchResponse<WithMetadata<Hit>>;
6
+ response?: HowlerSearchResponse<WithMetadata<Hit | Observable>>;
6
7
  execute?: boolean;
7
8
  onStart?: () => void;
8
9
  onComplete?: () => void;
@@ -4,8 +4,8 @@ import { Alert, AlertTitle, Autocomplete, Box, Button, Chip, CircularProgress, D
4
4
  import api from '@cccsaurora/howler-ui/api';
5
5
  import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
6
6
  import { FieldContext } from '@cccsaurora/howler-ui/components/app/providers/FieldProvider';
7
- import { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
8
7
  import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
8
+ import { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
9
9
  import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
10
10
  import { useMyLocalStorageItem } from '@cccsaurora/howler-ui/components/hooks/useMyLocalStorage';
11
11
  import useMySnackbar from '@cccsaurora/howler-ui/components/hooks/useMySnackbar';
@@ -14,6 +14,7 @@ import { memo, useCallback, useContext, useEffect, useState } from 'react';
14
14
  import { useTranslation } from 'react-i18next';
15
15
  import { useContextSelector } from 'use-context-selector';
16
16
  import { StorageKey } from '@cccsaurora/howler-ui/utils/constants';
17
+ import { isHit } from '@cccsaurora/howler-ui/utils/typeUtils';
17
18
  import { getTimeRange } from '@cccsaurora/howler-ui/utils/utils';
18
19
  import PluginChip from '../PluginChip';
19
20
  import HitGraph from './aggregate/HitGraph';
@@ -24,9 +25,9 @@ const HitSummary = ({ response, onStart, onComplete }) => {
24
25
  const { showErrorMessage } = useMySnackbar();
25
26
  const pageCount = useMyLocalStorageItem(StorageKey.PAGE_COUNT, 25)[0];
26
27
  const { getMatchingTemplate } = useMatchers();
27
- const searching = useContextSelector(HitSearchContext, ctx => ctx.searching);
28
- const error = useContextSelector(HitSearchContext, ctx => ctx.error);
29
- const getFilters = useContextSelector(HitSearchContext, ctx => ctx.getFilters);
28
+ const searching = useContextSelector(RecordSearchContext, ctx => ctx.searching);
29
+ const error = useContextSelector(RecordSearchContext, ctx => ctx.error);
30
+ const getFilters = useContextSelector(RecordSearchContext, ctx => ctx.getFilters);
30
31
  const query = useContextSelector(ParameterContext, ctx => ctx.query);
31
32
  const setQuery = useContextSelector(ParameterContext, ctx => ctx.setQuery);
32
33
  const views = useContextSelector(ParameterContext, ctx => ctx.views);
@@ -40,7 +41,7 @@ const HitSummary = ({ response, onStart, onComplete }) => {
40
41
  }
41
42
  try {
42
43
  // Get a list of every key in every template of the hits we're searching
43
- const rawCounts = await Promise.all((response?.items ?? []).map(async (h) => {
44
+ const rawCounts = await Promise.all((response?.items ?? []).filter(isHit).map(async (h) => {
44
45
  const matchingTemplate = await getMatchingTemplate(h);
45
46
  return (matchingTemplate?.keys ?? [])
46
47
  .filter(key => !['howler.id', 'howler.hash'].includes(key))
@@ -4,9 +4,9 @@ import { Alert, AlertTitle, Autocomplete, Box, Button, CircularProgress, IconBut
4
4
  import api from '@cccsaurora/howler-ui/api';
5
5
  import 'chartjs-adapter-dayjs-4';
6
6
  import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
7
- import { HitContext } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
8
- import { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
9
7
  import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
8
+ import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
9
+ import { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
10
10
  import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
11
11
  import useMyChart from '@cccsaurora/howler-ui/components/hooks/useMyChart';
12
12
  import dayjs from 'dayjs';
@@ -38,12 +38,12 @@ const HitGraph = () => {
38
38
  const setQuery = useContextSelector(ParameterContext, ctx => ctx.setQuery);
39
39
  const span = useContextSelector(ParameterContext, ctx => ctx.span);
40
40
  const views = useContextSelector(ParameterContext, ctx => ctx.views);
41
- const selectedHits = useContextSelector(HitContext, ctx => ctx.selectedHits);
42
- const addHitToSelection = useContextSelector(HitContext, ctx => ctx.addHitToSelection);
43
- const removeHitFromSelection = useContextSelector(HitContext, ctx => ctx.removeHitFromSelection);
44
- const error = useContextSelector(HitSearchContext, ctx => ctx.error);
45
- const response = useContextSelector(HitSearchContext, ctx => ctx.response);
46
- const getFilters = useContextSelector(HitSearchContext, ctx => ctx.getFilters);
41
+ const selectedHits = useContextSelector(RecordContext, ctx => ctx.selectedRecords);
42
+ const addHitToSelection = useContextSelector(RecordContext, ctx => ctx.addRecordToSelection);
43
+ const removeHitFromSelection = useContextSelector(RecordContext, ctx => ctx.removeRecordFromSelection);
44
+ const error = useContextSelector(RecordSearchContext, ctx => ctx.error);
45
+ const response = useContextSelector(RecordSearchContext, ctx => ctx.response);
46
+ const getFilters = useContextSelector(RecordSearchContext, ctx => ctx.getFilters);
47
47
  const chartRef = useRef();
48
48
  const [loading, setLoading] = useState(false);
49
49
  const [filterField, setFilterField] = useState(FILTER_FIELDS[0]);
@@ -0,0 +1,8 @@
1
+ import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
2
+ import { type FC } from 'react';
3
+ declare const AnalyticLink: FC<{
4
+ hit: Hit;
5
+ compressed?: boolean;
6
+ alignSelf?: string;
7
+ }>;
8
+ export default AnalyticLink;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Typography } from '@mui/material';
3
+ import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
4
+ import { useEffect, useState } from 'react';
5
+ import { Link } from 'react-router-dom';
6
+ const AnalyticLink = ({ hit, compressed, alignSelf = 'start' }) => {
7
+ const { getMatchingAnalytic } = useMatchers();
8
+ const [analyticId, setAnalyticId] = useState();
9
+ useEffect(() => {
10
+ if (!hit?.howler.analytic) {
11
+ return;
12
+ }
13
+ getMatchingAnalytic(hit).then(analytic => setAnalyticId(analytic?.analytic_id));
14
+ // eslint-disable-next-line react-hooks/exhaustive-deps
15
+ }, [hit?.howler.analytic]);
16
+ return (_jsxs(Typography, { variant: compressed ? 'body1' : 'h6', fontWeight: compressed && 'bold', sx: { alignSelf, '& a': { color: 'text.primary' } }, children: [analyticId ? (_jsx(Link, { to: `/analytics/${analyticId}`, onAuxClick: e => {
17
+ e.stopPropagation();
18
+ }, onClick: e => {
19
+ e.stopPropagation();
20
+ }, children: hit.howler.analytic })) : (hit.howler.analytic), hit.howler.detection && ': ', hit.howler.detection] }));
21
+ };
22
+ export default AnalyticLink;
@@ -41,7 +41,7 @@ const DefaultOutline = ({ hit, fields, template, layout = HitLayout.NORMAL, read
41
41
  if (!displayedData) {
42
42
  return null;
43
43
  }
44
- return (_jsxs(React.Fragment, { children: [_jsx(Tooltip, { title: (config.indexes.hit[field]?.description ?? t('none')).split('\n')[0], children: _jsxs(Typography, { variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', fontWeight: "bold", children: [field, ":"] }) }), _jsx(PluginTypography, { context: "outline", variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', whiteSpace: "normal", sx: { width: '100%', wordBreak: 'break-all' }, value: displayedData, field: field, hit: hit, children: displayedData })] }, field));
44
+ return (_jsxs(React.Fragment, { children: [_jsx(Tooltip, { title: (config.indexes.hit[field]?.description ?? t('none')).split('\n')[0], children: _jsxs(Typography, { variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', fontWeight: "bold", children: [field, ":"] }) }), _jsx(PluginTypography, { context: "outline", variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', whiteSpace: "normal", sx: { width: '100%', wordBreak: 'break-all' }, value: displayedData, field: field, obj: hit, children: displayedData })] }, field));
45
45
  })] }));
46
46
  };
47
47
  export default memo(DefaultOutline);
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Link as LinkIcon } from '@mui/icons-material';
3
+ import { alpha, Box, Chip, Divider, Stack, useTheme } from '@mui/material';
4
+ import CasePreview from '@cccsaurora/howler-ui/components/elements/case/CasePreview';
5
+ import ChipPopper from '@cccsaurora/howler-ui/components/elements/display/ChipPopper';
6
+ import ObservablePreview from '@cccsaurora/howler-ui/components/elements/observable/ObservablePreview';
7
+ import useRelatedRecords from '@cccsaurora/howler-ui/components/hooks/useRelatedRecords';
8
+ import { identity, uniq } from 'lodash-es';
9
+ import { memo, useMemo, useState } from 'react';
10
+ import { useTranslation } from 'react-i18next';
11
+ import { Link } from 'react-router-dom';
12
+ import { isCase, isHit, isObservable } from '@cccsaurora/howler-ui/utils/typeUtils';
13
+ import HitPreview from '../HitPreview';
14
+ const RecordLink = ({ to, ariaLabel, children }) => {
15
+ const theme = useTheme();
16
+ return (_jsxs(Box, { p: 1, flex: 1, position: "relative", sx: {
17
+ '& > a': {
18
+ backgroundColor: 'transparent',
19
+ transition: theme.transitions.create('background-color', {
20
+ duration: theme.transitions.duration.shortest
21
+ }),
22
+ '&:hover': {
23
+ backgroundColor: alpha('#555', 0.5)
24
+ }
25
+ }
26
+ }, children: [_jsx(Link, { to: to, style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 }, target: "_blank", rel: "noopener noreferrer", "aria-label": ariaLabel }), children] }));
27
+ };
28
+ const RelatedRecords = ({ hit }) => {
29
+ const { t } = useTranslation();
30
+ const [open, setOpen] = useState(false);
31
+ const [filter, setFilter] = useState(null);
32
+ const related = useMemo(() => hit?.howler.related ?? [], [hit?.howler.related]);
33
+ const records = useRelatedRecords(related, open);
34
+ return (_jsxs(ChipPopper
35
+ // eslint-disable-next-line jsx-a11y/anchor-is-valid
36
+ , {
37
+ // eslint-disable-next-line jsx-a11y/anchor-is-valid
38
+ icon: _jsx(LinkIcon, {}), label: _jsx("span", { style: { cursor: 'pointer' }, children: t('hit.header.related', { count: related.length }) }), slotProps: {
39
+ chip: { disabled: related.length < 1 },
40
+ paper: {
41
+ elevation: 4,
42
+ onAuxClick: ev => ev.stopPropagation()
43
+ }
44
+ }, disablePortal: false, placement: "bottom-end", onToggle: _open => setOpen(_open), children: [_jsx(Stack, { direction: "row", spacing: 1, mb: 1, justifyContent: "end", children: uniq(records.map(record => record.__index))
45
+ .filter(identity)
46
+ .map(_type => (_jsx(Chip, { color: _type === filter ? 'primary' : 'default', label: _type, onClick: () => setFilter(current => (current === _type ? null : _type)) }, _type))) }), _jsxs(Stack, { maxWidth: "40vw", maxHeight: "70vh", sx: { overflowY: 'auto' }, children: [_jsx(Divider, {}), records
47
+ .filter(record => !filter || record.__index === filter)
48
+ .map(entry => {
49
+ if (isHit(entry)) {
50
+ const key = entry.howler.id;
51
+ return (_jsx(RecordLink, { to: `/hits/${key}`, ariaLabel: t('hit.header.view.hit', { id: key }), children: _jsx(HitPreview, { hit: entry }) }, key));
52
+ }
53
+ else if (isCase(entry)) {
54
+ const key = entry.case_id;
55
+ return (_jsx(RecordLink, { to: `/cases/${key}`, ariaLabel: t('hit.header.view.case', { id: key }), children: _jsx(CasePreview, { case: entry }) }, key));
56
+ }
57
+ else if (isObservable(entry)) {
58
+ const key = entry.howler.id;
59
+ return (_jsx(RecordLink, { to: `/observables/${key}`, ariaLabel: t('hit.header.view.observable', { id: key }), children: _jsx(ObservablePreview, { observable: entry }) }, key));
60
+ }
61
+ })] })] }));
62
+ };
63
+ export default memo(RelatedRecords);
@@ -0,0 +1,6 @@
1
+ import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
2
+ declare const _default: import("react").NamedExoticComponent<{
3
+ id?: string;
4
+ observable?: Observable;
5
+ }>;
6
+ export default _default;
@@ -0,0 +1,23 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CardContent, Skeleton } from '@mui/material';
3
+ import { hit } from '@cccsaurora/howler-ui/api/search';
4
+ import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
5
+ import HowlerCard from '@cccsaurora/howler-ui/components/elements/display/HowlerCard';
6
+ import { memo, useEffect } from 'react';
7
+ import { useContextSelector } from 'use-context-selector';
8
+ import ObservablePreview from './ObservablePreview';
9
+ const ObservableCard = ({ id, observable: _observable }) => {
10
+ const getRecord = useContextSelector(RecordContext, ctx => ctx.getRecord);
11
+ const observable = useContextSelector(RecordContext, ctx => _observable ?? ctx.records[id]);
12
+ useEffect(() => {
13
+ if (!observable) {
14
+ getRecord(id);
15
+ }
16
+ // eslint-disable-next-line react-hooks/exhaustive-deps
17
+ }, [id]);
18
+ if (!hit) {
19
+ return _jsx(Skeleton, { variant: "rounded", height: "200px" });
20
+ }
21
+ return (_jsx(HowlerCard, { sx: { position: 'relative' }, children: _jsx(CardContent, { children: _jsx(ObservablePreview, { observable: observable }) }) }));
22
+ };
23
+ export default memo(ObservableCard);
@@ -0,0 +1,6 @@
1
+ import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
2
+ type PreviewProps = {
3
+ observable: Observable;
4
+ };
5
+ declare const _default: import("react").NamedExoticComponent<PreviewProps>;
6
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { OpenInNew } from '@mui/icons-material';
3
+ import { Chip, IconButton, Stack, Typography, useTheme } from '@mui/material';
4
+ import { memo } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { Link } from 'react-router-dom';
7
+ const ObservablePreview = ({ observable }) => {
8
+ const { t } = useTranslation();
9
+ const theme = useTheme();
10
+ return (_jsx(Stack, { flex: 1, spacing: 1, sx: { overflow: 'hidden', borderBottom: `thin solid ${theme.palette.divider}`, pb: 1, mb: 0 }, children: _jsxs(Stack, { children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { variant: "body1", fontWeight: "bold", children: observable.event.provider }), _jsx("div", { style: { flex: 1 } }), _jsx(Chip, { label: observable.event.kind }), observable.event.reference && (_jsx(IconButton, { size: "small", component: Link, to: observable.event.reference, sx: { opacity: 1 }, target: "_blank", rel: "noopener noreferrer", children: _jsx(OpenInNew, { fontSize: "small" }) }))] }), observable.event.type && (_jsxs(Typography, { variant: "caption", children: [t('event.type'), " - ", observable.event.type.join(', ')] })), observable.event.module && (_jsxs(Typography, { variant: "caption", children: [t('event.module'), " - ", observable.event.module] }))] }) }));
11
+ };
12
+ export default memo(ObservablePreview);
@@ -1,11 +1,12 @@
1
1
  import type { HowlerUser } from '@cccsaurora/howler-ui/models/entities/HowlerUser';
2
2
  import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
3
+ import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
3
4
  import { type FC } from 'react';
4
- interface HitCommentsProps {
5
- hit: Hit;
5
+ interface RecordCommentsProps {
6
+ record: Hit | Observable;
6
7
  users: {
7
8
  [id: string]: HowlerUser;
8
9
  };
9
10
  }
10
- declare const HitComments: FC<HitCommentsProps>;
11
- export default HitComments;
11
+ declare const RecordComments: FC<RecordCommentsProps>;
12
+ export default RecordComments;