@parca/profile 0.19.1 → 0.19.2
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 +4 -0
- 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/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,10 @@
|
|
|
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.2 (2025-06-19)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @parca/profile
|
|
9
|
+
|
|
6
10
|
## [0.19.1](https://github.com/parca-dev/parca/compare/@parca/profile@0.19.0...@parca/profile@0.19.1) (2025-06-18)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @parca/profile
|
|
@@ -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.2",
|
|
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": "a921a622ad49debb9ed7279b98d23938cd06cab4"
|
|
81
81
|
}
|
|
@@ -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
|
+
};
|