@cccsaurora/howler-ui 2.18.0-dev.704 → 2.18.0-dev.705

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 (245) hide show
  1. package/api/index.d.ts +2 -0
  2. package/api/index.js +4 -2
  3. package/api/search/case.d.ts +4 -0
  4. package/api/search/case.js +8 -0
  5. package/api/search/index.d.ts +2 -1
  6. package/api/search/index.js +2 -1
  7. package/api/v2/case/index.d.ts +8 -0
  8. package/api/v2/case/index.js +20 -0
  9. package/api/v2/case/items.d.ts +6 -0
  10. package/api/v2/case/items.js +18 -0
  11. package/api/v2/index.d.ts +4 -0
  12. package/api/v2/index.js +6 -0
  13. package/api/v2/search/facet.d.ts +3 -0
  14. package/api/v2/search/facet.js +12 -0
  15. package/api/v2/search/index.d.ts +5 -0
  16. package/api/v2/search/index.js +24 -0
  17. package/commons/components/leftnav/LeftNavDrawer.js +1 -1
  18. package/components/app/App.js +34 -7
  19. package/components/app/hooks/useMatchers.js +2 -2
  20. package/components/app/hooks/useMatchers.test.js +22 -22
  21. package/components/app/hooks/useTitle.js +3 -3
  22. package/components/app/providers/FavouritesProvider.js +2 -2
  23. package/components/app/providers/ModalProvider.d.ts +1 -0
  24. package/components/app/providers/ParameterProvider.d.ts +9 -2
  25. package/components/app/providers/ParameterProvider.js +165 -240
  26. package/components/app/providers/ParameterProvider.test.js +307 -14
  27. package/components/app/providers/RecordProvider.d.ts +23 -0
  28. package/components/app/providers/{HitProvider.js → RecordProvider.js} +41 -41
  29. package/components/app/providers/{HitSearchProvider.d.ts → RecordSearchProvider.d.ts} +6 -6
  30. package/components/app/providers/{HitSearchProvider.js → RecordSearchProvider.js} +12 -17
  31. package/components/app/providers/{HitSearchProvider.test.js → RecordSearchProvider.test.js} +51 -70
  32. package/components/elements/ContextMenu.d.ts +56 -0
  33. package/components/elements/ContextMenu.js +109 -0
  34. package/components/elements/ContextMenu.test.js +215 -0
  35. package/components/{routes/overviews/OverviewEditor.js → elements/MarkdownEditor.js} +3 -3
  36. package/components/elements/ObjectDetails.d.ts +6 -0
  37. package/components/elements/{hit/HitDetails.js → ObjectDetails.js} +17 -17
  38. package/components/elements/PluginTypography.d.ts +2 -1
  39. package/components/elements/PluginTypography.js +3 -2
  40. package/components/elements/UserList.d.ts +5 -2
  41. package/components/elements/UserList.js +14 -5
  42. package/components/elements/addons/search/phrase/Phrase.js +1 -1
  43. package/components/elements/case/CaseCard.d.ts +12 -0
  44. package/components/elements/case/CaseCard.js +42 -0
  45. package/components/elements/case/CasePreview.d.ts +6 -0
  46. package/components/elements/case/CasePreview.js +17 -0
  47. package/components/elements/case/StatusIcon.d.ts +5 -0
  48. package/components/elements/case/StatusIcon.js +13 -0
  49. package/components/elements/display/ChipPopper.d.ts +1 -1
  50. package/components/elements/display/HowlerCard.js +1 -1
  51. package/components/elements/display/Modal.js +2 -0
  52. package/components/elements/hit/HitActions.js +4 -4
  53. package/components/elements/hit/HitBanner.js +28 -48
  54. package/components/elements/hit/HitCard.js +5 -5
  55. package/components/elements/hit/HitLabels.js +2 -2
  56. package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
  57. package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +10 -4
  58. package/components/elements/hit/HitSummary.d.ts +2 -1
  59. package/components/elements/hit/HitSummary.js +6 -5
  60. package/components/elements/hit/aggregate/HitGraph.js +8 -8
  61. package/components/elements/hit/elements/AnalyticLink.d.ts +8 -0
  62. package/components/elements/hit/elements/AnalyticLink.js +22 -0
  63. package/components/elements/hit/outlines/DefaultOutline.js +1 -1
  64. package/components/elements/hit/related/RelatedRecords.js +63 -0
  65. package/components/elements/observable/ObservableCard.d.ts +6 -0
  66. package/components/elements/observable/ObservableCard.js +23 -0
  67. package/components/elements/observable/ObservablePreview.d.ts +6 -0
  68. package/components/elements/observable/ObservablePreview.js +12 -0
  69. package/components/elements/{hit/HitComments.d.ts → record/RecordComments.d.ts} +5 -4
  70. package/components/elements/{hit/HitComments.js → record/RecordComments.js} +29 -28
  71. package/components/{routes/hits/search/HitContextMenu.d.ts → elements/record/RecordContextMenu.d.ts} +3 -3
  72. package/components/elements/record/RecordContextMenu.js +247 -0
  73. package/components/elements/record/RecordContextMenu.test.d.ts +1 -0
  74. package/components/{routes/hits/search/HitContextMenu.test.js → elements/record/RecordContextMenu.test.js} +94 -39
  75. package/components/elements/record/RecordRelated.d.ts +7 -0
  76. package/components/elements/record/RecordRelated.js +34 -0
  77. package/components/elements/{hit/HitWorklog.d.ts → record/RecordWorklog.d.ts} +4 -3
  78. package/components/elements/{hit/HitWorklog.js → record/RecordWorklog.js} +15 -13
  79. package/components/elements/view/ViewTitle.d.ts +1 -0
  80. package/components/elements/view/ViewTitle.js +9 -2
  81. package/components/hooks/useHitActions.d.ts +1 -1
  82. package/components/hooks/useHitActions.js +4 -4
  83. package/components/hooks/useMyPreferences.js +10 -1
  84. package/components/hooks/useMySearch.js +2 -2
  85. package/components/hooks/useMySitemap.js +4 -1
  86. package/components/hooks/useMyTheme.js +9 -2
  87. package/components/hooks/useParamState.test.js +3 -4
  88. package/components/hooks/{useHitSelection.d.ts → useRecordSelection.d.ts} +2 -2
  89. package/components/hooks/{useHitSelection.js → useRecordSelection.js} +12 -33
  90. package/components/hooks/useRelatedRecords.d.ts +13 -0
  91. package/components/hooks/useRelatedRecords.js +32 -0
  92. package/components/routes/action/edit/ActionEditor.js +2 -2
  93. package/components/routes/action/view/ActionSearch.js +1 -1
  94. package/components/routes/advanced/QueryBuilder.js +1 -1
  95. package/components/routes/advanced/QueryEditor.js +3 -3
  96. package/components/routes/advanced/historyCompletionProvider.js +3 -3
  97. package/components/routes/analytics/AnalyticDetails.js +2 -2
  98. package/components/routes/analytics/AnalyticSearch.js +1 -1
  99. package/components/routes/cases/CaseViewer.d.ts +2 -0
  100. package/components/routes/cases/CaseViewer.js +22 -0
  101. package/components/routes/cases/Cases.d.ts +2 -0
  102. package/components/routes/cases/Cases.js +101 -0
  103. package/components/routes/cases/constants.d.ts +5 -0
  104. package/components/routes/cases/constants.js +5 -0
  105. package/components/routes/cases/detail/AlertPanel.d.ts +6 -0
  106. package/components/routes/cases/detail/AlertPanel.js +33 -0
  107. package/components/routes/cases/detail/CaseAssets.d.ts +12 -0
  108. package/components/routes/cases/detail/CaseAssets.js +104 -0
  109. package/components/routes/cases/detail/CaseAssets.test.d.ts +1 -0
  110. package/components/routes/cases/detail/CaseAssets.test.js +167 -0
  111. package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
  112. package/components/routes/cases/detail/CaseDashboard.js +54 -0
  113. package/components/routes/cases/detail/CaseDetails.d.ts +6 -0
  114. package/components/routes/cases/detail/CaseDetails.js +61 -0
  115. package/components/routes/cases/detail/CaseOverview.d.ts +7 -0
  116. package/components/routes/cases/detail/CaseOverview.js +43 -0
  117. package/components/routes/cases/detail/CaseSidebar.d.ts +8 -0
  118. package/components/routes/cases/detail/CaseSidebar.js +61 -0
  119. package/components/routes/cases/detail/CaseTask.d.ts +11 -0
  120. package/components/routes/cases/detail/CaseTask.js +57 -0
  121. package/components/routes/cases/detail/ItemPage.d.ts +6 -0
  122. package/components/routes/cases/detail/ItemPage.js +99 -0
  123. package/components/routes/cases/detail/RelatedCasePanel.d.ts +6 -0
  124. package/components/routes/cases/detail/RelatedCasePanel.js +31 -0
  125. package/components/routes/cases/detail/TaskPanel.d.ts +7 -0
  126. package/components/routes/cases/detail/TaskPanel.js +52 -0
  127. package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +12 -0
  128. package/components/routes/cases/detail/aggregates/CaseAggregate.js +19 -0
  129. package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +6 -0
  130. package/components/routes/cases/detail/aggregates/SourceAggregate.js +30 -0
  131. package/components/routes/cases/detail/assets/Asset.d.ts +14 -0
  132. package/components/routes/cases/detail/assets/Asset.js +12 -0
  133. package/components/routes/cases/detail/assets/Asset.test.d.ts +1 -0
  134. package/components/routes/cases/detail/assets/Asset.test.js +72 -0
  135. package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +14 -0
  136. package/components/routes/cases/detail/sidebar/CaseFolder.js +133 -0
  137. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.d.ts +34 -0
  138. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.js +105 -0
  139. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.d.ts +1 -0
  140. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.js +351 -0
  141. package/components/routes/cases/detail/sidebar/types.d.ts +3 -0
  142. package/components/routes/cases/detail/sidebar/utils.d.ts +3 -0
  143. package/components/routes/cases/detail/sidebar/utils.js +25 -0
  144. package/components/routes/cases/hooks/useCase.d.ts +13 -0
  145. package/components/routes/cases/hooks/useCase.js +51 -0
  146. package/components/routes/cases/modals/AddToCaseModal.d.ts +7 -0
  147. package/components/routes/cases/modals/AddToCaseModal.js +62 -0
  148. package/components/routes/cases/modals/RenameItemModal.d.ts +9 -0
  149. package/components/routes/cases/modals/RenameItemModal.js +48 -0
  150. package/components/routes/cases/modals/ResolveModal.d.ts +7 -0
  151. package/components/routes/cases/modals/ResolveModal.js +62 -0
  152. package/components/routes/dossiers/DossierEditor.js +2 -2
  153. package/components/routes/dossiers/DossierEditor.test.js +1 -1
  154. package/components/routes/help/ApiDocumentation.js +1 -1
  155. package/components/routes/help/HitBannerDocumentation.js +1 -0
  156. package/components/routes/help/HitDocumentation.js +1 -3
  157. package/components/routes/hits/search/InformationPane.d.ts +1 -0
  158. package/components/routes/hits/search/InformationPane.js +47 -60
  159. package/components/routes/hits/search/LayoutSettings.js +3 -3
  160. package/components/routes/hits/search/QuerySettings.js +2 -1
  161. package/components/routes/hits/search/QuerySettings.test.js +14 -9
  162. package/components/routes/hits/search/{HitBrowser.js → RecordBrowser.js} +9 -9
  163. package/components/routes/hits/search/{HitQuery.d.ts → RecordQuery.d.ts} +2 -2
  164. package/components/routes/hits/search/{HitQuery.js → RecordQuery.js} +6 -6
  165. package/components/routes/hits/search/SearchPane.js +26 -49
  166. package/components/routes/hits/search/ViewLink.js +3 -3
  167. package/components/routes/hits/search/ViewLink.test.js +8 -8
  168. package/components/routes/hits/search/grid/AddColumnModal.js +5 -4
  169. package/components/routes/hits/search/grid/EnhancedCell.d.ts +2 -1
  170. package/components/routes/hits/search/grid/EnhancedCell.js +2 -2
  171. package/components/routes/hits/search/grid/HitGrid.js +20 -18
  172. package/components/routes/hits/search/grid/{HitRow.d.ts → RecordRow.d.ts} +3 -2
  173. package/components/routes/hits/search/grid/{HitRow.js → RecordRow.js} +10 -8
  174. package/components/routes/hits/search/shared/IndexPicker.d.ts +2 -0
  175. package/components/routes/hits/search/shared/IndexPicker.js +20 -0
  176. package/components/routes/hits/view/HitViewer.js +12 -13
  177. package/components/routes/home/ViewCard.js +47 -41
  178. package/components/routes/observables/ObservableViewer.d.ts +7 -0
  179. package/components/routes/observables/ObservableViewer.js +27 -0
  180. package/components/routes/overviews/OverviewViewer.js +2 -2
  181. package/components/routes/views/ViewComposer.js +46 -19
  182. package/locales/en/translation.json +80 -3
  183. package/locales/fr/translation.json +78 -3
  184. package/models/WithMetadata.d.ts +2 -1
  185. package/models/entities/generated/AttachmentsFile.d.ts +12 -0
  186. package/models/entities/generated/Case.d.ts +28 -0
  187. package/models/entities/generated/DestinationOriginal.d.ts +19 -0
  188. package/models/entities/generated/EmailAttachment.d.ts +8 -0
  189. package/models/entities/generated/EmailParent.d.ts +19 -0
  190. package/models/entities/generated/Enrichments.d.ts +7 -0
  191. package/models/entities/generated/EnrichmentsIndicator.d.ts +21 -0
  192. package/models/entities/generated/Hit.d.ts +1 -0
  193. package/models/entities/generated/Howler.d.ts +0 -4
  194. package/models/entities/generated/HttpResponse.d.ts +11 -0
  195. package/models/entities/generated/Item.d.ts +9 -0
  196. package/models/entities/generated/Observable.d.ts +85 -0
  197. package/models/entities/generated/ObservableCloud.d.ts +20 -0
  198. package/models/entities/generated/ObservableDestination.d.ts +23 -0
  199. package/models/entities/generated/ObservableEmail.d.ts +30 -0
  200. package/models/entities/generated/ObservableFile.d.ts +36 -0
  201. package/models/entities/generated/ObservableHowler.d.ts +43 -0
  202. package/models/entities/generated/ObservableHttp.d.ts +11 -0
  203. package/models/entities/generated/ObservableObserver.d.ts +21 -0
  204. package/models/entities/generated/ObservableOrganization.d.ts +7 -0
  205. package/models/entities/generated/ObservableProcess.d.ts +34 -0
  206. package/models/entities/generated/ObservableSource.d.ts +23 -0
  207. package/models/entities/generated/ObservableThreat.d.ts +21 -0
  208. package/models/entities/generated/ObservableTls.d.ts +12 -0
  209. package/models/entities/generated/ObserverIngress.d.ts +9 -0
  210. package/models/entities/generated/Rule.d.ts +2 -10
  211. package/models/entities/generated/Task.d.ts +10 -0
  212. package/models/entities/generated/Threat.d.ts +2 -2
  213. package/models/entities/generated/{Enrichment.d.ts → ThreatEnrichment.d.ts} +1 -1
  214. package/models/entities/generated/View.d.ts +1 -0
  215. package/package.json +18 -1
  216. package/plugins/clue/components/ClueTypography.js +2 -2
  217. package/plugins/clue/utils.d.ts +2 -1
  218. package/tests/server-handlers.js +6 -1
  219. package/tests/utils.d.ts +4 -0
  220. package/tests/utils.js +20 -0
  221. package/utils/constants.d.ts +3 -3
  222. package/utils/hitFunctions.d.ts +2 -1
  223. package/utils/hitFunctions.js +4 -4
  224. package/utils/typeUtils.d.ts +7 -0
  225. package/utils/typeUtils.js +27 -0
  226. package/utils/viewUtils.js +3 -0
  227. package/components/app/providers/HitProvider.d.ts +0 -22
  228. package/components/elements/display/icons/BundleButton.d.ts +0 -6
  229. package/components/elements/display/icons/BundleButton.js +0 -32
  230. package/components/elements/hit/HitRelated.d.ts +0 -6
  231. package/components/elements/hit/HitRelated.js +0 -7
  232. package/components/routes/help/BundleDocumentation.d.ts +0 -3
  233. package/components/routes/help/BundleDocumentation.js +0 -12
  234. package/components/routes/help/markdown/en/bundles.md.js +0 -1
  235. package/components/routes/help/markdown/fr/bundles.md.js +0 -1
  236. package/components/routes/hits/search/BundleParentMenu.d.ts +0 -6
  237. package/components/routes/hits/search/BundleParentMenu.js +0 -32
  238. package/components/routes/hits/search/BundleScroller.d.ts +0 -2
  239. package/components/routes/hits/search/BundleScroller.js +0 -6
  240. package/components/routes/hits/search/HitContextMenu.js +0 -227
  241. /package/components/app/providers/{HitSearchProvider.test.d.ts → RecordSearchProvider.test.d.ts} +0 -0
  242. /package/components/{routes/hits/search/HitContextMenu.test.d.ts → elements/ContextMenu.test.d.ts} +0 -0
  243. /package/components/{routes/overviews/OverviewEditor.d.ts → elements/MarkdownEditor.d.ts} +0 -0
  244. /package/components/elements/hit/{HitDetails.d.ts → related/RelatedRecords.d.ts} +0 -0
  245. /package/components/routes/hits/search/{HitBrowser.d.ts → RecordBrowser.d.ts} +0 -0
