@cccsaurora/howler-ui 2.18.0-dev.824 → 2.18.0-dev.840

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 (330) hide show
  1. package/api/index.d.ts +4 -0
  2. package/api/index.js +10 -2
  3. package/api/search/case.d.ts +4 -0
  4. package/api/search/case.js +8 -0
  5. package/api/search/facet/hit.d.ts +1 -3
  6. package/api/search/facet/index.d.ts +3 -1
  7. package/api/search/index.d.ts +2 -1
  8. package/api/search/index.js +2 -1
  9. package/api/socket/index.d.ts +3 -0
  10. package/api/socket/index.js +6 -0
  11. package/api/socket/viewers.d.ts +2 -0
  12. package/api/socket/viewers.js +8 -0
  13. package/api/socket/viewers.test.js +44 -0
  14. package/api/v2/case/index.d.ts +9 -0
  15. package/api/v2/case/index.js +21 -0
  16. package/api/v2/case/items.d.ts +6 -0
  17. package/api/v2/case/items.js +18 -0
  18. package/api/v2/case/rules.d.ts +6 -0
  19. package/api/v2/case/rules.js +18 -0
  20. package/api/v2/index.d.ts +4 -0
  21. package/api/v2/index.js +6 -0
  22. package/api/v2/search/facet.d.ts +3 -0
  23. package/api/v2/search/facet.js +12 -0
  24. package/api/v2/search/index.d.ts +5 -0
  25. package/api/v2/search/index.js +24 -0
  26. package/commons/components/leftnav/LeftNavDrawer.js +1 -1
  27. package/components/app/App.js +41 -8
  28. package/components/app/hooks/useMatchers.d.ts +1 -1
  29. package/components/app/hooks/useMatchers.js +23 -11
  30. package/components/app/hooks/useMatchers.test.js +22 -22
  31. package/components/app/hooks/useTitle.js +5 -5
  32. package/components/app/providers/FavouritesProvider.js +2 -2
  33. package/components/app/providers/ModalProvider.d.ts +1 -0
  34. package/components/app/providers/ParameterProvider.d.ts +9 -2
  35. package/components/app/providers/ParameterProvider.js +165 -240
  36. package/components/app/providers/ParameterProvider.test.js +346 -94
  37. package/components/app/providers/RecordProvider.d.ts +23 -0
  38. package/components/app/providers/{HitProvider.js → RecordProvider.js} +41 -41
  39. package/components/app/providers/{HitSearchProvider.d.ts → RecordSearchProvider.d.ts} +6 -6
  40. package/components/app/providers/{HitSearchProvider.js → RecordSearchProvider.js} +12 -17
  41. package/components/app/providers/{HitSearchProvider.test.js → RecordSearchProvider.test.js} +52 -71
  42. package/components/app/providers/SocketProvider.d.ts +11 -2
  43. package/components/app/providers/SocketProvider.js +18 -5
  44. package/components/app/providers/UserListProvider.js +28 -8
  45. package/components/elements/ContextMenu.d.ts +56 -0
  46. package/components/elements/ContextMenu.js +109 -0
  47. package/components/elements/ContextMenu.test.d.ts +1 -0
  48. package/components/elements/ContextMenu.test.js +215 -0
  49. package/components/{routes/overviews/OverviewEditor.js → elements/MarkdownEditor.js} +3 -3
  50. package/components/elements/ObjectDetails.d.ts +6 -0
  51. package/components/elements/{hit/HitDetails.js → ObjectDetails.js} +17 -17
  52. package/components/elements/PluginTypography.d.ts +2 -1
  53. package/components/elements/PluginTypography.js +3 -2
  54. package/components/elements/UserList.d.ts +5 -2
  55. package/components/elements/UserList.js +18 -8
  56. package/components/elements/addons/search/phrase/Phrase.js +1 -1
  57. package/components/elements/case/CaseCard.d.ts +12 -0
  58. package/components/elements/case/CaseCard.js +42 -0
  59. package/components/elements/case/CasePreview.d.ts +6 -0
  60. package/components/elements/case/CasePreview.js +17 -0
  61. package/components/elements/case/StatusIcon.d.ts +5 -0
  62. package/components/elements/case/StatusIcon.js +13 -0
  63. package/components/elements/display/ChipPopper.d.ts +1 -1
  64. package/components/elements/display/ChipPopper.js +5 -5
  65. package/components/elements/display/HowlerCard.js +1 -1
  66. package/components/elements/display/Modal.js +2 -0
  67. package/components/elements/hit/HitActions.js +4 -4
  68. package/components/elements/hit/HitBanner.d.ts +1 -0
  69. package/components/elements/hit/HitBanner.js +29 -49
  70. package/components/elements/hit/HitCard.d.ts +2 -0
  71. package/components/elements/hit/HitCard.js +7 -7
  72. package/components/elements/hit/HitLabels.js +2 -2
  73. package/components/elements/hit/HitLinks.js +1 -1
  74. package/components/elements/hit/HitOutline.d.ts +1 -0
  75. package/components/elements/hit/HitOutline.js +3 -3
  76. package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
  77. package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +10 -4
  78. package/components/elements/hit/HitSummary.d.ts +2 -1
  79. package/components/elements/hit/HitSummary.js +6 -5
  80. package/components/elements/hit/aggregate/HitGraph.js +8 -8
  81. package/components/elements/hit/elements/AnalyticLink.d.ts +9 -0
  82. package/components/elements/hit/elements/AnalyticLink.js +22 -0
  83. package/components/elements/hit/elements/Assigned.js +6 -3
  84. package/components/elements/hit/elements/Assigned.test.d.ts +1 -0
  85. package/components/elements/hit/elements/Assigned.test.js +65 -0
  86. package/components/elements/hit/outlines/DefaultOutline.js +1 -1
  87. package/components/elements/hit/related/RelatedRecords.js +63 -0
  88. package/components/elements/observable/ObservableCard.d.ts +6 -0
  89. package/components/elements/observable/ObservableCard.js +22 -0
  90. package/components/elements/observable/ObservablePreview.d.ts +6 -0
  91. package/components/elements/observable/ObservablePreview.js +12 -0
  92. package/components/elements/{hit/HitComments.d.ts → record/RecordComments.d.ts} +5 -4
  93. package/components/elements/{hit/HitComments.js → record/RecordComments.js} +29 -28
  94. package/components/{routes/hits/search/HitContextMenu.d.ts → elements/record/RecordContextMenu.d.ts} +3 -3
  95. package/components/elements/record/RecordContextMenu.js +256 -0
  96. package/components/elements/record/RecordContextMenu.test.d.ts +1 -0
  97. package/components/{routes/hits/search/HitContextMenu.test.js → elements/record/RecordContextMenu.test.js} +94 -39
  98. package/components/elements/record/RecordRelated.d.ts +7 -0
  99. package/components/elements/record/RecordRelated.js +34 -0
  100. package/components/elements/{hit/HitWorklog.d.ts → record/RecordWorklog.d.ts} +4 -3
  101. package/components/elements/{hit/HitWorklog.js → record/RecordWorklog.js} +15 -13
  102. package/components/elements/view/ViewTitle.d.ts +1 -0
  103. package/components/elements/view/ViewTitle.js +9 -2
  104. package/components/hooks/useHitActions.d.ts +1 -1
  105. package/components/hooks/useHitActions.js +4 -4
  106. package/components/hooks/useMyPreferences.js +10 -1
  107. package/components/hooks/useMySearch.js +2 -2
  108. package/components/hooks/useMySitemap.js +4 -1
  109. package/components/hooks/useMyTheme.js +9 -2
  110. package/components/hooks/{useHitSelection.d.ts → useRecordSelection.d.ts} +2 -2
  111. package/components/hooks/{useHitSelection.js → useRecordSelection.js} +12 -33
  112. package/components/hooks/useRelatedRecords.d.ts +13 -0
  113. package/components/hooks/useRelatedRecords.js +32 -0
  114. package/components/routes/action/edit/ActionEditor.js +2 -2
  115. package/components/routes/action/useMyActionFunctions.js +4 -22
  116. package/components/routes/action/view/ActionSearch.js +1 -1
  117. package/components/routes/advanced/QueryBuilder.js +1 -1
  118. package/components/routes/advanced/QueryEditor.js +3 -3
  119. package/components/routes/advanced/historyCompletionProvider.js +3 -3
  120. package/components/routes/analytics/AnalyticDetails.js +2 -2
  121. package/components/routes/analytics/AnalyticSearch.js +1 -1
  122. package/components/routes/cases/CaseViewer.d.ts +2 -0
  123. package/components/routes/cases/CaseViewer.js +44 -0
  124. package/components/routes/cases/CaseViewer.test.d.ts +1 -0
  125. package/components/routes/cases/CaseViewer.test.js +133 -0
  126. package/components/routes/cases/Cases.d.ts +2 -0
  127. package/components/routes/cases/Cases.js +148 -0
  128. package/components/routes/cases/constants.d.ts +6 -0
  129. package/components/routes/cases/constants.js +6 -0
  130. package/components/routes/cases/detail/AlertPanel.d.ts +6 -0
  131. package/components/routes/cases/detail/AlertPanel.js +33 -0
  132. package/components/routes/cases/detail/CaseAssets.d.ts +11 -0
  133. package/components/routes/cases/detail/CaseAssets.js +104 -0
  134. package/components/routes/cases/detail/CaseAssets.test.d.ts +1 -0
  135. package/components/routes/cases/detail/CaseAssets.test.js +167 -0
  136. package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
  137. package/components/routes/cases/detail/CaseDashboard.js +66 -0
  138. package/components/routes/cases/detail/CaseDetails.d.ts +6 -0
  139. package/components/routes/cases/detail/CaseDetails.js +70 -0
  140. package/components/routes/cases/detail/CaseOverview.d.ts +7 -0
  141. package/components/routes/cases/detail/CaseOverview.js +43 -0
  142. package/components/routes/cases/detail/CaseRules.d.ts +7 -0
  143. package/components/routes/cases/detail/CaseRules.js +57 -0
  144. package/components/routes/cases/detail/CaseRules.test.d.ts +1 -0
  145. package/components/routes/cases/detail/CaseRules.test.js +221 -0
  146. package/components/routes/cases/detail/CaseSidebar.d.ts +8 -0
  147. package/components/routes/cases/detail/CaseSidebar.js +107 -0
  148. package/components/routes/cases/detail/CaseSidebar.test.d.ts +1 -0
  149. package/components/routes/cases/detail/CaseSidebar.test.js +266 -0
  150. package/components/routes/cases/detail/CaseTask.d.ts +11 -0
  151. package/components/routes/cases/detail/CaseTask.js +66 -0
  152. package/components/routes/cases/detail/CaseTimeline.d.ts +12 -0
  153. package/components/routes/cases/detail/CaseTimeline.js +106 -0
  154. package/components/routes/cases/detail/CaseTimeline.test.d.ts +1 -0
  155. package/components/routes/cases/detail/CaseTimeline.test.js +320 -0
  156. package/components/routes/cases/detail/CreateRuleDialog.d.ts +9 -0
  157. package/components/routes/cases/detail/CreateRuleDialog.js +163 -0
  158. package/components/routes/cases/detail/CreateRuleDialog.test.d.ts +1 -0
  159. package/components/routes/cases/detail/CreateRuleDialog.test.js +259 -0
  160. package/components/routes/cases/detail/ItemPage.d.ts +6 -0
  161. package/components/routes/cases/detail/ItemPage.js +95 -0
  162. package/components/routes/cases/detail/RelatedCasePanel.d.ts +6 -0
  163. package/components/routes/cases/detail/RelatedCasePanel.js +34 -0
  164. package/components/routes/cases/detail/TaskPanel.d.ts +7 -0
  165. package/components/routes/cases/detail/TaskPanel.js +52 -0
  166. package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +11 -0
  167. package/components/routes/cases/detail/aggregates/CaseAggregate.js +24 -0
  168. package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +6 -0
  169. package/components/routes/cases/detail/aggregates/SourceAggregate.js +26 -0
  170. package/components/routes/cases/detail/assets/Asset.d.ts +14 -0
  171. package/components/routes/cases/detail/assets/Asset.js +12 -0
  172. package/components/routes/cases/detail/assets/Asset.test.d.ts +1 -0
  173. package/components/routes/cases/detail/assets/Asset.test.js +72 -0
  174. package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +20 -0
  175. package/components/routes/cases/detail/sidebar/CaseFolder.js +83 -0
  176. package/components/routes/cases/detail/sidebar/CaseFolder.test.d.ts +1 -0
  177. package/components/routes/cases/detail/sidebar/CaseFolder.test.js +295 -0
  178. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.d.ts +34 -0
  179. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.js +103 -0
  180. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.d.ts +1 -0
  181. package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.js +363 -0
  182. package/components/routes/cases/detail/sidebar/FolderEntry.d.ts +25 -0
  183. package/components/routes/cases/detail/sidebar/FolderEntry.js +88 -0
  184. package/components/routes/cases/detail/sidebar/FolderEntry.test.d.ts +1 -0
  185. package/components/routes/cases/detail/sidebar/FolderEntry.test.js +206 -0
  186. package/components/routes/cases/detail/sidebar/RootDropZone.d.ts +5 -0
  187. package/components/routes/cases/detail/sidebar/RootDropZone.js +33 -0
  188. package/components/routes/cases/detail/sidebar/types.d.ts +9 -0
  189. package/components/routes/cases/detail/sidebar/utils.d.ts +3 -0
  190. package/components/routes/cases/detail/sidebar/utils.js +29 -0
  191. package/components/routes/cases/detail/sidebar/utils.test.d.ts +1 -0
  192. package/components/routes/cases/detail/sidebar/utils.test.js +82 -0
  193. package/components/routes/cases/hooks/useCase.d.ts +13 -0
  194. package/components/routes/cases/hooks/useCase.js +69 -0
  195. package/components/routes/cases/hooks/useCase.test.d.ts +1 -0
  196. package/components/routes/cases/hooks/useCase.test.js +141 -0
  197. package/components/routes/cases/modals/AddToCaseModal.d.ts +7 -0
  198. package/components/routes/cases/modals/AddToCaseModal.js +59 -0
  199. package/components/routes/cases/modals/AddToCaseModal.test.d.ts +1 -0
  200. package/components/routes/cases/modals/AddToCaseModal.test.js +313 -0
  201. package/components/routes/cases/modals/CaseRecordRow.d.ts +9 -0
  202. package/components/routes/cases/modals/CaseRecordRow.js +15 -0
  203. package/components/routes/cases/modals/CreateCaseModal.d.ts +7 -0
  204. package/components/routes/cases/modals/CreateCaseModal.js +55 -0
  205. package/components/routes/cases/modals/CreateCaseModal.test.d.ts +1 -0
  206. package/components/routes/cases/modals/CreateCaseModal.test.js +358 -0
  207. package/components/routes/cases/modals/RenameItemModal.d.ts +9 -0
  208. package/components/routes/cases/modals/RenameItemModal.js +48 -0
  209. package/components/routes/cases/modals/ResolveModal.d.ts +7 -0
  210. package/components/routes/cases/modals/ResolveModal.js +115 -0
  211. package/components/routes/cases/modals/ResolveModal.test.d.ts +1 -0
  212. package/components/routes/cases/modals/ResolveModal.test.js +394 -0
  213. package/components/routes/cases/modals/hooks.d.ts +7 -0
  214. package/components/routes/cases/modals/hooks.js +44 -0
  215. package/components/routes/cases/modals/types.d.ts +5 -0
  216. package/components/routes/cases/search/CaseAssigneeFilter.d.ts +6 -0
  217. package/components/routes/cases/search/CaseAssigneeFilter.js +33 -0
  218. package/components/routes/cases/search/CaseAssigneeFilter.test.d.ts +1 -0
  219. package/components/routes/cases/search/CaseAssigneeFilter.test.js +127 -0
  220. package/components/routes/cases/search/CaseDateFilter.d.ts +13 -0
  221. package/components/routes/cases/search/CaseDateFilter.js +26 -0
  222. package/components/routes/cases/search/CaseDateFilter.test.d.ts +1 -0
  223. package/components/routes/cases/search/CaseDateFilter.test.js +115 -0
  224. package/components/routes/cases/search/CaseStatusFilter.d.ts +6 -0
  225. package/components/routes/cases/search/CaseStatusFilter.js +13 -0
  226. package/components/routes/cases/search/CaseStatusFilter.test.d.ts +1 -0
  227. package/components/routes/cases/search/CaseStatusFilter.test.js +86 -0
  228. package/components/routes/dossiers/DossierEditor.js +2 -2
  229. package/components/routes/dossiers/DossierEditor.test.js +1 -1
  230. package/components/routes/help/ApiDocumentation.js +1 -1
  231. package/components/routes/help/HitBannerDocumentation.js +1 -0
  232. package/components/routes/help/HitDocumentation.js +1 -3
  233. package/components/routes/hits/search/InformationPane.d.ts +1 -0
  234. package/components/routes/hits/search/InformationPane.js +50 -63
  235. package/components/routes/hits/search/LayoutSettings.js +3 -3
  236. package/components/routes/hits/search/QuerySettings.js +2 -1
  237. package/components/routes/hits/search/QuerySettings.test.js +14 -9
  238. package/components/routes/hits/search/{HitBrowser.js → RecordBrowser.js} +9 -9
  239. package/components/routes/hits/search/{HitQuery.d.ts → RecordQuery.d.ts} +2 -2
  240. package/components/routes/hits/search/{HitQuery.js → RecordQuery.js} +6 -6
  241. package/components/routes/hits/search/SearchPane.js +26 -49
  242. package/components/routes/hits/search/ViewLink.js +3 -3
  243. package/components/routes/hits/search/ViewLink.test.js +8 -8
  244. package/components/routes/hits/search/grid/AddColumnModal.js +5 -4
  245. package/components/routes/hits/search/grid/EnhancedCell.d.ts +2 -1
  246. package/components/routes/hits/search/grid/EnhancedCell.js +2 -2
  247. package/components/routes/hits/search/grid/HitGrid.js +20 -18
  248. package/components/routes/hits/search/grid/{HitRow.d.ts → RecordRow.d.ts} +3 -2
  249. package/components/routes/hits/search/grid/{HitRow.js → RecordRow.js} +10 -8
  250. package/components/routes/hits/search/shared/IndexPicker.d.ts +2 -0
  251. package/components/routes/hits/search/shared/IndexPicker.js +20 -0
  252. package/components/routes/hits/view/HitViewer.js +12 -13
  253. package/components/routes/home/ViewCard.js +47 -41
  254. package/components/routes/observables/ObservableViewer.d.ts +7 -0
  255. package/components/routes/observables/ObservableViewer.js +27 -0
  256. package/components/routes/overviews/OverviewViewer.js +2 -2
  257. package/components/routes/views/ViewComposer.js +46 -19
  258. package/locales/en/translation.json +122 -5
  259. package/locales/fr/translation.json +120 -5
  260. package/models/WithMetadata.d.ts +2 -1
  261. package/models/entities/generated/AttachmentsFile.d.ts +12 -0
  262. package/models/entities/generated/Case.d.ts +28 -0
  263. package/models/entities/generated/DestinationOriginal.d.ts +19 -0
  264. package/models/entities/generated/EmailAttachment.d.ts +8 -0
  265. package/models/entities/generated/EmailParent.d.ts +19 -0
  266. package/models/entities/generated/Enrichments.d.ts +7 -0
  267. package/models/entities/generated/EnrichmentsIndicator.d.ts +21 -0
  268. package/models/entities/generated/Hit.d.ts +1 -0
  269. package/models/entities/generated/Howler.d.ts +0 -5
  270. package/models/entities/generated/HttpResponse.d.ts +11 -0
  271. package/models/entities/generated/Item.d.ts +9 -0
  272. package/models/entities/generated/Observable.d.ts +85 -0
  273. package/models/entities/generated/ObservableCloud.d.ts +20 -0
  274. package/models/entities/generated/ObservableDestination.d.ts +23 -0
  275. package/models/entities/generated/ObservableEmail.d.ts +30 -0
  276. package/models/entities/generated/ObservableFile.d.ts +36 -0
  277. package/models/entities/generated/ObservableHowler.d.ts +42 -0
  278. package/models/entities/generated/ObservableHttp.d.ts +11 -0
  279. package/models/entities/generated/ObservableObserver.d.ts +21 -0
  280. package/models/entities/generated/ObservableOrganization.d.ts +7 -0
  281. package/models/entities/generated/ObservableProcess.d.ts +34 -0
  282. package/models/entities/generated/ObservableSource.d.ts +23 -0
  283. package/models/entities/generated/ObservableThreat.d.ts +21 -0
  284. package/models/entities/generated/ObservableTls.d.ts +12 -0
  285. package/models/entities/generated/ObserverIngress.d.ts +9 -0
  286. package/models/entities/generated/Rule.d.ts +6 -9
  287. package/models/entities/generated/Task.d.ts +10 -0
  288. package/models/entities/generated/Threat.d.ts +2 -2
  289. package/models/entities/generated/{Enrichment.d.ts → ThreatEnrichment.d.ts} +1 -1
  290. package/models/entities/generated/View.d.ts +1 -0
  291. package/models/socket/CaseUpdate.d.ts +5 -0
  292. package/models/socket/ViewersUpdate.d.ts +4 -0
  293. package/package.json +26 -6
  294. package/plugins/clue/components/ClueTypography.js +2 -2
  295. package/plugins/clue/utils.d.ts +2 -1
  296. package/tests/mocks.d.ts +11 -1
  297. package/tests/mocks.js +12 -7
  298. package/tests/server-handlers.js +6 -1
  299. package/tests/utils.d.ts +4 -0
  300. package/tests/utils.js +20 -0
  301. package/utils/constants.d.ts +4 -3
  302. package/utils/constants.js +6 -0
  303. package/utils/hitFunctions.d.ts +2 -1
  304. package/utils/hitFunctions.js +4 -4
  305. package/utils/socketUtils.d.ts +14 -0
  306. package/utils/socketUtils.js +17 -1
  307. package/utils/socketUtils.test.d.ts +1 -0
  308. package/utils/socketUtils.test.js +59 -0
  309. package/utils/typeUtils.d.ts +7 -0
  310. package/utils/typeUtils.js +27 -0
  311. package/utils/viewUtils.js +3 -0
  312. package/components/app/providers/HitProvider.d.ts +0 -22
  313. package/components/elements/display/icons/BundleButton.d.ts +0 -6
  314. package/components/elements/display/icons/BundleButton.js +0 -32
  315. package/components/elements/hit/HitRelated.d.ts +0 -6
  316. package/components/elements/hit/HitRelated.js +0 -7
  317. package/components/routes/help/BundleDocumentation.d.ts +0 -3
  318. package/components/routes/help/BundleDocumentation.js +0 -12
  319. package/components/routes/help/markdown/en/bundles.md.js +0 -1
  320. package/components/routes/help/markdown/fr/bundles.md.js +0 -1
  321. package/components/routes/hits/search/BundleParentMenu.d.ts +0 -6
  322. package/components/routes/hits/search/BundleParentMenu.js +0 -32
  323. package/components/routes/hits/search/BundleScroller.d.ts +0 -2
  324. package/components/routes/hits/search/BundleScroller.js +0 -6
  325. package/components/routes/hits/search/HitContextMenu.js +0 -229
  326. /package/{components/app/providers/HitSearchProvider.test.d.ts → api/socket/viewers.test.d.ts} +0 -0
  327. /package/components/{routes/hits/search/HitContextMenu.test.d.ts → app/providers/RecordSearchProvider.test.d.ts} +0 -0
  328. /package/components/{routes/overviews/OverviewEditor.d.ts → elements/MarkdownEditor.d.ts} +0 -0
  329. /package/components/elements/hit/{HitDetails.d.ts → related/RelatedRecords.d.ts} +0 -0
  330. /package/components/routes/hits/search/{HitBrowser.d.ts → RecordBrowser.d.ts} +0 -0
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { render, screen } from '@testing-library/react';
3
+ import { SocketContext } from '@cccsaurora/howler-ui/components/app/providers/SocketProvider';
4
+ import { createMockHit } from '@cccsaurora/howler-ui/tests/utils';
5
+ import { describe, expect, it, vi } from 'vitest';
6
+ // ---------------------------------------------------------------------------
7
+ // Hoisted mocks
8
+ // ---------------------------------------------------------------------------
9
+ vi.mock('commons/components/app/hooks', () => ({
10
+ useAppUser: () => ({ user: { username: 'current-user' } })
11
+ }));
12
+ vi.mock('components/elements/display/HowlerAvatar', () => ({
13
+ default: ({ userId }) => _jsx("div", { id: `avatar-${userId}`, children: userId })
14
+ }));
15
+ vi.mock('react-i18next', () => ({
16
+ useTranslation: () => ({
17
+ t: (key) => key
18
+ })
19
+ }));
20
+ // ---------------------------------------------------------------------------
21
+ // Import after mocks
22
+ // ---------------------------------------------------------------------------
23
+ import { HitLayout } from '../HitLayout';
24
+ import Assigned from './Assigned';
25
+ // ---------------------------------------------------------------------------
26
+ // Helpers
27
+ // ---------------------------------------------------------------------------
28
+ const createWrapper = (viewers) => {
29
+ const Wrapper = ({ children }) => (_jsx(SocketContext.Provider, { value: {
30
+ viewers,
31
+ addListener: vi.fn(),
32
+ removeListener: vi.fn(),
33
+ emit: vi.fn(),
34
+ status: 1,
35
+ reconnect: vi.fn(),
36
+ isOpen: () => true,
37
+ fetchViewers: vi.fn()
38
+ }, children: children }));
39
+ return Wrapper;
40
+ };
41
+ // ---------------------------------------------------------------------------
42
+ // Tests
43
+ // ---------------------------------------------------------------------------
44
+ describe('Assigned', () => {
45
+ it('renders the assignment avatar', () => {
46
+ const hit = createMockHit({ howler: { assignment: 'analyst-1' } });
47
+ render(_jsx(Assigned, { hit: hit, layout: HitLayout.COMFY }), { wrapper: createWrapper({}) });
48
+ expect(screen.getByTestId('avatar-analyst-1')).toBeInTheDocument();
49
+ });
50
+ it('renders viewer avatars from socket context, filtering out current user', () => {
51
+ const hit = createMockHit({ howler: { id: 'hit-1', assignment: 'analyst-1' } });
52
+ render(_jsx(Assigned, { hit: hit, layout: HitLayout.COMFY }), {
53
+ wrapper: createWrapper({ 'hit-1': ['viewer-a', 'viewer-b', 'current-user'] })
54
+ });
55
+ expect(screen.getByTestId('avatar-viewer-a')).toBeInTheDocument();
56
+ expect(screen.getByTestId('avatar-viewer-b')).toBeInTheDocument();
57
+ expect(screen.queryByText('current-user')).not.toBeInTheDocument();
58
+ });
59
+ it('renders no viewer avatars when no viewers exist', () => {
60
+ const hit = createMockHit({ howler: { id: 'hit-2', assignment: 'analyst-1' } });
61
+ render(_jsx(Assigned, { hit: hit, layout: HitLayout.COMFY }), { wrapper: createWrapper({}) });
62
+ expect(screen.getByTestId('avatar-analyst-1')).toBeInTheDocument();
63
+ expect(screen.queryByTestId('avatar-viewer-a')).not.toBeInTheDocument();
64
+ });
65
+ });
@@ -41,7 +41,7 @@ const DefaultOutline = ({ hit, fields, template, layout = HitLayout.NORMAL, read
41
41
  if (!displayedData) {
42
42
  return null;
43
43
  }
44
- return (_jsxs(React.Fragment, { children: [_jsx(Tooltip, { title: (config.indexes.hit[field]?.description ?? t('none')).split('\n')[0], children: _jsxs(Typography, { variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', fontWeight: "bold", children: [field, ":"] }) }), _jsx(PluginTypography, { context: "outline", variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', whiteSpace: "normal", sx: { width: '100%', wordBreak: 'break-all' }, value: displayedData, field: field, hit: hit, children: displayedData })] }, field));
44
+ return (_jsxs(React.Fragment, { children: [_jsx(Tooltip, { title: (config.indexes.hit[field]?.description ?? t('none')).split('\n')[0], children: _jsxs(Typography, { variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', fontWeight: "bold", children: [field, ":"] }) }), _jsx(PluginTypography, { context: "outline", variant: layout !== HitLayout.COMFY ? 'caption' : 'body1', whiteSpace: "normal", sx: { width: '100%', wordBreak: 'break-all' }, value: displayedData, field: field, obj: hit, children: displayedData })] }, field));
45
45
  })] }));
46
46
  };
47
47
  export default memo(DefaultOutline);
@@ -0,0 +1,63 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Link as LinkIcon } from '@mui/icons-material';
3
+ import { alpha, Box, Chip, Divider, Stack, useTheme } from '@mui/material';
4
+ import CasePreview from '@cccsaurora/howler-ui/components/elements/case/CasePreview';
5
+ import ChipPopper from '@cccsaurora/howler-ui/components/elements/display/ChipPopper';
6
+ import ObservablePreview from '@cccsaurora/howler-ui/components/elements/observable/ObservablePreview';
7
+ import useRelatedRecords from '@cccsaurora/howler-ui/components/hooks/useRelatedRecords';
8
+ import { identity, uniq } from 'lodash-es';
9
+ import { memo, useMemo, useState } from 'react';
10
+ import { useTranslation } from 'react-i18next';
11
+ import { Link } from 'react-router-dom';
12
+ import { isCase, isHit, isObservable } from '@cccsaurora/howler-ui/utils/typeUtils';
13
+ import HitPreview from '../HitPreview';
14
+ const RecordLink = ({ to, ariaLabel, children }) => {
15
+ const theme = useTheme();
16
+ return (_jsxs(Box, { p: 1, flex: 1, position: "relative", sx: {
17
+ '& > a': {
18
+ backgroundColor: 'transparent',
19
+ transition: theme.transitions.create('background-color', {
20
+ duration: theme.transitions.duration.shortest
21
+ }),
22
+ '&:hover': {
23
+ backgroundColor: alpha('#555', 0.5)
24
+ }
25
+ }
26
+ }, children: [_jsx(Link, { to: to, style: { position: 'absolute', top: 0, bottom: 0, left: 0, right: 0 }, target: "_blank", rel: "noopener noreferrer", "aria-label": ariaLabel }), children] }));
27
+ };
28
+ const RelatedRecords = ({ hit }) => {
29
+ const { t } = useTranslation();
30
+ const [open, setOpen] = useState(false);
31
+ const [filter, setFilter] = useState(null);
32
+ const related = useMemo(() => hit?.howler.related ?? [], [hit?.howler.related]);
33
+ const records = useRelatedRecords(related, open);
34
+ return (_jsxs(ChipPopper
35
+ // eslint-disable-next-line jsx-a11y/anchor-is-valid
36
+ , {
37
+ // eslint-disable-next-line jsx-a11y/anchor-is-valid
38
+ icon: _jsx(LinkIcon, {}), label: _jsx("span", { style: { cursor: 'pointer' }, children: t('hit.header.related', { count: related.length }) }), slotProps: {
39
+ chip: { disabled: related.length < 1 },
40
+ paper: {
41
+ elevation: 4,
42
+ onAuxClick: ev => ev.stopPropagation()
43
+ }
44
+ }, disablePortal: false, placement: "bottom-end", onToggle: _open => setOpen(_open), children: [_jsx(Stack, { direction: "row", spacing: 1, mb: 1, justifyContent: "end", children: uniq(records.map(record => record.__index))
45
+ .filter(identity)
46
+ .map(_type => (_jsx(Chip, { color: _type === filter ? 'primary' : 'default', label: _type, onClick: () => setFilter(current => (current === _type ? null : _type)) }, _type))) }), _jsxs(Stack, { maxWidth: "40vw", maxHeight: "70vh", sx: { overflowY: 'auto' }, children: [_jsx(Divider, {}), records
47
+ .filter(record => !filter || record.__index === filter)
48
+ .map(entry => {
49
+ if (isHit(entry)) {
50
+ const key = entry.howler.id;
51
+ return (_jsx(RecordLink, { to: `/hits/${key}`, ariaLabel: t('hit.header.view.hit', { id: key }), children: _jsx(HitPreview, { hit: entry }) }, key));
52
+ }
53
+ else if (isCase(entry)) {
54
+ const key = entry.case_id;
55
+ return (_jsx(RecordLink, { to: `/cases/${key}`, ariaLabel: t('hit.header.view.case', { id: key }), children: _jsx(CasePreview, { case: entry }) }, key));
56
+ }
57
+ else if (isObservable(entry)) {
58
+ const key = entry.howler.id;
59
+ return (_jsx(RecordLink, { to: `/observables/${key}`, ariaLabel: t('hit.header.view.observable', { id: key }), children: _jsx(ObservablePreview, { observable: entry }) }, key));
60
+ }
61
+ })] })] }));
62
+ };
63
+ export default memo(RelatedRecords);
@@ -0,0 +1,6 @@
1
+ import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
2
+ declare const _default: import("react").NamedExoticComponent<{
3
+ id?: string;
4
+ observable?: Observable;
5
+ }>;
6
+ export default _default;
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { CardContent, Skeleton } from '@mui/material';
3
+ import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
4
+ import HowlerCard from '@cccsaurora/howler-ui/components/elements/display/HowlerCard';
5
+ import { memo, useEffect } from 'react';
6
+ import { useContextSelector } from 'use-context-selector';
7
+ import ObservablePreview from './ObservablePreview';
8
+ const ObservableCard = ({ id, observable: _observable }) => {
9
+ const getRecord = useContextSelector(RecordContext, ctx => ctx.getRecord);
10
+ const observable = useContextSelector(RecordContext, ctx => _observable ?? ctx.records[id]);
11
+ useEffect(() => {
12
+ if (!observable) {
13
+ getRecord(id);
14
+ }
15
+ // eslint-disable-next-line react-hooks/exhaustive-deps
16
+ }, [id]);
17
+ if (!observable) {
18
+ return _jsx(Skeleton, { variant: "rounded", height: "200px" });
19
+ }
20
+ return (_jsx(HowlerCard, { sx: { position: 'relative' }, children: _jsx(CardContent, { children: _jsx(ObservablePreview, { observable: observable }) }) }));
21
+ };
22
+ export default memo(ObservableCard);
@@ -0,0 +1,6 @@
1
+ import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
2
+ type PreviewProps = {
3
+ observable: Observable;
4
+ };
5
+ declare const _default: import("react").NamedExoticComponent<PreviewProps>;
6
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { OpenInNew } from '@mui/icons-material';
3
+ import { Chip, IconButton, Stack, Typography, useTheme } from '@mui/material';
4
+ import { memo } from 'react';
5
+ import { useTranslation } from 'react-i18next';
6
+ import { Link } from 'react-router-dom';
7
+ const ObservablePreview = ({ observable }) => {
8
+ const { t } = useTranslation();
9
+ const theme = useTheme();
10
+ return (_jsx(Stack, { flex: 1, spacing: 1, sx: { overflow: 'hidden', borderBottom: `thin solid ${theme.palette.divider}`, pb: 1, mb: 0 }, children: _jsxs(Stack, { children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { variant: "body1", fontWeight: "bold", children: observable.event.provider }), _jsx("div", { style: { flex: 1 } }), _jsx(Chip, { label: observable.event.kind }), observable.event.reference && (_jsx(IconButton, { size: "small", component: Link, to: observable.event.reference, sx: { opacity: 1 }, target: "_blank", rel: "noopener noreferrer", children: _jsx(OpenInNew, { fontSize: "small" }) }))] }), observable.event.type && (_jsxs(Typography, { variant: "caption", children: [t('event.type'), " - ", observable.event.type.join(', ')] })), observable.event.module && (_jsxs(Typography, { variant: "caption", children: [t('event.module'), " - ", observable.event.module] }))] }) }));
11
+ };
12
+ export default memo(ObservablePreview);
@@ -1,11 +1,12 @@
1
1
  import type { HowlerUser } from '@cccsaurora/howler-ui/models/entities/HowlerUser';
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
  import { type FC } from 'react';
