@parca/profile 0.16.126-alpha.5 → 0.16.127
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 +2 -90
- package/dist/ProfileExplorer/index.js +2 -2
- package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.js +3 -3
- package/package.json +3 -3
- package/src/ProfileExplorer/index.tsx +2 -2
- package/src/ProfileIcicleGraph/IcicleGraph/useNodeColor.ts +5 -2
- package/dist/DiffLegend/index.d.ts +0 -3
- package/dist/DiffLegend/index.js +0 -62
- package/dist/ProfileShareButton/ResultBox.d.ts +0 -7
- package/dist/ProfileShareButton/ResultBox.js +0 -46
- package/dist/ProfileShareButton/index.d.ts +0 -9
- package/dist/ProfileShareButton/index.js +0 -119
package/CHANGELOG.md
CHANGED
|
@@ -3,102 +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.16.
|
|
6
|
+
## [0.16.127](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.126...@parca/profile@0.16.127) (2023-03-01)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @parca/profile
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## [0.16.126-alpha.4](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.4) (2023-02-27)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @parca/profile
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## [0.16.126-alpha.3](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.3) (2023-02-27)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @parca/profile
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## [0.16.126-alpha.2](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.2) (2023-02-27)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @parca/profile
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## [0.16.126-alpha.1](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.1) (2023-02-27)
|
|
39
|
-
|
|
40
|
-
**Note:** Version bump only for package @parca/profile
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## [0.16.126-alpha.0](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.0) (2023-02-27)
|
|
47
|
-
|
|
48
|
-
**Note:** Version bump only for package @parca/profile
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
## [0.16.126-alpha.3](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.3) (2023-02-27)
|
|
10
|
+
## [0.16.126](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126) (2023-02-27)
|
|
55
11
|
|
|
56
12
|
**Note:** Version bump only for package @parca/profile
|
|
57
13
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## [0.16.126-alpha.2](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.2) (2023-02-27)
|
|
63
|
-
|
|
64
|
-
**Note:** Version bump only for package @parca/profile
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
## [0.16.126-alpha.1](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.1) (2023-02-27)
|
|
71
|
-
|
|
72
|
-
**Note:** Version bump only for package @parca/profile
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## [0.16.126-alpha.0](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.0) (2023-02-27)
|
|
79
|
-
|
|
80
|
-
**Note:** Version bump only for package @parca/profile
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
## [0.16.126-alpha.1](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.1) (2023-02-27)
|
|
87
|
-
|
|
88
|
-
**Note:** Version bump only for package @parca/profile
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
## [0.16.126-alpha.0](https://github.com/parca-dev/parca/compare/@parca/profile@0.16.125...@parca/profile@0.16.126-alpha.0) (2023-02-27)
|
|
95
|
-
|
|
96
|
-
**Note:** Version bump only for package @parca/profile
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
14
|
## 0.16.125 (2023-02-23)
|
|
103
15
|
|
|
104
16
|
**Note:** Version bump only for package @parca/profile
|
|
@@ -83,7 +83,7 @@ var ProfileExplorerApp = function (_a) {
|
|
|
83
83
|
var profileA = ProfileSelectionFromParams(expression_a, from_a, to_a, mergeFrom, mergeTo, labels, filter_by_function);
|
|
84
84
|
setProfileA(profileA);
|
|
85
85
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
86
|
-
}, [merge_from_a, merge_to_a]);
|
|
86
|
+
}, [merge_from_a, merge_to_a, filter_by_function]);
|
|
87
87
|
useEffect(function () {
|
|
88
88
|
var _a;
|
|
89
89
|
var mergeFrom = merge_from_b !== null && merge_from_b !== void 0 ? merge_from_b : undefined;
|
|
@@ -92,7 +92,7 @@ var ProfileExplorerApp = function (_a) {
|
|
|
92
92
|
var profileB = ProfileSelectionFromParams(expression_b, from_b, to_b, mergeFrom, mergeTo, labels, filter_by_function);
|
|
93
93
|
setProfileB(profileB);
|
|
94
94
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
95
|
-
}, [merge_from_b, merge_to_b]);
|
|
95
|
+
}, [merge_from_b, merge_to_b, filter_by_function]);
|
|
96
96
|
if (profileTypesLoading) {
|
|
97
97
|
return _jsx(_Fragment, { children: loader });
|
|
98
98
|
}
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { useMemo } from 'react';
|
|
14
|
-
import { diffColor } from '@parca/functions';
|
|
14
|
+
import { COLOR_PROFILES, diffColor } from '@parca/functions';
|
|
15
15
|
import { EVERYTHING_ELSE, selectDarkMode, selectStackColors, useAppSelector } from '@parca/store';
|
|
16
16
|
var useNodeColor = function (_a) {
|
|
17
17
|
var data = _a.data, compareMode = _a.compareMode;
|
|
18
18
|
var colors = useAppSelector(selectStackColors);
|
|
19
19
|
var isDarkMode = useAppSelector(selectDarkMode);
|
|
20
20
|
var color = useMemo(function () {
|
|
21
|
-
var _a;
|
|
21
|
+
var _a, _b;
|
|
22
22
|
if (compareMode) {
|
|
23
23
|
var diff = parseFloat(data.diff);
|
|
24
24
|
var cumulative = parseFloat(data.cumulative);
|
|
25
25
|
return diffColor(diff, cumulative, isDarkMode);
|
|
26
26
|
}
|
|
27
|
-
var color = colors[(_a = data.feature) !== null && _a !== void 0 ? _a : EVERYTHING_ELSE];
|
|
27
|
+
var color = (_b = colors[(_a = data.feature) !== null && _a !== void 0 ? _a : EVERYTHING_ELSE]) !== null && _b !== void 0 ? _b : (!isDarkMode ? COLOR_PROFILES.default.colors[0][0] : COLOR_PROFILES.default.colors[0][1]);
|
|
28
28
|
return color;
|
|
29
29
|
}, [data, colors, isDarkMode, compareMode]);
|
|
30
30
|
return color;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parca/profile",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.127",
|
|
4
4
|
"description": "Profile viewing libraries",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@parca/client": "^0.16.64",
|
|
7
|
-
"@parca/components": "^0.16.105
|
|
7
|
+
"@parca/components": "^0.16.105",
|
|
8
8
|
"@parca/dynamicsize": "^0.16.53",
|
|
9
9
|
"@parca/functions": "^0.16.65",
|
|
10
10
|
"@parca/parser": "^0.16.54",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"access": "public",
|
|
46
46
|
"registry": "https://registry.npmjs.org/"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "0b529baa421a579ed5d3201821108bcd5badeb7e"
|
|
49
49
|
}
|
|
@@ -131,7 +131,7 @@ const ProfileExplorerApp = ({
|
|
|
131
131
|
|
|
132
132
|
setProfileA(profileA);
|
|
133
133
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
134
|
-
}, [merge_from_a, merge_to_a]);
|
|
134
|
+
}, [merge_from_a, merge_to_a, filter_by_function]);
|
|
135
135
|
|
|
136
136
|
useEffect(() => {
|
|
137
137
|
const mergeFrom = merge_from_b ?? undefined;
|
|
@@ -149,7 +149,7 @@ const ProfileExplorerApp = ({
|
|
|
149
149
|
|
|
150
150
|
setProfileB(profileB);
|
|
151
151
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
152
|
-
}, [merge_from_b, merge_to_b]);
|
|
152
|
+
}, [merge_from_b, merge_to_b, filter_by_function]);
|
|
153
153
|
|
|
154
154
|
if (profileTypesLoading) {
|
|
155
155
|
return <>{loader}</>;
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import {useMemo} from 'react';
|
|
15
15
|
|
|
16
|
-
import {diffColor} from '@parca/functions';
|
|
16
|
+
import {COLOR_PROFILES, diffColor} from '@parca/functions';
|
|
17
17
|
import {EVERYTHING_ELSE, selectDarkMode, selectStackColors, useAppSelector} from '@parca/store';
|
|
18
18
|
|
|
19
19
|
import type {ColoredFlamegraphNode} from './useColoredGraph';
|
|
@@ -34,7 +34,10 @@ const useNodeColor = ({data, compareMode}: Props): string => {
|
|
|
34
34
|
return diffColor(diff, cumulative, isDarkMode);
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
const color =
|
|
37
|
+
const color =
|
|
38
|
+
colors[data.feature ?? EVERYTHING_ELSE] ??
|
|
39
|
+
(!isDarkMode ? COLOR_PROFILES.default.colors[0][0] : COLOR_PROFILES.default.colors[0][1]);
|
|
40
|
+
|
|
38
41
|
return color;
|
|
39
42
|
}, [data, colors, isDarkMode, compareMode]);
|
|
40
43
|
|
package/dist/DiffLegend/index.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
// Copyright 2022 The Parca Authors
|
|
14
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
// you may not use this file except in compliance with the License.
|
|
16
|
-
// You may obtain a copy of the License at
|
|
17
|
-
//
|
|
18
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
//
|
|
20
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
21
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
-
// See the License for the specific language governing permissions and
|
|
24
|
-
// limitations under the License.
|
|
25
|
-
import { Fragment, useState } from 'react';
|
|
26
|
-
import { Popover, Transition } from '@headlessui/react';
|
|
27
|
-
import { usePopper } from 'react-popper';
|
|
28
|
-
import { getIncreasedSpanColor, getNewSpanColor, getReducedSpanColor } from '@parca/functions';
|
|
29
|
-
import { selectDarkMode, useAppSelector } from '@parca/store';
|
|
30
|
-
var transparencyValues = [-100, -80, -60, -40, -20, 0, 20, 40, 60, 80, 100];
|
|
31
|
-
var DiffLegendBar = function (_a) {
|
|
32
|
-
var onMouseEnter = _a.onMouseEnter, onMouseLeave = _a.onMouseLeave;
|
|
33
|
-
var isDarkMode = useAppSelector(selectDarkMode);
|
|
34
|
-
return (_jsx("div", __assign({ className: "flex items-center m-2" }, { children: transparencyValues.map(function (value) {
|
|
35
|
-
var valueAsPercentage = value / 100;
|
|
36
|
-
var absoluteValue = Math.abs(valueAsPercentage);
|
|
37
|
-
return (_jsx("div", { onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, className: "w-8 h-4", style: {
|
|
38
|
-
backgroundColor: absoluteValue === 0
|
|
39
|
-
? getNewSpanColor(isDarkMode)
|
|
40
|
-
: valueAsPercentage > 0
|
|
41
|
-
? getIncreasedSpanColor(absoluteValue, isDarkMode)
|
|
42
|
-
: getReducedSpanColor(absoluteValue, isDarkMode),
|
|
43
|
-
} }, valueAsPercentage));
|
|
44
|
-
}) })));
|
|
45
|
-
};
|
|
46
|
-
var DiffLegend = function () {
|
|
47
|
-
var _a = useState(false), showLegendTooltip = _a[0], setShowLegendTooltip = _a[1];
|
|
48
|
-
var _b = useState(null), popperElement = _b[0], setPopperElement = _b[1];
|
|
49
|
-
var _c = useState(null), referenceElement = _c[0], setReferenceElement = _c[1];
|
|
50
|
-
var _d = usePopper(referenceElement, popperElement, {
|
|
51
|
-
placement: 'auto-start',
|
|
52
|
-
strategy: 'absolute',
|
|
53
|
-
}), styles = _d.styles, attributes = _d.attributes;
|
|
54
|
-
var handleMouseEnter = function () {
|
|
55
|
-
setShowLegendTooltip(true);
|
|
56
|
-
};
|
|
57
|
-
var handleMouseLeave = function () {
|
|
58
|
-
setShowLegendTooltip(false);
|
|
59
|
-
};
|
|
60
|
-
return (_jsxs("div", __assign({ className: "mt-1 mb-2" }, { children: [_jsxs("div", __assign({ ref: setReferenceElement, className: "flex items-center justify-center" }, { children: [_jsx("span", { children: "Better" }), _jsx(DiffLegendBar, { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }), _jsx("span", { children: "Worse" })] })), _jsx(Popover, __assign({ className: "relative" }, { children: function () { return (_jsx(Transition, __assign({ show: showLegendTooltip, as: Fragment, enter: "transition ease-out duration-200", enterFrom: "opacity-0 translate-y-1", enterTo: "opacity-100 translate-y-0", leave: "transition ease-in duration-150", leaveFrom: "opacity-100 translate-y-0", leaveTo: "opacity-0 translate-y-1" }, { children: _jsx(Popover.Panel, __assign({ ref: setPopperElement, style: styles.popper }, attributes.popper, { children: _jsx("div", __assign({ className: "overflow-hidden rounded-lg shadow-lg ring-1 ring-black ring-opacity-5" }, { children: _jsxs("div", __assign({ className: "p-4 bg-gray-50 dark:bg-gray-800" }, { children: [_jsx("div", { className: "flex items-center justify-center" }), _jsx("span", __assign({ className: "block text-sm text-gray-500 dark:text-gray-50" }, { children: "This is a differential icicle graph, where a purple-colored node means unchanged, and the darker the red, the worse the node got, and the darker the green, the better the node got." }))] })) })) })) }))); } }))] })));
|
|
61
|
-
};
|
|
62
|
-
export default DiffLegend;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
// Copyright 2022 The Parca Authors
|
|
14
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
15
|
-
// you may not use this file except in compliance with the License.
|
|
16
|
-
// You may obtain a copy of the License at
|
|
17
|
-
//
|
|
18
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
-
//
|
|
20
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
21
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
22
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
23
|
-
// See the License for the specific language governing permissions and
|
|
24
|
-
// limitations under the License.
|
|
25
|
-
import { useState } from 'react';
|
|
26
|
-
import { Icon } from '@iconify/react';
|
|
27
|
-
import cx from 'classnames';
|
|
28
|
-
import { CopyToClipboard } from 'react-copy-to-clipboard';
|
|
29
|
-
import { Button } from '@parca/components';
|
|
30
|
-
var timeoutHandle = null;
|
|
31
|
-
var ResultBox = function (_a) {
|
|
32
|
-
var _b;
|
|
33
|
-
var value = _a.value, _c = _a.className, className = _c === void 0 ? '' : _c;
|
|
34
|
-
var _d = useState(false), isCopied = _d[0], setIsCopied = _d[1];
|
|
35
|
-
var onCopy = function () {
|
|
36
|
-
var _a, _b;
|
|
37
|
-
setIsCopied(true);
|
|
38
|
-
(_b = (_a = window.document) === null || _a === void 0 ? void 0 : _a.activeElement) === null || _b === void 0 ? void 0 : _b.blur();
|
|
39
|
-
if (timeoutHandle != null) {
|
|
40
|
-
clearTimeout(timeoutHandle);
|
|
41
|
-
}
|
|
42
|
-
timeoutHandle = setTimeout(function () { return setIsCopied(false); }, 3000);
|
|
43
|
-
};
|
|
44
|
-
return (_jsxs("div", __assign({ className: cx('flex flex-row w-full', (_b = {}, _b[className] = (className === null || className === void 0 ? void 0 : className.length) > 0, _b)) }, { children: [_jsx("span", __assign({ className: "flex justify-center items-center border border-r-0 w-16 rounded-l" }, { children: _jsx(Icon, { icon: "ant-design:link-outlined" }) })), _jsx("input", { type: "text", className: "border text-sm bg-inherit w-full px-1 py-2 flex-grow", value: value, readOnly: true }), _jsx(CopyToClipboard, __assign({ text: value, onCopy: onCopy }, { children: _jsx(Button, __assign({ variant: "link", className: "border border-l-0 w-fit whitespace-nowrap p-4 items-center !text-indigo-600 dark:!text-indigo-400 rounded-none rounded-r" }, { children: isCopied ? 'Copied!' : 'Copy Link' })) }))] })));
|
|
45
|
-
};
|
|
46
|
-
export default ResultBox;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { QueryRequest, QueryServiceClient } from '@parca/client';
|
|
3
|
-
interface Props {
|
|
4
|
-
queryRequest: QueryRequest;
|
|
5
|
-
queryClient: QueryServiceClient;
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
}
|
|
8
|
-
declare const ProfileShareButton: ({ queryRequest, queryClient, disabled }: Props) => JSX.Element;
|
|
9
|
-
export default ProfileShareButton;
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
-
function step(op) {
|
|
26
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
-
switch (op[0]) {
|
|
31
|
-
case 0: case 1: t = op; break;
|
|
32
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
-
default:
|
|
36
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
-
if (t[2]) _.ops.pop();
|
|
41
|
-
_.trys.pop(); continue;
|
|
42
|
-
}
|
|
43
|
-
op = body.call(thisArg, _);
|
|
44
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
49
|
-
// Copyright 2022 The Parca Authors
|
|
50
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
51
|
-
// you may not use this file except in compliance with the License.
|
|
52
|
-
// You may obtain a copy of the License at
|
|
53
|
-
//
|
|
54
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
55
|
-
//
|
|
56
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
57
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
58
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
59
|
-
// See the License for the specific language governing permissions and
|
|
60
|
-
// limitations under the License.
|
|
61
|
-
import { useState } from 'react';
|
|
62
|
-
import { Icon } from '@iconify/react';
|
|
63
|
-
import { Button, Modal, useGrpcMetadata } from '@parca/components';
|
|
64
|
-
import ResultBox from './ResultBox';
|
|
65
|
-
var ProfileShareModal = function (_a) {
|
|
66
|
-
var isOpen = _a.isOpen, closeModal = _a.closeModal, queryRequest = _a.queryRequest, queryClient = _a.queryClient;
|
|
67
|
-
var _b = useState(false), isShared = _b[0], setIsShared = _b[1];
|
|
68
|
-
var _c = useState(false), loading = _c[0], setLoading = _c[1];
|
|
69
|
-
var _d = useState(''), error = _d[0], setError = _d[1];
|
|
70
|
-
var _e = useState(''), description = _e[0], setDescription = _e[1];
|
|
71
|
-
var _f = useState(''), sharedLink = _f[0], setSharedLink = _f[1];
|
|
72
|
-
var metadata = useGrpcMetadata();
|
|
73
|
-
var isFormDataValid = function () { return true; };
|
|
74
|
-
var handleSubmit = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
-
var response, err_1;
|
|
76
|
-
return __generator(this, function (_a) {
|
|
77
|
-
switch (_a.label) {
|
|
78
|
-
case 0:
|
|
79
|
-
_a.trys.push([0, 2, , 3]);
|
|
80
|
-
setLoading(true);
|
|
81
|
-
return [4 /*yield*/, queryClient.shareProfile({ queryRequest: queryRequest, description: description }, { meta: metadata })];
|
|
82
|
-
case 1:
|
|
83
|
-
response = (_a.sent()).response;
|
|
84
|
-
setSharedLink(response.link);
|
|
85
|
-
setLoading(false);
|
|
86
|
-
setIsShared(true);
|
|
87
|
-
return [3 /*break*/, 3];
|
|
88
|
-
case 2:
|
|
89
|
-
err_1 = _a.sent();
|
|
90
|
-
if (err_1 instanceof Error) {
|
|
91
|
-
console.error(err_1);
|
|
92
|
-
setLoading(false);
|
|
93
|
-
// https://github.com/microsoft/TypeScript/issues/38347
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
95
|
-
setError(err_1.toString());
|
|
96
|
-
}
|
|
97
|
-
return [3 /*break*/, 3];
|
|
98
|
-
case 3: return [2 /*return*/];
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
}); };
|
|
102
|
-
var onClose = function () {
|
|
103
|
-
setLoading(false);
|
|
104
|
-
setError('');
|
|
105
|
-
setDescription('');
|
|
106
|
-
setIsShared(false);
|
|
107
|
-
closeModal();
|
|
108
|
-
};
|
|
109
|
-
return (_jsx(Modal, __assign({ isOpen: isOpen, closeModal: onClose, title: "Share Profile", className: "w-[420px]" }, { children: _jsxs("form", __assign({ className: "py-2" }, { children: [_jsx("p", __assign({ className: "text-sm text-gray-500 dark:text-gray-300" }, { children: "Note: Shared profiles can be accessed by anyone with the link, even from people outside your organisation." })), !isShared || (error === null || error === void 0 ? void 0 : error.length) > 0 ? (_jsxs(_Fragment, { children: [_jsx("p", __assign({ className: "text-sm text-gray-500 dark:text-gray-300 mt-3 mb-2" }, { children: "Enter a description (optional)" })), _jsx("textarea", { className: "border w-full text-gray-500 dark:text-gray-300 bg-inherit text-sm px-2 py-2", value: description, onChange: function (e) { return setDescription(e.target.value); } }), _jsx(Button, __assign({ className: "w-fit mt-4", onClick: function (e) {
|
|
110
|
-
e.preventDefault();
|
|
111
|
-
void handleSubmit();
|
|
112
|
-
}, disabled: loading || !isFormDataValid(), type: "submit" }, { children: loading ? 'Sharing' : 'Share' })), error !== '' ? _jsx("p", { children: "Something went wrong please try again" }) : null] })) : (_jsxs(_Fragment, { children: [_jsx(ResultBox, { value: sharedLink, className: "mt-4" }), _jsx("div", __assign({ className: "flex justify-center mt-8" }, { children: _jsx(Button, __assign({ variant: "neutral", className: "w-fit", onClick: onClose }, { children: "Close" })) }))] }))] })) })));
|
|
113
|
-
};
|
|
114
|
-
var ProfileShareButton = function (_a) {
|
|
115
|
-
var queryRequest = _a.queryRequest, queryClient = _a.queryClient, _b = _a.disabled, disabled = _b === void 0 ? false : _b;
|
|
116
|
-
var _c = useState(false), isOpen = _c[0], setIsOpen = _c[1];
|
|
117
|
-
return (_jsxs(_Fragment, { children: [_jsx(Button, __assign({ color: "neutral", className: "w-fit", onClick: function () { return setIsOpen(true); }, disabled: disabled }, { children: _jsx(Icon, { icon: "ei:share-apple", width: 20 }) })), _jsx(ProfileShareModal, { isOpen: isOpen, closeModal: function () { return setIsOpen(false); }, queryRequest: queryRequest, queryClient: queryClient })] }));
|
|
118
|
-
};
|
|
119
|
-
export default ProfileShareButton;
|