@@ -0,0 +1,215 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { fireEvent, render, screen, waitFor } from '@testing-library/react';
3
+ import { omit } from 'lodash-es';
4
+ import { act } from 'react';
5
+ import { vi } from 'vitest';
6
+ // Mock react-router-dom Link
7
+ vi.mock('react-router-dom', () => ({
8
+ Link: ({ to, children, ...props }) => (_jsx("a", { href: to, ...props, children: children }))
9
+ }));
10
+ // Stub MUI components to simple HTML equivalents
11
+ vi.mock('@mui/material', async () => {
12
+ const actual = await vi.importActual('@mui/material');
13
+ return {
14
+ ...actual,
15
+ useTheme: () => ({ shape: { borderRadius: 4 } }),
16
+ Menu: ({ children, open, onClose, ...props }) => open ? (_jsx("div", { role: "menu", onClick: onClose, ...omit(props, ['sx', 'slotProps', 'MenuListProps', 'anchorOrigin', 'anchorEl']), children: children })) : null,
17
+ MenuItem: ({ children, onClick, disabled, component, to, id, onMouseEnter, onMouseLeave, ...props }) => {
18
+ const Component = component || 'div';
19
+ return (_jsx(Component, { role: "menuitem", onClick: onClick, "aria-disabled": disabled, href: to, id: id, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, ...omit(props, ['sx']), children: children }));
20
+ },
21
+ Fade: ({ children, in: inProp }) => (inProp ? _jsx(_Fragment, { children: children }) : null),
22
+ ListItemIcon: ({ children }) => _jsx("div", { children: children }),
23
+ ListItemText: ({ children }) => _jsx("div", { children: children }),
24
+ Divider: () => _jsx("hr", {}),
25
+ Paper: ({ children, id, ...props }) => (_jsx("div", { id: id, ...omit(props, ['sx', 'elevation']), children: children })),
26
+ MenuList: ({ children, ...props }) => (_jsx("div", { role: "group", ...omit(props, ['sx', 'dense']), children: children })),
27
+ Box: ({ children, id, onContextMenu, ...props }) => (_jsx("div", { id: id, onContextMenu: onContextMenu, ...omit(props, ['sx']), children: children }))
28
+ };
29
+ });
30
+ import ContextMenu, {} from './ContextMenu';
31
+ const renderMenu = (items, opts = {}) => {
32
+ const { autoOpen = true, onOpen = vi.fn(), onClose = vi.fn() } = opts;
33
+ const utils = render(_jsx(ContextMenu, { items: items, onOpen: onOpen, onClose: onClose, id: "test-menu", children: _jsx("div", { id: "trigger", children: "trigger" }) }));
34
+ const openMenu = () => act(() => {
35
+ fireEvent.contextMenu(screen.getByTestId('trigger'));
36
+ });
37
+ if (autoOpen) {
38
+ openMenu();
39
+ }
40
+ return { ...utils, onOpen, onClose, openMenu };
41
+ };
42
+ describe('ContextMenu', () => {
43
+ describe('Visibility', () => {
44
+ it('renders nothing before right-click', () => {
45
+ const { container } = renderMenu([], { autoOpen: false });
46
+ expect(container.querySelector('[role="menu"]')).toBeNull();
47
+ });
48
+ it('renders the menu after right-click', () => {
49
+ renderMenu([]);
50
+ expect(screen.getByRole('menu')).toBeInTheDocument();
51
+ });
52
+ it('calls onClose when the menu is clicked', () => {
53
+ const { onClose } = renderMenu([]);
54
+ fireEvent.click(screen.getByRole('menu'));
55
+ expect(onClose).toHaveBeenCalledTimes(1);
56
+ });
57
+ it('closes on a second right-click (toggle)', () => {
58
+ const { openMenu } = renderMenu([]);
59
+ expect(screen.getByRole('menu')).toBeInTheDocument();
60
+ openMenu();
61
+ expect(screen.queryByRole('menu')).not.toBeInTheDocument();
62
+ });
63
+ it('calls onOpen when right-clicked', () => {
64
+ const onOpen = vi.fn();
65
+ renderMenu([], { onOpen });
66
+ expect(onOpen).toHaveBeenCalledTimes(1);
67
+ });
68
+ it('calls onClose when closed via toggle right-click', () => {
69
+ const onClose = vi.fn();
70
+ const { openMenu } = renderMenu([], { onClose });
71
+ openMenu();
72
+ expect(onClose).toHaveBeenCalledTimes(1);
73
+ });
74
+ });
75
+ describe('Leaf items', () => {
76
+ it('renders a plain button item', () => {
77
+ const onClick = vi.fn();
78
+ renderMenu([{ kind: 'item', id: 'action-1', label: 'Do something', onClick }]);
79
+ const item = screen.getByRole('menuitem');
80
+ expect(item).toHaveTextContent('Do something');
81
+ });
82
+ it('calls onClick when a plain item is clicked', () => {
83
+ const onClick = vi.fn();
84
+ renderMenu([{ kind: 'item', id: 'action-1', label: 'Do something', onClick }]);
85
+ fireEvent.click(screen.getByRole('menuitem'));
86
+ expect(onClick).toHaveBeenCalledTimes(1);
87
+ });
88
+ it('renders a link item with correct href', () => {
89
+ renderMenu([{ kind: 'item', id: 'link-1', label: 'Go somewhere', to: '/some/path' }]);
90
+ const link = screen.getByRole('menuitem');
91
+ expect(link).toHaveAttribute('href', '/some/path');
92
+ });
93
+ it('marks a disabled item with aria-disabled', () => {
94
+ renderMenu([{ kind: 'item', id: 'action-1', label: 'Disabled', disabled: true }]);
95
+ expect(screen.getByRole('menuitem')).toHaveAttribute('aria-disabled', 'true');
96
+ });
97
+ it('renders an icon alongside the label when provided', () => {
98
+ renderMenu([{ kind: 'item', id: 'icon-item', label: 'With icon', icon: _jsx("span", { id: "test-icon" }) }]);
99
+ expect(screen.getByTestId('test-icon')).toBeInTheDocument();
100
+ expect(screen.getByRole('menuitem')).toHaveTextContent('With icon');
101
+ });
102
+ });
103
+ describe('Dividers', () => {
104
+ it('renders a divider between items', () => {
105
+ renderMenu([
106
+ { kind: 'item', id: 'item-a', label: 'A' },
107
+ { kind: 'divider', id: 'sep' },
108
+ { kind: 'item', id: 'item-b', label: 'B' }
109
+ ]);
110
+ expect(screen.getByRole('separator')).toBeInTheDocument();
111
+ expect(screen.getAllByRole('menuitem')).toHaveLength(2);
112
+ });
113
+ });
114
+ describe('Submenu items', () => {
115
+ const subItems = [
116
+ { key: 'sub-a', label: 'Sub A', onClick: vi.fn() },
117
+ { key: 'sub-b', label: 'Sub B', onClick: vi.fn() }
118
+ ];
119
+ const submenuEntry = {
120
+ kind: 'submenu',
121
+ id: 'my-submenu',
122
+ label: 'Parent',
123
+ items: subItems
124
+ };
125
+ it('renders the parent submenu item', () => {
126
+ renderMenu([submenuEntry]);
127
+ expect(screen.getByText('Parent')).toBeInTheDocument();
128
+ });
129
+ it('does not show submenu content before hovering', () => {
130
+ renderMenu([submenuEntry]);
131
+ expect(screen.queryByText('Sub A')).not.toBeInTheDocument();
132
+ });
133
+ it('shows submenu content on mouse enter', async () => {
134
+ renderMenu([submenuEntry]);
135
+ const parent = screen.getByRole('menuitem');
136
+ act(() => {
137
+ fireEvent.mouseEnter(parent);
138
+ });
139
+ await waitFor(() => {
140
+ expect(screen.getByText('Sub A')).toBeInTheDocument();
141
+ expect(screen.getByText('Sub B')).toBeInTheDocument();
142
+ });
143
+ });
144
+ it('hides submenu after mouse leave', async () => {
145
+ renderMenu([submenuEntry]);
146
+ const parent = screen.getByRole('menuitem');
147
+ act(() => {
148
+ fireEvent.mouseEnter(parent);
149
+ });
150
+ await waitFor(() => {
151
+ expect(screen.getByText('Sub A')).toBeInTheDocument();
152
+ });
153
+ act(() => {
154
+ fireEvent.mouseLeave(parent);
155
+ });
156
+ await waitFor(() => {
157
+ expect(screen.queryByText('Sub A')).not.toBeInTheDocument();
158
+ });
159
+ });
160
+ it('calls the sub-item onClick when a sub-item is clicked', async () => {
161
+ const onClick = vi.fn();
162
+ renderMenu([
163
+ {
164
+ kind: 'submenu',
165
+ id: 'actions',
166
+ label: 'Actions',
167
+ items: [{ key: 'do-it', label: 'Do it', onClick }]
168
+ }
169
+ ]);
170
+ const parent = screen.getByRole('menuitem');
171
+ act(() => {
172
+ fireEvent.mouseEnter(parent);
173
+ });
174
+ await waitFor(() => {
175
+ expect(screen.getByText('Do it')).toBeInTheDocument();
176
+ });
177
+ fireEvent.click(screen.getByText('Do it'));
178
+ expect(onClick).toHaveBeenCalledTimes(1);
179
+ });
180
+ it('marks a disabled submenu parent with aria-disabled', () => {
181
+ renderMenu([{ ...submenuEntry, disabled: true }]);
182
+ expect(screen.getByRole('menuitem')).toHaveAttribute('aria-disabled', 'true');
183
+ });
184
+ it('does not show expand arrow when submenu is disabled', () => {
185
+ renderMenu([{ ...submenuEntry, disabled: true }]);
186
+ // The KeyboardArrowRight icon only renders when !disabled
187
+ expect(screen.queryByTestId('KeyboardArrowRightIcon')).not.toBeInTheDocument();
188
+ });
189
+ it('assigns correct DOM ids to submenu parent and panel', async () => {
190
+ renderMenu([submenuEntry]);
191
+ expect(document.getElementById('my-submenu-menu-item')).not.toBeNull();
192
+ const parent = screen.getByRole('menuitem');
193
+ act(() => {
194
+ fireEvent.mouseEnter(parent);
195
+ });
196
+ await waitFor(() => {
197
+ expect(document.getElementById('my-submenu-submenu')).not.toBeNull();
198
+ });
199
+ });
200
+ });
201
+ describe('Mixed item list', () => {
202
+ it('renders items in order', () => {
203
+ renderMenu([
204
+ { kind: 'item', id: 'first', label: 'First' },
205
+ { kind: 'divider', id: 'div-1' },
206
+ { kind: 'submenu', id: 'third', label: 'Third', items: [] },
207
+ { kind: 'item', id: 'fourth', label: 'Fourth' }
208
+ ]);
209
+ const items = screen.getAllByRole('menuitem');
210
+ expect(items[0]).toHaveTextContent('First');
211
+ expect(items[1]).toHaveTextContent('Third');
212
+ expect(items[2]).toHaveTextContent('Fourth');
213
+ });
214
+ });
215
+ });
@@ -4,8 +4,8 @@ import { useTheme } from '@mui/material';
4
4
  import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
