Skip to content

Commit d7405d7

Browse files
v1.9.0 (#41)
* 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 <[email protected]>
1 parent 7b0b5e6 commit d7405d7

File tree

128 files changed

+3558
-1447
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+3558
-1447
lines changed

.env.development

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ REACT_APP_NEON_ROUTER_BASE_HOME="/core-components"
2828
REACT_APP_NEON_AUTH_DISABLE_WS="true"
2929
REACT_APP_NEON_USE_GRAPHQL="true"
3030
REACT_APP_NEON_SHOW_AOP_VIEWER="true"
31+
REACT_APP_NEON_ENABLE_GLOBAL_SIGNIN_STATE="false"
3132

3233
#-------------------------------------------------------------------------------
3334
# Third party APIs and options

.env.production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ REACT_APP_NEON_ROUTER_BASE_HOME="/core-components"
2424

2525
REACT_APP_NEON_USE_GRAPHQL="true"
2626
REACT_APP_NEON_SHOW_AOP_VIEWER="true"
27+
REACT_APP_NEON_ENABLE_GLOBAL_SIGNIN_STATE="false"
2728

2829
#-------------------------------------------------------------------------------
2930
# Third party APIs and options

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@
1919
npm-debug.log*
2020
yarn-debug.log*
2121
yarn-error.log*
22+
.vscode

lib/components/DataProductAvailability/AvailabilityContext.d.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ declare namespace AvailabilityContext {
3838
declare function Provider(props: any): JSX.Element;
3939
declare namespace Provider {
4040
namespace propTypes {
41+
const dataAvailabilityUniqueId: PropTypes.Requireable<number>;
4142
const sites: PropTypes.Requireable<(PropTypes.InferProps<{
4243
siteCode: PropTypes.Validator<string>;
4344
tables: PropTypes.Validator<(PropTypes.InferProps<{
@@ -52,11 +53,13 @@ declare namespace Provider {
5253
const children: PropTypes.Validator<string | number | boolean | {} | PropTypes.ReactElementLike | PropTypes.ReactNodeArray>;
5354
}
5455
namespace defaultProps {
56+
const dataAvailabilityUniqueId_1: number;
57+
export { dataAvailabilityUniqueId_1 as dataAvailabilityUniqueId };
5558
const sites_1: never[];
5659
export { sites_1 as sites };
5760
}
5861
}
59-
declare function useAvailabilityState(): any[] | {
62+
declare function useAvailabilityState(): {
6063
sites: never[];
6164
tables: {};
6265
rows: {};
@@ -71,7 +74,22 @@ declare function useAvailabilityState(): any[] | {
7174
states: {};
7275
domains: {};
7376
};
74-
};
77+
} | ({
78+
sites: never[];
79+
tables: {};
80+
rows: {};
81+
rowTitles: {};
82+
rowLabels: never[];
83+
breakouts: never[];
84+
validBreakouts: string[];
85+
sortDirection: string;
86+
neonContextHydrated: boolean;
87+
reference: {
88+
sites: {};
89+
states: {};
90+
domains: {};
91+
};
92+
} | (() => void))[];
7593
declare namespace SORT_DIRECTIONS {
7694
const ASC: string;
7795
const DESC: string;

lib/components/DataProductAvailability/AvailabilityContext.js

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
1515

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

18+
var _NeonEnvironment = _interopRequireDefault(require("../NeonEnvironment/NeonEnvironment"));
19+
1820
var _AvailabilityUtils = require("./AvailabilityUtils");
1921

22+
var _NeonSignInButtonState = _interopRequireDefault(require("../NeonSignInButton/NeonSignInButtonState"));
23+
24+
var _StateStorageService = _interopRequireDefault(require("../../service/StateStorageService"));
25+
2026
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2127

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

286292
return hookResponse;
287293
};
294+
/**
295+
* Defines a lookup of state key to a boolean
296+
* designating whether or not that instance of the context
297+
* should pull the state from the session storage and restore.
298+
* Keeping this lookup outside of the context provider function
299+
* as to not incur lifecycle interference by storing with useState.
300+
*/
301+
302+
303+
var restoreStateLookup = {};
288304
/**
289305
Context Provider
290306
*/
291307

292-
293308
var Provider = function Provider(props) {
294309
var sites = props.sites,
310+
dataAvailabilityUniqueId = props.dataAvailabilityUniqueId,
295311
children = props.children;
296312

297313
var _NeonContext$useNeonC = _NeonContext.default.useNeonContextState(),
@@ -300,30 +316,62 @@ var Provider = function Provider(props) {
300316
neonContextData = _NeonContext$useNeonC3.data,
301317
neonContextIsFinal = _NeonContext$useNeonC3.isFinal,
302318
neonContextHasError = _NeonContext$useNeonC3.hasError;
319+
320+
var key = "availabilityContextState-".concat(dataAvailabilityUniqueId);
321+
322+
if (typeof restoreStateLookup[key] === 'undefined') {
323+
restoreStateLookup[key] = true;
324+
}
325+
326+
var shouldRestoreState = restoreStateLookup[key];
327+
var stateStorage = (0, _StateStorageService.default)(key);
328+
var savedState = stateStorage.readState();
303329
/**
304330
Initial State and Reducer Setup
305331
*/
306332

307-
308333
var initialState = _extends({}, (0, _cloneDeep.default)(DEFAULT_STATE), {
309334
sites: sites
310335
});
311336

312337
initialState.tables = extractTables(initialState);
313338

314-
if (neonContextIsFinal && !neonContextHasError) {
339+
if (neonContextIsFinal && !neonContextHasError && !savedState) {
315340
initialState = hydrateNeonContextData(initialState, neonContextData);
316341
}
317342

343+
if (savedState && shouldRestoreState) {
344+
restoreStateLookup[key] = false;
345+
stateStorage.removeState();
346+
initialState = savedState;
347+
}
348+
318349
var _useReducer = (0, _react.useReducer)(reducer, calculateRows(initialState)),
319350
_useReducer2 = _slicedToArray(_useReducer, 2),
320351
state = _useReducer2[0],
321-
dispatch = _useReducer2[1];
352+
dispatch = _useReducer2[1]; // The current sign in process uses a separate domain. This function
353+
// persists the current state in storage when the button is clicked
354+
// so the state may be reloaded when the page is reloaded after sign
355+
// in.
356+
357+
358+
(0, _react.useEffect)(function () {
359+
var subscription = _NeonSignInButtonState.default.getObservable().subscribe({
360+
next: function next() {
361+
if (!_NeonEnvironment.default.enableGlobalSignInState) return;
362+
restoreStateLookup[key] = false;
363+
stateStorage.saveState(state);
364+
}
365+
});
366+
367+
return function () {
368+
subscription.unsubscribe();
369+
};
370+
}, [state, stateStorage, key]);
322371
/**
323372
Effect - Watch for changes to NeonContext data and push into local state
324373
*/
325374

326-
327375
(0, _react.useEffect)(function () {
328376
if (!state.neonContextHydrated && neonContextIsFinal && !neonContextHasError) {
329377
dispatch({
@@ -342,10 +390,12 @@ var Provider = function Provider(props) {
342390
};
343391

344392
Provider.propTypes = {
393+
dataAvailabilityUniqueId: _propTypes.default.number,
345394
sites: _AvailabilityUtils.AvailabilityPropTypes.enhancedSites,
346395
children: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.string])), _propTypes.default.node, _propTypes.default.string]).isRequired
347396
};
348397
Provider.defaultProps = {
398+
dataAvailabilityUniqueId: 0,
349399
sites: []
350400
};
351401
/**
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* Alter the current state for valid JSON serialization.
3+
* @param currentState The current state
4+
*/
5+
declare const convertStateForStorage: (state: any) => any;
6+
/**
7+
* Restore the state from JSON serialization.
8+
* @param storedState The state read from storage.
9+
*/
10+
declare const convertStateFromStorage: (state: any) => any;
11+
export { convertStateForStorage, convertStateFromStorage };
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
"use strict";
2+
3+
Object.defineProperty(exports, "__esModule", {
4+
value: true
5+
});
6+
exports.convertStateFromStorage = exports.convertStateForStorage = void 0;
7+
8+
var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
9+
10+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11+
12+
/**
13+
* Alter the current state for valid JSON serialization.
14+
* @param currentState The current state
15+
*/
16+
var convertStateForStorage = function convertStateForStorage(state) {
17+
var newState = (0, _cloneDeep.default)(state); // variables
18+
// const { variables: stateVariables } = state;
19+
// Object.keys(stateVariables).forEach((variableKey, index) => {
20+
// const { sites, tables, timeSteps } = stateVariables[variableKey];
21+
// if (sites instanceof Set && sites.size > 0) {
22+
// newState.variables[variableKey].sites = Array.from(sites);
23+
// } else {
24+
// newState.variables[variableKey].sites = [];
25+
// }
26+
// if (tables instanceof Set && sites.size > 0) {
27+
// newState.variables[variableKey].tables = Array.from(tables);
28+
// } else {
29+
// newState.variables[variableKey].tables = [];
30+
// }
31+
// if (timeSteps instanceof Set && sites.size > 0) {
32+
// newState.variables[variableKey].timeSteps = Array.from(timeSteps);
33+
// } else {
34+
// newState.variables[variableKey].timeSteps = [];
35+
// }
36+
// });
37+
// // product site variables
38+
// const { sites: productSites } = state.product;
39+
// Object.keys(productSites).forEach((siteKey, index) => {
40+
// const { variables: siteVariables } = productSites[siteKey];
41+
// if (siteVariables instanceof Set && siteVariables.size > 0) {
42+
// newState.product.sites[siteKey].variables = Array.from(siteVariables);
43+
// } else {
44+
// newState.product.sites[siteKey].variables = [];
45+
// }
46+
// });
47+
// // available quality flags
48+
// const { availableQualityFlags } = state;
49+
// if (availableQualityFlags instanceof Set) {
50+
// newState.availableQualityFlags = Array.from(availableQualityFlags);
51+
// } else {
52+
// newState.availableQualityFlags = [];
53+
// }
54+
// // available time steps
55+
// const { availableTimeSteps } = state;
56+
// if (availableTimeSteps instanceof Set) {
57+
// newState.availableTimeSteps = Array.from(availableTimeSteps);
58+
// } else {
59+
// newState.availableTimeSteps = [];
60+
// }
61+
62+
return newState;
63+
};
64+
/**
65+
* Restore the state from JSON serialization.
66+
* @param storedState The state read from storage.
67+
*/
68+
69+
70+
exports.convertStateForStorage = convertStateForStorage;
71+
72+
var convertStateFromStorage = function convertStateFromStorage(state) {
73+
var newState = (0, _cloneDeep.default)(state); // // graphData data
74+
// const data = state.graphData.data.map((entry: any) => [new Date(entry[0]), entry[1]]);
75+
// newState.graphData.data = data;
76+
// // state variables
77+
// const { variables } = state;
78+
// Object.keys(variables).forEach((key, index) => {
79+
// const { sites, tables, timeSteps } = variables[key];
80+
// if (Array.isArray(sites)) {
81+
// newState.variables[key].sites = new Set(sites);
82+
// } else {
83+
// newState.variables[key].sites = new Set();
84+
// }
85+
// if (Array.isArray(tables)) {
86+
// newState.variables[key].tables = new Set(tables);
87+
// } else {
88+
// newState.variables[key].tables = new Set();
89+
// }
90+
// if (Array.isArray(timeSteps)) {
91+
// newState.variables[key].timeSteps = new Set(timeSteps);
92+
// } else {
93+
// newState.variables[key].timeSteps = new Set();
94+
// }
95+
// });
96+
// // product site variables
97+
// const { sites: productSites } = state.product;
98+
// // get the variables for each site
99+
// Object.keys(productSites).forEach((siteKey, index) => {
100+
// const { variables: siteVariables } = productSites[siteKey];
101+
// if (Array.isArray(siteVariables) && siteVariables.length > 0) {
102+
// newState.product.sites[siteKey].variables = new Set(siteVariables);
103+
// } else {
104+
// newState.product.sites[siteKey].variables = new Set();
105+
// }
106+
// });
107+
// // available quality flags
108+
// const { availableQualityFlags } = state;
109+
// if (Array.isArray(availableQualityFlags)) {
110+
// newState.availableQualityFlags = new Set(availableQualityFlags);
111+
// } else {
112+
// newState.availableQualityFlags = new Set();
113+
// }
114+
// // available quality flags
115+
// const { availableTimeSteps } = state;
116+
// if (Array.isArray(availableTimeSteps)) {
117+
// newState.availableTimeSteps = new Set(availableTimeSteps);
118+
// } else {
119+
// newState.availableTimeSteps = new Set();
120+
// }
121+
122+
return newState;
123+
};
124+
125+
exports.convertStateFromStorage = convertStateFromStorage;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import { NeonDocument } from '../../types/neon';
3+
export interface DocumentViewerProps {
4+
document: NeonDocument;
5+
width: number;
6+
}
7+
declare const DocumentViewer: React.FC<DocumentViewerProps>;
8+
export default DocumentViewer;

0 commit comments

Comments
 (0)