@cccsaurora/howler-ui 2.17.0-dev.563 → 2.17.0-dev.600
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 +14 -0
- package/components/app/providers/FavouritesProvider.js +2 -2
- package/components/app/providers/HitSearchProvider.d.ts +0 -1
- package/components/app/providers/HitSearchProvider.js +6 -11
- package/components/app/providers/HitSearchProvider.test.js +11 -32
- 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/{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 -0
- package/components/elements/display/ChipPopper.js +2 -2
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +1 -0
- package/components/elements/hit/HitBanner.js +28 -48
- package/components/elements/hit/HitCard.js +1 -1
- package/components/elements/hit/HitLinks.js +5 -3
- package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
- package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +10 -4
- package/components/elements/hit/HitRelated.d.ts +1 -1
- package/components/elements/hit/HitRelated.js +30 -3
- 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 +5 -0
- package/components/elements/observable/ObservableCard.js +7 -0
- package/components/elements/observable/ObservablePreview.d.ts +6 -0
- package/components/elements/observable/ObservablePreview.js +12 -0
- 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 +3 -24
- 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/useRelatedRecords.d.ts +13 -0
- package/components/hooks/useRelatedRecords.js +32 -0
- 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/cases/CaseViewer.d.ts +2 -0
- package/components/routes/cases/CaseViewer.js +24 -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 +32 -0
- package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
- package/components/routes/cases/detail/CaseDashboard.js +49 -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 +36 -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 +93 -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/sidebar/CaseFolder.d.ts +12 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.js +179 -0
- package/components/routes/cases/detail/sidebar/types.d.ts +3 -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/help/ApiDocumentation.js +1 -1
- package/components/routes/help/HitDocumentation.js +1 -3
- package/components/routes/hits/search/HitContextMenu.js +3 -2
- package/components/routes/hits/search/InformationPane.d.ts +1 -0
- package/components/routes/hits/search/InformationPane.js +6 -28
- package/components/routes/hits/search/QuerySettings.js +2 -1
- package/components/routes/hits/search/QuerySettings.test.js +14 -9
- package/components/routes/hits/search/SearchPane.js +7 -32
- package/components/routes/hits/search/ViewLink.js +1 -1
- package/components/routes/hits/search/grid/EnhancedCell.js +1 -1
- 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 +3 -4
- package/components/routes/home/ViewCard.js +1 -1
- 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/locales/en/translation.json +437 -398
- package/locales/fr/translation.json +442 -408
- 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/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 +84 -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 +44 -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/package.json +16 -1
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +2 -1
- package/utils/constants.d.ts +3 -3
- package/utils/typeUtils.d.ts +7 -0
- package/utils/typeUtils.js +18 -0
- package/components/elements/display/icons/BundleButton.d.ts +0 -6
- package/components/elements/display/icons/BundleButton.js +0 -32
- 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/overviews/OverviewEditor.d.ts → elements/MarkdownEditor.d.ts} +0 -0
- /package/components/elements/hit/{HitDetails.d.ts → related/RelatedRecords.d.ts} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Clear, Edit, Save } from '@mui/icons-material';
|
|
3
|
+
import { Box, Card, CardContent, CardHeader, Divider, IconButton, LinearProgress, Skeleton, Stack, useTheme } from '@mui/material';
|
|
4
|
+
import Markdown from '@cccsaurora/howler-ui/components/elements/display/Markdown';
|
|
5
|
+
import MarkdownEditor from '@cccsaurora/howler-ui/components/elements/MarkdownEditor';
|
|
6
|
+
import { useEffect, useState } from 'react';
|
|
7
|
+
const CaseOverview = ({ case: _case, updateCase }) => {
|
|
8
|
+
const theme = useTheme();
|
|
9
|
+
const [editing, setEditing] = useState(false);
|
|
10
|
+
const [loading, setLoading] = useState(false);
|
|
11
|
+
const [overview, setOverview] = useState(_case?.overview);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!editing && _case?.overview) {
|
|
14
|
+
setOverview(_case.overview);
|
|
15
|
+
}
|
|
16
|
+
}, [_case?.overview, editing]);
|
|
17
|
+
if (!_case) {
|
|
18
|
+
return _jsx(Skeleton, { height: 370 });
|
|
19
|
+
}
|
|
20
|
+
return (_jsxs(Card, { children: [_jsx(CardHeader, { title: _case.title, subheader: _case.summary }), _jsxs(Stack, { children: [_jsx(Divider, {}), _jsx(LinearProgress, { sx: { opacity: +loading } })] }), _jsx(CardContent, { sx: { position: 'relative' }, children: _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Box, { flex: 1, sx: {
|
|
21
|
+
'& > :first-child': {
|
|
22
|
+
marginTop: '0 !important'
|
|
23
|
+
},
|
|
24
|
+
'& > h1,h2,h3,h4,h5': {
|
|
25
|
+
fontSize: theme.typography.h5.fontSize
|
|
26
|
+
}
|
|
27
|
+
}, children: editing ? (_jsx(MarkdownEditor, { height: "40vh", content: overview, setContent: _content => setOverview(_content) })) : (_jsx(Markdown, { md: _case.overview })) }), _jsxs(Stack, { spacing: 1, children: [_jsx(IconButton, { size: "small", disabled: loading, onClick: async () => {
|
|
28
|
+
if (editing) {
|
|
29
|
+
try {
|
|
30
|
+
setLoading(true);
|
|
31
|
+
await updateCase({ overview });
|
|
32
|
+
}
|
|
33
|
+
finally {
|
|
34
|
+
setEditing(false);
|
|
35
|
+
setLoading(false);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
setEditing(true);
|
|
40
|
+
}
|
|
41
|
+
}, children: editing ? _jsx(Save, { color: loading ? 'disabled' : 'success', fontSize: "small" }) : _jsx(Edit, { fontSize: "small" }) }), editing && (_jsx(IconButton, { size: "small", disabled: loading, onClick: () => setEditing(false), children: _jsx(Clear, { color: loading ? 'disabled' : 'error', fontSize: "small" }) }))] })] }) })] }));
|
|
42
|
+
};
|
|
43
|
+
export default CaseOverview;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Circle, Dashboard } from '@mui/icons-material';
|
|
3
|
+
import { Box, Card, Chip, Divider, Skeleton, Stack, Typography, useTheme } from '@mui/material';
|
|
4
|
+
import dayjs from 'dayjs';
|
|
5
|
+
import {} from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { Link } from 'react-router-dom';
|
|
8
|
+
import { ESCALATION_COLOR_MAP } from '../constants';
|
|
9
|
+
import CaseFolder from './sidebar/CaseFolder';
|
|
10
|
+
const CaseSidebar = ({ case: _case }) => {
|
|
11
|
+
const { t } = useTranslation();
|
|
12
|
+
const theme = useTheme();
|
|
13
|
+
return (_jsxs(Box, { sx: {
|
|
14
|
+
flex: 1,
|
|
15
|
+
maxWidth: '350px',
|
|
16
|
+
maxHeight: 'calc(100vh - 64px)',
|
|
17
|
+
display: 'flex',
|
|
18
|
+
flexDirection: 'column'
|
|
19
|
+
}, children: [_jsxs(Card, { sx: { borderRadius: 0, px: 2, py: 1 }, children: [_case?.title ? _jsx(Typography, { variant: "body1", children: _case.title }) : _jsx(Skeleton, { height: 24 }), _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", divider: _jsx(Circle, { color: "disabled", sx: { fontSize: '8px' } }), children: [_jsxs(Typography, { variant: "caption", color: "textSecondary", children: [t('started'), ": ", _case?.created ? dayjs(_case.created).toString() : _jsx(Skeleton, { height: 14 })] }), _case?.escalation ? (_jsx(Chip, { color: ESCALATION_COLOR_MAP[_case.escalation], label: t(_case.escalation) })) : (_jsx(Skeleton, { height: 24 }))] })] }), _jsxs(Stack, { direction: "row", alignItems: "center", sx: {
|
|
20
|
+
cursor: 'pointer',
|
|
21
|
+
px: 1,
|
|
22
|
+
py: 1,
|
|
23
|
+
transition: theme.transitions.create('background', { duration: 100 }),
|
|
24
|
+
color: `${theme.palette.text.primary} !important`,
|
|
25
|
+
textDecoration: 'none',
|
|
26
|
+
background: 'transparent',
|
|
27
|
+
borderRight: `thin solid ${theme.palette.divider}`,
|
|
28
|
+
'&:hover': {
|
|
29
|
+
background: theme.palette.grey[800]
|
|
30
|
+
}
|
|
31
|
+
}, component: Link, to: `/cases/${_case?.case_id}`, children: [_jsx(Dashboard, {}), _jsx(Typography, { sx: { userSelect: 'none', pl: 0.5, textWrap: 'nowrap' }, children: t('page.cases.dashboard') })] }), _jsx(Divider, {}), _case && (_jsx(Box, { flex: 1, overflow: "auto", width: "100%", sx: {
|
|
32
|
+
position: 'relative',
|
|
33
|
+
borderRight: `thin solid ${theme.palette.divider}`
|
|
34
|
+
}, children: _jsx(Box, { position: "absolute", sx: { left: 0 }, children: _jsx(CaseFolder, { case: _case }) }) }))] }));
|
|
35
|
+
};
|
|
36
|
+
export default CaseSidebar;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Task } from '@cccsaurora/howler-ui/models/entities/generated/Task';
|
|
2
|
+
import { type FC } from 'react';
|
|
3
|
+
declare const CaseTask: FC<{
|
|
4
|
+
task?: Task;
|
|
5
|
+
paths: string[];
|
|
6
|
+
onDelete?: () => Promise<void>;
|
|
7
|
+
onEdit: (task?: Partial<Task>) => Promise<void>;
|
|
8
|
+
loading?: boolean;
|
|
9
|
+
newTask?: boolean;
|
|
10
|
+
}>;
|
|
11
|
+
export default CaseTask;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Check, Close, Delete, Edit } from '@mui/icons-material';
|
|
3
|
+
import { Autocomplete, Card, Checkbox, Chip, IconButton, LinearProgress, Stack, TextField, Tooltip, Typography } from '@mui/material';
|
|
4
|
+
import UserList from '@cccsaurora/howler-ui/components/elements/UserList';
|
|
5
|
+
import { useEffect, useState } from 'react';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import { Link } from 'react-router-dom';
|
|
8
|
+
const CaseTask = ({ task, onEdit, onDelete, paths, newTask = false }) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const [loading, setLoading] = useState(false);
|
|
11
|
+
const [editing, setEditing] = useState(newTask);
|
|
12
|
+
const [summary, setSummary] = useState(task?.summary || '');
|
|
13
|
+
const [path, setPath] = useState(task?.path ?? null);
|
|
14
|
+
const [assignment, setAssignment] = useState(task?.assignment);
|
|
15
|
+
const [complete, setComplete] = useState(task?.complete ?? false);
|
|
16
|
+
const dirty = summary !== task?.summary || path !== task?.path || complete !== task?.complete || assignment !== task?.assignment;
|
|
17
|
+
const onSubmit = async () => {
|
|
18
|
+
if (dirty && editing) {
|
|
19
|
+
setLoading(true);
|
|
20
|
+
await onEdit({ summary, path: !path ? null : path, assignment, complete });
|
|
21
|
+
setLoading(false);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!editing && task?.assignment !== assignment) {
|
|
26
|
+
setLoading(true);
|
|
27
|
+
onEdit({ assignment }).finally(() => setLoading(false));
|
|
28
|
+
}
|
|
29
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
30
|
+
}, [assignment]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!editing && task?.complete !== complete) {
|
|
33
|
+
setLoading(true);
|
|
34
|
+
onEdit({ complete }).finally(() => setLoading(false));
|
|
35
|
+
}
|
|
36
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
37
|
+
}, [complete]);
|
|
38
|
+
return (_jsxs(Card, { sx: { pl: 0.5, pr: 1, py: 0.5, position: 'relative' }, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 1, children: [_jsx(Checkbox, { disabled: loading, color: "success", checked: complete, size: "small", onChange: (_ev, _complete) => setComplete(_complete) }), editing ? (_jsx(TextField, { disabled: loading, value: summary, onChange: e => setSummary(e.target.value), size: "small", fullWidth: true, sx: { minWidth: '40%' } })) : (_jsx(Typography, { sx: [complete && { textDecoration: 'line-through' }], children: task?.summary || summary })), !editing && path && _jsx(Chip, { clickable: true, component: Link, to: path, label: path }), editing && (_jsx(Autocomplete, { disabled: loading, value: path, options: paths, onChange: (_ev, value) => setPath(value), fullWidth: true, renderInput: params => _jsx(TextField, { ...params, size: "small" }) })), _jsx(UserList, { disabled: loading, userIds: [assignment], onChange: ([_assigment]) => setAssignment(_assigment), i18nLabel: "route.cases.task.set.assignment", avatarHeight: 24 }), _jsx("div", { style: { flex: 1 } }), editing && !newTask && (_jsx(Tooltip, { title: t('route.cases.task.delete'), children: _jsx(IconButton, { size: "small", color: "error", onClick: () => {
|
|
39
|
+
setLoading(true);
|
|
40
|
+
onDelete().then(() => setLoading(false));
|
|
41
|
+
}, disabled: loading, children: _jsx(Delete, { fontSize: "small" }) }) })), _jsx(Tooltip, { title: t(editing ? 'route.cases.task.edit.save' : 'route.cases.task.edit'), children: _jsx("span", { children: _jsx(IconButton, { size: "small", color: editing ? 'success' : 'default', onClick: async () => {
|
|
42
|
+
if (!editing) {
|
|
43
|
+
setEditing(true);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
await onSubmit();
|
|
47
|
+
setEditing(false);
|
|
48
|
+
}, disabled: (!dirty && editing) || loading || !summary, children: editing ? _jsx(Check, { fontSize: "small" }) : _jsx(Edit, { fontSize: "small" }) }) }) }), editing && (_jsx(Tooltip, { title: t('route.cases.task.edit.cancel'), children: _jsx(IconButton, { size: "small", onClick: () => {
|
|
49
|
+
if (newTask) {
|
|
50
|
+
onDelete();
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
setEditing(false);
|
|
54
|
+
}
|
|
55
|
+
}, disabled: loading, children: _jsx(Close, { fontSize: "small" }) }) }))] }), loading && _jsx(LinearProgress, { sx: { left: 0, bottom: 0, right: 0, position: 'absolute' } })] }));
|
|
56
|
+
};
|
|
57
|
+
export default CaseTask;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
3
|
+
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
4
|
+
import NotFoundPage from '@cccsaurora/howler-ui/components/routes/404';
|
|
5
|
+
import InformationPane from '@cccsaurora/howler-ui/components/routes/hits/search/InformationPane';
|
|
6
|
+
import ObservableViewer from '@cccsaurora/howler-ui/components/routes/observables/ObservableViewer';
|
|
7
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { useLocation } from 'react-router';
|
|
9
|
+
import CaseDashboard from './CaseDashboard';
|
|
10
|
+
const ItemPage = ({ case: _case }) => {
|
|
11
|
+
const location = useLocation();
|
|
12
|
+
const { dispatchApi } = useMyApi();
|
|
13
|
+
const [item, setItem] = useState(null);
|
|
14
|
+
const [loading, setLoading] = useState(true);
|
|
15
|
+
const subPath = decodeURIComponent(location.pathname).replace(`/cases/${_case.case_id}/`, '');
|
|
16
|
+
const normalizedSubPath = useMemo(() => subPath.replace(/^\/+|\/+$/g, ''), [subPath]);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
let cancelled = false;
|
|
19
|
+
const resolveItem = async () => {
|
|
20
|
+
setLoading(true);
|
|
21
|
+
if (!normalizedSubPath) {
|
|
22
|
+
if (!cancelled) {
|
|
23
|
+
setItem(null);
|
|
24
|
+
setLoading(false);
|
|
25
|
+
}
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
let currentCase = _case;
|
|
29
|
+
let remainingPath = normalizedSubPath;
|
|
30
|
+
while (currentCase && remainingPath) {
|
|
31
|
+
const currentRemainingPath = remainingPath;
|
|
32
|
+
const matchedNestedCase = currentCase.items
|
|
33
|
+
.filter(_item => _item?.path &&
|
|
34
|
+
_item?.type?.toLowerCase() === 'case' &&
|
|
35
|
+
(currentRemainingPath === _item.path || currentRemainingPath.startsWith(`${_item.path}/`)))
|
|
36
|
+
.sort((a, b) => (b.path?.length || 0) - (a.path?.length || 0))[0];
|
|
37
|
+
if (!matchedNestedCase) {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
if (currentRemainingPath === matchedNestedCase.path) {
|
|
41
|
+
if (!cancelled) {
|
|
42
|
+
setItem(matchedNestedCase);
|
|
43
|
+
setLoading(false);
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!matchedNestedCase.id) {
|
|
48
|
+
if (!cancelled) {
|
|
49
|
+
setItem(null);
|
|
50
|
+
setLoading(false);
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const nextCase = await dispatchApi(api.v2.case.get(matchedNestedCase.id), { throwError: false });
|
|
55
|
+
if (!nextCase) {
|
|
56
|
+
if (!cancelled) {
|
|
57
|
+
setItem(null);
|
|
58
|
+
setLoading(false);
|
|
59
|
+
}
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
remainingPath = currentRemainingPath.slice((matchedNestedCase.path?.length || 0) + 1);
|
|
63
|
+
currentCase = nextCase;
|
|
64
|
+
}
|
|
65
|
+
const resolvedItem = currentCase?.items?.find(_item => _item.path === remainingPath);
|
|
66
|
+
if (!cancelled) {
|
|
67
|
+
setItem(resolvedItem || null);
|
|
68
|
+
setLoading(false);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
resolveItem();
|
|
72
|
+
return () => {
|
|
73
|
+
cancelled = true;
|
|
74
|
+
};
|
|
75
|
+
}, [_case, dispatchApi, normalizedSubPath]);
|
|
76
|
+
if (loading) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
if (!item) {
|
|
80
|
+
return _jsx(NotFoundPage, {});
|
|
81
|
+
}
|
|
82
|
+
if (item.type === 'hit') {
|
|
83
|
+
return _jsx(InformationPane, { selected: item.id });
|
|
84
|
+
}
|
|
85
|
+
if (item.type === 'observable') {
|
|
86
|
+
return _jsx(ObservableViewer, { observableId: item.id });
|
|
87
|
+
}
|
|
88
|
+
if (item.type === 'case') {
|
|
89
|
+
return _jsx(CaseDashboard, { caseId: item.id });
|
|
90
|
+
}
|
|
91
|
+
return _jsx("h1", { children: JSON.stringify(item) });
|
|
92
|
+
};
|
|
93
|
+
export default ItemPage;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Divider, Pagination, Skeleton, Stack, Typography, useTheme } from '@mui/material';
|
|
3
|
+
import { chunk, uniq } from 'lodash-es';
|
|
4
|
+
import { useMemo, useState } from 'react';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
import { Link } from 'react-router-dom';
|
|
7
|
+
import CaseCard from '../../../elements/case/CaseCard';
|
|
8
|
+
const RelatedCasePanel = ({ case: _case }) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
10
|
+
const theme = useTheme();
|
|
11
|
+
const [casePage, setCasePage] = useState(1);
|
|
12
|
+
const casePages = useMemo(() => chunk(uniq((_case?.items ?? []).filter(item => item.type === 'case')), 5), [_case?.items]);
|
|
13
|
+
if (!_case) {
|
|
14
|
+
return _jsx(Skeleton, { height: 240 });
|
|
15
|
+
}
|
|
16
|
+
return (_jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", children: [_jsx(Typography, { flex: 1, variant: "h4", children: t('page.cases.dashboard.cases') }), _jsx(Pagination, { count: casePages.length, page: casePage, onChange: (_, page) => setCasePage(page) })] }), _jsx(Divider, {}), casePages[casePage - 1]?.map(item => (_jsxs(Box, { position: "relative", children: [_jsx(CaseCard, { caseId: item.id }), _jsx(Box, { component: Link, to: item.path, sx: {
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
top: 0,
|
|
19
|
+
left: 0,
|
|
20
|
+
width: '100%',
|
|
21
|
+
height: '100%',
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
zIndex: 100,
|
|
24
|
+
borderRadius: '4px',
|
|
25
|
+
'&:hover': {
|
|
26
|
+
background: theme.palette.divider,
|
|
27
|
+
border: `thin solid ${theme.palette.primary.light}`
|
|
28
|
+
}
|
|
29
|
+
} })] }, item.id)))] }));
|
|
30
|
+
};
|
|
31
|
+
export default RelatedCasePanel;
|
|
@@ -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,12 @@
|
|
|
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
|
+
declare const CaseFolder: FC<{
|
|
5
|
+
case: Case;
|
|
6
|
+
folder?: Tree;
|
|
7
|
+
name?: string;
|
|
8
|
+
step?: number;
|
|
9
|
+
rootCaseId?: string;
|
|
10
|
+
pathPrefix?: string;
|
|
11
|
+
}>;
|
|
12
|
+
export default CaseFolder;
|
|
@@ -0,0 +1,179 @@
|
|
|
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 { 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 { get, last, omit, set } from 'lodash-es';
|
|
7
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
8
|
+
import { Link, useLocation } from 'react-router-dom';
|
|
9
|
+
import { ESCALATION_COLORS } from '@cccsaurora/howler-ui/utils/constants';
|
|
10
|
+
const buildTree = (items = []) => {
|
|
11
|
+
// Root tree node stores direct children in `leaves` and nested folders as object keys.
|
|
12
|
+
const tree = { leaves: [] };
|
|
13
|
+
items.forEach(item => {
|
|
14
|
+
// Ignore items that cannot be placed in the folder structure.
|
|
15
|
+
if (!item?.path) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// Split path into folder segments + item name, then remove the item name.
|
|
19
|
+
const parts = item.path.split('/');
|
|
20
|
+
parts.pop();
|
|
21
|
+
if (parts.length > 0) {
|
|
22
|
+
// Use dot notation so lodash `get/set` can address nested folder objects.
|
|
23
|
+
const key = parts.join('.');
|
|
24
|
+
const size = get(tree, key)?.leaves?.length || 0;
|
|
25
|
+
// Append this item to the folder's `leaves` array.
|
|
26
|
+
set(tree, `${key}.leaves.${size}`, item);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
// Items without parent folders are top-level leaves.
|
|
30
|
+
tree.leaves.push(item);
|
|
31
|
+
});
|
|
32
|
+
return tree;
|
|
33
|
+
};
|
|
34
|
+
const CaseFolder = ({ case: _case, folder, name, step = -1, rootCaseId, pathPrefix = '' }) => {
|
|
35
|
+
const theme = useTheme();
|
|
36
|
+
const location = useLocation();
|
|
37
|
+
const { dispatchApi } = useMyApi();
|
|
38
|
+
const [open, setOpen] = useState(true);
|
|
39
|
+
const [openCases, setOpenCases] = useState({});
|
|
40
|
+
const [loadingCases, setLoadingCases] = useState({});
|
|
41
|
+
const [nestedCases, setNestedCases] = useState({});
|
|
42
|
+
const [hitMetadata, setHitMetadata] = useState({});
|
|
43
|
+
const tree = useMemo(() => folder || buildTree(_case?.items), [folder, _case?.items]);
|
|
44
|
+
const currentRootCaseId = rootCaseId || _case?.case_id;
|
|
45
|
+
// Metadata for hit-type items
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const ids = tree.leaves?.filter(leaf => leaf.type?.toLowerCase() === 'hit').map(leaf => leaf.id);
|
|
48
|
+
if (!ids || ids.length < 1) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
dispatchApi(api.search.hit.post({ query: `howler.id:(${ids.join(' OR ')})` }), { throwError: false }).then(result => {
|
|
52
|
+
if (result?.items?.length < 1) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
setHitMetadata(Object.fromEntries(result.items.map(hit => [hit.howler.id, hit.howler])));
|
|
56
|
+
});
|
|
57
|
+
}, [tree.leaves, dispatchApi]);
|
|
58
|
+
const getIconColor = (itemType, itemKey, leafId) => {
|
|
59
|
+
if (itemType === 'hit' && leafId) {
|
|
60
|
+
const meta = hitMetadata[leafId];
|
|
61
|
+
if (meta?.escalation && ESCALATION_COLORS[meta.escalation]) {
|
|
62
|
+
return ESCALATION_COLORS[meta.escalation];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (itemType === 'case' && itemKey) {
|
|
66
|
+
const caseData = nestedCases[itemKey];
|
|
67
|
+
if (caseData?.escalation && ESCALATION_COLORS[caseData.escalation]) {
|
|
68
|
+
return ESCALATION_COLORS[caseData.escalation];
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return 'default';
|
|
72
|
+
};
|
|
73
|
+
const getItemColor = (itemType, itemKey, leafId) => {
|
|
74
|
+
if (itemType === 'hit' && leafId) {
|
|
75
|
+
const meta = hitMetadata[leafId];
|
|
76
|
+
if (meta?.escalation && ESCALATION_COLORS[meta.escalation]) {
|
|
77
|
+
return `${ESCALATION_COLORS[meta.escalation]}.light`;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (itemType === 'case' && itemKey) {
|
|
81
|
+
const caseData = nestedCases[itemKey];
|
|
82
|
+
if (caseData?.escalation && ESCALATION_COLORS[caseData.escalation]) {
|
|
83
|
+
return `${ESCALATION_COLORS[caseData.escalation]}.light`;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return 'text.secondary';
|
|
87
|
+
};
|
|
88
|
+
const toggleCase = (item, itemKey) => {
|
|
89
|
+
// Use the fully-qualified path key when available so nested case toggles are unique.
|
|
90
|
+
const resolvedItemKey = itemKey || item.path || item.id;
|
|
91
|
+
if (!resolvedItemKey) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
// Toggle expand/collapse state for this case node.
|
|
95
|
+
const shouldOpen = !openCases[resolvedItemKey];
|
|
96
|
+
setOpenCases(current => ({ ...current, [resolvedItemKey]: shouldOpen }));
|
|
97
|
+
// Only fetch when opening, with a valid case id, and when no fetch/data is already in-flight/cached.
|
|
98
|
+
if (!shouldOpen || !item.id || nestedCases[resolvedItemKey] || loadingCases[resolvedItemKey]) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
setLoadingCases(current => ({ ...current, [resolvedItemKey]: true }));
|
|
102
|
+
// Lazy-load the nested case content and cache it by the same unique key.
|
|
103
|
+
dispatchApi(api.v2.case.get(item.id), { throwError: false })
|
|
104
|
+
.then(caseResponse => {
|
|
105
|
+
if (!caseResponse) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
setNestedCases(current => ({ ...current, [resolvedItemKey]: caseResponse }));
|
|
109
|
+
})
|
|
110
|
+
.finally(() => {
|
|
111
|
+
setLoadingCases(current => ({ ...current, [resolvedItemKey]: false }));
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
return (_jsxs(Stack, { sx: { overflow: 'visible' }, children: [name && (_jsxs(Stack, { direction: "row", pl: step * 1.5, py: 0.25, sx: {
|
|
115
|
+
cursor: 'pointer',
|
|
116
|
+
transition: theme.transitions.create('background', { duration: 50 }),
|
|
117
|
+
background: 'transparent',
|
|
118
|
+
'&:hover': {
|
|
119
|
+
background: theme.palette.grey[800]
|
|
120
|
+
}
|
|
121
|
+
}, onClick: () => setOpen(_open => !_open), children: [_jsx(ChevronRight, { fontSize: "small", color: "disabled", sx: [
|
|
122
|
+
{ transition: theme.transitions.create('transform', { duration: 100 }), transform: 'rotate(0deg)' },
|
|
123
|
+
open && { transform: 'rotate(90deg)' }
|
|
124
|
+
] }), _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 => {
|
|
125
|
+
const itemType = leaf.type?.toLowerCase();
|
|
126
|
+
const isCase = itemType === 'case';
|
|
127
|
+
const fullRelativePath = [pathPrefix, leaf.path].filter(Boolean).join('/');
|
|
128
|
+
const itemKey = fullRelativePath || leaf.id;
|
|
129
|
+
const isCaseOpen = !!(itemKey && openCases[itemKey]);
|
|
130
|
+
const isCaseLoading = !!(itemKey && loadingCases[itemKey]);
|
|
131
|
+
const nestedCase = itemKey ? nestedCases[itemKey] : null;
|
|
132
|
+
const itemPath = fullRelativePath
|
|
133
|
+
? `/cases/${currentRootCaseId}/${fullRelativePath}`
|
|
134
|
+
: `/cases/${currentRootCaseId}`;
|
|
135
|
+
const getIconForType = () => {
|
|
136
|
+
const iconColor = getIconColor(itemType, itemKey, leaf.id);
|
|
137
|
+
switch (itemType) {
|
|
138
|
+
case 'case':
|
|
139
|
+
return _jsx(BookRounded, { fontSize: "small", color: iconColor });
|
|
140
|
+
case 'observable':
|
|
141
|
+
return _jsx(Visibility, { fontSize: "small", color: iconColor });
|
|
142
|
+
case 'hit':
|
|
143
|
+
return _jsx(CheckCircle, { fontSize: "small", color: iconColor });
|
|
144
|
+
case 'table':
|
|
145
|
+
return _jsx(TableChart, { fontSize: "small", color: iconColor });
|
|
146
|
+
case 'lead':
|
|
147
|
+
return _jsx(Lightbulb, { fontSize: "small", color: iconColor });
|
|
148
|
+
case 'reference':
|
|
149
|
+
return _jsx(LinkIcon, { fontSize: "small", color: iconColor });
|
|
150
|
+
default:
|
|
151
|
+
return _jsx(Article, { fontSize: "small", color: iconColor });
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
const leafColor = getItemColor(itemType, itemKey, leaf.id);
|
|
155
|
+
return (_jsxs(Stack, { children: [_jsxs(Stack, { direction: "row", pl: step * 1.5 + 1, py: 0.25, sx: [
|
|
156
|
+
{
|
|
157
|
+
cursor: 'pointer',
|
|
158
|
+
overflow: 'visible',
|
|
159
|
+
color: `${theme.palette.text.secondary} !important`,
|
|
160
|
+
textDecoration: 'none',
|
|
161
|
+
transition: theme.transitions.create('background', { duration: 100 }),
|
|
162
|
+
background: 'transparent',
|
|
163
|
+
'&:hover': {
|
|
164
|
+
background: theme.palette.grey[800]
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
decodeURIComponent(location.pathname) === itemPath && {
|
|
168
|
+
background: theme.palette.grey[800]
|
|
169
|
+
}
|
|
170
|
+
], onClick: () => isCase && toggleCase(leaf, itemKey), component: Link, to: itemPath, children: [_jsx(ChevronRight, { fontSize: "small", sx: [
|
|
171
|
+
!isCase && { opacity: 0 },
|
|
172
|
+
isCase && {
|
|
173
|
+
transition: theme.transitions.create('transform', { duration: 100 }),
|
|
174
|
+
transform: isCaseOpen ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
175
|
+
}
|
|
176
|
+
] }), getIconForType(), _jsx(Typography, { variant: "caption", color: leafColor, sx: { userSelect: 'none', pl: 0.5, textWrap: 'nowrap' }, children: last(leaf.path?.split('/') || []) })] }), 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.id}-${leaf.path}`));
|
|
177
|
+
})] }))] }));
|
|
178
|
+
};
|
|
179
|
+
export default CaseFolder;
|