Skip to content

Commit

Permalink
v1.9.0 (#41)
Browse files Browse the repository at this point in the history
* Added Neon public API host variable with value pulled from server data.

* Fixed function name.

* Updates for setting public API host through server data.

* Updated valid hosts regex pattern.

* Reset NEON_SERVER_DATA

* Minor cleanup.

* Update for web socket host determination.

* Added prototype typescript environment module.

* Cleanup.

* Fixed test and cleanup.

* Removed unused variable.

* Removed file.

* site map: handle maxZoom property propagation

* site map: update mapZoom initialization to include bounds

* NeonContext final state when core auth, TS context include release

* resolve authentication state when silent SSO disabled

* Neon sign in modifications.

* Updates.

* pull out route handling to dedicated service

* fix host regex validation, update routes

* reduce .env usage

* fix account route

* fix logout redirect path handling

* Added new file.

* Updates.

* Update.

* Added subject type.

* Refactoring for NEON sign in button observer pattern.

* Create more generalized state storage service.

* Updates.

* change site type relocatable references to gradient

* Changes for persisting SiteMap state when sign in button is clicked.

* initial draft of document viewer component

* Added state persistence to TimeSeriesViewer

* Updates for DataAvailability state persistence.

* Updates from npm run lib.

* fix typo in document viewer style guide

* delineate TS state restore by key, update stored status

* Minor cleanup.

* Removed state after restore.

* Updates for state persistence with multiple instances.

* Updates after npm run lib.

* add global feature flag for sign in state save, download state save in dialog only

* propagate use of enable global sign in state

* handle AOP path in download context session storage

* Removed MG-RAST references.

* Removed MG-RAST reference.

* 1.9.0

Co-authored-by: Robert Markel <rmarkel@battelleecology.org>
  • Loading branch information
sampsonj and rmarkel-neon authored Aug 26, 2021
1 parent 7b0b5e6 commit d7405d7
Show file tree
Hide file tree
Showing 128 changed files with 3,558 additions and 1,447 deletions.
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ REACT_APP_NEON_ROUTER_BASE_HOME="/core-components"
REACT_APP_NEON_AUTH_DISABLE_WS="true"
REACT_APP_NEON_USE_GRAPHQL="true"
REACT_APP_NEON_SHOW_AOP_VIEWER="true"
REACT_APP_NEON_ENABLE_GLOBAL_SIGNIN_STATE="false"

#-------------------------------------------------------------------------------
# Third party APIs and options
Expand Down
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ REACT_APP_NEON_ROUTER_BASE_HOME="/core-components"

REACT_APP_NEON_USE_GRAPHQL="true"
REACT_APP_NEON_SHOW_AOP_VIEWER="true"
REACT_APP_NEON_ENABLE_GLOBAL_SIGNIN_STATE="false"

#-------------------------------------------------------------------------------
# Third party APIs and options
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.vscode
22 changes: 20 additions & 2 deletions lib/components/DataProductAvailability/AvailabilityContext.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ declare namespace AvailabilityContext {
declare function Provider(props: any): JSX.Element;
declare namespace Provider {
namespace propTypes {
const dataAvailabilityUniqueId: PropTypes.Requireable<number>;
const sites: PropTypes.Requireable<(PropTypes.InferProps<{
siteCode: PropTypes.Validator<string>;
tables: PropTypes.Validator<(PropTypes.InferProps<{
Expand All @@ -52,11 +53,13 @@ declare namespace Provider {
const children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
}
namespace defaultProps {
const dataAvailabilityUniqueId_1: number;
export { dataAvailabilityUniqueId_1 as dataAvailabilityUniqueId };
const sites_1: never[];
export { sites_1 as sites };
}
}
declare function useAvailabilityState(): any[] | {
declare function useAvailabilityState(): {
sites: never[];
tables: {};
rows: {};
Expand All @@ -71,7 +74,22 @@ declare function useAvailabilityState(): any[] | {
states: {};
domains: {};
};
};
} | ({
sites: never[];
tables: {};
rows: {};
rowTitles: {};
rowLabels: never[];
breakouts: never[];
validBreakouts: string[];
sortDirection: string;
neonContextHydrated: boolean;
reference: {
sites: {};
states: {};
domains: {};
};
} | (() => void))[];
declare namespace SORT_DIRECTIONS {
const ASC: string;
const DESC: string;
Expand Down
60 changes: 55 additions & 5 deletions lib/components/DataProductAvailability/AvailabilityContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));

var _NeonContext = _interopRequireDefault(require("../NeonContext/NeonContext"));

var _NeonEnvironment = _interopRequireDefault(require("../NeonEnvironment/NeonEnvironment"));

var _AvailabilityUtils = require("./AvailabilityUtils");

var _NeonSignInButtonState = _interopRequireDefault(require("../NeonSignInButton/NeonSignInButtonState"));

var _StateStorageService = _interopRequireDefault(require("../../service/StateStorageService"));

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 @@ -285,13 +291,23 @@ var useAvailabilityState = function useAvailabilityState() {

return hookResponse;
};
/**
* Defines a lookup of state key to a boolean
* designating whether or not that instance of the context
* should pull the state from the session storage and restore.
* Keeping this lookup outside of the context provider function
* as to not incur lifecycle interference by storing with useState.
*/


var restoreStateLookup = {};
/**
Context Provider
*/


var Provider = function Provider(props) {
var sites = props.sites,
dataAvailabilityUniqueId = props.dataAvailabilityUniqueId,
children = props.children;

var _NeonContext$useNeonC = _NeonContext.default.useNeonContextState(),
Expand All @@ -300,30 +316,62 @@ var Provider = function Provider(props) {
neonContextData = _NeonContext$useNeonC3.data,
neonContextIsFinal = _NeonContext$useNeonC3.isFinal,
neonContextHasError = _NeonContext$useNeonC3.hasError;

var key = "availabilityContextState-".concat(dataAvailabilityUniqueId);

if (typeof restoreStateLookup[key] === 'undefined') {
restoreStateLookup[key] = true;
}

var shouldRestoreState = restoreStateLookup[key];
var stateStorage = (0, _StateStorageService.default)(key);
var savedState = stateStorage.readState();
/**
Initial State and Reducer Setup
*/


var initialState = _extends({}, (0, _cloneDeep.default)(DEFAULT_STATE), {
sites: sites
});

initialState.tables = extractTables(initialState);

if (neonContextIsFinal && !neonContextHasError) {
if (neonContextIsFinal && !neonContextHasError && !savedState) {
initialState = hydrateNeonContextData(initialState, neonContextData);
}

if (savedState && shouldRestoreState) {
restoreStateLookup[key] = false;
stateStorage.removeState();
initialState = savedState;
}

var _useReducer = (0, _react.useReducer)(reducer, calculateRows(initialState)),
_useReducer2 = _slicedToArray(_useReducer, 2),
state = _useReducer2[0],
dispatch = _useReducer2[1];
dispatch = _useReducer2[1]; // The current sign in process uses a separate domain. This function
// persists the current state in storage when the button is clicked
// so the state may be reloaded when the page is reloaded after sign
// in.


(0, _react.useEffect)(function () {
var subscription = _NeonSignInButtonState.default.getObservable().subscribe({
next: function next() {
if (!_NeonEnvironment.default.enableGlobalSignInState) return;
restoreStateLookup[key] = false;
stateStorage.saveState(state);
}
});

return function () {
subscription.unsubscribe();
};
}, [state, stateStorage, key]);
/**
Effect - Watch for changes to NeonContext data and push into local state
*/


(0, _react.useEffect)(function () {
if (!state.neonContextHydrated && neonContextIsFinal && !neonContextHasError) {
dispatch({
Expand All @@ -342,10 +390,12 @@ var Provider = function Provider(props) {
};

Provider.propTypes = {
dataAvailabilityUniqueId: _propTypes.default.number,
sites: _AvailabilityUtils.AvailabilityPropTypes.enhancedSites,
children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string])), _propTypes.default.node, _propTypes.default.string]).isRequired
};
Provider.defaultProps = {
dataAvailabilityUniqueId: 0,
sites: []
};
/**
Expand Down
11 changes: 11 additions & 0 deletions lib/components/DataProductAvailability/StateStorageConverter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* Alter the current state for valid JSON serialization.
* @param currentState The current state
*/
declare const convertStateForStorage: (state: any) => any;
/**
* Restore the state from JSON serialization.
* @param storedState The state read from storage.
*/
declare const convertStateFromStorage: (state: any) => any;
export { convertStateForStorage, convertStateFromStorage };
125 changes: 125 additions & 0 deletions lib/components/DataProductAvailability/StateStorageConverter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});
exports.convertStateFromStorage = exports.convertStateForStorage = void 0;

var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

/**
* Alter the current state for valid JSON serialization.
* @param currentState The current state
*/
var convertStateForStorage = function convertStateForStorage(state) {
var newState = (0, _cloneDeep.default)(state); // variables
// const { variables: stateVariables } = state;
// Object.keys(stateVariables).forEach((variableKey, index) => {
// const { sites, tables, timeSteps } = stateVariables[variableKey];
// if (sites instanceof Set && sites.size > 0) {
// newState.variables[variableKey].sites = Array.from(sites);
// } else {
// newState.variables[variableKey].sites = [];
// }
// if (tables instanceof Set && sites.size > 0) {
// newState.variables[variableKey].tables = Array.from(tables);
// } else {
// newState.variables[variableKey].tables = [];
// }
// if (timeSteps instanceof Set && sites.size > 0) {
// newState.variables[variableKey].timeSteps = Array.from(timeSteps);
// } else {
// newState.variables[variableKey].timeSteps = [];
// }
// });
// // product site variables
// const { sites: productSites } = state.product;
// Object.keys(productSites).forEach((siteKey, index) => {
// const { variables: siteVariables } = productSites[siteKey];
// if (siteVariables instanceof Set && siteVariables.size > 0) {
// newState.product.sites[siteKey].variables = Array.from(siteVariables);
// } else {
// newState.product.sites[siteKey].variables = [];
// }
// });
// // available quality flags
// const { availableQualityFlags } = state;
// if (availableQualityFlags instanceof Set) {
// newState.availableQualityFlags = Array.from(availableQualityFlags);
// } else {
// newState.availableQualityFlags = [];
// }
// // available time steps
// const { availableTimeSteps } = state;
// if (availableTimeSteps instanceof Set) {
// newState.availableTimeSteps = Array.from(availableTimeSteps);
// } else {
// newState.availableTimeSteps = [];
// }

return newState;
};
/**
* Restore the state from JSON serialization.
* @param storedState The state read from storage.
*/


exports.convertStateForStorage = convertStateForStorage;

var convertStateFromStorage = function convertStateFromStorage(state) {
var newState = (0, _cloneDeep.default)(state); // // graphData data
// const data = state.graphData.data.map((entry: any) => [new Date(entry[0]), entry[1]]);
// newState.graphData.data = data;
// // state variables
// const { variables } = state;
// Object.keys(variables).forEach((key, index) => {
// const { sites, tables, timeSteps } = variables[key];
// if (Array.isArray(sites)) {
// newState.variables[key].sites = new Set(sites);
// } else {
// newState.variables[key].sites = new Set();
// }
// if (Array.isArray(tables)) {
// newState.variables[key].tables = new Set(tables);
// } else {
// newState.variables[key].tables = new Set();
// }
// if (Array.isArray(timeSteps)) {
// newState.variables[key].timeSteps = new Set(timeSteps);
// } else {
// newState.variables[key].timeSteps = new Set();
// }
// });
// // product site variables
// const { sites: productSites } = state.product;
// // get the variables for each site
// Object.keys(productSites).forEach((siteKey, index) => {
// const { variables: siteVariables } = productSites[siteKey];
// if (Array.isArray(siteVariables) && siteVariables.length > 0) {
// newState.product.sites[siteKey].variables = new Set(siteVariables);
// } else {
// newState.product.sites[siteKey].variables = new Set();
// }
// });
// // available quality flags
// const { availableQualityFlags } = state;
// if (Array.isArray(availableQualityFlags)) {
// newState.availableQualityFlags = new Set(availableQualityFlags);
// } else {
// newState.availableQualityFlags = new Set();
// }
// // available quality flags
// const { availableTimeSteps } = state;
// if (Array.isArray(availableTimeSteps)) {
// newState.availableTimeSteps = new Set(availableTimeSteps);
// } else {
// newState.availableTimeSteps = new Set();
// }

return newState;
};

exports.convertStateFromStorage = convertStateFromStorage;
8 changes: 8 additions & 0 deletions lib/components/DocumentViewer/DocumentViewer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { NeonDocument } from '../../types/neon';
export interface DocumentViewerProps {
document: NeonDocument;
width: number;
}
declare const DocumentViewer: React.FC<DocumentViewerProps>;
export default DocumentViewer;
Loading

0 comments on commit d7405d7

Please sign in to comment.