5
5
  import ThemedEditor from '@cccsaurora/howler-ui/components/elements/ThemedEditor';
6
6
  import { memo, useCallback, useContext, useEffect, useMemo } from 'react';
7
- import { conf, language } from './markdownExtendedTokenProvider';
8
- const OverviewEditor = ({ content, setContent, onMount, fontSize = 16, height = '100%', width = '100%', editorOptions = {} }) => {
7
+ import { conf, language } from '../routes/overviews/markdownExtendedTokenProvider';
8
+ const MarkdownEditor = ({ content, setContent, onMount, fontSize = 16, height = '100%', width = '100%', editorOptions = {} }) => {
9
9
  const theme = useTheme();
10
10
  const monaco = useMonaco();
11
11
  const { config } = useContext(ApiConfigContext);
@@ -53,4 +53,4 @@ const OverviewEditor = ({ content, setContent, onMount, fontSize = 16, height =
53
53
  }), [fontSize, editorOptions]);
54
54
  return (_jsx(ThemedEditor, { height: height, width: width, theme: theme.palette.mode === 'light' ? 'howler' : 'howler-dark', value: content, onChange: value => setContent(value), beforeMount: beforeEditorMount, onMount: onMount, options: options }));
55
55
  };
56
- export default memo(OverviewEditor);
56
+ export default memo(MarkdownEditor);
@@ -0,0 +1,6 @@
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
+ declare const _default: import("react").NamedExoticComponent<{
4
+ obj: Hit | Observable;
5
+ }>;
6
+ export default _default;
@@ -5,12 +5,12 @@ import { ArrowDropDown, InfoOutlined } from '@mui/icons-material';
5
5
  import { Accordion, AccordionDetails, AccordionSummary, Box, Divider, Grid, Stack, TextField, Tooltip, Typography, useTheme } from '@mui/material';
