@bundle-stats/ui 4.16.0-beta.9 → 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.
Files changed (150) hide show
  1. package/lib/components/asset-info/asset-info.js +4 -4
  2. package/lib/components/asset-info/asset-info.js.map +1 -1
  3. package/lib/components/asset-meta-tag/asset-meta-tag.js +17 -0
  4. package/lib/components/asset-meta-tag/asset-meta-tag.js.map +1 -0
  5. package/lib/components/asset-meta-tag/asset-meta-tag.module.css +55 -0
  6. package/lib/components/asset-meta-tag/index.js +18 -0
  7. package/lib/components/asset-meta-tag/index.js.map +1 -0
  8. package/lib/components/asset-name/asset-name.js +32 -0
  9. package/lib/components/asset-name/asset-name.js.map +1 -0
  10. package/lib/components/asset-name/asset-name.module.css +32 -0
  11. package/lib/components/asset-name/index.js +18 -0
  12. package/lib/components/asset-name/index.js.map +1 -0
  13. package/lib/components/asset-not-predictive/asset-not-predictive.js +4 -2
  14. package/lib/components/asset-not-predictive/asset-not-predictive.js.map +1 -1
  15. package/lib/components/bundle-assets/bundle-assets.js +7 -40
  16. package/lib/components/bundle-assets/bundle-assets.js.map +1 -1
  17. package/lib/components/bundle-assets/bundle-assets.module.css +0 -64
  18. package/lib/components/bundle-assets/bundle-assets.utils.js +56 -28
  19. package/lib/components/bundle-assets/bundle-assets.utils.js.map +1 -1
  20. package/lib/components/bundle-assets/index.js +1 -1
  21. package/lib/components/bundle-assets/index.js.map +1 -1
  22. package/lib/components/bundle-assets-totals/bundle-assets-totals.js +4 -2
  23. package/lib/components/bundle-assets-totals/bundle-assets-totals.js.map +1 -1
  24. package/lib/components/bundle-modules/bundle-modules.js +4 -2
  25. package/lib/components/bundle-modules/bundle-modules.js.map +1 -1
  26. package/lib/components/bundle-packages/bundle-packages.js +4 -2
  27. package/lib/components/bundle-packages/bundle-packages.js.map +1 -1
  28. package/lib/components/entry-info/entry-info.js +1 -1
  29. package/lib/components/entry-info/entry-info.js.map +1 -1
  30. package/lib/components/metrics-table-export/metrics-table-export.js +12 -10
  31. package/lib/components/metrics-table-export/metrics-table-export.js.map +1 -1
  32. package/lib/components/metrics-table-options/metrics-table-options.js +7 -5
  33. package/lib/components/metrics-table-options/metrics-table-options.js.map +1 -1
  34. package/lib/components/metrics-table-options/metrics-table-options.module.css +5 -0
  35. package/lib/components/metrics-treemap/metrics-treemap.utils.js +0 -1
  36. package/lib/components/metrics-treemap/metrics-treemap.utils.js.map +1 -1
  37. package/lib/components/preview-source/preview-source.js +1 -1
  38. package/lib/components/preview-source/preview-source.js.map +1 -1
  39. package/lib/i18n.js +2 -0
  40. package/lib/i18n.js.map +1 -1
  41. package/lib/stories/wrapper.js +5 -2
  42. package/lib/stories/wrapper.js.map +1 -1
  43. package/lib/ui/tabs/index.js +15 -3
  44. package/lib/ui/tabs/index.js.map +1 -1
  45. package/lib/ui/tabs/tabs.js +9 -20
  46. package/lib/ui/tabs/tabs.js.map +1 -1
  47. package/lib/ui/tabs/tabs.module.css +6 -6
  48. package/lib/ui/tag/tag.js.map +1 -1
  49. package/lib-esm/components/asset-info/asset-info.js +4 -4
  50. package/lib-esm/components/asset-info/asset-info.js.map +1 -1
  51. package/lib-esm/components/asset-meta-tag/asset-meta-tag.js +10 -0
  52. package/lib-esm/components/asset-meta-tag/asset-meta-tag.js.map +1 -0
  53. package/lib-esm/components/asset-meta-tag/asset-meta-tag.module.css +55 -0
  54. package/lib-esm/components/asset-meta-tag/index.js +2 -0
  55. package/lib-esm/components/asset-meta-tag/index.js.map +1 -0
  56. package/lib-esm/components/asset-name/asset-name.js +25 -0
  57. package/lib-esm/components/asset-name/asset-name.js.map +1 -0
  58. package/lib-esm/components/asset-name/asset-name.module.css +32 -0
  59. package/lib-esm/components/asset-name/index.js +2 -0
  60. package/lib-esm/components/asset-name/index.js.map +1 -0
  61. package/lib-esm/components/asset-not-predictive/asset-not-predictive.js +4 -2
  62. package/lib-esm/components/asset-not-predictive/asset-not-predictive.js.map +1 -1
  63. package/lib-esm/components/bundle-assets/bundle-assets.js +8 -41
  64. package/lib-esm/components/bundle-assets/bundle-assets.js.map +1 -1
  65. package/lib-esm/components/bundle-assets/bundle-assets.module.css +0 -64
  66. package/lib-esm/components/bundle-assets/bundle-assets.utils.js +52 -24
  67. package/lib-esm/components/bundle-assets/bundle-assets.utils.js.map +1 -1
  68. package/lib-esm/components/bundle-assets/index.js +2 -2
  69. package/lib-esm/components/bundle-assets/index.js.map +1 -1
  70. package/lib-esm/components/bundle-assets-totals/bundle-assets-totals.js +5 -3
  71. package/lib-esm/components/bundle-assets-totals/bundle-assets-totals.js.map +1 -1
  72. package/lib-esm/components/bundle-modules/bundle-modules.js +5 -3
  73. package/lib-esm/components/bundle-modules/bundle-modules.js.map +1 -1
  74. package/lib-esm/components/bundle-packages/bundle-packages.js +5 -3
  75. package/lib-esm/components/bundle-packages/bundle-packages.js.map +1 -1
  76. package/lib-esm/components/entry-info/entry-info.js +1 -1
  77. package/lib-esm/components/entry-info/entry-info.js.map +1 -1
  78. package/lib-esm/components/metrics-table-export/metrics-table-export.js +13 -11
  79. package/lib-esm/components/metrics-table-export/metrics-table-export.js.map +1 -1
  80. package/lib-esm/components/metrics-table-options/metrics-table-options.js +7 -5
  81. package/lib-esm/components/metrics-table-options/metrics-table-options.js.map +1 -1
  82. package/lib-esm/components/metrics-table-options/metrics-table-options.module.css +5 -0
  83. package/lib-esm/components/metrics-treemap/metrics-treemap.utils.js +0 -1
  84. package/lib-esm/components/metrics-treemap/metrics-treemap.utils.js.map +1 -1
  85. package/lib-esm/components/preview-source/preview-source.js +1 -1
  86. package/lib-esm/components/preview-source/preview-source.js.map +1 -1
  87. package/lib-esm/i18n.js +2 -0
  88. package/lib-esm/i18n.js.map +1 -1
  89. package/lib-esm/stories/wrapper.js +5 -2
  90. package/lib-esm/stories/wrapper.js.map +1 -1
  91. package/lib-esm/ui/tabs/index.js +1 -1
  92. package/lib-esm/ui/tabs/index.js.map +1 -1
  93. package/lib-esm/ui/tabs/tabs.js +7 -19
  94. package/lib-esm/ui/tabs/tabs.js.map +1 -1
  95. package/lib-esm/ui/tabs/tabs.module.css +6 -6
  96. package/lib-esm/ui/tag/tag.js.map +1 -1
  97. package/package.json +12 -12
  98. package/src/app/app-gladys.stories.tsx +41 -0
  99. package/src/app/app-home-assistant.stories.tsx +41 -0
  100. package/src/app/app-outline.stories.tsx +41 -0
  101. package/src/app/app.stories.tsx +127 -0
  102. package/src/components/asset-info/asset-info.tsx +14 -7
  103. package/src/components/asset-meta-tag/asset-meta-tag.module.css +55 -0
  104. package/src/components/asset-meta-tag/asset-meta-tag.tsx +34 -0
  105. package/src/components/asset-meta-tag/index.ts +1 -0
  106. package/src/components/asset-name/asset-name.module.css +32 -0
  107. package/src/components/asset-name/asset-name.stories.tsx +85 -0
  108. package/src/components/asset-name/asset-name.tsx +60 -0
  109. package/src/components/asset-name/index.ts +1 -0
  110. package/src/components/asset-not-predictive/asset-not-predictive.tsx +10 -8
  111. package/src/components/bundle-assets/__tests__/add-metric-report-asset-row-data.ts +181 -0
  112. package/src/components/bundle-assets/__tests__/get-asset-meta-status.ts +21 -0
  113. package/src/components/bundle-assets/__tests__/get-is-not-predictive.ts +119 -0
  114. package/src/components/bundle-assets/bundle-assets.jsx +26 -87
  115. package/src/components/bundle-assets/bundle-assets.module.css +0 -64
  116. package/src/components/bundle-assets/bundle-assets.utils.js +87 -26
  117. package/src/components/bundle-assets/index.jsx +2 -7
  118. package/src/components/bundle-assets-totals/bundle-assets-totals.jsx +11 -3
  119. package/src/components/bundle-modules/bundle-modules.tsx +11 -3
  120. package/src/components/bundle-packages/bundle-packages.jsx +11 -3
  121. package/src/components/entry-info/entry-info.tsx +1 -6
  122. package/src/components/metrics-table-export/metrics-table-export.tsx +28 -19
  123. package/src/components/metrics-table-options/metrics-table-options.module.css +5 -0
  124. package/src/components/metrics-table-options/metrics-table-options.tsx +14 -6
  125. package/src/components/metrics-treemap/metrics-treemap.utils.ts +0 -1
  126. package/src/components/preview-source/preview-source.stories.tsx +13 -1
  127. package/src/components/preview-source/preview-source.tsx +1 -1
  128. package/src/i18n.js +2 -0
  129. package/src/stories/wrapper.jsx +21 -15
  130. package/src/types.d.ts +30 -1
  131. package/src/ui/tabs/index.ts +1 -0
  132. package/src/ui/tabs/tabs.module.css +6 -6
  133. package/src/ui/tabs/tabs.stories.tsx +25 -0
  134. package/src/ui/tabs/tabs.tsx +32 -0
  135. package/src/ui/tag/tag.tsx +4 -3
  136. package/types/components/asset-meta-tag/asset-meta-tag.d.ts +8 -0
  137. package/types/components/asset-meta-tag/index.d.ts +1 -0
  138. package/types/components/asset-name/asset-name.d.ts +8 -0
  139. package/types/components/asset-name/index.d.ts +1 -0
  140. package/types/components/asset-not-predictive/asset-not-predictive.d.ts +4 -4
  141. package/types/components/bundle-assets/bundle-assets.utils.d.ts +3 -3
  142. package/types/components/metrics-table-export/metrics-table-export.d.ts +1 -0
  143. package/types/components/metrics-table-options/metrics-table-options.d.ts +1 -1
  144. package/types/i18n.d.ts +2 -0
  145. package/types/stories/wrapper.d.ts +1 -1
  146. package/types/ui/tabs/index.d.ts +1 -1
  147. package/types/ui/tabs/tabs.d.ts +11 -41
  148. package/types/ui/tag/tag.d.ts +4 -4
  149. package/src/ui/tabs/index.js +0 -1
  150. package/src/ui/tabs/tabs.jsx +0 -39
