@cccsaurora/howler-ui 2.18.0-dev.683 → 2.18.0-dev.686
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.d.ts +2 -0
- package/api/index.js +4 -2
- package/api/search/case.d.ts +4 -0
- package/api/search/case.js +8 -0
- package/api/search/index.d.ts +2 -1
- package/api/search/index.js +2 -1
- package/api/v2/case/index.d.ts +6 -0
- package/api/v2/case/index.js +18 -0
- package/api/v2/index.d.ts +4 -0
- package/api/v2/index.js +6 -0
- package/api/v2/search/facet.d.ts +3 -0
- package/api/v2/search/facet.js +12 -0
- package/api/v2/search/index.d.ts +5 -0
- package/api/v2/search/index.js +24 -0
- package/commons/components/leftnav/LeftNavDrawer.js +1 -1
- package/components/app/App.js +34 -7
- package/components/app/hooks/useMatchers.js +2 -2
- package/components/app/hooks/useMatchers.test.js +22 -22
- package/components/app/hooks/useTitle.js +3 -3
- package/components/app/providers/FavouritesProvider.js +2 -2
- package/components/app/providers/ParameterProvider.d.ts +9 -2
- package/components/app/providers/ParameterProvider.js +165 -240
- package/components/app/providers/ParameterProvider.test.js +307 -14
- package/components/app/providers/RecordProvider.d.ts +23 -0
- package/components/app/providers/{HitProvider.js → RecordProvider.js} +41 -41
- package/components/app/providers/{HitSearchProvider.d.ts → RecordSearchProvider.d.ts} +6 -6
- package/components/app/providers/{HitSearchProvider.js → RecordSearchProvider.js} +12 -17
- package/components/app/providers/{HitSearchProvider.test.js → RecordSearchProvider.test.js} +51 -70
- package/components/elements/ContextMenu.d.ts +56 -0
- package/components/elements/ContextMenu.js +109 -0
- package/components/elements/ContextMenu.test.js +215 -0
- package/components/{routes/overviews/OverviewEditor.js → elements/MarkdownEditor.js} +3 -3
- package/components/elements/ObjectDetails.d.ts +6 -0
- package/components/elements/{hit/HitDetails.js → ObjectDetails.js} +17 -17
- package/components/elements/PluginTypography.d.ts +2 -1
- package/components/elements/PluginTypography.js +3 -2
- package/components/elements/UserList.d.ts +5 -2
- package/components/elements/UserList.js +14 -5
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/case/CaseCard.d.ts +8 -0
- package/components/elements/case/CaseCard.js +39 -0
- package/components/elements/case/CasePreview.d.ts +6 -0
- package/components/elements/case/CasePreview.js +17 -0
- package/components/elements/case/StatusIcon.d.ts +5 -0
- package/components/elements/case/StatusIcon.js +13 -0
- package/components/elements/display/ChipPopper.d.ts +1 -1
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +1 -0
- package/components/elements/hit/HitActions.js +4 -4
- package/components/elements/hit/HitBanner.js +28 -48
- package/components/elements/hit/HitCard.js +5 -5
- package/components/elements/hit/HitLabels.js +2 -2
- package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
- package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +10 -4
- package/components/elements/hit/HitSummary.d.ts +2 -1
- package/components/elements/hit/HitSummary.js +6 -5
- package/components/elements/hit/aggregate/HitGraph.js +8 -8
- package/components/elements/hit/elements/AnalyticLink.d.ts +8 -0
- package/components/elements/hit/elements/AnalyticLink.js +22 -0
- package/components/elements/hit/outlines/DefaultOutline.js +1 -1
- package/components/elements/hit/related/RelatedRecords.js +63 -0
- package/components/elements/observable/ObservableCard.d.ts +6 -0
- package/components/elements/observable/ObservableCard.js +23 -0
- package/components/elements/observable/ObservablePreview.d.ts +6 -0
- package/components/elements/observable/ObservablePreview.js +12 -0
- package/components/elements/{hit/HitComments.d.ts → record/RecordComments.d.ts} +5 -4
- package/components/elements/{hit/HitComments.js → record/RecordComments.js} +29 -28
- package/components/{routes/hits/search/HitContextMenu.d.ts → elements/record/RecordContextMenu.d.ts} +3 -3
- package/components/elements/record/RecordContextMenu.js +235 -0
- package/components/elements/record/RecordContextMenu.test.d.ts +1 -0
- package/components/{routes/hits/search/HitContextMenu.test.js → elements/record/RecordContextMenu.test.js} +39 -39
- package/components/elements/record/RecordRelated.d.ts +7 -0
- package/components/elements/record/RecordRelated.js +34 -0
- package/components/elements/{hit/HitWorklog.d.ts → record/RecordWorklog.d.ts} +4 -3
- package/components/elements/{hit/HitWorklog.js → record/RecordWorklog.js} +15 -13
- package/components/elements/view/ViewTitle.d.ts +1 -0
- package/components/elements/view/ViewTitle.js +9 -2
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +4 -4
- package/components/hooks/useMyPreferences.js +10 -1
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +4 -1
- package/components/hooks/useMyTheme.js +9 -2
- package/components/hooks/useParamState.test.js +3 -4
- package/components/hooks/{useHitSelection.d.ts → useRecordSelection.d.ts} +2 -2
- package/components/hooks/{useHitSelection.js → useRecordSelection.js} +12 -33
- package/components/hooks/useRelatedRecords.d.ts +13 -0
- package/components/hooks/useRelatedRecords.js +32 -0
- package/components/routes/action/edit/ActionEditor.js +2 -2
- package/components/routes/action/view/ActionSearch.js +1 -1
- package/components/routes/advanced/QueryBuilder.js +1 -1
- package/components/routes/advanced/QueryEditor.js +3 -3
- package/components/routes/advanced/historyCompletionProvider.js +3 -3
- package/components/routes/analytics/AnalyticDetails.js +2 -2
- package/components/routes/analytics/AnalyticSearch.js +1 -1
- package/components/routes/cases/CaseViewer.d.ts +2 -0
- package/components/routes/cases/CaseViewer.js +22 -0
- package/components/routes/cases/Cases.d.ts +2 -0
- package/components/routes/cases/Cases.js +101 -0
- package/components/routes/cases/constants.d.ts +5 -0
- package/components/routes/cases/constants.js +5 -0
- package/components/routes/cases/detail/AlertPanel.d.ts +6 -0
- package/components/routes/cases/detail/AlertPanel.js +33 -0
- package/components/routes/cases/detail/CaseAssets.d.ts +12 -0
- package/components/routes/cases/detail/CaseAssets.js +101 -0
- package/components/routes/cases/detail/CaseAssets.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseAssets.test.js +163 -0
- package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
- package/components/routes/cases/detail/CaseDashboard.js +51 -0
- package/components/routes/cases/detail/CaseDetails.d.ts +6 -0
- package/components/routes/cases/detail/CaseDetails.js +61 -0
- package/components/routes/cases/detail/CaseOverview.d.ts +7 -0
- package/components/routes/cases/detail/CaseOverview.js +43 -0
- package/components/routes/cases/detail/CaseSidebar.d.ts +6 -0
- package/components/routes/cases/detail/CaseSidebar.js +61 -0
- package/components/routes/cases/detail/CaseTask.d.ts +11 -0
- package/components/routes/cases/detail/CaseTask.js +57 -0
- package/components/routes/cases/detail/ItemPage.d.ts +6 -0
- package/components/routes/cases/detail/ItemPage.js +99 -0
- package/components/routes/cases/detail/RelatedCasePanel.d.ts +6 -0
- package/components/routes/cases/detail/RelatedCasePanel.js +31 -0
- package/components/routes/cases/detail/TaskPanel.d.ts +7 -0
- package/components/routes/cases/detail/TaskPanel.js +52 -0
- package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +12 -0
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +19 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +6 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +27 -0
- package/components/routes/cases/detail/assets/Asset.d.ts +14 -0
- package/components/routes/cases/detail/assets/Asset.js +12 -0
- package/components/routes/cases/detail/assets/Asset.test.d.ts +1 -0
- package/components/routes/cases/detail/assets/Asset.test.js +72 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +13 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.js +131 -0
- package/components/routes/cases/detail/sidebar/types.d.ts +3 -0
- package/components/routes/cases/detail/sidebar/utils.d.ts +3 -0
- package/components/routes/cases/detail/sidebar/utils.js +25 -0
- package/components/routes/cases/hooks/useCase.d.ts +13 -0
- package/components/routes/cases/hooks/useCase.js +38 -0
- package/components/routes/cases/modals/ResolveModal.d.ts +7 -0
- package/components/routes/cases/modals/ResolveModal.js +59 -0
- package/components/routes/dossiers/DossierEditor.js +2 -2
- package/components/routes/dossiers/DossierEditor.test.js +1 -1
- package/components/routes/help/ApiDocumentation.js +1 -1
- package/components/routes/help/HitBannerDocumentation.js +1 -0
- package/components/routes/help/HitDocumentation.js +1 -3
- package/components/routes/hits/search/InformationPane.d.ts +1 -0
- package/components/routes/hits/search/InformationPane.js +47 -60
- package/components/routes/hits/search/LayoutSettings.js +3 -3
- package/components/routes/hits/search/QuerySettings.js +2 -1
- package/components/routes/hits/search/QuerySettings.test.js +14 -9
- package/components/routes/hits/search/{HitBrowser.js → RecordBrowser.js} +9 -9
- package/components/routes/hits/search/{HitQuery.d.ts → RecordQuery.d.ts} +2 -2
- package/components/routes/hits/search/{HitQuery.js → RecordQuery.js} +6 -6
- package/components/routes/hits/search/SearchPane.js +26 -49
- package/components/routes/hits/search/ViewLink.js +3 -3
- package/components/routes/hits/search/ViewLink.test.js +8 -8
- package/components/routes/hits/search/grid/AddColumnModal.js +5 -4
- package/components/routes/hits/search/grid/EnhancedCell.d.ts +2 -1
- package/components/routes/hits/search/grid/EnhancedCell.js +2 -2
- package/components/routes/hits/search/grid/HitGrid.js +20 -18
- package/components/routes/hits/search/grid/{HitRow.d.ts → RecordRow.d.ts} +3 -2
- package/components/routes/hits/search/grid/{HitRow.js → RecordRow.js} +10 -8
- package/components/routes/hits/search/shared/IndexPicker.d.ts +2 -0
- package/components/routes/hits/search/shared/IndexPicker.js +20 -0
- package/components/routes/hits/view/HitViewer.js +12 -13
- package/components/routes/home/ViewCard.js +47 -41
- package/components/routes/observables/ObservableViewer.d.ts +7 -0
- package/components/routes/observables/ObservableViewer.js +27 -0
- package/components/routes/overviews/OverviewViewer.js +2 -2
- package/components/routes/views/ViewComposer.js +46 -19
- package/locales/en/translation.json +65 -3
- package/locales/fr/translation.json +63 -3
- package/models/WithMetadata.d.ts +2 -1
- package/models/entities/generated/AttachmentsFile.d.ts +12 -0
- package/models/entities/generated/Case.d.ts +28 -0
- package/models/entities/generated/DestinationOriginal.d.ts +19 -0
- package/models/entities/generated/EmailAttachment.d.ts +8 -0
- package/models/entities/generated/EmailParent.d.ts +19 -0
- package/models/entities/generated/Enrichments.d.ts +7 -0
- package/models/entities/generated/EnrichmentsIndicator.d.ts +21 -0
- package/models/entities/generated/Hit.d.ts +1 -0
- package/models/entities/generated/Howler.d.ts +0 -4
- package/models/entities/generated/HttpResponse.d.ts +11 -0
- package/models/entities/generated/Item.d.ts +9 -0
- package/models/entities/generated/Observable.d.ts +85 -0
- package/models/entities/generated/ObservableCloud.d.ts +20 -0
- package/models/entities/generated/ObservableDestination.d.ts +23 -0
- package/models/entities/generated/ObservableEmail.d.ts +30 -0
- package/models/entities/generated/ObservableFile.d.ts +36 -0
- package/models/entities/generated/ObservableHowler.d.ts +43 -0
- package/models/entities/generated/ObservableHttp.d.ts +11 -0
- package/models/entities/generated/ObservableObserver.d.ts +21 -0
- package/models/entities/generated/ObservableOrganization.d.ts +7 -0
- package/models/entities/generated/ObservableProcess.d.ts +34 -0
- package/models/entities/generated/ObservableSource.d.ts +23 -0
- package/models/entities/generated/ObservableThreat.d.ts +21 -0
- package/models/entities/generated/ObservableTls.d.ts +12 -0
- package/models/entities/generated/ObserverIngress.d.ts +9 -0
- package/models/entities/generated/Rule.d.ts +2 -10
- package/models/entities/generated/Task.d.ts +10 -0
- package/models/entities/generated/Threat.d.ts +2 -2
- package/models/entities/generated/{Enrichment.d.ts → ThreatEnrichment.d.ts} +1 -1
- package/models/entities/generated/View.d.ts +1 -0
- package/package.json +19 -2
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +2 -1
- package/tests/utils.d.ts +2 -0
- package/tests/utils.js +8 -0
- package/utils/constants.d.ts +3 -3
- package/utils/hitFunctions.d.ts +2 -1
- package/utils/hitFunctions.js +4 -4
- package/utils/typeUtils.d.ts +7 -0
- package/utils/typeUtils.js +27 -0
- package/utils/viewUtils.js +3 -0
- package/components/app/providers/HitProvider.d.ts +0 -22
- package/components/elements/display/icons/BundleButton.d.ts +0 -6
- package/components/elements/display/icons/BundleButton.js +0 -32
- package/components/elements/hit/HitRelated.d.ts +0 -6
- package/components/elements/hit/HitRelated.js +0 -7
- package/components/routes/help/BundleDocumentation.d.ts +0 -3
- package/components/routes/help/BundleDocumentation.js +0 -12
- package/components/routes/help/markdown/en/bundles.md.js +0 -1
- package/components/routes/help/markdown/fr/bundles.md.js +0 -1
- package/components/routes/hits/search/BundleParentMenu.d.ts +0 -6
- package/components/routes/hits/search/BundleParentMenu.js +0 -32
- package/components/routes/hits/search/BundleScroller.d.ts +0 -2
- package/components/routes/hits/search/BundleScroller.js +0 -6
- package/components/routes/hits/search/HitContextMenu.js +0 -227
- /package/components/app/providers/{HitSearchProvider.test.d.ts → RecordSearchProvider.test.d.ts} +0 -0
- /package/components/{routes/hits/search/HitContextMenu.test.d.ts → elements/ContextMenu.test.d.ts} +0 -0
- /package/components/{routes/overviews/OverviewEditor.d.ts → elements/MarkdownEditor.d.ts} +0 -0
- /package/components/elements/hit/{HitDetails.d.ts → related/RelatedRecords.d.ts} +0 -0
- /package/components/routes/hits/search/{HitBrowser.d.ts → RecordBrowser.d.ts} +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Add } from '@mui/icons-material';
|
|
3
|
+
import { Divider, Skeleton, Stack, Typography } from '@mui/material';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import CaseTask from './CaseTask';
|
|
7
|
+
const TaskPanel = ({ case: _case, updateCase }) => {
|
|
8
|
+
const { t } = useTranslation();
|
|
9
|
+
const [addingTask, setAddingTask] = useState(false);
|
|
10
|
+
const onEdit = (task) => async (newTask) => {
|
|
11
|
+
if (task) {
|
|
12
|
+
await updateCase({
|
|
13
|
+
tasks: _case.tasks.map(_task => {
|
|
14
|
+
if (_task.id !== task.id) {
|
|
15
|
+
return _task;
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
..._task,
|
|
19
|
+
...newTask
|
|
20
|
+
};
|
|
21
|
+
})
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
await updateCase({
|
|
26
|
+
tasks: [..._case.tasks, newTask]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
if (!_case) {
|
|
31
|
+
return _jsx(Skeleton, { height: 240 });
|
|
32
|
+
}
|
|
33
|
+
return (_jsxs(Stack, { spacing: 1, children: [_jsx(Typography, { flex: 1, variant: "h4", children: t('page.cases.dashboard.tasks') }), _jsx(Divider, {}), _case.tasks.map(task => (_jsx(CaseTask, { task: task, paths: _case.items.map(item => item.path), onEdit: onEdit(task), onDelete: () => updateCase({ tasks: _case.tasks.filter(_task => _task.id !== task.id) }) }, task.id))), addingTask && (_jsx(CaseTask, { newTask: true, paths: _case.items.map(item => item.path), onEdit: async (task) => {
|
|
34
|
+
await onEdit()(task);
|
|
35
|
+
setAddingTask(false);
|
|
36
|
+
}, onDelete: async () => setAddingTask(false) })), _jsxs(Stack, { onClick: () => setAddingTask(true), direction: "row", spacing: 2, sx: theme => ({
|
|
37
|
+
borderStyle: 'dashed',
|
|
38
|
+
borderColor: theme.palette.text.secondary,
|
|
39
|
+
borderWidth: '0.15rem',
|
|
40
|
+
borderRadius: '0.15rem',
|
|
41
|
+
opacity: 0.3,
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
padding: 1,
|
|
45
|
+
transition: theme.transitions.create('opacity'),
|
|
46
|
+
'&:hover': {
|
|
47
|
+
opacity: 1,
|
|
48
|
+
cursor: 'pointer'
|
|
49
|
+
}
|
|
50
|
+
}), children: [_jsx(Add, {}), _jsx(Typography, { children: t('page.cases.dashboard.tasks.add') })] })] }));
|
|
51
|
+
};
|
|
52
|
+
export default TaskPanel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
|
|
2
|
+
import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
|
|
3
|
+
import { type FC } from 'react';
|
|
4
|
+
declare const CaseAggregate: FC<{
|
|
5
|
+
icon?: string;
|
|
6
|
+
iconColor?: string;
|
|
7
|
+
field?: string;
|
|
8
|
+
records?: Partial<Hit | Observable>[];
|
|
9
|
+
title?: string;
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
}>;
|
|
12
|
+
export default CaseAggregate;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Icon } from '@iconify/react';
|
|
3
|
+
import { Card, CardContent, Skeleton, Stack, styled, Tooltip, tooltipClasses, Typography, useTheme } from '@mui/material';
|
|
4
|
+
import { get, isEmpty, uniq } from 'lodash-es';
|
|
5
|
+
import {} from 'react';
|
|
6
|
+
const NoMaxWidthTooltip = styled(({ className, ...props }) => (_jsx(Tooltip, { ...props, classes: { popper: className } })))({
|
|
7
|
+
[`& .${tooltipClasses.tooltip}`]: {
|
|
8
|
+
maxWidth: 'none'
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const CaseAggregate = ({ icon, iconColor, field, records, title, subtitle }) => {
|
|
12
|
+
const theme = useTheme();
|
|
13
|
+
if (!title && (!records || !field)) {
|
|
14
|
+
return _jsx(Skeleton, { height: 120 });
|
|
15
|
+
}
|
|
16
|
+
const values = uniq(records?.map(_record => get(_record, field)).flat());
|
|
17
|
+
return (_jsx(Card, { sx: { height: '100%' }, children: _jsx(CardContent, { children: _jsxs(Stack, { alignItems: "center", spacing: 1, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [icon && _jsx(Icon, { fontSize: "96px", icon: icon, color: iconColor || theme.palette.grey[700] }), _jsx(NoMaxWidthTooltip, { title: !isEmpty(values) && (_jsx(Stack, { spacing: 0.5, children: values.map(value => (_jsx("span", { children: value }, value))) })), children: _jsxs(Typography, { variant: "h3", children: [values.length, !isEmpty(values) && !!title && ' - ', title] }) })] }), _jsx(Typography, { color: "textSecondary", children: subtitle })] }) }) }));
|
|
18
|
+
};
|
|
19
|
+
export default CaseAggregate;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Chip, Grid, Skeleton } from '@mui/material';
|
|
3
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
4
|
+
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
5
|
+
import { uniq } from 'lodash-es';
|
|
6
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
7
|
+
import useCase from '../../hooks/useCase';
|
|
8
|
+
const SourceAggregate = ({ case: providedCase }) => {
|
|
9
|
+
const { dispatchApi } = useMyApi();
|
|
10
|
+
const { case: _case } = useCase({ case: providedCase });
|
|
11
|
+
const [analytics, setAnalytics] = useState([]);
|
|
12
|
+
const hitIds = useMemo(() => _case?.items.filter(item => item.type === 'hit').map(item => item.id), [_case?.items]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
dispatchApi(api.v2.search.post('hit', { query: `howler.id:(${hitIds.join(' OR ')})`, fl: 'howler.analytic' }))
|
|
15
|
+
.then(response => response?.items.map(hit => hit.howler.analytic) ?? [])
|
|
16
|
+
.then(_analytics => setAnalytics(uniq(_analytics)));
|
|
17
|
+
api.v2.search.facet.post(['hit', 'observable'], {
|
|
18
|
+
query: `howler.id:(${hitIds.join(' OR ')})`,
|
|
19
|
+
fields: ['howler.analytic']
|
|
20
|
+
});
|
|
21
|
+
}, [dispatchApi, hitIds]);
|
|
22
|
+
if (!_case) {
|
|
23
|
+
return _jsx(Skeleton, { height: 12, variant: "rounded" });
|
|
24
|
+
}
|
|
25
|
+
return (_jsx(Grid, { container: true, spacing: 1, children: analytics.map(_analytic => (_jsx(Grid, { item: true, children: _jsx(Chip, { size: "small", label: _analytic }) }, _analytic))) }));
|
|
26
|
+
};
|
|
27
|
+
export default SourceAggregate;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Case } from '@cccsaurora/howler-ui/models/entities/generated/Case';
|
|
2
|
+
import type { FC } from 'react';
|
|
3
|
+
export type AssetType = 'hash' | 'hosts' | 'ip' | 'user' | 'ids' | 'id' | 'uri' | 'signature';
|
|
4
|
+
export interface AssetEntry {
|
|
5
|
+
type: AssetType;
|
|
6
|
+
value: string;
|
|
7
|
+
/** IDs of the hits/observables this asset was seen in */
|
|
8
|
+
seenIn: string[];
|
|
9
|
+
}
|
|
10
|
+
declare const Asset: FC<{
|
|
11
|
+
asset: AssetEntry;
|
|
12
|
+
case: Case;
|
|
13
|
+
}>;
|
|
14
|
+
export default Asset;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Card, CardContent, Chip, Stack, Typography } from '@mui/material';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
4
|
+
import { Link } from 'react-router-dom';
|
|
5
|
+
const Asset = ({ asset, case: _case }) => {
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
return (_jsx(Card, { sx: { height: '100%' }, children: _jsx(CardContent, { children: _jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [_jsx(Chip, { size: "small", label: t(`page.cases.assets.type.${asset.type}`), color: "primary", variant: "outlined" }), _jsx(Typography, { variant: "body2", sx: { wordBreak: 'break-all', fontFamily: 'monospace' }, children: asset.value })] }), asset.seenIn.length > 0 && (_jsxs(Stack, { spacing: 0.5, children: [_jsx(Typography, { variant: "caption", color: "text.secondary", children: t('page.cases.assets.seen_in') }), _jsx(Stack, { direction: "row", flexWrap: "wrap", gap: 0.5, children: asset.seenIn.map(id => {
|
|
8
|
+
const entry = _case.items.find(item => item.id === id);
|
|
9
|
+
return (_jsx(Chip, { clickable: true, size: "small", label: entry.path, variant: "outlined", component: Link, to: `/cases/${_case.case_id}/${entry.path}` }, id));
|
|
10
|
+
}) })] }))] }) }) }));
|
|
11
|
+
};
|
|
12
|
+
export default Asset;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
5
|
+
import { createMockCase } from '@cccsaurora/howler-ui/tests/utils';
|
|
6
|
+
import { describe, expect, it } from 'vitest';
|
|
7
|
+
import Asset, {} from './Asset';
|
|
8
|
+
const makeAsset = (overrides = {}) => ({
|
|
9
|
+
type: 'ip',
|
|
10
|
+
value: '192.168.1.1',
|
|
11
|
+
seenIn: [],
|
|
12
|
+
...overrides
|
|
13
|
+
});
|
|
14
|
+
describe('Asset', () => {
|
|
15
|
+
describe('type chip', () => {
|
|
16
|
+
it('renders the correct label for each type', () => {
|
|
17
|
+
const cases = ['hash', 'hosts', 'ip', 'user', 'ids', 'id', 'uri', 'signature'];
|
|
18
|
+
for (const type of cases) {
|
|
19
|
+
const { unmount } = render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ type, value: 'x' }), case: createMockCase() }) }));
|
|
20
|
+
expect(screen.getByText(`page.cases.assets.type.${type}`)).toBeTruthy();
|
|
21
|
+
unmount();
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('value display', () => {
|
|
26
|
+
it('renders the asset value', () => {
|
|
27
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ value: '10.0.0.1' }), case: createMockCase() }) }));
|
|
28
|
+
expect(screen.getByText('10.0.0.1')).toBeTruthy();
|
|
29
|
+
});
|
|
30
|
+
it('renders long hash values without truncation', () => {
|
|
31
|
+
const hash = 'a'.repeat(64);
|
|
32
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ type: 'hash', value: hash }), case: createMockCase() }) }));
|
|
33
|
+
expect(screen.getByText(hash)).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
describe('seen-in chips', () => {
|
|
37
|
+
it('renders nothing when seenIn is empty', () => {
|
|
38
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ seenIn: [] }), case: createMockCase() }) }));
|
|
39
|
+
expect(screen.queryByText('page.cases.assets.seen_in')).toBeNull();
|
|
40
|
+
});
|
|
41
|
+
it('renders "Seen in" label when seenIn has entries', () => {
|
|
42
|
+
const _case = createMockCase({
|
|
43
|
+
items: [{ id: 'hit-001', path: 'alerts/test-analytic (hit-001)', type: 'hit', value: 'hit-001' }]
|
|
44
|
+
});
|
|
45
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ seenIn: ['hit-001'] }), case: _case }) }));
|
|
46
|
+
expect(screen.getByText('page.cases.assets.seen_in')).toBeTruthy();
|
|
47
|
+
});
|
|
48
|
+
it('renders a chip labelled with entry.path for each seenIn id', () => {
|
|
49
|
+
const _case = createMockCase({
|
|
50
|
+
items: [
|
|
51
|
+
{ id: 'hit-001', path: 'alerts/my-analytic (hit-001)', type: 'hit', value: 'hit-001' },
|
|
52
|
+
{ id: 'obs-002', path: 'observables/obs-002', type: 'observable', value: 'obs-002' },
|
|
53
|
+
{ id: 'hit-003', path: 'alerts/other-analytic (hit-003)', type: 'hit', value: 'hit-003' }
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ seenIn: ['hit-001', 'obs-002', 'hit-003'] }), case: _case }) }));
|
|
57
|
+
expect(screen.getByText('alerts/my-analytic (hit-001)')).toBeTruthy();
|
|
58
|
+
expect(screen.getByText('observables/obs-002')).toBeTruthy();
|
|
59
|
+
expect(screen.getByText('alerts/other-analytic (hit-003)')).toBeTruthy();
|
|
60
|
+
});
|
|
61
|
+
it('links each chip to /cases/:case_id/:path', () => {
|
|
62
|
+
const _case = createMockCase({
|
|
63
|
+
case_id: 'case-abc',
|
|
64
|
+
items: [{ id: 'hit-001', path: 'alerts/my-analytic (hit-001)', type: 'hit', value: 'hit-001' }]
|
|
65
|
+
});
|
|
66
|
+
render(_jsx(MemoryRouter, { children: _jsx(Asset, { asset: makeAsset({ seenIn: ['hit-001'] }), case: _case }) }));
|
|
67
|
+
const link = screen.getByText('alerts/my-analytic (hit-001)').closest('a');
|
|
68
|
+
expect(link).not.toBeNull();
|
|
69
|
+
expect(link?.getAttribute('href')).toBe('/cases/case-abc/alerts/my-analytic (hit-001)');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Case } from '@cccsaurora/howler-ui/models/entities/generated/Case';
|
|
2
|
+
import { type FC } from 'react';
|
|
3
|
+
import type { Tree } from './types';
|
|
4
|
+
interface CaseFolderProps {
|
|
5
|
+
case: Case;
|
|
6
|
+
folder?: Tree;
|
|
7
|
+
name?: string;
|
|
8
|
+
step?: number;
|
|
9
|
+
rootCaseId?: string;
|
|
10
|
+
pathPrefix?: string;
|
|
11
|
+
}
|
|
12
|
+
declare const CaseFolder: FC<CaseFolderProps>;
|
|
13
|
+
export default CaseFolder;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Article, BookRounded, CheckCircle, ChevronRight, Folder as FolderIcon, Lightbulb, Link as LinkIcon, TableChart, Visibility } from '@mui/icons-material';
|
|
3
|
+
import { alpha, Skeleton, Stack, Typography, useTheme } from '@mui/material';
|
|
4
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
5
|
+
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
6
|
+
import { omit } from 'lodash-es';
|
|
7
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
9
|
+
import { ESCALATION_COLORS } from '@cccsaurora/howler-ui/utils/constants';
|
|
10
|
+
import { buildTree } from './utils';
|
|
11
|
+
// Static map: item type → MUI icon component (avoids re-creating closures on each render)
|
|
12
|
+
const ICON_FOR_TYPE = {
|
|
13
|
+
case: BookRounded,
|
|
14
|
+
observable: Visibility,
|
|
15
|
+
hit: CheckCircle,
|
|
16
|
+
table: TableChart,
|
|
17
|
+
lead: Lightbulb,
|
|
18
|
+
reference: LinkIcon
|
|
19
|
+
};
|
|
20
|
+
const CaseFolder = ({ case: _case, folder, name, step = -1, rootCaseId, pathPrefix = '' }) => {
|
|
21
|
+
const theme = useTheme();
|
|
22
|
+
const location = useLocation();
|
|
23
|
+
const { dispatchApi } = useMyApi();
|
|
24
|
+
const [open, setOpen] = useState(true);
|
|
25
|
+
const [caseStates, setCaseStates] = useState({});
|
|
26
|
+
const [hitMetadata, setHitMetadata] = useState({});
|
|
27
|
+
const tree = useMemo(() => folder || buildTree(_case?.items), [folder, _case?.items]);
|
|
28
|
+
const currentRootCaseId = rootCaseId || _case?.case_id;
|
|
29
|
+
const hitIds = useMemo(() => tree.leaves
|
|
30
|
+
?.filter(l => l.type?.toLowerCase() === 'hit')
|
|
31
|
+
.map(l => l.id)
|
|
32
|
+
.filter(Boolean) ?? [], [tree.leaves]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (hitIds.length < 1) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
dispatchApi(api.search.hit.post({ query: `howler.id:(${hitIds.join(' OR ')})` }), { throwError: false }).then(result => {
|
|
38
|
+
if ((result?.items?.length ?? 0) < 1)
|
|
39
|
+
return;
|
|
40
|
+
setHitMetadata(Object.fromEntries(result.items.map(hit => [hit.howler.id, hit.howler])));
|
|
41
|
+
});
|
|
42
|
+
}, [hitIds, dispatchApi]);
|
|
43
|
+
// Returns the MUI colour token for the item's escalation, or undefined if none.
|
|
44
|
+
const getEscalationColor = (itemType, itemKey, leafId) => {
|
|
45
|
+
if (itemType === 'hit' && leafId) {
|
|
46
|
+
const color = ESCALATION_COLORS[hitMetadata[leafId]?.escalation];
|
|
47
|
+
if (color)
|
|
48
|
+
return color;
|
|
49
|
+
}
|
|
50
|
+
if (itemType === 'case' && itemKey) {
|
|
51
|
+
const color = ESCALATION_COLORS[caseStates[itemKey]?.data?.escalation];
|
|
52
|
+
if (color)
|
|
53
|
+
return color;
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
};
|
|
57
|
+
const toggleCase = useCallback((item, itemKey) => {
|
|
58
|
+
const resolvedKey = itemKey || item.path || item.id;
|
|
59
|
+
if (!resolvedKey)
|
|
60
|
+
return;
|
|
61
|
+
const prev = caseStates[resolvedKey] ?? { open: false, loading: false, data: null };
|
|
62
|
+
const shouldOpen = !prev.open;
|
|
63
|
+
const shouldFetch = shouldOpen && !!item.id && !prev.data && !prev.loading;
|
|
64
|
+
setCaseStates(current => ({ ...current, [resolvedKey]: { ...prev, open: shouldOpen, loading: shouldFetch } }));
|
|
65
|
+
if (!shouldFetch)
|
|
66
|
+
return;
|
|
67
|
+
dispatchApi(api.v2.case.get(item.id), { throwError: false })
|
|
68
|
+
.then(caseResponse => {
|
|
69
|
+
if (!caseResponse)
|
|
70
|
+
return;
|
|
71
|
+
setCaseStates(current => ({ ...current, [resolvedKey]: { ...current[resolvedKey], data: caseResponse } }));
|
|
72
|
+
})
|
|
73
|
+
.finally(() => {
|
|
74
|
+
setCaseStates(current => ({ ...current, [resolvedKey]: { ...current[resolvedKey], loading: false } }));
|
|
75
|
+
});
|
|
76
|
+
}, [caseStates, dispatchApi]);
|
|
77
|
+
return (_jsxs(Stack, { sx: { overflow: 'visible' }, children: [name && (_jsxs(Stack, { direction: "row", pl: step * 1.5, py: 0.25, sx: {
|
|
78
|
+
cursor: 'pointer',
|
|
79
|
+
transition: theme.transitions.create('background', { duration: 50 }),
|
|
80
|
+
background: 'transparent',
|
|
81
|
+
'&:hover': {
|
|
82
|
+
background: theme.palette.grey[800]
|
|
83
|
+
}
|
|
84
|
+
}, onClick: () => setOpen(_open => !_open), children: [_jsx(ChevronRight, { fontSize: "small", color: "disabled", sx: [
|
|
85
|
+
{ transition: theme.transitions.create('transform', { duration: 100 }), transform: 'rotate(0deg)' },
|
|
86
|
+
open && { transform: 'rotate(90deg)' }
|
|
87
|
+
] }), _jsx(FolderIcon, { fontSize: "small", color: "disabled" }), _jsx(Typography, { variant: "caption", color: "textSecondary", sx: { userSelect: 'none', pl: 0.5, textWrap: 'nowrap' }, children: name })] })), open && (_jsxs(_Fragment, { children: [Object.entries(omit(tree, 'leaves')).map(([path, subfolder]) => (_jsx(CaseFolder, { name: path, case: _case, folder: subfolder, step: step + 1, rootCaseId: currentRootCaseId, pathPrefix: pathPrefix }, `${_case?.case_id}-${path}`))), tree.leaves?.map(leaf => {
|
|
88
|
+
const itemType = leaf.type?.toLowerCase();
|
|
89
|
+
const isCase = itemType === 'case';
|
|
90
|
+
const fullRelativePath = [pathPrefix, leaf.path].filter(Boolean).join('/');
|
|
91
|
+
const itemKey = fullRelativePath || leaf.value;
|
|
92
|
+
const nodeState = itemKey ? caseStates[itemKey] : null;
|
|
93
|
+
const isCaseOpen = !!nodeState?.open;
|
|
94
|
+
const isCaseLoading = !!nodeState?.loading;
|
|
95
|
+
const nestedCase = nodeState?.data ?? null;
|
|
96
|
+
const itemPath = itemType !== 'reference'
|
|
97
|
+
? fullRelativePath
|
|
98
|
+
? `/cases/${currentRootCaseId}/${fullRelativePath}`
|
|
99
|
+
: `/cases/${currentRootCaseId}`
|
|
100
|
+
: leaf.value;
|
|
101
|
+
const escalationColor = getEscalationColor(itemType, itemKey, leaf.value);
|
|
102
|
+
const iconColor = escalationColor ?? 'inherit';
|
|
103
|
+
const leafColor = escalationColor ? `${escalationColor}.light` : 'text.secondary';
|
|
104
|
+
const Icon = ICON_FOR_TYPE[itemType ?? ''] ?? Article;
|
|
105
|
+
return (_jsxs(Stack, { children: [_jsxs(Stack, { direction: "row", pl: step * 1.5 + 1, py: 0.25, sx: [
|
|
106
|
+
{
|
|
107
|
+
cursor: 'pointer',
|
|
108
|
+
overflow: 'visible',
|
|
109
|
+
color: `${theme.palette.text.secondary} !important`,
|
|
110
|
+
textDecoration: 'none',
|
|
111
|
+
transition: theme.transitions.create('background', { duration: 100 }),
|
|
112
|
+
background: 'transparent',
|
|
113
|
+
'&:hover': {
|
|
114
|
+
background: theme.palette.grey[800]
|
|
115
|
+
},
|
|
116
|
+
borderRight: '3px solid transparent'
|
|
117
|
+
},
|
|
118
|
+
decodeURIComponent(location.pathname) === itemPath && {
|
|
119
|
+
background: alpha(theme.palette.grey[600], 0.15),
|
|
120
|
+
borderRightColor: theme.palette.primary.main
|
|
121
|
+
}
|
|
122
|
+
], onClick: () => isCase && toggleCase(leaf, itemKey), component: Link, to: itemPath, target: itemType === 'reference' ? '_blank' : undefined, rel: itemType === 'reference' ? 'noopener noreferrer' : undefined, children: [_jsx(ChevronRight, { fontSize: "small", sx: [
|
|
123
|
+
!isCase && { opacity: 0 },
|
|
124
|
+
isCase && {
|
|
125
|
+
transition: theme.transitions.create('transform', { duration: 100 }),
|
|
126
|
+
transform: isCaseOpen ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
127
|
+
}
|
|
128
|
+
] }), _jsx(Icon, { fontSize: "small", color: iconColor }), _jsx(Typography, { variant: "caption", color: leafColor, sx: { userSelect: 'none', pl: 0.5, textWrap: 'nowrap' }, children: leaf.path?.split('/').pop() || leaf.value })] }), isCase && isCaseOpen && isCaseLoading && (_jsx(Stack, { pl: step * 1.5 + 4, py: 0.25, children: _jsx(Skeleton, { width: 140, height: 16 }) })), isCase && isCaseOpen && nestedCase && (_jsx(CaseFolder, { case: nestedCase, step: step + 1, rootCaseId: currentRootCaseId, pathPrefix: fullRelativePath }))] }, `${_case?.case_id}-${leaf.value}-${leaf.path}`));
|
|
129
|
+
})] }))] }));
|
|
130
|
+
};
|
|
131
|
+
export default CaseFolder;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { get, set } from 'lodash-es';
|
|
2
|
+
export const buildTree = (items = []) => {
|
|
3
|
+
// Root tree node stores direct children in `leaves` and nested folders as object keys.
|
|
4
|
+
const tree = { leaves: [] };
|
|
5
|
+
items.forEach(item => {
|
|
6
|
+
// Ignore items that cannot be placed in the folder structure.
|
|
7
|
+
if (!item?.path) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
// Split path into folder segments + item name, then remove the item name.
|
|
11
|
+
const parts = item.path.split('/');
|
|
12
|
+
parts.pop();
|
|
13
|
+
if (parts.length > 0) {
|
|
14
|
+
// Use dot notation so lodash `get/set` can address nested folder objects.
|
|
15
|
+
const key = parts.join('.');
|
|
16
|
+
const size = get(tree, key)?.leaves?.length || 0;
|
|
17
|
+
// Append this item to the folder's `leaves` array.
|
|
18
|
+
set(tree, `${key}.leaves.${size}`, item);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
// Items without parent folders are top-level leaves.
|
|
22
|
+
tree.leaves.push(item);
|
|
23
|
+
});
|
|
24
|
+
return tree;
|
|
25
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Case } from '@cccsaurora/howler-ui/models/entities/generated/Case';
|
|
2
|
+
interface CaseArguments {
|
|
3
|
+
case?: Case;
|
|
4
|
+
caseId?: string;
|
|
5
|
+
}
|
|
6
|
+
interface CaseResult {
|
|
7
|
+
case: Case;
|
|
8
|
+
updateCase: (update: Partial<Case>) => Promise<void>;
|
|
9
|
+
loading: boolean;
|
|
10
|
+
missing: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const useCase: (args: CaseArguments) => CaseResult;
|
|
13
|
+
export default useCase;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
2
|
+
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
3
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
const useCase = ({ caseId, case: providedCase }) => {
|
|
5
|
+
const { dispatchApi } = useMyApi();
|
|
6
|
+
const [loading, setLoading] = useState(false);
|
|
7
|
+
const [missing, setMissing] = useState(false);
|
|
8
|
+
const [_case, setCase] = useState(providedCase);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (providedCase) {
|
|
11
|
+
setCase(providedCase);
|
|
12
|
+
}
|
|
13
|
+
}, [providedCase]);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (caseId) {
|
|
16
|
+
setLoading(true);
|
|
17
|
+
dispatchApi(api.v2.case.get(caseId), { throwError: false })
|
|
18
|
+
.then(setCase)
|
|
19
|
+
.finally(() => setLoading(false));
|
|
20
|
+
}
|
|
21
|
+
}, [caseId, dispatchApi]);
|
|
22
|
+
const updateCase = useCallback(async (_updatedCase) => {
|
|
23
|
+
if (!_case?.case_id) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
setCase(await dispatchApi(api.v2.case.put(_case.case_id, _updatedCase)));
|
|
28
|
+
}
|
|
29
|
+
catch (e) {
|
|
30
|
+
setMissing(true);
|
|
31
|
+
}
|
|
32
|
+
finally {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}, [_case?.case_id, dispatchApi]);
|
|
36
|
+
return { case: _case, updateCase, loading, missing };
|
|
37
|
+
};
|
|
38
|
+
export default useCase;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { OpenInNew } from '@mui/icons-material';
|
|
3
|
+
import { Autocomplete, Box, Button, Card, Chip, Divider, IconButton, LinearProgress, Skeleton, Stack, TextField, Typography } from '@mui/material';
|
|
4
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
5
|
+
import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
|
|
6
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
7
|
+
import AnalyticLink from '@cccsaurora/howler-ui/components/elements/hit/elements/AnalyticLink';
|
|
8
|
+
import EscalationChip from '@cccsaurora/howler-ui/components/elements/hit/elements/EscalationChip';
|
|
9
|
+
import { HitLayout } from '@cccsaurora/howler-ui/components/elements/hit/HitLayout';
|
|
10
|
+
import useHitActions from '@cccsaurora/howler-ui/components/hooks/useHitActions';
|
|
11
|
+
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
12
|
+
import { uniq } from 'lodash-es';
|
|
13
|
+
import { useContext, useEffect, useMemo, useState } from 'react';
|
|
14
|
+
import { useTranslation } from 'react-i18next';
|
|
15
|
+
import { Link } from 'react-router-dom';
|
|
16
|
+
import useCase from '../hooks/useCase';
|
|
17
|
+
const ResolveModal = ({ case: _case, onConfirm }) => {
|
|
18
|
+
const { t } = useTranslation();
|
|
19
|
+
const { dispatchApi } = useMyApi();
|
|
20
|
+
const { close } = useContext(ModalContext);
|
|
21
|
+
const { config } = useContext(ApiConfigContext);
|
|
22
|
+
const { updateCase } = useCase({ case: _case });
|
|
23
|
+
const [loading, setLoading] = useState(true);
|
|
24
|
+
const [rationale, setRationale] = useState('');
|
|
25
|
+
const [assessment, setAssessment] = useState(null);
|
|
26
|
+
const [hits, setHits] = useState([]);
|
|
27
|
+
const hitIds = useMemo(() => uniq((_case?.items ?? []).filter(item => item.type === 'hit').map(item => item.id)), [_case?.items]);
|
|
28
|
+
const { assess } = useHitActions(hits);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
(async () => {
|
|
31
|
+
try {
|
|
32
|
+
const result = await dispatchApi(api.search.hit.post({
|
|
33
|
+
query: `howler.id:(${hitIds.join(' OR ')}) AND -howler.status:resolved`,
|
|
34
|
+
metadata: ['analytic']
|
|
35
|
+
}));
|
|
36
|
+
setHits(result.items);
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
setLoading(false);
|
|
40
|
+
}
|
|
41
|
+
})();
|
|
42
|
+
}, [dispatchApi, hitIds]);
|
|
43
|
+
const handleConfirm = async () => {
|
|
44
|
+
setLoading(true);
|
|
45
|
+
try {
|
|
46
|
+
await assess(assessment, true, rationale);
|
|
47
|
+
await updateCase({ status: 'resolved' });
|
|
48
|
+
onConfirm();
|
|
49
|
+
close();
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setLoading(false);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return (_jsxs(Stack, { spacing: 2, p: 2, alignItems: "start", sx: { minWidth: 'min(1000px, 60vw)', maxHeight: '100%', height: '100%' }, children: [_jsx(Typography, { variant: "h4", children: t('modal.cases.resolve') }), _jsx(Typography, { children: t('modal.cases.resolve.description') }), _jsxs(Stack, { spacing: 1, overflow: "auto", width: "100%", flex: 1, children: [_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Box, { flex: 1, children: _jsx(TextField, { size: "small", fullWidth: true, placeholder: t('modal.rationale.label'), value: rationale, onChange: ev => setRationale(ev.target.value) }) }), _jsx(Box, { flex: 1, children: _jsx(Autocomplete, { size: "small", value: assessment, onChange: (_ev, _assessment) => setAssessment(_assessment), options: config.lookups['howler.assessment'], disablePortal: true, renderInput: params => (_jsx(TextField, { ...params, placeholder: t('hit.details.actions.assessment'), fullWidth: true })) }) })] }), _jsxs(Stack, { position: "relative", children: [_jsx(Divider, {}), _jsx(LinearProgress, { sx: { opacity: +loading } })] }), loading
|
|
56
|
+
? hitIds.map(id => _jsx(Skeleton, { variant: "rounded", height: "40px", width: "100%" }, id))
|
|
57
|
+
: hits.map(hit => (_jsx(Card, { sx: { p: 1, flexShrink: 0 }, children: _jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, width: "100%", children: [_jsx(AnalyticLink, { hit: hit, compressed: true, alignSelf: "center" }), _jsx(EscalationChip, { hit: hit, layout: HitLayout.DENSE }), _jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, size: "small", color: "primary" }), _jsx("div", { style: { flex: 1 } }), _jsx(IconButton, { size: "small", component: Link, to: `/hits/${hit.howler.id}`, children: _jsx(OpenInNew, { fontSize: "small" }) })] }) }, hit.howler.id)))] }), _jsxs(Stack, { direction: "row", spacing: 1, alignSelf: "end", children: [_jsx(Button, { variant: "outlined", color: "error", onClick: close, children: t('cancel') }), _jsx(Button, { variant: "outlined", color: "success", disabled: loading || !assessment || !rationale, onClick: handleConfirm, children: t('confirm') })] })] }));
|
|
58
|
+
};
|
|
59
|
+
export default ResolveModal;
|
|
@@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
13
13
|
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
|
14
14
|
import { useContextSelector } from 'use-context-selector';
|
|
15
15
|
import QueryResultText from '../../elements/display/QueryResultText';
|
|
16
|
-
import
|
|
16
|
+
import RecordQuery from '../hits/search/RecordQuery';
|
|
17
17
|
import LeadForm from './LeadForm';
|
|
18
18
|
import PivotForm from './PivotForm';
|
|
19
19
|
const DossierEditor = () => {
|
|
@@ -188,6 +188,6 @@ const DossierEditor = () => {
|
|
|
188
188
|
fontSize: '0.9em',
|
|
189
189
|
fontStyle: 'italic',
|
|
190
190
|
mb: 0.5
|
|
191
|
-
}), variant: "body2", children: t('hit.search.prompt') }), _jsx(
|
|
191
|
+
}), variant: "body2", children: t('hit.search.prompt') }), _jsx(RecordQuery, { disabled: !dossier || loading, onChange: (_val, isDirty) => setSearchDirty(isDirty), triggerSearch: query => setDossier(_dossier => ({ ..._dossier, query })) }), searchTotal >= 0 && _jsx(QueryResultText, { count: searchTotal, query: dossier.query })] }) }), _jsxs(Tabs, { value: tab, onChange: (_ev, value) => setTab(value), children: [_jsx(Tab, { label: t('route.dossiers.manager.tabs.leads'), value: "leads" }), _jsx(Tab, { label: t('route.dossiers.manager.tabs.pivots'), value: "pivots" })] }), tab === 'leads' && _jsx(LeadForm, { dossier: dossier, setDossier: setDossier, loading: loading }), tab === 'pivots' && _jsx(PivotForm, { dossier: dossier, setDossier: setDossier, loading: loading })] })] }) }));
|
|
192
192
|
};
|
|
193
193
|
export default memo(DossierEditor);
|
|
@@ -61,7 +61,7 @@ vi.mock('commons/components/pages/PageCenter', () => ({
|
|
|
61
61
|
vi.mock('../../elements/display/QueryResultText', () => ({
|
|
62
62
|
default: ({ count, query }) => (_jsxs("div", { id: "query-result-text", children: [count, " ", ' results for ', " ", query] }))
|
|
63
63
|
}));
|
|
64
|
-
vi.mock('../hits/search/
|
|
64
|
+
vi.mock('../hits/search/RecordQuery', () => ({
|
|
65
65
|
default: ({ onChange, triggerSearch, disabled }) => {
|
|
66
66
|
return (_jsxs("div", { id: "hit-query", children: [_jsx("input", { id: "query-input", disabled: disabled, onChange: e => {
|
|
67
67
|
onChange?.(e.target.value, false);
|
|
@@ -49,7 +49,7 @@ const ApiDocumentation = () => {
|
|
|
49
49
|
.replace(/(\S+)\s+=>\s+(.+)/g, '\n`$1`: $2\n')
|
|
50
50
|
.replace(/(Data Block:\n)([\s\S]+)(Result Example:)/, (__, p1, p2, p3) => `${p1}\`\`\`\n${p2.trim()}\n\`\`\`\n${p3}`)
|
|
51
51
|
.replace(/(Result Example:\n)([\s\S]+)$/, (__, p1, p2) => `${p1}\`\`\`\n${p2.trim()}\n\`\`\``) }));
|
|
52
|
-
return (_jsxs(Fragment, { children: [_jsxs(TableRow, { style: { marginBottom: '1rem' }, sx: [isLg && { '& > td': { borderBottom: 0 } }], children: [_jsx(TableCell, { children: _jsxs(Stack, { direction: "column", spacing: 1, alignItems: "start", children: [_jsx(Typography, { children: endpoint.name }), _jsx("code", { children: endpoint.path }), _jsxs(Stack, { direction: "row", spacing: 1, children: [endpoint.complete ? (_jsx(Chip, {
|
|
52
|
+
return (_jsxs(Fragment, { children: [_jsxs(TableRow, { style: { marginBottom: '1rem' }, sx: [isLg && { '& > td': { borderBottom: 0 } }], children: [_jsx(TableCell, { children: _jsxs(Stack, { direction: "column", spacing: 1, alignItems: "start", children: [_jsx(Typography, { children: endpoint.name }), _jsx("code", { children: endpoint.path }), _jsxs(Stack, { direction: "row", spacing: 1, children: [endpoint.complete ? (_jsx(Chip, { label: "Stable", color: "success" })) : (_jsx(Chip, { label: "Unstable", color: "error" })), endpoint.protected ? (_jsx(Chip, { label: "Protected", color: "warning" })) : (_jsx(Chip, { label: "Unprotected" }))] }), _jsx(Stack, { spacing: 1, direction: "row", children: endpoint.methods.map(m => (_jsx(Chip, { size: "small", label: m }, m))) }), endpoint.ui_only && _jsx(Chip, { label: "UI Only" })] }) }), _jsx(TableCell, { children: _jsx(Stack, { spacing: 1, direction: "row", children: endpoint.required_type.map(type => (_jsx(Chip, { size: "small", label: type, color: user.roles?.includes(type) ? 'success' : 'default' }, type))) }) }), _jsx(TableCell, { children: _jsx(Stack, { spacing: 1, direction: "row", children: endpoint.required_priv.map((p) => (_jsx(Chip, { size: "small", label: t(APIKEY_LABELS[p]) }, p))) }) }), !isLg && _jsx(TableCell, { children: documentationCell })] }), isLg && (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, sx: { '& pre': { whiteSpace: 'pre-wrap' } }, children: documentationCell }) }))] }, endpoint.id));
|
|
53
53
|
}) })] }) })] }) }));
|
|
54
54
|
};
|
|
55
55
|
export default ApiDocumentation;
|
|
@@ -5,7 +5,6 @@ import { useScrollRestoration } from '@cccsaurora/howler-ui/components/hooks/use
|
|
|
5
5
|
import { useCallback, useState } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { useSearchParams } from 'react-router-dom';
|
|
8
|
-
import BundleDocumentation from './BundleDocumentation';
|
|
9
8
|
import HelpTabs from './components/HelpTabs';
|
|
10
9
|
import HitBannerDocumentation from './HitBannerDocumentation';
|
|
11
10
|
import HitLabelsDocumentation from './HitLabelsDocumentation';
|
|
@@ -23,8 +22,7 @@ const HitDocumentation = () => {
|
|
|
23
22
|
searchParams.set('tab', _tab);
|
|
24
23
|
setSearchParams(new URLSearchParams(searchParams));
|
|
25
24
|
}, [searchParams, setSearchParams]);
|
|
26
|
-
return (_jsx(PageCenter, { margin: 4, width: "100%", maxWidth: "1750px", textAlign: "left", children: _jsxs(Stack, { sx: { flexDirection: useHorizontal ? 'column' : 'row', '& h1': { mt: 0 } }, children: [_jsxs(HelpTabs, { value: tab, children: [_jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.schema.title') }), value: "schema", onClick: () => onChange('schema') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.banner.title') }), value: "header", onClick: () => onChange('header') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.
|
|
27
|
-
bundle: () => _jsx(BundleDocumentation, {}),
|
|
25
|
+
return (_jsx(PageCenter, { margin: 4, width: "100%", maxWidth: "1750px", textAlign: "left", children: _jsxs(Stack, { sx: { flexDirection: useHorizontal ? 'column' : 'row', '& h1': { mt: 0 } }, children: [_jsxs(HelpTabs, { value: tab, children: [_jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.schema.title') }), value: "schema", onClick: () => onChange('schema') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.banner.title') }), value: "header", onClick: () => onChange('header') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.links.title') }), value: "links", onClick: () => onChange('links') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.labels.title') }), value: "labels", onClick: () => onChange('labels') })] }), _jsx(Box, { children: {
|
|
28
26
|
header: () => _jsx(HitBannerDocumentation, {}),
|
|
29
27
|
links: () => _jsx(HitLinksDocumentation, {}),
|
|
30
28
|
labels: () => _jsx(HitLabelsDocumentation, {}),
|