6
6
  import { flatten } from 'flat';
7
7
  import Fuse from 'fuse.js';
8
- import { capitalize, groupBy, isArray, isEmpty, isNull, isObject, isPlainObject, isUndefined, max, sortBy, uniq } from 'lodash-es';
8
+ import { capitalize, groupBy, isArray, isBoolean, isEmpty, isNull, isNumber, isObject, isPlainObject, isUndefined, max, sortBy, uniq } from 'lodash-es';
9
9
  import { memo, useEffect, useMemo, useState } from 'react';
10
10
  import { useTranslation } from 'react-i18next';
11
11
  import Throttler from '@cccsaurora/howler-ui/utils/Throttler';
12
- import PluginTypography from '../PluginTypography';
13
- const ListRenderer = memo(({ hit, objKey: key, entries, maxKeyLength }) => {
12
+ import PluginTypography from './PluginTypography';
13
+ const ListRenderer = memo(({ obj, objKey: key, entries, maxKeyLength }) => {
14
14
  const theme = useTheme();
15
15
  const { t } = useTranslation();
16
16
  const allPrimitives = useMemo(() => entries.every(entry => !isObject(entry)), [entries]);
@@ -36,15 +36,15 @@ const ListRenderer = memo(({ hit, objKey: key, entries, maxKeyLength }) => {
36
36
  marginBottom: allPrimitives ? 0 : theme.spacing(1)
37
37
  }, children: allPrimitives ? key.padStart(maxKeyLength ?? key.length) : key }) }), _jsxs(Grid, { container: true, spacing: allPrimitives ? 1 : 4, ml: allPrimitives ? -1 : -4, overflow: "hidden", maxWidth: "100%", children: [uniqueEntries.map((entry, index) => {
38
38
  if (Array.isArray(entry)) {
39
- return (_jsx(Grid, { item: true, xs: "auto", maxWidth: "100%", children: _jsx(ListRenderer, { hit: hit, objKey: `${key}.${index}`, entries: entry }) }, index));
39
+ return (_jsx(Grid, { item: true, xs: "auto", maxWidth: "100%", children: _jsx(ListRenderer, { obj: obj, objKey: `${key}.${index}`, entries: entry }) }, index));
40
40
  }
41
41
  if (isPlainObject(entry)) {
42
42
  return (_jsx(Grid, { item: true, xs: 'auto', maxWidth: "100%", minWidth: "350px", children: _jsx(ObjectRenderer, { parentKey: `${key}.${index}`, indent: true, data: entry }) }, index));
43
43
  }
44
- return (_jsxs(Grid, { item: true, maxWidth: "100%", className: `${key}_${index}`.replace(/\./g, '_'), component: "code", display: "flex", flexDirection: "row", children: [_jsx(PluginTypography, { context: "details", component: "code", style: { maxWidth: '100%', font: 'inherit' }, value: entry, field: key.replace(/\.[0-9]+/g, ''), hit: hit, children: entry }), allPrimitives && index < uniqueEntries.length - 1 && _jsx("span", { children: "," })] }, entry));
44
+ return (_jsxs(Grid, { item: true, maxWidth: "100%", className: `${key}_${index}`.replace(/\./g, '_'), component: "code", display: "flex", flexDirection: "row", children: [_jsx(PluginTypography, { context: "details", component: "code", style: { maxWidth: '100%', font: 'inherit' }, value: entry, field: key.replace(/\.[0-9]+/g, ''), obj: obj, children: entry }), allPrimitives && index < uniqueEntries.length - 1 && _jsx("span", { children: "," })] }, entry));
45
45
  }), omittedDuplicates && (_jsx(Grid, { item: true, display: "flex", alignItems: "center", children: _jsx(Tooltip, { title: t('duplicates.omitted'), children: _jsx(InfoOutlined, { sx: { fontSize: '20px', ml: 1 }, color: "disabled" }) }) }))] })] }));
