@cccsaurora/howler-ui 3.2.0-dev.1791.1 → 3.2.0-dev.1797.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/components/app/App.js +33 -0
  2. package/components/elements/display/DocumentationButton.js +9 -2
  3. package/components/elements/display/DocumentationButton.test.js +12 -2
  4. package/components/elements/display/Markdown.js +6 -0
  5. package/components/elements/hit/HitBanner.js +23 -2
  6. package/components/elements/hit/HitBanner.test.js +31 -0
  7. package/components/hooks/useMyPreferences.js +21 -0
  8. package/components/routes/advanced/QueryBuilder.js +3 -24
  9. package/components/routes/advanced/QueryBuilderControls.d.ts +51 -0
  10. package/components/routes/advanced/QueryBuilderControls.js +50 -0
  11. package/components/routes/cases/detail/CaseDetailControls.d.ts +16 -0
  12. package/components/routes/cases/detail/CaseDetailControls.js +19 -0
  13. package/components/routes/cases/detail/CaseDetails.js +4 -20
  14. package/components/routes/cases/detail/CaseRuleRow.d.ts +10 -0
  15. package/components/routes/cases/detail/CaseRuleRow.js +11 -0
  16. package/components/routes/cases/detail/CaseRules.js +4 -7
  17. package/components/routes/cases/detail/CaseSidebar.js +45 -89
  18. package/components/routes/cases/detail/CaseSidebarActions.d.ts +10 -0
  19. package/components/routes/cases/detail/CaseSidebarActions.js +18 -0
  20. package/components/routes/cases/detail/CaseSidebarNavigation.d.ts +49 -0
  21. package/components/routes/cases/detail/CaseSidebarNavigation.js +44 -0
  22. package/components/routes/cases/modals/AddRecordToCaseModal.js +3 -7
  23. package/components/routes/cases/modals/AddToCaseModal.js +3 -10
  24. package/components/routes/cases/modals/CaseItemTypeSelect.d.ts +15 -0
  25. package/components/routes/cases/modals/CaseItemTypeSelect.js +16 -0
  26. package/components/routes/cases/modals/CaseSelector.d.ts +9 -0
  27. package/components/routes/cases/modals/CaseSelector.js +11 -0
  28. package/components/routes/help/AdvancedDocumentation.d.ts +3 -0
  29. package/components/routes/help/AdvancedDocumentation.js +66 -0
  30. package/components/routes/help/AdvancedDocumentation.test.d.ts +1 -0
  31. package/components/routes/help/AdvancedDocumentation.test.js +95 -0
  32. package/components/routes/help/CaseDocumentation.d.ts +3 -0
  33. package/components/routes/help/CaseDocumentation.js +76 -0
  34. package/components/routes/help/CaseDocumentation.test.d.ts +1 -0
  35. package/components/routes/help/CaseDocumentation.test.js +127 -0
  36. package/components/routes/help/DossierDocumentation.d.ts +3 -0
  37. package/components/routes/help/DossierDocumentation.js +94 -0
  38. package/components/routes/help/DossierDocumentation.test.d.ts +1 -0
  39. package/components/routes/help/DossierDocumentation.test.js +90 -0
  40. package/components/routes/help/Help.js +4 -1
  41. package/components/routes/help/Help.test.js +17 -2
  42. package/components/routes/help/components/CaseDocumentationPreviews.d.ts +12 -0
  43. package/components/routes/help/components/CaseDocumentationPreviews.js +127 -0
  44. package/components/routes/help/markdown/en/advancedLanguages.md.js +1 -0
  45. package/components/routes/help/markdown/en/advancedLucene.md.js +1 -0
  46. package/components/routes/help/markdown/en/advancedOverview.md.js +1 -0
  47. package/components/routes/help/markdown/en/advancedResults.md.js +1 -0
  48. package/components/routes/help/markdown/en/casesFolders.md.js +1 -0
  49. package/components/routes/help/markdown/en/casesInvestigation.md.js +1 -0
  50. package/components/routes/help/markdown/en/casesItems.md.js +1 -0
  51. package/components/routes/help/markdown/en/casesOverview.md.js +1 -0
  52. package/components/routes/help/markdown/en/casesRecords.md.js +1 -0
  53. package/components/routes/help/markdown/en/casesRules.md.js +1 -0
  54. package/components/routes/help/markdown/en/casesSidebar.md.js +1 -0
  55. package/components/routes/help/markdown/en/casesSummary.md.js +1 -0
  56. package/components/routes/help/markdown/en/dossiersLeads.md.js +1 -0
  57. package/components/routes/help/markdown/en/dossiersOverview.md.js +1 -0
  58. package/components/routes/help/markdown/en/dossiersPivots.md.js +1 -0
  59. package/components/routes/help/markdown/en/dossiersQuery.md.js +1 -0
  60. package/components/routes/help/markdown/en/dossiersUsage.md.js +1 -0
  61. package/components/routes/help/markdown/fr/advancedLanguages.md.js +1 -0
  62. package/components/routes/help/markdown/fr/advancedLucene.md.js +1 -0
  63. package/components/routes/help/markdown/fr/advancedOverview.md.js +1 -0
  64. package/components/routes/help/markdown/fr/advancedResults.md.js +1 -0
  65. package/components/routes/help/markdown/fr/casesFolders.md.js +1 -0
  66. package/components/routes/help/markdown/fr/casesInvestigation.md.js +1 -0
  67. package/components/routes/help/markdown/fr/casesItems.md.js +1 -0
  68. package/components/routes/help/markdown/fr/casesOverview.md.js +1 -0
  69. package/components/routes/help/markdown/fr/casesRecords.md.js +1 -0
  70. package/components/routes/help/markdown/fr/casesRules.md.js +1 -0
  71. package/components/routes/help/markdown/fr/casesSidebar.md.js +1 -0
  72. package/components/routes/help/markdown/fr/casesSummary.md.js +1 -0
  73. package/components/routes/help/markdown/fr/dossiersLeads.md.js +1 -0
  74. package/components/routes/help/markdown/fr/dossiersOverview.md.js +1 -0
  75. package/components/routes/help/markdown/fr/dossiersPivots.md.js +1 -0
  76. package/components/routes/help/markdown/fr/dossiersQuery.md.js +1 -0
  77. package/components/routes/help/markdown/fr/dossiersUsage.md.js +1 -0
  78. package/locales/en/help/main.json +3 -0
  79. package/locales/en/translation.json +27 -0
  80. package/locales/fr/help/main.json +3 -0
  81. package/locales/fr/translation.json +27 -0
  82. package/package.json +1 -1
@@ -41,9 +41,12 @@ import ItemPage from '@cccsaurora/howler-ui/components/routes/cases/detail/ItemP
41
41
  import DossierEditor from '@cccsaurora/howler-ui/components/routes/dossiers/DossierEditor';
42
42
  import Dossiers from '@cccsaurora/howler-ui/components/routes/dossiers/Dossiers';
43
43
  import ActionDocumentation from '@cccsaurora/howler-ui/components/routes/help/ActionDocumentation';
44
+ import AdvancedDocumentation from '@cccsaurora/howler-ui/components/routes/help/AdvancedDocumentation';
44
45
  import ApiDocumentation from '@cccsaurora/howler-ui/components/routes/help/ApiDocumentation';
45
46
  import AuthDocumentation from '@cccsaurora/howler-ui/components/routes/help/AuthDocumentation';
47
+ import CaseDocumentation from '@cccsaurora/howler-ui/components/routes/help/CaseDocumentation';
46
48
  import ClientDocumentation from '@cccsaurora/howler-ui/components/routes/help/ClientDocumentation';
49
+ import DossierDocumentation from '@cccsaurora/howler-ui/components/routes/help/DossierDocumentation';
47
50
  import HelpDashboard from '@cccsaurora/howler-ui/components/routes/help/Help';
48
51
  import HitDocumentation from '@cccsaurora/howler-ui/components/routes/help/HitDocumentation';
49
52
  import NotebookDocumentation from '@cccsaurora/howler-ui/components/routes/help/NotebookDocumentation';
@@ -414,6 +417,16 @@ const createRouter = () => createBrowserRouter([
414
417
  ]
415
418
  }
