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