@@ -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
+ });
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useMemo } from 'react';
1
+ import React, { useCallback, useMemo, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import cx from 'classnames';
4
4
  import get from 'lodash/get';
@@ -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
- <RowHeader
220
+ <AssetName
289
221
  row={row}
290
- customComponentLink={CustomComponentLink}
291
- filters={filters}
292
- search={search}
222
+ customComponentLink={assetNameCustomComponentLink}
223
+ className={css.assetName}
293
224
  />
294
225
  ),
295
226
  [CustomComponentLink, filters, search],
@@ -316,8 +247,10 @@ export const BundleAssets = (props) => {
316
247
  }, [allItems, entryId]);
317
248
 
318
249
  const exportDialog = useDialogState();
250
+ const [exportSourceType, setExportSourceType] = useState(undefined);
319
251
 
320
- const handleExportClick = useCallback(() => {
252
+ const handleExportClick = useCallback((sourceType) => {
253
+ setExportSourceType(sourceType);
321
254
  exportDialog.toggle();
322
255
  }, []);
323
256
 
@@ -396,7 +329,13 @@ export const BundleAssets = (props) => {
396
329
  )}
397
330
 
398
331
  <Dialog title={I18N.EXPORT} width="wide" state={exportDialog}>
399
- {exportDialog.open && <MetricsTableExport items={items} download="bundle-stats--assets" />}
332
+ {exportDialog.open && (
333
+ <MetricsTableExport
334
+ items={items}
335
+ initialSourceType={exportSourceType}
336
+ download="bundle-stats--assets"
337
+ />
338
+ )}
400
339
  </Dialog>
401
340
  </>
402
341
  );
@@ -3,70 +3,6 @@
3
3
  max-width: 240px;
4
4
  }
5
5
 
6
- .assetNameWrapper {
7
- }
8
-
9
- .assetName {}
10
-
11
- .notPredictive {
12
- margin-right: var(--space-xxsmall);
13
- display: inline-block;
14
- width: var(--space-small);
15
- height: var(--space-small);
16
- }
17
-
18
- .notPredictiveAnchor {}
19
-
20
- .notPredictiveIcon {
21
- color: var(--color-warning-dark);
22
- }
23
-
24
- .assetNameTags {
25
- display: inline;
26
- margin-right: var(--space-xxxsmall);
27
- }
28
-
29
- .assetNameTags:empty {
30
- display: none;
31
- }
32
-
33
- .assetNameTag {
34
- vertical-align: middle;
35
- }
36
-
37
- .assetNameTag + .assetNameTag {
38
- margin-left: 2px;
39
- }
40
-
41
- .assetNameTagEntry {
42
- background: var(--color-info-dark);
43
- }
44
-
45
- .assetNameTagEntry::before {
46
- content: 'e';
47
- }
48
-
49
- .assetNameTagInitial {
50
- background: var(--color-info);
51
- }
52
-
53
- .assetNameTagInitial::before {
54
- content: 'i';
55
- }
56
-
57
- .assetNameTagChunk {
58
- background: var(--color-info-light);
59
- }
60
-
61
- .assetNameTagChunk::before {
62
- content: 'c';
63
- }
64
-
65
- .assetNameText {
66
- display: inline-block;
67
- vertical-align: middle;
68
- }
69
-
70
6
  .root .assetName:hover,
71
7
  .root .assetName:active,
72
8
  .root .assetName:focus {
@@ -1,26 +1,21 @@
1
- import { ASSET_ENTRY_TYPE, ASSET_FILE_TYPE, ASSET_FILTERS, getFileType } from '@bundle-stats/utils';
2
-
3
- export const addRowAssetFlags = (row) => {
4
- const { runs } = row;
1
+ /**
2
+ * @type {import('@bundle-stats/utils').ReportMetricRow} ReportMetricRow
3
+ * @type {import('../../types').ReportMetricAssetRow} ReportMetricAssetRow
4
+ * @type {import('../../types').ReportMetricAssetRowMetaStatus} ReportMetricAssetRowFlagStatus
5
+ */
5
6
 
6
- const isEntry = runs.map((run) => run?.isEntry).includes(true);
7
- const isInitial = runs.map((run) => run?.isInitial).includes(true);
8
- const isChunk = runs.map((run) => run?.isChunk).includes(true);
9
- const isAsset = !(isEntry || isInitial || isChunk);
10
- const fileType = getFileType(row.key);
7
+ import { ASSET_ENTRY_TYPE, ASSET_FILE_TYPE, ASSET_FILTERS, getFileType } from '@bundle-stats/utils';
11
8
 
12
- return {
13
- ...row,
14
- isEntry,
15
- isInitial,
16
- isChunk,
17
- isAsset,
18
- fileType,
19
- };
20
- };
9
+ /**
10
+ * Check if the asset cache is not predictive
11
+ *
12
+ * @param {ReportMetricRow} row
13
+ * @returns {boolean}
14
+ */
15
+ export const getIsNotPredictive = (row) => {
16
+ const { key, runs } = row;
21
17
 
22
- export const getIsNotPredictive = (key, runs) =>
23
- runs.reduce((agg, current, index) => {
18
+ return runs.reduce((agg, current, index) => {
24
19
  if (agg) {
25
20
  return agg;
26
21
  }
@@ -32,20 +27,86 @@ export const getIsNotPredictive = (key, runs) =>
32
27
  if (
33
28
  current &&
34
29
  runs[index + 1] &&
35
- current.delta !== 0 &&
36
30
  key !== current.name &&
37
- current.name === runs[index + 1].name
31
+ current.name === runs[index + 1].name &&
32
+ current.value !== runs[index + 1].value
38
33
  ) {
39
34
  return true;
40
35
  }
41
36
 
42
37
  return agg;
43
38
  }, false);
39
+ };
40
+
41
+ /**
42
+ * @param {Array<boolean>}
43
+ * @returns {ReportMetricAssetRowFlagStatus | boolean}
44
+ */
45
+ export const getAssetMetaStatus = (values) => {
46
+ if (!values.includes(true)) {
47
+ return false;
48
+ }
49
+
50
+ // filter empty runs
51
+ const metaValues = values.filter((value) => typeof value !== 'undefined');
52
+
53
+ const current = metaValues[0];
54
+ const metaValuesLength = metaValues.length;
55
+
56
+ if (metaValuesLength === 1) {
57
+ return Boolean(current);
58
+ }
59
+
60
+ const baseline = metaValues[metaValuesLength - 1];
44
61
 
45
- export const addRowIsNotPredictive = (row) => ({
46
- ...row,
47
- isNotPredictive: getIsNotPredictive(row.key, row.runs),
48
- });
62
+ if (current && !baseline) {
63
+ return 'added';
64
+ }
65
+
66
+ if (!current && baseline) {
67
+ return 'removed';
68
+ }
69
+
70
+ return true;
71
+ };
72
+
73
+ /**
74
+ * Add asset row flags
75
+ *
76
+ * @param {ReportMetricRow} row
77
+ * @returns {ReportMetricAssetRow}
78
+ */
79
+ export const addMetricReportAssetRowData = (row) => {
80
+ const { runs } = row;
81
+
82
+ // Collect meta for each run
83
+ const runsEntry = [];
84
+ const runsInitial = [];
85
+ const runsChunk = [];
86
+
87
+ runs.forEach((run) => {
88
+ runsEntry.push(run?.isEntry);
89
+ runsInitial.push(run?.isInitial);
90
+ runsChunk.push(run?.isChunk);
91
+ });
92
+
93
+ const isEntry = getAssetMetaStatus(runsEntry);
94
+ const isInitial = getAssetMetaStatus(runsInitial);
95
+ const isChunk = getAssetMetaStatus(runsChunk);
96
+ const isAsset = !(isEntry || isInitial || isChunk);
97
+ const isNotPredictive = getIsNotPredictive(row);
98
+ const fileType = getFileType(row.key);
99
+
100
+ return {
101
+ ...row,
102
+ isEntry,
103
+ isInitial,
104
+ isChunk,
105
+ isAsset,
106
+ isNotPredictive,
107
+ fileType,
108
+ };
109
+ };
49
110
 
50
111
  export const getRowFilter = (filters) => (item) => {
51
112
  if (filters[ASSET_FILTERS.CHANGED] && !item.changed) {