@cccsaurora/howler-ui 2.17.0-dev.617 → 2.17.1-dev.627

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 (193) hide show
  1. package/api/index.d.ts +0 -2
  2. package/api/index.js +2 -4
  3. package/api/search/index.d.ts +1 -2
  4. package/api/search/index.js +1 -2
  5. package/commons/components/leftnav/LeftNavDrawer.js +1 -1
  6. package/components/app/App.js +0 -14
  7. package/components/app/providers/FavouritesProvider.js +2 -2
  8. package/components/app/providers/HitSearchProvider.d.ts +1 -0
  9. package/components/app/providers/HitSearchProvider.js +11 -6
  10. package/components/app/providers/HitSearchProvider.test.js +32 -11
  11. package/components/app/providers/LocalStorageProvider.js +1 -1
  12. package/components/app/providers/ParameterProvider.d.ts +2 -9
  13. package/components/app/providers/ParameterProvider.js +240 -165
  14. package/components/app/providers/ParameterProvider.test.js +14 -307
  15. package/components/elements/EditRow.d.ts +4 -1
  16. package/components/elements/EditRow.js +4 -4
  17. package/components/elements/PluginTypography.d.ts +1 -2
  18. package/components/elements/PluginTypography.js +2 -3
  19. package/components/elements/UserList.d.ts +2 -5
  20. package/components/elements/UserList.js +5 -14
  21. package/components/elements/addons/search/phrase/Phrase.js +1 -1
  22. package/components/elements/display/ChipPopper.d.ts +1 -1
  23. package/components/elements/display/ChipPopper.js +1 -1
  24. package/components/elements/display/HowlerCard.js +1 -1
  25. package/components/elements/display/Modal.js +0 -1
  26. package/components/elements/display/icons/BundleButton.d.ts +6 -0
  27. package/components/elements/display/icons/BundleButton.js +32 -0
  28. package/components/elements/hit/HitBanner.js +48 -28
  29. package/components/elements/hit/HitCard.js +1 -1
  30. package/components/elements/{ObjectDetails.js → hit/HitDetails.js} +17 -17
  31. package/components/elements/hit/HitOutline.js +7 -3
  32. package/components/elements/hit/{HitPreview.d.ts → HitQuickSearch.d.ts} +3 -3
  33. package/components/elements/hit/{HitPreview.js → HitQuickSearch.js} +4 -10
  34. package/components/elements/hit/HitRelated.d.ts +1 -1
  35. package/components/elements/hit/HitRelated.js +3 -30
  36. package/components/elements/hit/outlines/DefaultOutline.js +1 -1
  37. package/components/elements/hit/related/PivotLink.js +1 -1
  38. package/components/elements/hit/related/RelatedLink.d.ts +1 -0
  39. package/components/elements/hit/related/RelatedLink.js +2 -2
  40. package/components/elements/view/ViewTitle.js +1 -1
  41. package/components/hooks/useHitActions.d.ts +1 -1
  42. package/components/hooks/useHitActions.js +2 -2
  43. package/components/hooks/useHitSelection.js +24 -3
  44. package/components/hooks/useLocalStorage.d.ts +13 -0
  45. package/components/hooks/useLocalStorage.js +53 -0
  46. package/components/hooks/useLocalStorageItem.d.ts +18 -0
  47. package/components/hooks/useLocalStorageItem.js +78 -0
  48. package/components/hooks/useLocalStorageItem.test.d.ts +1 -0
  49. package/components/hooks/useLocalStorageItem.test.js +144 -0
  50. package/components/hooks/useMyLocalStorage.js +2 -2
  51. package/components/hooks/useMyPreferences.js +1 -10
  52. package/components/hooks/useMySearch.js +2 -2
  53. package/components/hooks/useMySitemap.js +1 -4
  54. package/components/hooks/useMyTheme.js +2 -9
  55. package/components/routes/action/view/ActionSearch.js +1 -1
  56. package/components/routes/advanced/QueryBuilder.js +1 -1
  57. package/components/routes/analytics/AnalyticDetails.js +2 -2
  58. package/components/routes/analytics/AnalyticSearch.js +1 -1
  59. package/components/routes/help/ApiDocumentation.js +1 -1
  60. package/components/routes/help/BundleDocumentation.d.ts +3 -0
  61. package/components/routes/help/BundleDocumentation.js +12 -0
  62. package/components/routes/help/HitDocumentation.js +3 -1
  63. package/components/routes/help/markdown/en/bundles.md.js +1 -0
  64. package/components/routes/help/markdown/fr/bundles.md.js +1 -0
  65. package/components/routes/hits/search/BundleParentMenu.d.ts +6 -0
  66. package/components/routes/hits/search/BundleParentMenu.js +32 -0
  67. package/components/routes/hits/search/HitContextMenu.js +2 -3
  68. package/components/routes/hits/search/InformationPane.d.ts +0 -1
  69. package/components/routes/hits/search/InformationPane.js +28 -6
  70. package/components/routes/hits/search/LayoutSettings.d.ts +3 -0
  71. package/components/routes/hits/search/LayoutSettings.js +18 -0
  72. package/components/routes/hits/search/QuerySettings.js +1 -2
  73. package/components/routes/hits/search/QuerySettings.test.js +9 -14
  74. package/components/routes/hits/search/SearchPane.js +37 -13
  75. package/components/routes/hits/search/ViewLink.js +1 -1
  76. package/components/routes/hits/search/grid/EnhancedCell.js +1 -1
  77. package/components/routes/hits/view/HitViewer.js +4 -3
  78. package/components/routes/home/AnalyticCard.d.ts +2 -3
  79. package/components/routes/home/AnalyticCard.js +2 -2
  80. package/components/routes/home/ViewCard.js +1 -1
  81. package/components/routes/home/ViewRefresh.d.ts +23 -0
  82. package/components/routes/home/ViewRefresh.js +67 -0
  83. package/components/routes/home/index.js +9 -46
  84. package/components/{elements/MarkdownEditor.js → routes/overviews/OverviewEditor.js} +3 -3
  85. package/components/routes/overviews/OverviewViewer.js +2 -2
  86. package/components/routes/settings/LocalSection.js +2 -1
  87. package/locales/en/translation.json +6 -42
  88. package/locales/fr/translation.json +4 -35
  89. package/models/WithMetadata.d.ts +1 -2
  90. package/models/entities/generated/{ThreatEnrichment.d.ts → Enrichment.d.ts} +1 -1
  91. package/models/entities/generated/Howler.d.ts +4 -0
  92. package/models/entities/generated/Rule.d.ts +10 -2
  93. package/models/entities/generated/Threat.d.ts +2 -2
  94. package/package.json +1 -16
  95. package/plugins/clue/components/ClueTypography.js +2 -2
  96. package/plugins/clue/utils.d.ts +1 -2
  97. package/utils/constants.d.ts +4 -3
  98. package/utils/constants.js +1 -0
  99. package/api/search/case.d.ts +0 -4
  100. package/api/search/case.js +0 -8
  101. package/api/v2/case/index.d.ts +0 -6
  102. package/api/v2/case/index.js +0 -18
  103. package/api/v2/index.d.ts +0 -4
  104. package/api/v2/index.js +0 -6
  105. package/api/v2/search/facet.d.ts +0 -3
  106. package/api/v2/search/facet.js +0 -12
  107. package/api/v2/search/index.d.ts +0 -5
  108. package/api/v2/search/index.js +0 -24
  109. package/components/elements/ObjectDetails.d.ts +0 -6
  110. package/components/elements/case/CaseCard.d.ts +0 -8
  111. package/components/elements/case/CaseCard.js +0 -39
  112. package/components/elements/case/CasePreview.d.ts +0 -6
  113. package/components/elements/case/CasePreview.js +0 -17
  114. package/components/elements/case/StatusIcon.d.ts +0 -5
  115. package/components/elements/case/StatusIcon.js +0 -13
  116. package/components/elements/hit/elements/AnalyticLink.d.ts +0 -8
  117. package/components/elements/hit/elements/AnalyticLink.js +0 -22
  118. package/components/elements/hit/related/RelatedRecords.js +0 -63
  119. package/components/elements/observable/ObservableCard.d.ts +0 -5
  120. package/components/elements/observable/ObservableCard.js +0 -7
  121. package/components/elements/observable/ObservablePreview.d.ts +0 -6
  122. package/components/elements/observable/ObservablePreview.js +0 -12
  123. package/components/hooks/useRelatedRecords.d.ts +0 -13
  124. package/components/hooks/useRelatedRecords.js +0 -32
  125. package/components/routes/cases/CaseViewer.d.ts +0 -2
  126. package/components/routes/cases/CaseViewer.js +0 -24
  127. package/components/routes/cases/Cases.d.ts +0 -2
  128. package/components/routes/cases/Cases.js +0 -101
  129. package/components/routes/cases/constants.d.ts +0 -5
  130. package/components/routes/cases/constants.js +0 -5
  131. package/components/routes/cases/detail/AlertPanel.d.ts +0 -6
  132. package/components/routes/cases/detail/AlertPanel.js +0 -32
  133. package/components/routes/cases/detail/CaseDashboard.d.ts +0 -7
  134. package/components/routes/cases/detail/CaseDashboard.js +0 -49
  135. package/components/routes/cases/detail/CaseDetails.d.ts +0 -6
  136. package/components/routes/cases/detail/CaseDetails.js +0 -61
  137. package/components/routes/cases/detail/CaseOverview.d.ts +0 -7
  138. package/components/routes/cases/detail/CaseOverview.js +0 -43
  139. package/components/routes/cases/detail/CaseSidebar.d.ts +0 -6
  140. package/components/routes/cases/detail/CaseSidebar.js +0 -36
  141. package/components/routes/cases/detail/CaseTask.d.ts +0 -11
  142. package/components/routes/cases/detail/CaseTask.js +0 -57
  143. package/components/routes/cases/detail/ItemPage.d.ts +0 -6
  144. package/components/routes/cases/detail/ItemPage.js +0 -93
  145. package/components/routes/cases/detail/RelatedCasePanel.d.ts +0 -6
  146. package/components/routes/cases/detail/RelatedCasePanel.js +0 -31
  147. package/components/routes/cases/detail/TaskPanel.d.ts +0 -7
  148. package/components/routes/cases/detail/TaskPanel.js +0 -52
  149. package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +0 -12
  150. package/components/routes/cases/detail/aggregates/CaseAggregate.js +0 -19
  151. package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +0 -6
  152. package/components/routes/cases/detail/aggregates/SourceAggregate.js +0 -27
  153. package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +0 -13
  154. package/components/routes/cases/detail/sidebar/CaseFolder.js +0 -134
  155. package/components/routes/cases/detail/sidebar/types.d.ts +0 -3
  156. package/components/routes/cases/detail/sidebar/utils.d.ts +0 -3
  157. package/components/routes/cases/detail/sidebar/utils.js +0 -25
  158. package/components/routes/cases/hooks/useCase.d.ts +0 -13
  159. package/components/routes/cases/hooks/useCase.js +0 -38
  160. package/components/routes/cases/modals/ResolveModal.d.ts +0 -7
  161. package/components/routes/cases/modals/ResolveModal.js +0 -59
  162. package/components/routes/hits/search/shared/IndexPicker.d.ts +0 -2
  163. package/components/routes/hits/search/shared/IndexPicker.js +0 -20
  164. package/components/routes/observables/ObservableViewer.d.ts +0 -7
  165. package/components/routes/observables/ObservableViewer.js +0 -27
  166. package/models/entities/generated/AttachmentsFile.d.ts +0 -12
  167. package/models/entities/generated/Case.d.ts +0 -28
  168. package/models/entities/generated/DestinationOriginal.d.ts +0 -19
  169. package/models/entities/generated/EmailAttachment.d.ts +0 -8
  170. package/models/entities/generated/EmailParent.d.ts +0 -19
  171. package/models/entities/generated/Enrichments.d.ts +0 -7
  172. package/models/entities/generated/EnrichmentsIndicator.d.ts +0 -21
  173. package/models/entities/generated/HttpResponse.d.ts +0 -11
  174. package/models/entities/generated/Item.d.ts +0 -9
  175. package/models/entities/generated/Observable.d.ts +0 -84
  176. package/models/entities/generated/ObservableCloud.d.ts +0 -20
  177. package/models/entities/generated/ObservableDestination.d.ts +0 -23
  178. package/models/entities/generated/ObservableEmail.d.ts +0 -30
  179. package/models/entities/generated/ObservableFile.d.ts +0 -36
  180. package/models/entities/generated/ObservableHowler.d.ts +0 -44
  181. package/models/entities/generated/ObservableHttp.d.ts +0 -11
  182. package/models/entities/generated/ObservableObserver.d.ts +0 -21
  183. package/models/entities/generated/ObservableOrganization.d.ts +0 -7
  184. package/models/entities/generated/ObservableProcess.d.ts +0 -34
  185. package/models/entities/generated/ObservableSource.d.ts +0 -23
  186. package/models/entities/generated/ObservableThreat.d.ts +0 -21
  187. package/models/entities/generated/ObservableTls.d.ts +0 -12
  188. package/models/entities/generated/ObserverIngress.d.ts +0 -9
  189. package/models/entities/generated/Task.d.ts +0 -10
  190. package/utils/typeUtils.d.ts +0 -7
  191. package/utils/typeUtils.js +0 -18
  192. /package/components/elements/hit/{related/RelatedRecords.d.ts → HitDetails.d.ts} +0 -0
  193. /package/components/{elements/MarkdownEditor.d.ts → routes/overviews/OverviewEditor.d.ts} +0 -0
