@cccsaurora/howler-ui 2.19.0-cases.863 → 2.19.0-dev.1000
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.d.ts +0 -4
- package/api/index.js +2 -10
- package/api/search/facet/hit.d.ts +3 -1
- package/api/search/facet/index.d.ts +1 -3
- package/api/search/index.d.ts +1 -2
- package/api/search/index.js +1 -2
- package/commons/components/leftnav/LeftNavDrawer.js +1 -1
- package/components/app/App.d.ts +1 -0
- package/components/app/App.js +20 -42
- package/components/app/hooks/useMatchers.d.ts +1 -1
- package/components/app/hooks/useMatchers.js +11 -23
- package/components/app/hooks/useMatchers.test.js +22 -22
- package/components/app/hooks/useTitle.js +5 -5
- package/components/app/providers/FavouritesProvider.js +2 -6
- package/components/app/providers/HitProvider.d.ts +22 -0
- package/components/app/providers/{RecordProvider.js → HitProvider.js} +42 -42
- package/components/app/providers/{RecordSearchProvider.d.ts → HitSearchProvider.d.ts} +6 -6
- package/components/app/providers/{RecordSearchProvider.js → HitSearchProvider.js} +17 -12
- package/components/app/providers/{RecordSearchProvider.test.js → HitSearchProvider.test.js} +71 -52
- package/components/app/providers/ModalProvider.d.ts +1 -1
- package/components/app/providers/ModalProvider.js +5 -1
- package/components/app/providers/ParameterProvider.d.ts +2 -9
- package/components/app/providers/ParameterProvider.js +240 -165
- package/components/app/providers/ParameterProvider.test.js +94 -346
- package/components/app/providers/SocketProvider.d.ts +2 -11
- package/components/app/providers/SocketProvider.js +5 -18
- package/components/app/providers/UserListProvider.js +8 -28
- package/components/elements/PluginTypography.d.ts +1 -2
- package/components/elements/PluginTypography.js +2 -3
- package/components/elements/UserList.d.ts +2 -5
- package/components/elements/UserList.js +8 -18
- package/components/elements/addons/buttons/CustomButton.test.js +106 -0
- package/components/elements/addons/layout/FlexOne.test.js +30 -0
- package/components/elements/addons/lists/TuiListBase.js +4 -0
- package/components/elements/addons/lists/TuiListElement.js +6 -3
- package/components/elements/addons/lists/index.d.ts +1 -0
- package/components/elements/addons/search/SearchPagination.test.js +80 -0
- package/components/elements/addons/search/SearchTotal.test.js +45 -0
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/display/ChipPopper.d.ts +1 -1
- package/components/elements/display/ChipPopper.js +5 -5
- package/components/elements/display/DocumentationButton.test.js +84 -0
- package/components/elements/display/DynamicTabs.test.js +93 -0
- package/components/elements/display/HowlerAvatar.js +2 -1
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/HowlerCard.test.js +55 -0
- package/components/elements/display/Image.test.js +79 -0
- package/components/elements/display/Markdown.js +9 -2
- package/components/elements/display/Modal.js +0 -2
- package/components/elements/display/QueryResultText.test.js +48 -0
- package/components/elements/display/TextDivider.test.js +43 -0
- package/components/elements/display/TypingIndicator.test.js +33 -0
- package/components/elements/display/icons/BundleButton.d.ts +6 -0
- package/components/elements/display/icons/BundleButton.js +32 -0
- package/components/elements/display/modals/ConfirmDeleteModal.d.ts +4 -0
- package/components/elements/display/modals/ConfirmDeleteModal.js +4 -2
- package/components/elements/hit/HitActions.js +4 -4
- package/components/elements/hit/HitBanner.d.ts +0 -1
- package/components/elements/hit/HitBanner.js +49 -31
- package/components/elements/hit/HitCard.d.ts +0 -2
- package/components/elements/hit/HitCard.js +7 -7
- package/components/elements/{record/RecordComments.d.ts → hit/HitComments.d.ts} +4 -5
- package/components/elements/{record/RecordComments.js → hit/HitComments.js} +28 -29
- package/components/elements/{ObjectDetails.js → hit/HitDetails.js} +17 -17
- package/components/elements/hit/HitLabels.js +2 -2
- package/components/elements/hit/HitOutline.d.ts +0 -1
- package/components/elements/hit/HitOutline.js +3 -3
- package/components/elements/hit/{HitPreview.d.ts → HitQuickSearch.d.ts} +3 -3
- package/components/elements/hit/{HitPreview.js → HitQuickSearch.js} +4 -10
- package/components/elements/hit/HitRelated.d.ts +6 -0
- package/components/elements/hit/HitRelated.js +7 -0
- package/components/elements/hit/HitSummary.d.ts +1 -2
- package/components/elements/hit/HitSummary.js +8 -8
- package/components/elements/{record/RecordWorklog.d.ts → hit/HitWorklog.d.ts} +3 -4
- package/components/elements/{record/RecordWorklog.js → hit/HitWorklog.js} +13 -15
- package/components/elements/hit/aggregate/HitGraph.js +8 -8
- package/components/elements/hit/elements/{Assigned.d.ts → HitUsers.d.ts} +5 -2
- package/components/elements/hit/elements/HitUsers.js +33 -0
- package/components/elements/hit/outlines/DefaultOutline.js +1 -1
- package/components/elements/view/ViewTitle.d.ts +0 -1
- package/components/elements/view/ViewTitle.js +2 -9
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +4 -4
- package/components/hooks/{useRecordSelection.d.ts → useHitSelection.d.ts} +2 -2
- package/components/hooks/{useRecordSelection.js → useHitSelection.js} +33 -12
- package/components/hooks/useMyPreferences.js +3 -11
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +1 -4
- package/components/hooks/useMyTheme.js +2 -9
- package/components/routes/403.test.js +27 -0
- package/components/routes/404.test.js +26 -0
- package/components/routes/ErrorBoundary.test.js +43 -0
- package/components/routes/ErrorOccured.test.js +35 -0
- package/components/routes/Logout.test.js +59 -0
- package/components/routes/action/edit/ActionEditor.js +2 -2
- package/components/routes/action/view/ActionDetails.js +4 -2
- package/components/routes/action/view/ActionSearch.js +12 -7
- package/components/routes/advanced/QueryBuilder.js +1 -1
- package/components/routes/advanced/QueryEditor.js +3 -3
- package/components/routes/advanced/historyCompletionProvider.js +3 -3
- package/components/routes/analytics/AnalyticDetails.js +12 -8
- package/components/routes/analytics/AnalyticSearch.js +1 -1
- package/components/routes/dossiers/DossierEditor.js +2 -2
- package/components/routes/dossiers/DossierEditor.test.js +1 -1
- package/components/routes/dossiers/Dossiers.js +15 -11
- package/components/routes/help/ApiDocumentation.js +1 -1
- package/components/routes/help/BundleDocumentation.d.ts +3 -0
- package/components/routes/help/BundleDocumentation.js +12 -0
- package/components/routes/help/HitBannerDocumentation.js +0 -1
- package/components/routes/help/HitDocumentation.js +3 -1
- package/components/routes/help/markdown/en/bundles.md.js +1 -0
- package/components/routes/help/markdown/en/client.md.js +1 -1
- package/components/routes/help/markdown/fr/bundles.md.js +1 -0
- package/components/routes/help/markdown/fr/client.md.js +1 -1
- package/components/routes/hits/search/BundleParentMenu.d.ts +6 -0
- package/components/routes/hits/search/BundleParentMenu.js +32 -0
- package/components/routes/hits/search/BundleScroller.d.ts +2 -0
- package/components/routes/hits/search/BundleScroller.js +6 -0
- package/components/routes/hits/search/{RecordBrowser.js → HitBrowser.js} +9 -9
- package/components/{elements/record/RecordContextMenu.d.ts → routes/hits/search/HitContextMenu.d.ts} +3 -3
- package/components/routes/hits/search/HitContextMenu.js +239 -0
- package/components/{elements/record/RecordContextMenu.test.js → routes/hits/search/HitContextMenu.test.js} +43 -98
- package/components/routes/hits/search/{RecordQuery.d.ts → HitQuery.d.ts} +2 -2
- package/components/routes/hits/search/{RecordQuery.js → HitQuery.js} +6 -6
- package/components/routes/hits/search/InformationPane.d.ts +0 -1
- package/components/routes/hits/search/InformationPane.js +63 -50
- package/components/routes/hits/search/LayoutSettings.js +3 -3
- package/components/routes/hits/search/QuerySettings.js +1 -2
- package/components/routes/hits/search/QuerySettings.test.js +9 -14
- package/components/routes/hits/search/SearchPane.js +49 -26
- package/components/routes/hits/search/ViewLink.js +3 -3
- package/components/routes/hits/search/ViewLink.test.js +8 -8
- package/components/routes/hits/search/grid/AddColumnModal.js +4 -5
- package/components/routes/hits/search/grid/EnhancedCell.d.ts +1 -2
- package/components/routes/hits/search/grid/EnhancedCell.js +2 -2
- package/components/routes/hits/search/grid/HitGrid.js +18 -20
- package/components/routes/hits/search/grid/{RecordRow.d.ts → HitRow.d.ts} +2 -3
- package/components/routes/hits/search/grid/{RecordRow.js → HitRow.js} +9 -11
- package/components/routes/hits/search/shared/CustomSpan.js +7 -7
- package/components/routes/hits/search/shared/CustomSpan.test.js +170 -0
- package/components/routes/hits/view/HitViewer.js +13 -12
- package/components/routes/home/AddNewCard.test.js +68 -0
- package/components/routes/home/ViewCard.js +41 -47
- package/components/routes/home/ViewRefresh.test.js +79 -0
- package/components/routes/overviews/OverviewCard.test.js +108 -0
- package/components/{elements/MarkdownEditor.js → routes/overviews/OverviewEditor.js} +3 -3
- package/components/routes/overviews/OverviewViewer.js +14 -10
- package/components/routes/overviews/Overviews.js +15 -11
- package/components/routes/settings/LocalSection.js +2 -1
- package/components/routes/settings/SettingsSection.test.js +19 -0
- package/components/routes/templates/TemplateCard.d.ts +3 -1
- package/components/routes/templates/TemplateCard.js +8 -4
- package/components/routes/templates/TemplateCard.test.d.ts +1 -0
- package/components/routes/templates/TemplateCard.test.js +115 -0
- package/components/routes/templates/TemplateViewer.js +57 -16
- package/components/routes/templates/Templates.js +23 -6
- package/components/routes/views/ViewComposer.js +19 -46
- package/components/routes/views/Views.js +8 -4
- package/locales/en/translation.json +17 -117
- package/locales/fr/translation.json +19 -119
- package/models/WithMetadata.d.ts +1 -2
- package/models/entities/generated/{ThreatEnrichment.d.ts → Enrichment.d.ts} +1 -1
- package/models/entities/generated/Hit.d.ts +1 -1
- package/models/entities/generated/Howler.d.ts +6 -0
- package/models/entities/generated/Rule.d.ts +9 -6
- package/models/entities/generated/Threat.d.ts +2 -2
- package/models/entities/generated/UserUser.d.ts +2 -0
- package/models/entities/generated/View.d.ts +0 -1
- package/package.json +112 -132
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +1 -2
- package/rest/FetchClient.test.d.ts +1 -0
- package/rest/FetchClient.test.js +81 -0
- package/setupTests.js +5 -0
- package/tests/mocks.d.ts +1 -11
- package/tests/mocks.js +7 -12
- package/tests/server-handlers.js +1 -6
- package/tests/utils.d.ts +0 -4
- package/tests/utils.js +0 -20
- package/utils/Throttler.test.d.ts +1 -0
- package/utils/Throttler.test.js +135 -0
- package/utils/actionUtils.test.d.ts +1 -0
- package/utils/actionUtils.test.js +140 -0
- package/utils/constants.d.ts +4 -4
- package/utils/constants.js +1 -6
- package/utils/hitFunctions.d.ts +1 -2
- package/utils/hitFunctions.js +4 -4
- package/utils/hitFunctions.test.d.ts +1 -0
- package/utils/hitFunctions.test.js +52 -0
- package/utils/localStorage.test.d.ts +1 -0
- package/utils/localStorage.test.js +96 -0
- package/utils/menuUtils.test.d.ts +1 -0
- package/utils/menuUtils.test.js +198 -0
- package/utils/sessionStorage.test.d.ts +1 -0
- package/utils/sessionStorage.test.js +81 -0
- package/utils/socketUtils.d.ts +0 -14
- package/utils/socketUtils.js +1 -17
- package/utils/socketUtils.test.js +16 -49
- package/utils/stringUtils.test.d.ts +1 -0
- package/utils/stringUtils.test.js +159 -0
- package/utils/utils.test.d.ts +1 -0
- package/utils/utils.test.js +292 -0
- package/utils/viewUtils.js +0 -3
- package/utils/viewUtils.test.d.ts +1 -0
- package/utils/viewUtils.test.js +45 -0
- package/utils/xsrf.test.d.ts +1 -0
- package/utils/xsrf.test.js +41 -0
- package/api/search/case.d.ts +0 -4
- package/api/search/case.js +0 -8
- package/api/socket/index.d.ts +0 -3
- package/api/socket/index.js +0 -6
- package/api/socket/viewers.d.ts +0 -2
- package/api/socket/viewers.js +0 -8
- package/api/socket/viewers.test.js +0 -44
- package/api/v2/case/index.d.ts +0 -9
- package/api/v2/case/index.js +0 -21
- package/api/v2/case/items.d.ts +0 -6
- package/api/v2/case/items.js +0 -18
- package/api/v2/case/rules.d.ts +0 -6
- package/api/v2/case/rules.js +0 -18
- package/api/v2/index.d.ts +0 -4
- package/api/v2/index.js +0 -6
- package/api/v2/search/facet.d.ts +0 -3
- package/api/v2/search/facet.js +0 -12
- package/api/v2/search/index.d.ts +0 -5
- package/api/v2/search/index.js +0 -24
- package/components/app/providers/RecordProvider.d.ts +0 -23
- package/components/elements/ContextMenu.d.ts +0 -56
- package/components/elements/ContextMenu.js +0 -109
- package/components/elements/ContextMenu.test.js +0 -215
- package/components/elements/ObjectDetails.d.ts +0 -6
- package/components/elements/case/CaseCard.d.ts +0 -12
- package/components/elements/case/CaseCard.js +0 -42
- package/components/elements/case/CasePreview.d.ts +0 -6
- package/components/elements/case/CasePreview.js +0 -17
- package/components/elements/case/StatusIcon.d.ts +0 -5
- package/components/elements/case/StatusIcon.js +0 -13
- package/components/elements/hit/elements/AnalyticLink.d.ts +0 -9
- package/components/elements/hit/elements/AnalyticLink.js +0 -22
- package/components/elements/hit/elements/Assigned.js +0 -34
- package/components/elements/hit/elements/Assigned.test.js +0 -65
- package/components/elements/hit/related/RelatedRecords.js +0 -63
- package/components/elements/observable/ObservableCard.d.ts +0 -6
- package/components/elements/observable/ObservableCard.js +0 -22
- package/components/elements/observable/ObservablePreview.d.ts +0 -6
- package/components/elements/observable/ObservablePreview.js +0 -12
- package/components/elements/record/RecordContextMenu.js +0 -268
- package/components/elements/record/RecordRelated.d.ts +0 -7
- package/components/elements/record/RecordRelated.js +0 -34
- package/components/hooks/useRelatedRecords.d.ts +0 -13
- package/components/hooks/useRelatedRecords.js +0 -32
- package/components/routes/cases/CaseViewer.d.ts +0 -2
- package/components/routes/cases/CaseViewer.js +0 -44
- package/components/routes/cases/CaseViewer.test.js +0 -133
- package/components/routes/cases/Cases.d.ts +0 -2
- package/components/routes/cases/Cases.js +0 -148
- package/components/routes/cases/constants.d.ts +0 -6
- package/components/routes/cases/constants.js +0 -6
- package/components/routes/cases/detail/AlertPanel.d.ts +0 -6
- package/components/routes/cases/detail/AlertPanel.js +0 -33
- package/components/routes/cases/detail/CaseAssets.d.ts +0 -11
- package/components/routes/cases/detail/CaseAssets.js +0 -104
- package/components/routes/cases/detail/CaseAssets.test.js +0 -167
- package/components/routes/cases/detail/CaseDashboard.d.ts +0 -7
- package/components/routes/cases/detail/CaseDashboard.js +0 -66
- package/components/routes/cases/detail/CaseDetails.d.ts +0 -6
- package/components/routes/cases/detail/CaseDetails.js +0 -70
- package/components/routes/cases/detail/CaseOverview.d.ts +0 -7
- package/components/routes/cases/detail/CaseOverview.js +0 -43
- package/components/routes/cases/detail/CaseRules.d.ts +0 -7
- package/components/routes/cases/detail/CaseRules.js +0 -57
- package/components/routes/cases/detail/CaseRules.test.js +0 -221
- package/components/routes/cases/detail/CaseSidebar.d.ts +0 -8
- package/components/routes/cases/detail/CaseSidebar.js +0 -107
- package/components/routes/cases/detail/CaseSidebar.test.js +0 -266
- package/components/routes/cases/detail/CaseTask.d.ts +0 -11
- package/components/routes/cases/detail/CaseTask.js +0 -66
- package/components/routes/cases/detail/CaseTimeline.d.ts +0 -12
- package/components/routes/cases/detail/CaseTimeline.js +0 -106
- package/components/routes/cases/detail/CaseTimeline.test.js +0 -320
- package/components/routes/cases/detail/CreateRuleDialog.d.ts +0 -9
- package/components/routes/cases/detail/CreateRuleDialog.js +0 -163
- package/components/routes/cases/detail/CreateRuleDialog.test.js +0 -259
- package/components/routes/cases/detail/ItemPage.d.ts +0 -6
- package/components/routes/cases/detail/ItemPage.js +0 -95
- package/components/routes/cases/detail/RelatedCasePanel.d.ts +0 -6
- package/components/routes/cases/detail/RelatedCasePanel.js +0 -34
- package/components/routes/cases/detail/TaskPanel.d.ts +0 -7
- package/components/routes/cases/detail/TaskPanel.js +0 -52
- package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +0 -11
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +0 -24
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +0 -6
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +0 -26
- package/components/routes/cases/detail/assets/Asset.d.ts +0 -14
- package/components/routes/cases/detail/assets/Asset.js +0 -12
- package/components/routes/cases/detail/assets/Asset.test.js +0 -72
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +0 -20
- package/components/routes/cases/detail/sidebar/CaseFolder.js +0 -83
- package/components/routes/cases/detail/sidebar/CaseFolder.test.js +0 -295
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.d.ts +0 -34
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.js +0 -103
- package/components/routes/cases/detail/sidebar/CaseFolderContextMenu.test.js +0 -363
- package/components/routes/cases/detail/sidebar/FolderEntry.d.ts +0 -25
- package/components/routes/cases/detail/sidebar/FolderEntry.js +0 -88
- package/components/routes/cases/detail/sidebar/FolderEntry.test.js +0 -206
- package/components/routes/cases/detail/sidebar/RootDropZone.d.ts +0 -5
- package/components/routes/cases/detail/sidebar/RootDropZone.js +0 -33
- package/components/routes/cases/detail/sidebar/types.d.ts +0 -9
- package/components/routes/cases/detail/sidebar/utils.d.ts +0 -3
- package/components/routes/cases/detail/sidebar/utils.js +0 -29
- package/components/routes/cases/detail/sidebar/utils.test.js +0 -82
- package/components/routes/cases/hooks/useCase.d.ts +0 -13
- package/components/routes/cases/hooks/useCase.js +0 -69
- package/components/routes/cases/hooks/useCase.test.js +0 -141
- package/components/routes/cases/modals/AddToCaseModal.d.ts +0 -7
- package/components/routes/cases/modals/AddToCaseModal.js +0 -59
- package/components/routes/cases/modals/AddToCaseModal.test.js +0 -313
- package/components/routes/cases/modals/CaseRecordRow.d.ts +0 -9
- package/components/routes/cases/modals/CaseRecordRow.js +0 -15
- package/components/routes/cases/modals/CreateCaseModal.d.ts +0 -7
- package/components/routes/cases/modals/CreateCaseModal.js +0 -55
- package/components/routes/cases/modals/CreateCaseModal.test.js +0 -358
- package/components/routes/cases/modals/RenameItemModal.d.ts +0 -9
- package/components/routes/cases/modals/RenameItemModal.js +0 -48
- package/components/routes/cases/modals/ResolveModal.d.ts +0 -7
- package/components/routes/cases/modals/ResolveModal.js +0 -115
- package/components/routes/cases/modals/ResolveModal.test.js +0 -394
- package/components/routes/cases/modals/hooks.d.ts +0 -7
- package/components/routes/cases/modals/hooks.js +0 -44
- package/components/routes/cases/modals/types.d.ts +0 -5
- package/components/routes/cases/search/CaseAssigneeFilter.d.ts +0 -6
- package/components/routes/cases/search/CaseAssigneeFilter.js +0 -33
- package/components/routes/cases/search/CaseAssigneeFilter.test.js +0 -127
- package/components/routes/cases/search/CaseDateFilter.d.ts +0 -13
- package/components/routes/cases/search/CaseDateFilter.js +0 -26
- package/components/routes/cases/search/CaseDateFilter.test.js +0 -115
- package/components/routes/cases/search/CaseStatusFilter.d.ts +0 -6
- package/components/routes/cases/search/CaseStatusFilter.js +0 -13
- package/components/routes/cases/search/CaseStatusFilter.test.js +0 -86
- package/components/routes/hits/search/shared/IndexPicker.d.ts +0 -2
- package/components/routes/hits/search/shared/IndexPicker.js +0 -20
- package/components/routes/observables/ObservableViewer.d.ts +0 -7
- package/components/routes/observables/ObservableViewer.js +0 -27
- package/models/entities/generated/AttachmentsFile.d.ts +0 -12
- package/models/entities/generated/Case.d.ts +0 -28
- package/models/entities/generated/DestinationOriginal.d.ts +0 -19
- package/models/entities/generated/EmailAttachment.d.ts +0 -8
- package/models/entities/generated/EmailParent.d.ts +0 -19
- package/models/entities/generated/Enrichments.d.ts +0 -7
- package/models/entities/generated/EnrichmentsIndicator.d.ts +0 -21
- package/models/entities/generated/HttpResponse.d.ts +0 -11
- package/models/entities/generated/Item.d.ts +0 -9
- package/models/entities/generated/Observable.d.ts +0 -85
- package/models/entities/generated/ObservableCloud.d.ts +0 -20
- package/models/entities/generated/ObservableDestination.d.ts +0 -23
- package/models/entities/generated/ObservableEmail.d.ts +0 -30
- package/models/entities/generated/ObservableFile.d.ts +0 -36
- package/models/entities/generated/ObservableHowler.d.ts +0 -42
- package/models/entities/generated/ObservableHttp.d.ts +0 -11
- package/models/entities/generated/ObservableObserver.d.ts +0 -21
- package/models/entities/generated/ObservableOrganization.d.ts +0 -7
- package/models/entities/generated/ObservableProcess.d.ts +0 -34
- package/models/entities/generated/ObservableSource.d.ts +0 -23
- package/models/entities/generated/ObservableThreat.d.ts +0 -21
- package/models/entities/generated/ObservableTls.d.ts +0 -12
- package/models/entities/generated/ObserverIngress.d.ts +0 -9
- package/models/entities/generated/Task.d.ts +0 -10
- package/models/socket/CaseUpdate.d.ts +0 -5
- package/models/socket/ViewersUpdate.d.ts +0 -4
- package/utils/typeUtils.d.ts +0 -7
- package/utils/typeUtils.js +0 -27
- /package/{api/socket/viewers.test.d.ts → components/app/providers/HitSearchProvider.test.d.ts} +0 -0
- /package/components/{app/providers/RecordSearchProvider.test.d.ts → elements/addons/buttons/CustomButton.test.d.ts} +0 -0
- /package/components/elements/{ContextMenu.test.d.ts → addons/layout/FlexOne.test.d.ts} +0 -0
- /package/components/elements/{hit/elements/Assigned.test.d.ts → addons/search/SearchPagination.test.d.ts} +0 -0
- /package/components/elements/{record/RecordContextMenu.test.d.ts → addons/search/SearchTotal.test.d.ts} +0 -0
- /package/components/{routes/cases/CaseViewer.test.d.ts → elements/display/DocumentationButton.test.d.ts} +0 -0
- /package/components/{routes/cases/detail/CaseAssets.test.d.ts → elements/display/DynamicTabs.test.d.ts} +0 -0
- /package/components/{routes/cases/detail/CaseRules.test.d.ts → elements/display/HowlerCard.test.d.ts} +0 -0
- /package/components/{routes/cases/detail/CaseSidebar.test.d.ts → elements/display/Image.test.d.ts} +0 -0
- /package/components/{routes/cases/detail/CaseTimeline.test.d.ts → elements/display/QueryResultText.test.d.ts} +0 -0
- /package/components/{routes/cases/detail/CreateRuleDialog.test.d.ts → elements/display/TextDivider.test.d.ts} +0 -0
- /package/components/{routes/cases/detail/assets/Asset.test.d.ts → elements/display/TypingIndicator.test.d.ts} +0 -0
- /package/components/elements/hit/{related/RelatedRecords.d.ts → HitDetails.d.ts} +0 -0
- /package/components/routes/{cases/detail/sidebar/CaseFolder.test.d.ts → 403.test.d.ts} +0 -0
- /package/components/routes/{cases/detail/sidebar/CaseFolderContextMenu.test.d.ts → 404.test.d.ts} +0 -0
- /package/components/routes/{cases/detail/sidebar/FolderEntry.test.d.ts → ErrorBoundary.test.d.ts} +0 -0
- /package/components/routes/{cases/detail/sidebar/utils.test.d.ts → ErrorOccured.test.d.ts} +0 -0
- /package/components/routes/{cases/hooks/useCase.test.d.ts → Logout.test.d.ts} +0 -0
- /package/components/routes/hits/search/{RecordBrowser.d.ts → HitBrowser.d.ts} +0 -0
- /package/components/routes/{cases/modals/AddToCaseModal.test.d.ts → hits/search/HitContextMenu.test.d.ts} +0 -0
- /package/components/routes/{cases/modals/CreateCaseModal.test.d.ts → hits/search/shared/CustomSpan.test.d.ts} +0 -0
- /package/components/routes/{cases/modals/ResolveModal.test.d.ts → home/AddNewCard.test.d.ts} +0 -0
- /package/components/routes/{cases/search/CaseAssigneeFilter.test.d.ts → home/ViewRefresh.test.d.ts} +0 -0
- /package/components/routes/{cases/search/CaseDateFilter.test.d.ts → overviews/OverviewCard.test.d.ts} +0 -0
- /package/components/{elements/MarkdownEditor.d.ts → routes/overviews/OverviewEditor.d.ts} +0 -0
- /package/components/routes/{cases/search/CaseStatusFilter.test.d.ts → settings/SettingsSection.test.d.ts} +0 -0
|
@@ -3,80 +3,74 @@ import { OpenInNew } from '@mui/icons-material';
|
|
|
3
3
|
import { Card, CardContent, IconButton, Skeleton, Stack, Typography } from '@mui/material';
|
|
4
4
|
import api from '@cccsaurora/howler-ui/api';
|
|
5
5
|
import AppListEmpty from '@cccsaurora/howler-ui/commons/components/display/AppListEmpty';
|
|
6
|
-
import {
|
|
6
|
+
import { useHitContextSelector } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
|
|
7
7
|
import { ViewContext } from '@cccsaurora/howler-ui/components/app/providers/ViewProvider';
|
|
8
8
|
import HitBanner from '@cccsaurora/howler-ui/components/elements/hit/HitBanner';
|
|
9
9
|
import { HitLayout } from '@cccsaurora/howler-ui/components/elements/hit/HitLayout';
|
|
10
|
-
import ObservableCard from '@cccsaurora/howler-ui/components/elements/observable/ObservableCard';
|
|
11
|
-
import RecordContextMenu from '@cccsaurora/howler-ui/components/elements/record/RecordContextMenu';
|
|
12
10
|
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
11
|
+
import HitContextMenu from '@cccsaurora/howler-ui/components/routes/hits/search/HitContextMenu';
|
|
13
12
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
13
|
import { useTranslation } from 'react-i18next';
|
|
15
14
|
import { Link, useNavigate } from 'react-router-dom';
|
|
16
15
|
import { useContextSelector } from 'use-context-selector';
|
|
17
|
-
import { isObservable } from '@cccsaurora/howler-ui/utils/typeUtils';
|
|
18
16
|
import { buildViewUrl } from '@cccsaurora/howler-ui/utils/viewUtils';
|
|
19
|
-
// Custom hook to select
|
|
20
|
-
const
|
|
21
|
-
const
|
|
17
|
+
// Custom hook to select hits by IDs with proper memoization
|
|
18
|
+
const useSelectHitsByIds = (hitIds) => {
|
|
19
|
+
const hitIdsRef = useRef(hitIds);
|
|
22
20
|
const prevResultRef = useRef([]);
|
|
23
|
-
const
|
|
24
|
-
// Keep ref up to date with latest
|
|
25
|
-
|
|
21
|
+
const prevHitIdsRef = useRef([]);
|
|
22
|
+
// Keep ref up to date with latest hitIds
|
|
23
|
+
hitIdsRef.current = hitIds;
|
|
26
24
|
const selector = useCallback(ctx => {
|
|
27
|
-
const
|
|
28
|
-
// Fast path: if
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
25
|
+
const currentHitIds = hitIdsRef.current;
|
|
26
|
+
// Fast path: if hitIds array didn't change, check if hit objects changed
|
|
27
|
+
if (prevHitIdsRef.current.length === currentHitIds.length &&
|
|
28
|
+
currentHitIds.every((id, i) => id === prevHitIdsRef.current[i])) {
|
|
29
|
+
// HitIds unchanged - check if any hit objects changed by reference
|
|
30
|
+
const anyHitChanged = currentHitIds.some((id, i) => ctx.hits[id] !== prevResultRef.current[i]);
|
|
31
|
+
if (!anyHitChanged) {
|
|
34
32
|
return prevResultRef.current;
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
// Something changed - rebuild the array
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
prevResultRef.current =
|
|
41
|
-
return
|
|
36
|
+
const currentHits = currentHitIds.map(id => ctx.hits[id]).filter(Boolean);
|
|
37
|
+
prevHitIdsRef.current = currentHitIds;
|
|
38
|
+
prevResultRef.current = currentHits;
|
|
39
|
+
return currentHits;
|
|
42
40
|
}, []); // Empty deps - selector never changes
|
|
43
|
-
return
|
|
41
|
+
return useHitContextSelector(selector);
|
|
44
42
|
};
|
|
45
43
|
// Utility functions
|
|
46
44
|
const normalize = (val) => (val == null ? '' : String(val));
|
|
47
45
|
// Have to normalize the fields as websockets and api return null and undefined respectively. This causes false positives when comparing signatures if not normalized to a consistent value. We also stringify non-primitive values to ensure changes are detected.
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
46
|
+
const createHitSignature = (hit) => {
|
|
47
|
+
if (!hit)
|
|
50
48
|
return '';
|
|
51
|
-
}
|
|
52
|
-
if (isObservable(record)) {
|
|
53
|
-
return record.howler?.id;
|
|
54
|
-
}
|
|
55
|
-
return `${record.howler?.id}:${normalize(record.howler?.status)}:${normalize(record.howler?.assignment)}:${normalize(record.howler?.assessment)}`;
|
|
49
|
+
return `${hit.howler?.id}:${normalize(hit.howler?.status)}:${normalize(hit.howler?.assignment)}:${normalize(hit.howler?.assessment)}`;
|
|
56
50
|
};
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
51
|
+
const createSignatureFromHits = (hits) => {
|
|
52
|
+
if (hits.length === 0)
|
|
59
53
|
return '';
|
|
60
|
-
return
|
|
54
|
+
return hits.map(createHitSignature).join('|');
|
|
61
55
|
};
|
|
62
56
|
const DEBOUNCE_TIME = 1000; // 1 second debounce for signature changes
|
|
63
57
|
const ViewCard = ({ viewId, limit, refreshTick, onRefreshComplete }) => {
|
|
64
58
|
const navigate = useNavigate();
|
|
65
59
|
const { t } = useTranslation();
|
|
66
60
|
const { dispatchApi } = useMyApi();
|
|
67
|
-
const [
|
|
61
|
+
const [hitIds, setHitIds] = useState([]);
|
|
68
62
|
const [loading, setLoading] = useState(false);
|
|
69
63
|
const debounceTimerRef = useRef(null);
|
|
70
64
|
const isRefreshing = useRef(false);
|
|
71
65
|
const lastSignature = useRef('');
|
|
72
66
|
const view = useContextSelector(ViewContext, ctx => ctx.views[viewId]);
|
|
73
67
|
const fetchViews = useContextSelector(ViewContext, ctx => ctx.fetchViews);
|
|
74
|
-
const
|
|
68
|
+
const loadHits = useHitContextSelector(ctx => ctx.loadHits);
|
|
75
69
|
// Subscribe to hits from HitProvider cache based on current hitIds in the view
|
|
76
70
|
// Uses memoized selector to avoid unnecessary re-renders on unrelated hit updates
|
|
77
|
-
const
|
|
71
|
+
const hits = useSelectHitsByIds(hitIds);
|
|
78
72
|
// Create a stable signature that only changes when relevant fields change
|
|
79
|
-
const
|
|
73
|
+
const hitsSignature = useMemo(() => createSignatureFromHits(hits), [hits]);
|
|
80
74
|
const refreshView = useCallback(async () => {
|
|
81
75
|
if (!view?.query || isRefreshing.current) {
|
|
82
76
|
onRefreshComplete?.();
|
|
@@ -84,21 +78,21 @@ const ViewCard = ({ viewId, limit, refreshTick, onRefreshComplete }) => {
|
|
|
84
78
|
}
|
|
85
79
|
isRefreshing.current = true;
|
|
86
80
|
try {
|
|
87
|
-
const res = await dispatchApi(api.
|
|
81
|
+
const res = await dispatchApi(api.search.hit.post({
|
|
88
82
|
query: view.query,
|
|
89
83
|
rows: limit,
|
|
90
84
|
metadata: ['analytic']
|
|
91
85
|
}));
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
lastSignature.current =
|
|
86
|
+
const fetchedHits = res.items ?? [];
|
|
87
|
+
loadHits(fetchedHits);
|
|
88
|
+
setHitIds(fetchedHits.map(h => h.howler.id));
|
|
89
|
+
lastSignature.current = createSignatureFromHits(fetchedHits);
|
|
96
90
|
}
|
|
97
91
|
finally {
|
|
98
92
|
isRefreshing.current = false;
|
|
99
93
|
onRefreshComplete?.();
|
|
100
94
|
}
|
|
101
|
-
}, [dispatchApi, limit, view?.query,
|
|
95
|
+
}, [dispatchApi, limit, view?.query, loadHits, onRefreshComplete]);
|
|
102
96
|
const debouncedRefresh = useCallback(() => {
|
|
103
97
|
if (debounceTimerRef.current) {
|
|
104
98
|
clearTimeout(debounceTimerRef.current);
|
|
@@ -131,16 +125,16 @@ const ViewCard = ({ viewId, limit, refreshTick, onRefreshComplete }) => {
|
|
|
131
125
|
}, [view?.query, limit, refreshView]);
|
|
132
126
|
// Monitor hits currently in the view for changes that might affect query results
|
|
133
127
|
useEffect(() => {
|
|
134
|
-
if (!
|
|
135
|
-
lastSignature.current =
|
|
128
|
+
if (!hitsSignature || hitIds.length === 0 || !lastSignature.current) {
|
|
129
|
+
lastSignature.current = hitsSignature;
|
|
136
130
|
return;
|
|
137
131
|
}
|
|
138
132
|
// Check if signature actually changed
|
|
139
|
-
if (lastSignature.current ===
|
|
133
|
+
if (lastSignature.current === hitsSignature) {
|
|
140
134
|
return;
|
|
141
135
|
}
|
|
142
136
|
debouncedRefresh();
|
|
143
|
-
}, [
|
|
137
|
+
}, [hitsSignature, hitIds, debouncedRefresh]);
|
|
144
138
|
useEffect(() => {
|
|
145
139
|
return () => {
|
|
146
140
|
if (debounceTimerRef.current) {
|
|
@@ -157,6 +151,6 @@ const ViewCard = ({ viewId, limit, refreshTick, onRefreshComplete }) => {
|
|
|
157
151
|
}
|
|
158
152
|
return selectedElement.id;
|
|
159
153
|
}, []);
|
|
160
|
-
return (_jsx(Card, { variant: "outlined", sx: { height: '100%' }, children: _jsxs(Stack, { spacing: 1, sx: { p: 1, minHeight: 100 }, children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { variant: "h6", children: t(view?.title) || _jsx(Skeleton, { variant: "text", height: "2em", width: "100px" }) }), _jsx(IconButton, { size: "small", component: Link, disabled: !view, to: view ? buildViewUrl(view) : '', onClick: () => onClick(view.query), children: _jsx(OpenInNew, { fontSize: "small" }) })] }), loading ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { height: 150, width: "100%", variant: "rounded" }), _jsx(Skeleton, { height: 160, width: "100%", variant: "rounded" }), _jsx(Skeleton, { height: 140, width: "100%", variant: "rounded" })] })) :
|
|
154
|
+
return (_jsx(Card, { variant: "outlined", sx: { height: '100%' }, children: _jsxs(Stack, { spacing: 1, sx: { p: 1, minHeight: 100 }, children: [_jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { variant: "h6", children: t(view?.title) || _jsx(Skeleton, { variant: "text", height: "2em", width: "100px" }) }), _jsx(IconButton, { size: "small", component: Link, disabled: !view, to: view ? buildViewUrl(view) : '', onClick: () => onClick(view.query), children: _jsx(OpenInNew, { fontSize: "small" }) })] }), loading ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { height: 150, width: "100%", variant: "rounded" }), _jsx(Skeleton, { height: 160, width: "100%", variant: "rounded" }), _jsx(Skeleton, { height: 140, width: "100%", variant: "rounded" })] })) : hits.length > 0 ? (_jsx(HitContextMenu, { getSelectedId: getSelectedId, children: hits.map(h => (_jsx(Card, { id: h.howler.id, variant: "outlined", sx: { cursor: 'pointer' }, onClick: () => navigate((h.howler.is_bundle ? '/bundles/' : '/hits/') + h.howler.id), children: _jsx(CardContent, { children: _jsx(HitBanner, { layout: HitLayout.DENSE, hit: h }) }) }, h.howler.id))) })) : (_jsx(AppListEmpty, {}))] }) }));
|
|
161
155
|
};
|
|
162
156
|
export default ViewCard;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { render, screen, act } from '@testing-library/react';
|
|
4
|
+
import i18n from '@cccsaurora/howler-ui/i18n';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { I18nextProvider } from 'react-i18next';
|
|
7
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
8
|
+
import ViewRefresh, {} from './ViewRefresh';
|
|
9
|
+
const Wrapper = ({ children }) => (_jsx(I18nextProvider, { i18n: i18n, children: children }));
|
|
10
|
+
describe('ViewRefresh', () => {
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
vi.useFakeTimers();
|
|
13
|
+
});
|
|
14
|
+
afterEach(() => {
|
|
15
|
+
vi.useRealTimers();
|
|
16
|
+
});
|
|
17
|
+
it('should render the refresh button', () => {
|
|
18
|
+
const onRefresh = vi.fn();
|
|
19
|
+
render(_jsx(ViewRefresh, { refreshRate: 30, viewCardCount: 2, onRefresh: onRefresh }), { wrapper: Wrapper });
|
|
20
|
+
expect(screen.getByRole('button')).toBeInTheDocument();
|
|
21
|
+
});
|
|
22
|
+
it('should show a progress indicator initially', () => {
|
|
23
|
+
const onRefresh = vi.fn();
|
|
24
|
+
render(_jsx(ViewRefresh, { refreshRate: 30, viewCardCount: 2, onRefresh: onRefresh }), { wrapper: Wrapper });
|
|
25
|
+
expect(screen.getByRole('progressbar')).toBeInTheDocument();
|
|
26
|
+
});
|
|
27
|
+
it('should trigger refresh when progress reaches 100%', async () => {
|
|
28
|
+
const onRefresh = vi.fn();
|
|
29
|
+
render(_jsx(ViewRefresh, { refreshRate: 30, viewCardCount: 2, onRefresh: onRefresh }), { wrapper: Wrapper });
|
|
30
|
+
// Progress increments by 1 every refreshRate*10ms = 300ms.
|
|
31
|
+
// Each increment triggers a re-render and a new setTimeout.
|
|
32
|
+
// We advance one tick at a time inside act to let React process each state update.
|
|
33
|
+
for (let i = 0; i < 101; i++) {
|
|
34
|
+
await act(async () => {
|
|
35
|
+
vi.advanceTimersByTime(300);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
expect(onRefresh).toHaveBeenCalled();
|
|
39
|
+
});
|
|
40
|
+
it('should clear refreshing state when all cards report back via ref', async () => {
|
|
41
|
+
const onRefresh = vi.fn();
|
|
42
|
+
const ref = React.createRef();
|
|
43
|
+
render(_jsx(ViewRefresh, { ref: ref, refreshRate: 30, viewCardCount: 2, onRefresh: onRefresh }), { wrapper: Wrapper });
|
|
44
|
+
// Advance to 100% to trigger refresh
|
|
45
|
+
for (let i = 0; i < 101; i++) {
|
|
46
|
+
await act(async () => {
|
|
47
|
+
vi.advanceTimersByTime(300);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
expect(onRefresh).toHaveBeenCalled();
|
|
51
|
+
// Simulate both cards completing
|
|
52
|
+
act(() => {
|
|
53
|
+
ref.current?.handleRefreshComplete();
|
|
54
|
+
ref.current?.handleRefreshComplete();
|
|
55
|
+
});
|
|
56
|
+
// After all cards complete, the progress should reset (button re-enabled)
|
|
57
|
+
expect(screen.getByRole('button')).not.toBeDisabled();
|
|
58
|
+
});
|
|
59
|
+
it('should trigger refresh via manual click', () => {
|
|
60
|
+
const onRefresh = vi.fn();
|
|
61
|
+
render(_jsx(ViewRefresh, { refreshRate: 30, viewCardCount: 2, onRefresh: onRefresh }), { wrapper: Wrapper });
|
|
62
|
+
// Click the refresh button directly using fireEvent (avoids userEvent timer issues)
|
|
63
|
+
const button = screen.getByRole('button');
|
|
64
|
+
act(() => {
|
|
65
|
+
button.click();
|
|
66
|
+
});
|
|
67
|
+
expect(onRefresh).toHaveBeenCalled();
|
|
68
|
+
});
|
|
69
|
+
it('should not call onRefresh when viewCardCount is 0 and button is clicked', () => {
|
|
70
|
+
const onRefresh = vi.fn();
|
|
71
|
+
render(_jsx(ViewRefresh, { refreshRate: 30, viewCardCount: 0, onRefresh: onRefresh }), { wrapper: Wrapper });
|
|
72
|
+
const button = screen.getByRole('button');
|
|
73
|
+
act(() => {
|
|
74
|
+
button.click();
|
|
75
|
+
});
|
|
76
|
+
// onRefresh should not be called because viewCardCount is 0
|
|
77
|
+
expect(onRefresh).not.toHaveBeenCalled();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent, {} from '@testing-library/user-event';
|
|
5
|
+
import i18n from '@cccsaurora/howler-ui/i18n';
|
|
6
|
+
import { I18nextProvider } from 'react-i18next';
|
|
7
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
8
|
+
import OverviewCard from './OverviewCard';
|
|
9
|
+
vi.mock('components/elements/display/HowlerAvatar', () => ({
|
|
10
|
+
default: ({ userId }) => _jsx("div", { id: "howler-avatar", children: userId })
|
|
11
|
+
}));
|
|
12
|
+
vi.mock('components/elements/addons/layout/FlexOne', () => ({
|
|
13
|
+
default: () => _jsx("div", { id: "flex-one" })
|
|
14
|
+
}));
|
|
15
|
+
const Wrapper = ({ children }) => (_jsx(I18nextProvider, { i18n: i18n, children: children }));
|
|
16
|
+
describe('OverviewCard', () => {
|
|
17
|
+
let user;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
user = userEvent.setup();
|
|
20
|
+
vi.clearAllMocks();
|
|
21
|
+
});
|
|
22
|
+
it('should render overview analytic and detection', () => {
|
|
23
|
+
const overview = {
|
|
24
|
+
overview_id: 'ov-1',
|
|
25
|
+
analytic: 'Test Analytic',
|
|
26
|
+
detection: 'Test Detection',
|
|
27
|
+
content: 'line 1\nline 2\nline 3',
|
|
28
|
+
owner: 'testuser'
|
|
29
|
+
};
|
|
30
|
+
render(_jsx(OverviewCard, { overview: overview }), { wrapper: Wrapper });
|
|
31
|
+
expect(screen.getByText(/Test Analytic/)).toBeInTheDocument();
|
|
32
|
+
expect(screen.getByText(/Test Detection/)).toBeInTheDocument();
|
|
33
|
+
});
|
|
34
|
+
it('should render "All" when detection is null', () => {
|
|
35
|
+
const overview = {
|
|
36
|
+
overview_id: 'ov-1',
|
|
37
|
+
analytic: 'Test Analytic',
|
|
38
|
+
detection: null,
|
|
39
|
+
content: 'line 1',
|
|
40
|
+
owner: 'testuser'
|
|
41
|
+
};
|
|
42
|
+
render(_jsx(OverviewCard, { overview: overview }), { wrapper: Wrapper });
|
|
43
|
+
expect(screen.getByText(/All/)).toBeInTheDocument();
|
|
44
|
+
});
|
|
45
|
+
it('should display content preview (max 3 lines)', () => {
|
|
46
|
+
const overview = {
|
|
47
|
+
overview_id: 'ov-1',
|
|
48
|
+
analytic: 'Test Analytic',
|
|
49
|
+
detection: null,
|
|
50
|
+
content: 'first line\nsecond line\nthird line\nfourth line\nfifth line',
|
|
51
|
+
owner: 'testuser'
|
|
52
|
+
};
|
|
53
|
+
render(_jsx(OverviewCard, { overview: overview }), { wrapper: Wrapper });
|
|
54
|
+
expect(screen.getByText(/first line/)).toBeInTheDocument();
|
|
55
|
+
expect(screen.getByText(/second line/)).toBeInTheDocument();
|
|
56
|
+
expect(screen.getByText(/third line/)).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
it('should render the owner avatar', () => {
|
|
59
|
+
const overview = {
|
|
60
|
+
overview_id: 'ov-1',
|
|
61
|
+
analytic: 'Test Analytic',
|
|
62
|
+
detection: null,
|
|
63
|
+
content: 'content',
|
|
64
|
+
owner: 'testuser'
|
|
65
|
+
};
|
|
66
|
+
render(_jsx(OverviewCard, { overview: overview }), { wrapper: Wrapper });
|
|
67
|
+
expect(screen.getByTestId('howler-avatar')).toBeInTheDocument();
|
|
68
|
+
expect(screen.getByText('testuser')).toBeInTheDocument();
|
|
69
|
+
});
|
|
70
|
+
it('should not show delete button when onDelete is not provided', () => {
|
|
71
|
+
const overview = {
|
|
72
|
+
overview_id: 'ov-1',
|
|
73
|
+
analytic: 'Test Analytic',
|
|
74
|
+
detection: null,
|
|
75
|
+
content: 'content',
|
|
76
|
+
owner: 'testuser'
|
|
77
|
+
};
|
|
78
|
+
render(_jsx(OverviewCard, { overview: overview }), { wrapper: Wrapper });
|
|
79
|
+
expect(document.querySelector('[data-testid="DeleteIcon"]')).not.toBeInTheDocument();
|
|
80
|
+
});
|
|
81
|
+
it('should show delete button and call onDelete when clicked', async () => {
|
|
82
|
+
const mockOnDelete = vi.fn();
|
|
83
|
+
const overview = {
|
|
84
|
+
overview_id: 'ov-1',
|
|
85
|
+
analytic: 'Test Analytic',
|
|
86
|
+
detection: null,
|
|
87
|
+
content: 'content',
|
|
88
|
+
owner: 'testuser'
|
|
89
|
+
};
|
|
90
|
+
render(_jsx(OverviewCard, { overview: overview, onDelete: mockOnDelete }), { wrapper: Wrapper });
|
|
91
|
+
const deleteButton = document.querySelector('[data-testid="DeleteIcon"]').closest('button');
|
|
92
|
+
await user.click(deleteButton);
|
|
93
|
+
expect(mockOnDelete).toHaveBeenCalledWith(expect.anything(), 'ov-1');
|
|
94
|
+
});
|
|
95
|
+
it('should apply custom className', () => {
|
|
96
|
+
const overview = {
|
|
97
|
+
overview_id: 'ov-1',
|
|
98
|
+
analytic: 'Test Analytic',
|
|
99
|
+
detection: null,
|
|
100
|
+
content: 'content',
|
|
101
|
+
owner: 'testuser'
|
|
102
|
+
};
|
|
103
|
+
const { container } = render(_jsx(OverviewCard, { overview: overview, className: "custom-class" }), {
|
|
104
|
+
wrapper: Wrapper
|
|
105
|
+
});
|
|
106
|
+
expect(container.querySelector('.custom-class')).toBeInTheDocument();
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -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 '
|
|
8
|
-
const
|
|
7
|
+
import { conf, language } from './markdownExtendedTokenProvider';
|
|
8
|
+
const OverviewEditor = ({ 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 MarkdownEditor = ({ 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(
|
|
56
|
+
export default memo(OverviewEditor);
|
|
@@ -8,6 +8,7 @@ import { Check, DarkMode, Delete, SsidChart, WbSunny } from '@mui/icons-material
|
|
|
8
8
|
import { useApp } from '@cccsaurora/howler-ui/commons/components/app/hooks';
|
|
9
9
|
import AppInfoPanel from '@cccsaurora/howler-ui/commons/components/display/AppInfoPanel';
|
|
10
10
|
import useThemeBuilder from '@cccsaurora/howler-ui/commons/components/utils/hooks/useThemeBuilder';
|
|
11
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
11
12
|
import { OverviewContext } from '@cccsaurora/howler-ui/components/app/providers/OverviewProvider';
|
|
12
13
|
import HitOverview from '@cccsaurora/howler-ui/components/elements/hit/HitOverview';
|
|
13
14
|
import useMyApi from '@cccsaurora/howler-ui/components/hooks/useMyApi';
|
|
@@ -15,7 +16,7 @@ import useMyTheme from '@cccsaurora/howler-ui/components/hooks/useMyTheme';
|
|
|
15
16
|
import { useSearchParams } from 'react-router-dom';
|
|
16
17
|
import hitsData from '@cccsaurora/howler-ui/utils/hit.json';
|
|
17
18
|
import { sanitizeLuceneQuery } from '@cccsaurora/howler-ui/utils/stringUtils';
|
|
18
|
-
import
|
|
19
|
+
import OverviewEditor from './OverviewEditor';
|
|
19
20
|
import { useStartingTemplate } from './startingTemplate';
|
|
20
21
|
const OverviewViewer = () => {
|
|
21
22
|
const theme = useTheme();
|
|
@@ -25,6 +26,7 @@ const OverviewViewer = () => {
|
|
|
25
26
|
const [params, setParams] = useSearchParams();
|
|
26
27
|
const { getOverviews } = useContext(OverviewContext);
|
|
27
28
|
const { dispatchApi } = useMyApi();
|
|
29
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
28
30
|
const [overviewList, setOverviewList] = useState([]);
|
|
29
31
|
const [selectedOverview, setSelectedOverview] = useState(null);
|
|
30
32
|
const [content, setContent] = useState('');
|
|
@@ -124,15 +126,17 @@ const OverviewViewer = () => {
|
|
|
124
126
|
replace: true
|
|
125
127
|
});
|
|
126
128
|
}, [analytic, detection, params, setParams]);
|
|
127
|
-
const onDelete = useCallback(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
const onDelete = useCallback(() => {
|
|
130
|
+
withConfirmDeleteModal(async () => {
|
|
131
|
+
await dispatchApi(api.overview.del(selectedOverview.overview_id), {
|
|
132
|
+
logError: false,
|
|
133
|
+
showError: true,
|
|
134
|
+
throwError: false
|
|
135
|
+
});
|
|
136
|
+
setSelectedOverview(null);
|
|
137
|
+
setContent('');
|
|
132
138
|
});
|
|
133
|
-
|
|
134
|
-
setContent('');
|
|
135
|
-
}, [dispatchApi, selectedOverview?.overview_id]);
|
|
139
|
+
}, [dispatchApi, selectedOverview?.overview_id, withConfirmDeleteModal]);
|
|
136
140
|
const onSave = useCallback(async () => {
|
|
137
141
|
if (analytic && detection) {
|
|
138
142
|
try {
|
|
@@ -188,7 +192,7 @@ const OverviewViewer = () => {
|
|
|
188
192
|
right: `calc(50% + 7px - ${x}px)`,
|
|
189
193
|
mr: -2.4,
|
|
190
194
|
pr: 1.5
|
|
191
|
-
}, children: _jsx(
|
|
195
|
+
}, children: _jsx(OverviewEditor, { height: "100%", content: content, setContent: setContent }) }) }), _jsx(Box, { sx: {
|
|
192
196
|
position: 'absolute',
|
|
193
197
|
top: 0,
|
|
194
198
|
bottom: 0,
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { Article } from '@mui/icons-material';
|
|
3
3
|
import { Typography } from '@mui/material';
|
|
4
4
|
import api from '@cccsaurora/howler-ui/api';
|
|
5
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
5
6
|
import { TuiListProvider } from '@cccsaurora/howler-ui/components/elements/addons/lists';
|
|
6
7
|
import { TuiListMethodContext } from '@cccsaurora/howler-ui/components/elements/addons/lists/TuiListProvider';
|
|
7
8
|
import ItemManager from '@cccsaurora/howler-ui/components/elements/display/ItemManager';
|
|
@@ -18,6 +19,7 @@ const OverviewsBase = () => {
|
|
|
18
19
|
const navigate = useNavigate();
|
|
19
20
|
const { dispatchApi } = useMyApi();
|
|
20
21
|
const { showSuccessMessage } = useMySnackbar();
|
|
22
|
+
const { withConfirmDeleteModal } = useContext(ModalContext);
|
|
21
23
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
22
24
|
const { load } = useContext(TuiListMethodContext);
|
|
23
25
|
const pageCount = useMyLocalStorageItem(StorageKey.PAGE_COUNT, 25)[0];
|
|
@@ -73,19 +75,21 @@ const OverviewsBase = () => {
|
|
|
73
75
|
setOffset(_offset);
|
|
74
76
|
}
|
|
75
77
|
}, [offset, searchParams, setSearchParams]);
|
|
76
|
-
const onDelete = useCallback(
|
|
78
|
+
const onDelete = useCallback((e, id) => {
|
|
77
79
|
e.preventDefault();
|
|
78
80
|
e.stopPropagation();
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
81
|
+
withConfirmDeleteModal(async () => {
|
|
82
|
+
try {
|
|
83
|
+
await dispatchApi(api.overview.del(id), { throwError: false, showError: true });
|
|
84
|
+
await onSearch();
|
|
85
|
+
showSuccessMessage(t('route.overviews.manager.delete.success'));
|
|
86
|
+
}
|
|
87
|
+
catch (_err) {
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
89
|
+
console.warn(_err);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}, [dispatchApi, onSearch, withConfirmDeleteModal, showSuccessMessage, t]);
|
|
89
93
|
useEffect(() => {
|
|
90
94
|
onSearch();
|
|
91
95
|
if (!searchParams.has('offset')) {
|
|
@@ -17,11 +17,12 @@ const LocalSection = () => {
|
|
|
17
17
|
const [compactJson, setCompactJson] = useMyLocalStorageItem(StorageKey.COMPACT_JSON, true);
|
|
18
18
|
const [flattenJson, setFlattenJson] = useMyLocalStorageItem(StorageKey.FLATTEN_JSON, false);
|
|
19
19
|
const [forceDrawer, setForceDrawer] = useMyLocalStorageItem(StorageKey.FORCE_DRAWER, false);
|
|
20
|
+
const [showHitSummaryGraph, setShowHitSummaryGraph] = useMyLocalStorageItem(StorageKey.SHOW_HIT_SUMMARY_GRAPH, true);
|
|
20
21
|
const [hitLayout, setHitLayout] = useMyLocalStorageItem(StorageKey.HIT_LAYOUT, false);
|
|
21
22
|
const [displayType, setDisplayType] = useMyLocalStorageItem(StorageKey.DISPLAY_TYPE, 'list');
|
|
22
23
|
const [pageCount, setPageCount] = useMyLocalStorageItem(StorageKey.PAGE_COUNT, 25);
|
|
23
24
|
const [searchWidth, setSearchWidth] = useMyLocalStorageItem(StorageKey.SEARCH_PANE_WIDTH, null);
|
|
24
25
|
const [templateFieldCount, setTemplateFieldCount] = useMyLocalStorageItem(StorageKey.TEMPLATE_FIELD_COUNT, null);
|
|
25
|
-
return (_jsxs(SettingsSection, { title: t('page.settings.local.title'), colSpan: 3, children: [_jsx(EditRow, { titleKey: "page.settings.local.compact.json", descriptionKey: "page.settings.local.compact.json.description", value: compactJson, type: "checkbox", onEdit: async (value) => setCompactJson(JSON.parse(value)) }), _jsx(EditRow, { titleKey: "page.settings.local.flatten.json", descriptionKey: "page.settings.local.flatten.json.description", value: flattenJson, type: "checkbox", onEdit: async (value) => setFlattenJson(JSON.parse(value)) }), _jsx(EditRow, { titleKey: "page.settings.local.details.drawer", descriptionKey: "page.settings.local.details.drawer.description", value: forceDrawer, type: "checkbox", onEdit: async (value) => setForceDrawer(JSON.parse(value)) }), _jsx(EditRow, { titleKey: "page.settings.local.search.width", descriptionKey: "page.settings.local.search.width.description", value: searchWidth, type: "range", min: 400, max: Math.floor(window.innerWidth / 100) * 100, optional: true, onEdit: async (value) => setSearchWidth(value ? parseInt(value) : null) }), _jsxs(TableRow, { children: [_jsx(TableCell, { sx: CELL_SX, style: { whiteSpace: 'nowrap' }, children: t('page.settings.local.hits.layout') }), _jsx(TableCell, { sx: CELL_SX, colSpan: 2, align: "right", children: _jsxs(ToggleButtonGroup, { size: "small", value: hitLayout, exclusive: true, onChange: (_, value) => setHitLayout(value), children: [_jsx(ToggleButton, { value: HitLayout.DENSE, children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(ViewCompact, {}), _jsx("span", { children: t('page.settings.local.hits.layout.dense') })] }) }), _jsx(ToggleButton, { value: HitLayout.NORMAL, children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(ViewModule, {}), _jsx("span", { children: t('page.settings.local.hits.layout.normal') })] }) }), _jsx(ToggleButton, { value: HitLayout.COMFY, children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(ViewComfy, {}), _jsx("span", { children: t('page.settings.local.hits.layout.comfy') })] }) })] }) })] }), _jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, sx: { paddingTop: '0 !important' }, children: _jsx(Typography, { variant: "caption", color: "text.secondary", children: t('page.settings.local.hits.layout.description') }) }) }), _jsx(EditRow, { titleKey: "page.settings.local.hits.field_count", descriptionKey: "page.settings.local.hits.field_count.description", value: templateFieldCount, type: "range", min: 0, step: 1, max: 15, optional: true, onEdit: async (value) => setTemplateFieldCount(value ? parseInt(value) : null), valueLabelFormat: val => val.toString() }), _jsxs(TableRow, { children: [_jsx(TableCell, { sx: CELL_SX, style: { whiteSpace: 'nowrap' }, children: t('page.settings.local.hits.display_type') }), _jsx(TableCell, { sx: CELL_SX, colSpan: 2, align: "right", children: _jsxs(ToggleButtonGroup, { size: "small", value: displayType, exclusive: true, onChange: (_, value) => setDisplayType(value), children: [_jsx(ToggleButton, { value: "list", children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(List, {}), _jsx("span", { children: t('page.settings.local.hits.display_type.list') })] }) }), _jsx(ToggleButton, { value: "grid", children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(TableChart, {}), _jsx("span", { children: t('page.settings.local.hits.display_type.grid') })] }) })] }) })] }), _jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, sx: { paddingTop: '0 !important' }, children: _jsx(Typography, { variant: "caption", color: "text.secondary", children: t('page.settings.local.hits.display_type.description') }) }) }), _jsxs(TableRow, { children: [_jsx(TableCell, { sx: CELL_SX, style: { whiteSpace: 'nowrap' }, children: t('page.settings.local.results.count') }), _jsx(TableCell, { sx: CELL_SX, colSpan: 2, align: "right", children: _jsxs(Select, { size: "small", sx: { minWidth: '75px', textAlign: 'left' }, value: pageCount, onChange: event => setPageCount(typeof event.target.value === 'string' ? parseInt(event.target.value) : event.target.value), children: [_jsx(MenuItem, { value: 5, children: "5" }), _jsx(MenuItem, { value: 10, children: "10" }), _jsx(MenuItem, { value: 25, children: "25" }), _jsx(MenuItem, { value: 50, children: "50" }), _jsx(MenuItem, { value: 75, children: "75" }), _jsx(MenuItem, { value: 100, children: "100" }), _jsx(MenuItem, { value: 150, children: "150" }), _jsx(MenuItem, { value: 250, children: "250" })] }) })] }), _jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, sx: { paddingTop: '0 !important' }, children: _jsx(Typography, { variant: "caption", color: "text.secondary", children: t('page.settings.local.results.count.description') }) }) }), howlerPluginStore.plugins.map(plugin => pluginStore.executeFunction(`${plugin}.settings`, 'local'))] }));
|
|
26
|
+
return (_jsxs(SettingsSection, { title: t('page.settings.local.title'), colSpan: 3, children: [_jsx(EditRow, { titleKey: "page.settings.local.compact.json", descriptionKey: "page.settings.local.compact.json.description", value: compactJson, type: "checkbox", onEdit: async (value) => setCompactJson(JSON.parse(value)) }), _jsx(EditRow, { titleKey: "page.settings.local.flatten.json", descriptionKey: "page.settings.local.flatten.json.description", value: flattenJson, type: "checkbox", onEdit: async (value) => setFlattenJson(JSON.parse(value)) }), _jsx(EditRow, { titleKey: "page.settings.local.details.drawer", descriptionKey: "page.settings.local.details.drawer.description", value: forceDrawer, type: "checkbox", onEdit: async (value) => setForceDrawer(JSON.parse(value)) }), _jsx(EditRow, { titleKey: "page.settings.local.show.hit.summary.graph", descriptionKey: "page.settings.local.show.hit.summary.graph.description", value: showHitSummaryGraph, type: "checkbox", onEdit: async (value) => setShowHitSummaryGraph(JSON.parse(value)) }), _jsx(EditRow, { titleKey: "page.settings.local.search.width", descriptionKey: "page.settings.local.search.width.description", value: searchWidth, type: "range", min: 400, max: Math.floor(window.innerWidth / 100) * 100, optional: true, onEdit: async (value) => setSearchWidth(value ? parseInt(value) : null) }), _jsxs(TableRow, { children: [_jsx(TableCell, { sx: CELL_SX, style: { whiteSpace: 'nowrap' }, children: t('page.settings.local.hits.layout') }), _jsx(TableCell, { sx: CELL_SX, colSpan: 2, align: "right", children: _jsxs(ToggleButtonGroup, { size: "small", value: hitLayout, exclusive: true, onChange: (_, value) => setHitLayout(value), children: [_jsx(ToggleButton, { value: HitLayout.DENSE, children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(ViewCompact, {}), _jsx("span", { children: t('page.settings.local.hits.layout.dense') })] }) }), _jsx(ToggleButton, { value: HitLayout.NORMAL, children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(ViewModule, {}), _jsx("span", { children: t('page.settings.local.hits.layout.normal') })] }) }), _jsx(ToggleButton, { value: HitLayout.COMFY, children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(ViewComfy, {}), _jsx("span", { children: t('page.settings.local.hits.layout.comfy') })] }) })] }) })] }), _jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, sx: { paddingTop: '0 !important' }, children: _jsx(Typography, { variant: "caption", color: "text.secondary", children: t('page.settings.local.hits.layout.description') }) }) }), _jsx(EditRow, { titleKey: "page.settings.local.hits.field_count", descriptionKey: "page.settings.local.hits.field_count.description", value: templateFieldCount, type: "range", min: 0, step: 1, max: 15, optional: true, onEdit: async (value) => setTemplateFieldCount(value ? parseInt(value) : null), valueLabelFormat: val => val.toString() }), _jsxs(TableRow, { children: [_jsx(TableCell, { sx: CELL_SX, style: { whiteSpace: 'nowrap' }, children: t('page.settings.local.hits.display_type') }), _jsx(TableCell, { sx: CELL_SX, colSpan: 2, align: "right", children: _jsxs(ToggleButtonGroup, { size: "small", value: displayType, exclusive: true, onChange: (_, value) => setDisplayType(value), children: [_jsx(ToggleButton, { value: "list", children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(List, {}), _jsx("span", { children: t('page.settings.local.hits.display_type.list') })] }) }), _jsx(ToggleButton, { value: "grid", children: _jsxs(Stack, { direction: "row", spacing: 0.5, children: [_jsx(TableChart, {}), _jsx("span", { children: t('page.settings.local.hits.display_type.grid') })] }) })] }) })] }), _jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, sx: { paddingTop: '0 !important' }, children: _jsx(Typography, { variant: "caption", color: "text.secondary", children: t('page.settings.local.hits.display_type.description') }) }) }), _jsxs(TableRow, { children: [_jsx(TableCell, { sx: CELL_SX, style: { whiteSpace: 'nowrap' }, children: t('page.settings.local.results.count') }), _jsx(TableCell, { sx: CELL_SX, colSpan: 2, align: "right", children: _jsxs(Select, { size: "small", sx: { minWidth: '75px', textAlign: 'left' }, value: pageCount, onChange: event => setPageCount(typeof event.target.value === 'string' ? parseInt(event.target.value) : event.target.value), children: [_jsx(MenuItem, { value: 5, children: "5" }), _jsx(MenuItem, { value: 10, children: "10" }), _jsx(MenuItem, { value: 25, children: "25" }), _jsx(MenuItem, { value: 50, children: "50" }), _jsx(MenuItem, { value: 75, children: "75" }), _jsx(MenuItem, { value: 100, children: "100" }), _jsx(MenuItem, { value: 150, children: "150" }), _jsx(MenuItem, { value: 250, children: "250" })] }) })] }), _jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, sx: { paddingTop: '0 !important' }, children: _jsx(Typography, { variant: "caption", color: "text.secondary", children: t('page.settings.local.results.count.description') }) }) }), howlerPluginStore.plugins.map(plugin => pluginStore.executeFunction(`${plugin}.settings`, 'local'))] }));
|
|
26
27
|
};
|
|
27
28
|
export default LocalSection;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import SettingsSection from './SettingsSection';
|
|
6
|
+
describe('SettingsSection', () => {
|
|
7
|
+
it('should render the title in a table header', () => {
|
|
8
|
+
render(_jsx(SettingsSection, { title: "Test Section", colSpan: 3, children: _jsx("tr", { children: _jsx("td", { children: "Content" }) }) }));
|
|
9
|
+
expect(screen.getByText('Test Section')).toBeInTheDocument();
|
|
10
|
+
});
|
|
11
|
+
it('should render children inside a table body', () => {
|
|
12
|
+
render(_jsx(SettingsSection, { title: "Test Section", colSpan: 2, children: _jsx("tr", { children: _jsx("td", { children: "Row Content" }) }) }));
|
|
13
|
+
expect(screen.getByText('Row Content')).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
it('should use the title as the table aria-label', () => {
|
|
16
|
+
render(_jsx(SettingsSection, { title: "Accessible Section", colSpan: 3, children: _jsx("tr", { children: _jsx("td", { children: "Content" }) }) }));
|
|
17
|
+
expect(screen.getByRole('table', { name: 'Accessible Section' })).toBeInTheDocument();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { Template } from '@cccsaurora/howler-ui/models/entities/generated/Template';
|
|
2
|
-
import type
|
|
2
|
+
import { type FC } from 'react';
|
|
3
3
|
declare const TemplateCard: FC<{
|
|
4
4
|
template: Template;
|
|
5
|
+
onRemove?: (templateId: string) => void;
|
|
6
|
+
error?: boolean;
|
|
5
7
|
className?: string;
|
|
6
8
|
}>;
|
|
7
9
|
export default TemplateCard;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Language, Lock, Person } from '@mui/icons-material';
|
|
3
|
-
import { Card, Divider, Stack, Tooltip, Typography } from '@mui/material';
|
|
2
|
+
import { Language, Lock, Person, ReportProblem } from '@mui/icons-material';
|
|
3
|
+
import { Button, Card, Divider, Stack, Tooltip, Typography } from '@mui/material';
|
|
4
|
+
import { ModalContext } from '@cccsaurora/howler-ui/components/app/providers/ModalProvider';
|
|
5
|
+
import ConfirmDeleteModal from '@cccsaurora/howler-ui/components/elements/display/modals/ConfirmDeleteModal';
|
|
6
|
+
import { useContext } from 'react';
|
|
4
7
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
const TemplateCard = ({ template, className }) => {
|
|
8
|
+
const TemplateCard = ({ template, onRemove, error, className }) => {
|
|
6
9
|
const { t } = useTranslation();
|
|
10
|
+
const { showModal } = useContext(ModalContext);
|
|
7
11
|
return (_jsx(Card, { variant: "outlined", sx: { p: 1, mb: 1 }, className: className, children: _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Tooltip, { title: t(`route.templates.manager.${template.type}`), children: {
|
|
8
12
|
readonly: _jsx(Lock, {}),
|
|
9
13
|
global: _jsx(Language, {}),
|
|
10
14
|
personal: _jsx(Person, {})
|
|
11
|
-
}[template.type] }), _jsx(Divider, { orientation: "vertical", flexItem: true }), _jsxs(Stack, { children: [_jsxs(Typography, { variant: "body1", children: [t(template.analytic), " - ", t(template.detection ?? 'all')] }), template.keys.map(key => (_jsx(Typography, { variant: "caption", sx: { ml: 1 }, children: _jsx("code", { children: key }) }, template.template_id + key)))] })] }) }, template.template_id));
|
|
15
|
+
}[template.type] }), _jsx(Divider, { orientation: "vertical", flexItem: true }), _jsxs(Stack, { children: [_jsxs(Typography, { variant: "body1", children: [t(template.analytic), " - ", t(template.detection ?? 'all')] }), template.keys.map(key => (_jsx(Typography, { variant: "caption", sx: { ml: 1 }, children: _jsx("code", { children: key }) }, template.template_id + key)))] }), error && (_jsx(Stack, { direction: "row", justifyContent: "end", width: "100%", children: _jsx(Stack, { children: _jsx(Tooltip, { title: t('route.templates.manager.error.action'), children: _jsx(Button, { startIcon: _jsx(ReportProblem, {}), color: "warning", onClick: () => showModal(_jsx(ConfirmDeleteModal, { onConfirm: () => onRemove?.(template.template_id), title: t('route.templates.manager.error.modal.title'), description: t('route.templates.manager.error.modal.description'), preferDelete: true })), children: t('route.templates.manager.error.message') }) }) }) }))] }) }, template.template_id));
|
|
12
16
|
};
|
|
13
17
|
export default TemplateCard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|