Skip to content

Commit

Permalink
v2.4.0 (#66)
Browse files Browse the repository at this point in the history
* allow ameriflux external host with no NEON data

* update drupal assets

* prepare v2.4.0

* revert upgrade branch asset testing
  • Loading branch information
sampsonj authored Oct 3, 2023
1 parent a6ddc8c commit 52719a7
Show file tree
Hide file tree
Showing 18 changed files with 217 additions and 60 deletions.
36 changes: 23 additions & 13 deletions lib/components/DownloadDataContext/DownloadDataContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var _rxUtil = require("../../util/rxUtil");
var _StateStorageService = _interopRequireDefault(require("../../service/StateStorageService"));
var _NeonSignInButtonState = _interopRequireDefault(require("../NeonSignInButton/NeonSignInButtonState"));
var _StateStorageConverter = require("./StateStorageConverter");
var _typeUtil = require("../../util/typeUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
Expand Down Expand Up @@ -203,7 +204,18 @@ var S3_PATTERN = {
// VALIDATOR FUNCTIONS
// Naive check, replace with a more robust JSON schema check
var productDataIsValid = function productDataIsValid(productData) {
return _typeof(productData) === 'object' && productData !== null && typeof productData.productName === 'string' && Array.isArray(productData.siteCodes);
if (_typeof(productData) !== 'object' || productData === null || typeof productData.productName !== 'string') {
return false;
}
var hasSiteCodes = Array.isArray(productData.siteCodes);
if (!hasSiteCodes) {
var externalHost = _ExternalHost.default.getByProductCode(productData.productCode);
if ((0, _typeUtil.exists)(externalHost)) {
var externalHostProduct = _ExternalHost.default.getProductSpecificInfo(productData.productCode);
return (0, _typeUtil.exists)(externalHostProduct) && externalHostProduct.allowNoAvailability === true;
}
}
return hasSiteCodes;
};
var yearMonthIsValid = function yearMonthIsValid() {
var yearMonth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
Expand Down Expand Up @@ -378,19 +390,17 @@ var getInitialStateFromProps = function getInitialStateFromProps(props) {
var fromAOPManifest = false;
var fromExternalHost = false;
var externalHost = _ExternalHost.default.getByProductCode(productData.productCode);
var externalHostProduct = _ExternalHost.default.getProductSpecificInfo(productData.productCode);
if (externalHost) {
switch (externalHost.hostType) {
case 'EXCLUSIVE_DATA':
fromManifest = false;
fromExternalHost = true;
requiredSteps = [{
key: 'externalExclusive',
isComplete: null
}];
break;
default:
fromExternalHost = true;
break;
fromExternalHost = true;
var allowNoAvailability = externalHostProduct.allowNoAvailability === true;
var useExternalExclusiveData = externalHost.hostType === _ExternalHost.default.HOST_TYPES.EXCLUSIVE_DATA || allowNoAvailability && !(0, _typeUtil.existsNonEmpty)(productData.siteCodes);
if (useExternalExclusiveData) {
fromManifest = false;
requiredSteps = [{
key: 'externalExclusive',
isComplete: null
}];
}
} else if (isAOPPipeline) {
fromManifest = false;
Expand Down
15 changes: 13 additions & 2 deletions lib/components/DownloadStepForm/DownloadStepForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var _Theme = _interopRequireWildcard(require("../Theme/Theme"));
var _ReleaseService = _interopRequireDefault(require("../../service/ReleaseService"));
var _RouteService = _interopRequireDefault(require("../../service/RouteService"));
var _manifestUtil = require("../../util/manifestUtil");
var _typeUtil = require("../../util/typeUtil");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
Expand Down Expand Up @@ -671,14 +672,24 @@ function DownloadStepForm(props) {
var availableSiteCodes = (state.productData.siteCodes || []).map(function (site) {
return site.siteCode;
});
var externalHostProduct = _ExternalHost.default.getProductSpecificInfo(state.productData.productCode);
var allowNoAvailability = (0, _typeUtil.exists)(externalHostProduct) && externalHostProduct.allowNoAvailability === true;
var noData = !(0, _typeUtil.existsNonEmpty)(availableSiteCodes);
var noLinks = allowNoAvailability && noData;
var blurb;
if (noLinks) {
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, ".");
} else {
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, ".");
}
return /*#__PURE__*/_react.default.createElement("div", {
"data-selenium": "download-data-dialog.step-form.external-links.".concat(externalHost.id.toLowerCase())
}, /*#__PURE__*/_react.default.createElement(_InfoMessageCard.default, {
title: "External Host",
messageContent: /*#__PURE__*/_react.default.createElement(_Typography.default, {
variant: "subtitle2"
}, "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, ".")
}), /*#__PURE__*/_react.default.createElement(_ExternalHostProductSpecificLinks.default, {
}, blurb)
}), noLinks ? null : /*#__PURE__*/_react.default.createElement(_ExternalHostProductSpecificLinks.default, {
productCode: state.productData.productCode,
siteCodes: availableSiteCodes
}));
Expand Down
2 changes: 2 additions & 0 deletions lib/components/ExternalHost/ExternalHost.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ declare namespace ExternalHost {
export { LINK_TYPES };
export { getByHostId };
export { getByProductCode };
export { getProductSpecificInfo };
export { renderExternalHostLink };
}
declare namespace HOST_TYPES {
Expand All @@ -17,4 +18,5 @@ declare namespace LINK_TYPES {
}
declare function getByHostId(hostId?: string): any;
declare function getByProductCode(productCode?: string): any;
declare function getProductSpecificInfo(productCode?: string): any;
declare function renderExternalHostLink(href?: string, text?: string, host?: string, productCode?: string): JSX.Element;
17 changes: 17 additions & 0 deletions lib/components/ExternalHost/ExternalHost.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ var externalProducts = {
title: 'Fish sequences DNA barcode'
}]
},
'DP2.00006.001': {
host: 'AMERIFLUX',
allowNoAvailability: true
},
'DP2.00020.001': {
host: 'AMERIFLUX',
allowNoAvailability: true
},
'DP2.00023.001': {
host: 'AMERIFLUX',
allowNoAvailability: true
},
'DP4.00002.001': {
host: 'AMERIFLUX'
},
Expand Down Expand Up @@ -334,11 +346,16 @@ var getByProductCode = function getByProductCode() {
var productCode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
return externalProducts[productCode] ? externalHosts[externalProducts[productCode].host] : null;
};
var getProductSpecificInfo = function getProductSpecificInfo() {
var productCode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
return externalProducts[productCode] ? externalProducts[productCode] : null;
};
var ExternalHost = {
HOST_TYPES: HOST_TYPES,
LINK_TYPES: LINK_TYPES,
getByHostId: getByHostId,
getByProductCode: getByProductCode,
getProductSpecificInfo: getProductSpecificInfo,
renderExternalHostLink: renderExternalHostLink
};
var _default = ExternalHost;
Expand Down
9 changes: 6 additions & 3 deletions lib/components/ExternalHostInfo/ExternalHostInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var _InfoMessageCard = _interopRequireDefault(require("../Card/InfoMessageCard")
var _ExternalHost = _interopRequireDefault(require("../ExternalHost/ExternalHost"));
var _ExternalHostProductSpecificLinks = _interopRequireDefault(require("../ExternalHostProductSpecificLinks/ExternalHostProductSpecificLinks"));
var _Theme = _interopRequireDefault(require("../Theme/Theme"));
var _typeUtil = require("../../util/typeUtil");
var _excluded = ["productCode", "expandable", "siteCodes"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
Expand Down Expand Up @@ -53,13 +54,15 @@ var ExternalHostInfo = function ExternalHostInfo(props) {
expanded = _useState2[0],
setExpanded = _useState2[1];
var externalHost = _ExternalHost.default.getByProductCode(productCode);
var externalHostProduct = _ExternalHost.default.getProductSpecificInfo(productCode);
if (!externalHost) {
return null;
}

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

// Remaining setup
var externalGeneralLink = externalHost.renderLink(productCode);
Expand All @@ -75,7 +78,7 @@ var ExternalHostInfo = function ExternalHostInfo(props) {
if (externalHost.hostType === _ExternalHost.default.HOST_TYPES.REFORMATTED_DATA) {
blurb = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "".concat(dataVariety, " for this product are available in other formats from"), "\xA0", externalGeneralLink);
}
if (externalHost.hostType === _ExternalHost.default.HOST_TYPES.EXCLUSIVE_DATA) {
if (externalHost.hostType === _ExternalHost.default.HOST_TYPES.EXCLUSIVE_DATA || allowNoLinks) {
blurb = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, "".concat(dataVariety, " for this product are only available from"), "\xA0", externalGeneralLink);
}
// Default: ExternalHost.HOST_TYPES.ADDITIONAL_DATA:
Expand All @@ -95,7 +98,7 @@ var ExternalHostInfo = function ExternalHostInfo(props) {
style: {
flexGrow: 1
}
}, blurb), hasSpecificLinks && expandable ? /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
}, blurb), hasSpecificLinks && expandable && !allowNoLinks ? /*#__PURE__*/_react.default.createElement(_Tooltip.default, {
title: expandTitle
}, /*#__PURE__*/_react.default.createElement(_IconButton.default, {
"aria-label": expandTitle,
Expand All @@ -107,7 +110,7 @@ var ExternalHostInfo = function ExternalHostInfo(props) {
}
}, expanded ? /*#__PURE__*/_react.default.createElement(_ExpandLess.default, null) : /*#__PURE__*/_react.default.createElement(_ExpandMore.default, null))) : null), /*#__PURE__*/_react.default.createElement("div", {
style: {
display: hasSpecificLinks && expanded ? 'block' : 'none'
display: hasSpecificLinks && expanded && !allowNoLinks ? 'block' : 'none'
}
}, /*#__PURE__*/_react.default.createElement(_ExternalHostProductSpecificLinks.default, {
productCode: productCode,
Expand Down
2 changes: 1 addition & 1 deletion lib/remoteAssets/drupal-header.html.d.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/remoteAssets/drupal-header.html.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "portal-core-components",
"version": "2.3.0",
"version": "2.4.0",
"main": "./lib/index.js",
"private": true,
"homepage": "http://localhost:3010/core-components",
Expand Down

Large diffs are not rendered by default.

This file was deleted.

2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<link
rel="stylesheet"
data-meta="drupal-theme"
href="%PUBLIC_URL%/assets/css/drupal-theme.e17db4d4671c58da18ec4cfa8dd9d2ee.min.css"
href="%PUBLIC_URL%/assets/css/drupal-theme.98af391f0797dc8df157fb52a8a37b1d.min.css"
/>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<!-- jQuery needed for drupal header -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import makeStateStorage from '../../service/StateStorageService';
import NeonSignInButtonState from '../NeonSignInButton/NeonSignInButtonState';
// eslint-disable-next-line import/no-cycle
import { convertStateForStorage, convertAOPInitialState } from './StateStorageConverter';
import { exists, existsNonEmpty } from '../../util/typeUtil';

const ALL_POSSIBLE_VALID_DATE_RANGE = ['2010-01', moment().format('YYYY-MM')];
const ALL_POSSIBLE_VALID_DOCUMENTATION = ['include', 'exclude'];
Expand Down Expand Up @@ -195,11 +196,23 @@ const S3_PATTERN = {

// VALIDATOR FUNCTIONS
// Naive check, replace with a more robust JSON schema check
const productDataIsValid = (productData) => (
typeof productData === 'object' && productData !== null
&& typeof productData.productName === 'string'
&& Array.isArray(productData.siteCodes)
);
const productDataIsValid = (productData) => {
if ((typeof productData !== 'object')
|| (productData === null)
|| (typeof productData.productName !== 'string')) {
return false;
}
const hasSiteCodes = Array.isArray(productData.siteCodes);
if (!hasSiteCodes) {
const externalHost = ExternalHost.getByProductCode(productData.productCode);
if (exists(externalHost)) {
const externalHostProduct = ExternalHost.getProductSpecificInfo(productData.productCode);
return exists(externalHostProduct)
&& (externalHostProduct.allowNoAvailability === true);
}
}
return hasSiteCodes;
};

const yearMonthIsValid = (yearMonth = '') => {
if (typeof yearMonth !== 'string') { return false; }
Expand Down Expand Up @@ -399,18 +412,17 @@ const getInitialStateFromProps = (props) => {
let fromAOPManifest = false;
let fromExternalHost = false;
const externalHost = ExternalHost.getByProductCode(productData.productCode);
const externalHostProduct = ExternalHost.getProductSpecificInfo(productData.productCode);
if (externalHost) {
switch (externalHost.hostType) {
case 'EXCLUSIVE_DATA':
fromManifest = false;
fromExternalHost = true;
requiredSteps = [
{ key: 'externalExclusive', isComplete: null },
];
break;
default:
fromExternalHost = true;
break;
fromExternalHost = true;
const allowNoAvailability = (externalHostProduct.allowNoAvailability === true);
const useExternalExclusiveData = (externalHost.hostType === ExternalHost.HOST_TYPES.EXCLUSIVE_DATA)
|| (allowNoAvailability && !existsNonEmpty(productData.siteCodes));
if (useExternalExclusiveData) {
fromManifest = false;
requiredSteps = [
{ key: 'externalExclusive', isComplete: null },
];
}
} else if (isAOPPipeline) {
fromManifest = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import Theme, { COLORS } from '../Theme/Theme';
import ReleaseService from '../../service/ReleaseService';
import RouteService from '../../service/RouteService';
import { formatBytes, MAX_POST_BODY_SIZE } from '../../util/manifestUtil';
import { exists, existsNonEmpty } from '../../util/typeUtil';

const useStyles = makeStyles((theme) => ({
copyButton: {
Expand Down Expand Up @@ -627,24 +628,51 @@ export default function DownloadStepForm(props) {
if (!externalHost) { return null; }
const hostLink = externalHost.renderLink(state.productData.productCode);
const availableSiteCodes = (state.productData.siteCodes || []).map((site) => site.siteCode);
const externalHostProduct = ExternalHost.getProductSpecificInfo(
state.productData.productCode,
);
const allowNoAvailability = exists(externalHostProduct)
&& (externalHostProduct.allowNoAvailability === true);
const noData = !existsNonEmpty(availableSiteCodes);
const noLinks = allowNoAvailability && noData;
let blurb;
if (noLinks) {
blurb = (
<>
{/* eslint-disable react/jsx-one-expression-per-line */}
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}.
{/* eslint-enable react/jsx-one-expression-per-line */}
</>
);
} else {
blurb = (
<>
{/* eslint-disable react/jsx-one-expression-per-line */}
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}.
{/* eslint-enable react/jsx-one-expression-per-line */}
</>
);
}
return (
<div data-selenium={`download-data-dialog.step-form.external-links.${externalHost.id.toLowerCase()}`}>
<InfoMessageCard
title="External Host"
messageContent={(
<Typography variant="subtitle2">
{/* eslint-disable react/jsx-one-expression-per-line */}
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}.
{/* eslint-enable react/jsx-one-expression-per-line */}
{blurb}
</Typography>
)}
/>
<ExternalHostProductSpecificLinks
productCode={state.productData.productCode}
siteCodes={availableSiteCodes}
/>
{noLinks ? null : (
<ExternalHostProductSpecificLinks
productCode={state.productData.productCode}
siteCodes={availableSiteCodes}
/>
)}
</div>
);
},
Expand Down
Loading

0 comments on commit 52719a7

Please sign in to comment.