@@ -1,34 +1,38 @@
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';
3
4
  import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
4
5
  import { uniq } from 'lodash-es';
5
6
  import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
6
- import { useCallback, useContext, useMemo } from 'react';
7
+ import { useCallback, useContext, useEffect, useMemo, useState } from 'react';
7
8
  import { Trans, useTranslation } from 'react-i18next';
8
9
  import { usePluginStore } from 'react-pluggable';
10
+ import { Link } from 'react-router-dom';
9
11
  import { ESCALATION_COLORS, PROVIDER_COLORS } from '@cccsaurora/howler-ui/utils/constants';
10
12
  import { stringToColor } from '@cccsaurora/howler-ui/utils/utils';
11
13
  import PluginTypography from '../PluginTypography';
12
- import AnalyticLink from './elements/AnalyticLink';
13
14
  import Assigned from './elements/Assigned';
14
15
  import EscalationChip from './elements/EscalationChip';
15
16
  import HitTimestamp from './elements/HitTimestamp';
16
17
  import HitBannerTooltip from './HitBannerTooltip';
17
18
  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();
24
26
  const compressed = useMemo(() => layout === HitLayout.DENSE, [layout]);
25
27
  const textVariant = useMemo(() => (layout === HitLayout.COMFY ? 'body1' : 'caption'), [layout]);
