Skip to content

Commit 52719a7

Browse files
authored
v2.4.0 (#66)
* allow ameriflux external host with no NEON data * update drupal assets * prepare v2.4.0 * revert upgrade branch asset testing
1 parent a6ddc8c commit 52719a7

File tree

18 files changed

+217
-60
lines changed

18 files changed

+217
-60
lines changed

lib/components/DownloadDataContext/DownloadDataContext.js

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ var _rxUtil = require("../../util/rxUtil");
1515
var _StateStorageService = _interopRequireDefault(require("../../service/StateStorageService"));
1616
var _NeonSignInButtonState = _interopRequireDefault(require("../NeonSignInButton/NeonSignInButtonState"));
1717
var _StateStorageConverter = require("./StateStorageConverter");
18+
var _typeUtil = require("../../util/typeUtil");
1819
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
1920
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); }
2021
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; }
@@ -203,7 +204,18 @@ var S3_PATTERN = {
203204
// VALIDATOR FUNCTIONS
204205
// Naive check, replace with a more robust JSON schema check
205206
var productDataIsValid = function productDataIsValid(productData) {
206-
return _typeof(productData) === 'object' && productData !== null && typeof productData.productName === 'string' && Array.isArray(productData.siteCodes);
207+
if (_typeof(productData) !== 'object' || productData === null || typeof productData.productName !== 'string') {
208+
return false;
209+
}
210+
var hasSiteCodes = Array.isArray(productData.siteCodes);
211+
if (!hasSiteCodes) {
212+
var externalHost = _ExternalHost.default.getByProductCode(productData.productCode);
213+
if ((0, _typeUtil.exists)(externalHost)) {
214+
var externalHostProduct = _ExternalHost.default.getProductSpecificInfo(productData.productCode);
215+
return (0, _typeUtil.exists)(externalHostProduct) && externalHostProduct.allowNoAvailability === true;
216+
}
217+
}
218+
return hasSiteCodes;
207219
};
208220
var yearMonthIsValid = function yearMonthIsValid() {
209221
var yearMonth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
@@ -378,19 +390,17 @@ var getInitialStateFromProps = function getInitialStateFromProps(props) {
378390
var fromAOPManifest = false;
379391
var fromExternalHost = false;
380392
var externalHost = _ExternalHost.default.getByProductCode(productData.productCode);
393+
var externalHostProduct = _ExternalHost.default.getProductSpecificInfo(productData.productCode);
381394
if (externalHost) {
382-
switch (externalHost.hostType) {
383-
case 'EXCLUSIVE_DATA':
384-
fromManifest = false;
385-
fromExternalHost = true;
386-
requiredSteps = [{
387-
key: 'externalExclusive',
388-
isComplete: null
389-
}];
390-
break;
391-
default:
392-
fromExternalHost = true;
393-
break;
395+
fromExternalHost = true;
396+
var allowNoAvailability = externalHostProduct.allowNoAvailability === true;
397+
var useExternalExclusiveData = externalHost.hostType === _ExternalHost.default.HOST_TYPES.EXCLUSIVE_DATA || allowNoAvailability && !(0, _typeUtil.existsNonEmpty)(productData.siteCodes);
398+
if (useExternalExclusiveData) {
399+
fromManifest = false;
400+
requiredSteps = [{
401+
key: 'externalExclusive',
402+
isComplete: null
403+
}];
394404
}
395405
} else if (isAOPPipeline) {
396406
fromManifest = false;

lib/components/DownloadStepForm/DownloadStepForm.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ var _Theme = _interopRequireWildcard(require("../Theme/Theme"));
4747
var _ReleaseService = _interopRequireDefault(require("../../service/ReleaseService"));
4848
var _RouteService = _interopRequireDefault(require("../../service/RouteService"));
4949
var _manifestUtil = require("../../util/manifestUtil");
50+
var _typeUtil = require("../../util/typeUtil");
5051
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
5152
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); }
5253
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; }
@@ -671,14 +672,24 @@ function DownloadStepForm(props) {
671672
var availableSiteCodes = (state.productData.siteCodes || []).map(function (site) {
672673
return site.siteCode;
673674
});
675+
var externalHostProduct = _ExternalHost.default.getProductSpecificInfo(state.productData.productCode);
676+
var allowNoAvailability = (0, _typeUtil.exists)(externalHostProduct) && externalHostProduct.allowNoAvailability === true;
677+
var noData = !(0, _typeUtil.existsNonEmpty)(availableSiteCodes);
678+
var noLinks = allowNoAvailability && noData;
679+
var blurb;
680+
if (noLinks) {
681+
blurb = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Data for this product is not currently available for download through the NEON Data Portal. Please use this link to access data for this product for a particular site from ", hostLink, ".");
682+
} else {
683+
blurb = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "Data for this product is not currently available for download through the NEON Data Portal. Please use the links below to access data for this product for a particular site from the ", hostLink, ".");
684+
}
674685
return /*#__PURE__*/_react.default.createElement("div", {
675686
"data-selenium": "download-data-dialog.step-form.external-links.".concat(externalHost.id.toLowerCase())
676687
}, /*#__PURE__*/_react.default.createElement(_InfoMessageCard.default, {
677688
title: "External Host",
678689
messageContent: /*#__PURE__*/_react.default.createElement(_Typography.default, {
679690
variant: "subtitle2"
680-
}, "Data for this product is not currently available for download through the NEON Data Portal. Please use the links below to access data for this product for a particular site from the ", hostLink, ".")
681-
}), /*#__PURE__*/_react.default.createElement(_ExternalHostProductSpecificLinks.default, {
691+
}, blurb)
692+
}), noLinks ? null : /*#__PURE__*/_react.default.createElement(_ExternalHostProductSpecificLinks.default, {
682693
productCode: state.productData.productCode,
683694
siteCodes: availableSiteCodes
684695
}));

