@cccsaurora/howler-ui 2.17.0-dev.513 → 2.17.0-dev.515
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.
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { Article, BookRounded, ChevronRight, Folder as FolderIcon } from '@mui/icons-material';
|
|
2
|
+
import { Article, BookRounded, CheckCircle, ChevronRight, Folder as FolderIcon, Lightbulb, Link as LinkIcon, TableChart, Visibility } from '@mui/icons-material';
|
|
3
3
|
import { Skeleton, Stack, Typography, useTheme } from '@mui/material';
|
|
4
4
|
import api from '@cccsaurora/howler-ui/api';
|
|
5
5
|
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
6
6
|
import { get, last, omit, set } from 'lodash-es';
|
|
7
|
-
import { useMemo, useState } from 'react';
|
|
7
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
8
8
|
import { Link, useLocation } from 'react-router-dom';
|
|
9
|
+
import { ESCALATION_COLORS, STATUS_COLORS } from '@cccsaurora/howler-ui/utils/constants';
|
|
9
10
|
const buildTree = (items = []) => {
|
|
10
11
|
// Root tree node stores direct children in `leaves` and nested folders as object keys.
|
|
11
12
|
const tree = { leaves: [] };
|
|
@@ -38,8 +39,43 @@ const CaseFolder = ({ case: _case, folder, name, step = -1, rootCaseId, pathPref
|
|
|
38
39
|
const [openCases, setOpenCases] = useState({});
|
|
39
40
|
const [loadingCases, setLoadingCases] = useState({});
|
|
40
41
|
const [nestedCases, setNestedCases] = useState({});
|
|
42
|
+
const [hitMetadata, setHitMetadata] = useState({});
|
|
41
43
|
const tree = useMemo(() => folder || buildTree(_case?.items), [folder, _case?.items]);
|
|
42
44
|
const currentRootCaseId = rootCaseId || _case?.case_id;
|
|
45
|
+
// Metadata for hit-type items
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
tree.leaves
|
|
48
|
+
?.filter(leaf => leaf.type?.toLowerCase() === 'hit')
|
|
49
|
+
.forEach(leaf => {
|
|
50
|
+
dispatchApi(api.hit.get(leaf.id), { throwError: false }).then(hit => {
|
|
51
|
+
if (!hit)
|
|
52
|
+
return;
|
|
53
|
+
setHitMetadata(prev => ({
|
|
54
|
+
...prev,
|
|
55
|
+
[leaf.id]: {
|
|
56
|
+
status: hit.howler?.status,
|
|
57
|
+
escalation: hit.howler?.escalation,
|
|
58
|
+
assessment: hit.howler?.assessment
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}, [tree.leaves, dispatchApi]);
|
|
64
|
+
const getItemColor = (itemType, itemKey, leafId) => {
|
|
65
|
+
if (itemType === 'hit' && leafId) {
|
|
66
|
+
const meta = hitMetadata[leafId];
|
|
67
|
+
if (meta?.status && STATUS_COLORS[meta.status]) {
|
|
68
|
+
return `${STATUS_COLORS[meta.status]}.main`;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (itemType === 'case' && itemKey) {
|
|
72
|
+
const caseData = nestedCases[itemKey];
|
|
73
|
+
if (caseData?.escalation && ESCALATION_COLORS[caseData.escalation]) {
|
|
74
|
+
return `${ESCALATION_COLORS[caseData.escalation]}.main`;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return 'text.secondary';
|
|
78
|
+
};
|
|
43
79
|
const toggleCase = (item, itemKey) => {
|
|
44
80
|
// Use the fully-qualified path key when available so nested case toggles are unique.
|
|
45
81
|
const resolvedItemKey = itemKey || item.path || item.id;
|
|
@@ -87,6 +123,25 @@ const CaseFolder = ({ case: _case, folder, name, step = -1, rootCaseId, pathPref
|
|
|
87
123
|
const itemPath = fullRelativePath
|
|
88
124
|
? `/cases/${currentRootCaseId}/${fullRelativePath}`
|
|
89
125
|
: `/cases/${currentRootCaseId}`;
|
|
126
|
+
const getIconForType = (type) => {
|
|
127
|
+
switch (type) {
|
|
128
|
+
case 'case':
|
|
129
|
+
return _jsx(BookRounded, { fontSize: "small" });
|
|
130
|
+
case 'observable':
|
|
131
|
+
return _jsx(Visibility, { fontSize: "small" });
|
|
132
|
+
case 'hit':
|
|
133
|
+
return _jsx(CheckCircle, { fontSize: "small" });
|
|
134
|
+
case 'table':
|
|
135
|
+
return _jsx(TableChart, { fontSize: "small" });
|
|
136
|
+
case 'lead':
|
|
137
|
+
return _jsx(Lightbulb, { fontSize: "small" });
|
|
138
|
+
case 'reference':
|
|
139
|
+
return _jsx(LinkIcon, { fontSize: "small" });
|
|
140
|
+
default:
|
|
141
|
+
return _jsx(Article, { fontSize: "small" });
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const leafColor = getItemColor(itemType, itemKey, leaf.id);
|
|
90
145
|
return (_jsxs(Stack, { children: [_jsxs(Stack, { direction: "row", pl: step * 1.5 + 1, py: 0.25, sx: [
|
|
91
146
|
{
|
|
92
147
|
cursor: 'pointer',
|
|
@@ -108,7 +163,7 @@ const CaseFolder = ({ case: _case, folder, name, step = -1, rootCaseId, pathPref
|
|
|
108
163
|
transition: theme.transitions.create('transform', { duration: 100 }),
|
|
109
164
|
transform: isCaseOpen ? 'rotate(90deg)' : 'rotate(0deg)'
|
|
110
165
|
}
|
|
111
|
-
] }),
|
|
166
|
+
] }), getIconForType(itemType), _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}`));
|
|
112
167
|
})] }))] }));
|
|
113
168
|
};
|
|
114
169
|
export default CaseFolder;
|
|
@@ -15,6 +15,7 @@ import Phrase from '@cccsaurora/howler-ui/components/elements/addons/search/phra
|
|
|
15
15
|
import SocketBadge from '@cccsaurora/howler-ui/components/elements/display/icons/SocketBadge';
|
|
16
16
|
import JSONViewer from '@cccsaurora/howler-ui/components/elements/display/json/JSONViewer';
|
|
17
17
|
import HitActions from '@cccsaurora/howler-ui/components/elements/hit/HitActions';
|
|
18
|
+
import HitBanner from '@cccsaurora/howler-ui/components/elements/hit/HitBanner';
|
|
18
19
|
import HitComments from '@cccsaurora/howler-ui/components/elements/hit/HitComments';
|
|
19
20
|
import HitLabels from '@cccsaurora/howler-ui/components/elements/hit/HitLabels';
|
|
20
21
|
import { HitLayout } from '@cccsaurora/howler-ui/components/elements/hit/HitLayout';
|
|
@@ -142,7 +143,7 @@ const InformationPane = ({ onClose, selected: _selected }) => {
|
|
|
142
143
|
}[tab]?.();
|
|
143
144
|
}, [dossiers, filter, hit, loading, tab, users]);
|
|
144
145
|
const hasError = useMemo(() => !validateRegex(filter), [filter]);
|
|
145
|
-
return (_jsxs(VSBox, { top: 10, sx: { height: '100%', flex: 1 }, children: [_jsxs(Stack, { direction: "column", flex: 1, sx: { overflowY: 'auto', flexGrow: 1 }, position: "relative", spacing: 1, ml: 2, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, flexShrink: 0, pr: 2, children: [_jsx(FlexOne, {}), onClose && !location.pathname.startsWith('/bundles') && (_jsx(TuiIconButton, { size: "small", onClick: onClose, tooltip: t('hit.panel.details.exit'), children: _jsx(Clear, {}) })), _jsx(SocketBadge, { size: "small" }), analytic && (_jsx(TuiIconButton, { size: "small", tooltip: t('hit.panel.analytic.open'), disabled: !analytic || loading, route: `/analytics/${analytic.analytic_id}`, children: _jsx(QueryStats, {}) })), !!hit && (_jsx(TuiIconButton, { tooltip: t('hit.panel.open'), href: `/hits/${selected}`, disabled: !hit || loading, size: "small", target: "_blank", children: _jsx(OpenInNew, {}) }))] }), !!hit &&
|
|
146
|
+
return (_jsxs(VSBox, { top: 10, sx: { height: '100%', flex: 1 }, children: [_jsxs(Stack, { direction: "column", flex: 1, sx: { overflowY: 'auto', flexGrow: 1 }, position: "relative", spacing: 1, ml: 2, children: [_jsxs(Stack, { direction: "row", alignItems: "center", spacing: 0.5, flexShrink: 0, pr: 2, children: [_jsx(FlexOne, {}), onClose && !location.pathname.startsWith('/bundles') && (_jsx(TuiIconButton, { size: "small", onClick: onClose, tooltip: t('hit.panel.details.exit'), children: _jsx(Clear, {}) })), _jsx(SocketBadge, { size: "small" }), analytic && (_jsx(TuiIconButton, { size: "small", tooltip: t('hit.panel.analytic.open'), disabled: !analytic || loading, route: `/analytics/${analytic.analytic_id}`, children: _jsx(QueryStats, {}) })), !!hit && (_jsx(TuiIconButton, { tooltip: t('hit.panel.open'), href: `/hits/${selected}`, disabled: !hit || loading, size: "small", target: "_blank", children: _jsx(OpenInNew, {}) }))] }), _jsx(Box, { pr: 2, children: loading ? _jsx(Skeleton, { variant: "rounded", height: 152 }) : _jsx(HitBanner, { layout: HitLayout.DENSE, hit: hit }) }), !!hit &&
|
|
146
147
|
(!loading ? (_jsxs(_Fragment, { children: [_jsx(HitOutline, { hit: hit, layout: HitLayout.DENSE }), _jsx(HitLabels, { hit: hit })] })) : (_jsx(Skeleton, { height: 124 }))), (hit?.howler?.links?.length > 0 ||
|
|
147
148
|
analytic?.notebooks?.length > 0 ||
|
|
148
149
|
dossiers.filter(_dossier => _dossier.pivots?.length > 0).length > 0) && (_jsxs(Stack, { direction: "row", spacing: 1, pr: 2, children: [analytic?.notebooks?.length > 0 && _jsx(HitNotebooks, { analytic: analytic, hit: hit }), hit?.howler?.links?.length > 0 &&
|