26
- const providerColor = useMemo(() => {
27
- if (!hit?.event.provider) {
28
- return PROVIDER_COLORS.unknown;
28
+ useEffect(() => {
29
+ if (!hit?.howler.analytic) {
30
+ return;
29
31
  }
30
- return PROVIDER_COLORS[hit?.event.provider] ?? stringToColor(hit?.event.provider);
31
- }, [hit?.event.provider]);
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]);
32
36
  const mitreId = useMemo(() => {
33
37
  if (hit.threat?.framework?.toLowerCase().startsWith('mitre')) {
34
38
  return;
@@ -48,23 +52,35 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
48
52
  }
49
53
  return `/api/static/mitre/${mitreId}.svg`;
50
54
  }, [mitreId]);
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]);
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]);
68
84
  /**
69
85
  * The tooltips are necessary only when in the most compressed format
70
86
  */
@@ -72,7 +88,7 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
72
88
  const _children = (_jsxs(Stack, { direction: "row", spacing: 1, flex: 1, children: [_jsxs(Typography, { variant: textVariant, noWrap: compressed, textOverflow: compressed ? 'ellipsis' : 'wrap', ...typographyProps, sx: [
73
89
  { display: 'flex', flexDirection: 'row' },
74
90
  ...(Array.isArray(typographyProps?.sx) ? typographyProps?.sx : [typographyProps?.sx])
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)))] }));
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)))] }));
76
92
  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);
77
93
  }, [compressed, hit, t, textVariant]);
78
94
  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: {
@@ -82,7 +98,11 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
82
98
  }, spacing: layout !== HitLayout.COMFY ? 1 : 2, divider: _jsx(Divider, { orientation: "horizontal", sx: [
83
99
  layout !== HitLayout.COMFY && { marginTop: '4px !important' },
84
100
  { mr: `${theme.spacing(-1)} !important` }
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) => {
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) => {
86
106
  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));
87
107
  }) })] })), 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: [
88
108
  { minWidth: 0, alignItems: { sm: 'end', md: 'start' }, flex: 1, pl: 1 },
@@ -96,6 +116,6 @@ const HitBanner = ({ hit, layout = HitLayout.NORMAL, showAssigned = true }) => {
96
116
  width: theme.spacing(3)
97
117
  }
98
118
  }
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 }))] })] }));
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 }))] })] }));
100
120
  };
101
121
  export default HitBanner;
@@ -19,6 +19,6 @@ const HitCard = ({ id, layout, readOnly = true }) => {
19
19
  if (!hit) {
20
20
  return _jsx(Skeleton, { variant: "rounded", height: "200px" });
21
21
  }
22
- return (_jsx(HowlerCard, { 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 })] }) }));
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 })] }) }));
23
23
  };
24
24
  export default memo(HitCard);
@@ -5,12 +5,12 @@ import { ArrowDropDown, InfoOutlined } from '@mui/icons-material';
5
5
  import { Accordion, AccordionDetails, AccordionSummary, Box, Divider, Grid, Stack, TextField, Tooltip, Typography, useTheme } from '@mui/material';