lib/components/ExternalHost/ExternalHost.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ declare namespace ExternalHost {
44
export { LINK_TYPES };
55
export { getByHostId };
66
export { getByProductCode };
7+
export { getProductSpecificInfo };
78
export { renderExternalHostLink };
89
}
910
declare namespace HOST_TYPES {
@@ -17,4 +18,5 @@ declare namespace LINK_TYPES {
1718
}
1819
declare function getByHostId(hostId?: string): any;
1920
declare function getByProductCode(productCode?: string): any;
21+
declare function getProductSpecificInfo(productCode?: string): any;
2022
declare function renderExternalHostLink(href?: string, text?: string, host?: string, productCode?: string): JSX.Element;

lib/components/ExternalHost/ExternalHost.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ var externalProducts = {
138138
title: 'Fish sequences DNA barcode'
139139
}]
140140
},
141+
'DP2.00006.001': {
142+
host: 'AMERIFLUX',
143+
allowNoAvailability: true
144+
},
145+
'DP2.00020.001': {
146+
host: 'AMERIFLUX',
147+
allowNoAvailability: true
148+
},
149+
'DP2.00023.001': {
150+
host: 'AMERIFLUX',
151+
allowNoAvailability: true
152+
},
141153
'DP4.00002.001': {
142154
host: 'AMERIFLUX'
143155
},
@@ -334,11 +346,16 @@ var getByProductCode = function getByProductCode() {
334346
var productCode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
335347
return externalProducts[productCode] ? externalHosts[externalProducts[productCode].host] : null;
336348
};
349+
var getProductSpecificInfo = function getProductSpecificInfo() {
350+
var productCode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
351+
return externalProducts[productCode] ? externalProducts[productCode] : null;
352+
};
337353
var ExternalHost = {
338354
HOST_TYPES: HOST_TYPES,
339355
LINK_TYPES: LINK_TYPES,
340356
getByHostId: getByHostId,
341357
getByProductCode: getByProductCode,
358+
getProductSpecificInfo: getProductSpecificInfo,
342359
renderExternalHostLink: renderExternalHostLink
343360
};
344361
var _default = ExternalHost;

