@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,258 @@
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 React, {useCallback} from 'react';
15
+
16
+ import {Menu} from '@headlessui/react';
17
+ import {Icon} from '@iconify/react';
18
+
19
+ import {useURLState} from '@parca/components';
20
+ import {USER_PREFERENCES, useUserPreference} from '@parca/hooks';
21
+ import {ProfileType} from '@parca/parser';
22
+
23
+ import {
24
+ FIELD_CUMULATIVE,
25
+ FIELD_DIFF,
26
+ FIELD_FUNCTION_NAME,
27
+ } from '../../ProfileIcicleGraph/IcicleGraphArrow';
28
+ import {useProfileViewContext} from '../../ProfileView/ProfileViewContext';
29
+
30
+ interface MenuItemType {
31
+ label: string;
32
+ items?: MenuItemType[];
33
+ onclick?: () => void;
34
+ hide?: boolean;
35
+ id?: string;
36
+ disabled?: boolean;
37
+ active?: boolean;
38
+ value?: string;
39
+ icon?: string;
40
+ }
41
+
42
+ type MenuItemProps = MenuItemType & {
43
+ onSelect: (path: string[]) => void;
44
+ path?: string[];
45
+ closeDropdown: () => void;
46
+ isNested?: boolean;
47
+ activeValue?: string;
48
+ icon?: string;
49
+ };
50
+
51
+ const MenuItem: React.FC<MenuItemProps> = ({
52
+ label,
53
+ items,
54
+ onclick,
55
+ onSelect,
56
+ path = [],
57
+ id,
58
+ closeDropdown,
59
+ isNested = false,
60
+ activeValue,
61
+ value,
62
+ disabled = false,
63
+ icon,
64
+ }) => {
65
+ const isActive = isNested && value === activeValue;
66
+
67
+ const handleSelect = (): void => {
68
+ if (items === undefined) {
69
+ if (onclick !== undefined) {
70
+ onclick();
71
+ closeDropdown();
72
+ } else {
73
+ onSelect([...path, label]);
74
+ closeDropdown();
75
+ }
76
+ }
77
+ };
78
+
79
+ return (
80
+ <div className="relative">
81
+ <Menu>
82
+ {({close}) => (
83
+ <>
84
+ <Menu.Button
85
+ className={`w-full text-left px-4 py-2 text-sm ${
86
+ disabled
87
+ ? 'text-gray-400'
88
+ : isActive
89
+ ? 'text-white bg-indigo-400 hover:text-white'
90
+ : 'text-white-600 hover:bg-indigo-600 hover:text-white'
91
+ } flex justify-between items-center`}
92
+ onClick={handleSelect}
93
+ id={id}
94
+ disabled={disabled}
95
+ >
96
+ <span className="flex items-center">
97
+ <div className="flex items-center">
98
+ <span>{label}</span>
99
+ {icon !== undefined && <Icon icon={icon} className="ml-2 h-4 w-4" />}
100
+ </div>
101
+ {isActive && <Icon icon="heroicons-solid:check" className="ml-2 h-4 w-4" />}
102
+ </span>
103
+ {items !== undefined && (
104
+ <Icon icon="flowbite:caret-right-solid" className="h-[14px] w-[14px]" />
105
+ )}
106
+ </Menu.Button>
107
+ {items !== undefined && (
108
+ <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">
109
+ {items?.map((item, index) => (
110
+ <MenuItem
111
+ key={index}
112
+ {...item}
113
+ onSelect={selectedPath => {
114
+ onSelect([...path, ...selectedPath]);
115
+ close();
116
+ closeDropdown();
117
+ }}
118
+ path={[...path, label]}
119
+ closeDropdown={closeDropdown}
120
+ isNested={true}
121
+ activeValue={activeValue}
122
+ />
123
+ ))}
124
+ </Menu.Items>
125
+ )}
126
+ </>
127
+ )}
128
+ </Menu>
129
+ </div>
130
+ );
131
+ };
132
+
133
+ interface MultiLevelDropdownProps {
134
+ onSelect: (path: string[]) => void;
135
+ profileType?: ProfileType;
136
+ }
137
+
138
+ const MultiLevelDropdown: React.FC<MultiLevelDropdownProps> = ({onSelect, profileType}) => {
139
+ const [storeSortBy, setStoreSortBy] = useURLState('sort_by', {
140
+ defaultValue: FIELD_FUNCTION_NAME,
141
+ });
142
+ const [colorStackLegend, setStoreColorStackLegend] = useURLState('color_stack_legend');
143
+ const [binaryFrameFilter, setBinaryFrameFilter] = useURLState('binary_frame_filter');
144
+ const {compareMode} = useProfileViewContext();
145
+ const [colorProfileName] = useUserPreference<string>(
146
+ USER_PREFERENCES.FLAMEGRAPH_COLOR_PROFILE.key
147
+ );
148
+ const [invertStack = '', setInvertStack] = useURLState('invert_call_stack');
149
+ const isInvert = invertStack === 'true';
150
+ const isColorStackLegendEnabled = colorStackLegend === 'true';
151
+
152
+ // By default, we want delta profiles (CPU) to be relatively compared.
153
+ // For non-delta profiles, like goroutines or memory, we want the profiles to be compared absolutely.
154
+ const compareAbsoluteDefault = profileType?.delta === false ? 'true' : 'false';
155
+
156
+ const [compareAbsolute = compareAbsoluteDefault, setCompareAbsolute] =
157
+ useURLState('compare_absolute');
158
+ const isCompareAbsolute = compareAbsolute === 'true';
159
+
160
+ const setColorStackLegend = useCallback(
161
+ (value: string): void => {
162
+ setStoreColorStackLegend(value);
163
+ },
164
+ [setStoreColorStackLegend]
165
+ );
166
+
167
+ const resetLegend = (): void => {
168
+ setBinaryFrameFilter([]);
169
+ };
170
+
171
+ const menuItems: MenuItemType[] = [
172
+ {
173
+ label: 'Sort by',
174
+ id: 'h-sort-by-filter',
175
+ items: [
176
+ {
177
+ label: 'Function',
178
+ onclick: () => setStoreSortBy(FIELD_FUNCTION_NAME),
179
+ value: FIELD_FUNCTION_NAME,
180
+ },
181
+ {
182
+ label: 'Cumulative',
183
+ onclick: () => setStoreSortBy(FIELD_CUMULATIVE),
184
+ value: FIELD_CUMULATIVE,
185
+ },
186
+ {
187
+ label: 'Diff',
188
+ onclick: () => setStoreSortBy(FIELD_DIFF),
189
+ value: FIELD_DIFF,
190
+ disabled: !compareMode,
191
+ },
192
+ ],
193
+ hide: false,
194
+ icon: 'material-symbols:sort',
195
+ },
196
+ {
197
+ label: isColorStackLegendEnabled ? 'Hide legend' : 'Show legend',
198
+ onclick: () => setColorStackLegend(isColorStackLegendEnabled ? 'false' : 'true'),
199
+ hide: compareMode || colorProfileName === 'default',
200
+ id: 'h-show-legend-button',
201
+ icon: isColorStackLegendEnabled ? 'ph:eye-closed' : 'ph:eye',
202
+ },
203
+ {
204
+ label: isInvert ? 'Original Call Stack' : 'Invert Call Stack',
205
+ onclick: () => setInvertStack(isInvert ? '' : 'true'),
206
+ hide: false,
207
+ icon: isInvert ? 'ph:sort-ascending' : 'ph:sort-descending',
208
+ },
209
+ {
210
+ label: isCompareAbsolute ? 'Compare Relative' : 'Compare Absolute',
211
+ onclick: () => setCompareAbsolute(isCompareAbsolute ? 'false' : 'true'),
212
+ hide: !compareMode,
213
+ icon: isCompareAbsolute ? 'fluent-mdl2:compare' : 'fluent-mdl2:compare-uneven',
214
+ },
215
+ {
216
+ label: 'Reset Legend',
217
+ hide: binaryFrameFilter === undefined || binaryFrameFilter.length === 0,
218
+ onclick: () => resetLegend(),
219
+ id: 'h-reset-legend-button',
220
+ icon: 'system-uicons:reset',
221
+ },
222
+ ];
223
+
224
+ return (
225
+ <div className="relative inline-block text-left">
226
+ <Menu>
227
+ {({open, close}) => (
228
+ <>
229
+ <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">
230
+ <Icon
231
+ icon="pepicons-pencil:dots-x"
232
+ className="h-5 w-5 text-gray-800 dark:text-gray-200"
233
+ />
234
+ </Menu.Button>
235
+ {open && (
236
+ <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">
237
+ <span className="text-xs text-gray-400 capitalize px-4 py-3">actions</span>
238
+ {menuItems
239
+ .filter(item => item.hide !== undefined && !item.hide)
240
+ .map((item, index) => (
241
+ <MenuItem
242
+ key={index}
243
+ {...item}
244
+ onSelect={onSelect}
245
+ closeDropdown={close}
246
+ activeValue={storeSortBy as string}
247
+ />
248
+ ))}
249
+ </Menu.Items>
250
+ )}
251
+ </>
252
+ )}
253
+ </Menu>
254
+ </div>
255
+ );
256
+ };
257
+
258
+ export default MultiLevelDropdown;
@@ -0,0 +1,222 @@
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, useMemo, useState} from 'react';
15
+
16
+ import {createColumnHelper, type CellContext, type ColumnDef} from '@tanstack/table-core';
17
+
18
+ import {useURLState} from '@parca/components';
19
+ import {ProfileType} from '@parca/parser';
20
+ import {valueFormatter} from '@parca/utilities';
21
+
22
+ import {useProfileViewContext} from '../../ProfileView/ProfileViewContext';
23
+ import {ColumnName, DataRow, Row, addPlusSign, getRatioString, isDummyRow} from '../../Table';
24
+ import ColumnsVisibility from '../../Table/ColumnsVisibility';
25
+
26
+ interface Props {
27
+ profileType?: ProfileType;
28
+ total: bigint;
29
+ filtered: bigint;
30
+ }
31
+
32
+ const TableColumnsDropdown = ({profileType, total, filtered}: Props): JSX.Element => {
33
+ const {compareMode} = useProfileViewContext();
34
+ const [tableColumns, setTableColumns] = useURLState<string[]>('table_columns', {
35
+ alwaysReturnArray: true,
36
+ });
37
+
38
+ const columnHelper = createColumnHelper<Row>();
39
+
40
+ const unit: string = useMemo(() => profileType?.sampleUnit ?? '', [profileType?.sampleUnit]);
41
+
42
+ const columns = useMemo<Array<ColumnDef<Row>>>(() => {
43
+ return [
44
+ columnHelper.accessor('flat', {
45
+ id: 'flat',
46
+ header: 'Flat',
47
+ cell: info => valueFormatter((info as CellContext<DataRow, bigint>).getValue(), unit, 2),
48
+ size: 80,
49
+ meta: {
50
+ align: 'right',
51
+ },
52
+ invertSorting: true,
53
+ }),
54
+ columnHelper.accessor('flat', {
55
+ id: 'flatPercentage',
56
+ header: 'Flat (%)',
57
+ cell: info => {
58
+ if (isDummyRow(info.row.original)) {
59
+ return '';
60
+ }
61
+ return getRatioString((info as CellContext<DataRow, bigint>).getValue(), total, filtered);
62
+ },
63
+ size: 120,
64
+ meta: {
65
+ align: 'right',
66
+ },
67
+ invertSorting: true,
68
+ }),
69
+ columnHelper.accessor('flatDiff', {
70
+ id: 'flatDiff',
71
+ header: 'Flat Diff',
72
+ cell: info =>
73
+ addPlusSign(valueFormatter((info as CellContext<DataRow, bigint>).getValue(), unit, 2)),
74
+ size: 120,
75
+ meta: {
76
+ align: 'right',
77
+ },
78
+ invertSorting: true,
79
+ }),
80
+ columnHelper.accessor('flatDiff', {
81
+ id: 'flatDiffPercentage',
82
+ header: 'Flat Diff (%)',
83
+ cell: info => {
84
+ if (isDummyRow(info.row.original)) {
85
+ return '';
86
+ }
87
+ return getRatioString((info as CellContext<DataRow, bigint>).getValue(), total, filtered);
88
+ },
89
+ size: 120,
90
+ meta: {
91
+ align: 'right',
92
+ },
93
+ invertSorting: true,
94
+ }),
95
+ columnHelper.accessor('cumulative', {
96
+ id: 'cumulative',
97
+ header: 'Cumulative',
98
+ cell: info => valueFormatter((info as CellContext<DataRow, bigint>).getValue(), unit, 2),
99
+ size: 150,
100
+ meta: {
101
+ align: 'right',
102
+ },
103
+ invertSorting: true,
104
+ }),
105
+ columnHelper.accessor('cumulative', {
106
+ id: 'cumulativePercentage',
107
+ header: 'Cumulative (%)',
108
+ cell: info => {
109
+ if (isDummyRow(info.row.original)) {
110
+ return '';
111
+ }
112
+ return getRatioString((info as CellContext<DataRow, bigint>).getValue(), total, filtered);
113
+ },
114
+ size: 150,
115
+ meta: {
116
+ align: 'right',
117
+ },
118
+ invertSorting: true,
119
+ }),
120
+ columnHelper.accessor('cumulativeDiff', {
121
+ id: 'cumulativeDiff',
122
+ header: 'Cumulative Diff',
123
+ cell: info =>
124
+ addPlusSign(valueFormatter((info as CellContext<DataRow, bigint>).getValue(), unit, 2)),
125
+ size: 170,
126
+ meta: {
127
+ align: 'right',
128
+ },
129
+ invertSorting: true,
130
+ }),
131
+ columnHelper.accessor('cumulativeDiff', {
132
+ id: 'cumulativeDiffPercentage',
133
+ header: 'Cumulative Diff (%)',
134
+ cell: info => {
135
+ if (isDummyRow(info.row.original)) {
136
+ return '';
137
+ }
138
+ return getRatioString((info as CellContext<DataRow, bigint>).getValue(), total, filtered);
139
+ },
140
+ size: 170,
141
+ meta: {
142
+ align: 'right',
143
+ },
144
+ invertSorting: true,
145
+ }),
146
+ columnHelper.accessor('name', {
147
+ id: 'name',
148
+ header: 'Name',
149
+ cell: info => info.getValue(),
150
+ }),
151
+ columnHelper.accessor('functionSystemName', {
152
+ id: 'functionSystemName',
153
+ header: 'Function System Name',
154
+ cell: info => info.getValue(),
155
+ }),
156
+ columnHelper.accessor('functionFileName', {
157
+ id: 'functionFileName',
158
+ header: 'Function File Name',
159
+ cell: info => info.getValue(),
160
+ }),
161
+ columnHelper.accessor('mappingFile', {
162
+ id: 'mappingFile',
163
+ header: 'Mapping File',
164
+ cell: info => info.getValue(),
165
+ }),
166
+ ];
167
+ // eslint-disable-next-line react-hooks/exhaustive-deps
168
+ }, [profileType, unit]);
169
+
170
+ const [columnVisibility, setColumnVisibility] = useState(() => {
171
+ return {
172
+ flat: true,
173
+ flatPercentage: false,
174
+ flatDiff: compareMode,
175
+ flatDiffPercentage: false,
176
+ cumulative: true,
177
+ cumulativePercentage: false,
178
+ cumulativeDiff: compareMode,
179
+ cumulativeDiffPercentage: false,
180
+ name: true,
181
+ functionSystemName: false,
182
+ functionFileName: false,
183
+ mappingFile: false,
184
+ };
185
+ });
186
+
187
+ useEffect(() => {
188
+ if (Array.isArray(tableColumns)) {
189
+ setColumnVisibility(prevState => {
190
+ const newState = {...prevState};
191
+ (Object.keys(newState) as ColumnName[]).forEach(column => {
192
+ newState[column] = tableColumns.includes(column);
193
+ });
194
+ return newState;
195
+ });
196
+ }
197
+ }, [tableColumns]);
198
+
199
+ const updateColumnVisibility = (column: string, isVisible: boolean): void => {
200
+ const updatedColumns = {...columnVisibility, [column]: isVisible};
201
+
202
+ const newTableColumns = (Object.keys(updatedColumns) as ColumnName[]).filter(
203
+ col => updatedColumns[col]
204
+ );
205
+ setTableColumns(newTableColumns);
206
+ };
207
+
208
+ return (
209
+ <div className="flex flex-col gap-1">
210
+ <label className="text-sm">Table Columns</label>
211
+ <ColumnsVisibility
212
+ columns={columns}
213
+ visibility={columnVisibility}
214
+ setVisibility={(id, visible) => {
215
+ updateColumnVisibility(id, visible);
216
+ }}
217
+ />
218
+ </div>
219
+ );
220
+ };
221
+
222
+ export default TableColumnsDropdown;
@@ -0,0 +1,169 @@
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 {useCallback} from 'react';
15
+
16
+ import {Icon} from '@iconify/react';
17
+ import cx from 'classnames';
18
+
19
+ import {QueryRequest, QueryServiceClient} from '@parca/client';
20
+ import {Button, UserPreferencesModal, useParcaContext, useURLState} from '@parca/components';
21
+ import {ProfileType} from '@parca/parser';
22
+
23
+ import {FIELD_FUNCTION_NAME} from '../../ProfileIcicleGraph/IcicleGraphArrow';
24
+ import {ProfileSource} from '../../ProfileSource';
25
+ import GroupByDropdown from '../ActionButtons/GroupByDropdown';
26
+ import FilterByFunctionButton from '../FilterByFunctionButton';
27
+ import ShareButton from '../ShareButton';
28
+ import ViewSelector from '../ViewSelector';
29
+ import MultiLevelDropdown from './MultiLevelDropdown';
30
+ import TableColumnsDropdown from './TableColumnsDropdown';
31
+
32
+ interface Props {
33
+ groupBy: string | string[];
34
+ toggleGroupBy: (key: string) => void;
35
+ hasProfileSource: boolean;
36
+ isMultiPanelView: boolean;
37
+ dashboardItems: any;
38
+ profileSource?: ProfileSource;
39
+ queryClient?: QueryServiceClient;
40
+ queryRequest?: QueryRequest;
41
+ onDownloadPProf: () => void;
42
+ pprofdownloading: boolean | undefined;
43
+ curPath: string[];
44
+ setNewCurPath: (path: string[]) => void;
45
+ profileType?: ProfileType;
46
+ total: bigint;
47
+ filtered: bigint;
48
+ setSearchString?: (searchString: string) => void;
49
+ currentSearchString?: string;
50
+ }
51
+
52
+ const VisualisationToolbar = ({
53
+ hasProfileSource,
54
+ profileSource,
55
+ queryClient,
56
+ onDownloadPProf,
57
+ pprofdownloading,
58
+ curPath,
59
+ setNewCurPath,
60
+ profileType,
61
+ total,
62
+ filtered,
63
+ setSearchString,
64
+ currentSearchString,
65
+ }: Props): JSX.Element => {
66
+ const [dashboardItems] = useURLState<string[]>('dashboard_items', {
67
+ alwaysReturnArray: true,
68
+ });
69
+ const {profileViewExternalMainActions, profileViewExternalSubActions, preferencesModal} =
70
+ useParcaContext();
71
+
72
+ const [groupBy, setStoreGroupBy] = useURLState<string[]>('group_by', {
73
+ defaultValue: [FIELD_FUNCTION_NAME],
74
+ alwaysReturnArray: true,
75
+ });
76
+
77
+ const setGroupBy = useCallback(
78
+ (keys: string[]): void => {
79
+ setStoreGroupBy(keys);
80
+ },
81
+ [setStoreGroupBy]
82
+ );
83
+
84
+ const toggleGroupBy = useCallback(
85
+ (key: string): void => {
86
+ groupBy.includes(key)
87
+ ? setGroupBy(groupBy.filter(v => v !== key)) // remove
88
+ : setGroupBy([...groupBy, key]); // add
89
+ },
90
+ [groupBy, setGroupBy]
91
+ );
92
+
93
+ const clearSelection = useCallback((): void => {
94
+ setSearchString?.('');
95
+ }, [setSearchString]);
96
+
97
+ const isTableViz = dashboardItems?.includes('table');
98
+ const isGraphViz = dashboardItems?.includes('icicle');
99
+
100
+ return (
101
+ <div
102
+ className={cx(
103
+ 'mb-4 flex w-full',
104
+ hasProfileSource || profileViewExternalMainActions != null
105
+ ? 'justify-between'
106
+ : 'justify-end',
107
+ {
108
+ 'items-end': !hasProfileSource && profileViewExternalMainActions != null,
109
+ 'items-center': hasProfileSource,
110
+ }
111
+ )}
112
+ >
113
+ <div className="flex w-full justify-between items-end">
114
+ <div className="flex gap-3 items-end">
115
+ {isGraphViz && (
116
+ <>
117
+ <GroupByDropdown groupBy={groupBy} toggleGroupBy={toggleGroupBy} />
118
+ <MultiLevelDropdown profileType={profileType} onSelect={() => {}} />
119
+ <Button
120
+ variant="neutral"
121
+ className="gap-2 w-max"
122
+ onClick={() => setNewCurPath([])}
123
+ disabled={curPath.length === 0}
124
+ >
125
+ Reset graph
126
+ <Icon icon="system-uicons:reset" width={20} />
127
+ </Button>
128
+ </>
129
+ )}
130
+
131
+ {isTableViz && (
132
+ <>
133
+ <TableColumnsDropdown profileType={profileType} total={total} filtered={filtered} />
134
+ {dashboardItems.length > 1 && (
135
+ <Button
136
+ color="neutral"
137
+ onClick={clearSelection}
138
+ className="w-auto"
139
+ variant="neutral"
140
+ disabled={currentSearchString === undefined || currentSearchString.length === 0}
141
+ >
142
+ Clear selection
143
+ </Button>
144
+ )}
145
+ </>
146
+ )}
147
+
148
+ <FilterByFunctionButton />
149
+
150
+ {profileViewExternalSubActions != null ? profileViewExternalSubActions : null}
151
+ </div>
152
+ <div className="flex gap-3">
153
+ {preferencesModal === true ? <UserPreferencesModal /> : null}
154
+ <ShareButton
155
+ profileSource={profileSource}
156
+ queryClient={queryClient}
157
+ queryRequest={profileSource?.QueryRequest() ?? undefined}
158
+ onDownloadPProf={onDownloadPProf}
159
+ pprofdownloading={pprofdownloading ?? false}
160
+ profileViewExternalSubActions={profileViewExternalSubActions}
161
+ />
162
+ <ViewSelector />
163
+ </div>
164
+ </div>
165
+ </div>
166
+ );
167
+ };
168
+
169
+ export default VisualisationToolbar;
@@ -1 +0,0 @@
1
- {"version":3,"file":"GroupByDropdown.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/ActionButtons/GroupByDropdown.tsx"],"names":[],"mappings":"AAyDA,QAAA,MAAM,eAAe,gCAGlB;IACD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC,KAAG,KAAK,CAAC,GAAG,CAAC,OA6Db,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,7 +0,0 @@
1
- declare const SortBySelect: ({ sortBy, setSortBy, compareMode, }: {
2
- sortBy: string;
3
- setSortBy: (key: string) => void;
4
- compareMode: boolean;
5
- }) => React.JSX.Element;
6
- export default SortBySelect;
7
- //# sourceMappingURL=SortBySelect.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SortBySelect.d.ts","sourceRoot":"","sources":["../../../src/ProfileIcicleGraph/ActionButtons/SortBySelect.tsx"],"names":[],"mappings":"AAiBA,QAAA,MAAM,YAAY,wCAIf;IACD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,WAAW,EAAE,OAAO,CAAC;CACtB,KAAG,KAAK,CAAC,GAAG,CAAC,OAqDb,CAAC;AAEF,eAAe,YAAY,CAAC"}