@cccsaurora/howler-ui 2.17.0-dev.617 → 2.18.0-dev.626
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.d.ts +0 -2
- package/api/index.js +2 -4
- package/api/search/index.d.ts +1 -2
- package/api/search/index.js +1 -2
- package/commons/components/leftnav/LeftNavDrawer.js +1 -1
- package/components/app/App.js +0 -14
- package/components/app/providers/FavouritesProvider.js +2 -2
- package/components/app/providers/HitSearchProvider.d.ts +1 -0
- package/components/app/providers/HitSearchProvider.js +11 -6
- package/components/app/providers/HitSearchProvider.test.js +32 -11
- package/components/app/providers/LocalStorageProvider.js +1 -1
- package/components/app/providers/ParameterProvider.d.ts +2 -9
- package/components/app/providers/ParameterProvider.js +240 -165
- package/components/app/providers/ParameterProvider.test.js +14 -307
- package/components/elements/EditRow.d.ts +4 -1
- package/components/elements/EditRow.js +4 -4
- package/components/elements/PluginTypography.d.ts +1 -2
- package/components/elements/PluginTypography.js +2 -3
- package/components/elements/UserList.d.ts +2 -5
- package/components/elements/UserList.js +5 -14
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/display/ChipPopper.d.ts +1 -1
- package/components/elements/display/ChipPopper.js +1 -1
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +0 -1
- package/components/elements/display/icons/BundleButton.d.ts +6 -0
- package/components/elements/display/icons/BundleButton.js +32 -0
- package/components/elements/hit/HitBanner.js +48 -28
- package/components/elements/hit/HitCard.js +1 -1
- package/components/elements/{ObjectDetails.js → hit/HitDetails.js} +17 -17
- package/components/elements/hit/HitOutline.js +7 -3
- package/components/elements/hit/{HitPreview.d.ts → HitQuickSearch.d.ts} +3 -3
- package/components/elements/hit/{HitPreview.js → HitQuickSearch.js} +4 -10
- package/components/elements/hit/HitRelated.d.ts +1 -1
- package/components/elements/hit/HitRelated.js +3 -30
- package/components/elements/hit/outlines/DefaultOutline.js +1 -1
- package/components/elements/hit/related/PivotLink.js +1 -1
- package/components/elements/hit/related/RelatedLink.d.ts +1 -0
- package/components/elements/hit/related/RelatedLink.js +2 -2
- package/components/elements/view/ViewTitle.js +1 -1
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +2 -2
- package/components/hooks/useHitSelection.js +24 -3
- package/components/hooks/useLocalStorage.d.ts +13 -0
- package/components/hooks/useLocalStorage.js +53 -0
- package/components/hooks/useLocalStorageItem.d.ts +18 -0
- package/components/hooks/useLocalStorageItem.js +78 -0
- package/components/hooks/useLocalStorageItem.test.d.ts +1 -0
- package/components/hooks/useLocalStorageItem.test.js +144 -0
- package/components/hooks/useMyLocalStorage.js +2 -2
- package/components/hooks/useMyPreferences.js +1 -10
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +1 -4
- package/components/hooks/useMyTheme.js +2 -9
- package/components/routes/action/view/ActionSearch.js +1 -1
- package/components/routes/advanced/QueryBuilder.js +1 -1
- package/components/routes/analytics/AnalyticDetails.js +2 -2
- package/components/routes/analytics/AnalyticSearch.js +1 -1
- package/components/routes/help/ApiDocumentation.js +1 -1
- package/components/routes/help/BundleDocumentation.d.ts +3 -0
- package/components/routes/help/BundleDocumentation.js +12 -0
- package/components/routes/help/HitDocumentation.js +3 -1
- package/components/routes/help/markdown/en/bundles.md.js +1 -0
- package/components/routes/help/markdown/fr/bundles.md.js +1 -0
- package/components/routes/hits/search/BundleParentMenu.d.ts +6 -0
- package/components/routes/hits/search/BundleParentMenu.js +32 -0
- package/components/routes/hits/search/HitContextMenu.js +2 -3
- package/components/routes/hits/search/InformationPane.d.ts +0 -1
- package/components/routes/hits/search/InformationPane.js +28 -6
- package/components/routes/hits/search/LayoutSettings.d.ts +3 -0
- package/components/routes/hits/search/LayoutSettings.js +18 -0
- package/components/routes/hits/search/QuerySettings.js +1 -2
- package/components/routes/hits/search/QuerySettings.test.js +9 -14
- package/components/routes/hits/search/SearchPane.js +37 -13
- package/components/routes/hits/search/ViewLink.js +1 -1
- package/components/routes/hits/search/grid/EnhancedCell.js +1 -1
- package/components/routes/hits/view/HitViewer.js +4 -3
- package/components/routes/home/AnalyticCard.d.ts +2 -3
- package/components/routes/home/AnalyticCard.js +2 -2
- package/components/routes/home/ViewCard.js +1 -1
- package/components/routes/home/ViewRefresh.d.ts +23 -0
- package/components/routes/home/ViewRefresh.js +67 -0
- package/components/routes/home/index.js +9 -46
- package/components/{elements/MarkdownEditor.js → routes/overviews/OverviewEditor.js} +3 -3
- package/components/routes/overviews/OverviewViewer.js +2 -2
- package/components/routes/settings/LocalSection.js +2 -1
- package/locales/en/translation.json +6 -42
- package/locales/fr/translation.json +4 -35
- package/models/WithMetadata.d.ts +1 -2
- package/models/entities/generated/{ThreatEnrichment.d.ts → Enrichment.d.ts} +1 -1
- package/models/entities/generated/Howler.d.ts +4 -0
- package/models/entities/generated/Rule.d.ts +10 -2
- package/models/entities/generated/Threat.d.ts +2 -2
- package/package.json +3 -18
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +1 -2
- package/utils/constants.d.ts +4 -3
- package/utils/constants.js +1 -0
- package/api/search/case.d.ts +0 -4
- package/api/search/case.js +0 -8
- package/api/v2/case/index.d.ts +0 -6
- package/api/v2/case/index.js +0 -18
- package/api/v2/index.d.ts +0 -4
- package/api/v2/index.js +0 -6
- package/api/v2/search/facet.d.ts +0 -3
- package/api/v2/search/facet.js +0 -12
- package/api/v2/search/index.d.ts +0 -5
- package/api/v2/search/index.js +0 -24
- package/components/elements/ObjectDetails.d.ts +0 -6
- package/components/elements/case/CaseCard.d.ts +0 -8
- package/components/elements/case/CaseCard.js +0 -39
- package/components/elements/case/CasePreview.d.ts +0 -6
- package/components/elements/case/CasePreview.js +0 -17
- package/components/elements/case/StatusIcon.d.ts +0 -5
- package/components/elements/case/StatusIcon.js +0 -13
- package/components/elements/hit/elements/AnalyticLink.d.ts +0 -8
- package/components/elements/hit/elements/AnalyticLink.js +0 -22
- package/components/elements/hit/related/RelatedRecords.js +0 -63
- package/components/elements/observable/ObservableCard.d.ts +0 -5
- package/components/elements/observable/ObservableCard.js +0 -7
- package/components/elements/observable/ObservablePreview.d.ts +0 -6
- package/components/elements/observable/ObservablePreview.js +0 -12
- package/components/hooks/useRelatedRecords.d.ts +0 -13
- package/components/hooks/useRelatedRecords.js +0 -32
- package/components/routes/cases/CaseViewer.d.ts +0 -2
- package/components/routes/cases/CaseViewer.js +0 -24
- package/components/routes/cases/Cases.d.ts +0 -2
- package/components/routes/cases/Cases.js +0 -101
- package/components/routes/cases/constants.d.ts +0 -5
- package/components/routes/cases/constants.js +0 -5
- package/components/routes/cases/detail/AlertPanel.d.ts +0 -6
- package/components/routes/cases/detail/AlertPanel.js +0 -32
- package/components/routes/cases/detail/CaseDashboard.d.ts +0 -7
- package/components/routes/cases/detail/CaseDashboard.js +0 -49
- package/components/routes/cases/detail/CaseDetails.d.ts +0 -6
- package/components/routes/cases/detail/CaseDetails.js +0 -61
- package/components/routes/cases/detail/CaseOverview.d.ts +0 -7
- package/components/routes/cases/detail/CaseOverview.js +0 -43
- package/components/routes/cases/detail/CaseSidebar.d.ts +0 -6
- package/components/routes/cases/detail/CaseSidebar.js +0 -36
- package/components/routes/cases/detail/CaseTask.d.ts +0 -11
- package/components/routes/cases/detail/CaseTask.js +0 -57
- package/components/routes/cases/detail/ItemPage.d.ts +0 -6
- package/components/routes/cases/detail/ItemPage.js +0 -93
- package/components/routes/cases/detail/RelatedCasePanel.d.ts +0 -6
- package/components/routes/cases/detail/RelatedCasePanel.js +0 -31
- package/components/routes/cases/detail/TaskPanel.d.ts +0 -7
- package/components/routes/cases/detail/TaskPanel.js +0 -52
- package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +0 -12
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +0 -19
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +0 -6
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +0 -27
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +0 -13
- package/components/routes/cases/detail/sidebar/CaseFolder.js +0 -134
- package/components/routes/cases/detail/sidebar/types.d.ts +0 -3
- package/components/routes/cases/detail/sidebar/utils.d.ts +0 -3
- package/components/routes/cases/detail/sidebar/utils.js +0 -25
- package/components/routes/cases/hooks/useCase.d.ts +0 -13
- package/components/routes/cases/hooks/useCase.js +0 -38
- package/components/routes/cases/modals/ResolveModal.d.ts +0 -7
- package/components/routes/cases/modals/ResolveModal.js +0 -59
- package/components/routes/hits/search/shared/IndexPicker.d.ts +0 -2
- package/components/routes/hits/search/shared/IndexPicker.js +0 -20
- package/components/routes/observables/ObservableViewer.d.ts +0 -7
- package/components/routes/observables/ObservableViewer.js +0 -27
- package/models/entities/generated/AttachmentsFile.d.ts +0 -12
- package/models/entities/generated/Case.d.ts +0 -28
- package/models/entities/generated/DestinationOriginal.d.ts +0 -19
- package/models/entities/generated/EmailAttachment.d.ts +0 -8
- package/models/entities/generated/EmailParent.d.ts +0 -19
- package/models/entities/generated/Enrichments.d.ts +0 -7
- package/models/entities/generated/EnrichmentsIndicator.d.ts +0 -21
- package/models/entities/generated/HttpResponse.d.ts +0 -11
- package/models/entities/generated/Item.d.ts +0 -9
- package/models/entities/generated/Observable.d.ts +0 -84
- package/models/entities/generated/ObservableCloud.d.ts +0 -20
- package/models/entities/generated/ObservableDestination.d.ts +0 -23
- package/models/entities/generated/ObservableEmail.d.ts +0 -30
- package/models/entities/generated/ObservableFile.d.ts +0 -36
- package/models/entities/generated/ObservableHowler.d.ts +0 -44
- package/models/entities/generated/ObservableHttp.d.ts +0 -11
- package/models/entities/generated/ObservableObserver.d.ts +0 -21
- package/models/entities/generated/ObservableOrganization.d.ts +0 -7
- package/models/entities/generated/ObservableProcess.d.ts +0 -34
- package/models/entities/generated/ObservableSource.d.ts +0 -23
- package/models/entities/generated/ObservableThreat.d.ts +0 -21
- package/models/entities/generated/ObservableTls.d.ts +0 -12
- package/models/entities/generated/ObserverIngress.d.ts +0 -9
- package/models/entities/generated/Task.d.ts +0 -10
- package/utils/typeUtils.d.ts +0 -7
- package/utils/typeUtils.js +0 -18
- /package/components/elements/hit/{related/RelatedRecords.d.ts → HitDetails.d.ts} +0 -0
- /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
|
-
|
|
27
|
-
if (!hit?.
|
|
28
|
-
return
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (!hit?.howler.analytic) {
|
|
30
|
+
return;
|
|
29
31
|
}
|
|
30
|
-
|
|
31
|
-
|
|
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(() =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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,
|
|
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: [
|
|
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" }))
|
|
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, {
|
|
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,
|
|
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 '
|
|
13
|
-
const ListRenderer = memo(({
|
|
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, {
|
|
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, ''),
|
|
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(({
|
|
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)
|
|
59
|
+
.filter(([__, val]) => !isNull(val) && !isUndefined(val) && !isEmpty(val))
|
|
60
60
|
.map(([key, val]) => {
|
|
61
61
|
if (Array.isArray(val)) {
|
|
62
|
-
return _jsx(ListRenderer, {
|
|
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, ''),
|
|
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(({
|
|
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
|
|
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, {}),
|
|
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
|
|
114
|
+
const HitDetails = ({ hit }) => {
|
|
115
115
|
const { t } = useTranslation();
|
|
116
116
|
const [query, setQuery] = useState('');
|
|
117
|
-
const groups = useMemo(() => groupBy(Object.entries(flatten(
|
|
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
|
-
|
|
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, {
|
|
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(
|
|
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:
|
|
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
|
|
3
|
+
type QuickSearchProps = {
|
|
4
4
|
hit: Hit;
|
|
5
|
-
options
|
|
5
|
+
options: AppSearchItemRendererOption<Hit>;
|
|
6
6
|
};
|
|
7
|
-
declare const _default: import("react").NamedExoticComponent<
|
|
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
|
|
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
|
|
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(
|
|
31
|
+
export default memo(HitQuickSearch);
|
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import {
|
|
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
|
-
|
|
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,
|
|
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
|
|
@@ -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
|
|
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
|
|
93
|
+
const assess = useCallback(async (assessment, skipRationale = false) => {
|
|
94
94
|
const rationale = skipRationale
|
|
95
|
-
?
|
|
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
|
-
|
|
45
|
-
|
|
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
|
|
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;
|