4
- interface HitCommentsProps {
5
- hit: Hit;
5
+ interface RecordCommentsProps {
6
+ record: Hit | Observable;
6
7
  users: {
7
8
  [id: string]: HowlerUser;
8
9
  };
9
10
  }
10
- declare const HitComments: FC<HitCommentsProps>;
11
- export default HitComments;
11
+ declare const RecordComments: FC<RecordCommentsProps>;
12
+ export default RecordComments;
@@ -10,12 +10,13 @@ import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
10
10
  import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
11
11
  import { useTranslation } from 'react-i18next';
12
12
  import { useNavigate } from 'react-router-dom';
13
+ import { isHit } from '@cccsaurora/howler-ui/utils/typeUtils';
13
14
  import { compareTimestamp, sortByTimestamp } from '@cccsaurora/howler-ui/utils/utils';
14
15
  import Comment from '../Comment';
15
16
  import HowlerAvatar from '../display/HowlerAvatar';
16
17
  import TypingIndicator from '../display/TypingIndicator';
17
18
  const MAX_LENGTH = 5000;
18
- const HitComments = ({ hit, users }) => {
19
+ const RecordComments = ({ record, users }) => {
19
20
  const { user } = useAppUser();
20
21
  const { t } = useTranslation();
21
22
  const navigate = useNavigate();
@@ -28,7 +29,7 @@ const HitComments = ({ hit, users }) => {
28
29
  const [length, setLength] = useState(0);
29
30
  const [analyticId, setAnalyticId] = useState();
30
31
  const [analyticComments, setAnalyticComments] = useState([]);
31
- const [comments, setComments] = useState(sortByTimestamp(hit?.howler?.comment));
32
+ const [comments, setComments] = useState(sortByTimestamp(record?.howler?.comment));
32
33
  const input = useRef();
33
34
  /**
34
35
  * Set the list of typers based on updates from the websocket
@@ -50,20 +51,20 @@ const HitComments = ({ hit, users }) => {
50
51
  // eslint-disable-next-line react-hooks/exhaustive-deps
51
52
  }, [handler]);
52
53
  useEffect(() => {
53
- if (hit?.howler?.analytic) {
54
- getMatchingAnalytic(hit).then(analytic => {
54
+ if (isHit(record) && record.howler.analytic) {
55
+ getMatchingAnalytic(record).then(analytic => {
55
56
  setAnalyticId(analytic?.analytic_id);
56
57
  setAnalyticComments(sortByTimestamp(analytic?.comment ?? []));
57
58
  });
58
59
  }
59
60
  // eslint-disable-next-line react-hooks/exhaustive-deps
60
- }, [getMatchingAnalytic, hit?.howler?.analytic]);
61
+ }, [getMatchingAnalytic, record]);
61
62
  const onSubmit = useCallback(async () => {
62
- if (!input.current?.value || !hit || input.current.value.length > MAX_LENGTH)
63
+ if (!input.current?.value || !record || input.current.value.length > MAX_LENGTH)
63
64
  return;
64
65
  setLoading(true);
65
66
  try {
66
- const result = await dispatchApi(api.hit.comments.post(hit.howler.id, input.current.value), {
67
+ const result = await dispatchApi(api.hit.comments.post(record.howler.id, input.current.value), {
67
68
  showError: true,
68
69
  throwError: true,
69
70
  logError: false
@@ -75,23 +76,23 @@ const HitComments = ({ hit, users }) => {
75
76
  finally {
76
77
  setLoading(false);
77
78
  }
78
- }, [dispatchApi, hit]);
79
+ }, [dispatchApi, record]);
79
80
  /**
80
81
  * Emit a typing event when textbox is focused
81
82
  */
82
83
  const onFocus = useCallback(() => emit({
83
84
  broadcast: true,
84
85
  action: 'typing',
85
- id: hit?.howler?.id
86
- }), [emit, hit?.howler?.id]);
86
+ id: record?.howler?.id
87
+ }), [emit, record?.howler?.id]);
87
88
  /**
88
89
  * Emit a stop typing event when textbox is blurred
89
90
  */
90
91
  const onBlur = useCallback(() => emit({
91
92
  broadcast: true,
92
93
  action: 'stop_typing',
93
- id: hit?.howler?.id
94
- }), [emit, hit?.howler?.id]);
94
+ id: record?.howler?.id
95
+ }), [emit, record?.howler?.id]);
95
96
  const onClear = useCallback(() => {
96
97
  input.current.value = '';
97
98
  setShowClear(false);
@@ -108,16 +109,16 @@ const HitComments = ({ hit, users }) => {
108
109
  }, [loading, onSubmit]);
109
110
  const checkLength = useCallback(() => setLength(input.current?.value.length), []);
110
111
  const handleDelete = useCallback(async (commentId) => {
111
- await dispatchApi(api.hit.comments.del(hit.howler.id, [commentId]), { throwError: true, showError: true });
112
+ await dispatchApi(api.hit.comments.del(record.howler.id, [commentId]), { throwError: true, showError: true });
112
113
  setComments(comments.filter(cmt => cmt.id !== commentId));
113
- }, [comments, dispatchApi, hit?.howler?.id]);
114
+ }, [comments, dispatchApi, record?.howler?.id]);
114
115
  const handleEdit = useCallback(async (commentId, editValue) => {
115
- await dispatchApi(api.hit.comments.put(hit.howler.id, commentId, editValue), {
116
+ await dispatchApi(api.hit.comments.put(record.howler.id, commentId, editValue), {
116
117
  throwError: true,
117
118
  showError: true
118
119
  });
119
120
  setComments(comments.map(cmt => (cmt.id !== commentId ? cmt : { ...cmt, value: editValue })));
120
- }, [comments, dispatchApi, hit?.howler?.id]);
121
+ }, [comments, dispatchApi, record?.howler?.id]);
121
122
  const handleQuote = useCallback((value) => {
122
123
  if (input.current) {
123
124
  // We use trimStart here so there isn't a bunch of newlines at the beginning of the comment
@@ -135,27 +136,27 @@ const HitComments = ({ hit, users }) => {
135
136
  }, []);
136
137
  const handleReact = useCallback(async (commentId, type) => {
137
138
  if (type) {
138
- await dispatchApi(api.hit.comments.react.put(hit.howler.id, commentId, type));
139
+ await dispatchApi(api.hit.comments.react.put(record.howler.id, commentId, type));
139
140
  setComments(comments.map(cmt => cmt.id !== commentId ? cmt : { ...cmt, reactions: { ...(cmt?.reactions ?? {}), [user.username]: type } }));
140
141
  }
141
142
  else {
142
- await dispatchApi(api.hit.comments.react.del(hit.howler.id, commentId));
143
+ await dispatchApi(api.hit.comments.react.del(record.howler.id, commentId));
143
144
  setComments(comments.map(cmt => cmt.id !== commentId
144
145
  ? cmt
145
146
  : { ...cmt, reactions: { ...(cmt?.reactions ?? {}), [user.username]: undefined } }));
146
147
  }
147
- }, [comments, dispatchApi, hit?.howler.id, user.username]);
148
+ }, [comments, dispatchApi, record?.howler.id, user.username]);
148
149
  /**
149
150
  * Handle loading the comments when the hit changes
150
151
  */
