@parca/profile 0.16.426 → 0.16.428

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.
Files changed (71) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.js +1 -1
  3. package/dist/ProfileIcicleGraph/index.d.ts +1 -1
  4. package/dist/ProfileIcicleGraph/index.d.ts.map +1 -1
  5. package/dist/ProfileIcicleGraph/index.js +4 -59
  6. package/dist/ProfileView/VisualizationPanel.d.ts.map +1 -1
  7. package/dist/ProfileView/VisualizationPanel.js +2 -3
  8. package/dist/ProfileView/index.d.ts.map +1 -1
  9. package/dist/ProfileView/index.js +21 -14
  10. package/dist/SimpleMatchers/index.d.ts.map +1 -1
  11. package/dist/SimpleMatchers/index.js +9 -2
  12. package/dist/Table/ColumnsVisibility.js +1 -1
  13. package/dist/Table/index.d.ts +6 -0
  14. package/dist/Table/index.d.ts.map +1 -1
  15. package/dist/Table/index.js +45 -21
  16. package/dist/components/ActionButtons/GroupByDropdown.d.ts.map +1 -0
  17. package/dist/{ProfileIcicleGraph → components}/ActionButtons/GroupByDropdown.js +1 -1
  18. package/dist/components/FilterByFunctionButton.d.ts.map +1 -0
  19. package/dist/components/ShareButton/ResultBox.d.ts.map +1 -0
  20. package/dist/components/ShareButton/index.d.ts +14 -0
  21. package/dist/components/ShareButton/index.d.ts.map +1 -0
  22. package/dist/components/{ProfileShareButton → ShareButton}/index.js +28 -5
  23. package/dist/components/ViewSelector/Dropdown.d.ts +30 -0
  24. package/dist/components/ViewSelector/Dropdown.d.ts.map +1 -0
  25. package/dist/components/ViewSelector/Dropdown.js +41 -0
  26. package/dist/components/ViewSelector/index.d.ts +3 -0
  27. package/dist/components/ViewSelector/index.d.ts.map +1 -0
  28. package/dist/{ProfileView/ViewSelector.js → components/ViewSelector/index.js} +25 -12
  29. package/dist/components/VisualisationToolbar/MultiLevelDropdown.d.ts +9 -0
  30. package/dist/components/VisualisationToolbar/MultiLevelDropdown.d.ts.map +1 -0
  31. package/dist/components/VisualisationToolbar/MultiLevelDropdown.js +123 -0
  32. package/dist/components/VisualisationToolbar/TableColumnsDropdown.d.ts +9 -0
  33. package/dist/components/VisualisationToolbar/TableColumnsDropdown.d.ts.map +1 -0
  34. package/dist/components/VisualisationToolbar/TableColumnsDropdown.js +189 -0
  35. package/dist/components/VisualisationToolbar/index.d.ts +25 -0
  36. package/dist/components/VisualisationToolbar/index.d.ts.map +1 -0
  37. package/dist/components/VisualisationToolbar/index.js +54 -0
  38. package/dist/styles.css +1 -1
  39. package/package.json +4 -4
  40. package/src/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.tsx +1 -1
  41. package/src/ProfileIcicleGraph/index.tsx +3 -206
  42. package/src/ProfileView/VisualizationPanel.tsx +1 -6
  43. package/src/ProfileView/index.tsx +46 -56
  44. package/src/SimpleMatchers/index.tsx +11 -2
  45. package/src/Table/ColumnsVisibility.tsx +1 -1
  46. package/src/Table/index.tsx +64 -42
  47. package/src/{ProfileIcicleGraph → components}/ActionButtons/GroupByDropdown.tsx +1 -1
  48. package/src/components/{ProfileShareButton → ShareButton}/index.tsx +88 -24
  49. package/src/components/ViewSelector/Dropdown.tsx +181 -0
  50. package/src/{ProfileView/ViewSelector.tsx → components/ViewSelector/index.tsx} +32 -39
  51. package/src/components/VisualisationToolbar/MultiLevelDropdown.tsx +258 -0
  52. package/src/components/VisualisationToolbar/TableColumnsDropdown.tsx +222 -0
  53. package/src/components/VisualisationToolbar/index.tsx +169 -0
  54. package/dist/ProfileIcicleGraph/ActionButtons/GroupByDropdown.d.ts.map +0 -1
  55. package/dist/ProfileIcicleGraph/ActionButtons/SortBySelect.d.ts +0 -7
  56. package/dist/ProfileIcicleGraph/ActionButtons/SortBySelect.d.ts.map +0 -1
  57. package/dist/ProfileIcicleGraph/ActionButtons/SortBySelect.js +0 -44
  58. package/dist/ProfileView/FilterByFunctionButton.d.ts.map +0 -1
  59. package/dist/ProfileView/ViewSelector.d.ts +0 -13
  60. package/dist/ProfileView/ViewSelector.d.ts.map +0 -1
  61. package/dist/components/ProfileShareButton/ResultBox.d.ts.map +0 -1
  62. package/dist/components/ProfileShareButton/index.d.ts +0 -9
  63. package/dist/components/ProfileShareButton/index.d.ts.map +0 -1
  64. package/src/ProfileIcicleGraph/ActionButtons/SortBySelect.tsx +0 -81
  65. /package/dist/{ProfileIcicleGraph → components}/ActionButtons/GroupByDropdown.d.ts +0 -0
  66. /package/dist/{ProfileView → components}/FilterByFunctionButton.d.ts +0 -0
  67. /package/dist/{ProfileView → components}/FilterByFunctionButton.js +0 -0
  68. /package/dist/components/{ProfileShareButton → ShareButton}/ResultBox.d.ts +0 -0
  69. /package/dist/components/{ProfileShareButton → ShareButton}/ResultBox.js +0 -0
  70. /package/src/{ProfileView → components}/FilterByFunctionButton.tsx +0 -0
  71. /package/src/components/{ProfileShareButton → ShareButton}/ResultBox.tsx +0 -0