6
6
  import { flatten } from 'flat';
7
7
  import Fuse from 'fuse.js';
8
- import { capitalize, groupBy, isArray, isBoolean, isEmpty, isNull, isNumber, isObject, isPlainObject, isUndefined, max, sortBy, uniq } from 'lodash-es';
8
+ import { capitalize, groupBy, isArray, isEmpty, isNull, isObject, isPlainObject, isUndefined, max, sortBy, uniq } from 'lodash-es';
9
9
  import { memo, useEffect, useMemo, useState } from 'react';
10
10
  import { useTranslation } from 'react-i18next';
11
11
  import Throttler from '@cccsaurora/howler-ui/utils/Throttler';
12
- import PluginTypography from './PluginTypography';
13
- const ListRenderer = memo(({ obj, objKey: key, entries, maxKeyLength }) => {
12
+ import PluginTypography from '../PluginTypography';
13
+ const ListRenderer = memo(({ hit, objKey: key, entries, maxKeyLength }) => {
14
14
  const theme = useTheme();
15
15
  const { t } = useTranslation();
16
16
  const allPrimitives = useMemo(() => entries.every(entry => !isObject(entry)), [entries]);
@@ -36,15 +36,15 @@ const ListRenderer = memo(({ obj, objKey: key, entries, maxKeyLength }) => {
36
36
  marginBottom: allPrimitives ? 0 : theme.spacing(1)
37
37
  }, children: allPrimitives ? key.padStart(maxKeyLength ?? key.length) : key }) }), _jsxs(Grid, { container: true, spacing: allPrimitives ? 1 : 4, ml: allPrimitives ? -1 : -4, overflow: "hidden", maxWidth: "100%", children: [uniqueEntries.map((entry, index) => {
38
38
  if (Array.isArray(entry)) {
39
- return (_jsx(Grid, { item: true, xs: "auto", maxWidth: "100%", children: _jsx(ListRenderer, { obj: obj, objKey: `${key}.${index}`, entries: entry }) }, index));
39
+ return (_jsx(Grid, { item: true, xs: "auto", maxWidth: "100%", children: _jsx(ListRenderer, { hit: hit, objKey: `${key}.${index}`, entries: entry }) }, index));
40
40
  }
41
41
  if (isPlainObject(entry)) {
42
42
  return (_jsx(Grid, { item: true, xs: 'auto', maxWidth: "100%", minWidth: "350px", children: _jsx(ObjectRenderer, { parentKey: `${key}.${index}`, indent: true, data: entry }) }, index));
43
43
  }
44
- return (_jsxs(Grid, { item: true, maxWidth: "100%", className: `${key}_${index}`.replace(/\./g, '_'), component: "code", display: "flex", flexDirection: "row", children: [_jsx(PluginTypography, { context: "details", component: "code", style: { maxWidth: '100%', font: 'inherit' }, value: entry, field: key.replace(/\.[0-9]+/g, ''), obj: obj, children: entry }), allPrimitives && index < uniqueEntries.length - 1 && _jsx("span", { children: "," })] }, entry));
44
+ return (_jsxs(Grid, { item: true, maxWidth: "100%", className: `${key}_${index}`.replace(/\./g, '_'), component: "code", display: "flex", flexDirection: "row", children: [_jsx(PluginTypography, { context: "details", component: "code", style: { maxWidth: '100%', font: 'inherit' }, value: entry, field: key.replace(/\.[0-9]+/g, ''), hit: hit, children: entry }), allPrimitives && index < uniqueEntries.length - 1 && _jsx("span", { children: "," })] }, entry));
45
45
  }), omittedDuplicates && (_jsx(Grid, { item: true, display: "flex", alignItems: "center", children: _jsx(Tooltip, { title: t('duplicates.omitted'), children: _jsx(InfoOutlined, { sx: { fontSize: '20px', ml: 1 }, color: "disabled" }) }) }))] })] }));
46
46
  });
47
- const ObjectRenderer = memo(({ obj: obj, data, parentKey, indent = false }) => {
47
+ const ObjectRenderer = memo(({ hit, data, parentKey, indent = false }) => {
48
48
  const theme = useTheme();
49
49
  const entries = useMemo(() => {
50
50
  const unsorted = Object.entries(flatten(data, { safe: true })).map(([key, val]) => [key, val]);
@@ -56,10 +56,10 @@ const ObjectRenderer = memo(({ obj: obj, data, parentKey, indent = false }) => {
56
56
  }, [data]);
57
57
  const longestKey = useMemo(() => max(entries.map(([key]) => key.length)), [entries]);
58
58
  return (_jsxs(Stack, { direction: "row", overflow: "hidden", maxWidth: "100%", children: [indent && _jsx(Divider, { orientation: "vertical", flexItem: true, sx: { borderColor: 'primary.main', borderWidth: '2px' } }), _jsx(Stack, { flex: 1, ml: 1, maxWidth: "100%", children: entries
59
- .filter(([__, val]) => !isNull(val) && !isUndefined(val) && !isEmpty(val) && !isBoolean(val) && !isNumber(val))
59
+ .filter(([__, val]) => !isNull(val) && !isUndefined(val) && !isEmpty(val))
60
60
  .map(([key, val]) => {
61
61
  if (Array.isArray(val)) {
62
- return _jsx(ListRenderer, { obj: obj, maxKeyLength: longestKey, objKey: key, entries: val }, key);
62
+ return _jsx(ListRenderer, { hit: hit, maxKeyLength: longestKey, objKey: key, entries: val }, key);
63
63
  }
64
64
  return (_jsxs("code", { className: (parentKey ? `${parentKey}.${key}` : key).replace(/\./g, '_'), style: {
65
65
  display: 'grid',
@@ -75,14 +75,14 @@ const ObjectRenderer = memo(({ obj: obj, data, parentKey, indent = false }) => {
75
75
  paddingRight: theme.spacing(1),
76
76
  height: '100%',
77
77
  wordWrap: 'break-word'
78
- }, children: _jsx("code", { style: { maxWidth: '100%' }, children: key }) }), _jsx(Box, { display: "flex", alignItems: "start", children: _jsx(PluginTypography, { context: "details", component: "code", style: { maxWidth: '100%', font: 'inherit' }, value: val, field: (parentKey ? parentKey.concat('.', key) : key).replace(/\.[0-9]+/g, ''), obj: obj, children: val }) })] }, key));
78
+ }, children: _jsx("code", { style: { maxWidth: '100%' }, children: key }) }), _jsx(Box, { display: "flex", alignItems: "start", children: _jsx(PluginTypography, { context: "details", component: "code", style: { maxWidth: '100%', font: 'inherit' }, value: val, field: (parentKey ? parentKey.concat('.', key) : key).replace(/\.[0-9]+/g, ''), hit: hit, children: val }) })] }, key));
79
79
  }) })] }));