416
419
  },
420
+ {
421
+ path: 'help/advanced',
422
+ element: _jsx(AdvancedDocumentation, {}),
423
+ handle: {
424
+ breadcrumb: (match) => [
425
+ crumb('/help', 'route.help', _jsx(Help, {})),
426
+ selfCrumb(match, 'route.help.advanced', _jsx(Code, {}))
427
+ ]
428
+ }
429
+ },
417
430
  {
418
431
  path: 'help/api',
419
432
  element: _jsx(ApiDocumentation, {}),
@@ -444,6 +457,26 @@ const createRouter = () => createBrowserRouter([
444
457
  ]
445
458
  }
446
459
  },
460
+ {
461
+ path: 'help/cases',
462
+ element: _jsx(CaseDocumentation, {}),
463
+ handle: {
464
+ breadcrumb: (match) => [
465
+ crumb('/help', 'route.help', _jsx(Help, {})),
466
+ selfCrumb(match, 'route.help.cases', _jsx(BookRounded, {}))
467
+ ]
468
+ }
469
+ },
470
+ {
471
+ path: 'help/dossiers',
472
+ element: _jsx(DossierDocumentation, {}),
473
+ handle: {
474
+ breadcrumb: (match) => [
475
+ crumb('/help', 'route.help', _jsx(Help, {})),
476
+ selfCrumb(match, 'route.help.dossiers', _jsx(Topic, {}))
477
+ ]
478
+ }
479
+ },
447
480
  {
448
481
  path: 'help/hit',
449
482
  element: _jsx(HitDocumentation, {}),
@@ -8,14 +8,21 @@ const DocumentationButton = () => {
8
8
  const { t } = useTranslation();
9
9
  const location = useLocation();
10
10
  const [link, i18nKey] = useMemo(() => {
11
+ if (location.pathname === '/advanced') {
12
+ return ['/help/advanced', 'documentation.open.advanced'];
13
+ }
14
+ if (location.pathname === '/cases' || location.pathname.startsWith('/cases/')) {
15
+ return ['/help/cases', 'documentation.open.cases'];
16
+ }
17
+ if (location.pathname === '/dossiers' || location.pathname.startsWith('/dossiers/')) {
18
+ return ['/help/dossiers', 'documentation.open.dossiers'];
19
+ }
11
20
  switch (location.pathname) {
12
21
  case '/action': {
13
22
  return ['/help/actions', 'documentation.open.actions'];
14
23
  }
15
24
  case '/search':
16
- case '/advanced': {
17
25
  return ['/help/search', 'documentation.open.search'];
18
- }
19
26
  case '/views':
20
27
  case '/views/create': {
21
28
  return ['/help/views', 'documentation.open.views'];
@@ -31,10 +31,20 @@ describe('DocumentationButton', () => {
31
31
  const link = screen.getByRole('link');
32
32
  expect(link).toHaveAttribute('href', '/help/search');
33
33
  });
34
- it('renders a link to /help/search on /advanced', () => {
34
+ it('renders a link to /help/advanced on /advanced', () => {
35
35
  renderAt('/advanced');
36
36
  const link = screen.getByRole('link');
37
- expect(link).toHaveAttribute('href', '/help/search');
37
+ expect(link).toHaveAttribute('href', '/help/advanced');
38
+ });
39
+ it('renders a link to /help/cases on a case route', () => {
40
+ renderAt('/cases/example-case/timeline');
41
+ const link = screen.getByRole('link');
42
+ expect(link).toHaveAttribute('href', '/help/cases');
43
+ });
44
+ it('renders a link to /help/dossiers on a dossier editor route', () => {
45
+ renderAt('/dossiers/example-dossier/edit');
46
+ const link = screen.getByRole('link');
47
+ expect(link).toHaveAttribute('href', '/help/dossiers');
38
48
  });
39
49
  it('renders a link to /help/views on /views', () => {
40
50
  renderAt('/views');
@@ -121,6 +121,12 @@ const Markdown = ({ md, components = {}, disableLinks = false }) => {
121
121
  td({ children, ...props }) {
122
122
  return _jsx(TableCell, { style: props.style, children: children });
123
123
  },
124
+ p({ children, node }) {
125
+ const containsMappedComponent = node?.children.some(child => child.type === 'element' &&
126
+ child.tagName === 'code' &&
127
+ child.children.some(codeChild => codeChild.type === 'text' && Object.prototype.hasOwnProperty.call(components, codeChild.value)));
128
+ return containsMappedComponent ? _jsx("div", { children: children }) : _jsx("p", { children: children });
129
+ },
124
130
  a({ children, ...props }) {
125
131
  if (!props.href) {
126
132
  return _jsx("a", { ...props, children: children });
@@ -15,6 +15,15 @@ import HitTimestamp from './elements/HitTimestamp';
15
15
  import HitBannerTooltip from './HitBannerTooltip';
16
16
  import { HitLayout } from './HitLayout';
17
17
  import RelatedRecords from './related/RelatedRecords';
18
+ const isHttpUrl = (value) => {
19
+ try {
20
+ const { protocol } = new URL(value);
21
+ return protocol === 'http:' || protocol === 'https:';
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ };
18
27
  const Wrapper = ({ compressed, hit, textVariant, i18nKey, value, field, ...typographyProps }) => {
19
28
  const { t } = useTranslation();
20
29
  const children = (_jsxs(Stack, { direction: "row", spacing: 1, flex: 1, sx: { lineHeight: '20px', '& .iconify': { maxHeight: '20px' } }, children: [_jsxs(Typography, { variant: textVariant, noWrap: compressed, fontWeight: "bold", textOverflow: compressed ? 'ellipsis' : 'wrap', ...typographyProps, sx: [
@@ -30,8 +39,20 @@ const HitBanner = ({ hit, lazy = false, layout = HitLayout.NORMAL, showAssigned
30
39
  const compressed = useMemo(() => layout === HitLayout.DENSE, [layout]);
31
40
  const textVariant = useMemo(() => (layout === HitLayout.COMFY ? 'body1' : 'caption'), [layout]);
32
41
  const providerColor = getProviderColor(hit?.event?.provider);
33
- return (_jsx(Box, { sx: { width: '100%', ml: 0, overflow: 'hidden', color: 'text.primary' }, children: _jsxs(Stack, { spacing: layout !== HitLayout.COMFY ? 0.25 : 1, children: [_jsxs(Stack, { direction: "row", spacing: 0.5, flexWrap: "wrap", alignItems: "center", children: [_jsx(HitBannerTooltip, { hit: hit, children: _jsx(Chip, { sx: { backgroundColor: providerColor, color: theme.palette.getContrastText(providerColor) }, label: hit.organization?.name ?? _jsx(Trans, { i18nKey: "unknown" }) }) }), _jsx(AnalyticLink, { lazy: lazy, hit: hit }), _jsx("div", { style: { flex: 1 } }), _jsx(EscalationChip, { hit: hit, layout: layout }), ['in-progress', 'on-hold'].includes(hit.howler.status ?? '') && (_jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, color: "primary" })), _jsx(HitTimestamp, { hit: hit, layout: layout }), _jsx(Assigned, { hit: hit, layout: layout, showAssigned: showAssigned }), (hit.howler.related?.length ?? 0) > 0 && _jsx(RelatedRecords, { hit: hit }), howlerPluginStore.plugins.flatMap(plugin => (_jsx(Fragment, { children: pluginStore.executeFunction(`${plugin}.status`, { hit, layout }) }, plugin)))] }), hit.howler?.rationale && (_jsx(Wrapper, { fontWeight: "bold", color: getEscalationColor(hit.howler.escalation) + '.main', compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.rationale", value: hit.howler.rationale, field: "howler.rationale" })), hit.howler?.outline && (_jsxs(_Fragment, { children: [hit.howler.outline.threat && (_jsx(Wrapper, { compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.threat", value: hit.howler.outline.threat, field: "howler.outline.threat" })), hit.howler.outline.target && (_jsx(Wrapper, { compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.target", value: hit.howler.outline.target, field: "howler.outline.target" })), (hit.howler.outline.indicators?.length ?? 0) > 0 && (_jsxs(Stack, { direction: "row", spacing: layout !== HitLayout.COMFY ? 0.25 : 1, children: [_jsxs(Typography, { component: "span", variant: textVariant, fontWeight: "bold", pr: 1, children: [t('hit.header.indicators'), ":"] }), _jsx(Grid, { container: true, spacing: 0.5, children: uniq(hit.howler.outline.indicators ?? []).map((_indicator, index) => {
34
- return (_jsx(Grid, { children: _jsxs(Stack, { direction: "row", children: [_jsx(PluginTypography, { context: "indicators", variant: textVariant, value: _indicator, children: _indicator }), index < (hit.howler.outline?.indicators?.length ?? 0) - 1 && (_jsx(Typography, { variant: textVariant, children: ',' }))] }) }, _indicator));
42
+ const indicators = uniq(hit.howler.outline?.indicators ?? []);
43
+ return (_jsx(Box, { sx: { width: '100%', ml: 0, overflow: 'hidden', color: 'text.primary' }, children: _jsxs(Stack, { spacing: layout !== HitLayout.COMFY ? 0.25 : 1, children: [_jsxs(Stack, { direction: "row", spacing: 0.5, flexWrap: "wrap", alignItems: "center", children: [_jsx(HitBannerTooltip, { hit: hit, children: _jsx(Chip, { sx: { backgroundColor: providerColor, color: theme.palette.getContrastText(providerColor) }, label: hit.organization?.name ?? _jsx(Trans, { i18nKey: "unknown" }) }) }), _jsx(AnalyticLink, { lazy: lazy, hit: hit }), _jsx("div", { style: { flex: 1 } }), _jsx(EscalationChip, { hit: hit, layout: layout }), ['in-progress', 'on-hold'].includes(hit.howler.status ?? '') && (_jsx(Chip, { sx: { width: 'fit-content', display: 'inline-flex' }, label: hit.howler.status, color: "primary" })), _jsx(HitTimestamp, { hit: hit, layout: layout }), _jsx(Assigned, { hit: hit, layout: layout, showAssigned: showAssigned }), (hit.howler.related?.length ?? 0) > 0 && _jsx(RelatedRecords, { hit: hit }), howlerPluginStore.plugins.flatMap(plugin => (_jsx(Fragment, { children: pluginStore.executeFunction(`${plugin}.status`, { hit, layout }) }, plugin)))] }), hit.howler?.rationale && (_jsx(Wrapper, { fontWeight: "bold", color: getEscalationColor(hit.howler.escalation) + '.main', compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.rationale", value: hit.howler.rationale, field: "howler.rationale" })), hit.howler?.outline && (_jsxs(_Fragment, { children: [hit.howler.outline.threat && (_jsx(Wrapper, { compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.threat", value: hit.howler.outline.threat, field: "howler.outline.threat" })), hit.howler.outline.target && (_jsx(Wrapper, { compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.target", value: hit.howler.outline.target, field: "howler.outline.target" })), indicators.length > 0 && (_jsxs(Stack, { direction: "row", spacing: layout !== HitLayout.COMFY ? 0.25 : 1, sx: { minWidth: 0 }, children: [_jsxs(Typography, { component: "span", variant: textVariant, fontWeight: "bold", pr: 1, children: [t('hit.header.indicators'), ":"] }), _jsx(Grid, { container: true, spacing: 0.5, sx: { flex: 1, minWidth: 0 }, children: indicators.map((indicator, index) => {
44
+ const isUrl = isHttpUrl(indicator);
45
+ const indicatorValue = (_jsx(Box, { tabIndex: isUrl ? 0 : undefined, sx: { minWidth: 0, maxWidth: '100%' }, children: _jsx(PluginTypography, { context: "indicators", variant: textVariant, value: indicator, sx: isUrl
46
+ ? {
47
+ display: '-webkit-box',
48
+ overflow: 'hidden',
49
+ overflowWrap: 'anywhere',
50
+ textOverflow: 'ellipsis',
51
+ WebkitBoxOrient: 'vertical',
52
+ WebkitLineClamp: 2
53
+ }
54
+ : { overflowWrap: 'anywhere' }, children: indicator }) }));
55
+ return (_jsx(Grid, { sx: { flexBasis: '100%', minWidth: 0, maxWidth: '100%' }, children: _jsxs(Stack, { direction: "row", sx: { minWidth: 0 }, children: [isUrl ? _jsx(Tooltip, { title: indicator, children: indicatorValue }) : indicatorValue, index < indicators.length - 1 && _jsx(Typography, { variant: textVariant, children: ',' })] }) }, indicator));
35
56
  }) })] })), hit.howler.outline.summary && (_jsx(Wrapper, { compressed: compressed, hit: hit, textVariant: textVariant, i18nKey: "hit.header.summary", value: hit.howler.outline.summary, textOverflow: "wrap", sx: [compressed && { marginTop: `0 !important` }], field: "howler.outline.summary" })), hit.howler.links?.[0]?.href && (_jsx(Chip, { icon: _jsx(OpenInNew, {}), label: hit.howler.links[0].title || t('hit.header.link'), size: layout !== HitLayout.COMFY ? 'small' : 'medium', component: "a", href: hit.howler.links[0].href, target: "_blank", rel: "noopener noreferrer", sx: { [`.${chipClasses.label}`]: { cursor: 'pointer !important' }, alignSelf: 'start' }, onClick: e => {
36
57
  e.stopPropagation();
37
58
  } }))] }))] }) }));
@@ -130,6 +130,37 @@ describe('HitBanner', () => {
130
130
  expect(screen.getByText('Summary value')).toBeInTheDocument();
131
131
  expect(screen.getByRole('link', { name: 'Open source link' })).toHaveAttribute('href', 'https://example.com');
132
132
  });
133
+ it('truncates HTTP indicator URLs and makes their tooltip keyboard reachable', async () => {
134
+ const user = userEvent.setup();
135
+ const indicator = 'https://example.example.com/v2/r03/__https://example.example.com/sites/security/documents/very-long-document-name?query=very-long-value-example';
136
+ const hit = createBannerHit({
137
+ howler: {
138
+ ...createBannerHit().howler,
139
+ outline: { ...createBannerHit().howler.outline, indicators: [indicator] }
140
+ }
141
+ });
142
+ renderHitBanner({ hit });
143
+ const indicatorText = screen.getByText(indicator);
144
+ expect(indicatorText).toHaveStyle({ WebkitLineClamp: '2', overflow: 'hidden', textOverflow: 'ellipsis' });
145
+ const indicatorWrapper = indicatorText.closest('[tabindex="0"]');
146
+ expect(indicatorWrapper).toBeInTheDocument();
147
+ await user.tab();
148
+ expect(indicatorWrapper).toHaveFocus();
149
+ await user.hover(indicatorText);
150
+ expect(await screen.findByRole('tooltip')).toHaveTextContent(indicator);
151
+ });
152
+ it('wraps non-URL indicators and does not add a tooltip', () => {
153
+ const indicator = 'a-very-long-unbroken-indicator-value';
154
+ const hit = createBannerHit({
155
+ howler: {
156
+ ...createBannerHit().howler,
157
+ outline: { ...createBannerHit().howler.outline, indicators: [indicator] }
158
+ }
159
+ });
160
+ renderHitBanner({ hit });
161
+ expect(screen.getByText(indicator)).toHaveStyle({ overflowWrap: 'anywhere' });
162
+ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
163
+ });
133
164
  it.each(['in-progress', 'on-hold'])('renders the status chip for %s', status => {
134
165
  const hit = createBannerHit({ howler: { ...createBannerHit().howler, status } });
135
166
  renderHitBanner({ hit });
@@ -137,7 +137,21 @@ const useMyPreferences = () => {
137
137
  route: '/help/client',
138
138
  icon: _jsx(Terminal, {})
139
139
  },
140
+ {
141
+ id: 'help.dossiers',
142
+ type: 'route',
143
+ i18nKey: 'route.help.dossiers',
144
+ route: '/help/dossiers',
145
+ icon: _jsx(Topic, {})
146
+ },
140
147
  { id: 'help.hit', type: 'route', i18nKey: 'route.help.hit', route: '/help/hit', icon: _jsx(Shield, {}) },
148
+ {
149
+ id: 'help.cases',
150
+ type: 'route',
151
+ i18nKey: 'route.help.cases',
152
+ route: '/help/cases',
153
+ icon: _jsx(BookRounded, {})
154
+ },
141
155
  {
142
156
  id: 'help.search',
143
157
  type: 'route',
@@ -145,6 +159,13 @@ const useMyPreferences = () => {
145
159
  route: '/help/search',
146
160
  icon: _jsx(Search, {})
147
161
  },
162
+ {
163
+ id: 'help.advanced',
164
+ type: 'route',
165
+ i18nKey: 'route.help.advanced',
166
+ route: '/help/advanced',
167
+ icon: _jsx(Code, {})
168
+ },
148
169
  {
149
170
  id: 'help.views',
150
171
  type: 'route',
@@ -1,24 +1,19 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /* eslint-disable no-useless-escape */
3
3
  import { useMonaco } from '@monaco-editor/react';
4
- import { OpenInNew, PlayArrowOutlined } from '@mui/icons-material';
5
- import { Alert, AlertTitle, Autocomplete, Box, Card, Checkbox, Chip, CircularProgress, FormControlLabel, IconButton, ListItemText, Slider, Stack, TextField, Tooltip, Typography, useMediaQuery, useTheme } from '@mui/material';
6
- import Popper, {} from '@mui/material/Popper';
4
+ import { Alert, AlertTitle, Box, Stack, Typography, useMediaQuery, useTheme } from '@mui/material';
7
5
  import { PageCenter, parseEvent } from '@tui/core';
8
6
  import api from '@cccsaurora/howler-ui/api';
9
7
  import { FieldContext } from '@cccsaurora/howler-ui/components/app/providers/FieldProvider';
10
- import CustomButton from '@cccsaurora/howler-ui/components/elements/addons/buttons/CustomButton';
11
8
  import FlexOne from '@cccsaurora/howler-ui/components/elements/addons/layout/FlexOne';
12
9
  import JSONViewer from '@cccsaurora/howler-ui/components/elements/display/json/JSONViewer';
13
10
  import dayjs from 'dayjs';
14
11
  import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
15
12
  import { useTranslation } from 'react-i18next';
16
- import { Link } from 'react-router';
17
13
  import { sanitizeMultilineLucene } from '@cccsaurora/howler-ui/utils/stringUtils';
18
14
  import { v4 as uuid } from 'uuid';
15
+ import { ExecuteQueryButton, FieldsControl, GroupByFieldSelect, LuceneQueryTypeSelect, OpenInSearchButton, QueryLanguageSelect, RowsControl, STEPS } from './QueryBuilderControls';
19
16
  import QueryEditor from './QueryEditor';
20
- const QUERY_TYPES = ['eql', 'lucene', 'yaml'];
21
- const STEPS = [1, 5, 25, 50, 100, 250, 500, 1000, 2500, 10000];
22
17
  const DEFAULT_VALUES = {
23
18
  eql: `sequence with maxspan=30m
24
19
  [ process where process.name == "regsvr32.exe" ]
@@ -58,19 +53,9 @@ falsepositives:
58
53
  level: informational
59
54
  `
60
55
  };
61
- const LUCENE_QUERY_OPTIONS = [
62
- 'default',
63
- 'facet',
64
- 'groupby',
65
- 'explain'
66
- ];
67
- const CustomPopper = (props) => {
68
- return _jsx(Popper, { ...props, style: { width: 'fit-content' }, placement: "bottom-start" });
69
- };
70
56
  const QueryBuilder = () => {
71
57
  const { t } = useTranslation();
72
58
  const theme = useTheme();
73
- const smallButtons = useMediaQuery('(max-width:1150px)');
74
59
  const compactLayout = useMediaQuery('(max-width:870px)');
75
60
  const monaco = useMonaco();
76
61
  const { hitFields, getHitFields } = useContext(FieldContext);
@@ -211,13 +196,7 @@ const QueryBuilder = () => {
211
196
  display: 'flex',
212
197
  alignSelf: 'stretch'
213
198
  }
214
- }, children: [smallButtons ? (_jsx(Tooltip, { title: t('route.actions.execute'), children: _jsx(IconButton, { size: "small", sx: { alignSelf: 'start' }, color: "success", onClick: execute, disabled: searchDisabled, children: loading ? (_jsx(CircularProgress, { size: 18, color: "success" })) : (_jsx(PlayArrowOutlined, { color: searchDisabled ? 'disabled' : 'success' })) }) })) : (_jsx(CustomButton, { size: "small", variant: "outlined", startIcon: loading ? (_jsx(CircularProgress, { size: 18, color: "success" })) : (_jsx(PlayArrowOutlined, { color: searchDisabled ? 'disabled' : 'success', sx: { '& path': { stroke: 'currentcolor', strokeWidth: '1px' } } })), color: "success", onClick: execute, disabled: searchDisabled, children: t('route.actions.execute') })), _jsxs(Stack, { direction: compactLayout ? 'column' : 'row', spacing: 1, children: [_jsx(Autocomplete, { value: type, onChange: (__, value) => setType(value), options: QUERY_TYPES, getOptionLabel: option => t(`route.advanced.query.${option}`), renderOption: (props, option) => (_jsx(ListItemText, { ...props, sx: { flexDirection: 'column', alignItems: 'start !important' }, primary: t(`route.advanced.query.${option}`), secondary: t(`route.advanced.query.${option}.description`) })), renderInput: params => (_jsx(TextField, { ...params, size: "small", label: t('route.advanced.query.type'), sx: { minWidth: '250px' } })), sx: [
215
- !compactLayout && {
216
- height: '100%',
217
- '& .MuiFormControl-root': { height: '100%', '& > div': { height: '100%' } }
218
- }
219
- ], slotProps: { paper: { sx: { minWidth: '600px' } } } }), _jsx(Card, { variant: "outlined", sx: { flex: 1, maxWidth: '350px', minWidth: '210px' }, children: _jsxs(Stack, { spacing: 0.5, sx: { px: 1, alignItems: 'start' }, children: [_jsxs(Typography, { variant: "caption", color: "text.secondary", sx: { whiteSpace: 'nowrap' }, children: [t('route.advanced.rows'), ": ", STEPS[rows]] }), _jsx(Slider, { size: "small", valueLabelDisplay: "off", value: rows, onChange: (_, value) => setRows(value), min: 0, max: 9, step: 1, marks: true, track: false, sx: { py: 0.5 } })] }) })] }), type === 'lucene' && (_jsx(Autocomplete, { size: "small", getOptionLabel: opt => t(`route.advanced.query.type.${opt}`), options: LUCENE_QUERY_OPTIONS, value: queryType, onChange: (_event, value) => setQueryType(value ?? 'default'), renderInput: params => (_jsx(TextField, { ...params, label: t('route.advanced.query.lucene.type'), sx: { minWidth: '230px' } })), renderOption: (props, option) => (_jsx(ListItemText, { ...props, sx: { flexDirection: 'column', alignItems: 'start !important' }, primary: t(`route.advanced.query.type.${option}`), secondary: t(`route.advanced.query.type.${option}.description`) })) })), queryType === 'groupby' && (_jsx(Autocomplete, { size: "small", options: fieldOptions, value: groupByField, onChange: (__, value) => setGroupByField(value ?? ''), renderInput: params => _jsx(TextField, { ...params, label: t('route.advanced.pivot.field') }), sx: { minWidth: '200px', '& label': { zIndex: 1200 } }, onKeyDown: onKeyDown, PopperComponent: CustomPopper })), allFields && queryType !== 'facet' ? (_jsx(FormControlLabel, { control: _jsx(Checkbox, { size: "small", checked: allFields, onChange: (__, checked) => setAllFields(checked) }), label: t('route.advanced.fields.all'), sx: { '& > span': { color: 'text.secondary' }, alignSelf: 'start' } })) : (_jsx(Autocomplete, { fullWidth: true, renderTags: values => values.length <= 3 ? (_jsx(Stack, { direction: "row", spacing: 0.5, children: values.map(_value => (_jsx(Chip, { label: _value }, _value))) })) : (_jsx(Tooltip, { title: _jsx(Stack, { spacing: 1, children: values.map(_value => (_jsx("span", { children: _value }, _value))) }), children: _jsx(Chip, { label: values.length }) })), multiple: true, size: "small", options: fieldOptions, value: fields, onChange: (__, values) => (values.length > 0 ? setFields(values) : setAllFields(true)), renderInput: params => _jsx(TextField, { ...params, label: t('route.advanced.fields') }), sx: { maxWidth: '500px', width: '20vw', minWidth: '200px', '& label': { zIndex: 1200 } }, onKeyDown: onKeyDown, slots: { popper: CustomPopper } })), _jsx(FlexOne, {}), type === 'lucene' &&
220
- (smallButtons ? (_jsx(Tooltip, { title: t('route.advanced.open'), children: _jsx(IconButton, { color: "primary", sx: { alignSelf: 'center' }, component: Link, disabled: !response, to: `/hits?query=${sanitizeMultilineLucene(query).replaceAll('\n', ' ').trim()}`, children: _jsx(OpenInNew, { fontSize: "small" }) }) })) : (_jsx(CustomButton, { size: "small", variant: "outlined", startIcon: _jsx(OpenInNew, {}), component: Link, disabled: !response, ...{ to: `/hits?query=${sanitizeMultilineLucene(query).replaceAll('\n', ' ').trim()}` }, children: t('route.advanced.open') })))] }), _jsxs(Box, { width: "100%", height: "calc(100vh - 112px)", sx: { position: 'relative', overflow: 'hidden', borderTop: `thin solid ${theme.palette.divider}` }, children: [_jsx(Box, { sx: {
199
+ }, children: [_jsx(ExecuteQueryButton, { loading: loading, searchDisabled: searchDisabled, onExecute: execute }), _jsxs(Stack, { direction: compactLayout ? 'column' : 'row', spacing: 1, children: [_jsx(QueryLanguageSelect, { value: type, onChange: setType, compactLayout: compactLayout }), _jsx(RowsControl, { value: rows, onChange: setRows })] }), type === 'lucene' && _jsx(LuceneQueryTypeSelect, { value: queryType, onChange: setQueryType }), queryType === 'groupby' && (_jsx(GroupByFieldSelect, { options: fieldOptions, value: groupByField, onChange: setGroupByField, onKeyDown: onKeyDown })), _jsx(FieldsControl, { allFields: allFields, onAllFieldsChange: setAllFields, queryType: queryType, fieldOptions: fieldOptions, fields: fields, onFieldsChange: setFields, onKeyDown: onKeyDown }), _jsx(FlexOne, {}), type === 'lucene' && _jsx(OpenInSearchButton, { query: query, hasResponse: !!response })] }), _jsxs(Box, { width: "100%", height: "calc(100vh - 112px)", sx: { position: 'relative', overflow: 'hidden', borderTop: `thin solid ${theme.palette.divider}` }, children: [_jsx(Box, { sx: {
221
200
  position: 'absolute',
222
201
  top: 0,
223
202
  left: 0,
@@ -0,0 +1,51 @@
1
+ import type { FC, KeyboardEventHandler } from 'react';
2
+ export declare const QUERY_TYPES: readonly ['eql', 'lucene', 'yaml'];
3
+ export type QueryLanguage = (typeof QUERY_TYPES)[number];
4
+ export declare const LUCENE_QUERY_OPTIONS: readonly ['default', 'facet', 'groupby', 'explain'];
5
+ export type LuceneQueryType = (typeof LUCENE_QUERY_OPTIONS)[number];
6
+ export declare const STEPS: number[];
7
+ interface ExecuteQueryButtonProps {
8
+ loading: boolean;
9
+ searchDisabled: boolean;
10
+ onExecute: () => void;
11
+ }
12
+ export declare const ExecuteQueryButton: FC<ExecuteQueryButtonProps>;
13
+ interface QueryLanguageSelectProps {
14
+ value: QueryLanguage;
15
+ onChange: (language: QueryLanguage) => void;
16
+ compactLayout: boolean;
17
+ }
18
+ export declare const QueryLanguageSelect: FC<QueryLanguageSelectProps>;
19
+ interface RowsControlProps {
20
+ value: number;
21
+ onChange: (rows: number) => void;
22
+ }
23
+ export declare const RowsControl: FC<RowsControlProps>;
24
+ interface LuceneQueryTypeSelectProps {
25
+ value: LuceneQueryType;
26
+ onChange: (queryType: LuceneQueryType) => void;
27
+ }
28
+ export declare const LuceneQueryTypeSelect: FC<LuceneQueryTypeSelectProps>;
29
+ interface GroupByFieldSelectProps {
30
+ options: string[];
31
+ value: string;
32
+ onChange: (field: string) => void;
33
+ onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
34
+ }
35
+ export declare const GroupByFieldSelect: FC<GroupByFieldSelectProps>;
36
+ interface FieldsControlProps {
37
+ allFields: boolean;
38
+ onAllFieldsChange: (checked: boolean) => void;
39
+ queryType: LuceneQueryType;
40
+ fieldOptions: string[];
41
+ fields: string[];
42
+ onFieldsChange: (fields: string[]) => void;
43
+ onKeyDown?: KeyboardEventHandler<HTMLDivElement>;
44
+ }
45
+ export declare const FieldsControl: FC<FieldsControlProps>;
46
+ interface OpenInSearchButtonProps {
47
+ query: string;
48
+ hasResponse: boolean;
49
+ }
50
+ export declare const OpenInSearchButton: FC<OpenInSearchButtonProps>;
51
+ export {};
@@ -0,0 +1,50 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { OpenInNew, PlayArrowOutlined } from '@mui/icons-material';
3
+ import { Autocomplete, Card, Checkbox, Chip, CircularProgress, FormControlLabel, IconButton, ListItemText, Slider, Stack, TextField, Tooltip, Typography, useMediaQuery } from '@mui/material';
4
+ import Popper, {} from '@mui/material/Popper';
5
+ import CustomButton from '@cccsaurora/howler-ui/components/elements/addons/buttons/CustomButton';
6
+ import { useTranslation } from 'react-i18next';
7
+ import { Link } from 'react-router';
8
+ import { sanitizeMultilineLucene } from '@cccsaurora/howler-ui/utils/stringUtils';
9
+ export const QUERY_TYPES = ['eql', 'lucene', 'yaml'];
10
+ export const LUCENE_QUERY_OPTIONS = ['default', 'facet', 'groupby', 'explain'];
11
+ export const STEPS = [1, 5, 25, 50, 100, 250, 500, 1000, 2500, 10000];
12
+ const CustomPopper = (props) => {
13
+ return _jsx(Popper, { ...props, style: { width: 'fit-content' }, placement: "bottom-start" });
14
+ };
15
+ export const ExecuteQueryButton = ({ loading, searchDisabled, onExecute }) => {
16
+ const { t } = useTranslation();
17
+ const smallButtons = useMediaQuery('(max-width:1150px)');
18
+ return smallButtons ? (_jsx(Tooltip, { title: t('route.actions.execute'), children: _jsx(IconButton, { size: "small", sx: { alignSelf: 'start' }, color: "success", onClick: onExecute, disabled: searchDisabled, children: loading ? (_jsx(CircularProgress, { size: 18, color: "success" })) : (_jsx(PlayArrowOutlined, { color: searchDisabled ? 'disabled' : 'success' })) }) })) : (_jsx(CustomButton, { size: "small", variant: "outlined", startIcon: loading ? (_jsx(CircularProgress, { size: 18, color: "success" })) : (_jsx(PlayArrowOutlined, { color: searchDisabled ? 'disabled' : 'success', sx: { '& path': { stroke: 'currentcolor', strokeWidth: '1px' } } })), color: "success", onClick: onExecute, disabled: searchDisabled, children: t('route.actions.execute') }));
19
+ };
20
+ export const QueryLanguageSelect = ({ value, onChange, compactLayout }) => {
21
+ const { t } = useTranslation();
22
+ return (_jsx(Autocomplete, { value: value, onChange: (__, nextValue) => onChange(nextValue), options: QUERY_TYPES, getOptionLabel: option => t(`route.advanced.query.${option}`), renderOption: (props, option) => (_jsx(ListItemText, { ...props, sx: { flexDirection: 'column', alignItems: 'start !important' }, primary: t(`route.advanced.query.${option}`), secondary: t(`route.advanced.query.${option}.description`) })), renderInput: params => (_jsx(TextField, { ...params, size: "small", label: t('route.advanced.query.type'), sx: { minWidth: '250px' } })), sx: [
23
+ !compactLayout && {
24
+ height: '100%',
25
+ '& .MuiFormControl-root': { height: '100%', '& > div': { height: '100%' } }
26
+ }
27
+ ], slotProps: { paper: { sx: { minWidth: '600px' } } } }));
28
+ };
29
+ export const RowsControl = ({ value, onChange }) => {
30
+ const { t } = useTranslation();
31
+ return (_jsx(Card, { variant: "outlined", sx: { flex: 1, maxWidth: '350px', minWidth: '210px' }, children: _jsxs(Stack, { spacing: 0.5, sx: { px: 1, alignItems: 'start' }, children: [_jsxs(Typography, { variant: "caption", color: "text.secondary", sx: { whiteSpace: 'nowrap' }, children: [t('route.advanced.rows'), ": ", STEPS[value]] }), _jsx(Slider, { size: "small", valueLabelDisplay: "off", value: value, onChange: (_, nextValue) => onChange(nextValue), min: 0, max: 9, step: 1, marks: true, track: false, sx: { py: 0.5 } })] }) }));
32
+ };
33
+ export const LuceneQueryTypeSelect = ({ value, onChange }) => {
34
+ const { t } = useTranslation();
35
+ return (_jsx(Autocomplete, { size: "small", getOptionLabel: option => t(`route.advanced.query.type.${option}`), options: LUCENE_QUERY_OPTIONS, value: value, onChange: (_, nextValue) => onChange(nextValue ?? 'default'), renderInput: params => (_jsx(TextField, { ...params, label: t('route.advanced.query.lucene.type'), sx: { minWidth: '230px' } })), renderOption: (props, option) => (_jsx(ListItemText, { ...props, sx: { flexDirection: 'column', alignItems: 'start !important' }, primary: t(`route.advanced.query.type.${option}`), secondary: t(`route.advanced.query.type.${option}.description`) })) }));
36
+ };
37
+ export const GroupByFieldSelect = ({ options, value, onChange, onKeyDown }) => {
38
+ const { t } = useTranslation();
39
+ return (_jsx(Autocomplete, { size: "small", options: options, value: value, onChange: (__, nextValue) => onChange(nextValue ?? ''), renderInput: params => _jsx(TextField, { ...params, label: t('route.advanced.pivot.field') }), sx: { minWidth: '200px', '& label': { zIndex: 1200 } }, onKeyDown: onKeyDown, PopperComponent: CustomPopper }));
40
+ };
41
+ export const FieldsControl = ({ allFields, onAllFieldsChange, queryType, fieldOptions, fields, onFieldsChange, onKeyDown }) => {
42
+ const { t } = useTranslation();
43
+ return allFields && queryType !== 'facet' ? (_jsx(FormControlLabel, { control: _jsx(Checkbox, { size: "small", checked: allFields, onChange: (__, checked) => onAllFieldsChange(checked) }), label: t('route.advanced.fields.all'), sx: { '& > span': { color: 'text.secondary' }, alignSelf: 'start' } })) : (_jsx(Autocomplete, { fullWidth: true, renderTags: values => values.length <= 3 ? (_jsx(Stack, { direction: "row", spacing: 0.5, children: values.map(_value => (_jsx(Chip, { label: _value }, _value))) })) : (_jsx(Tooltip, { title: _jsx(Stack, { spacing: 1, children: values.map(_value => (_jsx("span", { children: _value }, _value))) }), children: _jsx(Chip, { label: values.length }) })), multiple: true, size: "small", options: fieldOptions, value: fields, onChange: (__, values) => (values.length > 0 ? onFieldsChange(values) : onAllFieldsChange(true)), renderInput: params => _jsx(TextField, { ...params, label: t('route.advanced.fields') }), sx: { maxWidth: '500px', width: '20vw', minWidth: '200px', '& label': { zIndex: 1200 } }, onKeyDown: onKeyDown, slots: { popper: CustomPopper } }));
44
+ };
45
+ export const OpenInSearchButton = ({ query, hasResponse }) => {
46
+ const { t } = useTranslation();
47
+ const smallButtons = useMediaQuery('(max-width:1150px)');
48
+ const to = `/hits?query=${sanitizeMultilineLucene(query).replaceAll('\n', ' ').trim()}`;
49
+ return smallButtons ? (_jsx(Tooltip, { title: t('route.advanced.open'), children: _jsx(IconButton, { color: "primary", sx: { alignSelf: 'center' }, component: Link, disabled: !hasResponse, to: to, children: _jsx(OpenInNew, { fontSize: "small" }) }) })) : (_jsx(CustomButton, { size: "small", variant: "outlined", startIcon: _jsx(OpenInNew, {}), component: Link, disabled: !hasResponse, ...{ to }, children: t('route.advanced.open') }));
50
+ };
@@ -0,0 +1,16 @@
1
+ import type { FC } from 'react';
2
+ interface CaseStatusControlProps {
3
+ value?: string;
4
+ options: string[];
5
+ disabled?: boolean;
6
+ onChange: (status: string) => void;
7
+ }
8
+ export declare const CaseStatusControl: FC<CaseStatusControlProps>;
9
+ interface CaseEscalationControlProps {
10
+ value?: string;
11
+ options: string[];
12
+ disabled?: boolean;
13
+ onChange: (escalation: string) => void;
14
+ }
15
+ export declare const CaseEscalationControl: FC<CaseEscalationControlProps>;
16
+ export {};
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Check, HourglassBottom, Pause, TrendingUp, WarningRounded } from '@mui/icons-material';
3
+ import { Autocomplete, Stack, TextField, Typography } from '@mui/material';
4
+ import { useTranslation } from 'react-i18next';
5
+ import { ESCALATION_COLOR_MAP } from '../constants';
6
+ export const CaseStatusControl = ({ value, options, disabled = false, onChange }) => {
7
+ const { t } = useTranslation();
8
+ return (_jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [{
9
+ 'in-progress': _jsx(HourglassBottom, { color: "warning" }),
10
+ 'on-hold': _jsx(Pause, { color: "disabled" }),
11
+ resolved: _jsx(Check, { color: "success" })
12
+ }[value ?? ''] ?? _jsx(WarningRounded, { fontSize: "small" }), _jsx(Typography, { variant: "body1", children: t('page.cases.detail.status') })] }), _jsx(Autocomplete, { size: "small", disabled: disabled, disableClearable: true, value: value, options: options, renderInput: params => _jsx(TextField, { ...params, size: "small" }), onChange: (_ev, status) => status && onChange(status) })] }));
13
+ };
14
+ export const CaseEscalationControl = ({ value, options, disabled = false, onChange }) => {
15
+ const { t } = useTranslation();
16
+ const escalationColor = ESCALATION_COLOR_MAP[value];
17
+ const escalationIconColor = escalationColor === 'default' ? 'inherit' : escalationColor;
18
+ return (_jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(TrendingUp, { color: escalationIconColor }), _jsx(Typography, { variant: "body1", children: t('page.cases.detail.escalation') })] }), _jsx(Autocomplete, { size: "small", disabled: disabled, disableClearable: true, value: value ?? undefined, options: options, renderInput: params => _jsx(TextField, { ...params, size: "small" }), onChange: (_ev, escalation) => escalation && onChange(escalation) })] }));
19
+ };
@@ -1,6 +1,6 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Check, FormatListBulleted, HourglassBottom, Pause, People, TrendingUp, WarningRounded } from '@mui/icons-material';
3
- import { Autocomplete, AvatarGroup, Card, Divider, LinearProgress, Skeleton, Stack, Table, TableBody, TableCell, TableRow, TextField, Typography } from '@mui/material';
2
+ import { FormatListBulleted, People } from '@mui/icons-material';
3
+ import { AvatarGroup, Card, Divider, LinearProgress, Skeleton, Stack, Table, TableBody, TableCell, TableRow, Typography } from '@mui/material';
4
4
  import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
5
5
  import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
6
6
  import { SocketContext } from '@cccsaurora/howler-ui/components/app/providers/SocketProvider';
@@ -10,8 +10,8 @@ import UserList from '@cccsaurora/howler-ui/components/elements/UserList';
10
10
  import dayjs from 'dayjs';
11
11
  import { useContext, useState } from 'react';
12
12
  import { useTranslation } from 'react-i18next';
13
- import { ESCALATION_COLOR_MAP } from '../constants';
14
13
  import useCase from '../hooks/useCase';
14
+ import { CaseEscalationControl, CaseStatusControl } from './CaseDetailControls';
15
15
  import ResolveModal from '../modals/ResolveModal';
16
16
  import SourceAggregate from './aggregates/SourceAggregate';
17
17
  const CaseDetails = ({ case: providedCase }) => {
@@ -51,10 +51,6 @@ const CaseDetails = ({ case: providedCase }) => {
51
51
  p: 1
52
52
  }, children: _jsx(Skeleton, { variant: "rounded", height: 50 }) }));
53
53
  }
54
- // SvgIcon doesn't support the 'default' color, so fall back to 'inherit' (its own default) to keep the same
55
- // visual appearance the invalid value previously produced at runtime.
56
- const escalationColor = ESCALATION_COLOR_MAP[_case.escalation];
57
- const escalationIconColor = escalationColor === 'default' ? 'inherit' : escalationColor;
58
54
  return (_jsxs(Card, { elevation: 1, sx: {
59
55
  borderRadius: 0,
60
56
  width: '300px',
@@ -63,19 +59,7 @@ const CaseDetails = ({ case: providedCase }) => {
63
59
  flexDirection: 'column',
64
60
  p: 1,
65
61
  position: 'relative'
66
- }, children: [_jsx(LinearProgress, { sx: { opacity: +loading, position: 'absolute', top: 0, left: 0, right: 0 } }), _jsxs(Stack, { spacing: 2, children: [_jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [{
67
- 'in-progress': _jsx(HourglassBottom, { color: "warning" }),
68
- 'on-hold': _jsx(Pause, { color: "disabled" }),
69
- resolved: _jsx(Check, { color: "success" })
70
- }[_case.status] ?? _jsx(WarningRounded, { fontSize: "small" }), _jsx(Typography, { variant: "body1", children: t('page.cases.detail.status') })] }), _jsx(Autocomplete, { size: "small", disabled: loading, disableClearable: true, value: _case.status, options: config.lookups?.['howler.status'] ?? [], renderInput: params => _jsx(TextField, { ...params, size: "small" }), onChange: (_ev, status) => {
71
- if (status) {
72
- handleStatus(status);
73
- }
74
- } }), _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(TrendingUp, { color: escalationIconColor }), _jsx(Typography, { variant: "body1", children: t('page.cases.detail.escalation') })] }), _jsx(Autocomplete, { size: "small", disabled: loading, disableClearable: true, value: _case.escalation ?? undefined, options: escalationOptions, renderInput: params => _jsx(TextField, { ...params, size: "small" }), onChange: (_ev, escalation) => {
75
- if (escalation) {
76
- void wrappedUpdate({ escalation });
77
- }
78
- } })] }), _jsx(Divider, {}), _jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(People, {}), _jsx(Typography, { variant: "body1", children: t('page.cases.detail.participants') })] }), _jsxs(Stack, { direction: "row", spacing: 0.5, alignItems: "center", children: [_jsx(UserList, { buttonSx: { alignSelf: 'start' }, multiple: true, i18nLabel: "page.cases.detail.assignment", userIds: _case.participants ?? [], onChange: participants => wrappedUpdate({ participants }), disabled: loading }), _jsx("div", { style: { flex: 1 } })] }), caseViewers.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsxs(Stack, { direction: "row", alignItems: "center", children: [_jsx(SocketBadge, { size: "medium" }), _jsx(Typography, { variant: "body1", children: t('page.cases.detail.viewers') })] }), _jsx(AvatarGroup, { max: 4, sx: { alignSelf: 'start' }, componentsProps: {
62
+ }, children: [_jsx(LinearProgress, { sx: { opacity: +loading, position: 'absolute', top: 0, left: 0, right: 0 } }), _jsxs(Stack, { spacing: 2, children: [_jsxs(Stack, { spacing: 1, children: [_jsx(CaseStatusControl, { value: _case.status, options: config.lookups?.['howler.status'] ?? [], disabled: loading, onChange: handleStatus }), _jsx(CaseEscalationControl, { value: _case.escalation, options: escalationOptions, disabled: loading, onChange: escalation => void wrappedUpdate({ escalation }) })] }), _jsx(Divider, {}), _jsxs(Stack, { spacing: 1, children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(People, {}), _jsx(Typography, { variant: "body1", children: t('page.cases.detail.participants') })] }), _jsxs(Stack, { direction: "row", spacing: 0.5, alignItems: "center", children: [_jsx(UserList, { buttonSx: { alignSelf: 'start' }, multiple: true, i18nLabel: "page.cases.detail.assignment", userIds: _case.participants ?? [], onChange: participants => wrappedUpdate({ participants }), disabled: loading }), _jsx("div", { style: { flex: 1 } })] }), caseViewers.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsxs(Stack, { direction: "row", alignItems: "center", children: [_jsx(SocketBadge, { size: "medium" }), _jsx(Typography, { variant: "body1", children: t('page.cases.detail.viewers') })] }), _jsx(AvatarGroup, { max: 4, sx: { alignSelf: 'start' }, componentsProps: {
79
63
  additionalAvatar: {
80
64
  sx: { height: 32, width: 32, fontSize: '12px' }
81
65
  }
@@ -0,0 +1,10 @@
1
+ import type { Rule } from '@cccsaurora/howler-ui/models/entities/generated/Rule';
2
+ import type { FC } from 'react';
3
+ interface CaseRuleRowProps {
4
+ rule: Rule;
5
+ onToggleEnabled: (enabled: boolean) => void;
6
+ onBackfill: () => void;
7
+ onDelete: () => void;
8
+ }
9
+ declare const CaseRuleRow: FC<CaseRuleRowProps>;
10
+ export default CaseRuleRow;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Delete, History } from '@mui/icons-material';
3
+ import { Chip, IconButton, Stack, Switch, TableCell, TableRow, Tooltip, Typography } from '@mui/material';
4
+ import { useTranslation } from 'react-i18next';
5
+ const CaseRuleRow = ({ rule, onToggleEnabled, onBackfill, onDelete }) => {
6
+ const { t } = useTranslation();
7
+ return (_jsxs(TableRow, { id: `rule-row-${rule.rule_id}`, children: [_jsx(TableCell, { children: _jsx(Typography, { variant: "body2", sx: { fontFamily: 'monospace' }, children: rule.destination }) }), _jsx(TableCell, { children: _jsx(Typography, { variant: "body2", sx: { fontFamily: 'monospace' }, children: rule.query }) }), _jsx(TableCell, { children: _jsx(Stack, { direction: "row", spacing: 0.5, children: (rule.indexes ?? ['hit']).map(index => (_jsx(Chip, { size: "small", label: index, variant: "outlined" }, index))) }) }), _jsx(TableCell, { children: rule.timeframe != null ? (_jsx(Chip, { size: "small", label: rule.expire_after_resolved
8
+ ? t('page.cases.rules.timeframe.after_resolved', { days: rule.timeframe })
9
+ : t('page.cases.rules.timeframe.days', { days: rule.timeframe }), color: rule.expire_after_resolved ? 'info' : 'default' })) : (_jsx(Chip, { size: "small", label: t('page.cases.rules.no_expiry'), color: "success" })) }), _jsx(TableCell, { children: _jsx(Typography, { variant: "body2", children: rule.author }) }), _jsx(TableCell, { align: "center", children: _jsx(Switch, { id: `rule-toggle-${rule.rule_id}`, checked: rule.enabled ?? true, onChange: (_event, checked) => onToggleEnabled(checked), size: "small" }) }), _jsxs(TableCell, { align: "right", children: [_jsx(Tooltip, { title: t('page.cases.rules.backfill'), children: _jsx(IconButton, { id: `rule-backfill-${rule.rule_id}`, size: "small", disabled: rule.enabled === false, onClick: onBackfill, children: _jsx(History, { fontSize: "small" }) }) }), _jsx(Tooltip, { title: t('delete'), children: _jsx(IconButton, { id: `rule-delete-${rule.rule_id}`, size: "small", onClick: onDelete, children: _jsx(Delete, { fontSize: "small" }) }) })] })] }));
10
+ };
11
+ export default CaseRuleRow;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Add, Delete, History } from '@mui/icons-material';
3
- import { Button, Card, Chip, Dialog, DialogActions, DialogContent, DialogTitle, IconButton, Stack, Switch, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip, Typography } from '@mui/material';
2
+ import { Add } from '@mui/icons-material';
3
+ import { Button, Card, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography } from '@mui/material';
4
4
  import { LocalizationProvider } from '@mui/x-date-pickers';
5
5
  import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
6
6
  import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
@@ -14,6 +14,7 @@ import { useTranslation } from 'react-i18next';
14
14
  import { useOutletContext } from 'react-router';
15
15
  import useCase from '../hooks/useCase';
16
16
  import CreateRuleDialog from './CreateRuleDialog';
17
+ import CaseRuleRow from './CaseRuleRow';
17
18
  const CaseRules = ({ case: providedCase, caseId }) => {
18
19
  const { t } = useTranslation();
19
20
  const { dispatchApi } = useMyApi();
@@ -106,11 +107,7 @@ const CaseRules = ({ case: providedCase, caseId }) => {
106
107
  return null;
107
108
  }
108
109
  const rules = _case.rules ?? [];
109
- return (_jsxs(Stack, { spacing: 2, sx: { p: 2, height: '100%', overflow: 'auto' }, children: [_jsx(Button, { id: "create-rule-button", variant: "outlined", startIcon: _jsx(Add, {}), onClick: () => setDialogOpen(true), sx: { alignSelf: 'end' }, children: t('page.cases.rules.create') }), _jsx(Card, { children: rules.length === 0 ? (_jsx(Typography, { m: 2, color: "textSecondary", textAlign: "center", children: t('page.cases.rules.empty') })) : (_jsx(TableContainer, { children: _jsxs(Table, { id: "rules-table", size: "small", children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableCell, { children: t('page.cases.rules.destination') }), _jsx(TableCell, { children: t('page.cases.rules.query') }), _jsx(TableCell, { children: t('hit.search.index') }), _jsx(TableCell, { children: t('page.cases.rules.timeframe') }), _jsx(TableCell, { children: t('page.cases.rules.author') }), _jsx(TableCell, { align: "center", children: t('enabled') }), _jsx(TableCell, { align: "right" })] }) }), _jsx(TableBody, { children: rules.map(rule => (_jsxs(TableRow, { id: `rule-row-${rule.rule_id}`, children: [_jsx(TableCell, { children: _jsx(Typography, { variant: "body2", sx: { fontFamily: 'monospace' }, children: rule.destination }) }), _jsx(TableCell, { children: _jsx(Typography, { variant: "body2", sx: {
110
- fontFamily: 'monospace'
111
- }, children: rule.query }) }), _jsx(TableCell, { children: _jsx(Stack, { direction: "row", spacing: 0.5, children: (rule.indexes ?? ['hit']).map(idx => (_jsx(Chip, { size: "small", label: idx, variant: "outlined" }, idx))) }) }), _jsx(TableCell, { children: rule.timeframe != null ? (_jsx(Chip, { size: "small", label: rule.expire_after_resolved
112
- ? t('page.cases.rules.timeframe.after_resolved', { days: rule.timeframe })
113
- : t('page.cases.rules.timeframe.days', { days: rule.timeframe }), color: rule.expire_after_resolved ? 'info' : 'default' })) : (_jsx(Chip, { size: "small", label: t('page.cases.rules.no_expiry'), color: "success" })) }), _jsx(TableCell, { children: _jsx(Typography, { variant: "body2", children: rule.author }) }), _jsx(TableCell, { align: "center", children: _jsx(Switch, { id: `rule-toggle-${rule.rule_id}`, checked: rule.enabled ?? true, onChange: (_e, checked) => handleToggleEnabled(rule.rule_id, checked), size: "small" }) }), _jsxs(TableCell, { align: "right", children: [_jsx(Tooltip, { title: t('page.cases.rules.backfill'), children: _jsx(IconButton, { id: `rule-backfill-${rule.rule_id}`, size: "small", disabled: rule.enabled === false, onClick: () => handleBackfillDialogOpen(rule), children: _jsx(History, { fontSize: "small" }) }) }), _jsx(Tooltip, { title: t('delete'), children: _jsx(IconButton, { id: `rule-delete-${rule.rule_id}`, size: "small", onClick: () => handleDeleteRule(rule.rule_id), children: _jsx(Delete, { fontSize: "small" }) }) })] })] }, rule.rule_id))) })] }) })) }), _jsx(CreateRuleDialog, { open: dialogOpen, onClose: () => setDialogOpen(false), onSubmit: handleCreateRule }), _jsxs(Dialog, { open: !!backfillRule, onClose: handleBackfillDialogClose, maxWidth: "sm", fullWidth: true, id: "rule-backfill-dialog", children: [_jsx(DialogTitle, { children: t('page.cases.rules.backfill') }), _jsx(DialogContent, { children: _jsxs(Stack, { spacing: 2, sx: { mt: 1 }, children: [_jsx(Typography, { children: t('page.cases.rules.backfill.description') }), _jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: _jsx(DateTimePicker, { label: t('page.cases.rules.backfill.since'), value: backfillSince, onChange: value => {
110
+ return (_jsxs(Stack, { spacing: 2, sx: { p: 2, height: '100%', overflow: 'auto' }, children: [_jsx(Button, { id: "create-rule-button", variant: "outlined", startIcon: _jsx(Add, {}), onClick: () => setDialogOpen(true), sx: { alignSelf: 'end' }, children: t('page.cases.rules.create') }), _jsx(Card, { children: rules.length === 0 ? (_jsx(Typography, { m: 2, color: "textSecondary", textAlign: "center", children: t('page.cases.rules.empty') })) : (_jsx(TableContainer, { children: _jsxs(Table, { id: "rules-table", size: "small", children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableCell, { children: t('page.cases.rules.destination') }), _jsx(TableCell, { children: t('page.cases.rules.query') }), _jsx(TableCell, { children: t('hit.search.index') }), _jsx(TableCell, { children: t('page.cases.rules.timeframe') }), _jsx(TableCell, { children: t('page.cases.rules.author') }), _jsx(TableCell, { align: "center", children: t('enabled') }), _jsx(TableCell, { align: "right" })] }) }), _jsx(TableBody, { children: rules.map(rule => (_jsx(CaseRuleRow, { rule: rule, onToggleEnabled: enabled => handleToggleEnabled(rule.rule_id, enabled), onBackfill: () => handleBackfillDialogOpen(rule), onDelete: () => handleDeleteRule(rule.rule_id) }, rule.rule_id))) })] }) })) }), _jsx(CreateRuleDialog, { open: dialogOpen, onClose: () => setDialogOpen(false), onSubmit: handleCreateRule }), _jsxs(Dialog, { open: !!backfillRule, onClose: handleBackfillDialogClose, maxWidth: "sm", fullWidth: true, id: "rule-backfill-dialog", children: [_jsx(DialogTitle, { children: t('page.cases.rules.backfill') }), _jsx(DialogContent, { children: _jsxs(Stack, { spacing: 2, sx: { mt: 1 }, children: [_jsx(Typography, { children: t('page.cases.rules.backfill.description') }), _jsx(LocalizationProvider, { dateAdapter: AdapterDayjs, children: _jsx(DateTimePicker, { label: t('page.cases.rules.backfill.since'), value: backfillSince, onChange: value => {
114
111
  if (!value) {
115
112
  return;
116
113
  }