@cccsaurora/howler-ui 2.17.0-dev.617 → 2.17.1-dev.627
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/index.d.ts +0 -2
- package/api/index.js +2 -4
- package/api/search/index.d.ts +1 -2
- package/api/search/index.js +1 -2
- package/commons/components/leftnav/LeftNavDrawer.js +1 -1
- package/components/app/App.js +0 -14
- package/components/app/providers/FavouritesProvider.js +2 -2
- package/components/app/providers/HitSearchProvider.d.ts +1 -0
- package/components/app/providers/HitSearchProvider.js +11 -6
- package/components/app/providers/HitSearchProvider.test.js +32 -11
- package/components/app/providers/LocalStorageProvider.js +1 -1
- package/components/app/providers/ParameterProvider.d.ts +2 -9
- package/components/app/providers/ParameterProvider.js +240 -165
- package/components/app/providers/ParameterProvider.test.js +14 -307
- package/components/elements/EditRow.d.ts +4 -1
- package/components/elements/EditRow.js +4 -4
- package/components/elements/PluginTypography.d.ts +1 -2
- package/components/elements/PluginTypography.js +2 -3
- package/components/elements/UserList.d.ts +2 -5
- package/components/elements/UserList.js +5 -14
- package/components/elements/addons/search/phrase/Phrase.js +1 -1
- package/components/elements/display/ChipPopper.d.ts +1 -1
- package/components/elements/display/ChipPopper.js +1 -1
- package/components/elements/display/HowlerCard.js +1 -1
- package/components/elements/display/Modal.js +0 -1
- package/components/elements/display/icons/BundleButton.d.ts +6 -0
- package/components/elements/display/icons/BundleButton.js +32 -0
- package/components/elements/hit/HitBanner.js +48 -28
- package/components/elements/hit/HitCard.js +1 -1
- package/components/elements/{ObjectDetails.js → hit/HitDetails.js} +17 -17
- package/components/elements/hit/HitOutline.js +7 -3
- package/components/elements/hit/{HitPreview.d.ts → HitQuickSearch.d.ts} +3 -3
- package/components/elements/hit/{HitPreview.js → HitQuickSearch.js} +4 -10
- package/components/elements/hit/HitRelated.d.ts +1 -1
- package/components/elements/hit/HitRelated.js +3 -30
- package/components/elements/hit/outlines/DefaultOutline.js +1 -1
- package/components/elements/hit/related/PivotLink.js +1 -1
- package/components/elements/hit/related/RelatedLink.d.ts +1 -0
- package/components/elements/hit/related/RelatedLink.js +2 -2
- package/components/elements/view/ViewTitle.js +1 -1
- package/components/hooks/useHitActions.d.ts +1 -1
- package/components/hooks/useHitActions.js +2 -2
- package/components/hooks/useHitSelection.js +24 -3
- package/components/hooks/useLocalStorage.d.ts +13 -0
- package/components/hooks/useLocalStorage.js +53 -0
- package/components/hooks/useLocalStorageItem.d.ts +18 -0
- package/components/hooks/useLocalStorageItem.js +78 -0
- package/components/hooks/useLocalStorageItem.test.d.ts +1 -0
- package/components/hooks/useLocalStorageItem.test.js +144 -0
- package/components/hooks/useMyLocalStorage.js +2 -2
- package/components/hooks/useMyPreferences.js +1 -10
- package/components/hooks/useMySearch.js +2 -2
- package/components/hooks/useMySitemap.js +1 -4
- package/components/hooks/useMyTheme.js +2 -9
- package/components/routes/action/view/ActionSearch.js +1 -1
- package/components/routes/advanced/QueryBuilder.js +1 -1
- package/components/routes/analytics/AnalyticDetails.js +2 -2
- package/components/routes/analytics/AnalyticSearch.js +1 -1
- package/components/routes/help/ApiDocumentation.js +1 -1
- package/components/routes/help/BundleDocumentation.d.ts +3 -0
- package/components/routes/help/BundleDocumentation.js +12 -0
- package/components/routes/help/HitDocumentation.js +3 -1
- package/components/routes/help/markdown/en/bundles.md.js +1 -0
- package/components/routes/help/markdown/fr/bundles.md.js +1 -0
- package/components/routes/hits/search/BundleParentMenu.d.ts +6 -0
- package/components/routes/hits/search/BundleParentMenu.js +32 -0
- package/components/routes/hits/search/HitContextMenu.js +2 -3
- package/components/routes/hits/search/InformationPane.d.ts +0 -1
- package/components/routes/hits/search/InformationPane.js +28 -6
- package/components/routes/hits/search/LayoutSettings.d.ts +3 -0
- package/components/routes/hits/search/LayoutSettings.js +18 -0
- package/components/routes/hits/search/QuerySettings.js +1 -2
- package/components/routes/hits/search/QuerySettings.test.js +9 -14
- package/components/routes/hits/search/SearchPane.js +37 -13
- package/components/routes/hits/search/ViewLink.js +1 -1
- package/components/routes/hits/search/grid/EnhancedCell.js +1 -1
- package/components/routes/hits/view/HitViewer.js +4 -3
- package/components/routes/home/AnalyticCard.d.ts +2 -3
- package/components/routes/home/AnalyticCard.js +2 -2
- package/components/routes/home/ViewCard.js +1 -1
- package/components/routes/home/ViewRefresh.d.ts +23 -0
- package/components/routes/home/ViewRefresh.js +67 -0
- package/components/routes/home/index.js +9 -46
- package/components/{elements/MarkdownEditor.js → routes/overviews/OverviewEditor.js} +3 -3
- package/components/routes/overviews/OverviewViewer.js +2 -2
- package/components/routes/settings/LocalSection.js +2 -1
- package/locales/en/translation.json +6 -42
- package/locales/fr/translation.json +4 -35
- package/models/WithMetadata.d.ts +1 -2
- package/models/entities/generated/{ThreatEnrichment.d.ts → Enrichment.d.ts} +1 -1
- package/models/entities/generated/Howler.d.ts +4 -0
- package/models/entities/generated/Rule.d.ts +10 -2
- package/models/entities/generated/Threat.d.ts +2 -2
- package/package.json +1 -16
- package/plugins/clue/components/ClueTypography.js +2 -2
- package/plugins/clue/utils.d.ts +1 -2
- package/utils/constants.d.ts +4 -3
- package/utils/constants.js +1 -0
- package/api/search/case.d.ts +0 -4
- package/api/search/case.js +0 -8
- package/api/v2/case/index.d.ts +0 -6
- package/api/v2/case/index.js +0 -18
- package/api/v2/index.d.ts +0 -4
- package/api/v2/index.js +0 -6
- package/api/v2/search/facet.d.ts +0 -3
- package/api/v2/search/facet.js +0 -12
- package/api/v2/search/index.d.ts +0 -5
- package/api/v2/search/index.js +0 -24
- package/components/elements/ObjectDetails.d.ts +0 -6
- package/components/elements/case/CaseCard.d.ts +0 -8
- package/components/elements/case/CaseCard.js +0 -39
- package/components/elements/case/CasePreview.d.ts +0 -6
- package/components/elements/case/CasePreview.js +0 -17
- package/components/elements/case/StatusIcon.d.ts +0 -5
- package/components/elements/case/StatusIcon.js +0 -13
- package/components/elements/hit/elements/AnalyticLink.d.ts +0 -8
- package/components/elements/hit/elements/AnalyticLink.js +0 -22
- package/components/elements/hit/related/RelatedRecords.js +0 -63
- package/components/elements/observable/ObservableCard.d.ts +0 -5
- package/components/elements/observable/ObservableCard.js +0 -7
- package/components/elements/observable/ObservablePreview.d.ts +0 -6
- package/components/elements/observable/ObservablePreview.js +0 -12
- package/components/hooks/useRelatedRecords.d.ts +0 -13
- package/components/hooks/useRelatedRecords.js +0 -32
- package/components/routes/cases/CaseViewer.d.ts +0 -2
- package/components/routes/cases/CaseViewer.js +0 -24
- package/components/routes/cases/Cases.d.ts +0 -2
- package/components/routes/cases/Cases.js +0 -101
- package/components/routes/cases/constants.d.ts +0 -5
- package/components/routes/cases/constants.js +0 -5
- package/components/routes/cases/detail/AlertPanel.d.ts +0 -6
- package/components/routes/cases/detail/AlertPanel.js +0 -32
- package/components/routes/cases/detail/CaseDashboard.d.ts +0 -7
- package/components/routes/cases/detail/CaseDashboard.js +0 -49
- package/components/routes/cases/detail/CaseDetails.d.ts +0 -6
- package/components/routes/cases/detail/CaseDetails.js +0 -61
- package/components/routes/cases/detail/CaseOverview.d.ts +0 -7
- package/components/routes/cases/detail/CaseOverview.js +0 -43
- package/components/routes/cases/detail/CaseSidebar.d.ts +0 -6
- package/components/routes/cases/detail/CaseSidebar.js +0 -36
- package/components/routes/cases/detail/CaseTask.d.ts +0 -11
- package/components/routes/cases/detail/CaseTask.js +0 -57
- package/components/routes/cases/detail/ItemPage.d.ts +0 -6
- package/components/routes/cases/detail/ItemPage.js +0 -93
- package/components/routes/cases/detail/RelatedCasePanel.d.ts +0 -6
- package/components/routes/cases/detail/RelatedCasePanel.js +0 -31
- package/components/routes/cases/detail/TaskPanel.d.ts +0 -7
- package/components/routes/cases/detail/TaskPanel.js +0 -52
- package/components/routes/cases/detail/aggregates/CaseAggregate.d.ts +0 -12
- package/components/routes/cases/detail/aggregates/CaseAggregate.js +0 -19
- package/components/routes/cases/detail/aggregates/SourceAggregate.d.ts +0 -6
- package/components/routes/cases/detail/aggregates/SourceAggregate.js +0 -27
- package/components/routes/cases/detail/sidebar/CaseFolder.d.ts +0 -13
- package/components/routes/cases/detail/sidebar/CaseFolder.js +0 -134
- package/components/routes/cases/detail/sidebar/types.d.ts +0 -3
- package/components/routes/cases/detail/sidebar/utils.d.ts +0 -3
- package/components/routes/cases/detail/sidebar/utils.js +0 -25
- package/components/routes/cases/hooks/useCase.d.ts +0 -13
- package/components/routes/cases/hooks/useCase.js +0 -38
- package/components/routes/cases/modals/ResolveModal.d.ts +0 -7
- package/components/routes/cases/modals/ResolveModal.js +0 -59
- package/components/routes/hits/search/shared/IndexPicker.d.ts +0 -2
- package/components/routes/hits/search/shared/IndexPicker.js +0 -20
- package/components/routes/observables/ObservableViewer.d.ts +0 -7
- package/components/routes/observables/ObservableViewer.js +0 -27
- package/models/entities/generated/AttachmentsFile.d.ts +0 -12
- package/models/entities/generated/Case.d.ts +0 -28
- package/models/entities/generated/DestinationOriginal.d.ts +0 -19
- package/models/entities/generated/EmailAttachment.d.ts +0 -8
- package/models/entities/generated/EmailParent.d.ts +0 -19
- package/models/entities/generated/Enrichments.d.ts +0 -7
- package/models/entities/generated/EnrichmentsIndicator.d.ts +0 -21
- package/models/entities/generated/HttpResponse.d.ts +0 -11
- package/models/entities/generated/Item.d.ts +0 -9
- package/models/entities/generated/Observable.d.ts +0 -84
- package/models/entities/generated/ObservableCloud.d.ts +0 -20
- package/models/entities/generated/ObservableDestination.d.ts +0 -23
- package/models/entities/generated/ObservableEmail.d.ts +0 -30
- package/models/entities/generated/ObservableFile.d.ts +0 -36
- package/models/entities/generated/ObservableHowler.d.ts +0 -44
- package/models/entities/generated/ObservableHttp.d.ts +0 -11
- package/models/entities/generated/ObservableObserver.d.ts +0 -21
- package/models/entities/generated/ObservableOrganization.d.ts +0 -7
- package/models/entities/generated/ObservableProcess.d.ts +0 -34
- package/models/entities/generated/ObservableSource.d.ts +0 -23
- package/models/entities/generated/ObservableThreat.d.ts +0 -21
- package/models/entities/generated/ObservableTls.d.ts +0 -12
- package/models/entities/generated/ObserverIngress.d.ts +0 -9
- package/models/entities/generated/Task.d.ts +0 -10
- package/utils/typeUtils.d.ts +0 -7
- package/utils/typeUtils.js +0 -18
- /package/components/elements/hit/{related/RelatedRecords.d.ts → HitDetails.d.ts} +0 -0
- /package/components/{elements/MarkdownEditor.d.ts → routes/overviews/OverviewEditor.d.ts} +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This hooks backs the typical 'useState' hook with local storage.
|
|
3
|
+
*
|
|
4
|
+
* This means that it will initialize with the value stored in local storage.
|
|
5
|
+
*
|
|
6
|
+
* State changes are also persisted to local storage.
|
|
7
|
+
*
|
|
8
|
+
* All callers sharing the same key share a single logical state: updating the
|
|
9
|
+
* value in one component automatically re-renders all others using the same key,
|
|
10
|
+
* both within the same tab (via the module-level subscriber map) and across tabs
|
|
11
|
+
* (via the native 'storage' event).
|
|
12
|
+
*
|
|
13
|
+
* @param key - local storage key under which to store the state.
|
|
14
|
+
* @param initialValue - local storage initialization value.
|
|
15
|
+
* @returns a stateful value, a function to update it, and a function to remove it.
|
|
16
|
+
*/
|
|
17
|
+
declare const useLocalStorageItem: <T>(key: string, initialValue?: T) => [T, (value: T) => void, () => void];
|
|
18
|
+
export default useLocalStorageItem;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import useLocalStorage from '@cccsaurora/howler-ui/components/hooks/useLocalStorage';
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
// Module-level subscriber map for same-page cross-component synchronization.
|
|
4
|
+
// Maps each storage key to the set of React state setters currently subscribed to it.
|
|
5
|
+
const SUBSCRIBERS = new Map();
|
|
6
|
+
const notify = (key, value) => {
|
|
7
|
+
SUBSCRIBERS.get(key)?.forEach(setter => setter(value));
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* This hooks backs the typical 'useState' hook with local storage.
|
|
11
|
+
*
|
|
12
|
+
* This means that it will initialize with the value stored in local storage.
|
|
13
|
+
*
|
|
14
|
+
* State changes are also persisted to local storage.
|
|
15
|
+
*
|
|
16
|
+
* All callers sharing the same key share a single logical state: updating the
|
|
17
|
+
* value in one component automatically re-renders all others using the same key,
|
|
18
|
+
* both within the same tab (via the module-level subscriber map) and across tabs
|
|
19
|
+
* (via the native 'storage' event).
|
|
20
|
+
*
|
|
21
|
+
* @param key - local storage key under which to store the state.
|
|
22
|
+
* @param initialValue - local storage initialization value.
|
|
23
|
+
* @returns a stateful value, a function to update it, and a function to remove it.
|
|
24
|
+
*/
|
|
25
|
+
const useLocalStorageItem = (key, initialValue) => {
|
|
26
|
+
const { get, set, has, remove } = useLocalStorage();
|
|
27
|
+
const [value, setValue] = useState(get(key) ?? initialValue);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (initialValue !== null && initialValue !== undefined && !has(key)) {
|
|
30
|
+
set(key, initialValue);
|
|
31
|
+
}
|
|
32
|
+
}, [key, initialValue, has, set]);
|
|
33
|
+
// Register this instance's setter in the subscriber map.
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!SUBSCRIBERS.has(key)) {
|
|
36
|
+
SUBSCRIBERS.set(key, new Set());
|
|
37
|
+
}
|
|
38
|
+
const setter = (v) => setValue(v);
|
|
39
|
+
SUBSCRIBERS.get(key).add(setter);
|
|
40
|
+
return () => {
|
|
41
|
+
SUBSCRIBERS.get(key)?.delete(setter);
|
|
42
|
+
if (SUBSCRIBERS.get(key)?.size === 0) {
|
|
43
|
+
SUBSCRIBERS.delete(key);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}, [key]);
|
|
47
|
+
// React to cross-tab storage changes via the native 'storage' event.
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const handler = (event) => {
|
|
50
|
+
if (event.key !== key)
|
|
51
|
+
return;
|
|
52
|
+
const next = event.newValue !== null ? JSON.parse(event.newValue) : initialValue;
|
|
53
|
+
notify(key, next);
|
|
54
|
+
};
|
|
55
|
+
window.addEventListener('storage', handler);
|
|
56
|
+
return () => window.removeEventListener('storage', handler);
|
|
57
|
+
}, [key, initialValue]);
|
|
58
|
+
return useMemo(() => [
|
|
59
|
+
value,
|
|
60
|
+
(newValue, save = true) => {
|
|
61
|
+
if (save) {
|
|
62
|
+
if (newValue !== undefined) {
|
|
63
|
+
set(key, newValue);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
remove(key);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
// Update all subscribers for this key (including this instance).
|
|
70
|
+
notify(key, newValue);
|
|
71
|
+
},
|
|
72
|
+
() => {
|
|
73
|
+
remove(key);
|
|
74
|
+
notify(key, initialValue);
|
|
75
|
+
}
|
|
76
|
+
], [key, value, initialValue, set, remove]);
|
|
77
|
+
};
|
|
78
|
+
export default useLocalStorageItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
+
/// <reference types="vitest" />
|
|
3
|
+
import { act, renderHook } from '@testing-library/react';
|
|
4
|
+
import { setupLocalStorageMock } from '@cccsaurora/howler-ui/tests/mocks';
|
|
5
|
+
import { vi } from 'vitest';
|
|
6
|
+
import useLocalStorageItem from './useLocalStorageItem';
|
|
7
|
+
const mockLocalStorage = setupLocalStorageMock();
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
mockLocalStorage.clear();
|
|
10
|
+
vi.mocked(mockLocalStorage.setItem).mockClear();
|
|
11
|
+
vi.mocked(mockLocalStorage.removeItem).mockClear();
|
|
12
|
+
});
|
|
13
|
+
describe('useLocalStorageItem', () => {
|
|
14
|
+
describe('initialization', () => {
|
|
15
|
+
it('returns the initialValue when the key is absent from storage', () => {
|
|
16
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 42));
|
|
17
|
+
expect(result.current[0]).toBe(42);
|
|
18
|
+
});
|
|
19
|
+
it('returns the persisted storage value instead of initialValue', () => {
|
|
20
|
+
mockLocalStorage.setItem('testkey', JSON.stringify(99));
|
|
21
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 42));
|
|
22
|
+
expect(result.current[0]).toBe(99);
|
|
23
|
+
});
|
|
24
|
+
it('writes initialValue to storage when the key is absent', () => {
|
|
25
|
+
renderHook(() => useLocalStorageItem('testkey', 'hello'));
|
|
26
|
+
expect(mockLocalStorage.setItem).toHaveBeenCalledWith('testkey', JSON.stringify('hello'));
|
|
27
|
+
});
|
|
28
|
+
it('does not overwrite an existing storage value with initialValue', () => {
|
|
29
|
+
mockLocalStorage.setItem('testkey', JSON.stringify('existing'));
|
|
30
|
+
vi.mocked(mockLocalStorage.setItem).mockClear();
|
|
31
|
+
renderHook(() => useLocalStorageItem('testkey', 'initial'));
|
|
32
|
+
expect(mockLocalStorage.setItem).not.toHaveBeenCalled();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe('setter', () => {
|
|
36
|
+
it('updates the returned value', () => {
|
|
37
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
38
|
+
act(() => result.current[1](7));
|
|
39
|
+
expect(result.current[0]).toBe(7);
|
|
40
|
+
});
|
|
41
|
+
it('persists the new value to localStorage', () => {
|
|
42
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
43
|
+
act(() => result.current[1](7));
|
|
44
|
+
expect(mockLocalStorage.setItem).toHaveBeenCalledWith('testkey', JSON.stringify(7));
|
|
45
|
+
});
|
|
46
|
+
it('removes the key from storage when called with undefined', () => {
|
|
47
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
48
|
+
act(() => result.current[1](undefined));
|
|
49
|
+
expect(mockLocalStorage.removeItem).toHaveBeenCalledWith('testkey');
|
|
50
|
+
});
|
|
51
|
+
it('skips persisting to storage when save=false', () => {
|
|
52
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
53
|
+
vi.mocked(mockLocalStorage.setItem).mockClear();
|
|
54
|
+
act(() => result.current[1](10, false));
|
|
55
|
+
expect(result.current[0]).toBe(10);
|
|
56
|
+
expect(mockLocalStorage.setItem).not.toHaveBeenCalled();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('reset function', () => {
|
|
60
|
+
it('removes the key from localStorage', () => {
|
|
61
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
62
|
+
act(() => result.current[1](5));
|
|
63
|
+
act(() => result.current[2]());
|
|
64
|
+
expect(mockLocalStorage.removeItem).toHaveBeenCalledWith('testkey');
|
|
65
|
+
});
|
|
66
|
+
it('resets the value back to initialValue', () => {
|
|
67
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
68
|
+
act(() => result.current[1](5));
|
|
69
|
+
act(() => result.current[2]());
|
|
70
|
+
expect(result.current[0]).toBe(0);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('cross-component synchronization (same tab)', () => {
|
|
74
|
+
it('propagates updates to all hooks sharing the same key', () => {
|
|
75
|
+
const { result: a } = renderHook(() => useLocalStorageItem('shared', 0));
|
|
76
|
+
const { result: b } = renderHook(() => useLocalStorageItem('shared', 0));
|
|
77
|
+
act(() => a.current[1](42));
|
|
78
|
+
expect(a.current[0]).toBe(42);
|
|
79
|
+
expect(b.current[0]).toBe(42);
|
|
80
|
+
});
|
|
81
|
+
it('does not affect hooks using a different key', () => {
|
|
82
|
+
const { result: a } = renderHook(() => useLocalStorageItem('key-a', 0));
|
|
83
|
+
const { result: b } = renderHook(() => useLocalStorageItem('key-b', 0));
|
|
84
|
+
act(() => a.current[1](99));
|
|
85
|
+
expect(b.current[0]).toBe(0);
|
|
86
|
+
});
|
|
87
|
+
it('propagates the reset to all hooks sharing the same key', () => {
|
|
88
|
+
const { result: a } = renderHook(() => useLocalStorageItem('shared', 0));
|
|
89
|
+
const { result: b } = renderHook(() => useLocalStorageItem('shared', 0));
|
|
90
|
+
act(() => a.current[1](5));
|
|
91
|
+
act(() => a.current[2]());
|
|
92
|
+
expect(a.current[0]).toBe(0);
|
|
93
|
+
expect(b.current[0]).toBe(0);
|
|
94
|
+
});
|
|
95
|
+
it('propagates save=false updates to other subscribers', () => {
|
|
96
|
+
const { result: a } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
97
|
+
const { result: b } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
98
|
+
act(() => a.current[1](10, false));
|
|
99
|
+
expect(b.current[0]).toBe(10);
|
|
100
|
+
});
|
|
101
|
+
it('stops receiving updates after unmount', () => {
|
|
102
|
+
const { result: a, unmount } = renderHook(() => useLocalStorageItem('shared', 0));
|
|
103
|
+
const { result: b } = renderHook(() => useLocalStorageItem('shared', 0));
|
|
104
|
+
unmount();
|
|
105
|
+
act(() => b.current[1](55));
|
|
106
|
+
// b must have the new value; a is unmounted so no further updates reach it
|
|
107
|
+
expect(a.current[0]).toBe(0);
|
|
108
|
+
expect(b.current[0]).toBe(55);
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
describe('cross-tab synchronization (storage event)', () => {
|
|
112
|
+
it('reacts to a storage event for the same key', () => {
|
|
113
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
114
|
+
act(() => {
|
|
115
|
+
window.dispatchEvent(new StorageEvent('storage', { key: 'testkey', newValue: JSON.stringify(77) }));
|
|
116
|
+
});
|
|
117
|
+
expect(result.current[0]).toBe(77);
|
|
118
|
+
});
|
|
119
|
+
it('ignores storage events for different keys', () => {
|
|
120
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
121
|
+
act(() => {
|
|
122
|
+
window.dispatchEvent(new StorageEvent('storage', { key: 'other-key', newValue: JSON.stringify(99) }));
|
|
123
|
+
});
|
|
124
|
+
expect(result.current[0]).toBe(0);
|
|
125
|
+
});
|
|
126
|
+
it('falls back to initialValue when a storage event clears the key (newValue=null)', () => {
|
|
127
|
+
const { result } = renderHook(() => useLocalStorageItem('testkey', 5));
|
|
128
|
+
act(() => result.current[1](20));
|
|
129
|
+
act(() => {
|
|
130
|
+
window.dispatchEvent(new StorageEvent('storage', { key: 'testkey', newValue: null }));
|
|
131
|
+
});
|
|
132
|
+
expect(result.current[0]).toBe(5);
|
|
133
|
+
});
|
|
134
|
+
it('propagates cross-tab updates to all same-tab subscribers', () => {
|
|
135
|
+
const { result: a } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
136
|
+
const { result: b } = renderHook(() => useLocalStorageItem('testkey', 0));
|
|
137
|
+
act(() => {
|
|
138
|
+
window.dispatchEvent(new StorageEvent('storage', { key: 'testkey', newValue: JSON.stringify(33) }));
|
|
139
|
+
});
|
|
140
|
+
expect(a.current[0]).toBe(33);
|
|
141
|
+
expect(b.current[0]).toBe(33);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import useLocalStorage from '@cccsaurora/howler-ui/commons/components/utils/hooks/useLocalStorage';
|
|
2
|
-
import useLocalStorageItem from '@cccsaurora/howler-ui/commons/components/utils/hooks/useLocalStorageItem';
|
|
3
1
|
import { LocalStorageContext } from '@cccsaurora/howler-ui/components/app/providers/LocalStorageProvider';
|
|
4
2
|
import { useContext } from 'react';
|
|
5
3
|
import { MY_LOCAL_STORAGE_PREFIX } from '@cccsaurora/howler-ui/utils/constants';
|
|
4
|
+
import useLocalStorage from './useLocalStorage';
|
|
5
|
+
import useLocalStorageItem from './useLocalStorageItem';
|
|
6
6
|
const useMyLocalStorage = () => {
|
|
7
7
|
return useLocalStorage(MY_LOCAL_STORAGE_PREFIX);
|
|
8
8
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Api, Article, Book,
|
|
2
|
+
import { Api, Article, Book, Code, Dashboard, Description, ExitToApp, FormatListBulleted, Help, HelpCenter, Key, ManageSearch, QueryStats, SavedSearch, Search, Settings, SettingsSuggest, Shield, Storage, SupervisorAccount, Terminal, Topic } from '@mui/icons-material';
|
|
3
3
|
import { AppBrand } from '@cccsaurora/howler-ui/branding/AppBrand';
|
|
4
4
|
import Classification from '@cccsaurora/howler-ui/components/elements/display/Classification';
|
|
5
5
|
import DocumentationButton from '@cccsaurora/howler-ui/components/elements/display/DocumentationButton';
|
|
@@ -21,15 +21,6 @@ const useMyPreferences = () => {
|
|
|
21
21
|
icon: _jsx(Dashboard, {})
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
|
-
{
|
|
25
|
-
type: 'item',
|
|
26
|
-
element: {
|
|
27
|
-
id: 'cases',
|
|
28
|
-
i18nKey: 'route.cases',
|
|
29
|
-
route: '/cases',
|
|
30
|
-
icon: _jsx(BookRounded, {})
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
24
|
{
|
|
34
25
|
type: 'group',
|
|
35
26
|
element: {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Alert, Box, Typography } from '@mui/material';
|
|
3
3
|
import api from '@cccsaurora/howler-ui/api';
|
|
4
|
-
import
|
|
4
|
+
import HitQuickSearch from '@cccsaurora/howler-ui/components/elements/hit/HitQuickSearch';
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { Link, useNavigate } from 'react-router-dom';
|
|
@@ -40,7 +40,7 @@ const useMySearch = () => {
|
|
|
40
40
|
},
|
|
41
41
|
headerRenderer: (state) => (state.result?.error || !state.items) && (_jsx(Box, { sx: { p: 1, pb: 0, textAlign: 'center' }, children: state.result?.error ? (_jsx(Alert, { severity: "error", color: "error", children: t('hit.search.invalid') })) : ((!state.items || state.items.length === 0) && (_jsx(Typography, { sx: { mb: -1, color: 'text.secondary' }, children: t('hit.quicksearch') }))) })),
|
|
42
42
|
itemRenderer: (item, options) => {
|
|
43
|
-
return (_jsx(Link, { to: `/hits/${item.id}`, style: { flex: 1, textDecoration: 'none', color: 'inherit', overflow: 'hidden' }, children: _jsx(
|
|
43
|
+
return (_jsx(Link, { to: `/hits/${item.id}`, style: { flex: 1, textDecoration: 'none', color: 'inherit', overflow: 'hidden' }, children: _jsx(HitQuickSearch, { hit: item.item, options: options }) }));
|
|
44
44
|
}
|
|
45
45
|
}), [navigate, pageCount, t]);
|
|
46
46
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Article, Book,
|
|
2
|
+
import { Article, Book, Code, CreateNewFolder, Dashboard, Description, Edit, EditNote, FormatListBulleted, Help, Info, Key, Person, PersonSearch, QueryStats, SavedSearch, Search, Settings, SettingsSuggest, Shield, Storage, Terminal, Topic, Work } from '@mui/icons-material';
|
|
3
3
|
import howlerPluginStore from '@cccsaurora/howler-ui/plugins/store';
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
@@ -24,9 +24,6 @@ const useMySitemap = () => {
|
|
|
24
24
|
return useMemo(() => ({
|
|
25
25
|
routes: [
|
|
26
26
|
{ path: '/', title: t('route.home'), isRoot: true, icon: _jsx(Dashboard, {}) },
|
|
27
|
-
{ path: '/cases', title: t('route.cases'), isRoot: true, icon: _jsx(BookRounded, {}) },
|
|
28
|
-
{ path: '/cases/:id', title: t('route.cases.view'), breadcrumbs: ['/cases'] },
|
|
29
|
-
{ path: '/cases/:id/*', title: t('route.cases.view'), breadcrumbs: ['/cases'] },
|
|
30
27
|
{ path: '/admin/users', title: t('route.admin.user.search'), isRoot: true, icon: _jsx(PersonSearch, {}) },
|
|
31
28
|
{
|
|
32
29
|
path: '/admin/users/:id',
|
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
const DEFAULT_THEME = {
|
|
2
|
-
components: {
|
|
3
|
-
MuiChip: {
|
|
4
|
-
defaultProps: {
|
|
5
|
-
size: 'small'
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
},
|
|
9
2
|
palette: {
|
|
10
3
|
dark: {
|
|
11
4
|
background: {
|
|
12
|
-
default: '#
|
|
13
|
-
paper: '#
|
|
5
|
+
default: '#202020',
|
|
6
|
+
paper: '#202020'
|
|
14
7
|
},
|
|
15
8
|
primary: {
|
|
16
9
|
main: '#7DA1DB'
|
|
@@ -109,7 +109,7 @@ const ActionSearch = () => {
|
|
|
109
109
|
e.stopPropagation();
|
|
110
110
|
await deleteAction(item.item.action_id);
|
|
111
111
|
onSearch();
|
|
112
|
-
}, children: _jsx(Delete, {}) })), _jsx(HowlerAvatar, { sx: { width: 24, height: 24, marginRight: '8px !important' }, userId: item.item.owner_id })] }), subheader: item.item.query }), _jsx(CardContent, { sx: { paddingTop: 0 }, children: _jsx(Grid, { container: true, spacing: 1, children: item.item.operations.map(d => (_jsx(Grid, { item: true, children: _jsx(Chip, { label: t(`operations.${d.operation_id}`) }) }, d.operation_id))) }) })] }, item.item.name));
|
|
112
|
+
}, children: _jsx(Delete, {}) })), _jsx(HowlerAvatar, { sx: { width: 24, height: 24, marginRight: '8px !important' }, userId: item.item.owner_id })] }), subheader: item.item.query }), _jsx(CardContent, { sx: { paddingTop: 0 }, children: _jsx(Grid, { container: true, spacing: 1, children: item.item.operations.map(d => (_jsx(Grid, { item: true, children: _jsx(Chip, { size: "small", label: t(`operations.${d.operation_id}`) }) }, d.operation_id))) }) })] }, item.item.name));
|
|
113
113
|
}, [deleteAction, navigate, onSearch, t, user.roles, user.username]);
|
|
114
114
|
return (_jsx(ItemManager, { onSearch: onSearch, onCreate: () => navigate('/action/execute'), onPageChange: onPageChange, phrase: phrase, setPhrase: setPhrase, hasError: hasError, searching: searching, aboveSearch: _jsx(Typography, { sx: theme => ({ fontStyle: 'italic', color: theme.palette.text.disabled, mb: 0.5 }), variant: "body2", children: t('route.actions.search.prompt') }), searchFilters: _jsx(Autocomplete, { multiple: true, size: "small", value: searchModifiers, onChange: (__, values) => setSearchModifiers(values), getOptionLabel: trigger => t(`route.actions.trigger.${trigger}`), options: VALID_ACTION_TRIGGERS, renderInput: params => (_jsx(TextField, { ...params, sx: { maxWidth: '500px' }, label: t('route.actions.trigger') })) }), renderer: renderer, response: response, createPrompt: "route.actions.create", searchPrompt: "route.actions.search", createIcon: _jsx(Terminal, { sx: { mr: 1 } }) }));
|
|
115
115
|
};
|
|
@@ -233,7 +233,7 @@ const QueryBuilder = () => {
|
|
|
233
233
|
height: '100%',
|
|
234
234
|
'& .MuiFormControl-root': { height: '100%', '& > div': { height: '100%' } }
|
|
235
235
|
}
|
|
236
|
-
], slotProps: { paper: { sx: { minWidth: '600px' } } } }), _jsx(Card, { variant: "outlined", sx: { flex: 1, maxWidth: '350px', minWidth: '210px' }, children: _jsxs(Stack, { spacing: 0.5, sx: { px: 1, alignItems: 'start' }, children: [_jsxs(Typography, { variant: "caption", color: "text.secondary", sx: { whiteSpace: 'nowrap' }, children: [t('route.advanced.rows'), ": ", STEPS[rows]] }), _jsx(Slider, { size: "small", valueLabelDisplay: "off", value: rows, onChange: (_, value) => setRows(value), min: 0, max: 9, step: 1, marks: true, track: false, sx: { py: 0.5 } })] }) })] }), type === 'lucene' && (_jsx(Autocomplete, { size: "small", getOptionLabel: opt => t(`route.advanced.query.type.${opt}`), options: LUCENE_QUERY_OPTIONS, value: queryType, onChange: (_event, value) => setQueryType(value), renderInput: params => (_jsx(TextField, { ...params, label: t('route.advanced.query.lucene.type'), sx: { minWidth: '230px' } })), renderOption: (props, option) => (_jsx(ListItemText, { ...props, sx: { flexDirection: 'column', alignItems: 'start !important' }, primary: t(`route.advanced.query.type.${option}`), secondary: t(`route.advanced.query.type.${option}.description`) })) })), queryType === 'groupby' && (_jsx(Autocomplete, { size: "small", options: fieldOptions, value: groupByField, onChange: (__, value) => setGroupByField(value), renderInput: params => _jsx(TextField, { ...params, label: t('route.advanced.pivot.field') }), sx: { minWidth: '200px', '& label': { zIndex: 1200 } }, onKeyDown: onKeyDown, PopperComponent: CustomPopper })), allFields && queryType !== 'facet' ? (_jsx(FormControlLabel, { control: _jsx(Checkbox, { size: "small", checked: allFields, onChange: (__, checked) => setAllFields(checked) }), label: t('route.advanced.fields.all'), sx: { '& > span': { color: 'text.secondary' }, alignSelf: 'start' } })) : (_jsx(Autocomplete, { fullWidth: true, renderTags: values => values.length <= 3 ? (_jsx(Stack, { direction: "row", spacing: 0.5, children: values.map(_value => (_jsx(Chip, { label: _value }, _value))) })) : (_jsx(Tooltip, { title: _jsx(Stack, { spacing: 1, children: values.map(_value => (_jsx("span", { children: _value }, _value))) }), children: _jsx(Chip, { label: values.length }) })), multiple: true, size: "small", options: fieldOptions, value: fields, onChange: (__, values) => (values.length > 0 ? setFields(values) : setAllFields(true)), renderInput: params => _jsx(TextField, { ...params, label: t('route.advanced.fields') }), sx: { maxWidth: '500px', width: '20vw', minWidth: '200px', '& label': { zIndex: 1200 } }, onKeyDown: onKeyDown, PopperComponent: CustomPopper })), _jsx(FlexOne, {}), type === 'lucene' &&
|
|
236
|
+
], slotProps: { paper: { sx: { minWidth: '600px' } } } }), _jsx(Card, { variant: "outlined", sx: { flex: 1, maxWidth: '350px', minWidth: '210px' }, children: _jsxs(Stack, { spacing: 0.5, sx: { px: 1, alignItems: 'start' }, children: [_jsxs(Typography, { variant: "caption", color: "text.secondary", sx: { whiteSpace: 'nowrap' }, children: [t('route.advanced.rows'), ": ", STEPS[rows]] }), _jsx(Slider, { size: "small", valueLabelDisplay: "off", value: rows, onChange: (_, value) => setRows(value), min: 0, max: 9, step: 1, marks: true, track: false, sx: { py: 0.5 } })] }) })] }), type === 'lucene' && (_jsx(Autocomplete, { size: "small", getOptionLabel: opt => t(`route.advanced.query.type.${opt}`), options: LUCENE_QUERY_OPTIONS, value: queryType, onChange: (_event, value) => setQueryType(value), renderInput: params => (_jsx(TextField, { ...params, label: t('route.advanced.query.lucene.type'), sx: { minWidth: '230px' } })), renderOption: (props, option) => (_jsx(ListItemText, { ...props, sx: { flexDirection: 'column', alignItems: 'start !important' }, primary: t(`route.advanced.query.type.${option}`), secondary: t(`route.advanced.query.type.${option}.description`) })) })), queryType === 'groupby' && (_jsx(Autocomplete, { size: "small", options: fieldOptions, value: groupByField, onChange: (__, value) => setGroupByField(value), renderInput: params => _jsx(TextField, { ...params, label: t('route.advanced.pivot.field') }), sx: { minWidth: '200px', '& label': { zIndex: 1200 } }, onKeyDown: onKeyDown, PopperComponent: CustomPopper })), allFields && queryType !== 'facet' ? (_jsx(FormControlLabel, { control: _jsx(Checkbox, { size: "small", checked: allFields, onChange: (__, checked) => setAllFields(checked) }), label: t('route.advanced.fields.all'), sx: { '& > span': { color: 'text.secondary' }, alignSelf: 'start' } })) : (_jsx(Autocomplete, { fullWidth: true, renderTags: values => values.length <= 3 ? (_jsx(Stack, { direction: "row", spacing: 0.5, children: values.map(_value => (_jsx(Chip, { size: "small", label: _value }, _value))) })) : (_jsx(Tooltip, { title: _jsx(Stack, { spacing: 1, children: values.map(_value => (_jsx("span", { children: _value }, _value))) }), children: _jsx(Chip, { size: "small", label: values.length }) })), multiple: true, size: "small", options: fieldOptions, value: fields, onChange: (__, values) => (values.length > 0 ? setFields(values) : setAllFields(true)), renderInput: params => _jsx(TextField, { ...params, label: t('route.advanced.fields') }), sx: { maxWidth: '500px', width: '20vw', minWidth: '200px', '& label': { zIndex: 1200 } }, onKeyDown: onKeyDown, PopperComponent: CustomPopper })), _jsx(FlexOne, {}), type === 'lucene' &&
|
|
237
237
|
(smallButtons ? (_jsx(Tooltip, { title: t('route.advanced.open'), children: _jsx(IconButton, { color: "primary", sx: { alignSelf: 'center' }, component: Link, disabled: !response, to: `/hits?query=${sanitizeMultilineLucene(query).replaceAll('\n', ' ').trim()}`, children: _jsx(OpenInNew, { fontSize: "small" }) }) })) : (_jsx(CustomButton, { size: "small", variant: "outlined", startIcon: _jsx(OpenInNew, {}), component: Link, disabled: !response, ...{ to: `/hits?query=${sanitizeMultilineLucene(query).replaceAll('\n', ' ').trim()}` }, children: t('route.advanced.open') }))), smallButtons ? (_jsx(Tooltip, { title: response ? t('route.advanced.create.rule') : t('route.advanced.create.rule.disabled'), children: _jsx(IconButton, { size: "small", sx: { alignSelf: 'center' }, color: "info", onClick: onCreateRule, disabled: !response, children: _jsx(SsidChart, {}) }) })) : (_jsx(CustomButton, { size: "small", variant: "outlined", color: "info", startIcon: _jsx(SsidChart, {}), onClick: onCreateRule, disabled: !response, ...{ to: `/hits?query=${sanitizeMultilineLucene(query).replaceAll('\n', ' ').trim()}` }, tooltip: !response && t('route.advanced.create.rule.disabled'), children: t('route.advanced.create.rule') }))] }), _jsxs(Box, { width: "100%", height: "calc(100vh - 112px)", sx: { position: 'relative', overflow: 'hidden', borderTop: `thin solid ${theme.palette.divider}` }, children: [_jsx(Box, { sx: {
|
|
238
238
|
position: 'absolute',
|
|
239
239
|
top: 0,
|
|
@@ -51,7 +51,7 @@ const AnalyticDetails = () => {
|
|
|
51
51
|
_setFilter(detection);
|
|
52
52
|
}
|
|
53
53
|
}, [filter]);
|
|
54
|
-
const onOwnerChange = useCallback(async (
|
|
54
|
+
const onOwnerChange = useCallback(async (ownerId) => {
|
|
55
55
|
const result = await dispatchApi(api.analytic.owner.post(analytic.analytic_id, { username: ownerId }), {
|
|
56
56
|
throwError: true,
|
|
57
57
|
showError: true
|
|
@@ -108,7 +108,7 @@ const AnalyticDetails = () => {
|
|
|
108
108
|
marginTop: '0 !important',
|
|
109
109
|
marginLeft: `${theme.spacing(-1)} !important`,
|
|
110
110
|
marginRight: `${theme.spacing(-1)} !important`
|
|
111
|
-
},
|
|
111
|
+
}, userId: analytic?.owner, onChange: onOwnerChange, i18nLabel: "route.analytics.set.owner" })) : (_jsx(HowlerAvatar, { userId: analytic?.owner })), _jsx(Stack, { children: users[analytic?.owner] ? (_jsxs(_Fragment, { children: [_jsx(Typography, { variant: "body1", children: users[analytic?.owner].name }), _jsx(Typography, { component: "a", href: `mailto:${users[analytic?.owner].email}`, variant: "caption", color: "text.secondary", children: users[analytic?.owner].email })] })) : (_jsxs(_Fragment, { children: [_jsx(Skeleton, { variant: "text", width: "70px" }), _jsx(Skeleton, { variant: "text", width: "60px" })] })) })] })] }), filteredContributors.length > 0 && (_jsxs(Stack, { spacing: 1, children: [_jsx(Typography, { variant: "body1", color: "text.secondary", children: t('route.analytics.contributors') }), _jsx(Stack, { direction: "row", alignItems: "center", spacing: 1, children: filteredContributors.map(_user => (_jsx(HowlerAvatar, { userId: _user }, _user))) })] })), analytic?.rule_crontab && (_jsxs(Stack, { direction: "row", spacing: 1, children: [_jsxs(Stack, { spacing: 1, justifyContent: "space-between", children: [_jsx(Typography, { variant: "body1", color: "text.secondary", children: t('rule.interval') }), editingInterval ? (_jsxs(FormControl, { sx: { minWidth: '200px' }, children: [_jsx(InputLabel, { children: t('rule.interval') }), _jsx(Select, { size: "small", label: t('rule.interval'), onChange: event => setCrontab(event.target.value), value: crontab, children: RULE_INTERVALS.map(interval => (_jsx(MenuItem, { value: interval.crontab, children: t(interval.key) }, interval.key))) })] })) : (_jsx("code", { style: {
|
|
112
112
|
backgroundColor: theme.palette.background.paper,
|
|
113
113
|
padding: theme.spacing(0.5),
|
|
114
114
|
alignSelf: 'start',
|
|
@@ -128,7 +128,7 @@ const AnalyticSearchBase = () => {
|
|
|
128
128
|
padding: theme.spacing(0.5),
|
|
129
129
|
borderRadius: theme.shape.borderRadius,
|
|
130
130
|
border: `thin solid ${theme.palette.divider}`
|
|
131
|
-
}, children: item.item.rule_type })] })), _jsx(FlexOne, {}), _jsxs(Stack, { direction: "row", spacing: 1, sx: { mt: 1 }, children: [item.item.owner && _jsx(HowlerAvatar, { sx: { width: 24, height: 24 }, userId: item.item.owner }), filteredContributors.length > 0 && _jsx(Divider, { orientation: "vertical", flexItem: true }), _jsx(AvatarGroup, { children: filteredContributors.map(contributor => (_jsx(HowlerAvatar, { sx: { width: 24, height: 24 }, userId: contributor }, contributor))) })] }), _jsx(Tooltip, { title: t('button.pin'), children: _jsx(IconButton, { size: "small", onClick: e => onFavourite(e, item.item), children: appUser.user?.favourite_analytics?.includes(item.item.analytic_id) ? _jsx(Star, {}) : _jsx(StarBorder, {}) }) })] }) }), item.item.detections?.length > 0 && (_jsx(CardContent, { sx: { paddingTop: 0 }, children: _jsxs(Grid, { container: true, spacing: 0.5, sx: { marginTop: `${theme.spacing(-0.5)} !important` }, children: [item.item.detections.slice(0, 5).map(d => (_jsx(Grid, { item: true, children: _jsx(Chip, { variant: "outlined", label: d }) }, d))), item.item.detections.length > 5 && (_jsx(Grid, { item: true, children: _jsx(Tooltip, { title: _jsx(Stack, { children: item.item.detections.slice(5).map(d => (_jsx("span", { children: d }, d))) }), children: _jsx(Chip, { variant: "outlined", label: `+ ${item.item.detections.length - 5}` }) }) }))] }) }))] }, item.item.name));
|
|
131
|
+
}, children: item.item.rule_type })] })), _jsx(FlexOne, {}), _jsxs(Stack, { direction: "row", spacing: 1, sx: { mt: 1 }, children: [item.item.owner && _jsx(HowlerAvatar, { sx: { width: 24, height: 24 }, userId: item.item.owner }), filteredContributors.length > 0 && _jsx(Divider, { orientation: "vertical", flexItem: true }), _jsx(AvatarGroup, { children: filteredContributors.map(contributor => (_jsx(HowlerAvatar, { sx: { width: 24, height: 24 }, userId: contributor }, contributor))) })] }), _jsx(Tooltip, { title: t('button.pin'), children: _jsx(IconButton, { size: "small", onClick: e => onFavourite(e, item.item), children: appUser.user?.favourite_analytics?.includes(item.item.analytic_id) ? _jsx(Star, {}) : _jsx(StarBorder, {}) }) })] }) }), item.item.detections?.length > 0 && (_jsx(CardContent, { sx: { paddingTop: 0 }, children: _jsxs(Grid, { container: true, spacing: 0.5, sx: { marginTop: `${theme.spacing(-0.5)} !important` }, children: [item.item.detections.slice(0, 5).map(d => (_jsx(Grid, { item: true, children: _jsx(Chip, { size: "small", variant: "outlined", label: d }) }, d))), item.item.detections.length > 5 && (_jsx(Grid, { item: true, children: _jsx(Tooltip, { title: _jsx(Stack, { children: item.item.detections.slice(5).map(d => (_jsx("span", { children: d }, d))) }), children: _jsx(Chip, { size: "small", variant: "outlined", label: `+ ${item.item.detections.length - 5}` }) }) }))] }) }))] }, item.item.name));
|
|
132
132
|
}, [appUser.user?.favourite_analytics, navigate, onFavourite, t, theme]);
|
|
133
133
|
return (_jsx(ItemManager, { onSearch: onSearch, onPageChange: onPageChange, phrase: phrase, setPhrase: setPhrase, hasError: hasError, searching: searching, searchAdornment: _jsx(InputAdornment, { position: "end", children: _jsx(Tooltip, { title: t(`route.analytics.search.filter.rules.${onlyRules < 0 ? 'hide' : onlyRules > 0 ? 'show' : 'toggle'}`), children: _jsx(IconButton, { onClick: () => setOnlyRules((((onlyRules + 2) % 3) - 1)), children: _jsx(SsidChart, { color: onlyRules < 0 ? 'error' : onlyRules > 0 ? 'info' : 'inherit', sx: { transition: theme.transitions.create(['color']) } }) }) }) }), aboveSearch: _jsx(Typography, { sx: { fontStyle: 'italic', color: theme.palette.text.disabled, mb: 0.5 }, variant: "body2", children: t('route.analytics.search.prompt') }), renderer: renderer, response: response, searchPrompt: "route.analytics.manager.search" }));
|
|
134
134
|
};
|
|
@@ -49,7 +49,7 @@ const ApiDocumentation = () => {
|
|
|
49
49
|
.replace(/(\S+)\s+=>\s+(.+)/g, '\n`$1`: $2\n')
|
|
50
50
|
.replace(/(Data Block:\n)([\s\S]+)(Result Example:)/, (__, p1, p2, p3) => `${p1}\`\`\`\n${p2.trim()}\n\`\`\`\n${p3}`)
|
|
51
51
|
.replace(/(Result Example:\n)([\s\S]+)$/, (__, p1, p2) => `${p1}\`\`\`\n${p2.trim()}\n\`\`\``) }));
|
|
52
|
-
return (_jsxs(Fragment, { children: [_jsxs(TableRow, { style: { marginBottom: '1rem' }, sx: [isLg && { '& > td': { borderBottom: 0 } }], children: [_jsx(TableCell, { children: _jsxs(Stack, { direction: "column", spacing: 1, alignItems: "start", children: [_jsx(Typography, { children: endpoint.name }), _jsx("code", { children: endpoint.path }), _jsxs(Stack, { direction: "row", spacing: 1, children: [endpoint.complete ? (_jsx(Chip, { label: "Stable", color: "success" })) : (_jsx(Chip, { label: "Unstable", color: "error" })), endpoint.protected ? (_jsx(Chip, { label: "Protected", color: "warning" })) : (_jsx(Chip, { label: "Unprotected" }))] }), _jsx(Stack, { spacing: 1, direction: "row", children: endpoint.methods.map(m => (_jsx(Chip, { size: "small", label: m }, m))) }), endpoint.ui_only && _jsx(Chip, { label: "UI Only" })] }) }), _jsx(TableCell, { children: _jsx(Stack, { spacing: 1, direction: "row", children: endpoint.required_type.map(type => (_jsx(Chip, { size: "small", label: type, color: user.roles?.includes(type) ? 'success' : 'default' }, type))) }) }), _jsx(TableCell, { children: _jsx(Stack, { spacing: 1, direction: "row", children: endpoint.required_priv.map((p) => (_jsx(Chip, { size: "small", label: t(APIKEY_LABELS[p]) }, p))) }) }), !isLg && _jsx(TableCell, { children: documentationCell })] }), isLg && (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, sx: { '& pre': { whiteSpace: 'pre-wrap' } }, children: documentationCell }) }))] }, endpoint.id));
|
|
52
|
+
return (_jsxs(Fragment, { children: [_jsxs(TableRow, { style: { marginBottom: '1rem' }, sx: [isLg && { '& > td': { borderBottom: 0 } }], children: [_jsx(TableCell, { children: _jsxs(Stack, { direction: "column", spacing: 1, alignItems: "start", children: [_jsx(Typography, { children: endpoint.name }), _jsx("code", { children: endpoint.path }), _jsxs(Stack, { direction: "row", spacing: 1, children: [endpoint.complete ? (_jsx(Chip, { size: "small", label: "Stable", color: "success" })) : (_jsx(Chip, { size: "small", label: "Unstable", color: "error" })), endpoint.protected ? (_jsx(Chip, { size: "small", label: "Protected", color: "warning" })) : (_jsx(Chip, { size: "small", label: "Unprotected" }))] }), _jsx(Stack, { spacing: 1, direction: "row", children: endpoint.methods.map(m => (_jsx(Chip, { size: "small", label: m }, m))) }), endpoint.ui_only && _jsx(Chip, { size: "small", label: "UI Only" })] }) }), _jsx(TableCell, { children: _jsx(Stack, { spacing: 1, direction: "row", children: endpoint.required_type.map(type => (_jsx(Chip, { size: "small", label: type, color: user.roles?.includes(type) ? 'success' : 'default' }, type))) }) }), _jsx(TableCell, { children: _jsx(Stack, { spacing: 1, direction: "row", children: endpoint.required_priv.map((p) => (_jsx(Chip, { size: "small", label: t(APIKEY_LABELS[p]) }, p))) }) }), !isLg && _jsx(TableCell, { children: documentationCell })] }), isLg && (_jsx(TableRow, { children: _jsx(TableCell, { colSpan: 3, sx: { '& pre': { whiteSpace: 'pre-wrap' } }, children: documentationCell }) }))] }, endpoint.id));
|
|
53
53
|
}) })] }) })] }) }));
|
|
54
54
|
};
|
|
55
55
|
export default ApiDocumentation;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Markdown from '@cccsaurora/howler-ui/components/elements/display/Markdown';
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import BUNDLES_EN from './markdown/en/bundles.md';
|
|
6
|
+
import BUNDLES_FR from './markdown/fr/bundles.md';
|
|
7
|
+
const BundleDocumentation = () => {
|
|
8
|
+
const { i18n } = useTranslation();
|
|
9
|
+
const md = useMemo(() => (i18n.language === 'en' ? BUNDLES_EN : BUNDLES_FR), [i18n.language]);
|
|
10
|
+
return _jsx(Markdown, { md: md });
|
|
11
|
+
};
|
|
12
|
+
export default BundleDocumentation;
|
|
@@ -5,6 +5,7 @@ import { useScrollRestoration } from '@cccsaurora/howler-ui/components/hooks/use
|
|
|
5
5
|
import { useCallback, useState } from 'react';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
7
|
import { useSearchParams } from 'react-router-dom';
|
|
8
|
+
import BundleDocumentation from './BundleDocumentation';
|
|
8
9
|
import HelpTabs from './components/HelpTabs';
|
|
9
10
|
import HitBannerDocumentation from './HitBannerDocumentation';
|
|
10
11
|
import HitLabelsDocumentation from './HitLabelsDocumentation';
|
|
@@ -22,7 +23,8 @@ const HitDocumentation = () => {
|
|
|
22
23
|
searchParams.set('tab', _tab);
|
|
23
24
|
setSearchParams(new URLSearchParams(searchParams));
|
|
24
25
|
}, [searchParams, setSearchParams]);
|
|
25
|
-
return (_jsx(PageCenter, { margin: 4, width: "100%", maxWidth: "1750px", textAlign: "left", children: _jsxs(Stack, { sx: { flexDirection: useHorizontal ? 'column' : 'row', '& h1': { mt: 0 } }, children: [_jsxs(HelpTabs, { value: tab, children: [_jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.schema.title') }), value: "schema", onClick: () => onChange('schema') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.banner.title') }), value: "header", onClick: () => onChange('header') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.links.title') }), value: "links", onClick: () => onChange('links') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.labels.title') }), value: "labels", onClick: () => onChange('labels') })] }), _jsx(Box, { children: {
|
|
26
|
+
return (_jsx(PageCenter, { margin: 4, width: "100%", maxWidth: "1750px", textAlign: "left", children: _jsxs(Stack, { sx: { flexDirection: useHorizontal ? 'column' : 'row', '& h1': { mt: 0 } }, children: [_jsxs(HelpTabs, { value: tab, children: [_jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.schema.title') }), value: "schema", onClick: () => onChange('schema') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.banner.title') }), value: "header", onClick: () => onChange('header') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.bundle.title') }), value: "bundle", onClick: () => onChange('bundle') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.links.title') }), value: "links", onClick: () => onChange('links') }), _jsx(Tab, { label: _jsx(Typography, { variant: "caption", children: t('help.hit.labels.title') }), value: "labels", onClick: () => onChange('labels') })] }), _jsx(Box, { children: {
|
|
27
|
+
bundle: () => _jsx(BundleDocumentation, {}),
|
|
26
28
|
header: () => _jsx(HitBannerDocumentation, {}),
|
|
27
29
|
links: () => _jsx(HitLinksDocumentation, {}),
|
|
28
30
|
labels: () => _jsx(HitLabelsDocumentation, {}),
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default "<!-- docs/ingestion/bundles.md -->\n\n# Howler Hit Bundles\n\nHit bundles can be used to easily package together a large number of similar alerts, allowing analysts to easily triage them as a single incident. For example, consider a single computer that repeatedly makes a network call to `baddomain.ru` - while an alert may be generated for every instance of this computer hitting that domain, it makes sense for analysts to treat all these alerts as a single case.\n\n## Creating bundles through the Howler Client\n\nThere are a couple of ways to create a bundle through the howler client:\n\n```python\nfrom howler_client import get_client\n\nhowler = get_client(\"https://howler.dev.analysis.cyber.gc.ca\")\n\n\"\"\"Creating a howler bundle and the hits at the same time\"\"\"\nhowler.bundle.create(\n # First argument is the bundle hit\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n },\n # Second argument is a hit or list of hits to include in the bundle\n [\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n },\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n }\n ]\n)\n\n\"\"\"Creating a howler bundle from existing hits\"\"\"\nhowler.bundle.create(\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0,\n \"howler.hits\": [\"YcUsL8QsjmwwIdstieROk\", \"6s7MztwuSvz6tM0PgGJhvz\"]\n },\n # Note: In future releases, you won't need to include this argument\n []\n)\n\n\n\"\"\"Creating from a map\"\"\"\nbundle_hit = {\n \"score\": 0,\n \"bundle\": True\n}\n\nmap = {\n \"score\": [\"howler.score\"],\n \"bundle\": [\"howler.is_bundle\"]\n}\n\nhowler.bundle.create_from_map(\"example-test\", bundle_hit, map, [{\"score\": 0}])\n```\n\n## Viewing bundles on the Howler UI\n\nIn order to view created bundles on the Howler UI, you can use the query `howler.is_bundle:true`. This will provide a list of created bundles you can look through.\n\nClicking on a bundle will open up a slightly different search UI to normal. In this case, we automatically filter the search results to include only hits that are included in the bundle. To make this obvious, the header representing the bundle will appear above the search bar.\n\nYou can continue to filter through hits using the same queries as usual, and view them as usual. When triaging a bundle, assessing it will apply this assessment to all hits in the bundle, **except those that have already been triaged**. That is, if the bundle is open, all open hits will be assessed when you assess it.\n\nBundles also have a **Summary** tab not available for regular hits. This summary tab will aid you in aggregating data about all the hits in the bundle. Simply open the tab and click \"Create Summary\". Note that this may take some time, as a large number of queries are being run to aggregate the data.\n"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default "<!-- docs/ingestion/bundles.fr.md -->\n\n# Les groupes des hits Howler\n\nLes groupes des hits peuvent \u00eatre utilis\u00e9s pour regrouper facilement un grand nombre d'alertes similaires, ce qui permet aux analystes de les traiter comme un seul incident. Prenons l'exemple d'un ordinateur qui effectue \u00e0 plusieurs reprises un appel r\u00e9seau vers `baddomain.ru` - bien qu'une alerte puisse \u00eatre g\u00e9n\u00e9r\u00e9e pour chaque cas o\u00f9 cet ordinateur acc\u00e8de \u00e0 ce domaine, il est logique que les analystes traitent toutes ces alertes comme un seul et m\u00eame cas.\n\n## Cr\u00e9ation de groupes via le client Howler\n\nIl y a plusieurs fa\u00e7ons de cr\u00e9er un groupe via le client Howler:\n\n```python\nfrom howler_client import get_client\n\nhowler = get_client(\"https://howler.dev.analysis.cyber.gc.ca\")\n\n\"\"\"Cr\u00e9ation simultan\u00e9e d'un groupe howler et de hits\"\"\"\nhowler.bundle.create(\n # Le premier argument est le hit de l'offre group\u00e9e\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n },\n # Le deuxi\u00e8me argument est un hit ou une liste de hits \u00e0 inclure dans l'offre group\u00e9e.\n [\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n },\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0\n }\n ]\n)\n\n\"\"\"Cr\u00e9ation d'un groupe howler \u00e0 partir de hits existants\"\"\"\nhowler.bundle.create(\n {\n \"howler.analytic\": \"example-test\",\n \"howler.score\": 0,\n \"howler.hits\": [\"YcUsL8QsjmwwIdstieROk\", \"6s7MztwuSvz6tM0PgGJhvz\"]\n },\n # Noter: Dans les prochaines versions, vous n'aurez plus besoin d'inclure cet argument.\n []\n)\n\n\n\"\"\"Cr\u00e9ation \u00e0 partir d'une carte\"\"\"\nbundle_hit = {\n \"score\": 0,\n \"bundle\": True\n}\n\nmap = {\n \"score\": [\"howler.score\"],\n \"bundle\": [\"howler.is_bundle\"]\n}\n\nhowler.bundle.create_from_map(\"example-test\", bundle_hit, map, [{\"score\": 0}])\n```\n\n## Visualiser les groupes sur l'interface utilisateur de Howler\n\nAfin de visualiser les groupes cr\u00e9\u00e9s sur l'interface utilisateur de Howler, vous pouvez utiliser la requ\u00eate `howler.is_bundle:true`. Cela fournira une liste de groupes cr\u00e9\u00e9s que vous pourrez consulter.\n\nEn cliquant sur un groupe, vous ouvrirez une interface de recherche l\u00e9g\u00e8rement diff\u00e9rente de l'interface normale. Dans ce cas, nous filtrons automatiquement les r\u00e9sultats de la recherche pour n'inclure que les r\u00e9sultats inclus dans le groupe. Pour que cela soit \u00e9vident, l'en-t\u00eate repr\u00e9sentant le groupe appara\u00eet au-dessus de la barre de recherche.\n\nVous pouvez continuer \u00e0 filtrer les r\u00e9sultats en utilisant les m\u00eames requ\u00eates que d'habitude et \u00e0 les visualiser comme d'habitude. Lors du triage d'un groupe, son \u00e9valuation s'appliquera \u00e0 tous les hits du groupe, **sauf ceux qui ont d\u00e9j\u00e0 \u00e9t\u00e9 tri\u00e9s**. En d'autres termes, si le groupe est ouvert, tous les hits ouverts seront \u00e9valu\u00e9s lorsque vous l'\u00e9valuerez.\n\nLes groupes disposent \u00e9galement d'un onglet **R\u00e9sum\u00e9** qui n'est pas disponible pour les hits ordinaires. Cet onglet vous aidera \u00e0 regrouper les donn\u00e9es relatives \u00e0 tous les r\u00e9sultats du groupe. Il suffit d'ouvrir l'onglet et de cliquer sur \"Cr\u00e9er un sommaire\". Notez que cette op\u00e9ration peut prendre un certain temps, car un grand nombre de requ\u00eates sont ex\u00e9cut\u00e9es pour agr\u00e9ger les donn\u00e9es.\n"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AccountTree } from '@mui/icons-material';
|
|
3
|
+
import { IconButton, Paper, Popover, Skeleton, Stack, Tooltip } from '@mui/material';
|
|
4
|
+
import api from '@cccsaurora/howler-ui/api';
|
|
5
|
+
import HowlerCard from '@cccsaurora/howler-ui/components/elements/display/HowlerCard';
|
|
6
|
+
import HitBanner from '@cccsaurora/howler-ui/components/elements/hit/HitBanner';
|
|
7
|
+
import { HitLayout } from '@cccsaurora/howler-ui/components/elements/hit/HitLayout';
|
|
8
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
9
|
+
import { useTranslation } from 'react-i18next';
|
|
10
|
+
import { useNavigate } from 'react-router-dom';
|
|
11
|
+
const BundleParentMenu = ({ bundle }) => {
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
const [parentAnchor, setParentAnchor] = useState(null);
|
|
15
|
+
const [parentHits, setParentHits] = useState([]);
|
|
16
|
+
const onSelect = useCallback((bundleId) => {
|
|
17
|
+
navigate(`/bundles/${bundleId}?span=date.range.all&query=howler.id%3A*`);
|
|
18
|
+
setParentAnchor(null);
|
|
19
|
+
}, [navigate]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (!parentAnchor) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
api.search.hit
|
|
25
|
+
.post({ query: `howler.id:(${bundle.howler.bundles.join(' OR ')})` })
|
|
26
|
+
.then(response => setParentHits(response.items));
|
|
27
|
+
}, [bundle.howler.bundles, parentAnchor]);
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsx(Tooltip, { title: t('hit.bundle.parents.show'), children: _jsx(IconButton, { size: "small", onClick: event => setParentAnchor(event.currentTarget), children: _jsx(AccountTree, { fontSize: "small" }) }) }), _jsx(Popover, { open: !!parentAnchor, anchorEl: parentAnchor, anchorOrigin: { vertical: 'top', horizontal: 'left' }, transformOrigin: { horizontal: 'right', vertical: 'top' }, onClose: () => setParentAnchor(null), children: _jsx(Paper, { sx: { p: 1, minWidth: '750px' }, children: _jsx(Stack, { spacing: 1, children: parentHits.length < 1
|
|
29
|
+
? bundle.howler.bundles.map(id => _jsx(Skeleton, { variant: "rounded", height: "100px" }, id))
|
|
30
|
+
: parentHits.map(parent => (_jsx(HowlerCard, { sx: { p: 1, cursor: 'pointer' }, onClick: () => onSelect(parent.howler.id), children: _jsx(HitBanner, { hit: parent, layout: HitLayout.DENSE }) }, parent.howler.id))) }) }) })] }));
|
|
31
|
+
};
|
|
32
|
+
export default BundleParentMenu;
|
|
@@ -170,10 +170,9 @@ const HitContextMenu = ({ children, getSelectedId, Component = Box }) => {
|
|
|
170
170
|
sx: {
|
|
171
171
|
...transformProps,
|
|
172
172
|
overflow: 'visible !important'
|
|
173
|
-
}
|
|
174
|
-
elevation: 2
|
|
173
|
+
}
|
|
175
174
|
}
|
|
176
|
-
}, MenuListProps: { dense: true, sx: { minWidth: '250px' } }, anchorOrigin: { vertical: 'top', horizontal: 'left' }, onClick: () => setAnchorEl(null), children: [_jsxs(MenuItem, { component: Link, to: `/hits/${hit?.howler.id}`, disabled: !hit, children: [_jsx(ListItemIcon, { children: _jsx(OpenInNew, {}) }), _jsx(ListItemText, { children: t('hit.panel.open') })] }), _jsxs(MenuItem, { component: Link, to: `/analytics/${analytic?.analytic_id}`, disabled: !analytic, children: [_jsx(ListItemIcon, { children: _jsx(QueryStats, {}) }), _jsx(ListItemText, { children: t('hit.panel.analytic.open') })] }), _jsx(Divider, {}), entries.map(([type, items]) => (_jsxs(MenuItem, { id: `${type}-menu-item`, sx: { position: 'relative' }, onMouseEnter: ev => setShow(_show => ({ ..._show, [type]: ev.target })), onMouseLeave: () => setShow(_show => ({ ..._show, [type]: null })), disabled: rowStatus[type] === false, children: [_jsx(ListItemIcon, { children: ICON_MAP[type] ?? _jsx(Terminal, {}) }), _jsx(ListItemText, { sx: { flex: 1 }, children: t(`hit.details.actions.${type}`) }), rowStatus[type] !== false && (_jsx(KeyboardArrowRight, { fontSize: "small", sx: { color: 'text.secondary', mr: -1 } })), _jsx(Fade, { in: !!show[type], unmountOnExit: true, children: _jsx(Paper, { id: `${type}-submenu`, sx: calculateSubMenuStyles(show[type]), elevation:
|
|
175
|
+
}, MenuListProps: { dense: true, sx: { minWidth: '250px' } }, anchorOrigin: { vertical: 'top', horizontal: 'left' }, onClick: () => setAnchorEl(null), children: [_jsxs(MenuItem, { component: Link, to: `/hits/${hit?.howler.id}`, disabled: !hit, children: [_jsx(ListItemIcon, { children: _jsx(OpenInNew, {}) }), _jsx(ListItemText, { children: t('hit.panel.open') })] }), _jsxs(MenuItem, { component: Link, to: `/analytics/${analytic?.analytic_id}`, disabled: !analytic, children: [_jsx(ListItemIcon, { children: _jsx(QueryStats, {}) }), _jsx(ListItemText, { children: t('hit.panel.analytic.open') })] }), _jsx(Divider, {}), entries.map(([type, items]) => (_jsxs(MenuItem, { id: `${type}-menu-item`, sx: { position: 'relative' }, onMouseEnter: ev => setShow(_show => ({ ..._show, [type]: ev.target })), onMouseLeave: () => setShow(_show => ({ ..._show, [type]: null })), disabled: rowStatus[type] === false, children: [_jsx(ListItemIcon, { children: ICON_MAP[type] ?? _jsx(Terminal, {}) }), _jsx(ListItemText, { sx: { flex: 1 }, children: t(`hit.details.actions.${type}`) }), rowStatus[type] !== false && (_jsx(KeyboardArrowRight, { fontSize: "small", sx: { color: 'text.secondary', mr: -1 } })), _jsx(Fade, { in: !!show[type], unmountOnExit: true, children: _jsx(Paper, { id: `${type}-submenu`, sx: calculateSubMenuStyles(show[type]), elevation: 8, children: _jsx(MenuList, { sx: { p: 0, borderTopLeftRadius: 0 }, dense: true, role: "group", children: items.map(a => (_jsx(MenuItem, { value: a.name, onClick: a.actionFunction, children: a.i18nKey ? t(a.i18nKey) : capitalize(a.name) }, a.name))) }) }) })] }, type))), _jsxs(MenuItem, { id: "actions-menu-item", sx: { position: 'relative' }, onMouseEnter: ev => setShow(_show => ({ ..._show, actions: ev.target })), onMouseLeave: () => setShow(_show => ({ ..._show, actions: null })), disabled: actions.length < 1, children: [_jsx(ListItemIcon, { children: _jsx(SettingsSuggest, {}) }), _jsx(ListItemText, { sx: { flex: 1 }, children: t('route.actions.change') }), actions.length > 0 && _jsx(KeyboardArrowRight, { fontSize: "small", sx: { color: 'text.secondary', mr: -1 } }), _jsx(Fade, { in: !!show.actions, unmountOnExit: true, children: _jsx(Paper, { id: "actions-submenu", sx: calculateSubMenuStyles(show.actions), elevation: 8, children: _jsx(MenuList, { sx: { p: 0 }, dense: true, role: "group", children: actions.map(action => (_jsx(MenuItem, { onClick: () => executeAction(action.action_id, `howler.id:${hit?.howler.id}`), children: _jsx(ListItemText, { children: action.name }) }, action.action_id))) }) }) })] }), !isEmpty(template?.keys ?? []) && setQuery && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsxs(MenuItem, { id: "excludes-menu-item", sx: { position: 'relative' }, onMouseEnter: ev => setShow(_show => ({ ..._show, excludes: ev.target })), onMouseLeave: () => setShow(_show => ({ ..._show, excludes: null })), children: [_jsx(ListItemIcon, { children: _jsx(RemoveCircleOutline, {}) }), _jsx(ListItemText, { sx: { flex: 1 }, children: t('hit.panel.exclude') }), _jsx(KeyboardArrowRight, { fontSize: "small", sx: { color: 'text.secondary', mr: -1 } }), _jsx(Fade, { in: !!show.excludes, unmountOnExit: true, children: _jsx(Paper, { id: "excludes-submenu", sx: calculateSubMenuStyles(show.excludes), elevation: 8, children: _jsx(MenuList, { sx: { p: 0 }, dense: true, role: "group", children: template?.keys.map(key => {
|
|
177
176
|
// Build exclusion query based on current query and field value
|
|
178
177
|
let newQuery = '';
|
|
179
178
|
if (query !== DEFAULT_QUERY) {
|