80
80
  });
81
- const Collapsible = memo(({ obj, title, data, query }) => {
81
+ const Collapsible = memo(({ hit, title, data, query }) => {
82
82
  const throttler = useMemo(() => new Throttler(400), []);
83
83
  const [scores, setScores] = useState([]);
84
84
  const [results, setResults] = useState({});
85
- const options = useMemo(() => Object.entries(data).map(([key, value]) => ({ key, value: value.toString() })), [data]);
85
+ const options = useMemo(() => Object.entries(data).map(([key, value]) => ({ key, value })), [data]);
86
86
  const keys = useMemo(() => options
87
87
  .flatMap(option => (isArray(option.value) ? Object.keys(flatten(option.value)) : []))
88
88
  .map(key => key.replace(/\d+/g, 'value'))
@@ -109,20 +109,20 @@ const Collapsible = memo(({ obj, title, data, query }) => {
109
109
  if (isEmpty(results)) {
110
110
  return null;
111
111
  }
112
- return (_jsxs(Accordion, { defaultExpanded: true, children: [_jsx(AccordionSummary, { expandIcon: _jsx(ArrowDropDown, {}), sx: { my: 0 }, children: _jsx(Typography, { children: title }) }), _jsx(AccordionDetails, { children: _jsx(Stack, { spacing: 0.5, justifyContent: "stretch", sx: styles, children: _jsx(ObjectRenderer, { obj: obj, showParentKey: true, data: results }) }) })] }));
112
+ return (_jsxs(Accordion, { defaultExpanded: true, children: [_jsx(AccordionSummary, { expandIcon: _jsx(ArrowDropDown, {}), children: _jsx(Typography, { children: title }) }), _jsx(AccordionDetails, { children: _jsx(Stack, { spacing: 1, justifyContent: "stretch", sx: styles, children: _jsx(ObjectRenderer, { hit: hit, showParentKey: true, data: results }) }) })] }));
113
113
  });
114
- const ObjectDetails = ({ obj }) => {
114
+ const HitDetails = ({ hit }) => {
115
115
  const { t } = useTranslation();
116
116
  const [query, setQuery] = useState('');
117
- const groups = useMemo(() => groupBy(Object.entries(flatten(obj ?? {}, { safe: true })).filter(([key, value]) => !key.startsWith('__') &&
117
+ const groups = useMemo(() => groupBy(Object.entries(flatten(hit ?? {}, { safe: true })).filter(([key, value]) => !key.startsWith('__') &&
118
118
  key.includes('.') &&
119
119
  ['howler', 'labels'].every(prefix => !key.startsWith(prefix)) &&
120
- (!isEmpty(value) || isNumber(value) || isBoolean(value))), ([key]) => key.split('.')[0]), [obj]);
120
+ !isEmpty(value)), ([key]) => key.split('.')[0]), [hit]);
121
121
  return (_jsxs(Stack, { spacing: 1, children: [_jsx(TextField, { value: query, onChange: event => setQuery(event.target.value), label: t('overview.search') }), Object.entries(groups).map(([section, entries]) => {
122
- return (_jsx(Collapsible, { obj: obj, query: query, title: section
122
+ return (_jsx(Collapsible, { hit: hit, query: query, title: section
123
123
  .split('_')
124
124
  .map(word => capitalize(word))
125
125
  .join(' '), data: Object.fromEntries(entries) }, section));
126
126
  })] }));
127
127
  };
128
- export default memo(ObjectDetails);
128
+ export default memo(HitDetails);
@@ -1,14 +1,18 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box, Divider, Typography } from '@mui/material';
3
3
  import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
4
+ import { useMyLocalStorageItem } from '@cccsaurora/howler-ui/components/hooks/useMyLocalStorage';
5
+ import { isNil } from 'lodash-es';
4
6
  import { createElement, memo, useEffect, useMemo, useState } from 'react';
5
7
  import { useTranslation } from 'react-i18next';
8
+ import { StorageKey } from '@cccsaurora/howler-ui/utils/constants';
6
9
  import { HitLayout } from './HitLayout';
7
10
  import DefaultOutline from './outlines/DefaultOutline';
8
- export const DEFAULT_FIELDS = ['howler.hash'];
11
+ export const DEFAULT_FIELDS = ['event.created', 'howler.id', 'howler.hash'];
9
12
  const HitOutline = ({ hit, layout }) => {
10
13
  const { t } = useTranslation();
11
14
  const { getMatchingTemplate } = useMatchers();
15
+ const [templateFieldCount] = useMyLocalStorageItem(StorageKey.TEMPLATE_FIELD_COUNT, null);
12
16
  const [template, setTemplate] = useState(null);
13
17
  useEffect(() => {
14
18
  getMatchingTemplate(hit).then(setTemplate);
@@ -19,7 +23,7 @@ const HitOutline = ({ hit, layout }) => {
19
23
  hit,
20
24
  layout,
21
25
  template,
22
- fields: layout === HitLayout.DENSE ? [...template.keys].slice(0, 3) : template.keys,
26
+ fields: !isNil(templateFieldCount) ? [...template.keys].slice(0, templateFieldCount) : template.keys,
23
27
  readonly: template.type === 'readonly'
24
28
  });
25
29
  }
@@ -30,7 +34,7 @@ const HitOutline = ({ hit, layout }) => {
30
34
  fields: DEFAULT_FIELDS
31
35
  });
32
36
  }
33
- }, [hit, layout, template]);
37
+ }, [hit, layout, template, templateFieldCount]);
34
38
  return (_jsxs(Box, { sx: { py: 1, width: '100%', pr: 2 }, children: [layout === HitLayout.COMFY && (_jsx(Typography, { variant: "body1", fontWeight: "bold", sx: { mb: 1 }, children: t('hit.details.title') })), layout !== HitLayout.DENSE && _jsx(Divider, { orientation: "horizontal", sx: { mb: 1 } }), outline] }));
35
39
  };
36
40
  export default memo(HitOutline);
@@ -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 PreviewProps = {
3
+ type QuickSearchProps = {
4
4
  hit: Hit;
5
- options?: AppSearchItemRendererOption<Hit>;
5
+ options: AppSearchItemRendererOption<Hit>;
6
6
  };
7
- declare const _default: import("react").NamedExoticComponent<PreviewProps>;
7
+ declare const _default: import("react").NamedExoticComponent<QuickSearchProps>;
8
8
  export default _default;
@@ -4,18 +4,12 @@ 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 HitPreview = ({ hit, options }) => {
7
+ const HitQuickSearch = ({ 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: {
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: {
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: {
19
13
  tooltip: {
20
14
  sx: {
21
15
  fontSize: 12,
@@ -23,7 +17,7 @@ const HitPreview = ({ hit, options }) => {
23
17
  color: theme.palette.getContrastText(theme.palette.background.paper)
24
18
  }
25
19
  }
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: {
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: {
27
21
  backgroundColor: providerColor,
28
22
  color: theme.palette.getContrastText(providerColor)
29
23
  }, 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: {
@@ -34,4 +28,4 @@ const HitPreview = ({ hit, options }) => {
34
28
  ? hit?.howler.assignment
35
29
  : t('app.drawer.hit.assignment.unassigned.name'), size: "small" }), _jsx(Chip, { label: hit.howler.status, size: "small", color: STATUS_COLORS[hit.howler.status] })] })] })] }));
36
30
  };
