@parca/profile 0.19.27 → 0.19.29
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 +8 -0
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +4 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +10 -5
- package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +2 -2
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +11 -6
- package/package.json +2 -2
- package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +5 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.tsx +11 -5
- package/src/ProfileView/components/ProfileFilters/useProfileFilters.ts +2 -2
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +13 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.19.29](https://github.com/parca-dev/parca/compare/@parca/profile@0.19.28...@parca/profile@0.19.29) (2025-07-22)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @parca/profile
|
|
9
|
+
|
|
10
|
+
## [0.19.28](https://github.com/parca-dev/parca/compare/@parca/profile@0.19.27...@parca/profile@0.19.28) (2025-07-22)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @parca/profile
|
|
13
|
+
|
|
6
14
|
## [0.19.27](https://github.com/parca-dev/parca/compare/@parca/profile@0.19.26...@parca/profile@0.19.27) (2025-07-21)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @parca/profile
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenu.d.ts","sourceRoot":"","sources":["../../../src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAOnC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAO1C,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,QAAA,MAAM,WAAW,GAAI,kIAalB,gBAAgB,KAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"ContextMenu.d.ts","sourceRoot":"","sources":["../../../src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx"],"names":[],"mappings":"AAcA,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAOnC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAO1C,UAAU,gBAAgB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,QAAA,MAAM,WAAW,GAAI,kIAalB,gBAAgB,KAAG,GAAG,CAAC,OAsOzB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -93,13 +93,16 @@ const ContextMenu = ({ menuId, table, total, totalUnfiltered, row, compareAbsolu
|
|
|
93
93
|
setDashboardItems([...dashboardItems, 'table']);
|
|
94
94
|
}
|
|
95
95
|
}, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "ph:table" }), _jsx("div", { children: "Show in table" })] }) }), enableSandwichView === true && (_jsx(Item, { id: "show-in-sandwich", onClick: () => {
|
|
96
|
+
if (functionName === '' || functionName == null) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
96
99
|
if (dashboardItems.includes('sandwich')) {
|
|
97
100
|
setSandwichFunctionName(functionName);
|
|
98
101
|
return;
|
|
99
102
|
}
|
|
100
103
|
setSandwichFunctionName(functionName);
|
|
101
104
|
setDashboardItems([...dashboardItems, 'sandwich']);
|
|
102
|
-
}, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "tdesign:sandwich-filled" }), _jsxs("div", { className: "relative", children: [dashboardItems.includes('sandwich')
|
|
105
|
+
}, disabled: functionName === '' || functionName == null, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "tdesign:sandwich-filled" }), _jsxs("div", { className: "relative", children: [dashboardItems.includes('sandwich')
|
|
103
106
|
? 'Focus sandwich on this frame.'
|
|
104
107
|
: 'Show in sandwich', _jsx("span", { className: "absolute top-[-2px] text-xs lowercase text-red-500", children: "\u00A0alpha" })] })] }) })), _jsx(Item, { id: "reset-view", onClick: handleResetView, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "system-uicons:reset" }), _jsx("div", { children: "Reset graph" })] }) }), _jsxs(Item, { id: "hide-binary", onClick: () => hideBinary(getLastItem(mappingFile)), disabled: mappingFile === null || mappingFile === '', children: [_jsx("div", { "data-tooltip-id": "hide-binary-help", "data-tooltip-content": "Hide all frames for this binary", children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "bx:bxs-hide" }), _jsxs("div", { children: ["Hide binary ", mappingFile !== null && `(${getLastItem(mappingFile)})`] })] }) }), _jsx(Tooltip, { place: "left", id: "hide-binary-help" })] }), _jsx(Submenu, { label: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "ph:copy" }), _jsx("div", { children: "Copy" })] }), children: _jsx("div", { className: "max-h-[300px] overflow-scroll", children: nonEmptyValuesToCopy.map(({ id, value }) => (_jsx(Item, { id: id, onClick: () => handleCopyItem(value), className: "dark:bg-gray-800", children: _jsxs("div", { className: "flex flex-col dark:text-gray-300 hover:dark:text-gray-100", children: [_jsx("div", { className: "text-sm", children: id }), _jsx("div", { className: "text-xs", children: truncateString(value, 30) })] }) }, id))) }) }), checkDebuginfoStatusHandler !== undefined ? (_jsx(Item, { id: "check-debuginfo-status", onClick: () => checkDebuginfoStatusHandler(mappingBuildID), disabled: !isMappingBuildIDAvailable, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "bx:bx-info-circle" }), _jsx("div", { className: "relative pr-4", children: "Check debuginfo status" })] }) })) : null, _jsx(Separator, {}), _jsx(Item, { id: "dock-tooltip", onClick: handleDockTooltip, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "bx:dock-bottom" }), isGraphTooltipDocked ? 'Undock tooltip' : 'Dock tooltip'] }) })] }));
|
|
105
108
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuWrapper.d.ts","sourceRoot":"","sources":["../../../src/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAI1C,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CACtD;AAED,QAAA,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"ContextMenuWrapper.d.ts","sourceRoot":"","sources":["../../../src/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.tsx"],"names":[],"mappings":"AAeA,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAI1C,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,eAAe,EAAE,OAAO,CAAC;IACzB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,UAAU,EAAE,CAAC,cAAc,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;CACtD;AAED,QAAA,MAAM,kBAAkB,2HAwBvB,CAAC;AAIF,eAAe,kBAAkB,CAAC"}
|
|
@@ -14,19 +14,24 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
14
14
|
import { forwardRef, useImperativeHandle, useState } from 'react';
|
|
15
15
|
import ContextMenu from './ContextMenu';
|
|
16
16
|
const ContextMenuWrapper = forwardRef((props, ref) => {
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
const [row, setRow] = useState(0);
|
|
17
|
+
// Initialize with null to prevent rendering with invalid data
|
|
18
|
+
const [row, setRow] = useState(null);
|
|
20
19
|
useImperativeHandle(ref, () => ({
|
|
21
20
|
setRow: (newRow, callback) => {
|
|
22
21
|
setRow(newRow);
|
|
23
22
|
// Execute callback after state update using requestAnimationFrame
|
|
24
23
|
if (callback != null) {
|
|
25
|
-
requestAnimationFrame(
|
|
24
|
+
requestAnimationFrame(() => {
|
|
25
|
+
requestAnimationFrame(callback);
|
|
26
|
+
});
|
|
26
27
|
}
|
|
27
28
|
},
|
|
28
29
|
}));
|
|
29
|
-
|
|
30
|
+
// Only render ContextMenu when we have a valid row
|
|
31
|
+
if (row === null) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return _jsx(ContextMenu, { ...props, row: row, isSandwich: props.isInSandwichView });
|
|
30
35
|
});
|
|
31
36
|
ContextMenuWrapper.displayName = 'ContextMenuWrapper';
|
|
32
37
|
export default ContextMenuWrapper;
|
|
@@ -114,7 +114,7 @@ export const convertToProtoFilters = (profileFilters) => {
|
|
|
114
114
|
};
|
|
115
115
|
export const useProfileFilters = () => {
|
|
116
116
|
const { appliedFilters, setAppliedFilters } = useProfileFiltersUrlState();
|
|
117
|
-
const [localFilters, setLocalFilters] = useState([]);
|
|
117
|
+
const [localFilters, setLocalFilters] = useState(appliedFilters ?? []);
|
|
118
118
|
const lastAppliedFiltersRef = useRef([]);
|
|
119
119
|
const localFiltersRef = useRef(localFilters);
|
|
120
120
|
localFiltersRef.current = localFilters;
|
|
@@ -238,7 +238,7 @@ export const useProfileFilters = () => {
|
|
|
238
238
|
}, [appliedFilters]);
|
|
239
239
|
return {
|
|
240
240
|
localFilters,
|
|
241
|
-
appliedFilters,
|
|
241
|
+
appliedFilters: appliedFilters ?? [],
|
|
242
242
|
protoFilters,
|
|
243
243
|
hasUnsavedChanges,
|
|
244
244
|
onApplyFilters,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProfileFiltersUrlState.d.ts","sourceRoot":"","sources":["../../../../src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,KAAK,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"useProfileFiltersUrlState.d.ts","sourceRoot":"","sources":["../../../../src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts"],"names":[],"mappings":"AAaA,OAAO,EAAoB,KAAK,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AAIjF,OAAO,EAAC,KAAK,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAsDvD,eAAO,MAAM,oBAAoB,GAAI,SAAS,MAAM,KAAG,aAAa,EAuCnE,CAAC;AAEF,eAAO,MAAM,yBAAyB,QAAO;IAC3C,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,iBAAiB,EAAE,sBAAsB,CAAC,aAAa,EAAE,CAAC,CAAC;CAoB5D,CAAC"}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { useURLStateCustom } from '@parca/components';
|
|
14
|
+
import { decodeMultipleEncodings } from '@parca/utilities';
|
|
14
15
|
import { isPresetKey } from './filterPresets';
|
|
15
16
|
// Compact encoding mappings
|
|
16
17
|
const TYPE_MAP = {
|
|
@@ -62,12 +63,14 @@ export const decodeProfileFilters = (encoded) => {
|
|
|
62
63
|
if (encoded === '' || encoded === undefined)
|
|
63
64
|
return [];
|
|
64
65
|
try {
|
|
65
|
-
|
|
66
|
+
// Handle multiple levels of URL encoding
|
|
67
|
+
const decodedString = decodeMultipleEncodings(encoded) ?? encoded;
|
|
68
|
+
return decodedString.split(',').map((filter, index) => {
|
|
66
69
|
const parts = filter.split(':');
|
|
67
70
|
// Handle preset filters (format: p:presetKey:value)
|
|
68
71
|
if (parts[0] === 'p' && parts.length >= 3) {
|
|
69
|
-
const presetKey =
|
|
70
|
-
const value =
|
|
72
|
+
const presetKey = parts[1];
|
|
73
|
+
const value = parts.slice(2).join(':'); // Handle values with colons
|
|
71
74
|
return {
|
|
72
75
|
id: `filter-${Date.now()}-${index}`,
|
|
73
76
|
type: presetKey,
|
|
@@ -76,14 +79,15 @@ export const decodeProfileFilters = (encoded) => {
|
|
|
76
79
|
}
|
|
77
80
|
// Handle regular filters (format: type:field:match:value)
|
|
78
81
|
const [type, field, match, ...valueParts] = parts;
|
|
79
|
-
const value =
|
|
80
|
-
|
|
82
|
+
const value = valueParts.join(':'); // Handle values with colons
|
|
83
|
+
const decodedFilter = {
|
|
81
84
|
id: `filter-${Date.now()}-${index}`,
|
|
82
85
|
type: TYPE_MAP_REVERSE[type],
|
|
83
86
|
field: FIELD_MAP_REVERSE[field],
|
|
84
87
|
matchType: MATCH_MAP_REVERSE[match],
|
|
85
88
|
value,
|
|
86
89
|
};
|
|
90
|
+
return decodedFilter;
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
93
|
catch {
|
|
@@ -99,9 +103,10 @@ export const useProfileFiltersUrlState = () => {
|
|
|
99
103
|
stringify: value => {
|
|
100
104
|
return encodeProfileFilters(value);
|
|
101
105
|
},
|
|
106
|
+
defaultValue: [],
|
|
102
107
|
});
|
|
103
108
|
return {
|
|
104
|
-
appliedFilters,
|
|
109
|
+
appliedFilters: appliedFilters ?? [],
|
|
105
110
|
setAppliedFilters,
|
|
106
111
|
};
|
|
107
112
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parca/profile",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.29",
|
|
4
4
|
"description": "Profile viewing libraries",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@floating-ui/react": "^0.27.12",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"access": "public",
|
|
79
79
|
"registry": "https://registry.npmjs.org/"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "3695a715bae0531c5654c99a604fd9f1a66a80aa"
|
|
82
82
|
}
|
|
@@ -188,6 +188,10 @@ const ContextMenu = ({
|
|
|
188
188
|
<Item
|
|
189
189
|
id="show-in-sandwich"
|
|
190
190
|
onClick={() => {
|
|
191
|
+
if (functionName === '' || functionName == null) {
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
191
195
|
if (dashboardItems.includes('sandwich')) {
|
|
192
196
|
setSandwichFunctionName(functionName);
|
|
193
197
|
return;
|
|
@@ -196,6 +200,7 @@ const ContextMenu = ({
|
|
|
196
200
|
setSandwichFunctionName(functionName);
|
|
197
201
|
setDashboardItems([...dashboardItems, 'sandwich']);
|
|
198
202
|
}}
|
|
203
|
+
disabled={functionName === '' || functionName == null}
|
|
199
204
|
>
|
|
200
205
|
<div className="flex w-full items-center gap-2">
|
|
201
206
|
<Icon icon="tdesign:sandwich-filled" />
|
|
@@ -39,21 +39,27 @@ export interface ContextMenuWrapperRef {
|
|
|
39
39
|
|
|
40
40
|
const ContextMenuWrapper = forwardRef<ContextMenuWrapperRef, ContextMenuWrapperProps>(
|
|
41
41
|
(props, ref) => {
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
const [row, setRow] = useState(0);
|
|
42
|
+
// Initialize with null to prevent rendering with invalid data
|
|
43
|
+
const [row, setRow] = useState<number | null>(null);
|
|
45
44
|
|
|
46
45
|
useImperativeHandle(ref, () => ({
|
|
47
46
|
setRow: (newRow: number, callback?: () => void) => {
|
|
48
47
|
setRow(newRow);
|
|
49
48
|
// Execute callback after state update using requestAnimationFrame
|
|
50
49
|
if (callback != null) {
|
|
51
|
-
requestAnimationFrame(
|
|
50
|
+
requestAnimationFrame(() => {
|
|
51
|
+
requestAnimationFrame(callback);
|
|
52
|
+
});
|
|
52
53
|
}
|
|
53
54
|
},
|
|
54
55
|
}));
|
|
55
56
|
|
|
56
|
-
|
|
57
|
+
// Only render ContextMenu when we have a valid row
|
|
58
|
+
if (row === null) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return <ContextMenu {...props} row={row} isSandwich={props.isInSandwichView} />;
|
|
57
63
|
}
|
|
58
64
|
);
|
|
59
65
|
|
|
@@ -145,7 +145,7 @@ export const useProfileFilters = (): {
|
|
|
145
145
|
} => {
|
|
146
146
|
const {appliedFilters, setAppliedFilters} = useProfileFiltersUrlState();
|
|
147
147
|
|
|
148
|
-
const [localFilters, setLocalFilters] = useState<ProfileFilter[]>([]);
|
|
148
|
+
const [localFilters, setLocalFilters] = useState<ProfileFilter[]>(appliedFilters ?? []);
|
|
149
149
|
|
|
150
150
|
const lastAppliedFiltersRef = useRef<ProfileFilter[]>([]);
|
|
151
151
|
|
|
@@ -312,7 +312,7 @@ export const useProfileFilters = (): {
|
|
|
312
312
|
|
|
313
313
|
return {
|
|
314
314
|
localFilters,
|
|
315
|
-
appliedFilters,
|
|
315
|
+
appliedFilters: appliedFilters ?? [],
|
|
316
316
|
protoFilters,
|
|
317
317
|
hasUnsavedChanges,
|
|
318
318
|
onApplyFilters,
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
|
|
14
14
|
import {useURLStateCustom, type ParamValueSetterCustom} from '@parca/components';
|
|
15
|
+
import {decodeMultipleEncodings} from '@parca/utilities';
|
|
15
16
|
|
|
16
17
|
import {isPresetKey} from './filterPresets';
|
|
17
18
|
import {type ProfileFilter} from './useProfileFilters';
|
|
@@ -72,13 +73,16 @@ export const decodeProfileFilters = (encoded: string): ProfileFilter[] => {
|
|
|
72
73
|
if (encoded === '' || encoded === undefined) return [];
|
|
73
74
|
|
|
74
75
|
try {
|
|
75
|
-
|
|
76
|
+
// Handle multiple levels of URL encoding
|
|
77
|
+
const decodedString = decodeMultipleEncodings(encoded) ?? encoded;
|
|
78
|
+
|
|
79
|
+
return decodedString.split(',').map((filter, index) => {
|
|
76
80
|
const parts = filter.split(':');
|
|
77
81
|
|
|
78
82
|
// Handle preset filters (format: p:presetKey:value)
|
|
79
83
|
if (parts[0] === 'p' && parts.length >= 3) {
|
|
80
|
-
const presetKey =
|
|
81
|
-
const value =
|
|
84
|
+
const presetKey = parts[1];
|
|
85
|
+
const value = parts.slice(2).join(':'); // Handle values with colons
|
|
82
86
|
|
|
83
87
|
return {
|
|
84
88
|
id: `filter-${Date.now()}-${index}`,
|
|
@@ -89,15 +93,17 @@ export const decodeProfileFilters = (encoded: string): ProfileFilter[] => {
|
|
|
89
93
|
|
|
90
94
|
// Handle regular filters (format: type:field:match:value)
|
|
91
95
|
const [type, field, match, ...valueParts] = parts;
|
|
92
|
-
const value =
|
|
96
|
+
const value = valueParts.join(':'); // Handle values with colons
|
|
93
97
|
|
|
94
|
-
|
|
98
|
+
const decodedFilter = {
|
|
95
99
|
id: `filter-${Date.now()}-${index}`,
|
|
96
100
|
type: TYPE_MAP_REVERSE[type] as ProfileFilter['type'],
|
|
97
101
|
field: FIELD_MAP_REVERSE[field] as ProfileFilter['field'],
|
|
98
102
|
matchType: MATCH_MAP_REVERSE[match] as ProfileFilter['matchType'],
|
|
99
103
|
value,
|
|
100
104
|
};
|
|
105
|
+
|
|
106
|
+
return decodedFilter;
|
|
101
107
|
});
|
|
102
108
|
} catch {
|
|
103
109
|
return [];
|
|
@@ -118,11 +124,12 @@ export const useProfileFiltersUrlState = (): {
|
|
|
118
124
|
stringify: value => {
|
|
119
125
|
return encodeProfileFilters(value);
|
|
120
126
|
},
|
|
127
|
+
defaultValue: [],
|
|
121
128
|
}
|
|
122
129
|
);
|
|
123
130
|
|
|
124
131
|
return {
|
|
125
|
-
appliedFilters,
|
|
132
|
+
appliedFilters: appliedFilters ?? [],
|
|
126
133
|
setAppliedFilters,
|
|
127
134
|
};
|
|
128
135
|
};
|