@@ -0,0 +1,41 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } 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 { Fragment } from 'react';
15
+ import { Listbox, Transition } from '@headlessui/react';
16
+ import { Icon } from '@iconify/react';
17
+ import cx from 'classnames';
18
+ import { Button, useParcaContext } from '@parca/components';
19
+ export function contructItemsFromArray(items) {
20
+ return items.map(item => ({
21
+ key: item.key,
22
+ element: { active: _jsx(_Fragment, { children: item.label }), expanded: _jsx(_Fragment, { children: item.label }) },
23
+ innerAction: item.innerAction,
24
+ }));
25
+ }
26
+ const Dropdown = ({ items, selectedKey, onSelection, placeholder, width, className = '', loading, primary = false, disabled = false, icon, id, }) => {
27
+ const selection = items.find(v => v.key === selectedKey) ?? {
28
+ key: selectedKey,
29
+ element: { active: _jsx(_Fragment, { children: selectedKey }), expanded: _jsx(_Fragment, { children: selectedKey }) },
30
+ };
31
+ const { loader } = useParcaContext();
32
+ const styles = 'relative border rounded-md shadow-sm px-4 py-2 text-left cursor-default focus:outline-none focus:ring-1 items-center focus:ring-indigo-500 focus:border-indigo-500 text-sm flex gap-2 flex items-center justify-between';
33
+ const defaultStyles = 'bg-white dark:bg-gray-900 dark:border-gray-600';
34
+ const primaryStyles = 'text-gray-100 dark:gray-900 bg-indigo-600 border-indigo-500 font-medium py-2 px-4';
35
+ return (_jsx(Listbox, { value: selectedKey, onChange: onSelection, children: ({ open }) => (_jsxs("div", { className: "relative", children: [_jsx("div", { id: id, children: _jsxs(Listbox.Button, { className: cx(styles, width !== undefined ? `w-${width}` : 'w-full', disabled ? 'cursor-not-allowed opacity-50 pointer-events-none' : '', primary ? primaryStyles : defaultStyles, { [className]: className.length > 0 }), children: [_jsx("div", { className: cx(icon != null ? '' : 'block overflow-x-hidden text-ellipsis'), children: selection?.key !== '' ? selection.element.active : placeholder }), _jsx("div", { className: cx(icon != null ? '' : 'pointer-events-none text-gray-400'), children: icon ?? _jsx(Icon, { icon: "heroicons:chevron-up-down-20-solid", "aria-hidden": "true" }) })] }) }), _jsx(Transition, { show: open, as: Fragment, leave: "transition ease-in duration-100", leaveFrom: "opacity-100", leaveTo: "opacity-0", children: _jsx(Listbox.Options, { className: "absolute w-[246px] right-0 z-50 mt-1 max-h-[50vh] 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: loading === true ? (_jsx("div", { className: "w-[270px]", children: loader })) : (items.length > 0 &&
36
+ items.map(option => (_jsx(Listbox.Option, { id: `h-select-option-${option.key}`, disabled: option.disabled ?? false, className: ({ active }) => cx(active && 'bg-indigo-600 text-white', 'relative flex cursor-default select-none py-2 px-3'), value: option.key, children: ({ selected, active, disabled }) => (_jsxs("div", { className: "flex items-center w-full justify-between", children: [_jsx("div", { className: "flex items-center", children: _jsx("span", { className: cx(selected ? 'font-semibold' : 'font-normal', disabled && 'opacity-50'), children: option.element.expanded }) }), option.innerAction !== undefined && (_jsxs(Button, { variant: "neutral", className: "p-[6px]", onClick: e => {
37
+ e.stopPropagation();
38
+ option.innerAction?.onClick();
39
+ }, children: [option.innerAction.text, option.innerAction.text === 'Add Panel' && (_jsx(Icon, { icon: "ic:baseline-plus", className: "w-[14px] h-[14px] ml-2" }))] })), selected ? (_jsx("span", { className: cx(active ? 'text-white' : 'text-indigo-600', 'absolute inset-y-0 right-0 flex items-center pr-4'), children: _jsx(Icon, { icon: "heroicons:check-20-solid", "aria-hidden": "true" }) })) : null] })) }, option.key)))) }) })] })) }));
40
+ };
41
+ export default Dropdown;
@@ -0,0 +1,3 @@
1
+ declare const ViewSelector: () => JSX.Element;
2
+ export default ViewSelector;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/ViewSelector/index.tsx"],"names":[],"mappings":"AAiBA,QAAA,MAAM,YAAY,QAAO,GAAG,CAAC,OAwF5B,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -11,8 +11,9 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
11
11
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  // See the License for the specific language governing permissions and
13
13
  // limitations under the License.
