@cccsaurora/howler-ui 2.18.0-dev.674 → 2.18.0-dev.676
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 -2
- package/api/index.js +2 -4
- 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.js +7 -34
- package/components/app/hooks/useMatchers.js +2 -2
- package/components/app/hooks/useMatchers.test.js +22 -22
- package/components/app/hooks/useTitle.js +3 -3
- package/components/app/providers/FavouritesProvider.js +2 -2
- package/components/app/providers/HitProvider.d.ts +22 -0
- package/components/app/providers/{RecordProvider.js → HitProvider.js} +41 -41
- 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} +70 -51
- package/components/app/providers/ParameterProvider.d.ts +2 -9
- package/components/app/providers/ParameterProvider.js +240 -165
- package/components/app/providers/ParameterProvider.test.js +14 -307
- 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 +5 -14
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/display/ChipPopper.d.ts +1 -1
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +0 -1
- package/components/elements/display/icons/BundleButton.d.ts +6 -0
- package/components/elements/display/icons/BundleButton.js +32 -0
- package/components/elements/hit/HitActions.js +4 -4
- package/components/elements/hit/HitBanner.js +48 -28
- package/components/elements/hit/HitCard.js +5 -5
- 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/{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 +5 -6
- 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/outlines/DefaultOutline.js +1 -1
- package/components/elements/view/ViewTitle.js +1 -1
- 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 +1 -10
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +1 -4
- package/components/hooks/useMyTheme.js +2 -9
- package/components/hooks/useParamState.test.js +4 -3
- package/components/routes/action/edit/ActionEditor.js +2 -2
- package/components/routes/action/view/ActionSearch.js +1 -1
- 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 +2 -2
- 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/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/fr/bundles.md.js +1 -0
- 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 +227 -0
- package/components/{elements/record/RecordContextMenu.test.js → routes/hits/search/HitContextMenu.test.js} +39 -39
- 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 +60 -47
- 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} +8 -10
- package/components/routes/hits/view/HitViewer.js +13 -12
- package/components/routes/home/ViewCard.js +4 -4
- package/components/{elements/MarkdownEditor.js → routes/overviews/OverviewEditor.js} +3 -3
- package/components/routes/overviews/OverviewViewer.js +2 -2
- package/components/routes/views/ViewComposer.js +4 -4
- package/locales/en/translation.json +3 -65
- package/locales/fr/translation.json +3 -63
- 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 +0 -1
- package/models/entities/generated/Howler.d.ts +4 -0
- package/models/entities/generated/Rule.d.ts +10 -2
- package/models/entities/generated/Threat.d.ts +2 -2
- package/package.json +106 -123
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +1 -2
- package/tests/utils.d.ts +0 -2
- package/tests/utils.js +0 -8
- package/utils/constants.d.ts +3 -3
- package/utils/hitFunctions.d.ts +1 -2
- package/utils/hitFunctions.js +4 -4
- package/api/search/case.d.ts +0 -4
- package/api/search/case.js +0 -8
- package/api/v2/case/index.d.ts +0 -6
- package/api/v2/case/index.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 -8
- package/components/elements/case/CaseCard.js +0 -39
- 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 -8
- package/components/elements/hit/elements/AnalyticLink.js +0 -22
- 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 -23
- package/components/elements/observable/ObservablePreview.d.ts +0 -6
- package/components/elements/observable/ObservablePreview.js +0 -12
- package/components/elements/record/RecordContextMenu.js +0 -235
- package/components/elements/record/RecordContextMenu.test.d.ts +0 -1
- 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 -22
- package/components/routes/cases/Cases.d.ts +0 -2
- package/components/routes/cases/Cases.js +0 -101
- package/components/routes/cases/constants.d.ts +0 -5
- package/components/routes/cases/constants.js +0 -5
- 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 -12
- package/components/routes/cases/detail/CaseAssets.js +0 -101
- package/components/routes/cases/detail/CaseAssets.test.d.ts +0 -1
- package/components/routes/cases/detail/CaseAssets.test.js +0 -163
- package/components/routes/cases/detail/CaseDashboard.d.ts +0 -7
- package/components/routes/cases/detail/CaseDashboard.js +0 -51
- package/components/routes/cases/detail/CaseDetails.d.ts +0 -6
- package/components/routes/cases/detail/CaseDetails.js +0 -61
- package/components/routes/cases/detail/CaseOverview.d.ts +0 -7
- package/components/routes/cases/detail/CaseOverview.js +0 -43
- package/components/routes/cases/detail/CaseSidebar.d.ts +0 -6
- package/components/routes/cases/detail/CaseSidebar.js +0 -61
- package/components/routes/cases/detail/CaseTask.d.ts +0 -11
- package/components/routes/cases/detail/CaseTask.js +0 -57
- package/components/routes/cases/detail/ItemPage.d.ts +0 -6
- package/components/routes/cases/detail/ItemPage.js +0 -99
- package/components/routes/cases/detail/RelatedCasePanel.d.ts +0 -6
- package/components/routes/cases/detail/RelatedCasePanel.js +0 -31
- 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 -12
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +0 -19
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +0 -6
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +0 -27
- 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.d.ts +0 -1
- package/components/routes/cases/detail/assets/Asset.test.js +0 -72
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +0 -13
- package/components/routes/cases/detail/sidebar/CaseFolder.js +0 -131
- package/components/routes/cases/detail/sidebar/types.d.ts +0 -3
- package/components/routes/cases/detail/sidebar/utils.d.ts +0 -3
- package/components/routes/cases/detail/sidebar/utils.js +0 -25
- package/components/routes/cases/hooks/useCase.d.ts +0 -13
- package/components/routes/cases/hooks/useCase.js +0 -38
- package/components/routes/cases/modals/ResolveModal.d.ts +0 -7
- package/components/routes/cases/modals/ResolveModal.js +0 -59
- 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 -43
- 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/utils/typeUtils.d.ts +0 -7
- package/utils/typeUtils.js +0 -27
- /package/components/app/providers/{RecordSearchProvider.test.d.ts → HitSearchProvider.test.d.ts} +0 -0
- /package/components/elements/hit/{related/RelatedRecords.d.ts → HitDetails.d.ts} +0 -0
- /package/components/routes/hits/search/{RecordBrowser.d.ts → HitBrowser.d.ts} +0 -0
- /package/components/{elements/ContextMenu.test.d.ts → routes/hits/search/HitContextMenu.test.d.ts} +0 -0
- /package/components/{elements/MarkdownEditor.d.ts → routes/overviews/OverviewEditor.d.ts} +0 -0
|
@@ -16,9 +16,6 @@ vi.mock('./shared/HitSort', () => ({
|
|
|
16
16
|
vi.mock('./shared/SearchSpan', () => ({
|
|
17
17
|
default: () => _jsx("div", { id: "search-span", children: "SearchSpan" })
|
|
18
18
|
}));
|
|
19
|
-
vi.mock('./shared/IndexPicker', () => ({
|
|
20
|
-
default: () => _jsx("div", { id: "index-picker", children: "IndexPicker" })
|
|
21
|
-
}));
|
|
22
19
|
vi.mock('./ViewLink', () => ({
|
|
23
20
|
default: ({ id, viewId }) => (_jsxs("div", { id: `view-link-${id}`, "data-view-id": viewId, children: ["ViewLink ", id, ": ", viewId] }))
|
|
24
21
|
}));
|
|
@@ -36,7 +33,6 @@ const mockFetchViews = vi.fn();
|
|
|
36
33
|
let mockParameterContext = {
|
|
37
34
|
filters: [],
|
|
38
35
|
views: [],
|
|
39
|
-
indexes: [],
|
|
40
36
|
addFilter: mockAddFilter,
|
|
41
37
|
addView: mockAddView
|
|
42
38
|
};
|
|
@@ -274,16 +270,16 @@ describe('QuerySettings', () => {
|
|
|
274
270
|
mockParameterContext.views = ['view-1'];
|
|
275
271
|
const { container } = render(_jsx(QuerySettings, {}), { wrapper: Wrapper });
|
|
276
272
|
const gridItems = container.querySelectorAll('[class*="MuiGrid-item"]');
|
|
277
|
-
//
|
|
278
|
-
expect(gridItems.length).toBe(
|
|
273
|
+
// HitSort + SearchSpan + 1 view + 2 filters = 5 items
|
|
274
|
+
expect(gridItems.length).toBe(5);
|
|
279
275
|
});
|
|
280
276
|
it('should render correct number of items with multiple views', () => {
|
|
281
277
|
mockParameterContext.filters = ['filter1'];
|
|
282
278
|
mockParameterContext.views = ['view-1', 'view-2', 'view-3'];
|
|
283
279
|
const { container } = render(_jsx(QuerySettings, {}), { wrapper: Wrapper });
|
|
284
280
|
const gridItems = container.querySelectorAll('[class*="MuiGrid-item"]');
|
|
285
|
-
//
|
|
286
|
-
expect(gridItems.length).toBe(
|
|
281
|
+
// HitSort + SearchSpan + 3 views + 1 filter = 6 items
|
|
282
|
+
expect(gridItems.length).toBe(6);
|
|
287
283
|
});
|
|
288
284
|
});
|
|
289
285
|
describe('Edge Cases', () => {
|
|
@@ -512,12 +508,11 @@ describe('QuerySettings', () => {
|
|
|
512
508
|
mockParameterContext.views = ['view-1'];
|
|
513
509
|
const { container } = render(_jsx(QuerySettings, {}), { wrapper: Wrapper });
|
|
514
510
|
const gridItems = container.querySelectorAll('[class*="MuiGrid-item"]');
|
|
515
|
-
// Order:
|
|
516
|
-
expect(gridItems[0]).toContainElement(screen.getByTestId('
|
|
517
|
-
expect(gridItems[1]).toContainElement(screen.getByTestId('
|
|
518
|
-
expect(gridItems[2]).toContainElement(screen.getByTestId('
|
|
519
|
-
expect(gridItems[3]).toContainElement(screen.getByTestId('
|
|
520
|
-
expect(gridItems[4]).toContainElement(screen.getByTestId('hit-filter-0'));
|
|
511
|
+
// Order: HitSort, SearchSpan, ViewLink(s), HitFilter(s)
|
|
512
|
+
expect(gridItems[0]).toContainElement(screen.getByTestId('hit-sort'));
|
|
513
|
+
expect(gridItems[1]).toContainElement(screen.getByTestId('search-span'));
|
|
514
|
+
expect(gridItems[2]).toContainElement(screen.getByTestId('view-link-0'));
|
|
515
|
+
expect(gridItems[3]).toContainElement(screen.getByTestId('hit-filter-0'));
|
|
521
516
|
});
|
|
522
517
|
it('should pass correct props to ViewLink components', () => {
|
|
523
518
|
mockParameterContext.views = ['view-1', 'view-2'];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ErrorOutline, SavedSearch, Terminal } from '@mui/icons-material';
|
|
2
|
+
import { Close, ErrorOutline, SavedSearch, Terminal } from '@mui/icons-material';
|
|
3
3
|
import { Box, IconButton, LinearProgress, Stack, Tooltip, Typography, useMediaQuery, useTheme } from '@mui/material';
|
|
4
4
|
import { grey } from '@mui/material/colors';
|
|
5
5
|
import AppListEmpty from '@cccsaurora/howler-ui/commons/components/display/AppListEmpty';
|
|
6
6
|
import PageCenter from '@cccsaurora/howler-ui/commons/components/pages/PageCenter';
|
|
7
|
+
import { HitContext } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
|
|
8
|
+
import { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
|
|
7
9
|
import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
|
|
8
|
-
import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
|
|
9
|
-
import { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
|
|
10
10
|
import FlexOne from '@cccsaurora/howler-ui/components/elements/addons/layout/FlexOne';
|
|
11
11
|
import FlexPort from '@cccsaurora/howler-ui/components/elements/addons/layout/FlexPort';
|
|
12
12
|
import VSBox from '@cccsaurora/howler-ui/components/elements/addons/layout/vsbox/VSBox';
|
|
@@ -14,25 +14,27 @@ import VSBoxContent from '@cccsaurora/howler-ui/components/elements/addons/layou
|
|
|
14
14
|
import VSBoxHeader from '@cccsaurora/howler-ui/components/elements/addons/layout/vsbox/VSBoxHeader';
|
|
15
15
|
import SearchPagination from '@cccsaurora/howler-ui/components/elements/addons/search/SearchPagination';
|
|
16
16
|
import SearchTotal from '@cccsaurora/howler-ui/components/elements/addons/search/SearchTotal';
|
|
17
|
+
import HowlerCard from '@cccsaurora/howler-ui/components/elements/display/HowlerCard';
|
|
18
|
+
import HitBanner from '@cccsaurora/howler-ui/components/elements/hit/HitBanner';
|
|
17
19
|
import HitCard from '@cccsaurora/howler-ui/components/elements/hit/HitCard';
|
|
18
20
|
import { HitLayout } from '@cccsaurora/howler-ui/components/elements/hit/HitLayout';
|
|
19
|
-
import
|
|
20
|
-
import RecordContextMenu from '@cccsaurora/howler-ui/components/elements/record/RecordContextMenu';
|
|
21
|
+
import useHitSelection from '@cccsaurora/howler-ui/components/hooks/useHitSelection';
|
|
21
22
|
import { useMyLocalStorageItem } from '@cccsaurora/howler-ui/components/hooks/useMyLocalStorage';
|
|
22
|
-
import
|
|
23
|
-
import React, { memo, useCallback, useMemo } from 'react';
|
|
23
|
+
import React, { memo, useCallback, useEffect, useMemo } from 'react';
|
|
24
24
|
import { isMobile } from 'react-device-detect';
|
|
25
25
|
import { useTranslation } from 'react-i18next';
|
|
26
|
-
import { Link } from 'react-router-dom';
|
|
26
|
+
import { Link, useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
27
27
|
import { useContextSelector } from 'use-context-selector';
|
|
28
28
|
import { StorageKey } from '@cccsaurora/howler-ui/utils/constants';
|
|
29
|
-
import
|
|
29
|
+
import BundleParentMenu from './BundleParentMenu';
|
|
30
|
+
import { BundleScroller } from './BundleScroller';
|
|
31
|
+
import HitContextMenu from './HitContextMenu';
|
|
32
|
+
import HitQuery from './HitQuery';
|
|
30
33
|
import LayoutSettings from './LayoutSettings';
|
|
31
34
|
import QuerySettings from './QuerySettings';
|
|
32
|
-
|
|
33
|
-
const Item = memo(({ record, onClick }) => {
|
|
35
|
+
const Item = memo(({ hit, onClick }) => {
|
|
34
36
|
const theme = useTheme();
|
|
35
|
-
const
|
|
37
|
+
const selectedHits = useContextSelector(HitContext, ctx => ctx.selectedHits);
|
|
36
38
|
const selected = useContextSelector(ParameterContext, ctx => ctx.selected);
|
|
37
39
|
const checkMiddleClick = useCallback((e, id) => {
|
|
38
40
|
if (e.button === 1) {
|
|
@@ -44,14 +46,14 @@ const Item = memo(({ record, onClick }) => {
|
|
|
44
46
|
const [hitLayout] = useMyLocalStorageItem(StorageKey.HIT_LAYOUT, HitLayout.NORMAL);
|
|
45
47
|
const layout = useMemo(() => (isMobile ? HitLayout.COMFY : hitLayout), [hitLayout]);
|
|
46
48
|
// Search result list item renderer.
|
|
47
|
-
return (
|
|
49
|
+
return (_jsx(Box, { id: hit.howler.id, onAuxClick: e => checkMiddleClick(e, hit.howler.id), onClick: ev => onClick(ev, hit), sx: [
|
|
48
50
|
{
|
|
49
51
|
mb: 2,
|
|
50
52
|
cursor: 'pointer',
|
|
51
53
|
'& span,p,h6': {
|
|
52
54
|
cursor: 'text'
|
|
53
55
|
},
|
|
54
|
-
'&
|
|
56
|
+
'& .MuiPaper-root': {
|
|
55
57
|
border: '4px solid transparent',
|
|
56
58
|
boxShadow: `0px 0px 0px 0px transparent`,
|
|
57
59
|
transition: theme.transitions.create(['border-color', 'box-shadow'])
|
|
@@ -64,26 +66,34 @@ const Item = memo(({ record, onClick }) => {
|
|
|
64
66
|
paddingBottom: 'inherit' // prevents slight height variation on selected card.
|
|
65
67
|
}
|
|
66
68
|
},
|
|
67
|
-
|
|
68
|
-
'&
|
|
69
|
+
selectedHits.some(_hit => _hit.howler.id === hit.howler.id) && {
|
|
70
|
+
'& .MuiPaper-root': { borderColor: grey[500], boxShadow: `0px 0px 5px 2px ${grey[500]}` }
|
|
69
71
|
},
|
|
70
|
-
selected ===
|
|
71
|
-
'&
|
|
72
|
+
selected === hit.howler.id && {
|
|
73
|
+
'& .MuiPaper-root': {
|
|
72
74
|
borderColor: 'primary.main',
|
|
73
75
|
boxShadow: `0px 0px 5px 2px ${theme.palette.primary.main}`
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
|
-
], children:
|
|
78
|
+
], children: _jsx(HitCard, { id: hit.howler.id, layout: layout }) }));
|
|
77
79
|
});
|
|
78
80
|
const SearchPane = () => {
|
|
79
81
|
const { t } = useTranslation();
|
|
82
|
+
const location = useLocation();
|
|
83
|
+
const navigate = useNavigate();
|
|
84
|
+
const routeParams = useParams();
|
|
85
|
+
const selected = useContextSelector(ParameterContext, ctx => ctx.selected);
|
|
86
|
+
const setSelected = useContextSelector(ParameterContext, ctx => ctx.setSelected);
|
|
80
87
|
const query = useContextSelector(ParameterContext, ctx => ctx.query);
|
|
81
88
|
const setOffset = useContextSelector(ParameterContext, ctx => ctx.setOffset);
|
|
82
|
-
const triggerSearch = useContextSelector(
|
|
83
|
-
const searching = useContextSelector(
|
|
84
|
-
const response = useContextSelector(
|
|
85
|
-
const error = useContextSelector(
|
|
86
|
-
const { onClick } =
|
|
89
|
+
const triggerSearch = useContextSelector(HitSearchContext, ctx => ctx.search);
|
|
90
|
+
const searching = useContextSelector(HitSearchContext, ctx => ctx.searching);
|
|
91
|
+
const response = useContextSelector(HitSearchContext, ctx => ctx.response);
|
|
92
|
+
const error = useContextSelector(HitSearchContext, ctx => ctx.error);
|
|
93
|
+
const { onClick } = useHitSelection();
|
|
94
|
+
const getHit = useContextSelector(HitContext, ctx => ctx.getHit);
|
|
95
|
+
const clearSelectedHits = useContextSelector(HitContext, ctx => ctx.clearSelectedHits);
|
|
96
|
+
const bundleHit = useContextSelector(HitContext, ctx => location.pathname.startsWith('/bundles') ? ctx.hits[routeParams.id] : null);
|
|
87
97
|
const searchPaneWidth = useMyLocalStorageItem(StorageKey.SEARCH_PANE_WIDTH, null)[0];
|
|
88
98
|
const verticalSorters = useMediaQuery('(max-width: 1919px)') || (searchPaneWidth ?? Number.MAX_SAFE_INTEGER) < 900;
|
|
89
99
|
const getSelectedId = useCallback((event) => {
|
|
@@ -94,13 +104,26 @@ const SearchPane = () => {
|
|
|
94
104
|
}
|
|
95
105
|
return selectedElement.id;
|
|
96
106
|
}, []);
|
|
97
|
-
|
|
107
|
+
useEffect(() => {
|
|
108
|
+
if (location.pathname.startsWith('/bundles')) {
|
|
109
|
+
getHit(routeParams.id);
|
|
110
|
+
}
|
|
111
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
112
|
+
}, [location.pathname, routeParams.id]);
|
|
113
|
+
return (_jsx(FlexPort, { id: "hitscrollbar", children: _jsx(PageCenter, { textAlign: "left", mt: 0, mb: 6, ml: 0, mr: 0, maxWidth: "1500px", children: _jsxs(VSBox, { top: 0, children: [_jsxs(Stack, { ml: -1, mr: -1, sx: { '& .overflowingContentWidgets > *': { zIndex: '2000 !important' } }, spacing: 1, children: [bundleHit && (_jsx(BundleScroller, { children: _jsx(HitContextMenu, { getSelectedId: () => bundleHit.howler.id, children: _jsx(Stack, { spacing: 1, sx: { mx: -1 }, children: _jsx(HowlerCard, { sx: [
|
|
114
|
+
{ p: 1, border: '4px solid transparent', cursor: 'pointer' },
|
|
115
|
+
location.pathname.startsWith('/bundles') &&
|
|
116
|
+
selected === routeParams.id && { borderColor: 'primary.main' }
|
|
117
|
+
], onClick: () => {
|
|
118
|
+
clearSelectedHits(bundleHit.howler.id);
|
|
119
|
+
setSelected(bundleHit.howler.id);
|
|
120
|
+
}, children: _jsx(HitBanner, { hit: bundleHit, layout: HitLayout.DENSE, useListener: true }) }) }) }) })), _jsxs(Stack, { direction: "row", spacing: 1, alignItems: "center", children: [_jsx(Typography, { sx: { color: 'text.secondary', fontSize: '0.9em', fontStyle: 'italic', mb: 0.5 }, variant: "body2", children: t('hit.search.prompt') }), error && (_jsx(Tooltip, { title: `${t('route.advanced.error')}: ${error}`, children: _jsx(ErrorOutline, { fontSize: "small", color: "error" }) })), _jsx(FlexOne, {}), bundleHit?.howler.bundles.length > 0 && _jsx(BundleParentMenu, { bundle: bundleHit }), bundleHit && (_jsx(Tooltip, { title: t('hit.bundle.close'), children: _jsx(IconButton, { size: "small", onClick: () => navigate('/search'), children: _jsx(Close, {}) }) })), _jsx(Tooltip, { title: t('route.views.save'), children: _jsx(IconButton, { component: Link, disabled: !query, to: `/views/create?query=${query}`, children: _jsx(SavedSearch, {}) }) }), _jsx(Tooltip, { title: t('route.actions.save'), children: _jsx(IconButton, { component: Link, disabled: !query, to: `/action/execute?query=${query}`, children: _jsx(Terminal, {}) }) }), _jsx(LayoutSettings, {})] })] }), _jsxs(VSBoxHeader, { ml: -3, mr: -3, px: 2, pb: 1, sx: { zIndex: 989 }, children: [_jsxs(Stack, { sx: { pt: 1 }, children: [_jsxs(Stack, { sx: { position: 'relative', flex: 1 }, children: [_jsx(HitQuery, { searching: searching, triggerSearch: triggerSearch }), searching && (_jsx(LinearProgress, { sx: theme => ({
|
|
98
121
|
position: 'absolute',
|
|
99
122
|
left: 0,
|
|
100
123
|
right: 0,
|
|
101
124
|
bottom: 0,
|
|
102
125
|
borderBottomLeftRadius: theme.shape.borderRadius,
|
|
103
126
|
borderBottomRightRadius: theme.shape.borderRadius
|
|
104
|
-
}) }))] }), _jsx(QuerySettings, { verticalSorters: verticalSorters, boxSx: { position: 'relative', pt: 1.5 } })] }), response && (_jsxs(Stack, { direction: "row", alignItems: "center", sx: { pt: 1 }, children: [_jsx(SearchTotal, { total: response.total, pageLength: response.items.length, offset: response.offset, sx: theme => ({ color: theme.palette.text.secondary, fontSize: '0.9em', fontStyle: 'italic' }) }), _jsx(Box, { flex: 1 }), _jsx(SearchPagination, { total: response.total, limit: response.rows, offset: response.offset, onChange: nextOffset => setOffset(nextOffset) })] }))] }), _jsx(VSBoxContent, { mr: -1, ml: -1, mt: 1, children: _jsx(
|
|
127
|
+
}) }))] }), _jsx(QuerySettings, { verticalSorters: verticalSorters, boxSx: { position: 'relative', pt: 1.5 } })] }), response && (_jsxs(Stack, { direction: "row", alignItems: "center", sx: { pt: 1 }, children: [_jsx(SearchTotal, { total: response.total, pageLength: response.items.length, offset: response.offset, sx: theme => ({ color: theme.palette.text.secondary, fontSize: '0.9em', fontStyle: 'italic' }) }), _jsx(Box, { flex: 1 }), _jsx(SearchPagination, { total: response.total, limit: response.rows, offset: response.offset, onChange: nextOffset => setOffset(nextOffset) })] }))] }), _jsx(VSBoxContent, { mr: -1, ml: -1, mt: 1, children: _jsx(HitContextMenu, { getSelectedId: getSelectedId, children: !response ? (_jsx(AppListEmpty, {})) : (response.items.map(hit => _jsx(Item, { hit: hit, onClick: onClick }, hit.howler.id))) }) })] }) }) }));
|
|
105
128
|
};
|
|
106
129
|
export default memo(SearchPane);
|
|
@@ -2,8 +2,8 @@ import { createElement as _createElement } from "react";
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { ArrowDropDown, Delete, Edit, Language, Lock, OpenInNew, Person, Refresh, SavedSearch, SelectAll } from '@mui/icons-material';
|
|
4
4
|
import { Autocomplete, Chip, CircularProgress, IconButton, Stack, TextField, Tooltip, Typography } from '@mui/material';
|
|
5
|
+
import { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
|
|
5
6
|
import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
|
|
6
|
-
import { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
|
|
7
7
|
import { ViewContext } from '@cccsaurora/howler-ui/components/app/providers/ViewProvider';
|
|
8
8
|
import ChipPopper from '@cccsaurora/howler-ui/components/elements/display/ChipPopper';
|
|
9
9
|
import { memo, useEffect, useMemo, useState } from 'react';
|
|
@@ -20,7 +20,7 @@ const ViewLink = ({ id, viewId }) => {
|
|
|
20
20
|
const currentViews = useContextSelector(ParameterContext, ctx => ctx.views);
|
|
21
21
|
const removeView = useContextSelector(ParameterContext, ctx => ctx.removeView);
|
|
22
22
|
const setParamView = useContextSelector(ParameterContext, ctx => ctx.setView);
|
|
23
|
-
const search = useContextSelector(
|
|
23
|
+
const search = useContextSelector(HitSearchContext, ctx => ctx.search);
|
|
24
24
|
const [loading, setLoading] = useState(true);
|
|
25
25
|
const [view, setView] = useState(null);
|
|
26
26
|
useEffect(() => {
|
|
@@ -47,7 +47,7 @@ const ViewLink = ({ id, viewId }) => {
|
|
|
47
47
|
}, [query, sort, span, view]);
|
|
48
48
|
const options = useMemo(() => Object.values(views).filter(_view => !!_view && !currentViews?.includes(_view.view_id)), [currentViews, views]);
|
|
49
49
|
if (loading) {
|
|
50
|
-
return _jsx(Chip, { icon: _jsx(CircularProgress, { size: 12 }) });
|
|
50
|
+
return _jsx(Chip, { size: "small", icon: _jsx(CircularProgress, { size: 12 }) });
|
|
51
51
|
}
|
|
52
52
|
if (viewId === '') {
|
|
53
53
|
return (_jsx(ChipPopper, { icon: _jsx(SelectAll, {}), label: t('hit.search.view.select'), deleteIcon: _jsx(ArrowDropDown, {}), toggleOnDelete: true, slotProps: { chip: { size: 'small', color: 'warning' } }, children: _jsxs(Stack, { spacing: 1, direction: "row", children: [_jsx(Autocomplete, { fullWidth: true, size: "small", options: options, getOptionLabel: _view => t(_view.title), renderOption: ({ key, ...props }, o) => (_createElement("li", { ...props, key: key },
|
|
@@ -7,8 +7,8 @@ import { setupReactRouterMock } from '@cccsaurora/howler-ui/tests/mocks';
|
|
|
7
7
|
import { vi } from 'vitest';
|
|
8
8
|
setupReactRouterMock();
|
|
9
9
|
// Import component after mocks
|
|
10
|
+
import { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
|
|
10
11
|
import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
|
|
11
|
-
import { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
|
|
12
12
|
import { ViewContext } from '@cccsaurora/howler-ui/components/app/providers/ViewProvider';
|
|
13
13
|
import i18n from '@cccsaurora/howler-ui/i18n';
|
|
14
14
|
import { I18nextProvider } from 'react-i18next';
|
|
@@ -26,7 +26,7 @@ let mockParameterContext = {
|
|
|
26
26
|
removeView: vi.fn(),
|
|
27
27
|
setView: vi.fn()
|
|
28
28
|
};
|
|
29
|
-
let
|
|
29
|
+
let mockHitSearchContext = {
|
|
30
30
|
search: vi.fn()
|
|
31
31
|
};
|
|
32
32
|
let mockViewContext = {
|
|
@@ -38,7 +38,7 @@ let mockViewContext = {
|
|
|
38
38
|
};
|
|
39
39
|
// Test wrapper
|
|
40
40
|
const Wrapper = ({ children }) => {
|
|
41
|
-
return (_jsx(I18nextProvider, { i18n: i18n, children: _jsx(ParameterContext.Provider, { value: mockParameterContext, children: _jsx(
|
|
41
|
+
return (_jsx(I18nextProvider, { i18n: i18n, children: _jsx(ParameterContext.Provider, { value: mockParameterContext, children: _jsx(HitSearchContext.Provider, { value: mockHitSearchContext, children: _jsx(ViewContext.Provider, { value: mockViewContext, children: children }) }) }) }));
|
|
42
42
|
};
|
|
43
43
|
describe('ViewLink', () => {
|
|
44
44
|
let user;
|
|
@@ -52,7 +52,7 @@ describe('ViewLink', () => {
|
|
|
52
52
|
mockParameterContext.views = ['test-view-id'];
|
|
53
53
|
mockParameterContext.removeView = vi.fn();
|
|
54
54
|
mockParameterContext.setView = vi.fn();
|
|
55
|
-
|
|
55
|
+
mockHitSearchContext.search = vi.fn();
|
|
56
56
|
mockViewContext.getCurrentViews = vi.fn().mockResolvedValue([createMockView()]);
|
|
57
57
|
mockViewContext.views = {
|
|
58
58
|
'test-view-id': createMockView(),
|
|
@@ -230,7 +230,7 @@ describe('ViewLink', () => {
|
|
|
230
230
|
await user.click(screen.getByText('Test View').parentElement);
|
|
231
231
|
const refreshButton = await screen.findByLabelText(i18n.t('view.refresh'));
|
|
232
232
|
await user.click(refreshButton);
|
|
233
|
-
expect(
|
|
233
|
+
expect(mockHitSearchContext.search).toHaveBeenCalledWith('howler.id:*');
|
|
234
234
|
});
|
|
235
235
|
it('should display open button', async () => {
|
|
236
236
|
render(_jsx(ViewLink, { id: 0, viewId: "test-view-id" }), { wrapper: Wrapper });
|
|
@@ -306,7 +306,7 @@ describe('ViewLink', () => {
|
|
|
306
306
|
await user.click(screen.getByText('Test View').parentElement);
|
|
307
307
|
const refreshButton = await screen.findByLabelText(i18n.t('view.refresh'));
|
|
308
308
|
await user.click(refreshButton);
|
|
309
|
-
expect(
|
|
309
|
+
expect(mockHitSearchContext.search).toHaveBeenCalledWith(undefined);
|
|
310
310
|
});
|
|
311
311
|
it('should handle custom span correctly', async () => {
|
|
312
312
|
mockParameterContext.span = 'date.range.custom';
|
|
@@ -398,14 +398,14 @@ describe('ViewLink', () => {
|
|
|
398
398
|
expect(mockParameterContext.removeView).toHaveBeenCalledWith('test-view-id');
|
|
399
399
|
}
|
|
400
400
|
});
|
|
401
|
-
it('should use search from
|
|
401
|
+
it('should use search from HitSearchContext', async () => {
|
|
402
402
|
mockViewContext.getCurrentViews = vi.fn().mockResolvedValue([createMockView()]);
|
|
403
403
|
render(_jsx(ViewLink, { id: 0, viewId: "test-view-id" }), { wrapper: Wrapper });
|
|
404
404
|
await screen.findByText('Test View');
|
|
405
405
|
await user.click(screen.getByText('Test View').parentElement);
|
|
406
406
|
const refreshButton = await screen.findByLabelText(i18n.t('view.refresh'));
|
|
407
407
|
await user.click(refreshButton);
|
|
408
|
-
expect(
|
|
408
|
+
expect(mockHitSearchContext.search).toHaveBeenCalledWith('howler.id:*');
|
|
409
409
|
});
|
|
410
410
|
it('should filter available views using currentViews from ParameterContext', async () => {
|
|
411
411
|
mockParameterContext.views = ['test-view-id'];
|
|
@@ -3,24 +3,23 @@ import { Add, Check, Settings, TableChart } from '@mui/icons-material';
|
|
|
3
3
|
import { Autocomplete, Chip, Divider, Grid, IconButton, Stack, TextField } from '@mui/material';
|
|
4
4
|
import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
|
|
5
5
|
import { FieldContext } from '@cccsaurora/howler-ui/components/app/providers/FieldProvider';
|
|
6
|
-
import {
|
|
6
|
+
import { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
|
|
7
7
|
import ChipPopper from '@cccsaurora/howler-ui/components/elements/display/ChipPopper';
|
|
8
|
-
import { sortBy, uniq } from 'lodash-es';
|
|
8
|
+
import { has, sortBy, uniq } from 'lodash-es';
|
|
9
9
|
import { memo, useContext, useEffect, useMemo, useState } from 'react';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import { useContextSelector } from 'use-context-selector';
|
|
12
|
-
import { isHit } from '@cccsaurora/howler-ui/utils/typeUtils';
|
|
13
12
|
const AddColumnModal = ({ addColumn, columns }) => {
|
|
14
13
|
const { t } = useTranslation();
|
|
15
14
|
const { hitFields } = useContext(FieldContext);
|
|
16
|
-
const response = useContextSelector(
|
|
15
|
+
const response = useContextSelector(HitSearchContext, ctx => ctx.response);
|
|
17
16
|
const { getMatchingTemplate } = useMatchers();
|
|
18
17
|
const [columnToAdd, setColumnToAdd] = useState(null);
|
|
19
18
|
const options = useMemo(() => hitFields.map(field => field.key), [hitFields]);
|
|
20
19
|
const [suggestions, setSuggestions] = useState([]);
|
|
21
20
|
useEffect(() => {
|
|
22
21
|
(async () => {
|
|
23
|
-
setSuggestions(uniq((await Promise.all((response?.items ?? []).
|
|
22
|
+
setSuggestions(uniq((await Promise.all((response?.items ?? []).map(async (_hit) => (has(_hit, '__template') ? _hit.__template?.keys : (await getMatchingTemplate(_hit))?.keys) ?? []))).flat()));
|
|
24
23
|
})();
|
|
25
24
|
}, [getMatchingTemplate, response?.items]);
|
|
26
25
|
return (_jsx(ChipPopper, { icon: _jsx(TableChart, {}), deleteIcon: _jsx(Settings, {}), toggleOnDelete: true, slotProps: { chip: { size: 'small' } }, children: _jsxs(Stack, { spacing: 1, p: 1, width: "500px", children: [_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsx(Autocomplete, { sx: { flex: 1 }, size: "small", options: options, value: columnToAdd, renderInput: params => _jsx(TextField, { fullWidth: true, placeholder: t('hit.fields'), ...params }), onChange: (_ev, value) => setColumnToAdd(value) }), _jsx(IconButton, { disabled: !columnToAdd, onClick: () => {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type SxProps } from '@mui/material';
|
|
2
2
|
import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
|
|
3
|
-
import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
|
|
4
3
|
declare const _default: import("react").NamedExoticComponent<{
|
|
5
|
-
|
|
4
|
+
hit: Hit;
|
|
6
5
|
value: string;
|
|
7
6
|
sx?: SxProps;
|
|
8
7
|
className: string;
|
|
@@ -4,7 +4,7 @@ import { Stack, TableCell } from '@mui/material';
|
|
|
4
4
|
import PluginTypography from '@cccsaurora/howler-ui/components/elements/PluginTypography';
|
|
5
5
|
import { memo } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
|
-
const EnhancedCell = ({
|
|
7
|
+
const EnhancedCell = ({ hit, value: rawValue, sx = {}, className, field }) => {
|
|
8
8
|
const { t } = useTranslation();
|
|
9
9
|
if (!rawValue) {
|
|
10
10
|
return _jsx(TableCell, { style: { borderBottom: 'none' }, children: t('none') });
|
|
@@ -13,6 +13,6 @@ const EnhancedCell = ({ record, value: rawValue, sx = {}, className, field }) =>
|
|
|
13
13
|
return (_jsx(TableCell, { sx: { borderBottom: 'none', borderRight: 'thin solid', borderRightColor: 'divider', fontSize: '0.8rem' }, children: _jsx(Stack, { direction: "row", className: className, spacing: 0.5, sx: [
|
|
14
14
|
{ display: 'flex', justifyContent: 'start', width: '100%', overflow: 'hidden' },
|
|
15
15
|
...(Array.isArray(sx) ? sx : [sx])
|
|
16
|
-
], children: values.map((value, index) => (_jsx(PluginTypography, { context: "table", sx: { fontSize: 'inherit', textOverflow: 'ellipsis' }, value: value, field: field,
|
|
16
|
+
], children: values.map((value, index) => (_jsx(PluginTypography, { context: "table", sx: { fontSize: 'inherit', textOverflow: 'ellipsis' }, value: value, field: field, hit: hit, children: value }, value + index))) }) }));
|
|
17
17
|
};
|
|
18
18
|
export default memo(EnhancedCell);
|
|
@@ -4,37 +4,36 @@ import { arrayMove, SortableContext, sortableKeyboardCoordinates } from '@dnd-ki
|
|
|
4
4
|
import { FormatIndentDecrease, FormatIndentIncrease, Info, List, Search, TableChart } from '@mui/icons-material';
|
|
5
5
|
import { IconButton, LinearProgress, Paper, Stack, Table, TableBody, TableCell, TableHead, TableRow, ToggleButton, ToggleButtonGroup, Typography, useTheme } from '@mui/material';
|
|
6
6
|
import useMatchers from '@cccsaurora/howler-ui/components/app/hooks/useMatchers';
|
|
7
|
+
import { HitContext } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
|
|
8
|
+
import { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
|
|
7
9
|
import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
|
|
8
|
-
import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
|
|
9
|
-
import { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
|
|
10
10
|
import SearchTotal from '@cccsaurora/howler-ui/components/elements/addons/search/SearchTotal';
|
|
11
11
|
import DevelopmentBanner from '@cccsaurora/howler-ui/components/elements/display/features/DevelopmentBanner';
|
|
12
|
-
import
|
|
12
|
+
import useHitSelection from '@cccsaurora/howler-ui/components/hooks/useHitSelection';
|
|
13
13
|
import { useMyLocalStorageItem } from '@cccsaurora/howler-ui/components/hooks/useMyLocalStorage';
|
|
14
|
-
import useRecordSelection from '@cccsaurora/howler-ui/components/hooks/useRecordSelection';
|
|
15
14
|
import { uniq } from 'lodash-es';
|
|
16
15
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
17
16
|
import { useTranslation } from 'react-i18next';
|
|
18
17
|
import { useContextSelector } from 'use-context-selector';
|
|
19
18
|
import { StorageKey } from '@cccsaurora/howler-ui/utils/constants';
|
|
20
|
-
import
|
|
19
|
+
import HitContextMenu from '../HitContextMenu';
|
|
20
|
+
import HitQuery from '../HitQuery';
|
|
21
21
|
import QuerySettings from '../QuerySettings';
|
|
22
|
-
import RecordQuery from '../RecordQuery';
|
|
23
22
|
import AddColumnModal from './AddColumnModal';
|
|
24
23
|
import ColumnHeader from './ColumnHeader';
|
|
25
|
-
import
|
|
24
|
+
import HitRow from './HitRow';
|
|
26
25
|
const HitGrid = () => {
|
|
27
26
|
const { t } = useTranslation();
|
|
28
27
|
const theme = useTheme();
|
|
29
28
|
const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor, { coordinateGetter: sortableKeyboardCoordinates }));
|
|
30
|
-
const { onClick } =
|
|
29
|
+
const { onClick } = useHitSelection();
|
|
31
30
|
const { getMatchingAnalytic } = useMatchers();
|
|
32
|
-
const search = useContextSelector(
|
|
33
|
-
const displayType = useContextSelector(
|
|
34
|
-
const setDisplayType = useContextSelector(
|
|
35
|
-
const response = useContextSelector(
|
|
36
|
-
const searching = useContextSelector(
|
|
37
|
-
const selectedHits = useContextSelector(
|
|
31
|
+
const search = useContextSelector(HitSearchContext, ctx => ctx.search);
|
|
32
|
+
const displayType = useContextSelector(HitSearchContext, ctx => ctx.displayType);
|
|
33
|
+
const setDisplayType = useContextSelector(HitSearchContext, ctx => ctx.setDisplayType);
|
|
34
|
+
const response = useContextSelector(HitSearchContext, ctx => ctx.response);
|
|
35
|
+
const searching = useContextSelector(HitSearchContext, ctx => ctx.searching);
|
|
36
|
+
const selectedHits = useContextSelector(HitContext, ctx => ctx.selectedHits);
|
|
38
37
|
const query = useContextSelector(ParameterContext, ctx => ctx.query);
|
|
39
38
|
const selected = useContextSelector(ParameterContext, ctx => ctx.selected);
|
|
40
39
|
const [collapseMainColumn, setCollapseMainColumn] = useMyLocalStorageItem(StorageKey.GRID_COLLAPSE_COLUMN, false);
|
|
@@ -57,11 +56,10 @@ const HitGrid = () => {
|
|
|
57
56
|
return false;
|
|
58
57
|
}, [selected, selectedHits]);
|
|
59
58
|
useEffect(() => {
|
|
60
|
-
response?.items.forEach(
|
|
61
|
-
if (!
|
|
62
|
-
|
|
59
|
+
response?.items.forEach(hit => {
|
|
60
|
+
if (!analyticIds[hit.howler.analytic]) {
|
|
61
|
+
getMatchingAnalytic(hit).then(_analytic => setAnalyticIds(_analyticIds => ({ ..._analyticIds, [hit.howler.analytic]: _analytic.analytic_id })));
|
|
63
62
|
}
|
|
64
|
-
getMatchingAnalytic(record).then(_analytic => setAnalyticIds(_analyticIds => ({ ..._analyticIds, [record.howler.analytic]: _analytic.analytic_id })));
|
|
65
63
|
});
|
|
66
64
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
65
|
}, [analyticIds, response]);
|
|
@@ -119,7 +117,7 @@ const HitGrid = () => {
|
|
|
119
117
|
}
|
|
120
118
|
return selectedElement.id;
|
|
121
119
|
}, []);
|
|
122
|
-
return (_jsxs(Stack, { spacing: 1, p: 2, width: "100%", sx: { overflow: 'hidden', height: `calc(100vh - ${theme.spacing(showSelectBar ? 13 : 8)})` }, children: [_jsx(DevelopmentBanner, {}), _jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [_jsx(Typography, { sx: { color: 'text.secondary', fontSize: '0.9em', fontStyle: 'italic', mb: 0.5, textAlign: 'left' }, variant: "body2", children: t('hit.search.prompt') }), response && (_jsx(SearchTotal, { sx: { color: 'text.secondary', fontSize: '0.9em', fontStyle: 'italic', mb: 0.5 }, variant: "body2", offset: response.offset, pageLength: response.rows, total: response.total }))] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Stack, { position: "relative", flex: 1, children: [_jsx(
|
|
120
|
+
return (_jsxs(Stack, { spacing: 1, p: 2, width: "100%", sx: { overflow: 'hidden', height: `calc(100vh - ${theme.spacing(showSelectBar ? 13 : 8)})` }, children: [_jsx(DevelopmentBanner, {}), _jsxs(Stack, { direction: "row", justifyContent: "space-between", children: [_jsx(Typography, { sx: { color: 'text.secondary', fontSize: '0.9em', fontStyle: 'italic', mb: 0.5, textAlign: 'left' }, variant: "body2", children: t('hit.search.prompt') }), response && (_jsx(SearchTotal, { sx: { color: 'text.secondary', fontSize: '0.9em', fontStyle: 'italic', mb: 0.5 }, variant: "body2", offset: response.offset, pageLength: response.rows, total: response.total }))] }), _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Stack, { position: "relative", flex: 1, children: [_jsx(HitQuery, { searching: searching, triggerSearch: search, compact: true }), searching && (_jsx(LinearProgress, { sx: {
|
|
123
121
|
position: 'absolute',
|
|
124
122
|
left: 0,
|
|
125
123
|
right: 0,
|
|
@@ -129,6 +127,6 @@ const HitGrid = () => {
|
|
|
129
127
|
} }))] }), _jsxs(ToggleButtonGroup, { exclusive: true, value: displayType, onChange: (__, value) => setDisplayType(value), size: "small", children: [_jsx(ToggleButton, { value: "list", children: _jsx(List, {}) }), _jsx(ToggleButton, { value: "grid", children: _jsx(TableChart, {}) })] })] }), _jsxs(Stack, { direction: "row", spacing: 1, width: "100%", alignItems: "center", children: [_jsx(QuerySettings, { boxSx: { flex: 1 } }), _jsx(AddColumnModal, { columns: columns, addColumn: key => setColumns(uniq([...columns, key])) })] }), _jsxs(Stack, { component: Paper, spacing: 1, width: "100%", height: "100%", sx: { overflow: 'auto', flex: 1 }, onScroll: onScroll, children: [_jsxs(Table, { sx: { '& td,th': { px: 1, py: 0.25, whiteSpace: 'nowrap' } }, children: [_jsx(TableHead, { children: _jsxs(TableRow, { children: [_jsx(TableCell, { sx: {
|
|
130
128
|
borderRight: 'thin solid',
|
|
131
129
|
borderRightColor: 'divider'
|
|
132
|
-
}, children: _jsx(IconButton, { onClick: () => setCollapseMainColumn(!collapseMainColumn), children: collapseMainColumn ? (_jsx(FormatIndentIncrease, { fontSize: "small" })) : (_jsx(FormatIndentDecrease, { fontSize: "small" })) }) }), _jsx(DndContext, { sensors: sensors, collisionDetection: pointerWithin, onDragEnd: handleDragEnd, children: _jsx(SortableContext, { items: columns, children: columns.map(col => (_jsx(ColumnHeader, { col: col, width: columnWidths[col], onMouseDown: onMouseDown, setColumns: setColumns }, col))) }) }), _jsx(TableCell, { sx: { width: '100%' } })] }) }), _jsxs(
|
|
130
|
+
}, children: _jsx(IconButton, { onClick: () => setCollapseMainColumn(!collapseMainColumn), children: collapseMainColumn ? (_jsx(FormatIndentIncrease, { fontSize: "small" })) : (_jsx(FormatIndentDecrease, { fontSize: "small" })) }) }), _jsx(DndContext, { sensors: sensors, collisionDetection: pointerWithin, onDragEnd: handleDragEnd, children: _jsx(SortableContext, { items: columns, children: columns.map(col => (_jsx(ColumnHeader, { col: col, width: columnWidths[col], onMouseDown: onMouseDown, setColumns: setColumns }, col))) }) }), _jsx(TableCell, { sx: { width: '100%' } })] }) }), _jsxs(HitContextMenu, { Component: TableBody, getSelectedId: getSelectedId, children: [response?.items.map(hit => (_jsx(HitRow, { hit: hit, analyticIds: analyticIds, columns: columns, columnWidths: columnWidths, collapseMainColumn: collapseMainColumn, onClick: onClick }, hit.howler.id))), _jsx(TableRow, { children: _jsx(TableCell, { colSpan: columns.length + 2, children: _jsx(Stack, { alignItems: "center", justifyContent: "center", py: 0.5, px: 1, children: _jsx(IconButton, { onClick: () => search(query, true), children: _jsx(Search, {}) }) }) }) })] })] }), (response?.total ?? 0) < 1 && (_jsx(Stack, { direction: "row", spacing: 1, alignItems: "center", p: 1, justifyContent: "center", flex: 1, children: _jsxs(Typography, { variant: "h3", color: "text.secondary", display: "flex", flexDirection: "row", alignItems: "center", children: [_jsx(Info, { fontSize: "inherit", sx: { color: 'text.secondary', mr: 1 } }), _jsx("span", { children: t('app.list.empty') })] }) }))] })] }));
|
|
133
131
|
};
|
|
134
132
|
export default HitGrid;
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { Hit } from '@cccsaurora/howler-ui/models/entities/generated/Hit';
|
|
2
|
-
import type { Observable } from '@cccsaurora/howler-ui/models/entities/generated/Observable';
|
|
3
2
|
declare const _default: import("react").NamedExoticComponent<{
|
|
4
|
-
|
|
3
|
+
hit: Hit;
|
|
5
4
|
analyticIds: Record<string, string>;
|
|
6
5
|
columns: string[];
|
|
7
6
|
columnWidths: Record<string, string>;
|
|
8
7
|
collapseMainColumn: boolean;
|
|
9
|
-
onClick: (e: React.MouseEvent<HTMLDivElement>,
|
|
8
|
+
onClick: (e: React.MouseEvent<HTMLDivElement>, hit: Hit) => void;
|
|
10
9
|
}>;
|
|
11
10
|
export default _default;
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { KeyboardArrowUp } from '@mui/icons-material';
|
|
3
3
|
import { Box, Collapse, IconButton, lighten, Stack, TableCell, TableRow, Typography, useTheme } from '@mui/material';
|
|
4
|
+
import { HitContext } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
|
|
4
5
|
import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
|
|
5
|
-
import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
|
|
6
6
|
import Assigned from '@cccsaurora/howler-ui/components/elements/hit/elements/Assigned';
|
|
7
7
|
import EscalationChip from '@cccsaurora/howler-ui/components/elements/hit/elements/EscalationChip';
|
|
8
8
|
import HitCard from '@cccsaurora/howler-ui/components/elements/hit/HitCard';
|
|
9
9
|
import { HitLayout } from '@cccsaurora/howler-ui/components/elements/hit/HitLayout';
|
|
10
|
-
import ObservableCard from '@cccsaurora/howler-ui/components/elements/observable/ObservableCard';
|
|
11
10
|
import { get } from 'lodash-es';
|
|
12
11
|
import { memo, useState } from 'react';
|
|
13
12
|
import { useTranslation } from 'react-i18next';
|
|
14
13
|
import { Link } from 'react-router-dom';
|
|
15
14
|
import { useContextSelector } from 'use-context-selector';
|
|
16
|
-
import { isHit } from '@cccsaurora/howler-ui/utils/typeUtils';
|
|
17
15
|
import EnhancedCell from './EnhancedCell';
|
|
18
|
-
const
|
|
16
|
+
const HitRow = ({ hit, analyticIds, columns, columnWidths, collapseMainColumn, onClick }) => {
|
|
19
17
|
const theme = useTheme();
|
|
20
18
|
const { t } = useTranslation();
|
|
21
|
-
const selectedHits = useContextSelector(
|
|
19
|
+
const selectedHits = useContextSelector(HitContext, ctx => ctx.selectedHits);
|
|
22
20
|
const selected = useContextSelector(ParameterContext, ctx => ctx.selected);
|
|
23
21
|
const [expandRow, setExpandRow] = useState(false);
|
|
24
|
-
return (_jsxs(_Fragment, { children: [_jsxs(TableRow, { id:
|
|
22
|
+
return (_jsxs(_Fragment, { children: [_jsxs(TableRow, { id: hit.howler.id, onClick: ev => onClick(ev, hit), sx: [
|
|
25
23
|
{
|
|
26
24
|
transition: theme.transitions.create('background-color'),
|
|
27
25
|
'&:hover': {
|
|
@@ -29,10 +27,10 @@ const RecordRow = ({ record, analyticIds, columns, columnWidths, collapseMainCol
|
|
|
29
27
|
backgroundColor: theme.palette.background.paper
|
|
30
28
|
}
|
|
31
29
|
},
|
|
32
|
-
selectedHits.some(_hit => _hit.howler.id ===
|
|
30
|
+
selectedHits.some(_hit => _hit.howler.id === hit.howler.id) && {
|
|
33
31
|
backgroundColor: lighten(theme.palette.background.paper, 0.15)
|
|
34
32
|
},
|
|
35
|
-
selected ===
|
|
33
|
+
selected === hit.howler.id && {
|
|
36
34
|
backgroundColor: lighten(theme.palette.background.paper, 0.25)
|
|
37
35
|
}
|
|
38
36
|
], children: [_jsx(TableCell, { sx: {
|
|
@@ -47,6 +45,6 @@ const RecordRow = ({ record, analyticIds, columns, columnWidths, collapseMainCol
|
|
|
47
45
|
e.preventDefault();
|
|
48
46
|
e.stopPropagation();
|
|
49
47
|
setExpandRow(_expanded => !_expanded);
|
|
50
|
-
}, children: _jsx(KeyboardArrowUp, {}) }), _jsx(Collapse, { in: !collapseMainColumn, orientation: "horizontal", unmountOnExit: true, children: _jsxs(Stack, { direction: "row", spacing: 1, flexWrap: "nowrap", children: [
|
|
48
|
+
}, children: _jsx(KeyboardArrowUp, {}) }), _jsx(Collapse, { in: !collapseMainColumn, orientation: "horizontal", unmountOnExit: true, children: _jsxs(Stack, { direction: "row", spacing: 1, flexWrap: "nowrap", children: [_jsx(EscalationChip, { hit: hit, layout: HitLayout.DENSE, hideLabel: true }), _jsxs(Typography, { sx: { textWrap: 'nowrap', whiteSpace: 'nowrap', fontSize: 'inherit' }, children: [analyticIds[hit.howler.analytic] ? (_jsx(Link, { to: `/analytics/${analyticIds[hit.howler.analytic]}`, onClick: e => e.stopPropagation(), children: hit.howler.analytic })) : (hit.howler.analytic), hit.howler.detection && ': ', hit.howler.detection] }), hit.howler.assignment !== 'unassigned' && _jsx(Assigned, { hit: hit, layout: HitLayout.DENSE, hideLabel: true })] }) })] }) }), columns.map(col => (_jsx(EnhancedCell, { hit: hit, className: `col-${col.replaceAll('.', '-')}`, value: get(hit, col) ?? t('none'), sx: columnWidths[col] ? { width: columnWidths[col] } : { width: '220px', maxWidth: '300px' }, field: col }, col)))] }, hit.howler.id), _jsx(TableRow, { onClick: ev => onClick(ev, hit), children: _jsx(TableCell, { colSpan: columns.length + 2, style: { paddingBottom: 0, paddingTop: 0 }, children: _jsx(Collapse, { in: expandRow, unmountOnExit: true, children: _jsx(Box, { width: "100%", maxWidth: "1200px", margin: 1, children: _jsx(HitCard, { id: hit.howler.id, layout: HitLayout.NORMAL }) }) }) }) })] }));
|
|
51
49
|
};
|
|
52
|
-
export default memo(
|
|
50
|
+
export default memo(HitRow);
|