lib/components/ExternalHostInfo/ExternalHostInfo.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var _InfoMessageCard = _interopRequireDefault(require("../Card/InfoMessageCard")
1818
var _ExternalHost = _interopRequireDefault(require("../ExternalHost/ExternalHost"));
1919
var _ExternalHostProductSpecificLinks = _interopRequireDefault(require("../ExternalHostProductSpecificLinks/ExternalHostProductSpecificLinks"));
2020
var _Theme = _interopRequireDefault(require("../Theme/Theme"));
21+
var _typeUtil = require("../../util/typeUtil");
2122
var _excluded = ["productCode", "expandable", "siteCodes"];
2223
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2324
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); }
@@ -53,13 +54,15 @@ var ExternalHostInfo = function ExternalHostInfo(props) {
5354
expanded = _useState2[0],
5455
setExpanded = _useState2[1];
5556
var externalHost = _ExternalHost.default.getByProductCode(productCode);
57+
var externalHostProduct = _ExternalHost.default.getProductSpecificInfo(productCode);
5658
if (!externalHost) {
5759
return null;
5860
}
5961

6062
// Not only _should_ the info have specific links (links in addition to the top-level
6163
// one for the host), but _does_ it?
6264
var hasSpecificLinks = externalHost.linkType === _ExternalHost.default.LINK_TYPES.BY_PRODUCT && externalHost.getProductLinks(productCode).length || externalHost.linkType === _ExternalHost.default.LINK_TYPES.BY_SITE;
65+
var allowNoLinks = hasSpecificLinks && externalHostProduct.allowNoAvailability === true && !(0, _typeUtil.existsNonEmpty)(siteCodes);
6366

6467
// Remaining setup
6568
var externalGeneralLink = externalHost.renderLink(productCode);
@@ -75,7 +78,7 @@ var ExternalHostInfo = function ExternalHostInfo(props) {
7578
if (externalHost.hostType === _ExternalHost.default.HOST_TYPES.REFORMATTED_DATA) {
7679
blurb = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "".concat(dataVariety, " for this product are available in other formats from"), "\xA0", externalGeneralLink);
7780
}
78-
if (externalHost.hostType === _ExternalHost.default.HOST_TYPES.EXCLUSIVE_DATA) {
81+
if (externalHost.hostType === _ExternalHost.default.HOST_TYPES.EXCLUSIVE_DATA || allowNoLinks) {
7982
blurb = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "".concat(dataVariety, " for this product are only available from"), "\xA0", externalGeneralLink);
8083
}
8184
// Default: ExternalHost.HOST_TYPES.ADDITIONAL_DATA:
@@ -95,7 +98,7 @@ var ExternalHostInfo = function ExternalHostInfo(props) {
9598
style: {
9699
flexGrow: 1
97100
}
98-
}, blurb), hasSpecificLinks && expandable ? /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
101+
}, blurb), hasSpecificLinks && expandable && !allowNoLinks ? /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
99102
title: expandTitle
100103
}, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
101104
"aria-label": expandTitle,
@@ -107,7 +110,7 @@ var ExternalHostInfo = function ExternalHostInfo(props) {
107110
}
108111
}, expanded ? /*#__PURE__*/_react.default.createElement(_ExpandLess.default, null) : /*#__PURE__*/_react.default.createElement(_ExpandMore.default, null))) : null), /*#__PURE__*/_react.default.createElement("div", {
109112
style: {
110-
display: hasSpecificLinks && expanded ? 'block' : 'none'
113+
display: hasSpecificLinks && expanded && !allowNoLinks ? 'block' : 'none'
111114
}
112115
}, /*#__PURE__*/_react.default.createElement(_ExternalHostProductSpecificLinks.default, {
113116
productCode: productCode,

lib/remoteAssets/drupal-header.html.d.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/remoteAssets/drupal-header.html.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "portal-core-components",
3-
"version": "2.3.0",
3+
"version": "2.4.0",
44
"main": "./lib/index.js",
55
"private": true,
66
"homepage": "http://localhost:3010/core-components",

public/assets/css/drupal-theme.98af391f0797dc8df157fb52a8a37b1d.min.css

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)