@parca/profile 0.19.6 → 0.19.7
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 +1 -0
- package/dist/ProfileExplorer/index.d.ts.map +1 -1
- package/dist/ProfileExplorer/index.js +1 -1
- package/dist/ProfileView/hooks/useResetStateOnNewSearch.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnNewSearch.js +4 -1
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +20 -10
- package/package.json +2 -2
- package/src/ProfileExplorer/index.test.ts +97 -0
- package/src/ProfileExplorer/index.tsx +1 -1
- package/src/ProfileView/hooks/useResetStateOnNewSearch.ts +4 -1
- package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +20 -10
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.7](https://github.com/parca-dev/parca/compare/@parca/profile@0.19.6...@parca/profile@0.19.7) (2025-06-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @parca/profile
|
|
9
|
+
|
|
6
10
|
## [0.19.6](https://github.com/parca-dev/parca/compare/@parca/profile@0.19.5...@parca/profile@0.19.6) (2025-06-23)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @parca/profile
|
|
@@ -6,6 +6,7 @@ interface ProfileExplorerProps {
|
|
|
6
6
|
navigateTo: NavigateFunction;
|
|
7
7
|
}
|
|
8
8
|
export declare const getExpressionAsAString: (expression: string | []) => string;
|
|
9
|
+
export declare const filterEmptyParams: (o: Record<string, any>) => Record<string, any>;
|
|
9
10
|
declare const ProfileExplorer: ({ queryClient, queryParams, navigateTo, }: ProfileExplorerProps) => JSX.Element;
|
|
10
11
|
export default ProfileExplorer;
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -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;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;
|
|
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;AAiBF,eAAO,MAAM,iBAAiB,MAAO,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAiB5E,CAAC;AA+UF,QAAA,MAAM,eAAe,8CAIlB,oBAAoB,KAAG,GAAG,CAAC,OAkB7B,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -41,7 +41,7 @@ const sanitizeDateRange = (time_selection_a, from_a, to_a) => {
|
|
|
41
41
|
return { time_selection_a: range.getRangeKey(), from_a, to_a };
|
|
42
42
|
};
|
|
43
43
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
44
|
-
const filterEmptyParams = (o) => {
|
|
44
|
+
export const filterEmptyParams = (o) => {
|
|
45
45
|
return Object.fromEntries(Object.entries(o)
|
|
46
46
|
.filter(([_, value]) => value !== '' && value !== undefined && (Array.isArray(value) ? value.length > 0 : true))
|
|
47
47
|
.map(([key, value]) => {
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"useResetStateOnNewSearch.d.ts","sourceRoot":"","sources":["../../../src/ProfileView/hooks/useResetStateOnNewSearch.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,wBAAwB,QAAO,CAAC,MAAM,IAAI,CAWtD,CAAC"}
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { useURLState } from '@parca/components';
|
|
14
14
|
export const useResetStateOnNewSearch = () => {
|
|
15
|
-
const [, setCurPath] = useURLState('cur_path');
|
|
15
|
+
const [val, setCurPath] = useURLState('cur_path');
|
|
16
16
|
return () => {
|
|
17
17
|
setTimeout(() => {
|
|
18
|
+
if (val === undefined) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
18
21
|
setCurPath(undefined);
|
|
19
22
|
});
|
|
20
23
|
};
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"useResetStateOnProfileTypeChange.d.ts","sourceRoot":"","sources":["../../../src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,gCAAgC,QAAO,CAAC,MAAM,IAAI,CA0B9D,CAAC"}
|
|
@@ -12,18 +12,28 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { useURLState } from '@parca/components';
|
|
14
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');
|
|
15
|
+
const [groupBy, setGroupBy] = useURLState('group_by');
|
|
16
|
+
const [filterByFunction, setFilterByFunction] = useURLState('filter_by_function');
|
|
17
|
+
const [excludeFunction, setExcludeFunction] = useURLState('exclude_function');
|
|
18
|
+
const [searchString, setSearchString] = useURLState('search_string');
|
|
19
|
+
const [curPath, setCurPath] = useURLState('cur_path');
|
|
20
20
|
return () => {
|
|
21
21
|
setTimeout(() => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
if (groupBy !== undefined) {
|
|
23
|
+
setGroupBy(undefined);
|
|
24
|
+
}
|
|
25
|
+
if (filterByFunction !== undefined) {
|
|
26
|
+
setFilterByFunction(undefined);
|
|
27
|
+
}
|
|
28
|
+
if (excludeFunction !== undefined) {
|
|
29
|
+
setExcludeFunction(undefined);
|
|
30
|
+
}
|
|
31
|
+
if (searchString !== undefined) {
|
|
32
|
+
setSearchString(undefined);
|
|
33
|
+
}
|
|
34
|
+
if (curPath !== undefined) {
|
|
35
|
+
setCurPath(undefined);
|
|
36
|
+
}
|
|
27
37
|
});
|
|
28
38
|
};
|
|
29
39
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parca/profile",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.7",
|
|
4
4
|
"description": "Profile viewing libraries",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@floating-ui/react": "^0.27.12",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"access": "public",
|
|
79
79
|
"registry": "https://registry.npmjs.org/"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "4bcbd7e4e41cbb9d57aee3160784e74a40997526"
|
|
82
82
|
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 {describe, expect, it} from 'vitest';
|
|
15
|
+
|
|
16
|
+
import {filterEmptyParams} from './index';
|
|
17
|
+
|
|
18
|
+
describe('filterEmptyParams', () => {
|
|
19
|
+
it('should return an array with 2 elements when given object with 2 valid and multiple invalid values', () => {
|
|
20
|
+
const input = {
|
|
21
|
+
validString: 'hello',
|
|
22
|
+
validArray: ['item1', 'item2'],
|
|
23
|
+
emptyString: '',
|
|
24
|
+
undefinedValue: undefined,
|
|
25
|
+
emptyArray: [],
|
|
26
|
+
anotherEmptyString: '',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const result = filterEmptyParams(input);
|
|
30
|
+
const resultEntries = Object.entries(result);
|
|
31
|
+
|
|
32
|
+
expect(resultEntries).toHaveLength(2);
|
|
33
|
+
expect(result).toEqual({
|
|
34
|
+
validString: 'hello',
|
|
35
|
+
validArray: ['item1', 'item2'],
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should filter out empty strings', () => {
|
|
40
|
+
const input = {
|
|
41
|
+
valid: 'test',
|
|
42
|
+
empty: '',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const result = filterEmptyParams(input);
|
|
46
|
+
expect(result).toEqual({valid: 'test'});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should filter out undefined values', () => {
|
|
50
|
+
const input = {
|
|
51
|
+
valid: 'test',
|
|
52
|
+
notDefined: undefined,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const result = filterEmptyParams(input);
|
|
56
|
+
expect(result).toEqual({valid: 'test'});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should filter out empty arrays', () => {
|
|
60
|
+
const input = {
|
|
61
|
+
valid: 'test',
|
|
62
|
+
emptyArray: [],
|
|
63
|
+
nonEmptyArray: ['item'],
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const result = filterEmptyParams(input);
|
|
67
|
+
expect(result).toEqual({
|
|
68
|
+
valid: 'test',
|
|
69
|
+
nonEmptyArray: ['item'],
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it('should keep all valid values including numbers, booleans, and objects', () => {
|
|
74
|
+
const input = {
|
|
75
|
+
string: 'test',
|
|
76
|
+
number: 0,
|
|
77
|
+
boolean: false,
|
|
78
|
+
object: {key: 'value'},
|
|
79
|
+
array: ['item'],
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const result = filterEmptyParams(input);
|
|
83
|
+
expect(result).toEqual(input);
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
it('should return empty object when all values are invalid', () => {
|
|
87
|
+
const input = {
|
|
88
|
+
empty1: '',
|
|
89
|
+
empty2: '',
|
|
90
|
+
undefined1: undefined,
|
|
91
|
+
emptyArray: [],
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const result = filterEmptyParams(input);
|
|
95
|
+
expect(result).toEqual({});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -71,7 +71,7 @@ const sanitizeDateRange = (
|
|
|
71
71
|
};
|
|
72
72
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
73
73
|
|
|
74
|
-
const filterEmptyParams = (o: Record<string, any>): Record<string, any> => {
|
|
74
|
+
export const filterEmptyParams = (o: Record<string, any>): Record<string, any> => {
|
|
75
75
|
return Object.fromEntries(
|
|
76
76
|
Object.entries(o)
|
|
77
77
|
.filter(
|
|
@@ -14,10 +14,13 @@
|
|
|
14
14
|
import {useURLState} from '@parca/components';
|
|
15
15
|
|
|
16
16
|
export const useResetStateOnNewSearch = (): (() => void) => {
|
|
17
|
-
const [, setCurPath] = useURLState('cur_path');
|
|
17
|
+
const [val, setCurPath] = useURLState('cur_path');
|
|
18
18
|
|
|
19
19
|
return () => {
|
|
20
20
|
setTimeout(() => {
|
|
21
|
+
if (val === undefined) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
21
24
|
setCurPath(undefined);
|
|
22
25
|
});
|
|
23
26
|
};
|
|
@@ -14,19 +14,29 @@
|
|
|
14
14
|
import {useURLState} from '@parca/components';
|
|
15
15
|
|
|
16
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');
|
|
17
|
+
const [groupBy, setGroupBy] = useURLState('group_by');
|
|
18
|
+
const [filterByFunction, setFilterByFunction] = useURLState('filter_by_function');
|
|
19
|
+
const [excludeFunction, setExcludeFunction] = useURLState('exclude_function');
|
|
20
|
+
const [searchString, setSearchString] = useURLState('search_string');
|
|
21
|
+
const [curPath, setCurPath] = useURLState('cur_path');
|
|
22
22
|
|
|
23
23
|
return () => {
|
|
24
24
|
setTimeout(() => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
if (groupBy !== undefined) {
|
|
26
|
+
setGroupBy(undefined);
|
|
27
|
+
}
|
|
28
|
+
if (filterByFunction !== undefined) {
|
|
29
|
+
setFilterByFunction(undefined);
|
|
30
|
+
}
|
|
31
|
+
if (excludeFunction !== undefined) {
|
|
32
|
+
setExcludeFunction(undefined);
|
|
33
|
+
}
|
|
34
|
+
if (searchString !== undefined) {
|
|
35
|
+
setSearchString(undefined);
|
|
36
|
+
}
|
|
37
|
+
if (curPath !== undefined) {
|
|
38
|
+
setCurPath(undefined);
|
|
39
|
+
}
|
|
30
40
|
});
|
|
31
41
|
};
|
|
32
42
|
};
|