@parca/profile 0.19.140 → 0.19.143
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/CHANGELOG.md +9 -1
- package/dist/GraphTooltipArrow/Content.js +224 -30
- package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
- package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
- package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/index.js +86 -56
- package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +94 -68
- package/dist/MatchersInput/SuggestionItem.js +91 -12
- package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
- package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
- package/dist/MatchersInput/SuggestionsList.js +371 -157
- package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
- package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
- package/dist/MatchersInput/index.js +308 -115
- package/dist/MetricsCircle/index.js +39 -3
- package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
- package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
- package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
- package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
- package/dist/MetricsGraph/index.js +552 -203
- package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
- package/dist/MetricsGraph/utils/colorMapping.js +24 -17
- package/dist/MetricsSeries/index.js +70 -7
- package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
- package/dist/PreSelectedMatchers/index.js +249 -102
- package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
- package/dist/ProfileExplorer/ProfileExplorerCompare.js +240 -45
- package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
- package/dist/ProfileExplorer/index.js +183 -32
- package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
- package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
- package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
- package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
- package/dist/ProfileFlameChart/index.js +260 -126
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +283 -85
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
- package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
- package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +71 -45
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
- package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
- package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
- package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
- package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
- package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
- package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
- package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
- package/dist/ProfileFlameGraph/index.js +322 -147
- package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
- package/dist/ProfileMetricsGraph/index.js +515 -256
- package/dist/ProfileSelector/CompareButton.js +132 -12
- package/dist/ProfileSelector/MetricsGraphSection.js +228 -63
- package/dist/ProfileSelector/index.d.ts +1 -1
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +734 -142
- package/dist/ProfileSelector/useAutoQuerySelector.d.ts +1 -3
- package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
- package/dist/ProfileSelector/useAutoQuerySelector.js +280 -132
- package/dist/ProfileSource.js +230 -163
- package/dist/ProfileTypeSelector/index.js +214 -125
- package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +137 -32
- package/dist/ProfileView/components/ColorStackLegend.js +182 -54
- package/dist/ProfileView/components/DashboardItems/index.js +87 -28
- package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
- package/dist/ProfileView/components/DiffLegend.js +172 -29
- package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
- package/dist/ProfileView/components/InvertCallStack/index.js +97 -9
- package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
- package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
- package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +191 -118
- package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
- package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
- package/dist/ProfileView/components/ShareButton/index.js +352 -62
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +664 -192
- package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +196 -155
- package/dist/ProfileView/components/Toolbars/index.js +441 -21
- package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
- package/dist/ProfileView/components/ViewSelector/index.js +186 -82
- package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
- package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
- package/dist/ProfileView/components/VisualizationPanel.js +185 -8
- package/dist/ProfileView/context/DashboardContext.js +74 -26
- package/dist/ProfileView/context/ProfileViewContext.js +56 -15
- package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
- package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
- package/dist/ProfileView/hooks/useResetFlameGraphState.js +31 -10
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +53 -17
- package/dist/ProfileView/hooks/useVisualizationState.js +229 -69
- package/dist/ProfileView/index.js +383 -45
- package/dist/ProfileView/types/visualization.js +1 -13
- package/dist/ProfileView/utils/colorUtils.js +8 -7
- package/dist/ProfileViewWithData.js +319 -225
- package/dist/QueryControls/index.js +418 -47
- package/dist/Sandwich/components/CalleesSection.js +54 -4
- package/dist/Sandwich/components/CallersSection.js +97 -27
- package/dist/Sandwich/components/TableSection.js +77 -4
- package/dist/Sandwich/index.js +125 -12
- package/dist/Sandwich/utils/processRowData.js +48 -39
- package/dist/SelectWithRefresh/index.js +102 -28
- package/dist/SimpleMatchers/Select.js +520 -187
- package/dist/SimpleMatchers/index.js +590 -288
- package/dist/SourceView/Highlighter.js +230 -70
- package/dist/SourceView/LineNo.js +72 -17
- package/dist/SourceView/index.js +177 -101
- package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
- package/dist/SourceView/lang-detector/index.js +28 -14
- package/dist/SourceView/useSelectedLineRange.js +72 -20
- package/dist/Table/ColorCell.js +42 -1
- package/dist/Table/ColumnsVisibility.js +114 -6
- package/dist/Table/MoreDropdown.js +107 -21
- package/dist/Table/TableContextMenu.js +144 -134
- package/dist/Table/TableContextMenuWrapper.js +59 -14
- package/dist/Table/hooks/useColorManagement.js +58 -16
- package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
- package/dist/Table/hooks/useTableConfiguration.js +323 -167
- package/dist/Table/index.js +217 -123
- package/dist/Table/utils/functions.js +169 -144
- package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
- package/dist/TimelineGuide/index.js +209 -16
- package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
- package/dist/TopTable/index.js +325 -121
- package/dist/contexts/LabelsQueryProvider.js +94 -32
- package/dist/contexts/UnifiedLabelsContext.js +114 -49
- package/dist/contexts/utils.js +37 -15
- package/dist/hooks/urlParsers.js +27 -15
- package/dist/hooks/useColorBy.js +47 -10
- package/dist/hooks/useCompareModeMeta.js +112 -62
- package/dist/hooks/useDashboardItems.js +52 -11
- package/dist/hooks/useLabels.js +295 -52
- package/dist/hooks/useQueryState.d.ts +1 -1
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +375 -329
- package/dist/index.js +11 -6
- package/dist/testdata/fg-diff.json +3750 -0
- package/dist/testdata/fg-simple.json +1879 -0
- package/dist/testdata/link_data.json +56 -0
- package/dist/testdata/tabular.json +30 -0
- package/dist/testdata/test_flamegraph.json +26846 -0
- package/dist/testdata/test_graph.json +53 -0
- package/dist/useDelayedLoader.js +32 -18
- package/dist/useGrpcQuery/index.js +71 -11
- package/dist/useHasProfileData.js +90 -12
- package/dist/useQuery.js +205 -64
- package/dist/useSumBy.d.ts.map +1 -1
- package/dist/useSumBy.js +294 -138
- package/dist/utils.js +62 -30
- package/package.json +9 -9
- package/src/GraphTooltipArrow/index.tsx +3 -0
- package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
- package/src/MatchersInput/SuggestionsList.tsx +11 -10
- package/src/MatchersInput/index.tsx +1 -1
- package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
- package/src/PreSelectedMatchers/index.tsx +3 -0
- package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -2
- package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
- package/src/ProfileSelector/index.tsx +31 -9
- package/src/ProfileSelector/useAutoQuerySelector.ts +64 -42
- package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +3 -0
- package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
- package/src/Table/hooks/useTableConfiguration.tsx +7 -13
- package/src/hooks/useQueryState.ts +18 -3
- package/src/useDelayedLoader.ts +10 -10
- package/src/useSumBy.ts +12 -18
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
- package/dist/hooks/useQueryState.test.js +0 -868
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
10
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
1
13
|
// Copyright 2022 The Parca Authors
|
|
2
14
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
15
|
// you may not use this file except in compliance with the License.
|
|
@@ -10,7 +22,8 @@
|
|
|
10
22
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
23
|
// See the License for the specific language governing permissions and
|
|
12
24
|
// limitations under the License.
|
|
13
|
-
|
|
25
|
+
|
|
26
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
14
27
|
import { useQueryState as useNuqsQueryState, useQueryStates } from 'nuqs';
|
|
15
28
|
import { DateTimeRange, useParcaContext } from '@parca/components';
|
|
16
29
|
import { Query } from '@parca/parser';
|
|
@@ -19,333 +32,366 @@ import { useResetFlameGraphState } from '../ProfileView/hooks/useResetFlameGraph
|
|
|
19
32
|
import { useResetStateOnProfileTypeChange } from '../ProfileView/hooks/useResetStateOnProfileTypeChange';
|
|
20
33
|
import { DEFAULT_EMPTY_SUM_BY, sumByToParam, useSumBy, useSumByFromParams } from '../useSumBy';
|
|
21
34
|
import { commaArrayParam, stringParam } from './urlParsers';
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
export var useQueryState = function useQueryState() {
|
|
36
|
+
var _queryParams$expressi, _queryParams$from, _queryParams$to, _queryParams$time_sel, _ref, _ref2;
|
|
37
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
38
|
+
var _useParcaContext = useParcaContext(),
|
|
39
|
+
queryClient = _useParcaContext.queryServiceClient;
|
|
40
|
+
var _options$suffix = options.suffix,
|
|
41
|
+
suffix = _options$suffix === void 0 ? '' : _options$suffix,
|
|
42
|
+
_options$defaultExpre = options.defaultExpression,
|
|
43
|
+
defaultExpression = _options$defaultExpre === void 0 ? '' : _options$defaultExpre,
|
|
44
|
+
_options$defaultTimeS = options.defaultTimeSelection,
|
|
45
|
+
defaultTimeSelection = _options$defaultTimeS === void 0 ? 'relative:minute|15' : _options$defaultTimeS,
|
|
46
|
+
defaultFrom = options.defaultFrom,
|
|
47
|
+
defaultTo = options.defaultTo,
|
|
48
|
+
_options$comparing = options.comparing,
|
|
49
|
+
comparing = _options$comparing === void 0 ? false : _options$comparing,
|
|
50
|
+
onProfileTypeChange = options.onProfileTypeChange;
|
|
51
|
+
var resetFlameGraphState = useResetFlameGraphState();
|
|
52
|
+
var resetStateOnProfileTypeChange = useResetStateOnProfileTypeChange();
|
|
53
|
+
|
|
54
|
+
// URL state hooks with appropriate suffixes via useQueryStates
|
|
55
|
+
var _useQueryStates = useQueryStates({
|
|
56
|
+
expression: stringParam,
|
|
57
|
+
from: stringParam,
|
|
58
|
+
to: stringParam,
|
|
59
|
+
time_selection: stringParam,
|
|
60
|
+
sum_by: stringParam,
|
|
61
|
+
merge_from: stringParam,
|
|
62
|
+
merge_to: stringParam,
|
|
63
|
+
selection: stringParam
|
|
38
64
|
}, {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
65
|
+
history: 'replace',
|
|
66
|
+
urlKeys: {
|
|
67
|
+
expression: "expression".concat(suffix),
|
|
68
|
+
from: "from".concat(suffix),
|
|
69
|
+
to: "to".concat(suffix),
|
|
70
|
+
time_selection: "time_selection".concat(suffix),
|
|
71
|
+
sum_by: "sum_by".concat(suffix),
|
|
72
|
+
merge_from: "merge_from".concat(suffix),
|
|
73
|
+
merge_to: "merge_to".concat(suffix),
|
|
74
|
+
selection: "selection".concat(suffix)
|
|
75
|
+
}
|
|
76
|
+
}),
|
|
77
|
+
_useQueryStates2 = _slicedToArray(_useQueryStates, 2),
|
|
78
|
+
queryParams = _useQueryStates2[0],
|
|
79
|
+
setQueryParams = _useQueryStates2[1];
|
|
80
|
+
var expression = (_queryParams$expressi = queryParams.expression) !== null && _queryParams$expressi !== void 0 ? _queryParams$expressi : defaultExpression;
|
|
81
|
+
var from = (_queryParams$from = queryParams.from) !== null && _queryParams$from !== void 0 ? _queryParams$from : defaultFrom === null || defaultFrom === void 0 ? void 0 : defaultFrom.toString();
|
|
82
|
+
var to = (_queryParams$to = queryParams.to) !== null && _queryParams$to !== void 0 ? _queryParams$to : defaultTo === null || defaultTo === void 0 ? void 0 : defaultTo.toString();
|
|
83
|
+
var timeSelection = (_queryParams$time_sel = queryParams.time_selection) !== null && _queryParams$time_sel !== void 0 ? _queryParams$time_sel : defaultTimeSelection;
|
|
84
|
+
var sumByParam = queryParams.sum_by;
|
|
85
|
+
var mergeFrom = queryParams.merge_from;
|
|
86
|
+
var mergeTo = queryParams.merge_to;
|
|
87
|
+
var selectionParam = queryParams.selection;
|
|
88
|
+
|
|
89
|
+
// Individual setters for direct access
|
|
90
|
+
var setExpressionState = useCallback(function (val) {
|
|
91
|
+
return void setQueryParams({
|
|
92
|
+
expression: val
|
|
50
93
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
94
|
+
}, [setQueryParams]);
|
|
95
|
+
var setSumByParam = useCallback(function (val_0) {
|
|
96
|
+
return void setQueryParams({
|
|
97
|
+
sum_by: val_0
|
|
98
|
+
});
|
|
99
|
+
}, [setQueryParams]);
|
|
100
|
+
var _useNuqsQueryState = useNuqsQueryState('group_by', commaArrayParam),
|
|
101
|
+
_useNuqsQueryState2 = _slicedToArray(_useNuqsQueryState, 2),
|
|
102
|
+
setRawGroupByParam = _useNuqsQueryState2[1];
|
|
103
|
+
var setGroupByParam = useCallback(function (val_1) {
|
|
104
|
+
void setRawGroupByParam(val_1);
|
|
105
|
+
}, [setRawGroupByParam]);
|
|
106
|
+
|
|
107
|
+
// Parse sumBy from URL parameter format
|
|
108
|
+
var sumBy = useSumByFromParams(sumByParam !== null && sumByParam !== void 0 ? sumByParam : undefined);
|
|
109
|
+
|
|
110
|
+
// Draft state management
|
|
111
|
+
var _useState = useState(expression !== null && expression !== void 0 ? expression : defaultExpression),
|
|
112
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
113
|
+
draftExpression = _useState2[0],
|
|
114
|
+
setDraftExpression = _useState2[1];
|
|
115
|
+
var _useState3 = useState((_ref = from !== null && from !== void 0 ? from : defaultFrom === null || defaultFrom === void 0 ? void 0 : defaultFrom.toString()) !== null && _ref !== void 0 ? _ref : ''),
|
|
116
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
117
|
+
draftFrom = _useState4[0],
|
|
118
|
+
setDraftFrom = _useState4[1];
|
|
119
|
+
var _useState5 = useState((_ref2 = to !== null && to !== void 0 ? to : defaultTo === null || defaultTo === void 0 ? void 0 : defaultTo.toString()) !== null && _ref2 !== void 0 ? _ref2 : ''),
|
|
120
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
121
|
+
draftTo = _useState6[0],
|
|
122
|
+
setDraftTo = _useState6[1];
|
|
123
|
+
var _useState7 = useState(timeSelection !== null && timeSelection !== void 0 ? timeSelection : defaultTimeSelection),
|
|
124
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
125
|
+
draftTimeSelection = _useState8[0],
|
|
126
|
+
setDraftTimeSelection = _useState8[1];
|
|
127
|
+
// Parse the draft query to extract profile information
|
|
128
|
+
var draftQuery = useMemo(function () {
|
|
129
|
+
try {
|
|
130
|
+
return Query.parse(draftExpression !== null && draftExpression !== void 0 ? draftExpression : '');
|
|
131
|
+
} catch (error) {
|
|
132
|
+
console.warn('Failed to parse draft expression', {
|
|
133
|
+
expression: draftExpression,
|
|
134
|
+
error: error instanceof Error ? error.message : String(error)
|
|
135
|
+
});
|
|
136
|
+
return Query.parse('');
|
|
137
|
+
}
|
|
138
|
+
}, [draftExpression]);
|
|
139
|
+
var query = useMemo(function () {
|
|
140
|
+
try {
|
|
141
|
+
return Query.parse(expression !== null && expression !== void 0 ? expression : '');
|
|
142
|
+
} catch (error_0) {
|
|
143
|
+
console.warn('Failed to parse expression', {
|
|
144
|
+
expression: expression,
|
|
145
|
+
error: error_0 instanceof Error ? error_0.message : String(error_0)
|
|
146
|
+
});
|
|
147
|
+
return Query.parse('');
|
|
148
|
+
}
|
|
149
|
+
}, [expression]);
|
|
150
|
+
var draftProfileType = useMemo(function () {
|
|
151
|
+
return draftQuery.profileType();
|
|
152
|
+
}, [draftQuery]);
|
|
153
|
+
var draftProfileName = useMemo(function () {
|
|
154
|
+
return draftQuery.profileName();
|
|
155
|
+
}, [draftQuery]);
|
|
156
|
+
var profileType = useMemo(function () {
|
|
157
|
+
return query.profileType();
|
|
158
|
+
}, [query]);
|
|
159
|
+
|
|
160
|
+
// Compute draft time range for label fetching
|
|
161
|
+
var draftTimeRange = useMemo(function () {
|
|
162
|
+
return DateTimeRange.fromRangeKey(draftTimeSelection !== null && draftTimeSelection !== void 0 ? draftTimeSelection : defaultTimeSelection, draftFrom !== '' ? parseInt(draftFrom) : defaultFrom, draftTo !== '' ? parseInt(draftTo) : defaultTo);
|
|
163
|
+
}, [draftTimeSelection, draftFrom, draftTo, defaultTimeSelection, defaultFrom, defaultTo]);
|
|
164
|
+
// Use combined sumBy hook for fetching labels and computing defaults (based on committed state)
|
|
165
|
+
var _useSumBy = useSumBy(queryClient, (profileType === null || profileType === void 0 ? void 0 : profileType.profileName) !== '' ? profileType : draftProfileType, draftTimeRange, draftProfileType, draftTimeRange, sumBy),
|
|
166
|
+
computedSumByFromURL = _useSumBy.sumBy,
|
|
167
|
+
sumBySelectionLoading = _useSumBy.isLoading,
|
|
168
|
+
draftSumBy = _useSumBy.draftSumBy,
|
|
169
|
+
setDraftSumBy = _useSumBy.setDraftSumBy,
|
|
170
|
+
isDraftSumByLoading = _useSumBy.isDraftSumByLoading;
|
|
171
|
+
|
|
172
|
+
// Sync draft state with URL state when URL changes externally
|
|
173
|
+
useEffect(function () {
|
|
174
|
+
setDraftExpression(expression !== null && expression !== void 0 ? expression : defaultExpression);
|
|
175
|
+
}, [expression, defaultExpression]);
|
|
176
|
+
useEffect(function () {
|
|
177
|
+
var _ref3;
|
|
178
|
+
setDraftFrom((_ref3 = from !== null && from !== void 0 ? from : defaultFrom === null || defaultFrom === void 0 ? void 0 : defaultFrom.toString()) !== null && _ref3 !== void 0 ? _ref3 : '');
|
|
179
|
+
}, [from, defaultFrom]);
|
|
180
|
+
useEffect(function () {
|
|
181
|
+
var _ref4;
|
|
182
|
+
setDraftTo((_ref4 = to !== null && to !== void 0 ? to : defaultTo === null || defaultTo === void 0 ? void 0 : defaultTo.toString()) !== null && _ref4 !== void 0 ? _ref4 : '');
|
|
183
|
+
}, [to, defaultTo]);
|
|
184
|
+
useEffect(function () {
|
|
185
|
+
setDraftTimeSelection(timeSelection !== null && timeSelection !== void 0 ? timeSelection : defaultTimeSelection);
|
|
186
|
+
}, [timeSelection, defaultTimeSelection]);
|
|
187
|
+
useEffect(function () {
|
|
188
|
+
setDraftSumBy(sumBy);
|
|
189
|
+
}, [sumBy, setDraftSumBy]);
|
|
190
|
+
|
|
191
|
+
// Sync computed sumBy to URL if URL doesn't already have a value
|
|
192
|
+
// to ensure the shared URL can always pick it up.
|
|
193
|
+
// Only run once (when sumByParam first becomes available), not on every change,
|
|
194
|
+
// to avoid oscillation with external writers (useViewQueryState).
|
|
195
|
+
var hasSyncedSumByRef = useRef(false);
|
|
196
|
+
useEffect(function () {
|
|
197
|
+
if (sumByParam !== null) {
|
|
198
|
+
hasSyncedSumByRef.current = true;
|
|
199
|
+
}
|
|
200
|
+
if (!hasSyncedSumByRef.current && sumByParam === null && computedSumByFromURL !== undefined && !sumBySelectionLoading) {
|
|
201
|
+
hasSyncedSumByRef.current = true;
|
|
202
|
+
void setSumByParam(sumByToParam(computedSumByFromURL));
|
|
203
|
+
}
|
|
204
|
+
}, [sumByParam, computedSumByFromURL, sumBySelectionLoading, setSumByParam]);
|
|
205
|
+
|
|
206
|
+
// Construct the QuerySelection object (committed state from URL)
|
|
207
|
+
var querySelection = useMemo(function () {
|
|
208
|
+
var range = DateTimeRange.fromRangeKey(timeSelection !== null && timeSelection !== void 0 ? timeSelection : defaultTimeSelection, from != null && from !== '' ? parseInt(from) : defaultFrom, to != null && to !== '' ? parseInt(to) : defaultTo);
|
|
209
|
+
return _objectSpread({
|
|
210
|
+
expression: expression !== null && expression !== void 0 ? expression : defaultExpression,
|
|
211
|
+
from: range.getFromMs(),
|
|
212
|
+
to: range.getToMs(),
|
|
213
|
+
timeSelection: range.getRangeKey(),
|
|
214
|
+
sumBy: computedSumByFromURL
|
|
215
|
+
}, mergeFrom != null && mergeFrom !== '' && mergeTo != null && mergeTo !== '' ? {
|
|
216
|
+
mergeFrom: mergeFrom,
|
|
217
|
+
mergeTo: mergeTo
|
|
218
|
+
} : {});
|
|
219
|
+
}, [expression, from, to, timeSelection, computedSumByFromURL, mergeFrom, mergeTo, defaultExpression, defaultTimeSelection, defaultFrom, defaultTo]);
|
|
220
|
+
|
|
221
|
+
// Construct the draft QuerySelection object (local draft state)
|
|
222
|
+
var draftSelection = useMemo(function () {
|
|
223
|
+
var isDelta = draftProfileType.delta;
|
|
224
|
+
var draftMergeFrom = isDelta ? (BigInt(draftTimeRange.getFromMs()) * 1000000n).toString() : undefined;
|
|
225
|
+
var draftMergeTo = isDelta ? (BigInt(draftTimeRange.getToMs()) * 1000000n).toString() : undefined;
|
|
226
|
+
var finalSumBy = draftSumBy !== null && draftSumBy !== void 0 ? draftSumBy : computedSumByFromURL;
|
|
227
|
+
return _objectSpread({
|
|
228
|
+
expression: draftExpression !== null && draftExpression !== void 0 ? draftExpression : defaultExpression,
|
|
229
|
+
from: draftTimeRange.getFromMs(),
|
|
230
|
+
to: draftTimeRange.getToMs(),
|
|
231
|
+
timeSelection: draftTimeRange.getRangeKey(),
|
|
232
|
+
sumBy: finalSumBy
|
|
233
|
+
}, draftMergeFrom !== undefined && draftMergeFrom !== '' && draftMergeTo !== undefined && draftMergeTo !== '' ? {
|
|
234
|
+
mergeFrom: draftMergeFrom,
|
|
235
|
+
mergeTo: draftMergeTo
|
|
236
|
+
} : {});
|
|
237
|
+
}, [draftExpression, draftTimeRange, draftSumBy, computedSumByFromURL, draftProfileType.delta, defaultExpression]);
|
|
238
|
+
|
|
239
|
+
// Compute ProfileSelection from URL params
|
|
240
|
+
var profileSelection = useMemo(function () {
|
|
241
|
+
return ProfileSelectionFromParams(mergeFrom !== null && mergeFrom !== void 0 ? mergeFrom : undefined, mergeTo !== null && mergeTo !== void 0 ? mergeTo : undefined, selectionParam !== null && selectionParam !== void 0 ? selectionParam : undefined);
|
|
242
|
+
}, [mergeFrom, mergeTo, selectionParam]);
|
|
243
|
+
|
|
244
|
+
// Compute ProfileSource from ProfileSelection
|
|
245
|
+
var profileSource = useMemo(function () {
|
|
246
|
+
if (profileSelection === null) return null;
|
|
247
|
+
return profileSelection.ProfileSource();
|
|
248
|
+
}, [profileSelection]);
|
|
249
|
+
|
|
250
|
+
// Commit draft changes to URL
|
|
251
|
+
// Optional refreshedTimeRange parameter allows re-evaluating relative time ranges (e.g., "last 15 minutes")
|
|
252
|
+
// to the current moment when the Search button is clicked
|
|
253
|
+
// Optional expression parameter allows updating the expression before committing
|
|
254
|
+
var commitDraft = useCallback(function (refreshedTimeRange, expression_0) {
|
|
255
|
+
var _refreshedTimeRange$f, _refreshedTimeRange$f2, _refreshedTimeRange$t, _refreshedTimeRange$t2, _refreshedTimeRange$t3;
|
|
256
|
+
// Use provided expression or current draft expression
|
|
257
|
+
var finalExpression = expression_0 !== null && expression_0 !== void 0 ? expression_0 : draftExpression;
|
|
258
|
+
|
|
259
|
+
// Update draft state with new expression if provided
|
|
260
|
+
if (expression_0 !== undefined) {
|
|
261
|
+
setDraftExpression(expression_0);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// Calculate the actual from/to values from draftSelection if not provided
|
|
265
|
+
var calculatedFrom = draftSelection.from.toString();
|
|
266
|
+
var calculatedTo = draftSelection.to.toString();
|
|
267
|
+
var finalFrom = (_refreshedTimeRange$f = refreshedTimeRange === null || refreshedTimeRange === void 0 || (_refreshedTimeRange$f2 = refreshedTimeRange.from) === null || _refreshedTimeRange$f2 === void 0 ? void 0 : _refreshedTimeRange$f2.toString()) !== null && _refreshedTimeRange$f !== void 0 ? _refreshedTimeRange$f : draftFrom !== '' ? draftFrom : calculatedFrom;
|
|
268
|
+
var finalTo = (_refreshedTimeRange$t = refreshedTimeRange === null || refreshedTimeRange === void 0 || (_refreshedTimeRange$t2 = refreshedTimeRange.to) === null || _refreshedTimeRange$t2 === void 0 ? void 0 : _refreshedTimeRange$t2.toString()) !== null && _refreshedTimeRange$t !== void 0 ? _refreshedTimeRange$t : draftTo !== '' ? draftTo : calculatedTo;
|
|
269
|
+
var finalTimeSelection = (_refreshedTimeRange$t3 = refreshedTimeRange === null || refreshedTimeRange === void 0 ? void 0 : refreshedTimeRange.timeSelection) !== null && _refreshedTimeRange$t3 !== void 0 ? _refreshedTimeRange$t3 : draftTimeSelection;
|
|
270
|
+
|
|
271
|
+
// Update draft state with refreshed time range if provided
|
|
272
|
+
if ((refreshedTimeRange === null || refreshedTimeRange === void 0 ? void 0 : refreshedTimeRange.from) !== undefined) {
|
|
273
|
+
setDraftFrom(finalFrom);
|
|
274
|
+
}
|
|
275
|
+
if ((refreshedTimeRange === null || refreshedTimeRange === void 0 ? void 0 : refreshedTimeRange.to) !== undefined) {
|
|
276
|
+
setDraftTo(finalTo);
|
|
277
|
+
}
|
|
278
|
+
if ((refreshedTimeRange === null || refreshedTimeRange === void 0 ? void 0 : refreshedTimeRange.timeSelection) !== undefined) {
|
|
279
|
+
setDraftTimeSelection(finalTimeSelection);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
// Auto-calculate merge parameters for delta profiles
|
|
283
|
+
var finalQuery = Query.parse(finalExpression);
|
|
284
|
+
var isDelta_0 = finalQuery.profileType().delta;
|
|
285
|
+
var sumByValue = isDelta_0 ? sumByToParam(draftSumBy) : sumByToParam(DEFAULT_EMPTY_SUM_BY);
|
|
286
|
+
var mergeFromValue = null;
|
|
287
|
+
var mergeToValue = null;
|
|
288
|
+
var selectionValue = null;
|
|
289
|
+
if (isDelta_0 && finalFrom !== '' && finalTo !== '') {
|
|
290
|
+
var fromMs = parseInt(finalFrom);
|
|
291
|
+
var toMs = parseInt(finalTo);
|
|
292
|
+
mergeFromValue = (BigInt(fromMs) * 1000000n).toString();
|
|
293
|
+
mergeToValue = (BigInt(toMs) * 1000000n).toString();
|
|
294
|
+
if (!comparing) {
|
|
295
|
+
selectionValue = finalExpression;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Atomic URL update with all params at once
|
|
300
|
+
void setQueryParams({
|
|
301
|
+
expression: finalExpression,
|
|
302
|
+
from: finalFrom,
|
|
303
|
+
to: finalTo,
|
|
304
|
+
time_selection: finalTimeSelection,
|
|
305
|
+
sum_by: sumByValue,
|
|
306
|
+
merge_from: mergeFromValue,
|
|
307
|
+
merge_to: mergeToValue,
|
|
308
|
+
selection: selectionValue
|
|
309
|
+
});
|
|
310
|
+
resetFlameGraphState();
|
|
311
|
+
if (draftProfileType.toString() !== Query.parse(querySelection.expression).profileType().toString()) {
|
|
312
|
+
resetStateOnProfileTypeChange();
|
|
313
|
+
onProfileTypeChange === null || onProfileTypeChange === void 0 || onProfileTypeChange();
|
|
314
|
+
}
|
|
315
|
+
}, [draftExpression, draftFrom, draftTo, draftTimeSelection, draftSumBy, draftSelection.from, draftSelection.to, comparing, setQueryParams, resetFlameGraphState, resetStateOnProfileTypeChange, onProfileTypeChange, draftProfileType, querySelection.expression]);
|
|
316
|
+
var setDraftTimeRange = useCallback(function (newFrom, newTo, newTimeSelection) {
|
|
317
|
+
setDraftFrom(newFrom.toString());
|
|
318
|
+
setDraftTo(newTo.toString());
|
|
319
|
+
setDraftTimeSelection(newTimeSelection);
|
|
320
|
+
}, []);
|
|
321
|
+
var setDraftSumByCallback = useCallback(function (newSumBy) {
|
|
322
|
+
setDraftSumBy(newSumBy);
|
|
323
|
+
}, [setDraftSumBy]);
|
|
324
|
+
var setDraftProfileName = useCallback(function (newProfileName) {
|
|
325
|
+
if (newProfileName === '') return;
|
|
326
|
+
var _draftQuery$setProfil = draftQuery.setProfileName(newProfileName),
|
|
327
|
+
_draftQuery$setProfil2 = _slicedToArray(_draftQuery$setProfil, 2),
|
|
328
|
+
newQuery = _draftQuery$setProfil2[0],
|
|
329
|
+
changed = _draftQuery$setProfil2[1];
|
|
330
|
+
if (changed) {
|
|
331
|
+
setDraftExpression(newQuery.toString());
|
|
332
|
+
setDraftSumBy(undefined);
|
|
333
|
+
}
|
|
334
|
+
}, [draftQuery, setDraftSumBy]);
|
|
335
|
+
var setDraftMatchers = useCallback(function (matchers) {
|
|
336
|
+
var newExpression = "".concat(draftProfileName, "{").concat(matchers, "}");
|
|
337
|
+
setDraftExpression(newExpression);
|
|
338
|
+
}, [draftProfileName]);
|
|
339
|
+
|
|
340
|
+
// Set ProfileSelection (auto-commits to URL immediately)
|
|
341
|
+
var setProfileSelection = useCallback(function (mergeFrom_0, mergeTo_0, query_0) {
|
|
342
|
+
void setQueryParams({
|
|
343
|
+
selection: query_0.toString(),
|
|
344
|
+
merge_from: mergeFrom_0.toString(),
|
|
345
|
+
merge_to: mergeTo_0.toString()
|
|
346
|
+
});
|
|
347
|
+
}, [setQueryParams]);
|
|
348
|
+
var draftParsedQuery = useMemo(function () {
|
|
349
|
+
try {
|
|
350
|
+
var _draftSelection$expre;
|
|
351
|
+
return Query.parse((_draftSelection$expre = draftSelection.expression) !== null && _draftSelection$expre !== void 0 ? _draftSelection$expre : '');
|
|
352
|
+
} catch (error_1) {
|
|
353
|
+
console.warn('Failed to parse draft selection expression', {
|
|
354
|
+
expression: draftSelection.expression,
|
|
355
|
+
error: error_1 instanceof Error ? error_1.message : String(error_1)
|
|
356
|
+
});
|
|
357
|
+
return Query.parse('');
|
|
358
|
+
}
|
|
359
|
+
}, [draftSelection.expression]);
|
|
360
|
+
var parsedQuery = useMemo(function () {
|
|
361
|
+
try {
|
|
362
|
+
var _querySelection$expre;
|
|
363
|
+
return Query.parse((_querySelection$expre = querySelection.expression) !== null && _querySelection$expre !== void 0 ? _querySelection$expre : '');
|
|
364
|
+
} catch (error_2) {
|
|
365
|
+
console.warn('Failed to parse query selection expression', {
|
|
366
|
+
expression: querySelection.expression,
|
|
367
|
+
error: error_2 instanceof Error ? error_2.message : String(error_2)
|
|
368
|
+
});
|
|
369
|
+
return Query.parse('');
|
|
370
|
+
}
|
|
371
|
+
}, [querySelection.expression]);
|
|
372
|
+
return {
|
|
373
|
+
// Current committed state
|
|
374
|
+
querySelection: querySelection,
|
|
375
|
+
// Draft state
|
|
376
|
+
draftSelection: draftSelection,
|
|
377
|
+
// Draft setters
|
|
378
|
+
setDraftExpression: setDraftExpression,
|
|
379
|
+
setDraftTimeRange: setDraftTimeRange,
|
|
380
|
+
setDraftSumBy: setDraftSumByCallback,
|
|
381
|
+
setDraftProfileName: setDraftProfileName,
|
|
382
|
+
setDraftMatchers: setDraftMatchers,
|
|
383
|
+
// Commit function
|
|
384
|
+
commitDraft: commitDraft,
|
|
385
|
+
// ProfileSelection state
|
|
386
|
+
profileSelection: profileSelection,
|
|
387
|
+
profileSource: profileSource,
|
|
388
|
+
setProfileSelection: setProfileSelection,
|
|
389
|
+
// Loading state
|
|
390
|
+
sumByLoading: isDraftSumByLoading || sumBySelectionLoading,
|
|
391
|
+
draftParsedQuery: draftParsedQuery,
|
|
392
|
+
parsedQuery: parsedQuery,
|
|
393
|
+
setExpressionParam: setExpressionState,
|
|
394
|
+
setSumByParam: setSumByParam,
|
|
395
|
+
setGroupByParam: setGroupByParam
|
|
396
|
+
};
|
|
397
|
+
};
|