@cccsaurora/howler-ui 2.18.0-dev.648 → 2.18.0-dev.674
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 +2 -0
- package/api/index.js +4 -2
- package/api/search/case.d.ts +4 -0
- package/api/search/case.js +8 -0
- package/api/search/index.d.ts +2 -1
- package/api/search/index.js +2 -1
- package/api/v2/case/index.d.ts +6 -0
- package/api/v2/case/index.js +18 -0
- package/api/v2/index.d.ts +4 -0
- package/api/v2/index.js +6 -0
- package/api/v2/search/facet.d.ts +3 -0
- package/api/v2/search/facet.js +12 -0
- package/api/v2/search/index.d.ts +5 -0
- package/api/v2/search/index.js +24 -0
- package/commons/components/leftnav/LeftNavDrawer.js +1 -1
- package/components/app/App.js +34 -7
- 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/ParameterProvider.d.ts +9 -2
- package/components/app/providers/ParameterProvider.js +165 -240
- package/components/app/providers/ParameterProvider.test.js +307 -14
- package/components/app/providers/RecordProvider.d.ts +23 -0
- package/components/app/providers/{HitProvider.js → RecordProvider.js} +41 -41
- package/components/app/providers/{HitSearchProvider.d.ts → RecordSearchProvider.d.ts} +6 -6
- package/components/app/providers/{HitSearchProvider.js → RecordSearchProvider.js} +12 -17
- package/components/app/providers/{HitSearchProvider.test.js → RecordSearchProvider.test.js} +51 -70
- package/components/elements/ContextMenu.d.ts +56 -0
- package/components/elements/ContextMenu.js +109 -0
- package/components/elements/ContextMenu.test.js +215 -0
- package/components/{routes/overviews/OverviewEditor.js → elements/MarkdownEditor.js} +3 -3
- package/components/elements/ObjectDetails.d.ts +6 -0
- package/components/elements/{hit/HitDetails.js → ObjectDetails.js} +17 -17
- package/components/elements/PluginTypography.d.ts +2 -1
- package/components/elements/PluginTypography.js +3 -2
- package/components/elements/UserList.d.ts +5 -2
- package/components/elements/UserList.js +14 -5
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/case/CaseCard.d.ts +8 -0
- package/components/elements/case/CaseCard.js +39 -0
- package/components/elements/case/CasePreview.d.ts +6 -0
- package/components/elements/case/CasePreview.js +17 -0
- package/components/elements/case/StatusIcon.d.ts +5 -0
- package/components/elements/case/StatusIcon.js +13 -0
- package/components/elements/display/ChipPopper.d.ts +1 -1
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +1 -0
- package/components/elements/hit/HitActions.js +4 -4
- package/components/elements/hit/HitBanner.js +28 -48
- package/components/elements/hit/HitCard.js +5 -5
- package/components/elements/hit/HitLabels.js +2 -2
- package/components/elements/hit/{HitQuickSearch.d.ts → HitPreview.d.ts} +3 -3
- package/components/elements/hit/{HitQuickSearch.js → HitPreview.js} +10 -4
- package/components/elements/hit/HitSummary.d.ts +2 -1
- package/components/elements/hit/HitSummary.js +6 -5
- package/components/elements/hit/aggregate/HitGraph.js +8 -8
- package/components/elements/hit/elements/AnalyticLink.d.ts +8 -0
- package/components/elements/hit/elements/AnalyticLink.js +22 -0
- package/components/elements/hit/outlines/DefaultOutline.js +1 -1
- package/components/elements/hit/related/RelatedRecords.js +63 -0
- package/components/elements/observable/ObservableCard.d.ts +6 -0
- package/components/elements/observable/ObservableCard.js +23 -0
- package/components/elements/observable/ObservablePreview.d.ts +6 -0
- package/components/elements/observable/ObservablePreview.js +12 -0
- package/components/elements/{hit/HitComments.d.ts → record/RecordComments.d.ts} +5 -4
- package/components/elements/{hit/HitComments.js → record/RecordComments.js} +29 -28
- package/components/{routes/hits/search/HitContextMenu.d.ts → elements/record/RecordContextMenu.d.ts} +3 -3
- package/components/elements/record/RecordContextMenu.js +235 -0
- package/components/elements/record/RecordContextMenu.test.d.ts +1 -0
- package/components/{routes/hits/search/HitContextMenu.test.js → elements/record/RecordContextMenu.test.js} +39 -39
- package/components/elements/record/RecordRelated.d.ts +7 -0
- package/components/elements/record/RecordRelated.js +34 -0
- package/components/elements/{hit/HitWorklog.d.ts → record/RecordWorklog.d.ts} +4 -3
- package/components/elements/{hit/HitWorklog.js → record/RecordWorklog.js} +15 -13
- 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/useLocalStorage.test.d.ts +1 -0
- package/components/hooks/useLocalStorage.test.js +137 -0
- package/components/hooks/useMyPreferences.js +10 -1
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +4 -1
- package/components/hooks/useMyTheme.js +9 -2
- package/components/hooks/useParamState.d.ts +6 -0
- package/components/hooks/useParamState.js +48 -0
- package/components/hooks/useParamState.test.d.ts +1 -0
- package/components/hooks/useParamState.test.js +166 -0
- package/components/hooks/{useHitSelection.d.ts → useRecordSelection.d.ts} +2 -2
- package/components/hooks/{useHitSelection.js → useRecordSelection.js} +12 -33
- package/components/hooks/useRelatedRecords.d.ts +13 -0
- package/components/hooks/useRelatedRecords.js +32 -0
- 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/cases/CaseViewer.d.ts +2 -0
- package/components/routes/cases/CaseViewer.js +22 -0
- package/components/routes/cases/Cases.d.ts +2 -0
- package/components/routes/cases/Cases.js +101 -0
- package/components/routes/cases/constants.d.ts +5 -0
- package/components/routes/cases/constants.js +5 -0
- package/components/routes/cases/detail/AlertPanel.d.ts +6 -0
- package/components/routes/cases/detail/AlertPanel.js +33 -0
- package/components/routes/cases/detail/CaseAssets.d.ts +12 -0
- package/components/routes/cases/detail/CaseAssets.js +101 -0
- package/components/routes/cases/detail/CaseAssets.test.d.ts +1 -0
- package/components/routes/cases/detail/CaseAssets.test.js +163 -0
- package/components/routes/cases/detail/CaseDashboard.d.ts +7 -0
- package/components/routes/cases/detail/CaseDashboard.js +51 -0
- package/components/routes/cases/detail/CaseDetails.d.ts +6 -0
- package/components/routes/cases/detail/CaseDetails.js +61 -0
- package/components/routes/cases/detail/CaseOverview.d.ts +7 -0
- package/components/routes/cases/detail/CaseOverview.js +43 -0
- package/components/routes/cases/detail/CaseSidebar.d.ts +6 -0
- package/components/routes/cases/detail/CaseSidebar.js +61 -0
- package/components/routes/cases/detail/CaseTask.d.ts +11 -0
- package/components/routes/cases/detail/CaseTask.js +57 -0
- package/components/routes/cases/detail/ItemPage.d.ts +6 -0
- package/components/routes/cases/detail/ItemPage.js +99 -0
- package/components/routes/cases/detail/RelatedCasePanel.d.ts +6 -0
- package/components/routes/cases/detail/RelatedCasePanel.js +31 -0
- package/components/routes/cases/detail/TaskPanel.d.ts +7 -0
- package/components/routes/cases/detail/TaskPanel.js +52 -0
- package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +12 -0
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +19 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +6 -0
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +27 -0
- package/components/routes/cases/detail/assets/Asset.d.ts +14 -0
- package/components/routes/cases/detail/assets/Asset.js +12 -0
- package/components/routes/cases/detail/assets/Asset.test.d.ts +1 -0
- package/components/routes/cases/detail/assets/Asset.test.js +72 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +13 -0
- package/components/routes/cases/detail/sidebar/CaseFolder.js +131 -0
- package/components/routes/cases/detail/sidebar/types.d.ts +3 -0
- package/components/routes/cases/detail/sidebar/utils.d.ts +3 -0
- package/components/routes/cases/detail/sidebar/utils.js +25 -0
- package/components/routes/cases/hooks/useCase.d.ts +13 -0
- package/components/routes/cases/hooks/useCase.js +38 -0
- package/components/routes/cases/modals/ResolveModal.d.ts +7 -0
- package/components/routes/cases/modals/ResolveModal.js +59 -0
- 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/HitBannerDocumentation.js +1 -0
- package/components/routes/help/HitDocumentation.js +1 -3
- package/components/routes/hits/search/InformationPane.d.ts +1 -0
- package/components/routes/hits/search/InformationPane.js +47 -60
- package/components/routes/hits/search/LayoutSettings.js +3 -3
- package/components/routes/hits/search/QuerySettings.js +2 -1
- package/components/routes/hits/search/QuerySettings.test.js +14 -9
- package/components/routes/hits/search/{HitBrowser.js → RecordBrowser.js} +9 -9
- package/components/routes/hits/search/{HitQuery.d.ts → RecordQuery.d.ts} +2 -2
- package/components/routes/hits/search/{HitQuery.js → RecordQuery.js} +6 -6
- package/components/routes/hits/search/SearchPane.js +26 -49
- 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 +5 -4
- package/components/routes/hits/search/grid/EnhancedCell.d.ts +2 -1
- package/components/routes/hits/search/grid/EnhancedCell.js +2 -2
- package/components/routes/hits/search/grid/HitGrid.js +20 -18
- package/components/routes/hits/search/grid/{HitRow.d.ts → RecordRow.d.ts} +3 -2
- package/components/routes/hits/search/grid/{HitRow.js → RecordRow.js} +10 -8
- package/components/routes/hits/search/shared/IndexPicker.d.ts +2 -0
- package/components/routes/hits/search/shared/IndexPicker.js +20 -0
- package/components/routes/hits/view/HitViewer.js +12 -13
- package/components/routes/home/ViewCard.js +4 -4
- package/components/routes/observables/ObservableViewer.d.ts +7 -0
- package/components/routes/observables/ObservableViewer.js +27 -0
- package/components/routes/overviews/OverviewViewer.js +2 -2
- package/components/routes/views/ViewComposer.js +4 -4
- package/locales/en/translation.json +65 -3
- package/locales/fr/translation.json +63 -3
- package/models/WithMetadata.d.ts +2 -1
- package/models/entities/generated/AttachmentsFile.d.ts +12 -0
- package/models/entities/generated/Case.d.ts +28 -0
- package/models/entities/generated/DestinationOriginal.d.ts +19 -0
- package/models/entities/generated/EmailAttachment.d.ts +8 -0
- package/models/entities/generated/EmailParent.d.ts +19 -0
- package/models/entities/generated/Enrichments.d.ts +7 -0
- package/models/entities/generated/EnrichmentsIndicator.d.ts +21 -0
- package/models/entities/generated/Hit.d.ts +1 -0
- package/models/entities/generated/Howler.d.ts +0 -4
- package/models/entities/generated/HttpResponse.d.ts +11 -0
- package/models/entities/generated/Item.d.ts +9 -0
- package/models/entities/generated/Observable.d.ts +85 -0
- package/models/entities/generated/ObservableCloud.d.ts +20 -0
- package/models/entities/generated/ObservableDestination.d.ts +23 -0
- package/models/entities/generated/ObservableEmail.d.ts +30 -0
- package/models/entities/generated/ObservableFile.d.ts +36 -0
- package/models/entities/generated/ObservableHowler.d.ts +43 -0
- package/models/entities/generated/ObservableHttp.d.ts +11 -0
- package/models/entities/generated/ObservableObserver.d.ts +21 -0
- package/models/entities/generated/ObservableOrganization.d.ts +7 -0
- package/models/entities/generated/ObservableProcess.d.ts +34 -0
- package/models/entities/generated/ObservableSource.d.ts +23 -0
- package/models/entities/generated/ObservableThreat.d.ts +21 -0
- package/models/entities/generated/ObservableTls.d.ts +12 -0
- package/models/entities/generated/ObserverIngress.d.ts +9 -0
- package/models/entities/generated/Rule.d.ts +2 -10
- package/models/entities/generated/Task.d.ts +10 -0
- package/models/entities/generated/Threat.d.ts +2 -2
- package/models/entities/generated/{Enrichment.d.ts → ThreatEnrichment.d.ts} +1 -1
- package/package.json +18 -1
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +2 -1
- package/tests/utils.d.ts +2 -0
- package/tests/utils.js +8 -0
- package/utils/constants.d.ts +3 -3
- package/utils/hitFunctions.d.ts +2 -1
- package/utils/hitFunctions.js +4 -4
- package/utils/typeUtils.d.ts +7 -0
- package/utils/typeUtils.js +27 -0
- package/components/app/providers/HitProvider.d.ts +0 -22
- package/components/elements/display/icons/BundleButton.d.ts +0 -6
- package/components/elements/display/icons/BundleButton.js +0 -32
- package/components/elements/hit/HitRelated.d.ts +0 -6
- package/components/elements/hit/HitRelated.js +0 -7
- package/components/routes/help/BundleDocumentation.d.ts +0 -3
- package/components/routes/help/BundleDocumentation.js +0 -12
- package/components/routes/help/markdown/en/bundles.md.js +0 -1
- package/components/routes/help/markdown/fr/bundles.md.js +0 -1
- package/components/routes/hits/search/BundleParentMenu.d.ts +0 -6
- package/components/routes/hits/search/BundleParentMenu.js +0 -32
- package/components/routes/hits/search/BundleScroller.d.ts +0 -2
- package/components/routes/hits/search/BundleScroller.js +0 -6
- package/components/routes/hits/search/HitContextMenu.js +0 -227
- /package/components/app/providers/{HitSearchProvider.test.d.ts → RecordSearchProvider.test.d.ts} +0 -0
- /package/components/{routes/hits/search/HitContextMenu.test.d.ts → elements/ContextMenu.test.d.ts} +0 -0
- /package/components/{routes/overviews/OverviewEditor.d.ts → elements/MarkdownEditor.d.ts} +0 -0
- /package/components/elements/hit/{HitDetails.d.ts → related/RelatedRecords.d.ts} +0 -0
- /package/components/routes/hits/search/{HitBrowser.d.ts → RecordBrowser.d.ts} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ArrowDropDown, InfoOutlined, List, Settings, TableChart, ViewComfy, ViewCompact, ViewModule } from '@mui/icons-material';
|
|
3
3
|
import { Checkbox, Divider, FormLabel, Stack, TextField, ToggleButton, ToggleButtonGroup, Tooltip } from '@mui/material';
|
|
4
|
-
import {
|
|
4
|
+
import { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
|
|
5
5
|
import ChipPopper from '@cccsaurora/howler-ui/components/elements/display/ChipPopper';
|
|
6
6
|
import { HitLayout } from '@cccsaurora/howler-ui/components/elements/hit/HitLayout';
|
|
7
7
|
import { useMyLocalStorageItem } from '@cccsaurora/howler-ui/components/hooks/useMyLocalStorage';
|
|
@@ -10,8 +10,8 @@ import { useContextSelector } from 'use-context-selector';
|
|
|
10
10
|
import { StorageKey } from '@cccsaurora/howler-ui/utils/constants';
|
|
11
11
|
const LayoutSettings = () => {
|
|
12
12
|
const { t } = useTranslation();
|
|
13
|
-
const displayType = useContextSelector(
|
|
14
|
-
const setDisplayType = useContextSelector(
|
|
13
|
+
const displayType = useContextSelector(RecordSearchContext, ctx => ctx.displayType);
|
|
14
|
+
const setDisplayType = useContextSelector(RecordSearchContext, ctx => ctx.setDisplayType);
|
|
15
15
|
const [hitLayout, setHitLayout] = useMyLocalStorageItem(StorageKey.HIT_LAYOUT, false);
|
|
16
16
|
const [templateFieldCount, setTemplateFieldCount] = useMyLocalStorageItem(StorageKey.TEMPLATE_FIELD_COUNT, null);
|
|
17
17
|
return (_jsx(ChipPopper, { icon: _jsx(Tooltip, { title: t('search.layout.settings'), children: _jsx(Settings, {}) }), deleteIcon: _jsx(ArrowDropDown, {}), toggleOnDelete: true, disablePortal: false, slotProps: { chip: { size: 'medium', 'aria-label': t('search.layout.settings') } }, placement: "bottom-end", children: _jsxs(Stack, { spacing: 1, alignItems: "start", children: [_jsxs(Stack, { direction: "row", spacing: 0.5, alignItems: "center", alignSelf: "stretch", children: [_jsx(FormLabel, { id: "display_type", children: t('page.settings.local.hits.display_type') }), _jsx("div", { style: { flex: 1 } }), _jsx(Tooltip, { title: t('page.settings.local.hits.display_type.description'), children: _jsx(InfoOutlined, { fontSize: "inherit" }) })] }), _jsxs(ToggleButtonGroup, { exclusive: true, value: displayType, onChange: (__, value) => setDisplayType(value), size: "small", "aria-labelledby": "display_type", 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(Divider, { flexItem: true }), _jsxs(Stack, { direction: "row", spacing: 0.5, alignItems: "center", alignSelf: "stretch", children: [_jsx(FormLabel, { id: "layout", children: t('page.settings.local.hits.layout') }), _jsx("div", { style: { flex: 1 } }), _jsx(Tooltip, { title: t('page.settings.local.hits.layout.description'), children: _jsx(InfoOutlined, { fontSize: "inherit" }) })] }), _jsxs(ToggleButtonGroup, { exclusive: true, size: "small", value: hitLayout, onChange: (_, value) => setHitLayout(value), "aria-labelledby": "layout", 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(Divider, { flexItem: true }), _jsxs(Stack, { direction: "row", spacing: 0.5, alignItems: "center", alignSelf: "stretch", children: [_jsx(FormLabel, { id: "field_count", children: t('page.settings.local.hits.field_count') }), _jsx("div", { style: { flex: 1 } }), _jsx(Tooltip, { title: t('page.settings.local.hits.field_count.description'), children: _jsx(InfoOutlined, { fontSize: "inherit" }) })] }), _jsxs(Stack, { direction: "row", spacing: 0.5, alignSelf: "stretch", children: [_jsx(Checkbox, { checked: templateFieldCount !== null, onChange: (_, checked) => setTemplateFieldCount(checked ? 3 : null), size: "small" }), _jsx(TextField, { type: "number", size: "small", disabled: templateFieldCount === null, value: templateFieldCount ?? 3, fullWidth: true, onChange: e => {
|
|
@@ -9,6 +9,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
9
9
|
import { useContextSelector } from 'use-context-selector';
|
|
10
10
|
import HitFilter from './shared/HitFilter';
|
|
11
11
|
import HitSort from './shared/HitSort';
|
|
12
|
+
import IndexPicker from './shared/IndexPicker';
|
|
12
13
|
import SearchSpan from './shared/SearchSpan';
|
|
13
14
|
import ViewLink from './ViewLink';
|
|
14
15
|
const QuerySettings = ({ boxSx }) => {
|
|
@@ -25,6 +26,6 @@ const QuerySettings = ({ boxSx }) => {
|
|
|
25
26
|
await fetchViews();
|
|
26
27
|
addView('');
|
|
27
28
|
};
|
|
28
|
-
return (_jsx(Box, { sx: boxSx ?? { position: 'relative', maxWidth: '1200px' }, children: _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Grid, { container: true, spacing: 1, sx: theme => ({ ml: `${theme.spacing(-1)} !important`, mt: `${theme.spacing(-1)} !important` }), children: [_jsx(Grid, { item: true, children: _jsx(HitSort, {}) }), _jsx(Grid, { item: true, children: _jsx(SearchSpan, {}) }), currentViews?.map((view, id) => (_jsx(Grid, { item: true, children: _jsx(ViewLink, { id: id, viewId: view }) }, view))), filters?.map((filter, id) => (_jsx(Grid, { item: true, children: _jsx(HitFilter, { id: id, value: filter }) }, filter)))] }), _jsx(ChipPopper, { icon: _jsx(Add, {}), deleteIcon: _jsx(ArrowDropDown, {}), toggleOnDelete: true, closeOnClick: true, slotProps: { chip: { size: 'small', color: 'primary' }, paper: { sx: { p: 1 } } }, children: _jsxs(Stack, { spacing: 1, children: [_jsxs(Button, { id: "add-filter", "aria-label": t('hit.search.filter.add'), variant: "outlined", onClick: () => addFilter('howler.assessment:*'), disabled: filters?.some(filter => filter.endsWith('*')), sx: { display: 'flex', pl: 1 }, children: [_jsx(Add, { fontSize: "small", sx: { mr: 1 } }), _jsx("div", { style: { flex: 1 } }), _jsx("span", { children: t('hit.search.filter.add') })] }), _jsxs(Button, { id: "add-view", "aria-label": t('hit.search.view.add'), variant: "outlined", onClick: onAddView, disabled: !allowAddViews, sx: { display: 'flex', pl: 1 }, children: [_jsx(Add, { fontSize: "small", sx: { mr: 1 } }), _jsx("div", { style: { flex: 1 } }), _jsx("span", { children: t('hit.search.view.add') })] })] }) })] }) }));
|
|
29
|
+
return (_jsx(Box, { sx: boxSx ?? { position: 'relative', maxWidth: '1200px' }, children: _jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Grid, { container: true, spacing: 1, sx: theme => ({ ml: `${theme.spacing(-1)} !important`, mt: `${theme.spacing(-1)} !important` }), children: [_jsx(Grid, { item: true, children: _jsx(IndexPicker, {}) }), _jsx(Grid, { item: true, children: _jsx(HitSort, {}) }), _jsx(Grid, { item: true, children: _jsx(SearchSpan, {}) }), currentViews?.map((view, id) => (_jsx(Grid, { item: true, children: _jsx(ViewLink, { id: id, viewId: view }) }, view))), filters?.map((filter, id) => (_jsx(Grid, { item: true, children: _jsx(HitFilter, { id: id, value: filter }) }, filter)))] }), _jsx(ChipPopper, { icon: _jsx(Add, {}), deleteIcon: _jsx(ArrowDropDown, {}), toggleOnDelete: true, closeOnClick: true, slotProps: { chip: { size: 'small', color: 'primary' }, paper: { sx: { p: 1 } } }, children: _jsxs(Stack, { spacing: 1, children: [_jsxs(Button, { id: "add-filter", "aria-label": t('hit.search.filter.add'), variant: "outlined", onClick: () => addFilter('howler.assessment:*'), disabled: filters?.some(filter => filter.endsWith('*')), sx: { display: 'flex', pl: 1 }, children: [_jsx(Add, { fontSize: "small", sx: { mr: 1 } }), _jsx("div", { style: { flex: 1 } }), _jsx("span", { children: t('hit.search.filter.add') })] }), _jsxs(Button, { id: "add-view", "aria-label": t('hit.search.view.add'), variant: "outlined", onClick: onAddView, disabled: !allowAddViews, sx: { display: 'flex', pl: 1 }, children: [_jsx(Add, { fontSize: "small", sx: { mr: 1 } }), _jsx("div", { style: { flex: 1 } }), _jsx("span", { children: t('hit.search.view.add') })] })] }) })] }) }));
|
|
29
30
|
};
|
|
30
31
|
export default memo(QuerySettings);
|
|
@@ -16,6 +16,9 @@ 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
|
+
}));
|
|
19
22
|
vi.mock('./ViewLink', () => ({
|
|
20
23
|
default: ({ id, viewId }) => (_jsxs("div", { id: `view-link-${id}`, "data-view-id": viewId, children: ["ViewLink ", id, ": ", viewId] }))
|
|
21
24
|
}));
|
|
@@ -33,6 +36,7 @@ const mockFetchViews = vi.fn();
|
|
|
33
36
|
let mockParameterContext = {
|
|
34
37
|
filters: [],
|
|
35
38
|
views: [],
|
|
39
|
+
indexes: [],
|
|
36
40
|
addFilter: mockAddFilter,
|
|
37
41
|
addView: mockAddView
|
|
38
42
|
};
|
|
@@ -270,16 +274,16 @@ describe('QuerySettings', () => {
|
|
|
270
274
|
mockParameterContext.views = ['view-1'];
|
|
271
275
|
const { container } = render(_jsx(QuerySettings, {}), { wrapper: Wrapper });
|
|
272
276
|
const gridItems = container.querySelectorAll('[class*="MuiGrid-item"]');
|
|
273
|
-
// HitSort + SearchSpan + 1 view + 2 filters = 5 items
|
|
274
|
-
expect(gridItems.length).toBe(
|
|
277
|
+
// IndexPicker + HitSort + SearchSpan + 1 view + 2 filters = 5 items
|
|
278
|
+
expect(gridItems.length).toBe(6);
|
|
275
279
|
});
|
|
276
280
|
it('should render correct number of items with multiple views', () => {
|
|
277
281
|
mockParameterContext.filters = ['filter1'];
|
|
278
282
|
mockParameterContext.views = ['view-1', 'view-2', 'view-3'];
|
|
279
283
|
const { container } = render(_jsx(QuerySettings, {}), { wrapper: Wrapper });
|
|
280
284
|
const gridItems = container.querySelectorAll('[class*="MuiGrid-item"]');
|
|
281
|
-
// HitSort + SearchSpan + 3 views + 1 filter = 6 items
|
|
282
|
-
expect(gridItems.length).toBe(
|
|
285
|
+
// IndexPicker + HitSort + SearchSpan + 3 views + 1 filter = 6 items
|
|
286
|
+
expect(gridItems.length).toBe(7);
|
|
283
287
|
});
|
|
284
288
|
});
|
|
285
289
|
describe('Edge Cases', () => {
|
|
@@ -508,11 +512,12 @@ describe('QuerySettings', () => {
|
|
|
508
512
|
mockParameterContext.views = ['view-1'];
|
|
509
513
|
const { container } = render(_jsx(QuerySettings, {}), { wrapper: Wrapper });
|
|
510
514
|
const gridItems = container.querySelectorAll('[class*="MuiGrid-item"]');
|
|
511
|
-
// Order: HitSort, SearchSpan, ViewLink(s), HitFilter(s)
|
|
512
|
-
expect(gridItems[0]).toContainElement(screen.getByTestId('
|
|
513
|
-
expect(gridItems[1]).toContainElement(screen.getByTestId('
|
|
514
|
-
expect(gridItems[2]).toContainElement(screen.getByTestId('
|
|
515
|
-
expect(gridItems[3]).toContainElement(screen.getByTestId('
|
|
515
|
+
// Order: IndexPicker, HitSort, SearchSpan, ViewLink(s), HitFilter(s)
|
|
516
|
+
expect(gridItems[0]).toContainElement(screen.getByTestId('index-picker'));
|
|
517
|
+
expect(gridItems[1]).toContainElement(screen.getByTestId('hit-sort'));
|
|
518
|
+
expect(gridItems[2]).toContainElement(screen.getByTestId('search-span'));
|
|
519
|
+
expect(gridItems[3]).toContainElement(screen.getByTestId('view-link-0'));
|
|
520
|
+
expect(gridItems[4]).toContainElement(screen.getByTestId('hit-filter-0'));
|
|
516
521
|
});
|
|
517
522
|
it('should pass correct props to ViewLink components', () => {
|
|
518
523
|
mockParameterContext.views = ['view-1', 'view-2'];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronLeft, Close, ManageSearch } from '@mui/icons-material';
|
|
3
3
|
import { Box, Card, Checkbox, Collapse, Drawer, Fab, IconButton, Stack, Tooltip, Typography, useMediaQuery, useTheme } from '@mui/material';
|
|
4
|
-
import { HitContext } from '@cccsaurora/howler-ui/components/app/providers/HitProvider';
|
|
5
|
-
import HitSearchProvider, { HitSearchContext } from '@cccsaurora/howler-ui/components/app/providers/HitSearchProvider';
|
|
6
4
|
import ParameterProvider, { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
|
|
5
|
+
import { RecordContext } from '@cccsaurora/howler-ui/components/app/providers/RecordProvider';
|
|
6
|
+
import RecordSearchProvider, { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
|
|
7
7
|
import { ViewContext } from '@cccsaurora/howler-ui/components/app/providers/ViewProvider';
|
|
8
8
|
import FlexOne from '@cccsaurora/howler-ui/components/elements/addons/layout/FlexOne';
|
|
9
9
|
import FlexPort from '@cccsaurora/howler-ui/components/elements/addons/layout/FlexPort';
|
|
@@ -32,14 +32,14 @@ const HitBrowser = () => {
|
|
|
32
32
|
const setQuery = useContextSelector(ParameterContext, ctx => ctx.setQuery);
|
|
33
33
|
const setOffset = useContextSelector(ParameterContext, ctx => ctx.setOffset);
|
|
34
34
|
const selectedViews = useContextSelector(ParameterContext, ctx => ctx.views);
|
|
35
|
-
const selectedHits = useContextSelector(
|
|
36
|
-
const addHitToSelection = useContextSelector(
|
|
37
|
-
const removeHitFromSelection = useContextSelector(
|
|
38
|
-
const clearSelectedHits = useContextSelector(
|
|
35
|
+
const selectedHits = useContextSelector(RecordContext, ctx => ctx.selectedRecords);
|
|
36
|
+
const addHitToSelection = useContextSelector(RecordContext, ctx => ctx.addRecordToSelection);
|
|
37
|
+
const removeHitFromSelection = useContextSelector(RecordContext, ctx => ctx.removeRecordFromSelection);
|
|
38
|
+
const clearSelectedHits = useContextSelector(RecordContext, ctx => ctx.clearSelectedRecords);
|
|
39
39
|
const searchPaneWidth = useMyLocalStorageItem(StorageKey.SEARCH_PANE_WIDTH, null)[0];
|
|
40
40
|
const forceDrawer = useMyLocalStorageItem(StorageKey.FORCE_DRAWER, false)[0];
|
|
41
|
-
const displayType = useContextSelector(
|
|
42
|
-
const response = useContextSelector(
|
|
41
|
+
const displayType = useContextSelector(RecordSearchContext, ctx => ctx.displayType);
|
|
42
|
+
const response = useContextSelector(RecordSearchContext, ctx => ctx.response);
|
|
43
43
|
const location = useLocation();
|
|
44
44
|
const routeParams = useParams();
|
|
45
45
|
const [show, setShow] = useState(!!selected);
|
|
@@ -128,6 +128,6 @@ const HitBrowser = () => {
|
|
|
128
128
|
}, children: _jsx(ChevronLeft, { sx: { transition: 'rotate 250ms', rotate: show ? '180deg' : '0deg' } }) }))] }));
|
|
129
129
|
};
|
|
130
130
|
const HitBrowserProvider = () => {
|
|
131
|
-
return (_jsx(ParameterProvider, { children: _jsx(
|
|
131
|
+
return (_jsx(ParameterProvider, { children: _jsx(RecordSearchProvider, { children: _jsx(HitBrowser, {}) }) }));
|
|
132
132
|
};
|
|
133
133
|
export default HitBrowserProvider;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type RecordQueryProps = {
|
|
2
2
|
triggerSearch: (query: string) => void;
|
|
3
3
|
onChange?: (query: string, isDirty: boolean) => void;
|
|
4
4
|
searching?: boolean;
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
compact?: boolean;
|
|
7
7
|
};
|
|
8
|
-
declare const _default: import("react").NamedExoticComponent<
|
|
8
|
+
declare const _default: import("react").NamedExoticComponent<RecordQueryProps>;
|
|
9
9
|
export default _default;
|
|
@@ -5,7 +5,7 @@ import { Badge, Box, Card, Skeleton, Tooltip, alpha, useTheme } from '@mui/mater
|
|
|
5
5
|
import { ParameterContext } from '@cccsaurora/howler-ui/components/app/providers/ParameterProvider';
|
|
6
6
|
import TuiIconButton from '@cccsaurora/howler-ui/components/elements/addons/buttons/CustomIconButton';
|
|
7
7
|
import QueryEditor from '@cccsaurora/howler-ui/components/routes/advanced/QueryEditor';
|
|
8
|
-
import {
|
|
8
|
+
import { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
|
|
9
9
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import { useLocation } from 'react-router-dom';
|
|
@@ -13,8 +13,8 @@ import { useContextSelector } from 'use-context-selector';
|
|
|
13
13
|
import { DEFAULT_QUERY } from '@cccsaurora/howler-ui/utils/constants';
|
|
14
14
|
import { sanitizeMultilineLucene } from '@cccsaurora/howler-ui/utils/stringUtils';
|
|
15
15
|
const DEFAULT_MULTILINE_HEIGHT = 250;
|
|
16
|
-
const PROMPT_CONTEXT = '
|
|
17
|
-
const
|
|
16
|
+
const PROMPT_CONTEXT = 'isRecordQuery && !suggestWidgetVisible && !renameInputVisible && !inSnippetMode && !quickFixWidgetVisible';
|
|
17
|
+
const RecordQuery = ({ searching = false, disabled = false, compact = false, triggerSearch, onChange }) => {
|
|
18
18
|
const { t } = useTranslation();
|
|
19
19
|
const location = useLocation();
|
|
20
20
|
const theme = useTheme();
|
|
@@ -22,7 +22,7 @@ const HitQuery = ({ searching = false, disabled = false, compact = false, trigge
|
|
|
22
22
|
const savedQuery = useContextSelector(ParameterContext, ctx => ctx.query || DEFAULT_QUERY);
|
|
23
23
|
const prevQuery = useRef(null);
|
|
24
24
|
const [query, setQuery] = useState(new URLSearchParams(window.location.search).get('query') || DEFAULT_QUERY);
|
|
25
|
-
const fzfSearch = useContextSelector(
|
|
25
|
+
const fzfSearch = useContextSelector(RecordSearchContext, ctx => ctx?.fzfSearch ?? false);
|
|
26
26
|
const [loaded, setLoaded] = useState(false);
|
|
27
27
|
const [multiline, setMultiline] = useState(false);
|
|
28
28
|
const [y, setY] = useState(0);
|
|
@@ -90,7 +90,7 @@ const HitQuery = ({ searching = false, disabled = false, compact = false, trigge
|
|
|
90
90
|
window.addEventListener('mouseup', onMouseUp);
|
|
91
91
|
}, [onMouseMove, onMouseUp]);
|
|
92
92
|
const onMount = useCallback((ed) => {
|
|
93
|
-
ed.createContextKey('
|
|
93
|
+
ed.createContextKey('isRecordQuery', true);
|
|
94
94
|
setLoaded(true);
|
|
95
95
|
}, []);
|
|
96
96
|
const options = useMemo(() => ({
|
|
@@ -148,4 +148,4 @@ const HitQuery = ({ searching = false, disabled = false, compact = false, trigge
|
|
|
148
148
|
zIndex: 1000
|
|
149
149
|
}, onMouseDown: onMouseDown }))] }));
|
|
150
150
|
};
|
|
151
|
-
export default memo(
|
|
151
|
+
export default memo(RecordQuery);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { 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';
|
|
9
7
|
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,27 +14,25 @@ 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';
|
|
19
17
|
import HitCard from '@cccsaurora/howler-ui/components/elements/hit/HitCard';
|
|
20
18
|
import { HitLayout } from '@cccsaurora/howler-ui/components/elements/hit/HitLayout';
|
|
21
|
-
import
|
|
19
|
+
import ObservableCard from '@cccsaurora/howler-ui/components/elements/observable/ObservableCard';
|
|
20
|
+
import RecordContextMenu from '@cccsaurora/howler-ui/components/elements/record/RecordContextMenu';
|
|
22
21
|
import { useMyLocalStorageItem } from '@cccsaurora/howler-ui/components/hooks/useMyLocalStorage';
|
|
23
|
-
import
|
|
22
|
+
import useRecordSelection from '@cccsaurora/howler-ui/components/hooks/useRecordSelection';
|
|
23
|
+
import React, { memo, useCallback, useMemo } from 'react';
|
|
24
24
|
import { isMobile } from 'react-device-detect';
|
|
25
25
|
import { useTranslation } from 'react-i18next';
|
|
26
|
-
import { Link
|
|
26
|
+
import { Link } from 'react-router-dom';
|
|
27
27
|
import { useContextSelector } from 'use-context-selector';
|
|
28
28
|
import { StorageKey } from '@cccsaurora/howler-ui/utils/constants';
|
|
29
|
-
import
|
|
30
|
-
import { BundleScroller } from './BundleScroller';
|
|
31
|
-
import HitContextMenu from './HitContextMenu';
|
|
32
|
-
import HitQuery from './HitQuery';
|
|
29
|
+
import { isHit, isObservable } from '@cccsaurora/howler-ui/utils/typeUtils';
|
|
33
30
|
import LayoutSettings from './LayoutSettings';
|
|
34
31
|
import QuerySettings from './QuerySettings';
|
|
35
|
-
|
|
32
|
+
import RecordQuery from './RecordQuery';
|
|
33
|
+
const Item = memo(({ record, onClick }) => {
|
|
36
34
|
const theme = useTheme();
|
|
37
|
-
const
|
|
35
|
+
const selectedRecords = useContextSelector(RecordContext, ctx => ctx.selectedRecords);
|
|
38
36
|
const selected = useContextSelector(ParameterContext, ctx => ctx.selected);
|
|
39
37
|
const checkMiddleClick = useCallback((e, id) => {
|
|
40
38
|
if (e.button === 1) {
|
|
@@ -46,14 +44,14 @@ const Item = memo(({ hit, onClick }) => {
|
|
|
46
44
|
const [hitLayout] = useMyLocalStorageItem(StorageKey.HIT_LAYOUT, HitLayout.NORMAL);
|
|
47
45
|
const layout = useMemo(() => (isMobile ? HitLayout.COMFY : hitLayout), [hitLayout]);
|
|
48
46
|
// Search result list item renderer.
|
|
49
|
-
return (
|
|
47
|
+
return (_jsxs(Box, { id: record.howler.id, onAuxClick: e => checkMiddleClick(e, record.howler.id), onClick: ev => onClick(ev, record), sx: [
|
|
50
48
|
{
|
|
51
49
|
mb: 2,
|
|
52
50
|
cursor: 'pointer',
|
|
53
51
|
'& span,p,h6': {
|
|
54
52
|
cursor: 'text'
|
|
55
53
|
},
|
|
56
|
-
'& .MuiPaper-root': {
|
|
54
|
+
'& > .MuiPaper-root': {
|
|
57
55
|
border: '4px solid transparent',
|
|
58
56
|
boxShadow: `0px 0px 0px 0px transparent`,
|
|
59
57
|
transition: theme.transitions.create(['border-color', 'box-shadow'])
|
|
@@ -66,34 +64,26 @@ const Item = memo(({ hit, onClick }) => {
|
|
|
66
64
|
paddingBottom: 'inherit' // prevents slight height variation on selected card.
|
|
67
65
|
}
|
|
68
66
|
},
|
|
69
|
-
|
|
70
|
-
'& .MuiPaper-root': { borderColor: grey[500], boxShadow: `0px 0px 5px 2px ${grey[500]}` }
|
|
67
|
+
selectedRecords.some(_record => _record.howler.id === record.howler.id) && {
|
|
68
|
+
'& > .MuiPaper-root': { borderColor: grey[500], boxShadow: `0px 0px 5px 2px ${grey[500]}` }
|
|
71
69
|
},
|
|
72
|
-
selected ===
|
|
73
|
-
'& .MuiPaper-root': {
|
|
70
|
+
selected === record.howler.id && {
|
|
71
|
+
'& > .MuiPaper-root': {
|
|
74
72
|
borderColor: 'primary.main',
|
|
75
73
|
boxShadow: `0px 0px 5px 2px ${theme.palette.primary.main}`
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
], children: _jsx(HitCard, { id:
|
|
76
|
+
], children: [isHit(record) && _jsx(HitCard, { id: record.howler.id, layout: layout }), isObservable(record) && _jsx(ObservableCard, { id: record.howler.id, observable: record })] }));
|
|
79
77
|
});
|
|
80
78
|
const SearchPane = () => {
|
|
81
79
|
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);
|
|
87
80
|
const query = useContextSelector(ParameterContext, ctx => ctx.query);
|
|
88
81
|
const setOffset = useContextSelector(ParameterContext, ctx => ctx.setOffset);
|
|
89
|
-
const triggerSearch = useContextSelector(
|
|
90
|
-
const searching = useContextSelector(
|
|
91
|
-
const response = useContextSelector(
|
|
92
|
-
const error = useContextSelector(
|
|
93
|
-
const { onClick } =
|
|
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);
|
|
82
|
+
const triggerSearch = useContextSelector(RecordSearchContext, ctx => ctx.search);
|
|
83
|
+
const searching = useContextSelector(RecordSearchContext, ctx => ctx.searching);
|
|
84
|
+
const response = useContextSelector(RecordSearchContext, ctx => ctx.response);
|
|
85
|
+
const error = useContextSelector(RecordSearchContext, ctx => ctx.error);
|
|
86
|
+
const { onClick } = useRecordSelection();
|
|
97
87
|
const searchPaneWidth = useMyLocalStorageItem(StorageKey.SEARCH_PANE_WIDTH, null)[0];
|
|
98
88
|
const verticalSorters = useMediaQuery('(max-width: 1919px)') || (searchPaneWidth ?? Number.MAX_SAFE_INTEGER) < 900;
|
|
99
89
|
const getSelectedId = useCallback((event) => {
|
|
@@ -104,26 +94,13 @@ const SearchPane = () => {
|
|
|
104
94
|
}
|
|
105
95
|
return selectedElement.id;
|
|
106
96
|
}, []);
|
|
107
|
-
|
|
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 => ({
|
|
97
|
+
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: [_jsx(Stack, { ml: -1, mr: -1, sx: { '& .overflowingContentWidgets > *': { zIndex: '2000 !important' } }, spacing: 1, children: _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, {}), _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(RecordQuery, { searching: searching, triggerSearch: triggerSearch }), searching && (_jsx(LinearProgress, { sx: theme => ({
|
|
121
98
|
position: 'absolute',
|
|
122
99
|
left: 0,
|
|
123
100
|
right: 0,
|
|
124
101
|
bottom: 0,
|
|
125
102
|
borderBottomLeftRadius: theme.shape.borderRadius,
|
|
126
103
|
borderBottomRightRadius: theme.shape.borderRadius
|
|
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(
|
|
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(RecordContextMenu, { getSelectedId: getSelectedId, children: !response ? (_jsx(AppListEmpty, {})) : (response.items.map(record => _jsx(Item, { record: record, onClick: onClick }, record.howler.id))) }) })] }) }) }));
|
|
128
105
|
};
|
|
129
106
|
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';
|
|
6
5
|
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(RecordSearchContext, 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, {
|
|
50
|
+
return _jsx(Chip, { 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';
|
|
11
10
|
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 mockRecordSearchContext = {
|
|
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(RecordSearchContext.Provider, { value: mockRecordSearchContext, 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
|
+
mockRecordSearchContext.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(mockRecordSearchContext.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(mockRecordSearchContext.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 RecordSearchContext', 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(mockRecordSearchContext.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,23 +3,24 @@ 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 { RecordSearchContext } from '@cccsaurora/howler-ui/components/app/providers/RecordSearchProvider';
|
|
7
7
|
import ChipPopper from '@cccsaurora/howler-ui/components/elements/display/ChipPopper';
|
|
8
|
-
import {
|
|
8
|
+
import { 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';
|
|
12
13
|
const AddColumnModal = ({ addColumn, columns }) => {
|
|
13
14
|
const { t } = useTranslation();
|
|
14
15
|
const { hitFields } = useContext(FieldContext);
|
|
15
|
-
const response = useContextSelector(
|
|
16
|
+
const response = useContextSelector(RecordSearchContext, ctx => ctx.response);
|
|
16
17
|
const { getMatchingTemplate } = useMatchers();
|
|
17
18
|
const [columnToAdd, setColumnToAdd] = useState(null);
|
|
18
19
|
const options = useMemo(() => hitFields.map(field => field.key), [hitFields]);
|
|
19
20
|
const [suggestions, setSuggestions] = useState([]);
|
|
20
21
|
useEffect(() => {
|
|
21
22
|
(async () => {
|
|
22
|
-
setSuggestions(uniq((await Promise.all((response?.items ?? []).map(async (_hit) => (
|
|
23
|
+
setSuggestions(uniq((await Promise.all((response?.items ?? []).filter(isHit).map(async (_hit) => (await getMatchingTemplate(_hit))?.keys ?? []))).flat()));
|
|
23
24
|
})();
|
|
24
25
|
}, [getMatchingTemplate, response?.items]);
|
|
25
26
|
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,7 +1,8 @@
|
|
|
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';
|
|
3
4
|
declare const _default: import("react").NamedExoticComponent<{
|
|
4
|
-
|
|
5
|
+
record: Hit | Observable;
|
|
5
6
|
value: string;
|
|
6
7
|
sx?: SxProps;
|
|
7
8
|
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 = ({ record, 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 = ({ hit, 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, obj: record, children: value }, value + index))) }) }));
|
|
17
17
|
};
|
|
18
18
|
export default memo(EnhancedCell);
|