37
- export default memo(HitPreview);
31
+ export default memo(HitQuickSearch);
@@ -1,5 +1,5 @@
1
1
  import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
2
- import { type FC } from 'react';
2
+ import type { FC } from 'react';
3
3
  declare const HitRelated: FC<{
4
4
  hit: Hit;
5
5
  }>;
@@ -1,34 +1,7 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Box, Stack, Tab, Tabs, useTheme } from '@mui/material';
3
- import ObservableCard from '@cccsaurora/howler-ui/components/elements/observable/ObservableCard';
4
- import useRelatedRecords from '@cccsaurora/howler-ui/components/hooks/useRelatedRecords';
5
- import { groupBy } from 'lodash-es';
6
- import { useMemo, useState } from 'react';
7
- import { useTranslation } from 'react-i18next';
8
- import { Link } from 'react-router-dom';
9
- import { isCase, isHit, isObservable } from '@cccsaurora/howler-ui/utils/typeUtils';
10
- import CaseCard from '../case/CaseCard';
11
- import HitCard from './HitCard';
12
- import { HitLayout } from './HitLayout';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Grid } from '@mui/material';
13
3
  import RelatedLink from './related/RelatedLink';
14
4
  const HitRelated = ({ hit }) => {
15
- const theme = useTheme();
16
- const { t } = useTranslation();
17
- const related = useMemo(() => hit?.howler.related ?? [], [hit?.howler.related]);
18
- const records = useRelatedRecords(related, related.length > 0);
19
- const groups = groupBy(records, '__index');
20
- const hasLinks = (hit?.howler.links?.length ?? 0) > 0;
21
- const tabs = [
22
- hasLinks && 'links',
23
- groups.hit?.length > 0 && 'hit',
24
- groups.case?.length > 0 && 'case',
25
- groups.observable?.length > 0 && 'observable'
26
- ].filter(Boolean);
27
- const [activeTab, setActiveTab] = useState(false);
28
- const currentTab = activeTab !== false && tabs.includes(activeTab) ? activeTab : (tabs[0] ?? false);
29
- if (!hit) {
30
- return null;
31
- }
32
- return (_jsxs(Box, { sx: { borderTop: `thin solid ${theme.palette.divider}`, height: '100%', flex: 1, mr: 2, pb: 2 }, children: [_jsxs(Tabs, { value: currentTab, onChange: (_, v) => setActiveTab(v), variant: "scrollable", scrollButtons: "auto", children: [hasLinks && _jsx(Tab, { value: "links", label: t('hit.related.tab.links') }), groups.hit?.length > 0 && _jsx(Tab, { value: "hit", label: t('hit.related.tab.hit') }), groups.case?.length > 0 && _jsx(Tab, { value: "case", label: t('hit.related.tab.case') }), groups.observable?.length > 0 && _jsx(Tab, { value: "observable", label: t('hit.related.tab.observable') })] }), currentTab === 'links' && (_jsx(Box, { display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(200px, 1fr))", gap: 1, pt: 1, children: hit.howler.links.map(l => (_jsx(RelatedLink, { ...l }, l.title + l.href))) })), currentTab === 'hit' && (_jsx(Stack, { spacing: 1, pt: 1, children: records.filter(isHit).map(h => (_jsx(Link, { to: `/hits/${h.howler.id}`, target: "_blank", rel: "noopener noreferrer", style: { textDecoration: 'none' }, children: _jsx(HitCard, { id: h.howler.id, layout: HitLayout.NORMAL }) }, h.howler.id))) })), currentTab === 'case' && (_jsx(Stack, { spacing: 1, pt: 1, children: records.filter(isCase).map(c => (_jsx(Link, { to: `/cases/${c.case_id}`, target: "_blank", rel: "noopener noreferrer", style: { textDecoration: 'none' }, children: _jsx(CaseCard, { case: c }) }, c.case_id))) })), currentTab === 'observable' && (_jsx(Stack, { spacing: 1, pt: 1, children: records.filter(isObservable).map(o => (_jsx(Link, { to: `/observables/${o.howler.id}`, target: "_blank", rel: "noopener noreferrer", style: { textDecoration: 'none' }, children: _jsx(ObservableCard, { observable: o }) }, o.howler.id))) }))] }));
5
+ return (_jsx(Grid, { container: true, spacing: 1, pr: 2, children: hit?.howler.links?.map(l => (_jsx(Grid, { item: true, xs: 6, sm: 4, md: 3, children: _jsx(RelatedLink, { ...l }) }, l.title + l.href))) }));
33
6
  };
34
7
  export default HitRelated;
@@ -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, obj: 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, hit: hit, children: displayedData })] }, field));
45
45
  })] }));