14
- import { Select, useParcaContext, useURLState } from '@parca/components';
15
- const ViewSelector = ({ defaultValue, position, placeholderText, primary = false, addView = false, disabled = false, icon, id, }) => {
14
+ import { useParcaContext, useURLState } from '@parca/components';
15
+ import Dropdown from './Dropdown';
16
+ const ViewSelector = () => {
16
17
  const [dashboardItems = ['icicle'], setDashboardItems] = useURLState('dashboard_items', {
17
18
  alwaysReturnArray: true,
18
19
  });
@@ -31,28 +32,40 @@ const ViewSelector = ({ defaultValue, position, placeholderText, primary = false
31
32
  expanded: (_jsxs(_Fragment, { children: [title, supportingText !== null && _jsx("span", { className: "text-xs", children: supportingText })] })),
32
33
  };
33
34
  };
35
+ const getInnerActionForItem = (item) => {
36
+ if (dashboardItems.length === 1 && item.key === dashboardItems[0])
37
+ return undefined;
38
+ return {
39
+ text: !item.canBeSelected && item.key === 'source'
40
+ ? 'Add Panel'
41
+ : item.canBeSelected
42
+ ? 'Add Panel'
43
+ : 'Close Panel',
44
+ onClick: () => {
45
+ if (item.canBeSelected) {
46
+ setDashboardItems([...dashboardItems, item.key]);
47
+ }
48
+ else {
49
+ setDashboardItems(dashboardItems.filter(v => v !== item.key));
50
+ }
51
+ },
52
+ };
53
+ };
34
54
  const items = allItems.map(item => ({
35
55
  key: item.key,
36
56
  disabled: !item.canBeSelected,
37
57
  element: getOption(item),
58
+ innerAction: getInnerActionForItem(item),
38
59
  }));
39
60
  const onSelection = (value) => {
40
- if (addView) {
41
- setDashboardItems([dashboardItems[0], value]);
42
- return;
43
- }
44
61
  const isOnlyChart = dashboardItems.length === 1;
45
62
  if (isOnlyChart) {
46
63
  setDashboardItems([value]);
47
64
  return;
48
65
  }
49
- // Note: this will need to be updated if we ever have more more than 2 panels
50
- const isFirstChart = position === 0;
51
- const newDashboardItems = isFirstChart
52
- ? [value, dashboardItems[1]]
53
- : [dashboardItems[0], value];
66
+ const newDashboardItems = [dashboardItems[0], value];
54
67
  setDashboardItems(newDashboardItems);
55
68
  };
56
- return (_jsx(Select, { className: "h-view-selector", items: items, selectedKey: defaultValue, onSelection: onSelection, placeholder: placeholderText ?? 'Select view type...', primary: primary, disabled: disabled, icon: icon, id: id }));
69
+ return (_jsx(Dropdown, { className: "h-view-selector", items: items, selectedKey: dashboardItems.length >= 2 ? 'Multiple' : dashboardItems[0], onSelection: onSelection, placeholder: 'Select view type...', id: "h-view-selector" }));
57
70
  };
58
71
  export default ViewSelector;
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+ import { ProfileType } from '@parca/parser';
3
+ interface MultiLevelDropdownProps {
4
+ onSelect: (path: string[]) => void;
5
+ profileType?: ProfileType;
6
+ }
7
+ declare const MultiLevelDropdown: React.FC<MultiLevelDropdownProps>;
8
+ export default MultiLevelDropdown;
9
+ //# sourceMappingURL=MultiLevelDropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MultiLevelDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/VisualisationToolbar/MultiLevelDropdown.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAOzC,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAgH1C,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACnC,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAsHzD,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,123 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { useCallback } from 'react';
15
+ import { Menu } from '@headlessui/react';
16
+ import { Icon } from '@iconify/react';
17
+ import { useURLState } from '@parca/components';
18
+ import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
19
+ import { FIELD_CUMULATIVE, FIELD_DIFF, FIELD_FUNCTION_NAME, } from '../../ProfileIcicleGraph/IcicleGraphArrow';
20
+ import { useProfileViewContext } from '../../ProfileView/ProfileViewContext';
21
+ const MenuItem = ({ label, items, onclick, onSelect, path = [], id, closeDropdown, isNested = false, activeValue, value, disabled = false, icon, }) => {
22
+ const isActive = isNested && value === activeValue;
23
+ const handleSelect = () => {
24
+ if (items === undefined) {
25
+ if (onclick !== undefined) {
26
+ onclick();
27
+ closeDropdown();
28
+ }
29
+ else {
30
+ onSelect([...path, label]);
31
+ closeDropdown();
32
+ }
33
+ }
34
+ };
35
+ return (_jsx("div", { className: "relative", children: _jsx(Menu, { children: ({ close }) => (_jsxs(_Fragment, { children: [_jsxs(Menu.Button, { className: `w-full text-left px-4 py-2 text-sm ${disabled
36
+ ? 'text-gray-400'
37
+ : isActive
38
+ ? 'text-white bg-indigo-400 hover:text-white'
39
+ : 'text-white-600 hover:bg-indigo-600 hover:text-white'} flex justify-between items-center`, onClick: handleSelect, id: id, disabled: disabled, children: [_jsxs("span", { className: "flex items-center", children: [_jsxs("div", { className: "flex items-center", children: [_jsx("span", { children: label }), icon !== undefined && _jsx(Icon, { icon: icon, className: "ml-2 h-4 w-4" })] }), isActive && _jsx(Icon, { icon: "heroicons-solid:check", className: "ml-2 h-4 w-4" })] }), items !== undefined && (_jsx(Icon, { icon: "flowbite:caret-right-solid", className: "h-[14px] w-[14px]" }))] }), items !== undefined && (_jsx(Menu.Items, { className: "absolute left-full top-0 w-56 mt-0 origin-top-right bg-white border border-gray-200 rounded-md shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none dark:bg-gray-900 ml-1 dark:border-gray-600", children: items?.map((item, index) => (_jsx(MenuItem, { ...item, onSelect: selectedPath => {
40
+ onSelect([...path, ...selectedPath]);
41
+ close();
42
+ closeDropdown();
43
+ }, path: [...path, label], closeDropdown: closeDropdown, isNested: true, activeValue: activeValue }, index))) }))] })) }) }));
44
+ };
45
+ const MultiLevelDropdown = ({ onSelect, profileType }) => {
46
+ const [storeSortBy, setStoreSortBy] = useURLState('sort_by', {
47
+ defaultValue: FIELD_FUNCTION_NAME,
48
+ });
49
+ const [colorStackLegend, setStoreColorStackLegend] = useURLState('color_stack_legend');
50
+ const [binaryFrameFilter, setBinaryFrameFilter] = useURLState('binary_frame_filter');
51
+ const { compareMode } = useProfileViewContext();
52
+ const [colorProfileName] = useUserPreference(USER_PREFERENCES.FLAMEGRAPH_COLOR_PROFILE.key);
53
+ const [invertStack = '', setInvertStack] = useURLState('invert_call_stack');
54
+ const isInvert = invertStack === 'true';
55
+ const isColorStackLegendEnabled = colorStackLegend === 'true';
56
+ // By default, we want delta profiles (CPU) to be relatively compared.
57
+ // For non-delta profiles, like goroutines or memory, we want the profiles to be compared absolutely.
58
+ const compareAbsoluteDefault = profileType?.delta === false ? 'true' : 'false';
59
+ const [compareAbsolute = compareAbsoluteDefault, setCompareAbsolute] = useURLState('compare_absolute');
60
+ const isCompareAbsolute = compareAbsolute === 'true';
61
+ const setColorStackLegend = useCallback((value) => {
62
+ setStoreColorStackLegend(value);
63
+ }, [setStoreColorStackLegend]);
64
+ const resetLegend = () => {
65
+ setBinaryFrameFilter([]);
66
+ };
67
+ const menuItems = [
68
+ {
69
+ label: 'Sort by',
70
+ id: 'h-sort-by-filter',
71
+ items: [
72
+ {
73
+ label: 'Function',
74
+ onclick: () => setStoreSortBy(FIELD_FUNCTION_NAME),
75
+ value: FIELD_FUNCTION_NAME,
76
+ },
77
+ {
78
+ label: 'Cumulative',
79
+ onclick: () => setStoreSortBy(FIELD_CUMULATIVE),
80
+ value: FIELD_CUMULATIVE,
81
+ },
82
+ {
83
+ label: 'Diff',
84
+ onclick: () => setStoreSortBy(FIELD_DIFF),
85
+ value: FIELD_DIFF,
86
+ disabled: !compareMode,
87
+ },
88
+ ],
89
+ hide: false,
90
+ icon: 'material-symbols:sort',
91
+ },
92
+ {
93
+ label: isColorStackLegendEnabled ? 'Hide legend' : 'Show legend',
94
+ onclick: () => setColorStackLegend(isColorStackLegendEnabled ? 'false' : 'true'),
95
+ hide: compareMode || colorProfileName === 'default',
96
+ id: 'h-show-legend-button',
97
+ icon: isColorStackLegendEnabled ? 'ph:eye-closed' : 'ph:eye',
98
+ },
99
+ {
100
+ label: isInvert ? 'Original Call Stack' : 'Invert Call Stack',
101
+ onclick: () => setInvertStack(isInvert ? '' : 'true'),
102
+ hide: false,
103
+ icon: isInvert ? 'ph:sort-ascending' : 'ph:sort-descending',
104
+ },
105
+ {
106
+ label: isCompareAbsolute ? 'Compare Relative' : 'Compare Absolute',
107
+ onclick: () => setCompareAbsolute(isCompareAbsolute ? 'false' : 'true'),
108
+ hide: !compareMode,
109
+ icon: isCompareAbsolute ? 'fluent-mdl2:compare' : 'fluent-mdl2:compare-uneven',
110
+ },
111
+ {
112
+ label: 'Reset Legend',
113
+ hide: binaryFrameFilter === undefined || binaryFrameFilter.length === 0,
114
+ onclick: () => resetLegend(),
115
+ id: 'h-reset-legend-button',
116
+ icon: 'system-uicons:reset',
117
+ },
118
+ ];
119
+ return (_jsx("div", { className: "relative inline-block text-left", children: _jsx(Menu, { children: ({ open, close }) => (_jsxs(_Fragment, { children: [_jsx(Menu.Button, { className: "inline-flex dark:bg-gray-900 dark:border-gray-600 justify-center w-full px-4 py-2 text-sm font-medium text-white bg-white rounded-md focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 border border-gray-200", children: _jsx(Icon, { icon: "pepicons-pencil:dots-x", className: "h-5 w-5 text-gray-800 dark:text-gray-200" }) }), open && (_jsxs(Menu.Items, { className: "absolute z-30 right-0 w-56 mt-2 py-2 origin-top-right bg-white rounded-md shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none border dark:bg-gray-900 dark:border-gray-600", children: [_jsx("span", { className: "text-xs text-gray-400 capitalize px-4 py-3", children: "actions" }), menuItems
120
+ .filter(item => item.hide !== undefined && !item.hide)
121
+ .map((item, index) => (_jsx(MenuItem, { ...item, onSelect: onSelect, closeDropdown: close, activeValue: storeSortBy }, index)))] }))] })) }) }));
122
+ };
123
+ export default MultiLevelDropdown;
@@ -0,0 +1,9 @@
1
+ import { ProfileType } from '@parca/parser';
2
+ interface Props {
3
+ profileType?: ProfileType;
4
+ total: bigint;
5
+ filtered: bigint;
6
+ }
7
+ declare const TableColumnsDropdown: ({ profileType, total, filtered }: Props) => JSX.Element;
8
+ export default TableColumnsDropdown;
9
+ //# sourceMappingURL=TableColumnsDropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableColumnsDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/VisualisationToolbar/TableColumnsDropdown.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAO1C,UAAU,KAAK;IACb,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,QAAA,MAAM,oBAAoB,qCAAoC,KAAK,KAAG,GAAG,CAAC,OA4LzE,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,189 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } 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, useMemo, useState } from 'react';
15
+ import { createColumnHelper } from '@tanstack/table-core';
16
+ import { useURLState } from '@parca/components';
17
+ import { valueFormatter } from '@parca/utilities';
18
+ import { useProfileViewContext } from '../../ProfileView/ProfileViewContext';
19
+ import { addPlusSign, getRatioString, isDummyRow } from '../../Table';
20
+ import ColumnsVisibility from '../../Table/ColumnsVisibility';
21
+ const TableColumnsDropdown = ({ profileType, total, filtered }) => {
22
+ const { compareMode } = useProfileViewContext();
23
+ const [tableColumns, setTableColumns] = useURLState('table_columns', {
24
+ alwaysReturnArray: true,
25
+ });
26
+ const columnHelper = createColumnHelper();
27
+ const unit = useMemo(() => profileType?.sampleUnit ?? '', [profileType?.sampleUnit]);
28
+ const columns = useMemo(() => {
29
+ return [
30
+ columnHelper.accessor('flat', {
31
+ id: 'flat',
32
+ header: 'Flat',
33
+ cell: info => valueFormatter(info.getValue(), unit, 2),
34
+ size: 80,
35
+ meta: {
36
+ align: 'right',
37
+ },
38
+ invertSorting: true,
39
+ }),
40
+ columnHelper.accessor('flat', {
41
+ id: 'flatPercentage',
42
+ header: 'Flat (%)',
43
+ cell: info => {
44
+ if (isDummyRow(info.row.original)) {
45
+ return '';
46
+ }
47
+ return getRatioString(info.getValue(), total, filtered);
48
+ },
49
+ size: 120,
50
+ meta: {
51
+ align: 'right',
52
+ },
53
+ invertSorting: true,
54
+ }),
55
+ columnHelper.accessor('flatDiff', {
56
+ id: 'flatDiff',
57
+ header: 'Flat Diff',
58
+ cell: info => addPlusSign(valueFormatter(info.getValue(), unit, 2)),
59
+ size: 120,
60
+ meta: {
61
+ align: 'right',
62
+ },
63
+ invertSorting: true,
64
+ }),
65
+ columnHelper.accessor('flatDiff', {
66
+ id: 'flatDiffPercentage',
67
+ header: 'Flat Diff (%)',
68
+ cell: info => {
69
+ if (isDummyRow(info.row.original)) {
70
+ return '';
71
+ }
72
+ return getRatioString(info.getValue(), total, filtered);
73
+ },
74
+ size: 120,
75
+ meta: {
76
+ align: 'right',
77
+ },
78
+ invertSorting: true,
79
+ }),
80
+ columnHelper.accessor('cumulative', {
81
+ id: 'cumulative',
82
+ header: 'Cumulative',
83
+ cell: info => valueFormatter(info.getValue(), unit, 2),
84
+ size: 150,
85
+ meta: {
86
+ align: 'right',
87
+ },
88
+ invertSorting: true,
89
+ }),
90
+ columnHelper.accessor('cumulative', {
91
+ id: 'cumulativePercentage',
92
+ header: 'Cumulative (%)',
93
+ cell: info => {
94
+ if (isDummyRow(info.row.original)) {
95
+ return '';
96
+ }
97
+ return getRatioString(info.getValue(), total, filtered);
98
+ },
99
+ size: 150,
100
+ meta: {
101
+ align: 'right',
102
+ },
103
+ invertSorting: true,
104
+ }),
105
+ columnHelper.accessor('cumulativeDiff', {
106
+ id: 'cumulativeDiff',
107
+ header: 'Cumulative Diff',
108
+ cell: info => addPlusSign(valueFormatter(info.getValue(), unit, 2)),
109
+ size: 170,
110
+ meta: {
111
+ align: 'right',
112
+ },
113
+ invertSorting: true,
114
+ }),
115
+ columnHelper.accessor('cumulativeDiff', {
116
+ id: 'cumulativeDiffPercentage',
117
+ header: 'Cumulative Diff (%)',
118
+ cell: info => {
119
+ if (isDummyRow(info.row.original)) {
120
+ return '';
121
+ }
122
+ return getRatioString(info.getValue(), total, filtered);
123
+ },
124
+ size: 170,
125
+ meta: {
126
+ align: 'right',
127
+ },
128
+ invertSorting: true,
129
+ }),
130
+ columnHelper.accessor('name', {
131
+ id: 'name',
132
+ header: 'Name',
133
+ cell: info => info.getValue(),
134
+ }),
135
+ columnHelper.accessor('functionSystemName', {
136
+ id: 'functionSystemName',
137
+ header: 'Function System Name',
138
+ cell: info => info.getValue(),
139
+ }),
140
+ columnHelper.accessor('functionFileName', {
141
+ id: 'functionFileName',
142
+ header: 'Function File Name',
143
+ cell: info => info.getValue(),
144
+ }),
145
+ columnHelper.accessor('mappingFile', {
146
+ id: 'mappingFile',
147
+ header: 'Mapping File',
148
+ cell: info => info.getValue(),
149
+ }),
150
+ ];
151
+ // eslint-disable-next-line react-hooks/exhaustive-deps
152
+ }, [profileType, unit]);
153
+ const [columnVisibility, setColumnVisibility] = useState(() => {
154
+ return {
155
+ flat: true,
156
+ flatPercentage: false,
157
+ flatDiff: compareMode,
158
+ flatDiffPercentage: false,
159
+ cumulative: true,
160
+ cumulativePercentage: false,
161
+ cumulativeDiff: compareMode,
162
+ cumulativeDiffPercentage: false,
163
+ name: true,
164
+ functionSystemName: false,
165
+ functionFileName: false,
166
+ mappingFile: false,
167
+ };
168
+ });
169
+ useEffect(() => {
170
+ if (Array.isArray(tableColumns)) {
171
+ setColumnVisibility(prevState => {
172
+ const newState = { ...prevState };
173
+ Object.keys(newState).forEach(column => {
174
+ newState[column] = tableColumns.includes(column);
175
+ });
176
+ return newState;
177
+ });
178
+ }
179
+ }, [tableColumns]);
180
+ const updateColumnVisibility = (column, isVisible) => {
181
+ const updatedColumns = { ...columnVisibility, [column]: isVisible };
182
+ const newTableColumns = Object.keys(updatedColumns).filter(col => updatedColumns[col]);
183
+ setTableColumns(newTableColumns);
184
+ };
185
+ return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("label", { className: "text-sm", children: "Table Columns" }), _jsx(ColumnsVisibility, { columns: columns, visibility: columnVisibility, setVisibility: (id, visible) => {
186
+ updateColumnVisibility(id, visible);
187
+ } })] }));
188
+ };
189
+ export default TableColumnsDropdown;
@@ -0,0 +1,25 @@
1
+ import { QueryRequest, QueryServiceClient } from '@parca/client';
2
+ import { ProfileType } from '@parca/parser';
3
+ import { ProfileSource } from '../../ProfileSource';
4
+ interface Props {
5
+ groupBy: string | string[];
6
+ toggleGroupBy: (key: string) => void;
7
+ hasProfileSource: boolean;
8
+ isMultiPanelView: boolean;
9
+ dashboardItems: any;
10
+ profileSource?: ProfileSource;
11
+ queryClient?: QueryServiceClient;
12
+ queryRequest?: QueryRequest;
13
+ onDownloadPProf: () => void;
14
+ pprofdownloading: boolean | undefined;
15
+ curPath: string[];
16
+ setNewCurPath: (path: string[]) => void;
17
+ profileType?: ProfileType;
18
+ total: bigint;
19
+ filtered: bigint;
20
+ setSearchString?: (searchString: string) => void;
21
+ currentSearchString?: string;
22
+ }
23
+ declare const VisualisationToolbar: ({ hasProfileSource, profileSource, queryClient, onDownloadPProf, pprofdownloading, curPath, setNewCurPath, profileType, total, filtered, setSearchString, currentSearchString, }: Props) => JSX.Element;
24
+ export default VisualisationToolbar;
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/VisualisationToolbar/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAC,YAAY,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAQlD,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,GAAG,CAAC;IACpB,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,eAAe,EAAE,MAAM,IAAI,CAAC;IAC5B,gBAAgB,EAAE,OAAO,GAAG,SAAS,CAAC;IACtC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACxC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,QAAA,MAAM,oBAAoB,qLAavB,KAAK,KAAG,GAAG,CAAC,OAsGd,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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 { useCallback } from 'react';
15
+ import { Icon } from '@iconify/react';
16
+ import cx from 'classnames';
17
+ import { Button, UserPreferencesModal, useParcaContext, useURLState } from '@parca/components';
18
+ import { FIELD_FUNCTION_NAME } from '../../ProfileIcicleGraph/IcicleGraphArrow';
19
+ import GroupByDropdown from '../ActionButtons/GroupByDropdown';
20
+ import FilterByFunctionButton from '../FilterByFunctionButton';
21
+ import ShareButton from '../ShareButton';
22
+ import ViewSelector from '../ViewSelector';
23
+ import MultiLevelDropdown from './MultiLevelDropdown';
24
+ import TableColumnsDropdown from './TableColumnsDropdown';
25
+ const VisualisationToolbar = ({ hasProfileSource, profileSource, queryClient, onDownloadPProf, pprofdownloading, curPath, setNewCurPath, profileType, total, filtered, setSearchString, currentSearchString, }) => {
26
+ const [dashboardItems] = useURLState('dashboard_items', {
27
+ alwaysReturnArray: true,
28
+ });
29
+ const { profileViewExternalMainActions, profileViewExternalSubActions, preferencesModal } = useParcaContext();
30
+ const [groupBy, setStoreGroupBy] = useURLState('group_by', {
31
+ defaultValue: [FIELD_FUNCTION_NAME],
32
+ alwaysReturnArray: true,
33
+ });
34
+ const setGroupBy = useCallback((keys) => {
35
+ setStoreGroupBy(keys);
36
+ }, [setStoreGroupBy]);
37
+ const toggleGroupBy = useCallback((key) => {
38
+ groupBy.includes(key)
39
+ ? setGroupBy(groupBy.filter(v => v !== key)) // remove
40
+ : setGroupBy([...groupBy, key]); // add
41
+ }, [groupBy, setGroupBy]);
42
+ const clearSelection = useCallback(() => {
43
+ setSearchString?.('');
44
+ }, [setSearchString]);
45
+ const isTableViz = dashboardItems?.includes('table');
46
+ const isGraphViz = dashboardItems?.includes('icicle');
47
+ return (_jsx("div", { className: cx('mb-4 flex w-full', hasProfileSource || profileViewExternalMainActions != null
48
+ ? 'justify-between'
49
+ : 'justify-end', {
50
+ 'items-end': !hasProfileSource && profileViewExternalMainActions != null,
51
+ 'items-center': hasProfileSource,
52
+ }), children: _jsxs("div", { className: "flex w-full justify-between items-end", children: [_jsxs("div", { className: "flex gap-3 items-end", children: [isGraphViz && (_jsxs(_Fragment, { children: [_jsx(GroupByDropdown, { groupBy: groupBy, toggleGroupBy: toggleGroupBy }), _jsx(MultiLevelDropdown, { profileType: profileType, onSelect: () => { } }), _jsxs(Button, { variant: "neutral", className: "gap-2 w-max", onClick: () => setNewCurPath([]), disabled: curPath.length === 0, children: ["Reset graph", _jsx(Icon, { icon: "system-uicons:reset", width: 20 })] })] })), isTableViz && (_jsxs(_Fragment, { children: [_jsx(TableColumnsDropdown, { profileType: profileType, total: total, filtered: filtered }), dashboardItems.length > 1 && (_jsx(Button, { color: "neutral", onClick: clearSelection, className: "w-auto", variant: "neutral", disabled: currentSearchString === undefined || currentSearchString.length === 0, children: "Clear selection" }))] })), _jsx(FilterByFunctionButton, {}), profileViewExternalSubActions != null ? profileViewExternalSubActions : null] }), _jsxs("div", { className: "flex gap-3", children: [preferencesModal === true ? _jsx(UserPreferencesModal, {}) : null, _jsx(ShareButton, { profileSource: profileSource, queryClient: queryClient, queryRequest: profileSource?.QueryRequest() ?? undefined, onDownloadPProf: onDownloadPProf, pprofdownloading: pprofdownloading ?? false, profileViewExternalSubActions: profileViewExternalSubActions }), _jsx(ViewSelector, {})] })] }) }));
53
+ };
54
+ export default VisualisationToolbar;