Skip to content

Commit 87f6fd6

Browse files
authored
v2.5.0 (#67)
* initial provisional data download step * handle AOP provisional data selection and display * rework provisional data step filtering logic * add provisional data note to site and date selection form * add check for prov data for download step * prepare v2.5.0
1 parent 52719a7 commit 87f6fd6

File tree

25 files changed

+2192
-79
lines changed

25 files changed

+2192
-79
lines changed

lib/components/DownloadDataContext/DownloadDataContext.d.ts

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export function getTestableItems(): {
1515
ALL_POSSIBLE_VALID_DATE_RANGE?: undefined;
1616
ALL_POSSIBLE_VALID_DOCUMENTATION?: undefined;
1717
ALL_POSSIBLE_VALID_PACKAGE_TYPE?: undefined;
18+
ALL_POSSIBLE_VALID_PROVISIONAL_DATA?: undefined;
1819
} | {
1920
productDataIsValid: (productData: any) => boolean;
2021
yearMonthIsValid: (yearMonth?: string) => boolean;
@@ -93,6 +94,11 @@ export function getTestableItems(): {
9394
validValues: string[];
9495
isValid: boolean;
9596
};
97+
provisionalData: {
98+
value: string;
99+
validValues: string[];
100+
isValid: boolean;
101+
};
96102
policies: {
97103
value: boolean;
98104
validValues: null;
@@ -106,6 +112,7 @@ export function getTestableItems(): {
106112
ALL_POSSIBLE_VALID_DATE_RANGE: string[];
107113
ALL_POSSIBLE_VALID_DOCUMENTATION: string[];
108114
ALL_POSSIBLE_VALID_PACKAGE_TYPE: string[];
115+
ALL_POSSIBLE_VALID_PROVISIONAL_DATA: string[];
109116
};
110117
declare namespace DownloadDataContext {
111118
export { Provider };
@@ -126,6 +133,10 @@ declare namespace Provider {
126133
siteCodes: PropTypes.Requireable<(PropTypes.InferProps<{
127134
siteCode: PropTypes.Validator<string>;
128135
availableMonths: PropTypes.Validator<(string | null | undefined)[]>;
136+
availableReleases: PropTypes.Requireable<(PropTypes.InferProps<{
137+
release: PropTypes.Validator<string>;
138+
availableMonths: PropTypes.Validator<(string | null | undefined)[]>;
139+
}> | null | undefined)[]>;
129140
}> | null | undefined)[]>;
130141
}>>;
131142
const availabilityView: PropTypes.Requireable<string>;
@@ -134,6 +145,7 @@ declare namespace Provider {
134145
const dateRange: PropTypes.Requireable<(string | null | undefined)[]>;
135146
const documentation: PropTypes.Requireable<string>;
136147
const packageType: PropTypes.Requireable<string>;
148+
const provisionalData: PropTypes.Requireable<string>;
137149
const children: PropTypes.Validator<NonNullable<NonNullable<PropTypes.ReactNodeLike>>>;
138150
}
139151
namespace defaultProps {
@@ -155,6 +167,8 @@ declare namespace Provider {
155167
export { documentation_1 as documentation };
156168
import packageType_1 = value;
157169
export { packageType_1 as packageType };
170+
import provisionalData_1 = value;
171+
export { provisionalData_1 as provisionalData };
158172
}
159173
}
160174
declare function useDownloadDataState(): {
@@ -227,6 +241,11 @@ declare function useDownloadDataState(): {
227241
validValues: string[];
228242
isValid: boolean;
229243
};
244+
provisionalData: {
245+
value: string;
246+
validValues: string[];
247+
isValid: boolean;
248+
};
230249
policies: {
231250
value: boolean;
232251
validValues: null;
@@ -302,6 +321,11 @@ declare function useDownloadDataState(): {
302321
validValues: string[];
303322
isValid: boolean;
304323
};
324+
provisionalData: {
325+
value: string;
326+
validValues: string[];
327+
isValid: boolean;
328+
};
305329
policies: {
306330
value: boolean;
307331
validValues: null;
@@ -406,14 +430,23 @@ declare namespace DEFAULT_STATE {
406430
export { isValid_5 as isValid };
407431
}
408432
export { packageType_2 as packageType };
409-
export namespace policies {
410-
const value_7: boolean;
433+
export namespace provisionalData_2 {
434+
const value_7: string;
411435
export { value_7 as value };
412-
const validValues_6: null;
436+
const validValues_6: string[];
413437
export { validValues_6 as validValues };
414438
const isValid_6: boolean;
415439
export { isValid_6 as isValid };
416440
}
441+
export { provisionalData_2 as provisionalData };
442+
export namespace policies {
443+
const value_8: boolean;
444+
export { value_8 as value };
445+
const validValues_7: null;
446+
export { validValues_7 as validValues };
447+
const isValid_7: boolean;
448+
export { isValid_7 as isValid };
449+
}
417450
}
418451
declare namespace ALL_STEPS {
419452
export namespace documentation_3 {
@@ -446,31 +479,40 @@ declare namespace ALL_STEPS {
446479
export { title_2 as title };
447480
}
448481
export { packageType_3 as packageType };
449-
export namespace sitesAndDateRange {
482+
export namespace provisionalData_3 {
450483
const requiredStateKeys_4: string[];
451484
export { requiredStateKeys_4 as requiredStateKeys };
452485
const label_4: string;
453486
export { label_4 as label };
454487
const title_3: string;
455488
export { title_3 as title };
456489
}
457-
export namespace policies_1 {
490+
export { provisionalData_3 as provisionalData };
491+
export namespace sitesAndDateRange {
458492
const requiredStateKeys_5: string[];
459493
export { requiredStateKeys_5 as requiredStateKeys };
460494
const label_5: string;
461495
export { label_5 as label };
462496
const title_4: string;
463497
export { title_4 as title };
464498
}
465-
export { policies_1 as policies };
466-
export namespace summary {
467-
const requiredStateKeys_6: never[];
499+
export namespace policies_1 {
500+
const requiredStateKeys_6: string[];
468501
export { requiredStateKeys_6 as requiredStateKeys };
469502
const label_6: string;
470503
export { label_6 as label };
471504
const title_5: string;
472505
export { title_5 as title };
473506
}
507+
export { policies_1 as policies };
508+
export namespace summary {
509+
const requiredStateKeys_7: never[];
510+
export { requiredStateKeys_7 as requiredStateKeys };
511+
const label_7: string;
512+
export { label_7 as label };
513+
const title_6: string;
514+
export { title_6 as title };
515+
}
474516
}
475517
declare function getStateObservable(): import("rxjs").Observable<any>;
476518
import PropTypes from "prop-types";

lib/components/DownloadDataContext/DownloadDataContext.js

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var _manifestUtil = require("../../util/manifestUtil");
1414
var _rxUtil = require("../../util/rxUtil");
1515
var _StateStorageService = _interopRequireDefault(require("../../service/StateStorageService"));
1616
var _NeonSignInButtonState = _interopRequireDefault(require("../NeonSignInButton/NeonSignInButtonState"));
17+
var _ReleaseService = _interopRequireDefault(require("../../service/ReleaseService"));
1718
var _StateStorageConverter = require("./StateStorageConverter");
1819
var _typeUtil = require("../../util/typeUtil");
1920
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -34,6 +35,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3435
var ALL_POSSIBLE_VALID_DATE_RANGE = ['2010-01', (0, _moment.default)().format('YYYY-MM')];
3536
var ALL_POSSIBLE_VALID_DOCUMENTATION = ['include', 'exclude'];
3637
var ALL_POSSIBLE_VALID_PACKAGE_TYPE = ['basic', 'expanded'];
38+
var ALL_POSSIBLE_VALID_PROVISIONAL_DATA = ['include', 'exclude'];
3739
var AVAILABILITY_VIEW_MODES = ['summary', 'sites', 'states', 'domains'];
3840
var ALL_STEPS = {
3941
documentation: {
@@ -55,6 +57,11 @@ var ALL_STEPS = {
5557
label: 'Package Type',
5658
title: 'Which package type do you want?'
5759
},
60+
provisionalData: {
61+
requiredStateKeys: ['provisionalData'],
62+
label: 'Provisional Data',
63+
title: 'Do you want to include provisional data?'
64+
},
5865
sitesAndDateRange: {
5966
requiredStateKeys: ['sites', 'dateRange'],
6067
label: 'Sites and Date Range',
@@ -79,11 +86,14 @@ var DEFAULT_REQUIRED_STEPS = [{
7986
key: 'sitesAndDateRange',
8087
isComplete: false
8188
}, {
82-
key: 'documentation',
89+
key: 'provisionalData',
8390
isComplete: true
8491
}, {
8592
key: 'packageType',
8693
isComplete: false
94+
}, {
95+
key: 'documentation',
96+
isComplete: true
8797
}, {
8898
key: 'policies',
8999
isComplete: false
@@ -171,6 +181,11 @@ var DEFAULT_STATE = {
171181
validValues: [].concat(ALL_POSSIBLE_VALID_PACKAGE_TYPE),
172182
isValid: false
173183
},
184+
provisionalData: {
185+
value: 'exclude',
186+
validValues: [].concat(ALL_POSSIBLE_VALID_PROVISIONAL_DATA),
187+
isValid: true
188+
},
174189
policies: {
175190
value: false,
176191
validValues: null,
@@ -179,15 +194,15 @@ var DEFAULT_STATE = {
179194
};
180195

181196
// State keys that have a common { value, validValues, isValid } shape and can be validated
182-
var VALIDATABLE_STATE_KEYS = ['release', 'sites', 'dateRange', 'documentation', 'packageType', 's3Files', 'policies'];
197+
var VALIDATABLE_STATE_KEYS = ['release', 'sites', 'dateRange', 'documentation', 'packageType', 'provisionalData', 's3Files', 'policies'];
183198

184199
// State keys that can be transfered between contexts through higher order state
185200
// (must be a subset of VALIDATABLE_STATE_KEYS)
186201
var HIGHER_ORDER_TRANSFERABLE_STATE_KEYS = ['release', 'sites', 'dateRange'];
187202

188203
// State keys that should trigger a new manifest (file size estimate) request when updated
189204
// (must be a subset of VALIDATABLE_STATE_KEYS)
190-
var MANIFEST_TRIGGERING_STATE_KEYS = ['release', 'sites', 'dateRange', 'documentation', 'packageType'];
205+
var MANIFEST_TRIGGERING_STATE_KEYS = ['release', 'sites', 'dateRange', 'documentation', 'packageType', 'provisionalData'];
191206

192207
// Regexes and associated capture group names for parse s3 file names and URLs
193208
var S3_PATTERN = {
@@ -249,6 +264,8 @@ var newStateIsAllowable = function newStateIsAllowable(key, value) {
249264
return ALL_POSSIBLE_VALID_DOCUMENTATION.includes(value) || value === null;
250265
case 'packageType':
251266
return ALL_POSSIBLE_VALID_PACKAGE_TYPE.includes(value) || value === null;
267+
case 'provisionalData':
268+
return ALL_POSSIBLE_VALID_PROVISIONAL_DATA.includes(value) || value === null;
252269
case 's3Files':
253270
return Array.isArray(value) && value.every(function (id) {
254271
return typeof id === 'string';
@@ -347,6 +364,8 @@ var getValidValuesFromProductData = function getValidValuesFromProductData(produ
347364
return [].concat(ALL_POSSIBLE_VALID_DOCUMENTATION);
348365
case 'packageType':
349366
return [].concat(ALL_POSSIBLE_VALID_PACKAGE_TYPE);
367+
case 'provisionalData':
368+
return [].concat(ALL_POSSIBLE_VALID_PROVISIONAL_DATA);
350369
case 'policies':
351370
return null;
352371
default:
@@ -360,7 +379,8 @@ var getValidValuesFromProductData = function getValidValuesFromProductData(produ
360379
var getInitialStateFromProps = function getInitialStateFromProps(props) {
361380
// Handle base product data
362381
var productData = props.productData,
363-
availabilityView = props.availabilityView;
382+
availabilityView = props.availabilityView,
383+
release = props.release;
364384
if (!productDataIsValid(productData)) {
365385
return _extends({}, DEFAULT_STATE, {
366386
availabilityView: availabilityView,
@@ -408,6 +428,9 @@ var getInitialStateFromProps = function getInitialStateFromProps(props) {
408428
requiredSteps = [{
409429
key: 'sitesAndDateRange',
410430
isComplete: false
431+
}, {
432+
key: 'provisionalData',
433+
isComplete: true
411434
}, {
412435
key: 's3Files',
413436
isComplete: false
@@ -430,6 +453,28 @@ var getInitialStateFromProps = function getInitialStateFromProps(props) {
430453
return step.key === 'packageType';
431454
}), 1);
432455
}
456+
// Remove provisional data step if release specified and is not a non-release
457+
var hasRelease = (0, _typeUtil.isStringNonEmpty)(release);
458+
var excludeProvisionalStep = hasRelease && !_ReleaseService.default.isNonRelease(release);
459+
var hasProvisionalDataStep = requiredSteps.some(function (step) {
460+
return step.key === 'provisionalData';
461+
});
462+
var hasProvisionalData = false;
463+
if ((0, _typeUtil.exists)(productData) && (0, _typeUtil.existsNonEmpty)(productData.siteCodes)) {
464+
hasProvisionalData = productData.siteCodes.some(function (siteCode) {
465+
if (!(0, _typeUtil.existsNonEmpty)(siteCode.availableReleases)) {
466+
return false;
467+
}
468+
return siteCode.availableReleases.some(function (availableRelease) {
469+
return _ReleaseService.default.isProv(availableRelease.release) && (0, _typeUtil.existsNonEmpty)(availableRelease.availableMonths);
470+
});
471+
});
472+
}
473+
if (hasProvisionalDataStep && excludeProvisionalStep || hasProvisionalDataStep && !hasProvisionalData) {
474+
requiredSteps.splice(requiredSteps.findIndex(function (step) {
475+
return step.key === 'provisionalData';
476+
}), 1);
477+
}
433478
initialState.requiredSteps = requiredSteps;
434479
initialState.fromManifest = fromManifest;
435480
initialState.fromAOPManifest = fromAOPManifest;
@@ -1201,7 +1246,11 @@ Provider.propTypes = {
12011246
productName: _propTypes.default.string.isRequired,
12021247
siteCodes: _propTypes.default.arrayOf(_propTypes.default.shape({
12031248
siteCode: _propTypes.default.string.isRequired,
1204-
availableMonths: _propTypes.default.arrayOf(_propTypes.default.string).isRequired
1249+
availableMonths: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
1250+
availableReleases: _propTypes.default.arrayOf(_propTypes.default.shape({
1251+
release: _propTypes.default.string.isRequired,
1252+
availableMonths: _propTypes.default.arrayOf(_propTypes.default.string).isRequired
1253+
}))
12051254
}))
12061255
}),
12071256
/* eslint-disable react/no-unused-prop-types */
@@ -1211,6 +1260,7 @@ Provider.propTypes = {
12111260
dateRange: _propTypes.default.arrayOf(_propTypes.default.string),
12121261
documentation: _propTypes.default.oneOf(ALL_POSSIBLE_VALID_DOCUMENTATION),
12131262
packageType: _propTypes.default.oneOf(ALL_POSSIBLE_VALID_PACKAGE_TYPE),
1263+
provisionalData: _propTypes.default.oneOf(ALL_POSSIBLE_VALID_PROVISIONAL_DATA),
12141264
/* eslint-enable react/no-unused-prop-types */
12151265
children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string])), _propTypes.default.node, _propTypes.default.string]).isRequired
12161266
};
@@ -1223,7 +1273,8 @@ Provider.defaultProps = {
12231273
sites: DEFAULT_STATE.sites.value,
12241274
dateRange: DEFAULT_STATE.dateRange.value,
12251275
documentation: DEFAULT_STATE.documentation.value,
1226-
packageType: DEFAULT_STATE.packageType.value
1276+
packageType: DEFAULT_STATE.packageType.value,
1277+
provisionalData: DEFAULT_STATE.provisionalData.value
12271278
};
12281279
var DownloadDataContext = {
12291280
Provider: Provider,
@@ -1251,7 +1302,8 @@ var getTestableItems = function getTestableItems() {
12511302
getAndValidateNewState: getAndValidateNewState,
12521303
ALL_POSSIBLE_VALID_DATE_RANGE: ALL_POSSIBLE_VALID_DATE_RANGE,
12531304
ALL_POSSIBLE_VALID_DOCUMENTATION: ALL_POSSIBLE_VALID_DOCUMENTATION,
1254-
ALL_POSSIBLE_VALID_PACKAGE_TYPE: ALL_POSSIBLE_VALID_PACKAGE_TYPE
1305+
ALL_POSSIBLE_VALID_PACKAGE_TYPE: ALL_POSSIBLE_VALID_PACKAGE_TYPE,
1306+
ALL_POSSIBLE_VALID_PROVISIONAL_DATA: ALL_POSSIBLE_VALID_PROVISIONAL_DATA
12551307
};
12561308
};
12571309
exports.getTestableItems = getTestableItems;

0 commit comments

Comments
 (0)