46
46
  };
47
47
  export default memo(DefaultOutline);
@@ -51,7 +51,7 @@ const PivotLink = ({ pivot, hit, compact = false }) => {
51
51
  }
52
52
  }, [flatHit, pivot, handlebars, helpers]);
53
53
  if (href) {
54
- return (_jsx(RelatedLink, { title: pivot.label[i18n.language], href: href, compact: compact, icon: pivot.icon, target: "_blank" }));
54
+ return (_jsx(RelatedLink, { title: pivot.label[i18n.language], href: href, compact: compact, icon: pivot.icon, target: "_blank", rel: "noopener noreferrer" }));
55
55
  }
56
56
  // Hide a relatively useless console error, we'll show a UI component instead
57
57
  // eslint-disable-next-line no-console
@@ -5,5 +5,6 @@ declare const RelatedLink: React.FC<PropsWithChildren<{
5
5
  href?: string;
6
6
  compact?: boolean;
7
7
  target?: string;
8
+ rel?: string;
8
9
  }>>;
9
10
  export default RelatedLink;
@@ -4,7 +4,7 @@ import HowlerCard from '@cccsaurora/howler-ui/components/elements/display/Howler
4
4
  import React, {} from 'react';
5
5
  import { Link } from 'react-router-dom';
6
6
  import RelatedIcon from './RelatedIcon';
7
- const RelatedLink = ({ icon, title, href, target, compact = false, children }) => {
7
+ const RelatedLink = ({ icon, title, href, target, rel, compact = false, children }) => {
8
8
  return (_jsx(HowlerCard, { variant: compact ? 'outlined' : 'elevation', onClick: () => window.open(href, target), sx: [
9
9
  theme => ({
10
10
  cursor: 'pointer',
@@ -17,6 +17,6 @@ const RelatedLink = ({ icon, title, href, target, compact = false, children }) =
17
17
  '& a': { textDecoration: 'none', color: 'text.primary' }
18
18
  }),
19
19
  !compact && { border: 'thin solid', borderColor: 'transparent' }
20
- ], children: _jsxs(Stack, { direction: "row", p: compact ? 0.5 : 1, spacing: 1, alignItems: "center", children: [children || _jsx(RelatedIcon, { icon: icon, title: title, href: href, compact: compact }), _jsx(Typography, { component: Link, to: href, target: target, onClick: e => e.stopPropagation(), children: title ?? href })] }) }, href));
20
+ ], children: _jsxs(Stack, { direction: "row", p: compact ? 0.5 : 1, spacing: 1, alignItems: "center", children: [children || _jsx(RelatedIcon, { icon: icon, title: title, href: href, compact: compact }), _jsx(Typography, { component: Link, to: href, target: target, rel: rel, onClick: e => e.stopPropagation(), children: title ?? href })] }) }, href));
21
21
  };
22
22
  export default RelatedLink;
@@ -21,5 +21,5 @@ export const ViewTitle = ({ title, type, query, sort, span }) => {
21
21
  readonly: _jsx(Lock, { fontSize: "small" }),
22
22
  global: _jsx(Language, { fontSize: "small" }),
23
23
  personal: _jsx(Person, { fontSize: "small" })
24
- }[type] }), _jsx(Typography, { variant: "body1", children: t(title) })] }), _jsx(Typography, { variant: "caption", children: _jsx("code", { children: query }) }), (sort || span) && (_jsxs(Stack, { direction: "row", sx: { mt: 1 }, spacing: 1, children: [sort?.split(',').map(_sort => (_jsx(Chip, { size: "small", label: _sort.split(' ')[0], icon: _sort.endsWith('desc') ? _jsx(ArrowDownward, {}) : _jsx(ArrowUpward, {}) }, _sort.split(' ')[0]))), spanLabel && _jsx(Chip, { label: spanLabel })] }))] }));
24
+ }[type] }), _jsx(Typography, { variant: "body1", children: t(title) })] }), _jsx(Typography, { variant: "caption", children: _jsx("code", { children: query }) }), (sort || span) && (_jsxs(Stack, { direction: "row", sx: { mt: 1 }, spacing: 1, children: [sort?.split(',').map(_sort => (_jsx(Chip, { size: "small", label: _sort.split(' ')[0], icon: _sort.endsWith('desc') ? _jsx(ArrowDownward, {}) : _jsx(ArrowUpward, {}) }, _sort.split(' ')[0]))), spanLabel && _jsx(Chip, { size: "small", label: spanLabel })] }))] }));
25
25
  };
@@ -7,7 +7,7 @@ declare const useHitActions: (_hits: Hit | Hit[]) => {
7
7
  canAssess: boolean;
8
8
  loading: boolean;
9
9
  manage: (transition: string) => Promise<void>;
10
- assess: (assessment: string, skipRationale?: boolean, providedRationale?: any) => Promise<void>;
10
+ assess: (assessment: string, skipRationale?: boolean) => Promise<void>;
11
11
  vote: (v: string) => Promise<void>;
12
12
  selectedVote: string;
13
13
  };
@@ -90,9 +90,9 @@ const useHitActions = (_hits) => {
90
90
  }
91
91
  }
92
92
  }, [dispatchApi, hits, selectedVote, updateHit, user.email]);