46
46
  });
47
- const ObjectRenderer = memo(({ hit, data, parentKey, indent = false }) => {
47
+ const ObjectRenderer = memo(({ obj: obj, data, parentKey, indent = false }) => {
48
48
  const theme = useTheme();
49
49
  const entries = useMemo(() => {
50
50
  const unsorted = Object.entries(flatten(data, { safe: true })).map(([key, val]) => [key, val]);
@@ -56,10 +56,10 @@ const ObjectRenderer = memo(({ hit, data, parentKey, indent = false }) => {
56
56
  }, [data]);
57
57
  const longestKey = useMemo(() => max(entries.map(([key]) => key.length)), [entries]);
58
58
  return (_jsxs(Stack, { direction: "row", overflow: "hidden", maxWidth: "100%", children: [indent && _jsx(Divider, { orientation: "vertical", flexItem: true, sx: { borderColor: 'primary.main', borderWidth: '2px' } }), _jsx(Stack, { flex: 1, ml: 1, maxWidth: "100%", children: entries
59
- .filter(([__, val]) => !isNull(val) && !isUndefined(val) && !isEmpty(val))
59
+ .filter(([__, val]) => !isNull(val) && !isUndefined(val) && !isEmpty(val) && !isBoolean(val) && !isNumber(val))
60
60
  .map(([key, val]) => {
61
61
  if (Array.isArray(val)) {
62
- return _jsx(ListRenderer, { hit: hit, maxKeyLength: longestKey, objKey: key, entries: val }, key);
62
+ return _jsx(ListRenderer, { obj: obj, maxKeyLength: longestKey, objKey: key, entries: val }, key);
63
63
  }
64
64
  return (_jsxs("code", { className: (parentKey ? `${parentKey}.${key}` : key).replace(/\./g, '_'), style: {
65
65
  display: 'grid',
@@ -75,14 +75,14 @@ const ObjectRenderer = memo(({ hit, data, parentKey, indent = false }) => {
75
75
  paddingRight: theme.spacing(1),
76
76
  height: '100%',
77
77
  wordWrap: 'break-word'
78
- }, children: _jsx("code", { style: { maxWidth: '100%' }, children: key }) }), _jsx(Box, { display: "flex", alignItems: "start", children: _jsx(PluginTypography, { context: "details", component: "code", style: { maxWidth: '100%', font: 'inherit' }, value: val, field: (parentKey ? parentKey.concat('.', key) : key).replace(/\.[0-9]+/g, ''), hit: hit, children: val }) })] }, key));
78
+ }, children: _jsx("code", { style: { maxWidth: '100%' }, children: key }) }), _jsx(Box, { display: "flex", alignItems: "start", children: _jsx(PluginTypography, { context: "details", component: "code", style: { maxWidth: '100%', font: 'inherit' }, value: val, field: (parentKey ? parentKey.concat('.', key) : key).replace(/\.[0-9]+/g, ''), obj: obj, children: val }) })] }, key));
79
79
  }) })] }));
80
80
  });
