@parca/profile 0.19.1 → 0.19.3
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/MetricsGraph/MetricsContextMenu/index.d.ts.map +1 -1
- package/dist/MetricsGraph/MetricsContextMenu/index.js +2 -2
- package/dist/ProfileExplorer/index.d.ts.map +1 -1
- package/dist/ProfileExplorer/index.js +16 -0
- package/dist/ProfileView/components/FilterByFunctionButton.d.ts.map +1 -1
- package/dist/ProfileView/components/FilterByFunctionButton.js +7 -1
- package/dist/ProfileView/hooks/useResetStateOnNewSearch.d.ts +2 -0
- package/dist/ProfileView/hooks/useResetStateOnNewSearch.d.ts.map +1 -0
- package/dist/ProfileView/hooks/useResetStateOnNewSearch.js +21 -0
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts +2 -0
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -0
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +29 -0
- package/package.json +2 -2
- package/src/MetricsGraph/MetricsContextMenu/index.tsx +25 -16
- package/src/ProfileExplorer/index.tsx +17 -0
- package/src/ProfileView/components/FilterByFunctionButton.tsx +8 -1
- package/src/ProfileView/hooks/useResetStateOnNewSearch.ts +24 -0
- package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +32 -0
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.3](https://github.com/parca-dev/parca/compare/@parca/profile@0.19.2...@parca/profile@0.19.3) (2025-06-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @parca/profile
|
|
9
|
+
|
|
10
|
+
## 0.19.2 (2025-06-19)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @parca/profile
|
|
13
|
+
|
|
6
14
|
## [0.19.1](https://github.com/parca-dev/parca/compare/@parca/profile@0.19.0...@parca/profile@0.19.1) (2025-06-18)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @parca/profile
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/MetricsGraph/MetricsContextMenu/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,iBAAiB,EAAC,MAAM,KAAK,CAAC;AAEtC,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,CACjB,MAAM,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAAG,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,KACvE,IAAI,CAAC;IACV,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,eAAe,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9C,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AASD,QAAA,MAAM,kBAAkB,qFAMrB,uBAAuB,KAAG,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/MetricsGraph/MetricsContextMenu/index.tsx"],"names":[],"mappings":"AAmBA,OAAO,EAAC,iBAAiB,EAAC,MAAM,KAAK,CAAC;AAEtC,UAAU,uBAAuB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,EAAE,CACjB,MAAM,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,GAAG,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAC,CAAC,KACvE,IAAI,CAAC;IACV,WAAW,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACtC,eAAe,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC9C,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AASD,QAAA,MAAM,kBAAkB,qFAMrB,uBAAuB,KAAG,GAAG,CAAC,OA4DhC,CAAC;AAEF,eAAe,kBAAkB,CAAC"}
|
|
@@ -30,11 +30,11 @@ const MetricsContextMenu = ({ menuId, onAddLabelMatcher, highlighted, trackVisib
|
|
|
30
30
|
}));
|
|
31
31
|
labelsToAdd !== undefined && onAddLabelMatcher(labelsToAdd);
|
|
32
32
|
};
|
|
33
|
-
return (_jsxs(Menu, { id: menuId, onVisibilityChange: trackVisibility, theme: isDarkMode ? 'dark' : '', children: [_jsx(Item, { id: "focus-on-single-series", onClick: handleFocusOnSingleSeries, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "ph:star" }), _jsx("div", { children: "Focus only on this series" })] }) }), _jsx(Submenu, { label: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "material-symbols:add" }), _jsx("div", { children: "Add to query" })] }), children: _jsx("div", { className: "max-h-[300px] overflow-
|
|
33
|
+
return (_jsxs(Menu, { id: menuId, onVisibilityChange: trackVisibility, theme: isDarkMode ? 'dark' : '', children: [_jsx(Item, { id: "focus-on-single-series", onClick: handleFocusOnSingleSeries, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "ph:star" }), _jsx("div", { children: "Focus only on this series" })] }) }), _jsx(Submenu, { label: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "material-symbols:add" }), _jsx("div", { children: "Add to query" })] }), children: _jsx("div", { className: "max-h-[300px] overflow-auto", children: labels == null || labels.length === 0 ? (_jsx(Item, { disabled: true, children: _jsxs("div", { className: "flex w-full items-center gap-2", children: [_jsx(Icon, { icon: "ph:warning" }), _jsx("div", { children: "No labels available" })] }) })) : (labels.map((label) => (_jsx(Item, { id: label.name, onClick: () => {
|
|
34
34
|
onAddLabelMatcher({
|
|
35
35
|
key: label.name,
|
|
36
36
|
value: label.value,
|
|
37
37
|
});
|
|
38
|
-
}, className: "max-w-[400px] overflow-hidden", children: _jsx("div", { className: "mr-3 inline-block rounded-lg bg-gray-200 px-2 py-1 text-xs font-bold text-gray-700 dark:bg-gray-700 dark:text-gray-300", children: `${transformUtilizationLabels(label.name, utilizationMetrics)}="${label.value}"` }) }, label.name))) }) })] }));
|
|
38
|
+
}, className: "max-w-[400px] overflow-hidden", children: _jsx("div", { className: "mr-3 inline-block rounded-lg bg-gray-200 px-2 py-1 text-xs font-bold text-gray-700 dark:bg-gray-700 dark:text-gray-300", children: `${transformUtilizationLabels(label.name, utilizationMetrics)}="${label.value}"` }) }, label.name)))) }) })] }));
|
|
39
39
|
};
|
|
40
40
|
export default MetricsContextMenu;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileExplorer/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ProfileExplorer/index.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAC,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAIjD,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAU1B,UAAU,oBAAoB;IAC5B,WAAW,EAAE,kBAAkB,CAAC;IAChC,WAAW,EAAE,GAAG,CAAC;IACjB,UAAU,EAAE,gBAAgB,CAAC;CAC9B;AAaD,eAAO,MAAM,sBAAsB,eAAgB,MAAM,GAAG,EAAE,KAAG,MAGhE,CAAC;AAiXF,QAAA,MAAM,eAAe,8CAIlB,oBAAoB,KAAG,GAAG,CAAC,OAkB7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -14,10 +14,13 @@ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
14
14
|
import { useEffect, useMemo, useState } from 'react';
|
|
15
15
|
import { Provider } from 'react-redux';
|
|
16
16
|
import { DateTimeRange, KeyDownProvider, useParcaContext } from '@parca/components';
|
|
17
|
+
import { Query } from '@parca/parser';
|
|
17
18
|
import { createStore } from '@parca/store';
|
|
18
19
|
import { capitalizeOnlyFirstLetter, decodeMultipleEncodings, isUrlEncoded, } from '@parca/utilities';
|
|
19
20
|
import { ProfileSelectionFromParams, SuffixParams } from '..';
|
|
20
21
|
import { useProfileTypes } from '../ProfileSelector';
|
|
22
|
+
import { useResetStateOnNewSearch } from '../ProfileView/hooks/useResetStateOnNewSearch';
|
|
23
|
+
import { useResetStateOnProfileTypeChange } from '../ProfileView/hooks/useResetStateOnProfileTypeChange';
|
|
21
24
|
import { sumByToParam, useSumByFromParams } from '../useSumBy';
|
|
22
25
|
import ProfileExplorerCompare from './ProfileExplorerCompare';
|
|
23
26
|
import ProfileExplorerSingle from './ProfileExplorerSingle';
|
|
@@ -93,6 +96,8 @@ const ProfileExplorerApp = ({ queryClient, queryParams, navigateTo, }) => {
|
|
|
93
96
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
94
97
|
const [profileA, setProfileA] = useState(null);
|
|
95
98
|
const [profileB, setProfileB] = useState(null);
|
|
99
|
+
const resetStateOnProfileTypeChange = useResetStateOnProfileTypeChange();
|
|
100
|
+
const resetStateOnNewSearch = useResetStateOnNewSearch();
|
|
96
101
|
const sumByA = useSumByFromParams(sum_by_a);
|
|
97
102
|
const sumByB = useSumByFromParams(sum_by_b);
|
|
98
103
|
useEffect(() => {
|
|
@@ -151,6 +156,17 @@ const ProfileExplorerApp = ({ queryClient, queryParams, navigateTo, }) => {
|
|
|
151
156
|
// Show the SingleProfileExplorer when not comparing
|
|
152
157
|
if (compare_a !== 'true' && compare_b !== 'true') {
|
|
153
158
|
const selectQuery = (q) => {
|
|
159
|
+
const profileNameAfter = Query.parse(q.expression).profileName();
|
|
160
|
+
if (profileA != null) {
|
|
161
|
+
if (profileA.ProfileName() !== profileNameAfter) {
|
|
162
|
+
// Reset required state when the profile type changes.
|
|
163
|
+
resetStateOnProfileTypeChange();
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
// Reset the state when a new search is performed.
|
|
167
|
+
resetStateOnNewSearch();
|
|
168
|
+
}
|
|
169
|
+
}
|
|
154
170
|
const mergeParams = q.mergeFrom !== undefined && q.mergeTo !== undefined
|
|
155
171
|
? {
|
|
156
172
|
merge_from_a: q.mergeFrom,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterByFunctionButton.d.ts","sourceRoot":"","sources":["../../../src/ProfileView/components/FilterByFunctionButton.tsx"],"names":[],"mappings":"AAoBA,QAAA,MAAM,sBAAsB,QAAO,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"FilterByFunctionButton.d.ts","sourceRoot":"","sources":["../../../src/ProfileView/components/FilterByFunctionButton.tsx"],"names":[],"mappings":"AAoBA,QAAA,MAAM,sBAAsB,QAAO,GAAG,CAAC,OAyGtC,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
|
|
@@ -11,7 +11,7 @@ import { Fragment as _Fragment, jsx as _jsx, 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 { useCallback, useMemo, useState } from 'react';
|
|
14
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
15
15
|
import { Icon } from '@iconify/react';
|
|
16
16
|
import { Input, Select, useURLState } from '@parca/components';
|
|
17
17
|
import { USER_PREFERENCES, useUserPreference } from '@parca/hooks';
|
|
@@ -30,6 +30,12 @@ const FilterByFunctionButton = () => {
|
|
|
30
30
|
? excludeFunctionStoreValue === 'true'
|
|
31
31
|
: excludeFunctionStoreValue !== 'true'));
|
|
32
32
|
}, [localValue, storeValue, excludeFunction, excludeFunctionStoreValue]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (storeValue === undefined) {
|
|
35
|
+
setLocalValue('');
|
|
36
|
+
setExcludeFunction(false);
|
|
37
|
+
}
|
|
38
|
+
}, [storeValue]);
|
|
33
39
|
const onAction = useCallback(() => {
|
|
34
40
|
if (isClearAction) {
|
|
35
41
|
setLocalValue('');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResetStateOnNewSearch.d.ts","sourceRoot":"","sources":["../../../src/ProfileView/hooks/useResetStateOnNewSearch.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,wBAAwB,QAAO,CAAC,MAAM,IAAI,CAQtD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
import { useURLState } from '@parca/components';
|
|
14
|
+
export const useResetStateOnNewSearch = () => {
|
|
15
|
+
const [, setCurPath] = useURLState('cur_path');
|
|
16
|
+
return () => {
|
|
17
|
+
setTimeout(() => {
|
|
18
|
+
setCurPath(undefined);
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResetStateOnProfileTypeChange.d.ts","sourceRoot":"","sources":["../../../src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gCAAgC,QAAO,CAAC,MAAM,IAAI,CAgB9D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
import { useURLState } from '@parca/components';
|
|
14
|
+
export const useResetStateOnProfileTypeChange = () => {
|
|
15
|
+
const [, setGroupBy] = useURLState('group_by');
|
|
16
|
+
const [, setFilterByFunction] = useURLState('filter_by_function');
|
|
17
|
+
const [, setExcludeFunction] = useURLState('exclude_function');
|
|
18
|
+
const [, setSearchString] = useURLState('search_string');
|
|
19
|
+
const [, setCurPath] = useURLState('cur_path');
|
|
20
|
+
return () => {
|
|
21
|
+
setTimeout(() => {
|
|
22
|
+
setGroupBy(undefined);
|
|
23
|
+
setFilterByFunction(undefined);
|
|
24
|
+
setExcludeFunction(undefined);
|
|
25
|
+
setSearchString(undefined);
|
|
26
|
+
setCurPath(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parca/profile",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.3",
|
|
4
4
|
"description": "Profile viewing libraries",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@headlessui/react": "^1.7.19",
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"access": "public",
|
|
78
78
|
"registry": "https://registry.npmjs.org/"
|
|
79
79
|
},
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "20c7f506dd35795cbc417a5d94c75d72b4128b97"
|
|
81
81
|
}
|
|
@@ -71,24 +71,33 @@ const MetricsContextMenu = ({
|
|
|
71
71
|
</div>
|
|
72
72
|
}
|
|
73
73
|
>
|
|
74
|
-
<div className="max-h-[300px] overflow-
|
|
75
|
-
{labels
|
|
76
|
-
<Item
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
onAddLabelMatcher({
|
|
81
|
-
key: label.name,
|
|
82
|
-
value: label.value,
|
|
83
|
-
});
|
|
84
|
-
}}
|
|
85
|
-
className="max-w-[400px] overflow-hidden"
|
|
86
|
-
>
|
|
87
|
-
<div className="mr-3 inline-block rounded-lg bg-gray-200 px-2 py-1 text-xs font-bold text-gray-700 dark:bg-gray-700 dark:text-gray-300">
|
|
88
|
-
{`${transformUtilizationLabels(label.name, utilizationMetrics)}="${label.value}"`}
|
|
74
|
+
<div className="max-h-[300px] overflow-auto">
|
|
75
|
+
{labels == null || labels.length === 0 ? (
|
|
76
|
+
<Item disabled>
|
|
77
|
+
<div className="flex w-full items-center gap-2">
|
|
78
|
+
<Icon icon="ph:warning" />
|
|
79
|
+
<div>No labels available</div>
|
|
89
80
|
</div>
|
|
90
81
|
</Item>
|
|
91
|
-
)
|
|
82
|
+
) : (
|
|
83
|
+
labels.map((label: Label) => (
|
|
84
|
+
<Item
|
|
85
|
+
key={label.name}
|
|
86
|
+
id={label.name}
|
|
87
|
+
onClick={() => {
|
|
88
|
+
onAddLabelMatcher({
|
|
89
|
+
key: label.name,
|
|
90
|
+
value: label.value,
|
|
91
|
+
});
|
|
92
|
+
}}
|
|
93
|
+
className="max-w-[400px] overflow-hidden"
|
|
94
|
+
>
|
|
95
|
+
<div className="mr-3 inline-block rounded-lg bg-gray-200 px-2 py-1 text-xs font-bold text-gray-700 dark:bg-gray-700 dark:text-gray-300">
|
|
96
|
+
{`${transformUtilizationLabels(label.name, utilizationMetrics)}="${label.value}"`}
|
|
97
|
+
</div>
|
|
98
|
+
</Item>
|
|
99
|
+
))
|
|
100
|
+
)}
|
|
92
101
|
</div>
|
|
93
102
|
</Submenu>
|
|
94
103
|
</Menu>
|
|
@@ -17,6 +17,7 @@ import {Provider} from 'react-redux';
|
|
|
17
17
|
|
|
18
18
|
import {QueryServiceClient} from '@parca/client';
|
|
19
19
|
import {DateTimeRange, KeyDownProvider, useParcaContext} from '@parca/components';
|
|
20
|
+
import {Query} from '@parca/parser';
|
|
20
21
|
import {createStore} from '@parca/store';
|
|
21
22
|
import {
|
|
22
23
|
capitalizeOnlyFirstLetter,
|
|
@@ -27,6 +28,8 @@ import {
|
|
|
27
28
|
|
|
28
29
|
import {ProfileSelection, ProfileSelectionFromParams, SuffixParams} from '..';
|
|
29
30
|
import {QuerySelection, useProfileTypes} from '../ProfileSelector';
|
|
31
|
+
import {useResetStateOnNewSearch} from '../ProfileView/hooks/useResetStateOnNewSearch';
|
|
32
|
+
import {useResetStateOnProfileTypeChange} from '../ProfileView/hooks/useResetStateOnProfileTypeChange';
|
|
30
33
|
import {sumByToParam, useSumByFromParams} from '../useSumBy';
|
|
31
34
|
import ProfileExplorerCompare from './ProfileExplorerCompare';
|
|
32
35
|
import ProfileExplorerSingle from './ProfileExplorerSingle';
|
|
@@ -173,6 +176,9 @@ const ProfileExplorerApp = ({
|
|
|
173
176
|
const [profileA, setProfileA] = useState<ProfileSelection | null>(null);
|
|
174
177
|
const [profileB, setProfileB] = useState<ProfileSelection | null>(null);
|
|
175
178
|
|
|
179
|
+
const resetStateOnProfileTypeChange = useResetStateOnProfileTypeChange();
|
|
180
|
+
const resetStateOnNewSearch = useResetStateOnNewSearch();
|
|
181
|
+
|
|
176
182
|
const sumByA = useSumByFromParams(sum_by_a);
|
|
177
183
|
const sumByB = useSumByFromParams(sum_by_b);
|
|
178
184
|
|
|
@@ -258,6 +264,17 @@ const ProfileExplorerApp = ({
|
|
|
258
264
|
// Show the SingleProfileExplorer when not comparing
|
|
259
265
|
if (compare_a !== 'true' && compare_b !== 'true') {
|
|
260
266
|
const selectQuery = (q: QuerySelection): void => {
|
|
267
|
+
const profileNameAfter = Query.parse(q.expression).profileName();
|
|
268
|
+
if (profileA != null) {
|
|
269
|
+
if (profileA.ProfileName() !== profileNameAfter) {
|
|
270
|
+
// Reset required state when the profile type changes.
|
|
271
|
+
resetStateOnProfileTypeChange();
|
|
272
|
+
} else {
|
|
273
|
+
// Reset the state when a new search is performed.
|
|
274
|
+
resetStateOnNewSearch();
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
261
278
|
const mergeParams =
|
|
262
279
|
q.mergeFrom !== undefined && q.mergeTo !== undefined
|
|
263
280
|
? {
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
|
|
14
|
-
import {useCallback, useMemo, useState} from 'react';
|
|
14
|
+
import {useCallback, useEffect, useMemo, useState} from 'react';
|
|
15
15
|
|
|
16
16
|
import {Icon} from '@iconify/react';
|
|
17
17
|
|
|
@@ -39,6 +39,13 @@ const FilterByFunctionButton = (): JSX.Element => {
|
|
|
39
39
|
);
|
|
40
40
|
}, [localValue, storeValue, excludeFunction, excludeFunctionStoreValue]);
|
|
41
41
|
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (storeValue === undefined) {
|
|
44
|
+
setLocalValue('');
|
|
45
|
+
setExcludeFunction(false);
|
|
46
|
+
}
|
|
47
|
+
}, [storeValue]);
|
|
48
|
+
|
|
42
49
|
const onAction = useCallback((): void => {
|
|
43
50
|
if (isClearAction) {
|
|
44
51
|
setLocalValue('');
|
|
@@ -0,0 +1,24 @@
|
|
|
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 {useURLState} from '@parca/components';
|
|
15
|
+
|
|
16
|
+
export const useResetStateOnNewSearch = (): (() => void) => {
|
|
17
|
+
const [, setCurPath] = useURLState('cur_path');
|
|
18
|
+
|
|
19
|
+
return () => {
|
|
20
|
+
setTimeout(() => {
|
|
21
|
+
setCurPath(undefined);
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
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 {useURLState} from '@parca/components';
|
|
15
|
+
|
|
16
|
+
export const useResetStateOnProfileTypeChange = (): (() => void) => {
|
|
17
|
+
const [, setGroupBy] = useURLState('group_by');
|
|
18
|
+
const [, setFilterByFunction] = useURLState('filter_by_function');
|
|
19
|
+
const [, setExcludeFunction] = useURLState('exclude_function');
|
|
20
|
+
const [, setSearchString] = useURLState('search_string');
|
|
21
|
+
const [, setCurPath] = useURLState('cur_path');
|
|
22
|
+
|
|
23
|
+
return () => {
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
setGroupBy(undefined);
|
|
26
|
+
setFilterByFunction(undefined);
|
|
27
|
+
setExcludeFunction(undefined);
|
|
28
|
+
setSearchString(undefined);
|
|
29
|
+
setCurPath(undefined);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
};
|