@bundle-stats/ui 4.16.0 → 4.17.0-beta.0
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/components/asset-info/asset-info.js +4 -4
- package/lib/components/asset-info/asset-info.js.map +1 -1
- package/lib/components/asset-meta-tag/asset-meta-tag.js +17 -0
- package/lib/components/asset-meta-tag/asset-meta-tag.js.map +1 -0
- package/lib/components/asset-meta-tag/asset-meta-tag.module.css +55 -0
- package/lib/components/asset-meta-tag/index.js +18 -0
- package/lib/components/asset-meta-tag/index.js.map +1 -0
- package/lib/components/asset-name/asset-name.js +32 -0
- package/lib/components/asset-name/asset-name.js.map +1 -0
- package/lib/components/asset-name/asset-name.module.css +32 -0
- package/lib/components/asset-name/index.js +18 -0
- package/lib/components/asset-name/index.js.map +1 -0
- package/lib/components/asset-not-predictive/asset-not-predictive.js +4 -2
- package/lib/components/asset-not-predictive/asset-not-predictive.js.map +1 -1
- package/lib/components/bundle-assets/bundle-assets.js +3 -38
- package/lib/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib/components/bundle-assets/bundle-assets.module.css +0 -64
- package/lib/components/bundle-assets/bundle-assets.utils.js +56 -28
- package/lib/components/bundle-assets/bundle-assets.utils.js.map +1 -1
- package/lib/components/bundle-assets/index.js +1 -1
- package/lib/components/bundle-assets/index.js.map +1 -1
- package/lib/components/entry-info/entry-info.js +1 -1
- package/lib/components/entry-info/entry-info.js.map +1 -1
- package/lib/components/metrics-treemap/metrics-treemap.utils.js +0 -1
- package/lib/components/metrics-treemap/metrics-treemap.utils.js.map +1 -1
- package/lib/stories/wrapper.js +5 -2
- package/lib/stories/wrapper.js.map +1 -1
- package/lib/ui/tag/tag.js.map +1 -1
- package/lib-esm/components/asset-info/asset-info.js +4 -4
- package/lib-esm/components/asset-info/asset-info.js.map +1 -1
- package/lib-esm/components/asset-meta-tag/asset-meta-tag.js +10 -0
- package/lib-esm/components/asset-meta-tag/asset-meta-tag.js.map +1 -0
- package/lib-esm/components/asset-meta-tag/asset-meta-tag.module.css +55 -0
- package/lib-esm/components/asset-meta-tag/index.js +2 -0
- package/lib-esm/components/asset-meta-tag/index.js.map +1 -0
- package/lib-esm/components/asset-name/asset-name.js +25 -0
- package/lib-esm/components/asset-name/asset-name.js.map +1 -0
- package/lib-esm/components/asset-name/asset-name.module.css +32 -0
- package/lib-esm/components/asset-name/index.js +2 -0
- package/lib-esm/components/asset-name/index.js.map +1 -0
- package/lib-esm/components/asset-not-predictive/asset-not-predictive.js +4 -2
- package/lib-esm/components/asset-not-predictive/asset-not-predictive.js.map +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.js +3 -38
- package/lib-esm/components/bundle-assets/bundle-assets.js.map +1 -1
- package/lib-esm/components/bundle-assets/bundle-assets.module.css +0 -64
- package/lib-esm/components/bundle-assets/bundle-assets.utils.js +52 -24
- package/lib-esm/components/bundle-assets/bundle-assets.utils.js.map +1 -1
- package/lib-esm/components/bundle-assets/index.js +2 -2
- package/lib-esm/components/bundle-assets/index.js.map +1 -1
- package/lib-esm/components/entry-info/entry-info.js +1 -1
- package/lib-esm/components/entry-info/entry-info.js.map +1 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.utils.js +0 -1
- package/lib-esm/components/metrics-treemap/metrics-treemap.utils.js.map +1 -1
- package/lib-esm/stories/wrapper.js +5 -2
- package/lib-esm/stories/wrapper.js.map +1 -1
- package/lib-esm/ui/tag/tag.js.map +1 -1
- package/package.json +11 -11
- package/src/app/app-gladys.stories.tsx +41 -0
- package/src/app/app-home-assistant.stories.tsx +41 -0
- package/src/app/app-outline.stories.tsx +41 -0
- package/src/app/app.stories.tsx +127 -0
- package/src/components/asset-info/asset-info.tsx +14 -7
- package/src/components/asset-meta-tag/asset-meta-tag.module.css +55 -0
- package/src/components/asset-meta-tag/asset-meta-tag.tsx +34 -0
- package/src/components/asset-meta-tag/index.ts +1 -0
- package/src/components/asset-name/asset-name.module.css +32 -0
- package/src/components/asset-name/asset-name.stories.tsx +85 -0
- package/src/components/asset-name/asset-name.tsx +60 -0
- package/src/components/asset-name/index.ts +1 -0
- package/src/components/asset-not-predictive/asset-not-predictive.tsx +10 -8
- package/src/components/bundle-assets/__tests__/add-metric-report-asset-row-data.ts +181 -0
- package/src/components/bundle-assets/__tests__/get-asset-meta-status.ts +21 -0
- package/src/components/bundle-assets/__tests__/get-is-not-predictive.ts +119 -0
- package/src/components/bundle-assets/bundle-assets.jsx +15 -84
- package/src/components/bundle-assets/bundle-assets.module.css +0 -64
- package/src/components/bundle-assets/bundle-assets.utils.js +87 -26
- package/src/components/bundle-assets/index.jsx +2 -7
- package/src/components/entry-info/entry-info.tsx +1 -6
- package/src/components/metrics-treemap/metrics-treemap.utils.ts +0 -1
- package/src/stories/wrapper.jsx +21 -15
- package/src/types.d.ts +30 -1
- package/src/ui/tag/tag.tsx +4 -3
- package/types/components/asset-meta-tag/asset-meta-tag.d.ts +8 -0
- package/types/components/asset-meta-tag/index.d.ts +1 -0
- package/types/components/asset-name/asset-name.d.ts +8 -0
- package/types/components/asset-name/index.d.ts +1 -0
- package/types/components/asset-not-predictive/asset-not-predictive.d.ts +4 -4
- package/types/components/bundle-assets/bundle-assets.utils.d.ts +3 -3
- package/types/stories/wrapper.d.ts +1 -1
- package/types/ui/tag/tag.d.ts +4 -4
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.root {}
|
|
2
|
+
|
|
3
|
+
.notPredictive {
|
|
4
|
+
margin-right: var(--space-xxsmall);
|
|
5
|
+
display: inline-block;
|
|
6
|
+
width: var(--space-small);
|
|
7
|
+
height: var(--space-small);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.notPredictiveAnchor {}
|
|
11
|
+
|
|
12
|
+
.notPredictiveIcon {
|
|
13
|
+
color: var(--color-warning-dark);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.metaTags {
|
|
17
|
+
display: inline;
|
|
18
|
+
margin-right: var(--space-xxxsmall);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.metaTag + .metaTag {
|
|
22
|
+
margin-left: calc(var(--space-xxxsmall) / 2);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.metaTags:empty {
|
|
26
|
+
display: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.nameText {
|
|
30
|
+
display: inline-block;
|
|
31
|
+
vertical-align: middle;
|
|
32
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
|
|
3
|
+
import { AssetName } from '.';
|
|
4
|
+
|
|
5
|
+
const ROW = {
|
|
6
|
+
key: 'asset/main.js',
|
|
7
|
+
label: 'asset/main.js',
|
|
8
|
+
changed: true,
|
|
9
|
+
isEntry: false,
|
|
10
|
+
isChunk: false,
|
|
11
|
+
isInitial: false,
|
|
12
|
+
isAsset: true,
|
|
13
|
+
isNotPredictive: false,
|
|
14
|
+
fileType: 'JS',
|
|
15
|
+
biggerIsBetter: false,
|
|
16
|
+
runs: [
|
|
17
|
+
{ name: 'asset/main.abcd1234.js', value: 1024 * 10 },
|
|
18
|
+
{ name: 'asset/main.abcd1234.js', value: 1024 * 11 },
|
|
19
|
+
],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const meta = {
|
|
23
|
+
title: 'Components/AssetName',
|
|
24
|
+
component: AssetName,
|
|
25
|
+
args: {
|
|
26
|
+
customComponentLink: 'span',
|
|
27
|
+
filters: {},
|
|
28
|
+
search: '',
|
|
29
|
+
},
|
|
30
|
+
} as Meta<typeof AssetName>;
|
|
31
|
+
|
|
32
|
+
export default meta;
|
|
33
|
+
|
|
34
|
+
type Story = StoryObj<typeof meta>;
|
|
35
|
+
|
|
36
|
+
export const Default: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
row: ROW,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const MetaDefault: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
row: {
|
|
45
|
+
...ROW,
|
|
46
|
+
isEntry: true,
|
|
47
|
+
isChunk: true,
|
|
48
|
+
isInitial: true,
|
|
49
|
+
isAsset: false,
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const MetaAdded: Story = {
|
|
55
|
+
args: {
|
|
56
|
+
row: {
|
|
57
|
+
...ROW,
|
|
58
|
+
isEntry: 'added',
|
|
59
|
+
isChunk: 'added',
|
|
60
|
+
isInitial: 'added',
|
|
61
|
+
isAsset: false,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const MetaRemoved: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
row: {
|
|
69
|
+
...ROW,
|
|
70
|
+
isEntry: 'removed',
|
|
71
|
+
isChunk: 'removed',
|
|
72
|
+
isInitial: 'removed',
|
|
73
|
+
isAsset: false,
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const NotPredictive: Story = {
|
|
79
|
+
args: {
|
|
80
|
+
row: {
|
|
81
|
+
...ROW,
|
|
82
|
+
isNotPredictive: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React, { ElementType } from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { Icon } from '../../ui/icon';
|
|
5
|
+
import { FileName } from '../../ui/file-name';
|
|
6
|
+
import { HoverCard } from '../../ui/hover-card';
|
|
7
|
+
import { AssetNotPredictive } from '../asset-not-predictive';
|
|
8
|
+
|
|
9
|
+
import { ReportMetricAssetRow } from '../../types';
|
|
10
|
+
import { AssetMetaTag } from '../asset-meta-tag';
|
|
11
|
+
import css from './asset-name.module.css';
|
|
12
|
+
|
|
13
|
+
const RUN_TITLE_CURRENT = 'Current';
|
|
14
|
+
const RUN_TITLE_BASELINE = 'Baseline';
|
|
15
|
+
const RUNS_LABELS = [RUN_TITLE_CURRENT, RUN_TITLE_BASELINE];
|
|
16
|
+
|
|
17
|
+
export type AssetNameProps = {
|
|
18
|
+
className?: string;
|
|
19
|
+
row: ReportMetricAssetRow;
|
|
20
|
+
customComponentLink: ElementType;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const AssetName = (props: AssetNameProps) => {
|
|
24
|
+
const { className = '', customComponentLink: CustomComponentLink, row } = props;
|
|
25
|
+
const { label, isNotPredictive, runs, isChunk, isEntry, isInitial } = row;
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<span className={cx(css.root, className)}>
|
|
29
|
+
{isNotPredictive && (
|
|
30
|
+
<HoverCard
|
|
31
|
+
label={<Icon className={css.notPredictiveIcon} glyph={Icon.ICONS.WARNING} />}
|
|
32
|
+
className={css.notPredictive}
|
|
33
|
+
anchorClassName={css.notPredictiveAnchor}
|
|
34
|
+
>
|
|
35
|
+
<AssetNotPredictive runs={runs} labels={RUNS_LABELS} />
|
|
36
|
+
</HoverCard>
|
|
37
|
+
)}
|
|
38
|
+
|
|
39
|
+
<CustomComponentLink entryId={row.key} className={css.name}>
|
|
40
|
+
<span className={css.metaTags}>
|
|
41
|
+
{isEntry && (
|
|
42
|
+
<AssetMetaTag className={css.metaTag} title="Entrypoint" tag="entry" status={isEntry} />
|
|
43
|
+
)}
|
|
44
|
+
{isInitial && (
|
|
45
|
+
<AssetMetaTag
|
|
46
|
+
className={css.metaTag}
|
|
47
|
+
title="Initial"
|
|
48
|
+
tag="initial"
|
|
49
|
+
status={isInitial}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
{isChunk && (
|
|
53
|
+
<AssetMetaTag className={css.metaTag} title="Chunk" tag="chunk" status={isChunk} />
|
|
54
|
+
)}
|
|
55
|
+
</span>
|
|
56
|
+
<FileName className={css.nameText} name={label} />
|
|
57
|
+
</CustomComponentLink>
|
|
58
|
+
</span>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './asset-name';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import cx from 'classnames';
|
|
3
4
|
import type { Asset } from '@bundle-stats/utils/types/webpack';
|
|
@@ -6,19 +7,20 @@ import { Stack } from '../../layout/stack';
|
|
|
6
7
|
import { Table } from '../../ui/table';
|
|
7
8
|
import css from './asset-not-predictive.module.css';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
export type AssetNotPredictiveProps = {
|
|
10
11
|
runs?: Array<Asset>;
|
|
11
|
-
labels?: Array<string
|
|
12
|
-
}
|
|
12
|
+
labels?: Array<string>;
|
|
13
|
+
} & ComponentProps<'div'>;
|
|
13
14
|
|
|
14
|
-
export const AssetNotPredictive = (props: AssetNotPredictiveProps
|
|
15
|
+
export const AssetNotPredictive = (props: AssetNotPredictiveProps) => {
|
|
15
16
|
const { className = '', runs = null, labels = null, ...restProps } = props;
|
|
16
17
|
|
|
17
18
|
return (
|
|
18
|
-
<Stack space="
|
|
19
|
-
<
|
|
20
|
-
Asset
|
|
21
|
-
|
|
19
|
+
<Stack space="small" {...restProps} className={cx(css.root, className)}>
|
|
20
|
+
<Stack space="xxxsmall">
|
|
21
|
+
<h3>Asset hash is not predictive</h3>
|
|
22
|
+
<p className={css.text}>File names are equal, but the size is different.</p>
|
|
23
|
+
</Stack>
|
|
22
24
|
{runs && (
|
|
23
25
|
<Table outline compact>
|
|
24
26
|
<Table.THead>
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { addMetricReportAssetRowData } from '../bundle-assets.utils';
|
|
2
|
+
|
|
3
|
+
describe('BundleAssets / addMetricReportAssetRowData', () => {
|
|
4
|
+
test('should add data to a single run', () => {
|
|
5
|
+
expect(
|
|
6
|
+
addMetricReportAssetRowData({
|
|
7
|
+
key: 'assets/main.js',
|
|
8
|
+
label: 'assets/main.js',
|
|
9
|
+
biggerIsBetter: false,
|
|
10
|
+
changed: false,
|
|
11
|
+
runs: [
|
|
12
|
+
{
|
|
13
|
+
name: 'assets/main.abc123.js',
|
|
14
|
+
value: 1024 * 10,
|
|
15
|
+
isEntry: true,
|
|
16
|
+
isChunk: true,
|
|
17
|
+
isInitial: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
}),
|
|
21
|
+
).toEqual({
|
|
22
|
+
key: 'assets/main.js',
|
|
23
|
+
label: 'assets/main.js',
|
|
24
|
+
biggerIsBetter: false,
|
|
25
|
+
changed: false,
|
|
26
|
+
fileType: 'JS',
|
|
27
|
+
isAsset: false,
|
|
28
|
+
isChunk: true,
|
|
29
|
+
isEntry: true,
|
|
30
|
+
isInitial: true,
|
|
31
|
+
isNotPredictive: false,
|
|
32
|
+
runs: [
|
|
33
|
+
{
|
|
34
|
+
name: 'assets/main.abc123.js',
|
|
35
|
+
value: 1024 * 10,
|
|
36
|
+
isEntry: true,
|
|
37
|
+
isChunk: true,
|
|
38
|
+
isInitial: true,
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test('should add add data when baseline run is null', () => {
|
|
45
|
+
expect(
|
|
46
|
+
addMetricReportAssetRowData({
|
|
47
|
+
key: 'assets/main.js',
|
|
48
|
+
label: 'assets/main.js',
|
|
49
|
+
biggerIsBetter: false,
|
|
50
|
+
changed: false,
|
|
51
|
+
runs: [
|
|
52
|
+
{
|
|
53
|
+
name: 'assets/main.abc123.js',
|
|
54
|
+
value: 1024 * 10,
|
|
55
|
+
isEntry: true,
|
|
56
|
+
isChunk: true,
|
|
57
|
+
isInitial: true,
|
|
58
|
+
},
|
|
59
|
+
null,
|
|
60
|
+
],
|
|
61
|
+
}),
|
|
62
|
+
).toEqual({
|
|
63
|
+
key: 'assets/main.js',
|
|
64
|
+
label: 'assets/main.js',
|
|
65
|
+
biggerIsBetter: false,
|
|
66
|
+
changed: false,
|
|
67
|
+
fileType: 'JS',
|
|
68
|
+
isAsset: false,
|
|
69
|
+
isChunk: true,
|
|
70
|
+
isEntry: true,
|
|
71
|
+
isInitial: true,
|
|
72
|
+
isNotPredictive: false,
|
|
73
|
+
runs: [
|
|
74
|
+
{
|
|
75
|
+
name: 'assets/main.abc123.js',
|
|
76
|
+
value: 1024 * 10,
|
|
77
|
+
isEntry: true,
|
|
78
|
+
isChunk: true,
|
|
79
|
+
isInitial: true,
|
|
80
|
+
},
|
|
81
|
+
null,
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('should add add data when curent run is null', () => {
|
|
87
|
+
expect(
|
|
88
|
+
addMetricReportAssetRowData({
|
|
89
|
+
key: 'assets/main.js',
|
|
90
|
+
label: 'assets/main.js',
|
|
91
|
+
biggerIsBetter: false,
|
|
92
|
+
changed: true,
|
|
93
|
+
runs: [
|
|
94
|
+
null,
|
|
95
|
+
{
|
|
96
|
+
name: 'assets/main.abc123.js',
|
|
97
|
+
value: 1024 * 10,
|
|
98
|
+
isEntry: true,
|
|
99
|
+
isChunk: true,
|
|
100
|
+
isInitial: true,
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
}),
|
|
104
|
+
).toEqual({
|
|
105
|
+
key: 'assets/main.js',
|
|
106
|
+
label: 'assets/main.js',
|
|
107
|
+
biggerIsBetter: false,
|
|
108
|
+
changed: true,
|
|
109
|
+
fileType: 'JS',
|
|
110
|
+
isAsset: false,
|
|
111
|
+
isChunk: true,
|
|
112
|
+
isEntry: true,
|
|
113
|
+
isInitial: true,
|
|
114
|
+
isNotPredictive: false,
|
|
115
|
+
runs: [
|
|
116
|
+
null,
|
|
117
|
+
{
|
|
118
|
+
name: 'assets/main.abc123.js',
|
|
119
|
+
value: 1024 * 10,
|
|
120
|
+
isEntry: true,
|
|
121
|
+
isChunk: true,
|
|
122
|
+
isInitial: true,
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('should add data when baseline is not null', () => {
|
|
129
|
+
expect(
|
|
130
|
+
addMetricReportAssetRowData({
|
|
131
|
+
key: 'assets/main.js',
|
|
132
|
+
label: 'assets/main.js',
|
|
133
|
+
biggerIsBetter: false,
|
|
134
|
+
changed: false,
|
|
135
|
+
runs: [
|
|
136
|
+
{
|
|
137
|
+
name: 'assets/main.abc123.js',
|
|
138
|
+
value: 1024 * 10,
|
|
139
|
+
isEntry: true,
|
|
140
|
+
isChunk: true,
|
|
141
|
+
isInitial: true,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: 'assets/main.abc123.js',
|
|
145
|
+
value: 1024 * 10,
|
|
146
|
+
isEntry: true,
|
|
147
|
+
isChunk: true,
|
|
148
|
+
isInitial: true,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
}),
|
|
152
|
+
).toEqual({
|
|
153
|
+
key: 'assets/main.js',
|
|
154
|
+
label: 'assets/main.js',
|
|
155
|
+
biggerIsBetter: false,
|
|
156
|
+
changed: false,
|
|
157
|
+
fileType: 'JS',
|
|
158
|
+
isAsset: false,
|
|
159
|
+
isChunk: true,
|
|
160
|
+
isEntry: true,
|
|
161
|
+
isInitial: true,
|
|
162
|
+
isNotPredictive: false,
|
|
163
|
+
runs: [
|
|
164
|
+
{
|
|
165
|
+
name: 'assets/main.abc123.js',
|
|
166
|
+
value: 1024 * 10,
|
|
167
|
+
isEntry: true,
|
|
168
|
+
isChunk: true,
|
|
169
|
+
isInitial: true,
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
name: 'assets/main.abc123.js',
|
|
173
|
+
value: 1024 * 10,
|
|
174
|
+
isEntry: true,
|
|
175
|
+
isChunk: true,
|
|
176
|
+
isInitial: true,
|
|
177
|
+
},
|
|
178
|
+
],
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getAssetMetaStatus } from '../bundle-assets.utils';
|
|
2
|
+
|
|
3
|
+
describe('BundleAssets / getAssetMetaStatus', () => {
|
|
4
|
+
test('should return true when all runs meta values are truthy', () => {
|
|
5
|
+
expect(getAssetMetaStatus([true])).toBeTruthy();
|
|
6
|
+
expect(getAssetMetaStatus([true, true])).toBeTruthy();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('should return false when all runs meta values are falsy', () => {
|
|
10
|
+
expect(getAssetMetaStatus([false])).toBeFalsy();
|
|
11
|
+
expect(getAssetMetaStatus([false, false])).toBeFalsy();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('should return "added" when current is truthy and baseline is falsy', () => {
|
|
15
|
+
expect(getAssetMetaStatus([true, false])).toEqual('added');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('should return "removed" when current is false and baseline is truthy', () => {
|
|
19
|
+
expect(getAssetMetaStatus([false, true])).toEqual('removed');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { getIsNotPredictive } from '../bundle-assets.utils';
|
|
2
|
+
|
|
3
|
+
describe('BundleAssets / getIsNotPredictive', () => {
|
|
4
|
+
test('should return false by default', () => {
|
|
5
|
+
expect(
|
|
6
|
+
getIsNotPredictive({
|
|
7
|
+
key: 'assets/main.js',
|
|
8
|
+
label: 'assets/main.js',
|
|
9
|
+
biggerIsBetter: false,
|
|
10
|
+
changed: false,
|
|
11
|
+
runs: [
|
|
12
|
+
{
|
|
13
|
+
name: 'assets/main.abc123.js',
|
|
14
|
+
value: 1024 * 10,
|
|
15
|
+
isEntry: true,
|
|
16
|
+
isChunk: true,
|
|
17
|
+
isInitial: true,
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
}),
|
|
21
|
+
).toBeFalsy();
|
|
22
|
+
|
|
23
|
+
expect(
|
|
24
|
+
getIsNotPredictive({
|
|
25
|
+
key: 'assets/main.js',
|
|
26
|
+
label: 'assets/main.js',
|
|
27
|
+
biggerIsBetter: false,
|
|
28
|
+
changed: false,
|
|
29
|
+
runs: [
|
|
30
|
+
{
|
|
31
|
+
name: 'assets/main.abc123.js',
|
|
32
|
+
value: 1024 * 10,
|
|
33
|
+
isEntry: true,
|
|
34
|
+
isChunk: true,
|
|
35
|
+
isInitial: true,
|
|
36
|
+
},
|
|
37
|
+
null,
|
|
38
|
+
],
|
|
39
|
+
}),
|
|
40
|
+
).toBeFalsy();
|
|
41
|
+
|
|
42
|
+
expect(
|
|
43
|
+
getIsNotPredictive({
|
|
44
|
+
key: 'assets/main.js',
|
|
45
|
+
label: 'assets/main.js',
|
|
46
|
+
biggerIsBetter: false,
|
|
47
|
+
changed: false,
|
|
48
|
+
runs: [
|
|
49
|
+
{
|
|
50
|
+
name: 'assets/main.abc123.js',
|
|
51
|
+
value: 1024 * 10,
|
|
52
|
+
isEntry: true,
|
|
53
|
+
isChunk: true,
|
|
54
|
+
isInitial: true,
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'assets/main.abc123.js',
|
|
58
|
+
value: 1024 * 10,
|
|
59
|
+
isEntry: true,
|
|
60
|
+
isChunk: true,
|
|
61
|
+
isInitial: true,
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
}),
|
|
65
|
+
).toBeFalsy();
|
|
66
|
+
|
|
67
|
+
expect(
|
|
68
|
+
getIsNotPredictive({
|
|
69
|
+
key: 'assets/main.js',
|
|
70
|
+
label: 'assets/main.js',
|
|
71
|
+
biggerIsBetter: false,
|
|
72
|
+
changed: false,
|
|
73
|
+
runs: [
|
|
74
|
+
{
|
|
75
|
+
name: 'assets/main.def456.js',
|
|
76
|
+
value: 1024 * 10,
|
|
77
|
+
isEntry: true,
|
|
78
|
+
isChunk: true,
|
|
79
|
+
isInitial: true,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'assets/main.abc123.js',
|
|
83
|
+
value: 1024 * 11,
|
|
84
|
+
isEntry: true,
|
|
85
|
+
isChunk: true,
|
|
86
|
+
isInitial: true,
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
}),
|
|
90
|
+
).toBeFalsy();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test('should return true when not predictive', () => {
|
|
94
|
+
expect(
|
|
95
|
+
getIsNotPredictive({
|
|
96
|
+
key: 'assets/main.js',
|
|
97
|
+
label: 'assets/main.js',
|
|
98
|
+
biggerIsBetter: false,
|
|
99
|
+
changed: false,
|
|
100
|
+
runs: [
|
|
101
|
+
{
|
|
102
|
+
name: 'assets/main.abc123.js',
|
|
103
|
+
value: 1024 * 10,
|
|
104
|
+
isEntry: true,
|
|
105
|
+
isChunk: true,
|
|
106
|
+
isInitial: true,
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
name: 'assets/main.abc123.js',
|
|
110
|
+
value: 1024 * 11,
|
|
111
|
+
isEntry: true,
|
|
112
|
+
isChunk: true,
|
|
113
|
+
isInitial: true,
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
}),
|
|
117
|
+
).toBeTruthy();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
@@ -20,17 +20,12 @@ import { Box } from '../../layout/box';
|
|
|
20
20
|
import { FlexStack } from '../../layout/flex-stack';
|
|
21
21
|
import { Stack } from '../../layout/stack';
|
|
22
22
|
import { Dialog, useDialogState } from '../../ui/dialog';
|
|
23
|
-
import { Icon } from '../../ui/icon';
|
|
24
23
|
import { InputSearch } from '../../ui/input-search';
|
|
25
|
-
import { FileName } from '../../ui/file-name';
|
|
26
|
-
import { HoverCard } from '../../ui/hover-card';
|
|
27
|
-
import { Tag } from '../../ui/tag';
|
|
28
24
|
import { Table } from '../../ui/table';
|
|
29
25
|
import { Filters } from '../../ui/filters';
|
|
30
26
|
import { EmptySet } from '../../ui/empty-set';
|
|
31
27
|
import { Toolbar } from '../../ui/toolbar';
|
|
32
28
|
import { AssetInfo } from '../asset-info';
|
|
33
|
-
import { AssetNotPredictive } from '../asset-not-predictive';
|
|
34
29
|
import { ComponentLink } from '../component-link';
|
|
35
30
|
import { MetricsTable } from '../metrics-table';
|
|
36
31
|
import { MetricsTableExport } from '../metrics-table-export';
|
|
@@ -41,10 +36,7 @@ import { MetricsTableHeader } from '../metrics-table-header';
|
|
|
41
36
|
import { MetricsTreemap, getTreemapNodes, getTreemapNodesGroupedByPath } from '../metrics-treemap';
|
|
42
37
|
import { SEARCH_PLACEHOLDER } from './bundle-assets.i18n';
|
|
43
38
|
import css from './bundle-assets.module.css';
|
|
44
|
-
|
|
45
|
-
const RUN_TITLE_CURRENT = 'Current';
|
|
46
|
-
const RUN_TITLE_BASELINE = 'Baseline';
|
|
47
|
-
const RUNS_LABELS = [RUN_TITLE_CURRENT, RUN_TITLE_BASELINE];
|
|
39
|
+
import { AssetName } from '../asset-name';
|
|
48
40
|
|
|
49
41
|
const DISPLAY_TYPE_GROUPS = {
|
|
50
42
|
[MetricsDisplayType.TREEMAP]: ['folder'],
|
|
@@ -94,77 +86,6 @@ const getFilters = ({ compareMode, filters }) => ({
|
|
|
94
86
|
},
|
|
95
87
|
});
|
|
96
88
|
|
|
97
|
-
const RowHeader = ({ row, customComponentLink: CustomComponentLink, filters, search }) => {
|
|
98
|
-
const { label, isNotPredictive, runs, isChunk, isEntry, isInitial } = row;
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<span className={css.assetNameWrapper}>
|
|
102
|
-
{isNotPredictive && (
|
|
103
|
-
<HoverCard
|
|
104
|
-
label={<Icon className={css.notPredictiveIcon} glyph={Icon.ICONS.WARNING} />}
|
|
105
|
-
className={css.notPredictive}
|
|
106
|
-
anchorClassName={css.notPredictiveAnchor}
|
|
107
|
-
>
|
|
108
|
-
<AssetNotPredictive runs={runs} labels={RUNS_LABELS} />
|
|
109
|
-
</HoverCard>
|
|
110
|
-
)}
|
|
111
|
-
|
|
112
|
-
<CustomComponentLink
|
|
113
|
-
section={SECTIONS.ASSETS}
|
|
114
|
-
params={{ [COMPONENT.BUNDLE_ASSETS]: { filters, search, entryId: row.key } }}
|
|
115
|
-
className={css.assetName}
|
|
116
|
-
>
|
|
117
|
-
<span className={css.assetNameTags}>
|
|
118
|
-
{isEntry && (
|
|
119
|
-
<Tag
|
|
120
|
-
className={cx(css.assetNameTag, css.assetNameTagEntry)}
|
|
121
|
-
title="Entrypoint"
|
|
122
|
-
size={Tag.SIZES.SMALL}
|
|
123
|
-
kind={Tag.KINDS.INFO}
|
|
124
|
-
/>
|
|
125
|
-
)}
|
|
126
|
-
{isInitial && (
|
|
127
|
-
<Tag
|
|
128
|
-
className={cx(css.assetNameTag, css.assetNameTagInitial)}
|
|
129
|
-
title="Initial"
|
|
130
|
-
size={Tag.SIZES.SMALL}
|
|
131
|
-
kind={Tag.KINDS.INFO}
|
|
132
|
-
/>
|
|
133
|
-
)}
|
|
134
|
-
{isChunk && (
|
|
135
|
-
<Tag
|
|
136
|
-
className={cx(css.assetNameTag, css.assetNameTagChunk)}
|
|
137
|
-
title="Chunk"
|
|
138
|
-
size={Tag.SIZES.SMALL}
|
|
139
|
-
kind={Tag.KINDS.INFO}
|
|
140
|
-
/>
|
|
141
|
-
)}
|
|
142
|
-
</span>
|
|
143
|
-
<FileName className={css.assetNameText} name={label} />
|
|
144
|
-
</CustomComponentLink>
|
|
145
|
-
</span>
|
|
146
|
-
);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
RowHeader.propTypes = {
|
|
150
|
-
row: PropTypes.shape({
|
|
151
|
-
key: PropTypes.string,
|
|
152
|
-
label: PropTypes.string,
|
|
153
|
-
isNotPredictive: PropTypes.bool,
|
|
154
|
-
isChunk: PropTypes.bool,
|
|
155
|
-
isInitial: PropTypes.bool,
|
|
156
|
-
isEntry: PropTypes.bool,
|
|
157
|
-
runs: PropTypes.arrayOf(PropTypes.object), // eslint-disable-line react/forbid-prop-types
|
|
158
|
-
}).isRequired,
|
|
159
|
-
customComponentLink: PropTypes.elementType.isRequired,
|
|
160
|
-
filters: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
|
|
161
|
-
search: PropTypes.string,
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
RowHeader.defaultProps = {
|
|
165
|
-
search: '',
|
|
166
|
-
};
|
|
167
|
-
|
|
168
89
|
const ViewMetricsTreemap = (props) => {
|
|
169
90
|
const {
|
|
170
91
|
metricsTableTitle,
|
|
@@ -283,13 +204,23 @@ export const BundleAssets = (props) => {
|
|
|
283
204
|
[items, totalRowCount],
|
|
284
205
|
);
|
|
285
206
|
|
|
207
|
+
const assetNameCustomComponentLink = useCallback(
|
|
208
|
+
({ entryId: assetEntryId, ...assetNameRestProps }) => (
|
|
209
|
+
<CustomComponentLink
|
|
210
|
+
section={SECTIONS.ASSETS}
|
|
211
|
+
params={{ [COMPONENT.BUNDLE_ASSETS]: { filters, search, entryId: assetEntryId } }}
|
|
212
|
+
{...assetNameRestProps}
|
|
213
|
+
/>
|
|
214
|
+
),
|
|
215
|
+
[CustomComponentLink, filters, search],
|
|
216
|
+
);
|
|
217
|
+
|
|
286
218
|
const renderRowHeader = useCallback(
|
|
287
219
|
(row) => (
|
|
288
|
-
<
|
|
220
|
+
<AssetName
|
|
289
221
|
row={row}
|
|
290
|
-
customComponentLink={
|
|
291
|
-
|
|
292
|
-
search={search}
|
|
222
|
+
customComponentLink={assetNameCustomComponentLink}
|
|
223
|
+
className={css.assetName}
|
|
293
224
|
/>
|
|
294
225
|
),
|
|
295
226
|
[CustomComponentLink, filters, search],
|