93
- const assess = useCallback(async (assessment, skipRationale = false, providedRationale = null) => {
93
+ const assess = useCallback(async (assessment, skipRationale = false) => {
94
94
  const rationale = skipRationale
95
- ? (providedRationale ?? t('rationale.default', { assessment }))
95
+ ? t('rationale.default', { assessment })
96
96
  : await new Promise(res => {
97
97
  showModal(_jsx(RationaleModal, { hits: hits, onSubmit: _rationale => {
98
98
  res(_rationale);
@@ -1,9 +1,15 @@
1
+ import { useAppBreadcrumbs } from '@cccsaurora/howler-ui/commons/components/app/hooks';
1
2
  import { HitContext } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
2
3
  import { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
3
4
  import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
5
+ import useMySitemap from '@cccsaurora/howler-ui/components/hooks/useMySitemap';
4
6
  import { useCallback, useState } from 'react';
7
+ import { useNavigate } from 'react-router-dom';
5
8
  import { useContextSelector } from 'use-context-selector';
6
9
  const useHitSelection = () => {
10
+ const navigate = useNavigate();
11
+ const { setItems } = useAppBreadcrumbs();
12
+ const { routes } = useMySitemap();
7
13
  const response = useContextSelector(HitSearchContext, ctx => ctx.response);
8
14
  const selectedHits = useContextSelector(HitContext, ctx => ctx.selectedHits);
9
15
  const addHitToSelection = useContextSelector(HitContext, ctx => ctx.addHitToSelection);
@@ -41,15 +47,30 @@ const useHitSelection = () => {
41
47
  e.stopPropagation();
42
48
  return;
43
49
  }
44
- clearSelectedHits(hit.howler.id);
45
- setSelected(hit.howler.id);
50
+ if (hit.howler.is_bundle) {
51
+ const searchRoute = routes.find(_route => _route.path.startsWith(location.pathname.replace(/^(\/.*)\/.+/, '$1')));
52
+ const newBreadcrumb = {
53
+ ...searchRoute,
54
+ path: location.pathname + location.search
55
+ };
56
+ setItems([{ route: newBreadcrumb, matcher: null }]);
57
+ navigate(`/bundles/${hit.howler.id}?span=date.range.all&query=howler.id%3A*&offset=0`);
58
+ clearSelectedHits(hit.howler.id);
59
+ }
60
+ else {
61
+ clearSelectedHits(hit.howler.id);
62
+ setSelected(hit.howler.id);
63
+ }
46
64
  }, [
47
65
  addHitToSelection,
48
66
  clearSelectedHits,
49
67
  lastSelected,
68
+ navigate,
50
69
  removeHitFromSelection,
51
- response?.items,
70
+ response,
71
+ routes,
52
72
  selectedHits,
73
+ setItems,
53
74
  setSelected
54
75
  ]);
55
76
  return { lastSelected, setLastSelected, onClick };
@@ -0,0 +1,13 @@
1
+ declare const useLocalStorage: (prefix?: string) => {
2
+ get: <T>(key: string) => T;
3
+ set: (key: string, value: any) => void;
4
+ remove: (key: string, withPrefix?: boolean) => void;
5
+ has: (key: string) => boolean;
6
+ keys: () => string[];
7
+ items: () => {
8
+ key: string;
9
+ value: unknown;
10
+ }[];
11
+ clear: () => void;
12
+ };
13
+ export default useLocalStorage;
@@ -0,0 +1,53 @@
1
+ import { useCallback, useMemo } from 'react';
2
+ const useLocalStorage = (prefix) => {
3
+ // Build the name of the key.
4
+ // If a 'prefix' was specified, the 'key' will be appended to the 'prefix' automatically.
5
+ const _buildKey = useCallback((name) => (prefix ? `${prefix}.${name}` : name), [prefix]);
6
+ // Get an item from local storage.
7
+ // If a 'prefix' was specified, the 'key' will be appended to the 'prefix' automatically.
8
+ const get = useCallback((key) => {
9
+ try {
10
+ return JSON.parse(localStorage.getItem(_buildKey(key)));
11
+ }
12
+ catch (e) {
13
+ return null;
14
+ }
15
+ }, [_buildKey]);
16
+ // Set an item to local storage.
17
+ // If a 'prefix' was specified, the 'key' will be appended to the 'prefix' automatically.
18
+ const set = useCallback((key, value) => localStorage.setItem(_buildKey(key), JSON.stringify(value)), [_buildKey]);
19
+ // Remove an item from local storage.
20
+ // If a 'prefix' was specified, the 'key' will be appended to the 'prefix' automatically.
21
+ const remove = useCallback((key, withPrefix = false) => localStorage.removeItem(withPrefix ? key : _buildKey(key)), [_buildKey]);
22
+ // Indicates if the local storage has an item with the specified key.
23
+ // If a 'prefix' was specified, the 'key' will be appended to the 'prefix' automatically.
24
+ const has = useCallback((key) => get(key) !== null, [get]);
25
+ // Get all the keys in the local storage.
26
+ const keys = useCallback(() => Object.keys(localStorage), []);
27
+ // Get the local storage items {key: string, value: any}.
28
+ // If a 'prefix' key was specified, it will return the items that have a key starting with the prefix.
29
+ // If no 'prefix' was specified, it will return all items.
30
+ const items = useCallback(() => keys().map(k => ({ key: k, value: get(k) })), [get, keys]);
31
+ // Clear all local storage.
32
+ // If a 'prefix' key was specified, it will only clear/remove the items that start with that key.
33
+ // If no 'prefix' key was specified, it will clear/remove all of them.
34
+ const clear = useCallback(() => keys().forEach(key => {
35
+ if (prefix && key.startsWith(prefix)) {
36
+ remove(key, true);
37
+ }
38
+ else if (!prefix) {
39
+ remove(key);
40
+ }
41
+ }), [prefix, remove, keys]);
42
+ // Return memoized object to prevent unecessary renders.
43
+ return useMemo(() => ({
44
+ get,
45
+ set,
46
+ remove,
47
+ has,
48
+ keys,
49
+ items,
50
+ clear
51
+ }), [get, set, remove, has, keys, items, clear]);
52
+ };
53
+ export default useLocalStorage;