81
- const Collapsible = memo(({ hit, title, data, query }) => {
81
+ const Collapsible = memo(({ obj, title, data, query }) => {
82
82
  const throttler = useMemo(() => new Throttler(400), []);
83
83
  const [scores, setScores] = useState([]);
84
84
  const [results, setResults] = useState({});
85
- const options = useMemo(() => Object.entries(data).map(([key, value]) => ({ key, value })), [data]);
85
+ const options = useMemo(() => Object.entries(data).map(([key, value]) => ({ key, value: value.toString() })), [data]);
86
86
  const keys = useMemo(() => options
87
87
  .flatMap(option => (isArray(option.value) ? Object.keys(flatten(option.value)) : []))
88
88
  .map(key => key.replace(/\d+/g, 'value'))
@@ -109,20 +109,20 @@ const Collapsible = memo(({ hit, title, data, query }) => {
109
109
  if (isEmpty(results)) {
110
110
  return null;
111
111
  }
112
- return (_jsxs(Accordion, { defaultExpanded: true, children: [_jsx(AccordionSummary, { expandIcon: _jsx(ArrowDropDown, {}), children: _jsx(Typography, { children: title }) }), _jsx(AccordionDetails, { children: _jsx(Stack, { spacing: 1, justifyContent: "stretch", sx: styles, children: _jsx(ObjectRenderer, { hit: hit, showParentKey: true, data: results }) }) })] }));
112
+ return (_jsxs(Accordion, { defaultExpanded: true, children: [_jsx(AccordionSummary, { expandIcon: _jsx(ArrowDropDown, {}), sx: { my: 0 }, children: _jsx(Typography, { children: title }) }), _jsx(AccordionDetails, { children: _jsx(Stack, { spacing: 0.5, justifyContent: "stretch", sx: styles, children: _jsx(ObjectRenderer, { obj: obj, showParentKey: true, data: results }) }) })] }));
113
113
  });
114
- const HitDetails = ({ hit }) => {
114
+ const ObjectDetails = ({ obj }) => {
115
115
  const { t } = useTranslation();
116
116
  const [query, setQuery] = useState('');
117
- const groups = useMemo(() => groupBy(Object.entries(flatten(hit ?? {}, { safe: true })).filter(([key, value]) => !key.startsWith('__') &&
117
+ const groups = useMemo(() => groupBy(Object.entries(flatten(obj ?? {}, { safe: true })).filter(([key, value]) => !key.startsWith('__') &&
118
118
  key.includes('.') &&
119
119
  ['howler', 'labels'].every(prefix => !key.startsWith(prefix)) &&
120
- !isEmpty(value)), ([key]) => key.split('.')[0]), [hit]);
120
+ (!isEmpty(value) || isNumber(value) || isBoolean(value))), ([key]) => key.split('.')[0]), [obj]);
121
121
  return (_jsxs(Stack, { spacing: 1, children: [_jsx(TextField, { value: query, onChange: event => setQuery(event.target.value), label: t('overview.search') }), Object.entries(groups).map(([section, entries]) => {
122
- return (_jsx(Collapsible, { hit: hit, query: query, title: section
122
+ return (_jsx(Collapsible, { obj: obj, query: query, title: section
123
123
  .split('_')
124
124
  .map(word => capitalize(word))
125
125
  .join(' '), data: Object.fromEntries(entries) }, section));
126
126
  })] }));
127
127
  };
128
- export default memo(HitDetails);
128
+ export default memo(ObjectDetails);
@@ -1,10 +1,11 @@
1
1
  import { type TypographyProps } from '@mui/material';
2
2
  import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
3
+ import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
3
4
  export type PluginTypographyProps = TypographyProps & {
4
5
  value: string;
5
6
  context: string;
6
7
  field?: string;
7
- hit?: Hit;
8
+ obj?: Hit | Observable;
8
9
  };
9
10
  declare const _default: import("react").NamedExoticComponent<PluginTypographyProps>;
10
11
  export default _default;
@@ -3,7 +3,7 @@ import { Typography } from '@mui/material';
3
3
  import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
4
4
  import { memo } from 'react';
5
5
  import { usePluginStore } from 'react-pluggable';
6
- const PluginTypography = ({ children, value, context, field, hit, ...props }) => {
6
+ const PluginTypography = ({ children, value, context, field, obj, ...props }) => {
7
7
  const pluginStore = usePluginStore();
8
8
  for (const plugin of howlerPluginStore.plugins) {
9
9
  const component = pluginStore.executeFunction(`${plugin}.typography`, {
@@ -11,7 +11,8 @@ const PluginTypography = ({ children, value, context, field, hit, ...props }) =>
11
11
  value,
12
12
  context,
13
13
  field,
14
- hit,
14
+ hit: obj,
15
+ obj,
15
16
  ...props
16
17
  });
17
18
  if (component) {
@@ -2,8 +2,11 @@ import type { SxProps, Theme } from '@mui/material';
2
2
  import type { FC } from 'react';
3
3
  declare const UserList: FC<{
4
4
  buttonSx?: SxProps<Theme>;
5
- userId: string;
6
- onChange: (userId: string) => void;
5
+ userIds: string[];
6
+ onChange: (userIds: string[]) => void;
7
7
  i18nLabel: string;
8
+ avatarHeight?: number;
9
+ disabled?: boolean;
10
+ multiple?: boolean;
8
11
  }>;
9
12
  export default UserList;
@@ -1,18 +1,20 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Autocomplete, Box, IconButton, Popover, TextField, Typography } from '@mui/material';
2
+ import { Add } from '@mui/icons-material';
3
+ import { Autocomplete, AvatarGroup, Box, IconButton, Popover, Stack, TextField, Typography } from '@mui/material';
3
4
  import { UserListContext } from '@cccsaurora/howler-ui/components/app/providers/UserListProvider';
5
+ import { uniq } from 'lodash-es';
4
6
  import { useContext, useEffect, useMemo, useState } from 'react';
5
7
  import { useTranslation } from 'react-i18next';
6
8
  import HowlerAvatar from './display/HowlerAvatar';
7
- const UserList = ({ buttonSx = {}, userId, onChange, i18nLabel }) => {
9
+ const UserList = ({ buttonSx = {}, userIds, onChange, i18nLabel, avatarHeight = 32, multiple = false, disabled = false }) => {
8
10
  const { t } = useTranslation();
9
11
  const [anchorEl, setAnchorEl] = useState(null);
10
12
  const { users, searchUsers } = useContext(UserListContext);
11
- const userIds = useMemo(() => Object.keys(users), [users]);
13
+ const allUserIds = useMemo(() => Object.keys(users), [users]);
12
14
  useEffect(() => {
13
15
  searchUsers('uname:*');
14
16
  }, [searchUsers]);
15
- return (_jsxs(_Fragment, { children: [_jsx(IconButton, { sx: buttonSx, onClick: e => setAnchorEl(e.currentTarget), children: _jsx(HowlerAvatar, { userId: userId }) }), _jsx(Popover, { open: !!anchorEl, onClose: () => setAnchorEl(null), anchorEl: anchorEl, anchorOrigin: { vertical: 'bottom', horizontal: 'left' }, children: _jsx(Box, { sx: { p: 2 }, children: _jsx(Autocomplete, { sx: { minWidth: '300px' }, options: userIds, renderInput: params => _jsx(TextField, { ...params, label: t(i18nLabel), size: "small" }), renderOption: (props, _userId) => {
17
+ return (_jsxs(_Fragment, { children: [multiple ? (_jsxs(Stack, { direction: "row", spacing: 0.25, alignItems: "center", children: [_jsx(AvatarGroup, { children: uniq(userIds ?? [null]).map(userId => (_jsx(HowlerAvatar, { userId: userId, sx: { height: avatarHeight, width: avatarHeight } }, userId))) }), _jsx(IconButton, { size: "small", sx: buttonSx, disabled: disabled, onClick: e => setAnchorEl(e.currentTarget), children: _jsx(Add, {}) })] })) : (_jsx(IconButton, { sx: buttonSx, disabled: disabled, onClick: e => setAnchorEl(e.currentTarget), children: _jsx(HowlerAvatar, { userId: userIds[0], sx: { height: avatarHeight, width: avatarHeight } }) })), _jsx(Popover, { open: !!anchorEl, onClose: () => setAnchorEl(null), anchorEl: anchorEl, anchorOrigin: { vertical: 'bottom', horizontal: 'left' }, children: _jsx(Box, { sx: { p: 2 }, children: _jsx(Autocomplete, { disabled: disabled, multiple: multiple, sx: { minWidth: '300px' }, options: allUserIds, renderInput: params => _jsx(TextField, { ...params, label: t(i18nLabel), size: "small" }), renderOption: (props, _userId) => {
16
18
  const user = users[_userId];
17
19
  return (_jsx("li", { ...props, children: _jsxs(Box, { sx: {
18
20
  display: 'grid',
@@ -21,6 +23,13 @@ const UserList = ({ buttonSx = {}, userId, onChange, i18nLabel }) => {
21
23
  gridTemplateAreas: `"profile name"\n"profile email"`,
22
24
  columnGap: 1.5
23
25
  }, children: [_jsx(HowlerAvatar, { sx: { gridArea: 'profile', alignSelf: 'center', height: '32px', width: '32px' }, userId: user.username }), _jsx(Typography, { sx: { gridArea: 'name' }, variant: "body1", children: user.name }), _jsx(Typography, { sx: { gridArea: 'email' }, variant: "caption", children: user.email })] }) }));
24
- }, value: userId, onChange: (__, option) => onChange(option) }) }) })] }));
26
+ }, value: userIds, onChange: (__, options) => {
27
+ if (multiple) {
28
+ onChange(Array.isArray(options) ? options : [options]);
29
+ }
30
+ else {
31
+ onChange([Array.isArray(options) ? (options[0] ?? null) : options]);
32
+ }
33
+ } }) }) })] }));
25
34
  };
26
35
  export default UserList;
@@ -80,7 +80,7 @@ const Phrase = ({ value = '', variant = 'outlined', suggestions = [], lexer, sug
80
80
  onSelectCapture: _onSelectCapture,
81
81
  startAdornment: startAdornment && _jsx(InputAdornment, { position: "start", children: startAdornment }),
82
82
  endAdornment: endAdornment && _jsx(InputAdornment, { position: "end", children: endAdornment })
83
- } }), _jsx(Popper, { anchorEl: containerRef.current, style: { width: '100%', zIndex: 100 }, open: optionsOpen && (options.length > 0 || (debug && analysisRef.current?.tokens.length > 0)), disablePortal: true, children: _jsx(Paper, { elevation: 2, sx: { maxHeight: 200, overflow: 'auto', borderTopRightRadius: 0, borderTopLeftRadius: 0 }, children: _jsx(MenuList, { ref: menuRef, onKeyDown: _onMenuKeyDown, sx: {
83
+ } }), _jsx(Popper, { anchorEl: containerRef.current, style: { width: '100%', zIndex: 100 }, open: optionsOpen && (options.length > 0 || (debug && analysisRef.current?.tokens.length > 0)), disablePortal: true, children: _jsx(Paper, { elevation: 1, sx: { maxHeight: 200, overflow: 'auto', borderTopRightRadius: 0, borderTopLeftRadius: 0 }, children: _jsx(MenuList, { ref: menuRef, onKeyDown: _onMenuKeyDown, sx: {
84
84
  '&:focus': {
85
85
  outline: 'none'
86
86
  }
@@ -0,0 +1,12 @@
1
+ import { type CardProps } from '@mui/material';
2
+ import type { Case } from '@cccsaurora/howler-ui/models/entities/generated/Case';
3
+ import { type FC } from 'react';
4
+ declare const CaseCard: FC<{
5
+ case?: Case;
6
+ caseId?: string;
7
+ className?: string;
8
+ slotProps?: {
9
+ card?: CardProps;
10
+ };
11
+ }>;
12
+ export default CaseCard;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { CheckCircleOutline, HourglassBottom, RadioButtonUnchecked, UpdateOutlined } from '@mui/icons-material';
3
+ import { Card, Chip, Divider, Grid, Skeleton, Stack, Tooltip, Typography, useTheme } from '@mui/material';
4
+ import api from '@cccsaurora/howler-ui/api';
5
+ import StatusIcon from '@cccsaurora/howler-ui/components/elements/case/StatusIcon';
6
+ import HowlerAvatar from '@cccsaurora/howler-ui/components/elements/display/HowlerAvatar';
7
+ import PluginChip from '@cccsaurora/howler-ui/components/elements/PluginChip';
8
+ import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
9
+ import dayjs from 'dayjs';
10
+ import { countBy } from 'lodash-es';
11
+ import { useEffect, useState } from 'react';
12
+ import { useTranslation } from 'react-i18next';
13
+ import { twitterShort } from '@cccsaurora/howler-ui/utils/utils';
14
+ const STATUS_COLORS = {
15
+ resolved: 'success'
16
+ };
17
+ const CaseCard = ({ case: providedCase, caseId, className, slotProps }) => {
18
+ const { t } = useTranslation();
19
+ const { dispatchApi } = useMyApi();
20
+ const theme = useTheme();
21
+ const [_case, setCase] = useState(providedCase);
22
+ useEffect(() => {
23
+ if (providedCase) {
24
+ setCase(providedCase);
25
+ }
26
+ }, [providedCase]);
27
+ useEffect(() => {
28
+ if (caseId) {
29
+ dispatchApi(api.v2.case.get(caseId), { throwError: false }).then(setCase);
30
+ }
31
+ }, [caseId, dispatchApi]);
32
+ if (!_case) {
33
+ return _jsx(Skeleton, { variant: "rounded", height: 250, sx: { mb: 1 }, className: className });
34
+ }
35
+ return (_jsx(Card, { variant: "outlined", ...slotProps?.card, sx: [
36
+ { p: 1, mb: 1, borderColor: theme.palette[STATUS_COLORS[_case.status]]?.main },
37
+ ...(Array.isArray(slotProps?.card?.sx) ? slotProps.card.sx : slotProps?.card?.sx ? [slotProps.card.sx] : [])
38
+ ], className: className, children: _jsx(Stack, { direction: "row", alignItems: "start", spacing: 1, children: _jsxs(Stack, { sx: { flex: 1 }, spacing: 1, children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { variant: "h6", display: "flex", alignItems: "start", children: _case.title }), _jsx(StatusIcon, { status: _case.status }), _jsx("div", { style: { flex: 1 } }), _case.start && _case.end && (_jsx(Tooltip, { title: dayjs(_case.updated).toString(), children: _jsx(Chip, { icon: _jsx(HourglassBottom, { fontSize: "small" }), size: "small", label: twitterShort(_case.start) + ' - ' + twitterShort(_case.end) }) })), _jsx(Tooltip, { title: dayjs(_case.updated).toString(), children: _jsx(Chip, { icon: _jsx(UpdateOutlined, { fontSize: "small" }), size: "small", label: twitterShort(_case.updated) }) })] }), _jsx(Typography, { variant: "caption", color: "textSecondary", children: _case.summary.trim().split('\n')[0] }), _case.participants?.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Divider, { flexItem: true }), _jsx(Stack, { direction: "row", spacing: 1, children: _case.participants?.map(participant => (_jsx(HowlerAvatar, { sx: { height: '20px', width: '20px' }, userId: participant }, participant))) })] })), _jsx(Divider, { flexItem: true }), _jsxs(Grid, { container: true, spacing: 1, children: [_case.targets?.map(indicator => (_jsx(Grid, { item: true, children: _jsx(PluginChip, { size: "small", color: "primary", context: "casecard", variant: "outlined", value: indicator, label: indicator }) }, indicator))), _case.targets?.length > 0 && (_case.indicators?.length > 0 || _case.threats?.length > 0) && (_jsx(Grid, { item: true, children: _jsx(Divider, { orientation: "vertical" }) })), _case.indicators?.map(indicator => (_jsx(Grid, { item: true, children: _jsx(PluginChip, { variant: "outlined", context: "casecard", value: indicator, label: indicator }) }, indicator))), _case.indicators?.length > 0 && _case.threats?.length > 0 && (_jsx(Grid, { item: true, children: _jsx(Divider, { orientation: "vertical" }) })), _case.threats?.map(indicator => (_jsx(Grid, { item: true, children: _jsx(PluginChip, { size: "small", color: "warning", variant: "outlined", context: "casecard", value: indicator, label: indicator }) }, indicator)))] }), _case.tasks?.length > 0 && (_jsxs(_Fragment, { children: [_jsx(Divider, { flexItem: true }), _jsxs(Stack, { spacing: 0.5, alignItems: "start", children: [_case.tasks.some(task => task.complete) && (_jsx(Chip, { size: "small", color: "success", icon: _jsx(CheckCircleOutline, {}), label: `${countBy(_case.tasks, task => task.complete).true} ${t('complete')}` })), _case.tasks
39
+ .filter(task => !task.complete)
40
+ .map(task => (_jsx(Chip, { icon: _jsx(RadioButtonUnchecked, {}), label: task.summary }, task.id)))] })] }))] }) }) }, _case.case_id));
41
+ };
42
+ export default CaseCard;
@@ -0,0 +1,6 @@
1
+ import type { Case } from '@cccsaurora/howler-ui/models/entities/generated/Case';
2
+ type PreviewProps = {
3
+ case: Case;
4
+ };
5
+ declare const _default: import("react").NamedExoticComponent<PreviewProps>;
6
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CheckCircleOutline, HourglassBottom, RadioButtonUnchecked, UpdateOutlined } from '@mui/icons-material';
3
+ import { Chip, Stack, Tooltip, Typography, useTheme } from '@mui/material';
4
+ import dayjs from 'dayjs';
5
+ import { countBy } from 'lodash-es';
6
+ import { memo } from 'react';
7
+ import { useTranslation } from 'react-i18next';
8
+ import { twitterShort } from '@cccsaurora/howler-ui/utils/utils';
9
+ import HowlerAvatar from '../display/HowlerAvatar';
10
+ import StatusIcon from './StatusIcon';
11
+ const CasePreview = ({ case: _case }) => {
12
+ const { t } = useTranslation();
13
+ const theme = useTheme();
14
+ const taskCounts = countBy(_case.tasks, task => task.complete);
15
+ return (_jsxs(Stack, { flex: 1, spacing: 1, sx: { overflow: 'hidden', borderBottom: `thin solid ${theme.palette.divider}`, pb: 1, mb: 0 }, children: [_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Stack, { spacing: 1, children: [_jsx(Typography, { variant: "body1", fontWeight: "bold", children: _case.title }), _jsx(Typography, { variant: "caption", color: "textSecondary", children: _case.summary.trim().split('\n')[0] })] }), _jsx(StatusIcon, { status: _case.status }), _jsx("div", { style: { flex: 1 } }), _jsxs(Stack, { spacing: 1, alignItems: "end", children: [_case.start && _case.end && (_jsx(Tooltip, { title: dayjs(_case.updated).toString(), children: _jsx(Chip, { icon: _jsx(HourglassBottom, { fontSize: "small" }), size: "small", label: twitterShort(_case.start) + ' - ' + twitterShort(_case.end) }) })), _jsx(Tooltip, { title: dayjs(_case.updated).toString(), children: _jsx(Chip, { icon: _jsx(UpdateOutlined, { fontSize: "small" }), size: "small", label: twitterShort(_case.updated) }) })] })] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_case.participants?.length > 0 && (_jsx(Stack, { direction: "row", spacing: 1, children: _case.participants?.map(participant => (_jsx(HowlerAvatar, { sx: { height: '24px', width: '24px' }, userId: participant }, participant))) })), _jsx(Chip, { color: "success", icon: _jsx(CheckCircleOutline, {}), label: `${taskCounts.true ?? 0} ${t('complete')}` }), _jsx(Chip, { icon: _jsx(RadioButtonUnchecked, {}), label: `${taskCounts.false ?? 0} ${t('incomplete')}` })] })] }));
16
+ };
17
+ export default memo(CasePreview);
@@ -0,0 +1,5 @@
1
+ import type { FC } from 'react';
2
+ declare const StatusIcon: FC<{
3
+ status: string;
4
+ }>;
5
+ export default StatusIcon;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Check, HourglassBottom, Pause, Troubleshoot } from '@mui/icons-material';
3
+ import { Tooltip } from '@mui/material';
4
+ import { useTranslation } from 'react-i18next';
5
+ const StatusIcon = ({ status }) => {
6
+ const { t } = useTranslation();
7
+ return (_jsx(Tooltip, { title: t(`page.cases.status.${status}`), children: {
8
+ 'in-progress': _jsx(HourglassBottom, { color: "warning" }),
9
+ 'on-hold': _jsx(Pause, { color: "disabled" }),
10
+ resolved: _jsx(Check, { color: "success" })
11
+ }[status] ?? _jsx(Troubleshoot, { color: "primary" }) }));
12
+ };
13
+ export default StatusIcon;
@@ -15,8 +15,8 @@ interface ChipPopperProps {
15
15
  onToggle?: (show: boolean) => void;
16
16
  onDelete?: (event?: any) => void;
17
17
  toggleOnDelete?: boolean;
18
- closeOnClick?: boolean;
19
18
  disablePortal?: boolean;
19
+ closeOnClick?: boolean;
20
20
  }
21
21
  declare const _default: import("react").NamedExoticComponent<ChipPopperProps>;
22
22
  export default _default;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Card } from '@mui/material';
3
3
  import { memo } from 'react';
4
- const HowlerCard = props => (_jsx(Card, { style: { outline: 'none' }, elevation: props.variant !== 'outlined' ? 4 : 0, ...props }));
4
+ const HowlerCard = props => _jsx(Card, { elevation: props.variant !== 'outlined' ? 1 : 0, ...props });
5
5
  export default memo(HowlerCard);
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Box, Modal as MuiModal } from '@mui/material';
3
3
  import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
4
+ import { has } from 'lodash-es';
4
5
  import { useCallback, useContext } from 'react';
5
6
  const Modal = () => {
6
7
  const { content, setContent, options } = useContext(ModalContext);
@@ -15,6 +16,7 @@ const Modal = () => {
15
16
  left: '50%',
16
17
  maxWidth: options.maxWidth || '1200px',
17
18
  maxHeight: options.maxHeight || '400px',
19
+ height: has(options, 'height') ? options.height : '100%',
18
20
  transform: 'translate(-50%, -50%)',
19
21
  backgroundColor: 'background.paper',
20
22
  borderRadius: theme.shape.borderRadius,
@@ -3,9 +3,9 @@ import { MoreHoriz } from '@mui/icons-material';
3
3
  import { Box, CircularProgress, Divider, FormControl, FormControlLabel, FormLabel, IconButton, Menu, Radio, RadioGroup, Stack, Switch, useMediaQuery } from '@mui/material';
4
4
  import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
5
5
  import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
6
- import { HitContext } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
7
- import { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
8
6
  import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
7
+ import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
8
+ import { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
9
9
  import { ViewContext } from '@cccsaurora/howler-ui/components/app/providers/ViewProvider';
10
10
  import useHitActions from '@cccsaurora/howler-ui/components/hooks/useHitActions';
11
11
  import { useMyLocalStorageProvider } from '@cccsaurora/howler-ui/components/hooks/useMyLocalStorage';
@@ -30,8 +30,8 @@ const HitActions = ({ hit, orientation = 'horizontal' }) => {
30
30
  const getCurrentViews = useContextSelector(ViewContext, ctx => ctx.getCurrentViews);
31
31
  const selected = useContextSelector(ParameterContext, ctx => ctx?.selected);
32
32
  const setSelected = useContextSelector(ParameterContext, ctx => ctx?.setSelected);
33
- const clearSelectedHits = useContextSelector(HitContext, ctx => ctx.clearSelectedHits);
34
- const nextHit = useContextSelector(HitSearchContext, ctx => {
33
+ const clearSelectedHits = useContextSelector(RecordContext, ctx => ctx.clearSelectedRecords);
34
+ const nextHit = useContextSelector(RecordSearchContext, ctx => {
35
35
  if (!ctx?.response || !selected) {
36
36
  return null;
37
37
  }