151
152
  useEffect(() => {
152
- if (hit?.howler?.comment) {
153
- setComments(hit?.howler?.comment.slice().sort((a, b) => compareTimestamp(b.timestamp, a.timestamp)));
153
+ if (record?.howler?.comment) {
154
+ setComments(record?.howler?.comment.slice().sort((a, b) => compareTimestamp(b.timestamp, a.timestamp)));
154
155
  }
155
- else if (!hit) {
156
+ else if (!record) {
156
157
  setComments([]);
157
158
  }
158
- }, [hit]);
159
+ }, [record]);
159
160
  /**
160
161
  * This is the comments for the analytic associated with the hit. We show this at the start of the comment
161
162
  * list, as if they've been pinned
@@ -164,13 +165,13 @@ const HitComments = ({ hit, users }) => {
164
165
  if (analyticComments.length < 1) {
165
166
  return null;
166
167
  }
167
- const displayedComments = analyticComments.filter(c => !c.detection || c.detection === hit?.howler.detection);
168
+ const displayedComments = analyticComments.filter(c => !c.detection || c.detection === record?.howler.detection);
168
169
  return (_jsxs(Accordion, { variant: "outlined", children: [_jsx(AccordionSummary, { expandIcon: _jsx(KeyboardArrowDown, { fontSize: "small" }), children: _jsx(Typography, { variant: "body1", children: t('comments.analytic', { count: displayedComments.length }) }) }), _jsx(AccordionDetails, { children: _jsx(Stack, { spacing: 1, children: displayedComments.map(c => (_jsx(Comment, { comment: c, extra: _jsx(Chip, { size: "small", variant: "outlined", onClick: () => navigate('/analytics' +
169
170
  (analyticId
170
171
  ? `/${analyticId}?tab=comments` + (c.detection ? `&filter=${c.detection}` : '')
171
- : '')), sx: theme => ({ marginLeft: '0 !important', mr: `${theme.spacing(2)} !important` }), label: `${hit?.howler?.analytic ?? 'Analytic'}${c.detection ? ' - ' + c.detection : ''}` }), users: users }, c.id))) }) })] }));
172
- }, [analyticComments, analyticId, hit?.howler.analytic, hit?.howler.detection, navigate, t, users]);
172
+ : '')), sx: theme => ({ marginLeft: '0 !important', mr: `${theme.spacing(2)} !important` }), label: `${record?.howler?.analytic ?? 'Analytic'}${c.detection ? ' - ' + c.detection : ''}` }), users: users }, c.id))) }) })] }));
173
+ }, [analyticComments, analyticId, record?.howler.analytic, record?.howler.detection, navigate, t, users]);
173
174
  const renderedComments = useMemo(() => comments.map(c => (_jsx(Comment, { comment: c, users: users, handleDelete: () => handleDelete(c.id), handleEdit: value => handleEdit(c.id, value), handleReact: type => handleReact(c.id, type), handleQuote: () => handleQuote(c.value) }, c.id))), [comments, handleDelete, handleEdit, handleQuote, handleReact, users]);
174
- return (_jsxs(Stack, { sx: { py: 1, pr: 1 }, spacing: 1, children: [hit && renderedAnalyticComments, _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(HowlerAvatar, { userId: user.username }), _jsx(TextField, { inputProps: { sx: theme => ({ fontSize: theme.typography.body2.fontSize }) }, InputLabelProps: { shrink: false }, placeholder: t('comments.add'), onKeyDown: checkForSubmit, onChangeCapture: checkLength, inputRef: input, onFocus: onFocus, onBlur: onBlur, error: length > MAX_LENGTH, fullWidth: true, multiline: true })] }), _jsxs(Stack, { direction: "row", alignItems: "center", children: [typers.length > 0 && (_jsxs(_Fragment, { children: [_jsx(AvatarGroup, { componentsProps: { additionalAvatar: { sx: { height: 24, width: 24, fontSize: '12px' } } }, children: typers.map(typer => (_jsx(HowlerAvatar, { userId: typer, sx: { height: 24, width: 24 } }, typer))) }), _jsx(TypingIndicator, {})] })), _jsx(FlexOne, {}), length > 0.9 * MAX_LENGTH && (_jsxs(Typography, { variant: "caption", sx: [{ opacity: 0.7, mr: 1 }, length > MAX_LENGTH && { color: 'error.main' }], children: [length, "/", MAX_LENGTH] })), showClear && (_jsx(IconButton, { size: "small", onClick: onClear, disabled: loading, children: _jsx(Clear, { fontSize: "small" }) })), _jsx(IconButton, { size: "small", onClick: onSubmit, disabled: loading || length > MAX_LENGTH, children: _jsx(Send, { fontSize: "small" }) })] }), hit ? (renderedComments) : (_jsxs(_Fragment, { children: [_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Skeleton, { width: 40, height: 40, variant: "circular" }), _jsx(Skeleton, { width: "100%", height: 80, variant: "rounded" })] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Skeleton, { width: 40, height: 40, variant: "circular" }), _jsx(Skeleton, { width: "100%", height: 100, variant: "rounded" })] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Skeleton, { width: 40, height: 40, variant: "circular" }), _jsx(Skeleton, { width: "100%", height: 80, variant: "rounded" })] })] }))] }));
175
+ return (_jsxs(Stack, { sx: { py: 1, pr: 1 }, spacing: 1, children: [record && renderedAnalyticComments, _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(HowlerAvatar, { userId: user.username }), _jsx(TextField, { inputProps: { sx: theme => ({ fontSize: theme.typography.body2.fontSize }) }, InputLabelProps: { shrink: false }, placeholder: t('comments.add'), onKeyDown: checkForSubmit, onChangeCapture: checkLength, inputRef: input, onFocus: onFocus, onBlur: onBlur, error: length > MAX_LENGTH, fullWidth: true, multiline: true })] }), _jsxs(Stack, { direction: "row", alignItems: "center", children: [typers.length > 0 && (_jsxs(_Fragment, { children: [_jsx(AvatarGroup, { componentsProps: { additionalAvatar: { sx: { height: 24, width: 24, fontSize: '12px' } } }, children: typers.map(typer => (_jsx(HowlerAvatar, { userId: typer, sx: { height: 24, width: 24 } }, typer))) }), _jsx(TypingIndicator, {})] })), _jsx(FlexOne, {}), length > 0.9 * MAX_LENGTH && (_jsxs(Typography, { variant: "caption", sx: [{ opacity: 0.7, mr: 1 }, length > MAX_LENGTH && { color: 'error.main' }], children: [length, "/", MAX_LENGTH] })), showClear && (_jsx(IconButton, { size: "small", onClick: onClear, disabled: loading, children: _jsx(Clear, { fontSize: "small" }) })), _jsx(IconButton, { size: "small", onClick: onSubmit, disabled: loading || length > MAX_LENGTH, children: _jsx(Send, { fontSize: "small" }) })] }), record ? (renderedComments) : (_jsxs(_Fragment, { children: [_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Skeleton, { width: 40, height: 40, variant: "circular" }), _jsx(Skeleton, { width: "100%", height: 80, variant: "rounded" })] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Skeleton, { width: 40, height: 40, variant: "circular" }), _jsx(Skeleton, { width: "100%", height: 100, variant: "rounded" })] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Skeleton, { width: 40, height: 40, variant: "circular" }), _jsx(Skeleton, { width: "100%", height: 80, variant: "rounded" })] })] }))] }));
175
176
  };
176
- export default HitComments;
177
+ export default RecordComments;
@@ -3,7 +3,7 @@ import React from 'react';
3
3
  /**
4
4
  * Props for the HitContextMenu component
5
5
  */
