@opengeoweb/taf 9.0.0 → 9.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.esm.js +29 -16
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -35122,12 +35122,16 @@ var TafModule = function TafModule() {
35122
35122
  setIsLoading = _React$useState4[1];
35123
35123
  var _React$useState5 = React.useState(null),
35124
35124
  _React$useState6 = _slicedToArray(_React$useState5, 2),
35125
- getTafListError = _React$useState6[0],
35126
- setError = _React$useState6[1];
35125
+ errorMessage = _React$useState6[0],
35126
+ setErrorMessage = _React$useState6[1];
35127
35127
  var _React$useState7 = React.useState(),
35128
35128
  _React$useState8 = _slicedToArray(_React$useState7, 2),
35129
35129
  lastUpdateTime = _React$useState8[0],
35130
35130
  setLastUpdateTime = _React$useState8[1];
35131
+ var _useAuthenticationCon = useAuthenticationContext(),
35132
+ isLoggedIn = _useAuthenticationCon.isLoggedIn;
35133
+ var ERROR_AUTH = 'This feature is protected by authentication.';
35134
+ var ERROR_AUTH_MESSAGE = 'Please log in to proceed.';
35131
35135
  var fetchNewTafList = function fetchNewTafList() {
35132
35136
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
35133
35137
  var result;
@@ -35135,7 +35139,7 @@ var TafModule = function TafModule() {
35135
35139
  while (1) switch (_context.prev = _context.next) {
35136
35140
  case 0:
35137
35141
  setIsLoading(true);
35138
- setError(null);
35142
+ setErrorMessage(null);
35139
35143
  _context.prev = 2;
35140
35144
  _context.next = 5;
35141
35145
  return api.getTafList();
@@ -35148,7 +35152,10 @@ var TafModule = function TafModule() {
35148
35152
  case 12:
35149
35153
  _context.prev = 12;
35150
35154
  _context.t0 = _context["catch"](2);
35151
- setError(_context.t0);
35155
+ setErrorMessage({
35156
+ title: 'An error has occurred while retrieving the list',
35157
+ info: _context.t0.message
35158
+ });
35152
35159
  setIsLoading(false);
35153
35160
  return _context.abrupt("return", []);
35154
35161
  case 17:
@@ -35172,11 +35179,17 @@ var TafModule = function TafModule() {
35172
35179
  }));
35173
35180
  };
35174
35181
  React.useEffect(function () {
35175
- fetchNewTafList();
35182
+ if (!isLoggedIn) {
35183
+ setErrorMessage({
35184
+ title: ERROR_AUTH,
35185
+ info: ERROR_AUTH_MESSAGE
35186
+ });
35187
+ } else {
35188
+ fetchNewTafList();
35189
+ }
35176
35190
  // eslint-disable-next-line react-hooks/exhaustive-deps
35177
- }, []);
35178
- usePoller([tafList, getTafListError], fetchNewTafList);
35179
- var hasTafListError = getTafListError !== null;
35191
+ }, [isLoggedIn]);
35192
+ usePoller([tafList, errorMessage], fetchNewTafList);
35180
35193
  return /*#__PURE__*/React.createElement(ResponsiveWrapper, null, /*#__PURE__*/React.createElement(Box, {
35181
35194
  component: "div",
35182
35195
  id: "tafmodule",
@@ -35184,22 +35197,22 @@ var TafModule = function TafModule() {
35184
35197
  sx: {
35185
35198
  height: '100%'
35186
35199
  }
35187
- }, isLoading && /*#__PURE__*/React.createElement(LinearProgress, {
35200
+ }, isLoggedIn && isLoading && /*#__PURE__*/React.createElement(LinearProgress, {
35188
35201
  "data-testid": "loading-bar",
35189
35202
  color: "secondary",
35190
35203
  sx: {
35191
35204
  marginBottom: '-4px'
35192
35205
  }
35193
- }), hasTafListError && /*#__PURE__*/React.createElement(AlertBanner, {
35206
+ }), errorMessage ? /*#__PURE__*/React.createElement(AlertBanner, {
35194
35207
  severity: "error",
35195
- title: "An error has occurred while retrieving the list",
35196
- info: getTafListError.message,
35197
- dataTestId: "taf-list-error",
35198
- actionButtonProps: {
35208
+ title: errorMessage.title,
35209
+ info: errorMessage.info,
35210
+ "data-testid": "error-message",
35211
+ actionButtonProps: errorMessage.title !== ERROR_AUTH ? {
35199
35212
  title: 'Try again',
35200
35213
  onClick: fetchNewTafList
35201
- }
35202
- }), /*#__PURE__*/React.createElement(TafLayout, {
35214
+ } : undefined
35215
+ }) : null, /*#__PURE__*/React.createElement(TafLayout, {
35203
35216
  tafList: tafList,
35204
35217
  onUpdateTaf: onUpdateTaf,
35205
35218
  lastUpdateTime: lastUpdateTime
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/taf",
3
- "version": "9.0.0",
3
+ "version": "9.2.0",
4
4
  "description": "GeoWeb TAF library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {