Skip to content

Commit a6ddc8c

Browse files
authored
v2.3.0 (#65)
* initial released-prov mixed status for data ava chart * mixed release, prov pattern scaling tweaks * propagate ava chart updates to download form * ga4 support, regen lib + assets * clean up gtm data layer reference * pull out analytics service for any custom ga events * add UA events to service * fix CodeQL identified escape shortcomings * use only gtm, regen assets * fix comment spelling * rebuild availability chart key * fix availability key selection item * ava key display adjustment at certain viewports * delineate ava release based on context * ava key ui tweak, regen lib * prepare v2.3.0
1 parent 83e9e1f commit a6ddc8c

File tree

53 files changed

+10938
-1269
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+10938
-1269
lines changed

lib/components/DataProductAvailability/AvailabilitySvgComponents.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ export const CELL_ATTRS: {
1818
fill: string;
1919
stroke: string;
2020
};
21+
'mixed-available-provisional': {
22+
strokeWidth: string;
23+
width: string;
24+
height: string;
25+
rx: string;
26+
nudge: number;
27+
fill: string;
28+
stroke: string;
29+
};
2130
'not available': {
2231
stroke: null;
2332
strokeWidth: null;

lib/components/DataProductAvailability/AvailabilitySvgComponents.js

Lines changed: 141 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,142 @@ HalfAndHalfPattern.propTypes = {
7878
HalfAndHalfPattern.defaultProps = {
7979
secondaryColor: '#ffffff'
8080
};
81+
var DiagHalfAndHalfPattern = function DiagHalfAndHalfPattern(props) {
82+
var id = props.id,
83+
color = props.color,
84+
diagColor = props.diagColor,
85+
diagColorFillOpacity = props.diagColorFillOpacity,
86+
secondaryDiagColor = props.secondaryDiagColor;
87+
var cellW = _AvailabilityUtils.SVG.CELL_WIDTH;
88+
var cellH = _AvailabilityUtils.SVG.CELL_HEIGHT;
89+
// Extends the bounds of the applied rectangle dimensions
90+
// when computing coordinates. This will overlay the
91+
// computed coordinate such that they extend beyond the actual bounds
92+
// of the rectangle, to account for squared stroke end of line points
93+
// so that there's no gaps with a sufficiently heavy stroke width.
94+
// Setting this to 0 will disable to the extension and map directly
95+
// onto the bounding box of the rectangle.
96+
// When divided by 2, should result in a rational number.
97+
var extendBoundsPadding = 0;
98+
var w = _AvailabilityUtils.SVG.CELL_WIDTH + extendBoundsPadding;
99+
var h = _AvailabilityUtils.SVG.CELL_HEIGHT + extendBoundsPadding;
100+
// Nudge the half fill color to prevent background from initial
101+
// line from top right corner consuming the color at normal
102+
// viewing levels. Ensures it looks visually appropriate for half color
103+
// fill and half diag line pattern.
104+
// Will be based on initDist
105+
var nudgeDiagFill = 1;
106+
var numLines = 4;
107+
// Distance of the diagonal of the rectangle
108+
var diagLengthRaw = Math.sqrt(Math.pow(cellW, 2) + Math.pow(cellH, 2));
109+
// Distance of initial line to top right corner, as opposed to starting
110+
// at point (0, w)
111+
var initDist = diagLengthRaw * 0.18;
112+
// Distance of furthest potential end line to bottom left corner
113+
var trailingDist = diagLengthRaw * 0.1;
114+
// Distance of the diagonal of the rectangle
115+
var diagLength = diagLengthRaw - (initDist + trailingDist);
116+
// Distance between parallel lines
117+
var diagLineGap = diagLength / numLines;
118+
var diagLineStrokeWidth = (diagLength * 0.1).toFixed(2);
119+
// Compute the initial x coordinate of the first line based on specified
120+
// initial distance from top right corner
121+
// 45 degree lines means perpendicular line to top right corner
122+
// c^2 = a^2 + b^2 where a == b
123+
// Find the initial x coordinate (y == 0) to derive linear function from
124+
var initXCoordDist = w - Math.sqrt(2 * Math.pow(initDist, 2));
125+
var coords = [];
126+
// eslint-disable-next-line no-plusplus
127+
var _loop = function _loop() {
128+
// Vertical transformation of linear function scalar value
129+
// As m == 1, use distance between parallel lines to compute hypotenuse
130+
// of equilateral triangle which will be the vertical transformation scalar
131+
// to apply to the linear function
132+
// Then scale by line index for each line
133+
var v = Math.sqrt(2 * Math.pow(diagLineGap, 2)) * i;
134+
// Linear functions derived from initial X coordinate, known slope
135+
var findY = function findY(x) {
136+
return x - initXCoordDist + v;
137+
};
138+
var findX = function findX(y) {
139+
return y + initXCoordDist - v;
140+
};
141+
var x1 = 0;
142+
var y1 = findY(x1);
143+
var x2 = w;
144+
var y2 = findY(x2);
145+
// Snap coordinates to bounding box
146+
if (y1 < 0) {
147+
x1 = findX(0);
148+
y1 = 0;
149+
}
150+
if (y2 > h) {
151+
x2 = findX(h);
152+
y2 = h;
153+
}
154+
coords.push({
155+
x1: (x1 - extendBoundsPadding / 2).toFixed(2),
156+
y1: (y1 - extendBoundsPadding / 2).toFixed(2),
157+
x2: (x2 - extendBoundsPadding / 2).toFixed(2),
158+
y2: (y2 - extendBoundsPadding / 2).toFixed(2)
159+
});
160+
};
161+
for (var i = 0; i < numLines; i++) {
162+
_loop();
163+
}
164+
return /*#__PURE__*/_react.default.createElement("pattern", {
165+
id: id,
166+
x: 0,
167+
y: 0,
168+
width: 1,
169+
height: 1,
170+
patternUnits: "objectBoundingBox",
171+
patternContentUnits: "userSpaceOnUse"
172+
}, /*#__PURE__*/_react.default.createElement("polygon", {
173+
points: "0,0 0,1 1,1 1,0",
174+
fill: secondaryDiagColor,
175+
fillOpacity: diagColorFillOpacity
176+
}), coords.map(function (coord, idx) {
177+
return /*#__PURE__*/_react.default.createElement("line", {
178+
// eslint-disable-next-line react/no-array-index-key
179+
key: "DiagHalfAndHalfPatternKey-".concat(coord.x1, "-").concat(coord.y1, "-").concat(coord.x2, "-").concat(coord.y2, "-").concat(idx),
180+
x1: coord.x1,
181+
y1: coord.y1,
182+
x2: coord.x2,
183+
y2: coord.y2,
184+
stroke: diagColor,
185+
strokeWidth: diagLineStrokeWidth,
186+
strokeLinecap: "square"
187+
});
188+
}), /*#__PURE__*/_react.default.createElement("polygon", {
189+
points: "0,0 ".concat(cellW - nudgeDiagFill, ",0 ", 0, ",").concat(cellH),
190+
fill: color
191+
}));
192+
};
193+
DiagHalfAndHalfPattern.propTypes = {
194+
id: _propTypes.default.string.isRequired,
195+
color: _propTypes.default.string.isRequired,
196+
diagColor: _propTypes.default.string.isRequired,
197+
diagColorFillOpacity: _propTypes.default.number.isRequired,
198+
secondaryDiagColor: _propTypes.default.string
199+
};
200+
DiagHalfAndHalfPattern.defaultProps = {
201+
secondaryDiagColor: '#ffffff'
202+
};
81203
var SvgDefs = function SvgDefs() {
82204
return /*#__PURE__*/_react.default.createElement("svg", {
83205
width: "0px",
84206
height: "0px"
85207
}, /*#__PURE__*/_react.default.createElement("defs", null, /*#__PURE__*/_react.default.createElement(DiagLinesPattern, {
86208
id: "availableProvisionalPattern",
87209
color: _Theme.COLORS.NEON_BLUE[700],
88-
secondaryColor: _Theme.COLORS.NEON_BLUE[100]
210+
secondaryColor: _Theme.COLORS.NEON_BLUE[50]
211+
}), /*#__PURE__*/_react.default.createElement(DiagHalfAndHalfPattern, {
212+
id: "mixedAvailableProvisionalPattern",
213+
color: _Theme.COLORS.NEON_BLUE[700],
214+
diagColor: _Theme.COLORS.NEON_BLUE[700],
215+
diagColorFillOpacity: 0.25,
216+
secondaryDiagColor: _Theme.COLORS.NEON_BLUE[50]
89217
}), /*#__PURE__*/_react.default.createElement(DiagLinesPattern, {
90218
id: "beingProcessedPattern",
91219
color: _Theme.COLORS.NEON_BLUE[700]
@@ -118,6 +246,13 @@ var thinStrokeAttrs = {
118246
rx: "".concat(_AvailabilityUtils.SVG.CELL_RX * 1.5, "px"),
119247
nudge: 0.4
120248
};
249+
var midStrokeAttrs = {
250+
strokeWidth: '1.15px',
251+
width: "".concat(_AvailabilityUtils.SVG.CELL_WIDTH - 1.15, "px"),
252+
height: "".concat(_AvailabilityUtils.SVG.CELL_HEIGHT - 1.15, "px"),
253+
rx: "".concat(_AvailabilityUtils.SVG.CELL_RX * 1.25, "px"),
254+
nudge: 0.60
255+
};
121256
var fatStrokeAttrs = {
122257
strokeWidth: '1.5px',
123258
width: "".concat(_AvailabilityUtils.SVG.CELL_WIDTH - 1.5, "px"),
@@ -140,7 +275,11 @@ var CELL_ATTRS = {
140275
'available-provisional': _extends({
141276
fill: 'url(#availableProvisionalPattern)',
142277
stroke: _Theme.COLORS.NEON_BLUE[700]
143-
}, fatStrokeAttrs),
278+
}, midStrokeAttrs),
279+
'mixed-available-provisional': _extends({
280+
fill: 'url(#mixedAvailableProvisionalPattern)',
281+
stroke: _Theme.COLORS.NEON_BLUE[700]
282+
}, thinStrokeAttrs),
144283
'not available': _extends({
145284
fill: _Theme.default.palette.grey[200]
146285
}, noStrokeAttrs),

lib/components/DataProductAvailability/AvailabilityUtils.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ export const VALID_ENHANCED_STATUSES: {
1818
title: string;
1919
description: string;
2020
};
21+
'mixed-available-provisional': {
22+
title: string;
23+
description: string;
24+
};
2125
delayed: {
2226
title: string;
2327
description: string;
@@ -51,6 +55,7 @@ export const VALID_ENHANCED_STATUSES: {
5155
description: string;
5256
};
5357
};
58+
export function calcBasicRollupStatus(statuses: any): any;
5459
export function calcRollupStatus(statuses?: any[]): any;
5560
export namespace AvailabilityPropTypes {
5661
const basicSiteCodes: PropTypes.Requireable<(PropTypes.InferProps<{

lib/components/DataProductAvailability/AvailabilityUtils.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
44
Object.defineProperty(exports, "__esModule", {
55
value: true
66
});
7-
exports.calcRollupStatus = exports.VALID_ENHANCED_STATUSES = exports.TIME = exports.SVG_STYLES = exports.SVG = exports.AvailabilityPropTypes = void 0;
7+
exports.calcRollupStatus = exports.calcBasicRollupStatus = exports.VALID_ENHANCED_STATUSES = exports.TIME = exports.SVG_STYLES = exports.SVG = exports.AvailabilityPropTypes = void 0;
88
var _propTypes = _interopRequireDefault(require("prop-types"));
99
var _moment = _interopRequireDefault(require("moment"));
1010
var _d3Transition = require("d3-transition");
@@ -25,13 +25,17 @@ var VALID_ENHANCED_STATUSES = {
2525
description: 'Data have been collected and will be published after processing has completed'
2626
},
2727
available: {
28-
title: 'Available',
29-
description: 'Data have been published and are available for download'
28+
title: 'Release Available',
29+
description: 'Data have been published and released. Data are available for download'
3030
},
3131
'available-provisional': {
32-
title: 'Provisional Available',
32+
title: 'Provisional',
3333
description: 'Provisional data have been published and are available for download'
3434
},
35+
'mixed-available-provisional': {
36+
title: 'Mixed',
37+
description: 'Data have been published and are available for download. Some data are released and some data are provisional.'
38+
},
3539
delayed: {
3640
title: 'Delayed',
3741
description: 'Data should be available for download but something has prevented publication'
@@ -66,6 +70,28 @@ var VALID_ENHANCED_STATUSES = {
6670
}
6771
};
6872
exports.VALID_ENHANCED_STATUSES = VALID_ENHANCED_STATUSES;
73+
var calcBasicRollupStatus = function calcBasicRollupStatus(statuses) {
74+
if (!statuses) {
75+
return null;
76+
}
77+
if (Array.from(statuses).some(function (s) {
78+
return !Object.keys(VALID_ENHANCED_STATUSES).includes(s);
79+
})) {
80+
return null;
81+
}
82+
if (statuses.size === 0) {
83+
return null;
84+
}
85+
if (statuses.size === 1) {
86+
return Array.from(statuses)[0];
87+
}
88+
var hasTomb = statuses.has('tombstoned');
89+
if (hasTomb) {
90+
return 'tombstoned';
91+
}
92+
return statuses.has('available-provisional') ? 'mixed-available-provisional' : 'available';
93+
};
94+
exports.calcBasicRollupStatus = calcBasicRollupStatus;
6995
var calcRollupStatus = function calcRollupStatus() {
7096
var statuses = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
7197
if (!Array.isArray(statuses)) {

lib/components/DataProductAvailability/BasicAvailabilityGrid.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ var _d3Selection = require("d3-selection");
1010
var _d3Drag = require("d3-drag");
1111
var _uniqueId = _interopRequireDefault(require("lodash/uniqueId"));
1212
var _Theme = _interopRequireWildcard(require("../Theme/Theme"));
13-
var _AvailabilityUtils = require("./AvailabilityUtils");
1413
var _AvailabilitySvgComponents = require("./AvailabilitySvgComponents");
14+
var _AvailabilityUtils = require("./AvailabilityUtils");
1515
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); }
1616
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; }
1717
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -584,7 +584,7 @@ function BasicAvailabilityGrid(config) {
584584
dataG.selectAll('g').data(rowKeys).join('g').attr('transform', getRowTranslation).each(function (rowKey, rowIdx, gNodes) {
585585
var rowData = data.rows[rowKey];
586586
var getCellAttr = function getCellAttr(month, attr) {
587-
var status = rowData[month];
587+
var status = (0, _AvailabilityUtils.calcBasicRollupStatus)(rowData[month]);
588588
return !_AvailabilitySvgComponents.CELL_ATTRS[status] ? _AvailabilitySvgComponents.CELL_ATTRS['not available'][attr] || null : _AvailabilitySvgComponents.CELL_ATTRS[status][attr] || null;
589589
};
590590
(0, _d3Selection.select)(gNodes[rowIdx]).selectAll('rect').data(function () {

lib/components/DataProductAvailability/BasicAvailabilityInterface.js

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -486,10 +486,22 @@ var BasicAvailabilityInterface = function BasicAvailabilityInterface(props) {
486486
status = 'available-provisional';
487487
}
488488
}
489-
views.summary.rows.summary[month] = status;
490-
views.sites.rows[siteCode][month] = status;
491-
views.states.rows[stateCode][month] = status;
492-
views.domains.rows[domainCode][month] = status;
489+
if (!views.summary.rows.summary[month]) {
490+
views.summary.rows.summary[month] = new Set();
491+
}
492+
if (!views.sites.rows[siteCode][month]) {
493+
views.sites.rows[siteCode][month] = new Set();
494+
}
495+
if (!views.states.rows[stateCode][month]) {
496+
views.states.rows[stateCode][month] = new Set();
497+
}
498+
if (!views.domains.rows[domainCode][month]) {
499+
views.domains.rows[domainCode][month] = new Set();
500+
}
501+
views.summary.rows.summary[month].add(status);
502+
views.sites.rows[siteCode][month].add(status);
503+
views.states.rows[stateCode][month].add(status);
504+
views.domains.rows[domainCode][month].add(status);
493505
});
494506
});
495507
dataProducts.forEach(function (product) {
@@ -513,7 +525,10 @@ var BasicAvailabilityInterface = function BasicAvailabilityInterface(props) {
513525
status = 'available-provisional';
514526
}
515527
}
516-
views.products.rows[dataProductCode][month] = status;
528+
if (!views.products.rows[dataProductCode][month]) {
529+
views.products.rows[dataProductCode][month] = new Set();
530+
}
531+
views.products.rows[dataProductCode][month].add(status);
517532
});
518533
});
519534
if (!downloadContextIsActive) {
@@ -710,13 +725,7 @@ var BasicAvailabilityInterface = function BasicAvailabilityInterface(props) {
710725
display: 'flex',
711726
alignItems: 'center'
712727
}
713-
}, /*#__PURE__*/_react.default.createElement(_Typography.default, {
714-
variant: "h6",
715-
className: classes.h6Small,
716-
style: {
717-
marginRight: _Theme.default.spacing(1.5)
718-
}
719-
}, "Key:"), /*#__PURE__*/_react.default.createElement(_BasicAvailabilityKey.default, {
728+
}, /*#__PURE__*/_react.default.createElement(_BasicAvailabilityKey.default, {
720729
orientation: currentView === 'products' ? 'horizontal' : '',
721730
selectionEnabled: selectionEnabled,
722731
delineateRelease: delineateRelease,
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
/**
2-
Main Function
3-
*/
1+
export default BasicAvailabilityKey;
42
declare function BasicAvailabilityKey(props: any): JSX.Element;
53
declare namespace BasicAvailabilityKey {
64
namespace propTypes {
7-
const orientation: PropTypes.Requireable<string>;
85
const selectionEnabled: PropTypes.Requireable<boolean>;
96
const delineateRelease: PropTypes.Requireable<boolean>;
107
const availabilityStatusType: PropTypes.Requireable<string>;
8+
const dialogOnly: PropTypes.Requireable<boolean>;
119
}
1210
namespace defaultProps {
13-
const orientation_1: string;
14-
export { orientation_1 as orientation };
1511
const selectionEnabled_1: boolean;
1612
export { selectionEnabled_1 as selectionEnabled };
1713
const delineateRelease_1: boolean;
1814
export { delineateRelease_1 as delineateRelease };
19-
const availabilityStatusType_1: null;
15+
const availabilityStatusType_1: string;
2016
export { availabilityStatusType_1 as availabilityStatusType };
17+
const dialogOnly_1: boolean;
18+
export { dialogOnly_1 as dialogOnly };
2119
}
2220
}
23-
export default BasicAvailabilityKey;
2421
import PropTypes from "prop-types";

0 commit comments

Comments
 (0)