Skip to content

Commit

Permalink
v2.5.0 (#67)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sampsonj authored Oct 19, 2023
1 parent 52719a7 commit 87f6fd6
Show file tree
Hide file tree
Showing 25 changed files with 2,192 additions and 79 deletions.
58 changes: 50 additions & 8 deletions lib/components/DownloadDataContext/DownloadDataContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function getTestableItems(): {
ALL_POSSIBLE_VALID_DATE_RANGE?: undefined;
ALL_POSSIBLE_VALID_DOCUMENTATION?: undefined;
ALL_POSSIBLE_VALID_PACKAGE_TYPE?: undefined;
ALL_POSSIBLE_VALID_PROVISIONAL_DATA?: undefined;
} | {
productDataIsValid: (productData: any) => boolean;
yearMonthIsValid: (yearMonth?: string) => boolean;
Expand Down Expand Up @@ -93,6 +94,11 @@ export function getTestableItems(): {
validValues: string[];
isValid: boolean;
};
provisionalData: {
value: string;
validValues: string[];
isValid: boolean;
};
policies: {
value: boolean;
validValues: null;
Expand All @@ -106,6 +112,7 @@ export function getTestableItems(): {
ALL_POSSIBLE_VALID_DATE_RANGE: string[];
ALL_POSSIBLE_VALID_DOCUMENTATION: string[];
ALL_POSSIBLE_VALID_PACKAGE_TYPE: string[];
ALL_POSSIBLE_VALID_PROVISIONAL_DATA: string[];
};
declare namespace DownloadDataContext {
export { Provider };
Expand All @@ -126,6 +133,10 @@ declare namespace Provider {
siteCodes: PropTypes.Requireable<(PropTypes.InferProps<{
siteCode: PropTypes.Validator<string>;
availableMonths: PropTypes.Validator<(string | null | undefined)[]>;
availableReleases: PropTypes.Requireable<(PropTypes.InferProps<{
release: PropTypes.Validator<string>;
availableMonths: PropTypes.Validator<(string | null | undefined)[]>;
}> | null | undefined)[]>;
}> | null | undefined)[]>;
}>>;
const availabilityView: PropTypes.Requireable<string>;
Expand All @@ -134,6 +145,7 @@ declare namespace Provider {
const dateRange: PropTypes.Requireable<(string | null | undefined)[]>;
const documentation: PropTypes.Requireable<string>;
const packageType: PropTypes.Requireable<string>;
const provisionalData: PropTypes.Requireable<string>;
const children: PropTypes.Validator<NonNullable<NonNullable<PropTypes.ReactNodeLike>>>;
}
namespace defaultProps {
Expand All @@ -155,6 +167,8 @@ declare namespace Provider {
export { documentation_1 as documentation };
import packageType_1 = value;
export { packageType_1 as packageType };
import provisionalData_1 = value;
export { provisionalData_1 as provisionalData };
}
}
declare function useDownloadDataState(): {
Expand Down Expand Up @@ -227,6 +241,11 @@ declare function useDownloadDataState(): {
validValues: string[];
isValid: boolean;
};
provisionalData: {
value: string;
validValues: string[];
isValid: boolean;
};
policies: {
value: boolean;
validValues: null;
Expand Down Expand Up @@ -302,6 +321,11 @@ declare function useDownloadDataState(): {
validValues: string[];
isValid: boolean;
};
provisionalData: {
value: string;
validValues: string[];
isValid: boolean;
};
policies: {
value: boolean;
validValues: null;
Expand Down Expand Up @@ -406,14 +430,23 @@ declare namespace DEFAULT_STATE {
export { isValid_5 as isValid };
}
export { packageType_2 as packageType };
export namespace policies {
const value_7: boolean;
export namespace provisionalData_2 {
const value_7: string;
export { value_7 as value };
const validValues_6: null;
const validValues_6: string[];
export { validValues_6 as validValues };
const isValid_6: boolean;
export { isValid_6 as isValid };
}
export { provisionalData_2 as provisionalData };
export namespace policies {
const value_8: boolean;
export { value_8 as value };
const validValues_7: null;
export { validValues_7 as validValues };
const isValid_7: boolean;
export { isValid_7 as isValid };
}
}
declare namespace ALL_STEPS {
export namespace documentation_3 {
Expand Down Expand Up @@ -446,31 +479,40 @@ declare namespace ALL_STEPS {
export { title_2 as title };
}
export { packageType_3 as packageType };
export namespace sitesAndDateRange {
export namespace provisionalData_3 {
const requiredStateKeys_4: string[];
export { requiredStateKeys_4 as requiredStateKeys };
const label_4: string;
export { label_4 as label };
const title_3: string;
export { title_3 as title };
}
export namespace policies_1 {
export { provisionalData_3 as provisionalData };
export namespace sitesAndDateRange {
const requiredStateKeys_5: string[];
export { requiredStateKeys_5 as requiredStateKeys };
const label_5: string;
export { label_5 as label };
const title_4: string;
export { title_4 as title };
}
export { policies_1 as policies };
export namespace summary {
const requiredStateKeys_6: never[];
export namespace policies_1 {
const requiredStateKeys_6: string[];
export { requiredStateKeys_6 as requiredStateKeys };
const label_6: string;
export { label_6 as label };
const title_5: string;
export { title_5 as title };
}
export { policies_1 as policies };
export namespace summary {
const requiredStateKeys_7: never[];
export { requiredStateKeys_7 as requiredStateKeys };
const label_7: string;
export { label_7 as label };
const title_6: string;
export { title_6 as title };
}
}
declare function getStateObservable(): import("rxjs").Observable<any>;
import PropTypes from "prop-types";
66 changes: 59 additions & 7 deletions lib/components/DownloadDataContext/DownloadDataContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ var _manifestUtil = require("../../util/manifestUtil");
var _rxUtil = require("../../util/rxUtil");
var _StateStorageService = _interopRequireDefault(require("../../service/StateStorageService"));
var _NeonSignInButtonState = _interopRequireDefault(require("../NeonSignInButton/NeonSignInButtonState"));
var _ReleaseService = _interopRequireDefault(require("../../service/ReleaseService"));
var _StateStorageConverter = require("./StateStorageConverter");
var _typeUtil = require("../../util/typeUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
Expand All @@ -34,6 +35,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
var ALL_POSSIBLE_VALID_DATE_RANGE = ['2010-01', (0, _moment.default)().format('YYYY-MM')];
var ALL_POSSIBLE_VALID_DOCUMENTATION = ['include', 'exclude'];
var ALL_POSSIBLE_VALID_PACKAGE_TYPE = ['basic', 'expanded'];
var ALL_POSSIBLE_VALID_PROVISIONAL_DATA = ['include', 'exclude'];
var AVAILABILITY_VIEW_MODES = ['summary', 'sites', 'states', 'domains'];
var ALL_STEPS = {
documentation: {
Expand All @@ -55,6 +57,11 @@ var ALL_STEPS = {
label: 'Package Type',
title: 'Which package type do you want?'
},
provisionalData: {
requiredStateKeys: ['provisionalData'],
label: 'Provisional Data',
title: 'Do you want to include provisional data?'
},
sitesAndDateRange: {
requiredStateKeys: ['sites', 'dateRange'],
label: 'Sites and Date Range',
Expand All @@ -79,11 +86,14 @@ var DEFAULT_REQUIRED_STEPS = [{
key: 'sitesAndDateRange',
isComplete: false
}, {
key: 'documentation',
key: 'provisionalData',
isComplete: true
}, {
key: 'packageType',
isComplete: false
}, {
key: 'documentation',
isComplete: true
}, {
key: 'policies',
isComplete: false
Expand Down Expand Up @@ -171,6 +181,11 @@ var DEFAULT_STATE = {
validValues: [].concat(ALL_POSSIBLE_VALID_PACKAGE_TYPE),
isValid: false
},
provisionalData: {
value: 'exclude',
validValues: [].concat(ALL_POSSIBLE_VALID_PROVISIONAL_DATA),
isValid: true
},
policies: {
value: false,
validValues: null,
Expand All @@ -179,15 +194,15 @@ var DEFAULT_STATE = {
};

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

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

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

// Regexes and associated capture group names for parse s3 file names and URLs
var S3_PATTERN = {
Expand Down Expand Up @@ -249,6 +264,8 @@ var newStateIsAllowable = function newStateIsAllowable(key, value) {
return ALL_POSSIBLE_VALID_DOCUMENTATION.includes(value) || value === null;
case 'packageType':
return ALL_POSSIBLE_VALID_PACKAGE_TYPE.includes(value) || value === null;
case 'provisionalData':
return ALL_POSSIBLE_VALID_PROVISIONAL_DATA.includes(value) || value === null;
case 's3Files':
return Array.isArray(value) && value.every(function (id) {
return typeof id === 'string';
Expand Down Expand Up @@ -347,6 +364,8 @@ var getValidValuesFromProductData = function getValidValuesFromProductData(produ
return [].concat(ALL_POSSIBLE_VALID_DOCUMENTATION);
case 'packageType':
return [].concat(ALL_POSSIBLE_VALID_PACKAGE_TYPE);
case 'provisionalData':
return [].concat(ALL_POSSIBLE_VALID_PROVISIONAL_DATA);
case 'policies':
return null;
default:
Expand All @@ -360,7 +379,8 @@ var getValidValuesFromProductData = function getValidValuesFromProductData(produ
var getInitialStateFromProps = function getInitialStateFromProps(props) {
// Handle base product data
var productData = props.productData,
availabilityView = props.availabilityView;
availabilityView = props.availabilityView,
release = props.release;
if (!productDataIsValid(productData)) {
return _extends({}, DEFAULT_STATE, {
availabilityView: availabilityView,
Expand Down Expand Up @@ -408,6 +428,9 @@ var getInitialStateFromProps = function getInitialStateFromProps(props) {
requiredSteps = [{
key: 'sitesAndDateRange',
isComplete: false
}, {
key: 'provisionalData',
isComplete: true
}, {
key: 's3Files',
isComplete: false
Expand All @@ -430,6 +453,28 @@ var getInitialStateFromProps = function getInitialStateFromProps(props) {
return step.key === 'packageType';
}), 1);
}
// Remove provisional data step if release specified and is not a non-release
var hasRelease = (0, _typeUtil.isStringNonEmpty)(release);
var excludeProvisionalStep = hasRelease && !_ReleaseService.default.isNonRelease(release);
var hasProvisionalDataStep = requiredSteps.some(function (step) {
return step.key === 'provisionalData';
});
var hasProvisionalData = false;
if ((0, _typeUtil.exists)(productData) && (0, _typeUtil.existsNonEmpty)(productData.siteCodes)) {
hasProvisionalData = productData.siteCodes.some(function (siteCode) {
if (!(0, _typeUtil.existsNonEmpty)(siteCode.availableReleases)) {
return false;
}
return siteCode.availableReleases.some(function (availableRelease) {
return _ReleaseService.default.isProv(availableRelease.release) && (0, _typeUtil.existsNonEmpty)(availableRelease.availableMonths);
});
});
}
if (hasProvisionalDataStep && excludeProvisionalStep || hasProvisionalDataStep && !hasProvisionalData) {
requiredSteps.splice(requiredSteps.findIndex(function (step) {
return step.key === 'provisionalData';
}), 1);
}
initialState.requiredSteps = requiredSteps;
initialState.fromManifest = fromManifest;
initialState.fromAOPManifest = fromAOPManifest;
Expand Down Expand Up @@ -1201,7 +1246,11 @@ Provider.propTypes = {
productName: _propTypes.default.string.isRequired,
siteCodes: _propTypes.default.arrayOf(_propTypes.default.shape({
siteCode: _propTypes.default.string.isRequired,
availableMonths: _propTypes.default.arrayOf(_propTypes.default.string).isRequired
availableMonths: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
availableReleases: _propTypes.default.arrayOf(_propTypes.default.shape({
release: _propTypes.default.string.isRequired,
availableMonths: _propTypes.default.arrayOf(_propTypes.default.string).isRequired
}))
}))
}),
/* eslint-disable react/no-unused-prop-types */
Expand All @@ -1211,6 +1260,7 @@ Provider.propTypes = {
dateRange: _propTypes.default.arrayOf(_propTypes.default.string),
documentation: _propTypes.default.oneOf(ALL_POSSIBLE_VALID_DOCUMENTATION),
packageType: _propTypes.default.oneOf(ALL_POSSIBLE_VALID_PACKAGE_TYPE),
provisionalData: _propTypes.default.oneOf(ALL_POSSIBLE_VALID_PROVISIONAL_DATA),
/* eslint-enable react/no-unused-prop-types */
children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string])), _propTypes.default.node, _propTypes.default.string]).isRequired
};
Expand All @@ -1223,7 +1273,8 @@ Provider.defaultProps = {
sites: DEFAULT_STATE.sites.value,
dateRange: DEFAULT_STATE.dateRange.value,
documentation: DEFAULT_STATE.documentation.value,
packageType: DEFAULT_STATE.packageType.value
packageType: DEFAULT_STATE.packageType.value,
provisionalData: DEFAULT_STATE.provisionalData.value
};
var DownloadDataContext = {
Provider: Provider,
Expand Down Expand Up @@ -1251,7 +1302,8 @@ var getTestableItems = function getTestableItems() {
getAndValidateNewState: getAndValidateNewState,
ALL_POSSIBLE_VALID_DATE_RANGE: ALL_POSSIBLE_VALID_DATE_RANGE,
ALL_POSSIBLE_VALID_DOCUMENTATION: ALL_POSSIBLE_VALID_DOCUMENTATION,
ALL_POSSIBLE_VALID_PACKAGE_TYPE: ALL_POSSIBLE_VALID_PACKAGE_TYPE
ALL_POSSIBLE_VALID_PACKAGE_TYPE: ALL_POSSIBLE_VALID_PACKAGE_TYPE,
ALL_POSSIBLE_VALID_PROVISIONAL_DATA: ALL_POSSIBLE_VALID_PROVISIONAL_DATA
};
};
exports.getTestableItems = getTestableItems;
Loading

0 comments on commit 87f6fd6

Please sign in to comment.