6
- interface HitContextMenuProps {
6
+ interface RecordContextMenuProps {
7
7
  /**
8
8
  * Function to extract the hit ID from a mouse event
9
9
  */
@@ -18,5 +18,5 @@ interface HitContextMenuProps {
18
18
  * Provides quick access to common hit actions including assessment, voting,
19
19
  * transitions, and exclusion filters based on template fields.
20
20
  */
21
- declare const HitContextMenu: FC<PropsWithChildren<HitContextMenuProps>>;
22
- export default HitContextMenu;
21
+ declare const RecordContextMenu: FC<PropsWithChildren<RecordContextMenuProps>>;
22
+ export default RecordContextMenu;
@@ -0,0 +1,256 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { AddCircleOutline, Assignment, CreateNewFolder, Edit, HowToVote, NoteAdd, OpenInNew, QueryStats, RemoveCircleOutline, SettingsSuggest, Terminal } from '@mui/icons-material';
3
+ import api from '@cccsaurora/howler-ui/api';
4
+ import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
5
+ import { ApiConfigContext } from '@cccsaurora/howler-ui/components/app/providers/ApiConfigProvider';
6
+ import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
7
+ import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
8
+ import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
9
+ import ContextMenu, {} from '@cccsaurora/howler-ui/components/elements/ContextMenu';
10
+ import { TOP_ROW, VOTE_OPTIONS } from '@cccsaurora/howler-ui/components/elements/hit/actions/SharedComponents';
11
+ import useHitActions from '@cccsaurora/howler-ui/components/hooks/useHitActions';
12
+ import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
13
+ import useMyActionFunctions from '@cccsaurora/howler-ui/components/routes/action/useMyActionFunctions';
14
+ import AddToCaseModal from '@cccsaurora/howler-ui/components/routes/cases/modals/AddToCaseModal';
15
+ import CreateCaseModal from '@cccsaurora/howler-ui/components/routes/cases/modals/CreateCaseModal';
16
+ import { capitalize, get, groupBy, isEmpty, toString } from 'lodash-es';
17
+ import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
18
+ import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
19
+ import { useTranslation } from 'react-i18next';
20
+ import { usePluginStore } from 'react-pluggable';
21
+ import { useContextSelector } from 'use-context-selector';
22
+ import { DEFAULT_QUERY } from '@cccsaurora/howler-ui/utils/constants';
23
+ import { sanitizeLuceneQuery } from '@cccsaurora/howler-ui/utils/stringUtils';
24
+ import { isHit } from '@cccsaurora/howler-ui/utils/typeUtils';
25
+ /**
26
+ * Order in which action types should be displayed in the context menu
27
+ */
28
+ const ORDER = ['assessment', 'vote', 'action'];
29
+ /**
30
+ * Icon mapping for different action types
31
+ */
32
+ const ICON_MAP = {
33
+ assessment: _jsx(Assignment, {}),
34
+ vote: _jsx(HowToVote, {}),
35
+ action: _jsx(Edit, {})
36
+ };
37
+ /**
38
+ * Context menu component for hit operations.
39
+ * Provides quick access to common hit actions including assessment, voting,
40
+ * transitions, and exclusion filters based on template fields.
41
+ */
42
+ const RecordContextMenu = ({ children, getSelectedId, Component }) => {
43
+ const { t } = useTranslation();
44
+ const { dispatchApi } = useMyApi();
45
+ const { executeAction } = useMyActionFunctions();
46
+ const { config } = useContext(ApiConfigContext);
47
+ const { showModal } = useContext(ModalContext);
48
+ const pluginStore = usePluginStore();
49
+ const { getMatchingAnalytic, getMatchingTemplate } = useMatchers();
50
+ const query = useContextSelector(ParameterContext, ctx => ctx?.query);
51
+ const setQuery = useContextSelector(ParameterContext, ctx => ctx?.setQuery);
52
+ const [id, setId] = useState(null);
53
+ const record = useContextSelector(RecordContext, ctx => ctx.records[id]);
54
+ const selectedRecords = useContextSelector(RecordContext, ctx => ctx.selectedRecords);
55
+ const [analytic, setAnalytic] = useState(null);
56
+ const [template, setTemplate] = useState(null);
57
+ const [actions, setActions] = useState([]);
58
+ const records = useMemo(() => selectedRecords.some(_record => _record.howler.id === record?.howler.id)
59
+ ? selectedRecords
60
+ : record
61
+ ? [record]
62
+ : [], [record, selectedRecords]);
63
+ const hits = useMemo(() => records.filter(isHit), [records]);
64
+ const { availableTransitions, canVote, canAssess, assess, vote } = useHitActions(hits);
65
+ /**
66
+ * Called by ContextMenu after the menu is positioned and opened.
67
+ * Identifies the clicked record and fetches available actions.
68
+ */
69
+ const onOpen = useCallback(async (event) => {
70
+ const _id = getSelectedId(event);
71
+ setId(_id);
72
+ const _actions = (await dispatchApi(api.search.action.post({ query: 'action_id:*' }), { throwError: false }))
73
+ ?.items;
74
+ if (_actions) {
75
+ setActions(_actions);
76
+ }
77
+ }, [dispatchApi, getSelectedId]);
78
+ const rowStatus = useMemo(() => ({
79
+ assessment: canAssess,
80
+ vote: canVote
81
+ }), [canAssess, canVote]);
82
+ const pluginActions = howlerPluginStore.plugins.flatMap(plugin => pluginStore.executeFunction(`${plugin}.actions`, records));
83
+ /**
84
+ * Generates grouped action entries for the context menu.
85
+ * Combines transitions, plugin actions, votes, and assessments based on permissions.
86
+ */
87
+ const entries = useMemo(() => {
88
+ let _actions = [...availableTransitions, ...pluginActions];
89
+ if (canVote) {
90
+ _actions = [
91
+ ..._actions,
92
+ ...VOTE_OPTIONS.map(option => ({ ...option, actionFunction: () => vote(option.name.toLowerCase()) }))
93
+ ];
94
+ }
95
+ if (config.lookups?.['howler.assessment'] && canAssess) {
96
+ _actions = [
97
+ ..._actions,
98
+ ...config.lookups['howler.assessment']
99
+ .filter(_assessment => analytic?.triage_settings?.valid_assessments
100
+ ? analytic.triage_settings?.valid_assessments.includes(_assessment)
101
+ : true)
102
+ .sort((a, b) => +TOP_ROW.includes(b) - +TOP_ROW.includes(a))
103
+ .map(assessment => ({
104
+ type: 'assessment',
105
+ name: assessment,
106
+ actionFunction: async () => {
107
+ await assess(assessment, analytic?.triage_settings?.skip_rationale);
108
+ }
109
+ }))
110
+ ];
111
+ }
112
+ return Object.entries(groupBy(_actions, 'type')).sort(([a], [b]) => ORDER.indexOf(a) - ORDER.indexOf(b));
113
+ }, [analytic, assess, availableTransitions, canAssess, canVote, config.lookups, vote, pluginActions]);
114
+ // Load analytic and template data when a hit is selected
115
+ useEffect(() => {
116
+ if (!record?.howler.analytic) {
117
+ return;
118
+ }
119
+ getMatchingAnalytic(record).then(setAnalytic);
120
+ getMatchingTemplate(record).then(setTemplate);
121
+ // eslint-disable-next-line react-hooks/exhaustive-deps
122
+ }, [record]);
123
+ /**
124
+ * Builds the declarative items structure for the ContextMenu component.
125
+ */
126
+ const items = useMemo(() => {
127
+ const result = [
128
+ {
129
+ kind: 'item',
130
+ id: 'open-record',
131
+ icon: _jsx(OpenInNew, {}),
132
+ label: t(`${record?.__index ?? 'hit'}.open`),
133
+ disabled: !record,
134
+ to: `/${record?.__index}s/${record?.howler.id}`
135
+ }
136
+ ];
137
+ if (isHit(record)) {
138
+ result.push({
139
+ kind: 'item',
140
+ id: 'open-analytic',
141
+ icon: _jsx(QueryStats, {}),
142
+ label: t('analytic.open'),
143
+ disabled: !analytic,
144
+ to: `/analytics/${analytic?.analytic_id}`
145
+ });
146
+ result.push({ kind: 'divider', id: 'actions-divider' });
147
+ for (const [type, typeItems] of entries) {
148
+ result.push({
149
+ kind: 'submenu',
150
+ id: type,
151
+ icon: ICON_MAP[type] ?? _jsx(Terminal, {}),
152
+ label: t(`hit.details.actions.${type}`),
153
+ disabled: rowStatus[type] === false,
154
+ items: typeItems.map(a => ({
155
+ key: a.name,
156
+ label: a.i18nKey ? t(a.i18nKey) : capitalize(a.name),
157
+ onClick: a.actionFunction
158
+ }))
159
+ });
160
+ }
161
+ result.push({
162
+ kind: 'submenu',
163
+ id: 'actions',
164
+ icon: _jsx(SettingsSuggest, {}),
165
+ label: t('route.actions.change'),
166
+ disabled: actions.length < 1,
167
+ items: actions.map(action => ({
168
+ key: action.action_id,
169
+ label: action.name,
170
+ onClick: () => executeAction(action.action_id, `howler.id:${record?.howler.id}`)
171
+ }))
172
+ });
173
+ if (!isEmpty(template?.keys ?? []) && setQuery) {
174
+ result.push({ kind: 'divider', id: 'filter-divider' });
175
+ result.push({
176
+ kind: 'submenu',
177
+ id: 'excludes',
178
+ icon: _jsx(RemoveCircleOutline, {}),
179
+ label: t('hit.panel.exclude'),
180
+ items: (template?.keys ?? []).flatMap(key => {
181
+ let newQuery = '';
182
+ if (query !== DEFAULT_QUERY) {
183
+ newQuery = `(${query}) AND `;
184
+ }
185
+ const value = get(record, key);
186
+ if (!value) {
187
+ return [];
188
+ }
189
+ else if (Array.isArray(value)) {
190
+ const sanitizedValues = value
191
+ .map(toString)
192
+ .filter(val => !!val)
193
+ .map(val => `"${sanitizeLuceneQuery(val)}"`);
194
+ if (sanitizedValues.length < 1) {
195
+ return [];
196
+ }
197
+ newQuery += `-${key}:(${sanitizedValues.join(' OR ')})`;
198
+ }
199
+ else {
200
+ newQuery += `-${key}:"${sanitizeLuceneQuery(value.toString())}"`;
201
+ }
202
+ return [{ key, label: key, onClick: () => setQuery(newQuery) }];
203
+ })
204
+ });
205
+ result.push({
206
+ kind: 'submenu',
207
+ id: 'includes',
208
+ icon: _jsx(AddCircleOutline, {}),
209
+ label: t('hit.panel.include'),
210
+ items: (template?.keys ?? []).flatMap(key => {
211
+ let newQuery = `(${query}) AND `;
212
+ const value = get(record, key);
213
+ if (!value) {
214
+ return [];
215
+ }
216
+ else if (Array.isArray(value)) {
217
+ const sanitizedValues = value
218
+ .map(toString)
219
+ .filter(val => !!val)
220
+ .map(val => `"${sanitizeLuceneQuery(val)}"`);
221
+ if (sanitizedValues.length < 1) {
222
+ return [];
223
+ }
224
+ newQuery += `${key}:(${sanitizedValues.join(' OR ')})`;
225
+ }
226
+ else {
227
+ newQuery += `${key}:"${sanitizeLuceneQuery(value.toString())}"`;
228
+ }
229
+ return [{ key, label: key, onClick: () => setQuery(newQuery) }];
230
+ })
231
+ });
232
+ }
233
+ }
234
+ result.push({ kind: 'divider', id: 'add-to-case-divider' });
235
+ result.push({
236
+ kind: 'item',
237
+ id: 'add-to-case',
238
+ icon: _jsx(CreateNewFolder, {}),
239
+ label: t('modal.cases.add_to_case'),
240
+ disabled: !record,
241
+ onClick: () => showModal(_jsx(AddToCaseModal, { records: records }), { maxHeight: '90vh' })
242
+ });
243
+ result.push({
244
+ kind: 'item',
245
+ id: 'create-case',
246
+ icon: _jsx(NoteAdd, {}),
247
+ label: t('modal.cases.create_case'),
248
+ disabled: !record,
249
+ onClick: () => showModal(_jsx(CreateCaseModal, { records: records }), { maxHeight: '90vh' })
250
+ });
251
+ return result;
252
+ // eslint-disable-next-line react-hooks/exhaustive-deps
253
+ }, [record, analytic, template, entries, rowStatus, actions, query, t, setQuery, executeAction, showModal, records]);
254
+ return (_jsx(ContextMenu, { id: "contextMenu", Component: Component, onOpen: onOpen, onClose: () => setAnalytic(null), items: items, children: children }));
255
+ };
256
+ export default RecordContextMenu;