@bundle-stats/ui 3.4.0-beta.0 → 4.0.0-alpha.10
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/lib/app/app.js +6 -21
- package/lib/app/app.stories.js +1 -22
- package/lib/assets/icons.svg +0 -8
- package/lib/components/asset-info/asset-info.js +1 -1
- package/lib/components/bundle-assets/bundle-assets.js +1 -1
- package/lib/components/bundle-assets/index.js +1 -1
- package/lib/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +1 -1
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.js +8 -43
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
- package/lib/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +1 -20
- package/lib/components/bundle-modules/bundle-modules.js +2 -3
- package/lib/components/bundle-modules/index.js +1 -1
- package/lib/components/bundle-packages/bundle-packages.js +3 -2
- package/lib/components/bundle-packages/index.js +1 -1
- package/lib/components/component-link.js +1 -1
- package/lib/components/index.js +0 -8
- package/lib/components/job-meta/job-meta.js +1 -1
- package/lib/components/job-name/job-name.js +1 -1
- package/lib/components/metrics-table/metrics-table.js +1 -1
- package/lib/components/metrics-table-options/metrics-table-options.js +1 -1
- package/lib/components/module-info/module-info.js +1 -1
- package/lib/components/summary/summary.js +8 -13
- package/lib/components/summary/summary.stories.js +1 -58
- package/lib/components/summary-item/summary-item.js +6 -21
- package/lib/components/summary-item/summary-item.module.css +0 -6
- package/lib/components/summary-item/summary-item.stories.js +53 -65
- package/lib/constants.js +4 -4
- package/lib/layout/box/box.js +1 -1
- package/lib/layout/flex-stack/flex-stack.js +1 -1
- package/lib/layout/footer/footer.js +1 -1
- package/lib/layout/separator.js +1 -1
- package/lib/layout/stack/stack.js +1 -1
- package/lib/query-state.js +1 -1
- package/lib/ui/alert/alert.js +3 -13
- package/lib/ui/container/container.js +1 -1
- package/lib/ui/filters/filters.container.js +3 -3
- package/lib/ui/filters/filters.js +1 -1
- package/lib/ui/horizontal-bar-chart/horizontal-bar-chart.js +2 -2
- package/lib/ui/hover-card/hover-card.js +1 -1
- package/lib/ui/hover-card/hover-card.stories.js +1 -1
- package/lib/ui/icon/icon.js +1 -3
- package/lib/ui/input/input.js +1 -1
- package/lib/ui/loader/loader.js +1 -1
- package/lib/ui/logo/logo.js +1 -1
- package/lib/ui/panels/panels.js +1 -1
- package/lib/ui/skeleton/skeleton.js +1 -1
- package/lib/ui/sort-dropdown/sort-dropdown.js +1 -1
- package/lib/ui/tag/tag.js +1 -1
- package/lib/ui/tooltip/tooltip.js +1 -1
- package/lib-esm/app/app.js +6 -20
- package/lib-esm/app/app.stories.js +1 -22
- package/lib-esm/assets/icons.svg +0 -8
- package/lib-esm/components/asset-info/asset-info.js +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.js +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.utils.js +1 -0
- package/lib-esm/components/bundle-assets/index.js +1 -1
- package/lib-esm/components/bundle-assets-totals-chart-bars/bundle-assets-totals-chart-bars.js +1 -1
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.js +8 -24
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
- package/lib-esm/components/bundle-assets-totals-table/bundle-assets-totals-table.stories.js +0 -18
- package/lib-esm/components/bundle-modules/bundle-modules.js +2 -3
- package/lib-esm/components/bundle-modules/index.js +1 -1
- package/lib-esm/components/bundle-packages/bundle-packages.js +3 -2
- package/lib-esm/components/bundle-packages/bundle-packages.utils.js +1 -0
- package/lib-esm/components/bundle-packages/index.js +1 -1
- package/lib-esm/components/component-link.js +1 -1
- package/lib-esm/components/index.js +0 -1
- package/lib-esm/components/job-meta/job-meta.js +1 -1
- package/lib-esm/components/job-name/job-name.js +1 -1
- package/lib-esm/components/metrics-table/metrics-table.js +1 -1
- package/lib-esm/components/metrics-table-options/metrics-table-options.js +1 -1
- package/lib-esm/components/module-info/module-info.js +1 -1
- package/lib-esm/components/summary/summary.js +9 -12
- package/lib-esm/components/summary/summary.stories.js +1 -56
- package/lib-esm/components/summary-item/summary-item.js +5 -18
- package/lib-esm/components/summary-item/summary-item.module.css +0 -6
- package/lib-esm/components/summary-item/summary-item.stories.js +38 -64
- package/lib-esm/constants.js +4 -4
- package/lib-esm/layout/box/box.js +1 -1
- package/lib-esm/layout/flex-stack/flex-stack.js +1 -1
- package/lib-esm/layout/footer/footer.js +1 -1
- package/lib-esm/layout/separator.js +1 -1
- package/lib-esm/layout/stack/stack.js +1 -1
- package/lib-esm/query-state.js +1 -1
- package/lib-esm/ui/alert/alert.js +3 -6
- package/lib-esm/ui/container/container.js +1 -1
- package/lib-esm/ui/filters/filters.container.js +1 -1
- package/lib-esm/ui/filters/filters.js +2 -1
- package/lib-esm/ui/hover-card/hover-card.js +1 -1
- package/lib-esm/ui/hover-card/hover-card.stories.js +1 -1
- package/lib-esm/ui/icon/icon.js +1 -3
- package/lib-esm/ui/input/input.js +1 -1
- package/lib-esm/ui/loader/loader.js +1 -1
- package/lib-esm/ui/logo/logo.js +1 -1
- package/lib-esm/ui/panels/panels.js +1 -1
- package/lib-esm/ui/skeleton/skeleton.js +1 -1
- package/lib-esm/ui/sort-dropdown/sort-dropdown.js +1 -1
- package/lib-esm/ui/tag/tag.js +1 -1
- package/lib-esm/ui/tooltip/tooltip.js +1 -1
- package/package.json +22 -22
- package/src/app/app.jsx +5 -12
- package/src/assets/icons.svg +0 -8
- package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.jsx +13 -27
- package/src/components/bundle-assets-totals-table/bundle-assets-totals-table.module.css +2 -2
- package/src/components/bundle-modules/bundle-modules.jsx +0 -1
- package/src/components/bundle-packages/bundle-packages.jsx +2 -2
- package/src/components/index.js +0 -1
- package/src/components/summary/summary.jsx +7 -8
- package/src/components/summary-item/summary-item.jsx +3 -10
- package/src/components/summary-item/summary-item.module.css +0 -6
- package/src/constants.js +11 -7
- package/src/ui/alert/alert.jsx +2 -7
- package/src/ui/icon/icon.jsx +0 -2
- package/lib/assets/icons/alert-circle.svg +0 -1
- package/lib/assets/icons/check-circle.svg +0 -1
- package/lib/components/budget-info/budget-info.js +0 -74
- package/lib/components/budget-info/budget-info.module.css +0 -40
- package/lib/components/budget-info/budget-info.stories.js +0 -59
- package/lib/components/budget-info/index.js +0 -18
- package/lib/components/budget-insights/budget-insights.js +0 -162
- package/lib/components/budget-insights/budget-insights.module.css +0 -61
- package/lib/components/budget-insights/budget-insights.stories.js +0 -165
- package/lib/components/budget-insights/index.js +0 -18
- package/lib-esm/assets/icons/alert-circle.svg +0 -1
- package/lib-esm/assets/icons/check-circle.svg +0 -1
- package/lib-esm/components/budget-info/budget-info.js +0 -57
- package/lib-esm/components/budget-info/budget-info.module.css +0 -40
- package/lib-esm/components/budget-info/budget-info.stories.js +0 -45
- package/lib-esm/components/budget-info/index.js +0 -1
- package/lib-esm/components/budget-insights/budget-insights.js +0 -112
- package/lib-esm/components/budget-insights/budget-insights.module.css +0 -61
- package/lib-esm/components/budget-insights/budget-insights.stories.js +0 -144
- package/lib-esm/components/budget-insights/index.js +0 -1
- package/src/assets/icons/alert-circle.svg +0 -1
- package/src/assets/icons/check-circle.svg +0 -1
- package/src/components/budget-info/budget-info.jsx +0 -55
- package/src/components/budget-info/budget-info.module.css +0 -40
- package/src/components/budget-info/index.js +0 -1
- package/src/components/budget-insights/budget-insights.jsx +0 -124
- package/src/components/budget-insights/budget-insights.module.css +0 -61
- package/src/components/budget-insights/index.js +0 -1
|
@@ -11,14 +11,11 @@ import { ComponentLink } from '../component-link';
|
|
|
11
11
|
import { SummaryItem } from '../summary-item';
|
|
12
12
|
import css from './summary.module.css';
|
|
13
13
|
|
|
14
|
-
const getSourceMetricId = (fullMetricId) => fullMetricId.split('.').slice(1).join('.');
|
|
15
|
-
|
|
16
14
|
export const Summary = ({
|
|
17
15
|
className,
|
|
18
16
|
size,
|
|
19
17
|
keys,
|
|
20
18
|
data,
|
|
21
|
-
budgets,
|
|
22
19
|
loading,
|
|
23
20
|
showSummaryItemDelta,
|
|
24
21
|
summaryItemLink: SummaryItemCustomLink,
|
|
@@ -26,7 +23,7 @@ export const Summary = ({
|
|
|
26
23
|
<Box outline className={cx(css.root, className)}>
|
|
27
24
|
<FlexStack className={css.items}>
|
|
28
25
|
{Array.from(METRIC_COMPONENT_LINKS)
|
|
29
|
-
.filter(([metricId]) => keys.includes(
|
|
26
|
+
.filter(([metricId]) => keys.includes(metricId))
|
|
30
27
|
.map(([metricId, metricOptions]) => (
|
|
31
28
|
<SummaryItem
|
|
32
29
|
key={metricId}
|
|
@@ -36,7 +33,6 @@ export const Summary = ({
|
|
|
36
33
|
size={size}
|
|
37
34
|
id={metricId}
|
|
38
35
|
data={get(data, metricId)}
|
|
39
|
-
budget={get(budgets, ['data', getSourceMetricId(metricId)])}
|
|
40
36
|
loading={loading}
|
|
41
37
|
showMetricDescription
|
|
42
38
|
showDelta={showSummaryItemDelta && metricOptions.showDelta !== false}
|
|
@@ -49,7 +45,6 @@ export const Summary = ({
|
|
|
49
45
|
Summary.defaultProps = {
|
|
50
46
|
className: '',
|
|
51
47
|
data: null,
|
|
52
|
-
budgets: null,
|
|
53
48
|
loading: false,
|
|
54
49
|
size: '',
|
|
55
50
|
keys: METRICS_WEBPACK_GENERAL,
|
|
@@ -61,8 +56,12 @@ Summary.propTypes = {
|
|
|
61
56
|
className: PropTypes.string,
|
|
62
57
|
size: PropTypes.string,
|
|
63
58
|
keys: PropTypes.arrayOf(PropTypes.string),
|
|
64
|
-
data: PropTypes.
|
|
65
|
-
|
|
59
|
+
data: PropTypes.shape({
|
|
60
|
+
[PropTypes.string]: PropTypes.shape({
|
|
61
|
+
baseline: PropTypes.number,
|
|
62
|
+
current: PropTypes.number,
|
|
63
|
+
}),
|
|
64
|
+
}),
|
|
66
65
|
loading: PropTypes.bool,
|
|
67
66
|
showSummaryItemDelta: PropTypes.bool,
|
|
68
67
|
summaryItemLink: PropTypes.elementType,
|
|
@@ -5,11 +5,9 @@ import { getGlobalMetricType, getMetricRunInfo } from '@bundle-stats/utils';
|
|
|
5
5
|
|
|
6
6
|
import { HoverCard } from '../../ui/hover-card';
|
|
7
7
|
import { Skeleton } from '../../ui/skeleton';
|
|
8
|
-
import { FlexStack } from '../../layout/flex-stack';
|
|
9
8
|
import { Stack } from '../../layout/stack';
|
|
10
9
|
import { Metric } from '../metric';
|
|
11
10
|
import { Delta } from '../delta';
|
|
12
|
-
import { BudgetInfo } from '../budget-info';
|
|
13
11
|
import css from './summary-item.module.css';
|
|
14
12
|
|
|
15
13
|
const MetricInfo = ({ description, url }) => (
|
|
@@ -43,7 +41,6 @@ export const SummaryItem = ({
|
|
|
43
41
|
loading,
|
|
44
42
|
showDelta,
|
|
45
43
|
showMetricDescription,
|
|
46
|
-
budget,
|
|
47
44
|
...props
|
|
48
45
|
}) => {
|
|
49
46
|
const { baseline, current } = data || { baseline: 0, current: 0 };
|
|
@@ -51,11 +48,12 @@ export const SummaryItem = ({
|
|
|
51
48
|
const metric = getGlobalMetricType(id);
|
|
52
49
|
const runInfo = getMetricRunInfo(metric, current, baseline);
|
|
53
50
|
const showMetricDescriptionTooltip = showMetricDescription && metric?.description;
|
|
51
|
+
|
|
54
52
|
const rootClassName = cx(css.root, className, css[size], showDelta && css.showDelta);
|
|
55
53
|
|
|
56
54
|
return (
|
|
57
55
|
<Stack space="xxsmall" as={Component} className={rootClassName} {...props}>
|
|
58
|
-
<
|
|
56
|
+
<h3 className={css.title}>
|
|
59
57
|
{showMetricDescriptionTooltip ? (
|
|
60
58
|
<HoverCard label={metric.label}>
|
|
61
59
|
<MetricInfo {...metric} />
|
|
@@ -63,8 +61,7 @@ export const SummaryItem = ({
|
|
|
63
61
|
) : (
|
|
64
62
|
metric.label
|
|
65
63
|
)}
|
|
66
|
-
|
|
67
|
-
</FlexStack>
|
|
64
|
+
</h3>
|
|
68
65
|
|
|
69
66
|
{!loading ? (
|
|
70
67
|
<Stack>
|
|
@@ -103,7 +100,6 @@ SummaryItem.defaultProps = {
|
|
|
103
100
|
loading: false,
|
|
104
101
|
showMetricDescription: false,
|
|
105
102
|
showDelta: true,
|
|
106
|
-
budget: undefined,
|
|
107
103
|
};
|
|
108
104
|
|
|
109
105
|
SummaryItem.propTypes = {
|
|
@@ -130,7 +126,4 @@ SummaryItem.propTypes = {
|
|
|
130
126
|
|
|
131
127
|
/** Show delta */
|
|
132
128
|
showDelta: PropTypes.bool,
|
|
133
|
-
|
|
134
|
-
/** Budget insight data */
|
|
135
|
-
budget: PropTypes.object, // eslint-disable-line react/forbid-prop-types
|
|
136
129
|
};
|
package/src/constants.js
CHANGED
|
@@ -47,11 +47,15 @@ export const ASSETS_SIZES_FILE_TYPE_MAP = FILE_TYPES.reduce(
|
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
export const METRICS_WEBPACK_GENERAL = [
|
|
50
|
-
'totalSizeByTypeALL',
|
|
51
|
-
'totalInitialSizeJS',
|
|
52
|
-
'totalInitialSizeCSS',
|
|
53
|
-
'cacheInvalidation',
|
|
50
|
+
'webpack.totalSizeByTypeALL',
|
|
51
|
+
'webpack.totalInitialSizeJS',
|
|
52
|
+
'webpack.totalInitialSizeCSS',
|
|
53
|
+
'webpack.cacheInvalidation',
|
|
54
54
|
];
|
|
55
|
-
export const METRICS_WEBPACK_ASSETS = ['assetCount', 'chunkCount'];
|
|
56
|
-
export const METRICS_WEBPACK_MODULES = [
|
|
57
|
-
|
|
55
|
+
export const METRICS_WEBPACK_ASSETS = ['webpack.assetCount', 'webpack.chunkCount'];
|
|
56
|
+
export const METRICS_WEBPACK_MODULES = [
|
|
57
|
+
'webpack.moduleCount',
|
|
58
|
+
'webpack.duplicateModulesCount',
|
|
59
|
+
'webpack.duplicateCode',
|
|
60
|
+
];
|
|
61
|
+
export const METRICS_WEBPACK_PACKAGES = ['webpack.packageCount', 'webpack.duplicatePackagesCount'];
|
package/src/ui/alert/alert.jsx
CHANGED
|
@@ -6,15 +6,10 @@ import { Box } from '../../layout/box';
|
|
|
6
6
|
import css from './alert.module.css';
|
|
7
7
|
|
|
8
8
|
export const Alert = (props) => {
|
|
9
|
-
const { className, kind, children
|
|
9
|
+
const { className, kind, children } = props;
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
|
-
<Box
|
|
13
|
-
padding={['xsmall', 'small']}
|
|
14
|
-
outline
|
|
15
|
-
className={cx(css.root, className, css[kind])}
|
|
16
|
-
{...restProps}
|
|
17
|
-
>
|
|
12
|
+
<Box padding={['xsmall', 'small']} outline className={cx(css.root, className, css[kind])}>
|
|
18
13
|
{children}
|
|
19
14
|
</Box>
|
|
20
15
|
);
|
package/src/ui/icon/icon.jsx
CHANGED
|
@@ -5,13 +5,11 @@ import cx from 'classnames';
|
|
|
5
5
|
import css from './icon.module.css';
|
|
6
6
|
|
|
7
7
|
const ICONS = {
|
|
8
|
-
ALERT_CIRCLE: 'alert-circle',
|
|
9
8
|
ARROW: 'arrow',
|
|
10
9
|
ARROW_RIGHT_CIRLCE: 'arrow-right-circle',
|
|
11
10
|
CANCEL: 'cancel',
|
|
12
11
|
CLOSE: 'close',
|
|
13
12
|
CLOCK: 'clock',
|
|
14
|
-
CHECK_CIRCLE: 'check-circle',
|
|
15
13
|
COMMIT: 'commit',
|
|
16
14
|
FILTER: 'filter',
|
|
17
15
|
HELP: 'help',
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-alert-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="12"></line><line x1="12" y1="16" x2="12.01" y2="16"></line></svg>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-check-circle"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path><polyline points="22 4 12 14.01 9 11.01"></polyline></svg>
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.BudgetInfo = void 0;
|
|
7
|
-
|
|
8
|
-
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
var _utils = require("@bundle-stats/utils");
|
|
15
|
-
|
|
16
|
-
var _icon = require("../../ui/icon");
|
|
17
|
-
|
|
18
|
-
var _tooltip = require("../../ui/tooltip");
|
|
19
|
-
|
|
20
|
-
var _budgetInfoModule = _interopRequireDefault(require("./budget-info.module.css"));
|
|
21
|
-
|
|
22
|
-
var _INSIGHT_TYPE_MAP;
|
|
23
|
-
|
|
24
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
-
|
|
26
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
|
-
|
|
28
|
-
var INSIGHT_TYPE_MAP = (_INSIGHT_TYPE_MAP = {}, _defineProperty(_INSIGHT_TYPE_MAP, _utils.InsightType.SUCCESS, {
|
|
29
|
-
className: _budgetInfoModule["default"].success,
|
|
30
|
-
glyph: _icon.Icon.ICONS.CHECK_CIRCLE
|
|
31
|
-
}), _defineProperty(_INSIGHT_TYPE_MAP, _utils.InsightType.ERROR, {
|
|
32
|
-
className: _budgetInfoModule["default"].error,
|
|
33
|
-
glyph: _icon.Icon.ICONS.ALERT_CIRCLE
|
|
34
|
-
}), _defineProperty(_INSIGHT_TYPE_MAP, _utils.InsightType.WARNING, {
|
|
35
|
-
className: _budgetInfoModule["default"].warning,
|
|
36
|
-
glyph: _icon.Icon.ICONS.WARNING
|
|
37
|
-
}), _INSIGHT_TYPE_MAP);
|
|
38
|
-
|
|
39
|
-
var BudgetInfo = function BudgetInfo(_ref) {
|
|
40
|
-
var _ref$className = _ref.className,
|
|
41
|
-
className = _ref$className === void 0 ? '' : _ref$className,
|
|
42
|
-
budgetInsight = _ref.budgetInsight;
|
|
43
|
-
var _INSIGHT_TYPE_MAP$bud = INSIGHT_TYPE_MAP[budgetInsight.type],
|
|
44
|
-
insightTypeClassName = _INSIGHT_TYPE_MAP$bud.className,
|
|
45
|
-
glyph = _INSIGHT_TYPE_MAP$bud.glyph;
|
|
46
|
-
var rootClassName = (0, _classnames["default"])(_budgetInfoModule["default"].root, insightTypeClassName, className);
|
|
47
|
-
return /*#__PURE__*/_react["default"].createElement(_tooltip.Tooltip, {
|
|
48
|
-
className: rootClassName,
|
|
49
|
-
title: budgetInsight.message.text
|
|
50
|
-
}, /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
|
|
51
|
-
className: _budgetInfoModule["default"].icon,
|
|
52
|
-
glyph: glyph,
|
|
53
|
-
size: "medium"
|
|
54
|
-
}));
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
exports.BudgetInfo = BudgetInfo;
|
|
58
|
-
BudgetInfo.propTypes = {
|
|
59
|
-
budgetInsight: _propTypes["default"].shape({
|
|
60
|
-
type: _propTypes["default"].string,
|
|
61
|
-
message: _propTypes["default"].shape({
|
|
62
|
-
text: _propTypes["default"].string
|
|
63
|
-
}),
|
|
64
|
-
data: _propTypes["default"].shape({
|
|
65
|
-
currentValue: _propTypes["default"].number,
|
|
66
|
-
budgetValue: _propTypes["default"].number,
|
|
67
|
-
failed: _propTypes["default"].bool
|
|
68
|
-
})
|
|
69
|
-
}).isRequired,
|
|
70
|
-
className: _propTypes["default"].string
|
|
71
|
-
};
|
|
72
|
-
BudgetInfo.defaultProps = {
|
|
73
|
-
className: ''
|
|
74
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
display: inline-block;
|
|
3
|
-
line-height: 1em;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
/* Budget error */
|
|
7
|
-
.error .icon {
|
|
8
|
-
color: var(--color-danger);
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.error .icon:hover,
|
|
12
|
-
.error .icon:focus,
|
|
13
|
-
.error .icon:active
|
|
14
|
-
{
|
|
15
|
-
color: var(--color-danger-light);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/* Budget success */
|
|
19
|
-
.success .icon {
|
|
20
|
-
color: var(--color-success);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.success .icon:hover,
|
|
24
|
-
.success .icon:focus,
|
|
25
|
-
.success .icon:active
|
|
26
|
-
{
|
|
27
|
-
color: var(--color-success-light);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/* Budget warning */
|
|
31
|
-
.warning .icon {
|
|
32
|
-
color: var(--color-warning-dark);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.warning .icon:hover,
|
|
36
|
-
.warning .icon:focus,
|
|
37
|
-
.warning .icon:active
|
|
38
|
-
{
|
|
39
|
-
color: var(--color-warning);
|
|
40
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = _interopRequireDefault(require("react"));
|
|
4
|
-
|
|
5
|
-
var _react2 = require("@storybook/react");
|
|
6
|
-
|
|
7
|
-
var _stories = require("../../stories");
|
|
8
|
-
|
|
9
|
-
var _ = require(".");
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
-
|
|
13
|
-
var stories = (0, _react2.storiesOf)('Components/BudgetInfo', module);
|
|
14
|
-
stories.addDecorator((0, _stories.getWrapperDecorator)());
|
|
15
|
-
stories.add('default', function () {
|
|
16
|
-
return /*#__PURE__*/_react["default"].createElement(_.BudgetInfo, {
|
|
17
|
-
budgetInsight: {
|
|
18
|
-
type: 'SUCCESS',
|
|
19
|
-
message: {
|
|
20
|
-
text: 'Metric is under the budget'
|
|
21
|
-
},
|
|
22
|
-
data: {
|
|
23
|
-
budgetValue: 300,
|
|
24
|
-
currentValue: 250,
|
|
25
|
-
failed: false
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
stories.add('error', function () {
|
|
31
|
-
return /*#__PURE__*/_react["default"].createElement(_.BudgetInfo, {
|
|
32
|
-
budgetInsight: {
|
|
33
|
-
type: 'ERROR',
|
|
34
|
-
message: {
|
|
35
|
-
text: 'Metric is over the budget'
|
|
36
|
-
},
|
|
37
|
-
data: {
|
|
38
|
-
budgetValue: 300,
|
|
39
|
-
currentValue: 250,
|
|
40
|
-
failed: false
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
stories.add('warning', function () {
|
|
46
|
-
return /*#__PURE__*/_react["default"].createElement(_.BudgetInfo, {
|
|
47
|
-
budgetInsight: {
|
|
48
|
-
type: 'WARNING',
|
|
49
|
-
message: {
|
|
50
|
-
text: 'Metric is equal the budget'
|
|
51
|
-
},
|
|
52
|
-
data: {
|
|
53
|
-
budgetValue: 300,
|
|
54
|
-
currentValue: 250,
|
|
55
|
-
failed: false
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _budgetInfo = require("./budget-info");
|
|
8
|
-
|
|
9
|
-
Object.keys(_budgetInfo).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _budgetInfo[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _budgetInfo[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.BudgetInsights = void 0;
|
|
9
|
-
|
|
10
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
|
|
14
|
-
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
-
|
|
16
|
-
var _utils = require("@bundle-stats/utils");
|
|
17
|
-
|
|
18
|
-
var _box = require("../../layout/box");
|
|
19
|
-
|
|
20
|
-
var _stack = require("../../layout/stack");
|
|
21
|
-
|
|
22
|
-
var _flexStack = require("../../layout/flex-stack");
|
|
23
|
-
|
|
24
|
-
var _alert = require("../../ui/alert");
|
|
25
|
-
|
|
26
|
-
var _icon = require("../../ui/icon");
|
|
27
|
-
|
|
28
|
-
var _componentLink = require("../component-link");
|
|
29
|
-
|
|
30
|
-
var _budgetInsightsModule = _interopRequireDefault(require("./budget-insights.module.css"));
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
33
|
-
|
|
34
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
35
|
-
|
|
36
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
37
|
-
|
|
38
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
39
|
-
|
|
40
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
41
|
-
|
|
42
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
43
|
-
|
|
44
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
45
|
-
|
|
46
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
47
|
-
|
|
48
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
49
|
-
|
|
50
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
51
|
-
|
|
52
|
-
var Budget = function Budget(props) {
|
|
53
|
-
var className = props.className,
|
|
54
|
-
metricId = props.metricId,
|
|
55
|
-
budget = props.budget,
|
|
56
|
-
CustomLink = props.CustomLink;
|
|
57
|
-
|
|
58
|
-
var componentLinkOptions = _utils.METRIC_COMPONENT_LINKS.get(metricId);
|
|
59
|
-
|
|
60
|
-
return /*#__PURE__*/_react["default"].createElement(CustomLink, _extends({
|
|
61
|
-
className: (0, _classnames["default"])(_budgetInsightsModule["default"].budget, className, budget.type === 'SUCCESS' && _budgetInsightsModule["default"].budgetSuccess)
|
|
62
|
-
}, componentLinkOptions === null || componentLinkOptions === void 0 ? void 0 : componentLinkOptions.link), budget.message.text);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
Budget.propTypes = {
|
|
66
|
-
className: _propTypes["default"].string,
|
|
67
|
-
metricId: _propTypes["default"].string.isRequired,
|
|
68
|
-
budget: _propTypes["default"].shape({
|
|
69
|
-
type: _propTypes["default"].string,
|
|
70
|
-
message: _propTypes["default"].shape({
|
|
71
|
-
text: _propTypes["default"].string
|
|
72
|
-
}),
|
|
73
|
-
data: _propTypes["default"].shape({
|
|
74
|
-
currentValue: _propTypes["default"].number.isRequired,
|
|
75
|
-
budgetValue: _propTypes["default"].number.isRequired,
|
|
76
|
-
failed: _propTypes["default"].bool.isRequired
|
|
77
|
-
})
|
|
78
|
-
}).isRequired,
|
|
79
|
-
CustomLink: _propTypes["default"].elementType.isRequired
|
|
80
|
-
};
|
|
81
|
-
Budget.defaultProps = {
|
|
82
|
-
className: ''
|
|
83
|
-
};
|
|
84
|
-
var BUDGET_ALERT_KIND = new Map([['ERROR', 'danger'], ['WARNING', 'warning'], ['SUCCESS', 'success']]);
|
|
85
|
-
var BUDGET_ICON = new Map([['ERROR', _icon.Icon.ICONS.ALERT_CIRCLE], ['WARNING', _icon.Icon.ICONS.WARNING], ['SUCCESS', _icon.Icon.ICONS.CHECK_CIRCLE]]);
|
|
86
|
-
|
|
87
|
-
var BudgetInsights = function BudgetInsights(props) {
|
|
88
|
-
var className = props.className,
|
|
89
|
-
source = props.source,
|
|
90
|
-
budgets = props.budgets,
|
|
91
|
-
CustomLink = props.CustomLink;
|
|
92
|
-
|
|
93
|
-
var _useState = (0, _react.useState)(false),
|
|
94
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
95
|
-
showBudgets = _useState2[0],
|
|
96
|
-
setShowBudgets = _useState2[1];
|
|
97
|
-
|
|
98
|
-
var iconGlyph = BUDGET_ICON.get(budgets.type);
|
|
99
|
-
var alertKind = BUDGET_ALERT_KIND.get(budgets.type);
|
|
100
|
-
var rootClassName = (0, _classnames["default"])(_budgetInsightsModule["default"].group, className, _budgetInsightsModule["default"]["group-".concat(alertKind)]);
|
|
101
|
-
var budgetItems = (0, _react.useMemo)(function () {
|
|
102
|
-
var items = Object.entries(budgets.data); // When there are errors/warnings, sort budget items first
|
|
103
|
-
|
|
104
|
-
if (['ERROR', 'WARNING'].includes(budgets.type)) {
|
|
105
|
-
items.sort(function (a) {
|
|
106
|
-
return a[1].type === budgets.type ? -1 : 1;
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return items;
|
|
111
|
-
}, [budgets]);
|
|
112
|
-
return /*#__PURE__*/_react["default"].createElement(_alert.Alert, {
|
|
113
|
-
kind: alertKind,
|
|
114
|
-
padding: "none",
|
|
115
|
-
className: rootClassName
|
|
116
|
-
}, /*#__PURE__*/_react["default"].createElement(_box.Box, {
|
|
117
|
-
padding: ['xsmall', 'small'],
|
|
118
|
-
className: _budgetInsightsModule["default"].groupHeader,
|
|
119
|
-
as: "button",
|
|
120
|
-
type: "button",
|
|
121
|
-
onClick: function onClick() {
|
|
122
|
-
return setShowBudgets(!showBudgets);
|
|
123
|
-
}
|
|
124
|
-
}, /*#__PURE__*/_react["default"].createElement(_flexStack.FlexStack, {
|
|
125
|
-
space: "xxsmall",
|
|
126
|
-
className: _budgetInsightsModule["default"].groupTitle
|
|
127
|
-
}, iconGlyph && /*#__PURE__*/_react["default"].createElement(_icon.Icon, {
|
|
128
|
-
className: _budgetInsightsModule["default"].groupIcon,
|
|
129
|
-
glyph: iconGlyph
|
|
130
|
-
}), /*#__PURE__*/_react["default"].createElement("span", null, budgets.message.text), /*#__PURE__*/_react["default"].createElement("span", {
|
|
131
|
-
className: _budgetInsightsModule["default"].groupTitleToggle
|
|
132
|
-
}, showBudgets ? 'hide' : 'show', " all"))), showBudgets && /*#__PURE__*/_react["default"].createElement(_box.Box, {
|
|
133
|
-
padding: ['xsmall', 'small'],
|
|
134
|
-
className: _budgetInsightsModule["default"].groupContent
|
|
135
|
-
}, /*#__PURE__*/_react["default"].createElement(_stack.Stack, {
|
|
136
|
-
space: "none"
|
|
137
|
-
}, budgetItems.map(function (_ref) {
|
|
138
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
139
|
-
key = _ref2[0],
|
|
140
|
-
budget = _ref2[1];
|
|
141
|
-
|
|
142
|
-
return /*#__PURE__*/_react["default"].createElement(Budget, {
|
|
143
|
-
key: key,
|
|
144
|
-
metricId: "".concat(source, ".").concat(key),
|
|
145
|
-
budget: budget,
|
|
146
|
-
CustomLink: CustomLink
|
|
147
|
-
});
|
|
148
|
-
}))));
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
exports.BudgetInsights = BudgetInsights;
|
|
152
|
-
BudgetInsights.propTypes = {
|
|
153
|
-
className: _propTypes["default"].string,
|
|
154
|
-
source: _propTypes["default"].string.isRequired,
|
|
155
|
-
budgets: _propTypes["default"].object.isRequired,
|
|
156
|
-
// eslint-disable-line react/forbid-prop-types
|
|
157
|
-
CustomLink: _propTypes["default"].elementType
|
|
158
|
-
};
|
|
159
|
-
BudgetInsights.defaultProps = {
|
|
160
|
-
className: '',
|
|
161
|
-
CustomLink: _componentLink.ComponentLink
|
|
162
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
.groupHeader {
|
|
2
|
-
width: 100%;
|
|
3
|
-
border: none;
|
|
4
|
-
background: none;
|
|
5
|
-
cursor: pointer;
|
|
6
|
-
color: inherit;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.groupTitle {
|
|
10
|
-
width: 100%;
|
|
11
|
-
align-items: center;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.groupTitle:hover {
|
|
15
|
-
color: var(--color-text-dark);
|
|
16
|
-
text-decoration: underline;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.groupTitleToggle {
|
|
20
|
-
margin: 0 0 0 auto !important;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.group-danger .groupIcon {
|
|
24
|
-
color: var(--color-danger);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.group-warning .groupIcon {
|
|
28
|
-
color: var(--color-warning);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.group-success .groupIcon {
|
|
32
|
-
color: var(--color-success);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
.groupContent {
|
|
36
|
-
padding-top: 0px;
|
|
37
|
-
background: transparent;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.budget {
|
|
41
|
-
display: block;
|
|
42
|
-
color: var(--color-text);
|
|
43
|
-
text-decoration: none;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.budgetSuccess {
|
|
47
|
-
color: var(--color-text-light);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
.budgetLabel,
|
|
51
|
-
.budgetValue {
|
|
52
|
-
color: var(--color-text-dark);
|
|
53
|
-
font-weight: 500;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.budget:hover,
|
|
57
|
-
.budget:focus,
|
|
58
|
-
.budget:active {
|
|
59
|
-
color: var(--color-text);
|
|
60
|
-
text-decoration: underline;
|
|
61
|
-
}
|