@parca/profile 0.16.454 → 0.16.456
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/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.d.ts.map +1 -1
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.js +2 -1
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/TextWithEllipsis.d.ts +9 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/TextWithEllipsis.d.ts.map +1 -0
- package/dist/ProfileIcicleGraph/IcicleGraphArrow/TextWithEllipsis.js +62 -0
- package/dist/ProfileView/components/ActionButtons/GroupByDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +15 -1
- package/dist/ProfileView/components/Toolbars/index.js +1 -1
- package/package.json +4 -4
- package/src/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.tsx +7 -3
- package/src/ProfileIcicleGraph/IcicleGraphArrow/TextWithEllipsis.tsx +91 -0
- package/src/ProfileView/components/ActionButtons/GroupByDropdown.tsx +20 -1
- package/src/ProfileView/components/Toolbars/index.tsx +1 -1
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.16.456](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.455...@parca/profile@0.16.456) (2024-12-16)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @parca/profile
|
|
9
|
+
|
|
10
|
+
## [0.16.455](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.454...@parca/profile@0.16.455) (2024-12-11)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @parca/profile
|
|
13
|
+
|
|
6
14
|
## [0.16.454](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.453...@parca/profile@0.16.454) (2024-12-10)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @parca/profile
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IcicleGraphNodes.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.tsx"],"names":[],"mappings":"AAaA,OAAO,KAA2B,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAMnC,OAAO,yCAAyC,CAAC;AAEjD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"IcicleGraphNodes.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.tsx"],"names":[],"mappings":"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"}
|
|
@@ -16,6 +16,7 @@ import cx from 'classnames';
|
|
|
16
16
|
import { selectBinaries, useAppSelector } from '@parca/store';
|
|
17
17
|
import { isSearchMatch, scaleLinear } from '@parca/utilities';
|
|
18
18
|
import 'react-contexify/dist/ReactContexify.css';
|
|
19
|
+
import TextWithEllipsis from './TextWithEllipsis';
|
|
19
20
|
import { FIELD_CHILDREN, FIELD_CUMULATIVE, FIELD_DIFF, FIELD_FUNCTION_FILE_NAME, FIELD_FUNCTION_NAME, FIELD_MAPPING_FILE, } from './index';
|
|
20
21
|
import useNodeColor from './useNodeColor';
|
|
21
22
|
import { arrowToString, nodeLabel } from './utils';
|
|
@@ -196,5 +197,5 @@ export const IcicleNode = React.memo(function IcicleNodeNoMemo({ table, row, col
|
|
|
196
197
|
? `${colorForSimilarNodes} stroke-[3] [stroke-dasharray:6,4] [stroke-linecap:round] [stroke-linejoin:round] h-6`
|
|
197
198
|
: 'stroke-white dark:stroke-gray-700', {
|
|
198
199
|
'opacity-50': isHighlightEnabled && !isHighlighted,
|
|
199
|
-
}) }), width > 5 && (_jsx("svg", { width: width - 5, height: height, children: _jsx(
|
|
200
|
+
}) }), width > 5 && (_jsx("svg", { width: width - 5, height: height, children: _jsx(TextWithEllipsis, { text: name, x: 5, y: 15, width: width - 10 }) }))] }), childRows.length > 0 && (_jsx(IcicleGraphNodes, { table: table, row: row, colors: colors, colorBy: colorBy, childRows: childRows, x: x, y: RowHeight, xScale: newXScale, total: total, totalWidth: totalWidth, level: nextLevel, path: nextPath, curPath: nextCurPath, setCurPath: setCurPath, setHoveringRow: setHoveringRow, setHoveringLevel: setHoveringLevel, searchString: searchString, sortBy: sortBy, darkMode: darkMode, profileType: profileType, compareMode: compareMode, isContextMenuOpen: isContextMenuOpen, hoveringName: hoveringName, setHoveringName: setHoveringName, hoveringRow: hoveringRow, colorForSimilarNodes: colorForSimilarNodes, highlightSimilarStacksPreference: highlightSimilarStacksPreference }))] }));
|
|
200
201
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextWithEllipsis.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/IcicleGraphArrow/TextWithEllipsis.tsx"],"names":[],"mappings":"AAiBA,UAAU,KAAK;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;CACf;AA2CD,iBAAS,gBAAgB,CAAC,EAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAC,EAAE,KAAK,GAAG,GAAG,CAAC,OAAO,CAuBjE;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// Copyright 2022 The Parca Authors
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { useEffect, useRef, useState } from 'react';
|
|
15
|
+
import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
|
|
16
|
+
function calculateTruncatedText(text, textElement, maxWidth) {
|
|
17
|
+
// Create a temporary element for measurement
|
|
18
|
+
const tempElement = textElement.cloneNode();
|
|
19
|
+
tempElement.textContent = text;
|
|
20
|
+
textElement.parentElement?.appendChild(tempElement);
|
|
21
|
+
// If the text fits, return it
|
|
22
|
+
const fullWidth = tempElement.getComputedTextLength();
|
|
23
|
+
if (fullWidth <= maxWidth) {
|
|
24
|
+
textElement.parentElement?.removeChild(tempElement);
|
|
25
|
+
return text;
|
|
26
|
+
}
|
|
27
|
+
// Binary search to find the maximum text that fits
|
|
28
|
+
let start = 0;
|
|
29
|
+
let end = text.length;
|
|
30
|
+
let result = text;
|
|
31
|
+
while (start < end) {
|
|
32
|
+
const mid = Math.floor((start + end + 1) / 2);
|
|
33
|
+
const truncated = text.slice(-mid);
|
|
34
|
+
tempElement.textContent = truncated;
|
|
35
|
+
const currentWidth = tempElement.getComputedTextLength();
|
|
36
|
+
if (currentWidth <= maxWidth) {
|
|
37
|
+
result = truncated;
|
|
38
|
+
start = mid;
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
end = mid - 1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
textElement.parentElement?.removeChild(tempElement);
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
function TextWithEllipsis({ text, x, y, width }) {
|
|
48
|
+
const textRef = useRef(null);
|
|
49
|
+
const [displayText, setDisplayText] = useState(text);
|
|
50
|
+
const [showFunctionNameFromLeft] = useUserPreference(USER_PREFERENCES.SHOW_FUNCTION_NAME_FROM_LEFT.key);
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
const textElement = textRef.current;
|
|
53
|
+
if (textElement === null)
|
|
54
|
+
return;
|
|
55
|
+
const newText = showFunctionNameFromLeft
|
|
56
|
+
? text
|
|
57
|
+
: calculateTruncatedText(text, textElement, width);
|
|
58
|
+
setDisplayText(newText);
|
|
59
|
+
}, [text, width, showFunctionNameFromLeft]);
|
|
60
|
+
return (_jsx("text", { ref: textRef, x: x, y: y, className: "text-xs", children: displayText }));
|
|
61
|
+
}
|
|
62
|
+
export default TextWithEllipsis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupByDropdown.d.ts","sourceRoot":"","sources":["../../../../src/ProfileView/components/ActionButtons/GroupByDropdown.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GroupByDropdown.d.ts","sourceRoot":"","sources":["../../../../src/ProfileView/components/ActionButtons/GroupByDropdown.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoC,MAAM,OAAO,CAAC;AAuRzD,UAAU,oBAAoB;IAC5B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,gBAAgB,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;CAC9C;AAED,QAAA,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAoDnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -95,6 +95,20 @@ const LabelSelector = ({ labels, groupBy, setGroupByLabels, isOpen, labelsButton
|
|
|
95
95
|
};
|
|
96
96
|
const GroupByDropdown = ({ groupBy, toggleGroupBy, onLabelClick, labelsButtonRef, }) => {
|
|
97
97
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
98
|
+
const dropdownRef = useRef(null);
|
|
99
|
+
useEffect(() => {
|
|
100
|
+
const handleClickOutside = (event) => {
|
|
101
|
+
if (isDropdownOpen &&
|
|
102
|
+
dropdownRef.current != null &&
|
|
103
|
+
!dropdownRef.current.contains(event.target)) {
|
|
104
|
+
setIsDropdownOpen(false);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
108
|
+
return () => {
|
|
109
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
110
|
+
};
|
|
111
|
+
}, [isDropdownOpen]);
|
|
98
112
|
const label = groupBy.length === 0
|
|
99
113
|
? 'Nothing'
|
|
100
114
|
: groupBy.length === 1
|
|
@@ -103,7 +117,7 @@ const GroupByDropdown = ({ groupBy, toggleGroupBy, onLabelClick, labelsButtonRef
|
|
|
103
117
|
const selectedLabels = groupBy
|
|
104
118
|
.filter(l => l.startsWith(FIELD_LABELS))
|
|
105
119
|
.map(l => l.slice(FIELD_LABELS.length + 1));
|
|
106
|
-
return (_jsxs("div", { className: "relative", children: [_jsx("label", { className: "text-sm", children: "Group by" }), _jsxs("div", { className: "relative text-left", id: "h-group-by-filter", children: [_jsxs(Button, { variant: "neutral", onClick: () => setIsDropdownOpen(!isDropdownOpen), className: "relative w-max cursor-default rounded-md border bg-white py-2 pl-3 pr-[1.7rem] text-left text-sm shadow-sm dark:border-gray-600 dark:bg-gray-900 sm:text-sm", children: [_jsx("span", { className: "block overflow-x-hidden text-ellipsis", children: label }), _jsx("span", { className: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400", children: _jsx(Icon, { icon: "heroicons:chevron-down-20-solid", "aria-hidden": "true" }) })] }), _jsx(Transition, { as: "div", leave: "transition ease-in duration-100", leaveFrom: "opacity-100", leaveTo: "opacity-0", show: isDropdownOpen, children: _jsx("div", { className: "absolute left-0 z-10 mt-1 min-w-[400px] overflow-auto rounded-md bg-gray-50 py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:border-gray-600 dark:bg-gray-900 dark:ring-white dark:ring-opacity-20 sm:text-sm", children: _jsx("div", { className: "p-4", children: _jsx("fieldset", { children: _jsxs("div", { className: "space-y-5", children: [groupByOptions.map(({ value, label, description, disabled }) => (_jsxs("div", { className: "relative flex items-start", children: [_jsx("div", { className: "flex h-6 items-center", children: _jsx("input", { id: value, name: value, type: "checkbox", disabled: disabled, className: "h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600", checked: groupBy.includes(value), onChange: () => toggleGroupBy(value) }) }), _jsxs("div", { className: "ml-3 text-sm leading-6", children: [_jsx("label", { htmlFor: value, className: "font-medium text-gray-900 dark:text-gray-200", children: label }), _jsx("p", { className: "text-gray-500 dark:text-gray-400", children: description })] })] }, value))), _jsxs("div", { className: "ml-7 flex flex-col items-start text-sm leading-6 cursor-pointer", onClick: onLabelClick, ref: labelsButtonRef, children: [_jsxs("div", { className: "flex justify-between w-full items-center", children: [_jsxs("div", { children: [_jsx("span", { className: "font-medium text-gray-900 dark:text-gray-200", children: "Labels" }), _jsx("p", { className: "text-gray-500 dark:text-gray-400", children: "Stacktraces are grouped by labels." })] }), _jsx(Icon, { icon: "flowbite:caret-right-solid", className: "h-[14px] w-[14px]" })] }), selectedLabels.length > 0 && (_jsxs("div", { className: "flex gap-2 flex-wrap", children: [_jsx("span", { className: "text-gray-500 dark:text-gray-200", children: "Selected labels:" }), _jsx("div", { className: "flex flex-wrap gap-3", children: selectedLabels.map(label => (_jsx("span", { className: "mr-2 px-3 py-1 text-xs text-gray-700 dark:text-gray-200 bg-gray-200 rounded-md dark:bg-gray-800", children: label }, label))) })] }))] })] }) }) }) }) })] })] }));
|
|
120
|
+
return (_jsxs("div", { className: "relative", ref: dropdownRef, children: [_jsx("label", { className: "text-sm", children: "Group by" }), _jsxs("div", { className: "relative text-left", id: "h-group-by-filter", children: [_jsxs(Button, { variant: "neutral", onClick: () => setIsDropdownOpen(!isDropdownOpen), className: "relative w-max cursor-default rounded-md border bg-white py-2 pl-3 pr-[1.7rem] text-left text-sm shadow-sm dark:border-gray-600 dark:bg-gray-900 sm:text-sm", children: [_jsx("span", { className: "block overflow-x-hidden text-ellipsis", children: label }), _jsx("span", { className: "pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2 text-gray-400", children: _jsx(Icon, { icon: "heroicons:chevron-down-20-solid", "aria-hidden": "true" }) })] }), _jsx(Transition, { as: "div", leave: "transition ease-in duration-100", leaveFrom: "opacity-100", leaveTo: "opacity-0", show: isDropdownOpen, children: _jsx("div", { className: "absolute left-0 z-10 mt-1 min-w-[400px] overflow-auto rounded-md bg-gray-50 py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:border-gray-600 dark:bg-gray-900 dark:ring-white dark:ring-opacity-20 sm:text-sm", children: _jsx("div", { className: "p-4", children: _jsx("fieldset", { children: _jsxs("div", { className: "space-y-5", children: [groupByOptions.map(({ value, label, description, disabled }) => (_jsxs("div", { className: "relative flex items-start", children: [_jsx("div", { className: "flex h-6 items-center", children: _jsx("input", { id: value, name: value, type: "checkbox", disabled: disabled, className: "h-4 w-4 rounded border-gray-300 text-indigo-600 focus:ring-indigo-600", checked: groupBy.includes(value), onChange: () => toggleGroupBy(value) }) }), _jsxs("div", { className: "ml-3 text-sm leading-6", children: [_jsx("label", { htmlFor: value, className: "font-medium text-gray-900 dark:text-gray-200", children: label }), _jsx("p", { className: "text-gray-500 dark:text-gray-400", children: description })] })] }, value))), _jsxs("div", { className: "ml-7 flex flex-col items-start text-sm leading-6 cursor-pointer", onClick: onLabelClick, ref: labelsButtonRef, children: [_jsxs("div", { className: "flex justify-between w-full items-center", children: [_jsxs("div", { children: [_jsx("span", { className: "font-medium text-gray-900 dark:text-gray-200", children: "Labels" }), _jsx("p", { className: "text-gray-500 dark:text-gray-400", children: "Stacktraces are grouped by labels." })] }), _jsx(Icon, { icon: "flowbite:caret-right-solid", className: "h-[14px] w-[14px]" })] }), selectedLabels.length > 0 && (_jsxs("div", { className: "flex gap-2 flex-wrap", children: [_jsx("span", { className: "text-gray-500 dark:text-gray-200", children: "Selected labels:" }), _jsx("div", { className: "flex flex-wrap gap-3", children: selectedLabels.map(label => (_jsx("span", { className: "mr-2 px-3 py-1 text-xs text-gray-700 dark:text-gray-200 bg-gray-200 rounded-md dark:bg-gray-800", children: label }, label))) })] }))] })] }) }) }) }) })] })] }));
|
|
107
121
|
};
|
|
108
122
|
const GroupByControls = ({ groupBy, labels, toggleGroupBy, setGroupByLabels, }) => {
|
|
109
123
|
const [isLabelSelectorOpen, setIsLabelSelectorOpen] = useState(false);
|
|
@@ -20,5 +20,5 @@ export const VisualisationToolbar = ({ groupBy, toggleGroupBy, groupByLabels, se
|
|
|
20
20
|
const { dashboardItems } = useDashboard();
|
|
21
21
|
const isTableViz = dashboardItems?.includes('table');
|
|
22
22
|
const isGraphViz = dashboardItems?.includes('icicle');
|
|
23
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex w-full justify-between items-end", children: [_jsxs("div", { className: "flex gap-3 items-end", children: [_jsxs(_Fragment, { children: [_jsx(GroupByDropdown, { groupBy: groupBy, toggleGroupBy: toggleGroupBy, labels: groupByLabels, setGroupByLabels: setGroupByLabels }), _jsx(MultiLevelDropdown, { profileType: profileType, onSelect: () => { } })] }), _jsx(FilterByFunctionButton, {}), profileViewExternalSubActions != null ? profileViewExternalSubActions : null] }), _jsxs("div", { className: "flex gap-3", children: [preferencesModal
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "flex w-full justify-between items-end", children: [_jsxs("div", { className: "flex gap-3 items-end", children: [_jsxs(_Fragment, { children: [_jsx(GroupByDropdown, { groupBy: groupBy, toggleGroupBy: toggleGroupBy, labels: groupByLabels, setGroupByLabels: setGroupByLabels }), _jsx(MultiLevelDropdown, { profileType: profileType, onSelect: () => { } })] }), _jsx(FilterByFunctionButton, {}), profileViewExternalSubActions != null ? profileViewExternalSubActions : null] }), _jsxs("div", { className: "flex gap-3", children: [preferencesModal === true && _jsx(UserPreferencesModal, {}), _jsx(ShareButton, { profileSource: profileSource, queryClient: queryClient, queryRequest: profileSource?.QueryRequest() ?? undefined, onDownloadPProf: onDownloadPProf, pprofdownloading: pprofdownloading ?? false, profileViewExternalSubActions: profileViewExternalSubActions }), showVisualizationSelector ? _jsx(ViewSelector, {}) : null] })] }), isGraphViz && !isTableViz && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsx(IcicleGraphToolbar, { curPath: curPath, setNewCurPath: setNewCurPath })] })), isTableViz && !isGraphViz && (_jsxs(_Fragment, { children: [_jsx(Divider, {}), _jsx(TableToolbar, { profileType: profileType, total: total, filtered: filtered, clearSelection: clearSelection, currentSearchString: currentSearchString })] }))] }));
|
|
24
24
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parca/profile",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.456",
|
|
4
4
|
"description": "Profile viewing libraries",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@headlessui/react": "^1.7.19",
|
|
7
7
|
"@iconify/react": "^4.0.0",
|
|
8
8
|
"@parca/client": "0.16.125",
|
|
9
|
-
"@parca/components": "0.16.
|
|
9
|
+
"@parca/components": "0.16.313",
|
|
10
10
|
"@parca/dynamicsize": "0.16.65",
|
|
11
|
-
"@parca/hooks": "0.0.
|
|
11
|
+
"@parca/hooks": "0.0.76",
|
|
12
12
|
"@parca/icons": "0.16.71",
|
|
13
13
|
"@parca/parser": "0.16.78",
|
|
14
14
|
"@parca/store": "0.16.162",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"access": "public",
|
|
75
75
|
"registry": "https://registry.npmjs.org/"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "0e071ed2fe26da987341ab6f8fcee0e272e9aa64"
|
|
78
78
|
}
|
|
@@ -23,6 +23,7 @@ import 'react-contexify/dist/ReactContexify.css';
|
|
|
23
23
|
|
|
24
24
|
import {ProfileType} from '@parca/parser';
|
|
25
25
|
|
|
26
|
+
import TextWithEllipsis from './TextWithEllipsis';
|
|
26
27
|
import {
|
|
27
28
|
FIELD_CHILDREN,
|
|
28
29
|
FIELD_CUMULATIVE,
|
|
@@ -412,9 +413,12 @@ export const IcicleNode = React.memo(function IcicleNodeNoMemo({
|
|
|
412
413
|
/>
|
|
413
414
|
{width > 5 && (
|
|
414
415
|
<svg width={width - 5} height={height}>
|
|
415
|
-
<
|
|
416
|
-
{name}
|
|
417
|
-
|
|
416
|
+
<TextWithEllipsis
|
|
417
|
+
text={name}
|
|
418
|
+
x={5}
|
|
419
|
+
y={15}
|
|
420
|
+
width={width - 10} // Subtract padding from available width
|
|
421
|
+
/>
|
|
418
422
|
</svg>
|
|
419
423
|
)}
|
|
420
424
|
</g>
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Copyright 2022 The Parca Authors
|
|
2
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
// you may not use this file except in compliance with the License.
|
|
4
|
+
// You may obtain a copy of the License at
|
|
5
|
+
//
|
|
6
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
//
|
|
8
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
// See the License for the specific language governing permissions and
|
|
12
|
+
// limitations under the License.
|
|
13
|
+
|
|
14
|
+
import {useEffect, useRef, useState} from 'react';
|
|
15
|
+
|
|
16
|
+
import {USER_PREFERENCES, useUserPreference} from '@parca/hooks';
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
text: string;
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
width: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function calculateTruncatedText(
|
|
26
|
+
text: string,
|
|
27
|
+
textElement: SVGTextElement,
|
|
28
|
+
maxWidth: number
|
|
29
|
+
): string {
|
|
30
|
+
// Create a temporary element for measurement
|
|
31
|
+
const tempElement = textElement.cloneNode() as SVGTextElement;
|
|
32
|
+
tempElement.textContent = text;
|
|
33
|
+
textElement.parentElement?.appendChild(tempElement);
|
|
34
|
+
|
|
35
|
+
// If the text fits, return it
|
|
36
|
+
const fullWidth = tempElement.getComputedTextLength();
|
|
37
|
+
if (fullWidth <= maxWidth) {
|
|
38
|
+
textElement.parentElement?.removeChild(tempElement);
|
|
39
|
+
return text;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Binary search to find the maximum text that fits
|
|
43
|
+
let start = 0;
|
|
44
|
+
let end = text.length;
|
|
45
|
+
let result = text;
|
|
46
|
+
|
|
47
|
+
while (start < end) {
|
|
48
|
+
const mid = Math.floor((start + end + 1) / 2);
|
|
49
|
+
const truncated = text.slice(-mid);
|
|
50
|
+
|
|
51
|
+
tempElement.textContent = truncated;
|
|
52
|
+
const currentWidth = tempElement.getComputedTextLength();
|
|
53
|
+
|
|
54
|
+
if (currentWidth <= maxWidth) {
|
|
55
|
+
result = truncated;
|
|
56
|
+
start = mid;
|
|
57
|
+
} else {
|
|
58
|
+
end = mid - 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
textElement.parentElement?.removeChild(tempElement);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function TextWithEllipsis({text, x, y, width}: Props): JSX.Element {
|
|
67
|
+
const textRef = useRef<SVGTextElement>(null);
|
|
68
|
+
const [displayText, setDisplayText] = useState(text);
|
|
69
|
+
const [showFunctionNameFromLeft] = useUserPreference<boolean>(
|
|
70
|
+
USER_PREFERENCES.SHOW_FUNCTION_NAME_FROM_LEFT.key
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
const textElement = textRef.current;
|
|
75
|
+
if (textElement === null) return;
|
|
76
|
+
|
|
77
|
+
const newText = showFunctionNameFromLeft
|
|
78
|
+
? text
|
|
79
|
+
: calculateTruncatedText(text, textElement, width);
|
|
80
|
+
|
|
81
|
+
setDisplayText(newText);
|
|
82
|
+
}, [text, width, showFunctionNameFromLeft]);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<text ref={textRef} x={x} y={y} className="text-xs">
|
|
86
|
+
{displayText}
|
|
87
|
+
</text>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export default TextWithEllipsis;
|
|
@@ -167,6 +167,25 @@ const GroupByDropdown: React.FC<GroupByDropdownProps> = ({
|
|
|
167
167
|
labelsButtonRef,
|
|
168
168
|
}) => {
|
|
169
169
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
170
|
+
const dropdownRef = useRef<HTMLDivElement>(null);
|
|
171
|
+
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
const handleClickOutside = (event: MouseEvent): void => {
|
|
174
|
+
if (
|
|
175
|
+
isDropdownOpen &&
|
|
176
|
+
dropdownRef.current != null &&
|
|
177
|
+
!dropdownRef.current.contains(event.target as Node)
|
|
178
|
+
) {
|
|
179
|
+
setIsDropdownOpen(false);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
184
|
+
return () => {
|
|
185
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
186
|
+
};
|
|
187
|
+
}, [isDropdownOpen]);
|
|
188
|
+
|
|
170
189
|
const label =
|
|
171
190
|
groupBy.length === 0
|
|
172
191
|
? 'Nothing'
|
|
@@ -179,7 +198,7 @@ const GroupByDropdown: React.FC<GroupByDropdownProps> = ({
|
|
|
179
198
|
.map(l => l.slice(FIELD_LABELS.length + 1));
|
|
180
199
|
|
|
181
200
|
return (
|
|
182
|
-
<div className="relative">
|
|
201
|
+
<div className="relative" ref={dropdownRef}>
|
|
183
202
|
<label className="text-sm">Group by</label>
|
|
184
203
|
<div className="relative text-left" id="h-group-by-filter">
|
|
185
204
|
<Button
|
|
@@ -157,7 +157,7 @@ export const VisualisationToolbar: FC<VisualisationToolbarProps> = ({
|
|
|
157
157
|
{profileViewExternalSubActions != null ? profileViewExternalSubActions : null}
|
|
158
158
|
</div>
|
|
159
159
|
<div className="flex gap-3">
|
|
160
|
-
{preferencesModal
|
|
160
|
+
{preferencesModal === true && <UserPreferencesModal />}
|
|
161
161
|
<ShareButton
|
|
162
162
|
profileSource={profileSource}
|
|
163
163
|
queryClient={queryClient}
|