@opengeoweb/warnings 12.13.0 → 13.1.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.
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useDispatch, useSelector } from 'react-redux';
3
- import { Polygons, ExitDomain, Share, Edit, Delete, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, Thunderstorm, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, DrawPolygon, Visibility, Add, ArrowUpCompact, ArrowDownCompact, breakpoints, DragHandle, Options, Close, ChevronDown, ChevronUp, Copy, Update, Cancel, Success, Expire, Remove } from '@opengeoweb/theme';
3
+ import { Polygons, ExitDomain, Share, Edit, Delete, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, Thunderstorm, SevereMountainWaves, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, DrawPolygon, Visibility, Add, ArrowUpCompact, ArrowDownCompact, breakpoints, DragHandle, Options, Close, ChevronDown, ChevronUp, Copy, Update, Cancel, Success, Expire, Remove } from '@opengeoweb/theme';
4
4
  import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawingToolSelectors, layerSelectors, uiSelectors, drawingToolActions, layerActions, mapListener, layersListener, drawingToolListener, syncGroupsListener, openlayersListener, syncGroupsReducer, drawingToolReducer, uiReducer, layerReducer, mapReducer, useSetupDialog, genericSelectors, useUpdateSharedData, genericActions, selectorMemoizationOptions } from '@opengeoweb/store';
5
5
  import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, defaultLayers, viewUtils, OpenLayersMapView, MapControls, OpenLayersZoomControl, OpenLayersLayer, OpenLayersFeatureLayer, genericOpenLayersFeatureStyle } from '@opengeoweb/webmap-react';
6
6
  import { SHARED_NAMESPACE, useConfirmationDialog, dateUtils, ToggleMenu, calculateStartSize, ToolContainerDraggable, AlertBanner, sessionStorageProvider, ConfirmationDialog, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, FilterChip, TooltipSelect, LastUpdateTime, usePreventBrowserClose, CustomToggleButton, Filter, FilterOption, StatusTag, getAxiosErrorMessage, ErrorBoundary } from '@opengeoweb/shared';
@@ -264,7 +264,6 @@ var en = {
264
264
  "maritime-warning-post-success": "Warning published successfully",
265
265
  "maritime-loading-config": "Loading config...",
266
266
  "maritime-config-error": "Something went wrong with loading the configuration file",
267
- "maritime-warning-validfrom": "Start time: ",
268
267
  "maritime-warning-validuntil": "End time: "
269
268
  };
270
269
  var nl = {
@@ -463,7 +462,6 @@ var nl = {
463
462
  "maritime-warning-post-success": "Waarschuwing succesvol gepubliceerd",
464
463
  "maritime-loading-config": "Laden van configuratie...",
465
464
  "maritime-config-error": "Er is iets misgegaan bij het laden van het configuratiebestand",
466
- "maritime-warning-validfrom": "Start tijd: ",
467
465
  "maritime-warning-validuntil": "Eind tijd: "
468
466
  };
469
467
  var fi = {
@@ -628,14 +626,14 @@ var no = {
628
626
  "drawing-tool-form-update": "Oppdater objekt",
629
627
  "drawing-tool-form-exit-draw-mode": "Trykk ESC for å avslutte tegnemodus",
630
628
  "drawing-tool-form-drawing-required": "Objekttegning kreves",
631
- "close-dialog-cancel": "Avbryt",
629
+ "close-dialog-cancel": "Cancel",
632
630
  "close-dialog-confirm": "Lukk",
633
631
  "close-draw-dialog-title": "Lukk tegneverktøy",
634
632
  "close-dialog-description": "Du har gjort endringer, er du sikker på at du vil lukke?",
635
633
  "drawing-tool-title": "Tegneverktøy",
636
- "object-manager-title": "Objektmanager for",
634
+ "object-manager-title": "Objekter for",
637
635
  "object-manager-add": "Legg til nytt objekt",
638
- "delete-dialog-cancel": "Avbryt",
636
+ "delete-dialog-cancel": "Cancel",
639
637
  "delete-dialog-confirm": "Slett",
640
638
  "delete-dialog-title": "Slett objekt",
641
639
  "delete-dialog-description": "Er du sikker på at du vil slette?",
@@ -747,30 +745,30 @@ var no = {
747
745
  "filter-phenomenon": "Fenomen",
748
746
  "filter-level": "Grad",
749
747
  "filter-source": "Kilder",
750
- "warning-dialog-expire-succes": "ikke oversatt",
751
- "warning-dialog-expire-title": "ikke oversatt",
752
- "warning-dialog-expire-confirm": "ikke oversatt",
753
- "warning-dialog-expire-description": "ikke oversatt",
754
- "warning-dialog-withdraw-succes": "ikke oversatt",
755
- "warning-dialog-withdraw-title": "ikke oversatt",
756
- "warning-dialog-withdraw-confirm": "ikke oversatt",
757
- "warning-dialog-withdraw-description": "ikke oversatt",
758
- "warning-domain-aviation": "ikke oversatt",
759
- "warning-domain-maritime": "ikke oversatt",
760
- "warning-domain-public": "ikke oversatt",
748
+ "warning-dialog-expire-succes": "Varselet er utgått",
749
+ "warning-dialog-expire-title": "Opphør varsel",
750
+ "warning-dialog-expire-confirm": "Opphør",
751
+ "warning-dialog-expire-description": "Er du sikker på at du vil opphøre dette varselet?",
752
+ "warning-dialog-withdraw-succes": "Varselet er tilbaketrukket",
753
+ "warning-dialog-withdraw-title": "Trekk tilbake varsel",
754
+ "warning-dialog-withdraw-confirm": "Trekk tilbake",
755
+ "warning-dialog-withdraw-description": "Er du sikker på at du vil tilbaketrekke dette varselet?",
756
+ "warning-domain-aviation": "SIGMET/AIRMET",
757
+ "warning-domain-maritime": "Maritim",
758
+ "warning-domain-public": "Farevarsel",
761
759
  "error-title-retry": "Prøv igjen",
762
760
  "tac-missing-data": "Mangler data: ingen TAC kan genereres",
763
761
  "warning-list-button-renew": "Renew",
764
- "aviation-save-success": "{{warningType}} er lagret!",
765
- "aviation-publish-success": "{{warningType}} er lagret!",
766
- "publish-this-product": "Er du sikker at du vil publisere dette {{product}}?",
767
- "yes-cancel": "Ja, kanseller {{product}}",
768
- "cancel-this-product": "Er du sikker at du vil avbryte dette {{product}}?",
769
- "aviation-cancel-success": "{{warningType}} er kansellert!",
770
- "aviation-discard-success": "{{warningType}} er forkastet!",
762
+ "aviation-save-success": "{{warningType}} has succesfully been saved!",
763
+ "aviation-publish-success": "{{warningType}} has succesfully been published!",
764
+ "publish-this-product": "Are you sure you want to publish this {{product}}?",
765
+ "yes-cancel": "Yes, cancel {{product}}",
766
+ "cancel-this-product": "Are you sure you want to cancel this {{product}}?",
767
+ "aviation-cancel-success": "{{warningType}} has succesfully been cancelled!",
768
+ "aviation-discard-success": "{{warningType}} has been discarded!",
771
769
  "error-auth-login": "Denne delen er passordbeskyttet. Vennligst logg inn.",
772
- "cancel-warningType": "Kanseller {{warningType}}",
773
- cancelling: "Kansellerer"
770
+ "cancel-warningType": "Cancel {{warningType}}",
771
+ cancelling: "Cancelling"
774
772
  };
775
773
  var warningsTranslations = {
776
774
  en: en,
@@ -2658,6 +2656,8 @@ var getAviationPhenomenaIcon = function getAviationPhenomenaIcon(key) {
2658
2656
  return jsx(Haze, {});
2659
2657
  case 'VA_CLD':
2660
2658
  return jsx(VulcanicEruption, {});
2659
+ case 'SEV_MTW':
2660
+ return jsx(SevereMountainWaves, {});
2661
2661
  case 'EMBD_TS':
2662
2662
  case 'EMBD_TSGR':
2663
2663
  case 'FRQ_TS':
@@ -3342,6 +3342,7 @@ var useMutateDeleteDrawing = function useMutateDeleteDrawing() {
3342
3342
  }
3343
3343
  });
3344
3344
  };
3345
+ var BE_EDITOR_WARNING = 'Warning is being edited by another user and cannot be updated';
3345
3346
  var usePostMaritimeWarnings = function usePostMaritimeWarnings() {
3346
3347
  var _useAuthenticationCon6 = useAuthenticationContext(),
3347
3348
  auth = _useAuthenticationCon6.auth;
@@ -3355,31 +3356,22 @@ var usePostMaritimeWarnings = function usePostMaritimeWarnings() {
3355
3356
  return postMaritimeWarnings(auth, data);
3356
3357
  },
3357
3358
  onSuccess: function onSuccess() {
3359
+ void queryClient.invalidateQueries({
3360
+ queryKey: ['public-warning-list']
3361
+ });
3358
3362
  dispatch(snackbarActions.openSnackbar({
3359
3363
  type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
3360
3364
  key: 'maritime-warning-post-success'
3361
3365
  }));
3362
3366
  },
3363
- onSettled: function () {
3364
- var _onSettled = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
3365
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
3366
- while (1) switch (_context6.prev = _context6.next) {
3367
- case 0:
3368
- _context6.next = 2;
3369
- return queryClient.invalidateQueries({
3370
- queryKey: ['public-warning-list']
3371
- });
3372
- case 2:
3373
- case "end":
3374
- return _context6.stop();
3375
- }
3376
- }, _callee6);
3377
- }));
3378
- function onSettled() {
3379
- return _onSettled.apply(this, arguments);
3367
+ onError: function onError(error) {
3368
+ if (error.message === BE_EDITOR_WARNING) {
3369
+ // only in case of an editor conflict, we need to update the list
3370
+ void queryClient.invalidateQueries({
3371
+ queryKey: ['public-warning-list']
3372
+ });
3380
3373
  }
3381
- return onSettled;
3382
- }()
3374
+ }
3383
3375
  });
3384
3376
  };
3385
3377
  var useMutateMaritimeWarningsEditor = function useMutateMaritimeWarningsEditor() {
@@ -5091,9 +5083,7 @@ var renewAviationProduct = function renewAviationProduct(aviationWarning, produc
5091
5083
  };
5092
5084
  var amendAviationProduct = function amendAviationProduct(aviationWarning, productConfig) {
5093
5085
  var warningDetail = aviationWarning.sigmetAirmetDetails;
5094
- var newValidStart = dateUtils.dateToString(dateUtils.add(new Date(), {
5095
- minutes: 5
5096
- }));
5086
+ var newValidStart = dateUtils.dateToString(new Date());
5097
5087
  var newValidUntil = 'phenomenon' in warningDetail ? getDefaultValidUntilValue(productConfig, warningDetail.phenomenon, warningDetail.locationIndicatorATSR, newValidStart) : warningDetail.validDateEnd;
5098
5088
  var amendedWarningDetail = Object.assign({}, warningDetail, {
5099
5089
  validDateStart: newValidStart,
@@ -5604,7 +5594,7 @@ var ProbabilityField = function ProbabilityField(_ref) {
5604
5594
  });
5605
5595
  };
5606
5596
 
5607
- var VALID_FROM_MAX_HOURS_AFTER_CURRENT = 168;
5597
+ var VALID_FROM_MAX_HOURS_AFTER_CURRENT = 192;
5608
5598
  var _isValueBeforeCurrentTime$1 = function isValueBeforeCurrentTime(value, t) {
5609
5599
  return isXHoursBefore(value, dateUtils.getCurrentTimeAsString(), 0) || t('warning-valid-from-error-before-current');
5610
5600
  };
@@ -5650,7 +5640,7 @@ var ValidFrom = function ValidFrom(_ref) {
5650
5640
  });
5651
5641
  };
5652
5642
 
5653
- var VALID_UNTIL_MAX_HOURS_AFTER_CURRENT = 180;
5643
+ var VALID_UNTIL_MAX_HOURS_AFTER_CURRENT = 192;
5654
5644
  var VALID_UNTIL_MIN_HOURS_AFTER_VALID_FROM = 1;
5655
5645
  var _isValueBeforeCurrentTime = function isValueBeforeCurrentTime(value, t) {
5656
5646
  return isXHoursBefore(value, dateUtils.getCurrentTimeAsString(), 0) || t('warning-valid-until-error-before-current');
@@ -6893,10 +6883,18 @@ var MaritimeWarningAvatar = function MaritimeWarningAvatar(_ref) {
6893
6883
  });
6894
6884
  };
6895
6885
 
6886
+ var spinnerSx$1 = {
6887
+ width: '16px!important',
6888
+ height: '16px!important',
6889
+ position: 'absolute',
6890
+ top: 0,
6891
+ bottom: 0,
6892
+ margin: 'auto',
6893
+ marginLeft: 1
6894
+ };
6896
6895
  var getWarningsValidity = function getWarningsValidity(t, warnings) {
6897
- var validFrom = warnings.length > 0 && warnings[0].validFrom ? dateUtils.dateToString(dateUtils.createDate(warnings[0].validFrom), dateUtils.DATE_FORMAT_NAME_OF_DAY_MONTH) : '';
6898
6896
  var validUntil = warnings.length > 0 && warnings[0].validUntil ? dateUtils.dateToString(dateUtils.createDate(warnings[0].validUntil), dateUtils.DATE_FORMAT_NAME_OF_DAY_MONTH) : '';
6899
- return validFrom && validUntil ? "" + t('maritime-warning-validfrom') + validFrom + " - " + t('maritime-warning-validuntil') + validUntil : '';
6897
+ return validUntil ? "" + t('maritime-warning-validuntil') + validUntil : '';
6900
6898
  };
6901
6899
  var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
6902
6900
  var _sx, _sx2, _sx3, _sx4;
@@ -6924,6 +6922,9 @@ var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
6924
6922
  maritimeConfig = _ref.maritimeConfig,
6925
6923
  _ref$lastUpdatedTime = _ref.lastUpdatedTime,
6926
6924
  lastUpdatedTime = _ref$lastUpdatedTime === void 0 ? '' : _ref$lastUpdatedTime;
6925
+ var _React$useState = React__default.useState(false),
6926
+ isPublishing = _React$useState[0],
6927
+ setIsPublishing = _React$useState[1];
6927
6928
  var _useWarningsTranslati = useWarningsTranslation(),
6928
6929
  t = _useWarningsTranslati.t;
6929
6930
  var showConfirmDialog = useConfirmationDialog();
@@ -6989,6 +6990,39 @@ var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
6989
6990
  };
6990
6991
  }();
6991
6992
  var validTimes = getWarningsValidity(t, warnings);
6993
+ var onPressPublish = /*#__PURE__*/function () {
6994
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
6995
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
6996
+ while (1) switch (_context3.prev = _context3.next) {
6997
+ case 0:
6998
+ if (isPublishing) {
6999
+ _context3.next = 12;
7000
+ break;
7001
+ }
7002
+ setIsPublishing(true);
7003
+ _context3.prev = 2;
7004
+ _context3.next = 5;
7005
+ return onSubmit();
7006
+ case 5:
7007
+ _context3.next = 9;
7008
+ break;
7009
+ case 7:
7010
+ _context3.prev = 7;
7011
+ _context3.t0 = _context3["catch"](2);
7012
+ case 9:
7013
+ _context3.prev = 9;
7014
+ setIsPublishing(false);
7015
+ return _context3.finish(9);
7016
+ case 12:
7017
+ case "end":
7018
+ return _context3.stop();
7019
+ }
7020
+ }, _callee3, null, [[2, 7, 9, 12]]);
7021
+ }));
7022
+ return function onPressPublish() {
7023
+ return _ref4.apply(this, arguments);
7024
+ };
7025
+ }();
6992
7026
  return jsxs(Box, {
6993
7027
  sx: (_sx = {
6994
7028
  display: 'flex',
@@ -7122,9 +7156,18 @@ var MaritimeWarningsForm = function MaritimeWarningsForm(_ref) {
7122
7156
  }, _sx4["@container maritime (min-width: " + breakpoints.tablet + "px)"] = {
7123
7157
  marginLeft: '24px!important'
7124
7158
  }, _sx4),
7125
- disabled: !modified || !isValid,
7126
- onClick: onSubmit,
7127
- children: t('warning-button-publish')
7159
+ disabled: !modified || !isValid || isPublishing,
7160
+ onClick: onPressPublish,
7161
+ children: jsxs("span", {
7162
+ style: {
7163
+ position: 'relative'
7164
+ },
7165
+ children: [isPublishing ? t('warning-button-publishing') : t('warning-button-publish'), isPublishing && jsx(CircularProgress, {
7166
+ "data-testid": "spinner",
7167
+ color: "inherit",
7168
+ sx: spinnerSx$1
7169
+ })]
7170
+ })
7128
7171
  })]
7129
7172
  })]
7130
7173
  });
@@ -7157,7 +7200,7 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
7157
7200
  refetchWarnings = _usePublicWarnings.refetch,
7158
7201
  dataUpdatedAt = _usePublicWarnings.dataUpdatedAt;
7159
7202
  var _usePostMaritimeWarni = usePostMaritimeWarnings(),
7160
- postWarnings = _usePostMaritimeWarni.mutate,
7203
+ postWarnings = _usePostMaritimeWarni.mutateAsync,
7161
7204
  publishError = _usePostMaritimeWarni.error;
7162
7205
  var _useMutateMaritimeWar = useMutateMaritimeWarningsEditor(),
7163
7206
  mutateEditor = _useMutateMaritimeWar.mutate,
@@ -7289,14 +7332,15 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
7289
7332
  type: 'mergeWarnings'
7290
7333
  });
7291
7334
  maritimeWarnings = mapItemsToMaritimeWarnings(nextState.warnings, domain, maritimeConfig, auth == null ? void 0 : auth.username);
7292
- postWarnings(maritimeWarnings, {
7335
+ _context.next = 5;
7336
+ return postWarnings(maritimeWarnings, {
7293
7337
  onSuccess: function onSuccess() {
7294
7338
  dispatch({
7295
7339
  type: 'submitWarnings'
7296
7340
  });
7297
7341
  }
7298
7342
  });
7299
- case 4:
7343
+ case 5:
7300
7344
  case "end":
7301
7345
  return _context.stop();
7302
7346
  }
@@ -7355,7 +7399,8 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
7355
7399
  void updateEditor(false);
7356
7400
  }, [t, domainLabel, mutateEditor, domain, refetchWarnings, confirmDialog, showSnackbar]);
7357
7401
  useEffect(function () {
7358
- if (publishError) {
7402
+ // the BE_EDITOR_WARNING is handled in shouldGiveEditorWarning
7403
+ if (publishError && publishError.message !== BE_EDITOR_WARNING) {
7359
7404
  setError({
7360
7405
  title: publishError.message,
7361
7406
  severity: 'error'
@@ -7368,10 +7413,10 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
7368
7413
  } else {
7369
7414
  setError(undefined);
7370
7415
  }
7371
- }, [publishError, editorError]);
7416
+ }, [editorError, publishError]);
7372
7417
  var shouldGiveEditorWarning = React__default.useCallback(function (newEditor, oldEditor) {
7373
7418
  var oldEditorIsYou = oldEditor && oldEditor === (auth == null ? void 0 : auth.username);
7374
- if (oldEditorIsYou && newEditor && newEditor !== oldEditor) {
7419
+ if (oldEditorIsYou && (newEditor || publishError) && newEditor !== oldEditor) {
7375
7420
  setError({
7376
7421
  title: t('maritime-editor-off', {
7377
7422
  domain: domainLabel
@@ -7379,7 +7424,7 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
7379
7424
  severity: 'warning'
7380
7425
  });
7381
7426
  }
7382
- }, [auth == null ? void 0 : auth.username, domainLabel, t]);
7427
+ }, [auth == null ? void 0 : auth.username, domainLabel, publishError, t]);
7383
7428
  useEffect(function () {
7384
7429
  // Only give editor warning when the change in editor is from a refetch
7385
7430
  if (hasFetched) {
@@ -7720,6 +7765,24 @@ var Form = function Form(_ref5) {
7720
7765
  var formMethods = useForm({
7721
7766
  defaultValues: {}
7722
7767
  });
7768
+ var endOfWarningValidity = publicWarningDetails == null ? void 0 : publicWarningDetails.validUntil;
7769
+ React.useEffect(function () {
7770
+ if (!endOfWarningValidity || formState !== 'amending') {
7771
+ return function () {};
7772
+ }
7773
+ var end = new Date(endOfWarningValidity).getTime();
7774
+ var now = Date.now();
7775
+ if (end <= now) {
7776
+ onCloseForm();
7777
+ return function () {};
7778
+ }
7779
+ var timer = setTimeout(function () {
7780
+ onCloseForm();
7781
+ }, end - now + 1000);
7782
+ return function () {
7783
+ return clearTimeout(timer);
7784
+ };
7785
+ }, [endOfWarningValidity, formState, onCloseForm]);
7723
7786
  var initialPublicWarningArea = (publicWarningDetails == null || (_publicWarningDetails = publicWarningDetails.areas) == null ? void 0 : _publicWarningDetails.length) && (publicWarningDetails == null || (_publicWarningDetails2 = publicWarningDetails.areas[0]) == null ? void 0 : _publicWarningDetails2.geoJSON);
7724
7787
  var _React$useState4 = React.useState(initialPublicWarningArea),
7725
7788
  warningGeoJSONFeature = _React$useState4[0],
@@ -7816,11 +7879,27 @@ var Form = function Form(_ref5) {
7816
7879
  })) : null
7817
7880
  });
7818
7881
  };
7819
- var cancelAviationProduct = function cancelAviationProduct(warningType) {
7820
- return onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType, isVAPhenomenon(selectedAviationProduct, ProductAction.CANCEL) && watch('vaSigmetMoveToFIR')).then(function (result) {
7821
- return result != null ? result : null;
7822
- });
7823
- };
7882
+ var cancelAviationProduct = /*#__PURE__*/function () {
7883
+ var _ref1 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(warningType) {
7884
+ var result;
7885
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
7886
+ while (1) switch (_context6.prev = _context6.next) {
7887
+ case 0:
7888
+ _context6.next = 2;
7889
+ return onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType, isVAPhenomenon(selectedAviationProduct, ProductAction.CANCEL) && watch('vaSigmetMoveToFIR'));
7890
+ case 2:
7891
+ result = _context6.sent;
7892
+ return _context6.abrupt("return", result != null ? result : null);
7893
+ case 4:
7894
+ case "end":
7895
+ return _context6.stop();
7896
+ }
7897
+ }, _callee6);
7898
+ }));
7899
+ return function cancelAviationProduct(_x3) {
7900
+ return _ref1.apply(this, arguments);
7901
+ };
7902
+ }();
7824
7903
  var getPublishButtonLabel = function getPublishButtonLabel() {
7825
7904
  if (isCancelling) {
7826
7905
  return t('cancelling');
@@ -7836,7 +7915,7 @@ var Form = function Form(_ref5) {
7836
7915
  return t('warning-button-publish');
7837
7916
  };
7838
7917
  var handleSubmitAviationProduct = /*#__PURE__*/function () {
7839
- var _ref1 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(action, warningType) {
7918
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(action, warningType) {
7840
7919
  var formValues;
7841
7920
  return _regeneratorRuntime().wrap(function _callee0$(_context0) {
7842
7921
  while (1) switch (_context0.prev = _context0.next) {
@@ -7871,35 +7950,35 @@ var Form = function Form(_ref5) {
7871
7950
  case 14:
7872
7951
  toggleIsDraft(false);
7873
7952
  void handleSubmit(/*#__PURE__*/function () {
7874
- var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(formValues) {
7875
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
7876
- while (1) switch (_context7.prev = _context7.next) {
7953
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(formValues) {
7954
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
7955
+ while (1) switch (_context8.prev = _context8.next) {
7877
7956
  case 0:
7878
- _context7.next = 2;
7879
- return showConfirmDialog(action).then(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
7880
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
7881
- while (1) switch (_context6.prev = _context6.next) {
7957
+ _context8.next = 2;
7958
+ return showConfirmDialog(action).then(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
7959
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
7960
+ while (1) switch (_context7.prev = _context7.next) {
7882
7961
  case 0:
7883
7962
  setIsPublishing(true);
7884
- _context6.next = 3;
7963
+ _context7.next = 3;
7885
7964
  return onSaveAviationForm(formValues, 'PUBLISHED', warningType)["catch"](function () {});
7886
7965
  case 3:
7887
7966
  case "end":
7888
- return _context6.stop();
7967
+ return _context7.stop();
7889
7968
  }
7890
- }, _callee6);
7969
+ }, _callee7);
7891
7970
  })));
7892
7971
  case 2:
7893
7972
  setIsPublishing(false);
7894
7973
  onCloseForm();
7895
7974
  case 4:
7896
7975
  case "end":
7897
- return _context7.stop();
7976
+ return _context8.stop();
7898
7977
  }
7899
- }, _callee7);
7978
+ }, _callee8);
7900
7979
  }));
7901
- return function (_x5) {
7902
- return _ref10.apply(this, arguments);
7980
+ return function (_x6) {
7981
+ return _ref11.apply(this, arguments);
7903
7982
  };
7904
7983
  }())();
7905
7984
  return _context0.abrupt("break", 23);
@@ -7914,36 +7993,35 @@ var Form = function Form(_ref5) {
7914
7993
  return _context0.abrupt("break", 23);
7915
7994
  case 19:
7916
7995
  void handleSubmit(/*#__PURE__*/function () {
7917
- var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(formValues) {
7996
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(formValues) {
7918
7997
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
7919
7998
  while (1) switch (_context9.prev = _context9.next) {
7920
7999
  case 0:
7921
- _context9.next = 2;
7922
- return showConfirmDialog(action).then(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
7923
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
7924
- while (1) switch (_context8.prev = _context8.next) {
7925
- case 0:
7926
- setIsPublishing(true);
7927
- void cancelAviationProduct(warningType).then(function () {
7928
- void onSaveAviationForm(formValues, 'PUBLISHED', warningType).then(function () {
7929
- setIsPublishing(false);
7930
- onCloseForm();
7931
- });
7932
- });
7933
- case 2:
7934
- case "end":
7935
- return _context8.stop();
7936
- }
7937
- }, _callee8);
7938
- })));
7939
- case 2:
8000
+ _context9.prev = 0;
8001
+ _context9.next = 3;
8002
+ return showConfirmDialog(action);
8003
+ case 3:
8004
+ setIsPublishing(true);
8005
+ // 1) Publish amended warning
8006
+ _context9.next = 6;
8007
+ return onSaveAviationForm(formValues, 'PUBLISHED', warningType);
8008
+ case 6:
8009
+ _context9.next = 8;
8010
+ return cancelAviationProduct(warningType);
8011
+ case 8:
8012
+ onCloseForm();
8013
+ case 9:
8014
+ _context9.prev = 9;
8015
+ setIsPublishing(false);
8016
+ return _context9.finish(9);
8017
+ case 12:
7940
8018
  case "end":
7941
8019
  return _context9.stop();
7942
8020
  }
7943
- }, _callee9);
8021
+ }, _callee9, null, [[0,, 9, 12]]);
7944
8022
  }));
7945
- return function (_x6) {
7946
- return _ref12.apply(this, arguments);
8023
+ return function (_x7) {
8024
+ return _ref13.apply(this, arguments);
7947
8025
  };
7948
8026
  }())();
7949
8027
  return _context0.abrupt("break", 23);
@@ -7957,8 +8035,8 @@ var Form = function Form(_ref5) {
7957
8035
  }
7958
8036
  }, _callee0);
7959
8037
  }));
7960
- return function handleSubmitAviationProduct(_x3, _x4) {
7961
- return _ref1.apply(this, arguments);
8038
+ return function handleSubmitAviationProduct(_x4, _x5) {
8039
+ return _ref10.apply(this, arguments);
7962
8040
  };
7963
8041
  }();
7964
8042
  var onPressClear = function onPressClear() {
@@ -8067,7 +8145,8 @@ var Form = function Form(_ref5) {
8067
8145
  return fetchSigmetTAC(product);
8068
8146
  },
8069
8147
  storedGeoJSON: storedStartGeoJSON,
8070
- storedEndGeoJSON: storedEndGeoJSON
8148
+ storedEndGeoJSON: storedEndGeoJSON,
8149
+ isAmending: formState === 'amending'
8071
8150
  })
8072
8151
  });
8073
8152
  }
@@ -8090,7 +8169,8 @@ var Form = function Form(_ref5) {
8090
8169
  getTAC: function getTAC(product) {
8091
8170
  return fetchAirmetTAC(product);
8092
8171
  },
8093
- storedGeoJSON: storedStartGeoJSON
8172
+ storedGeoJSON: storedStartGeoJSON,
8173
+ isAmending: formState === 'amending'
8094
8174
  })
8095
8175
  });
8096
8176
  }
@@ -8390,49 +8470,46 @@ var PublicWarningsForm = function PublicWarningsForm(props) {
8390
8470
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
8391
8471
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
8392
8472
  * */
8393
- var getPublicWarningStore = function getPublicWarningStore(store) {
8473
+ var selectPublicWarningState = function selectPublicWarningState(store) {
8394
8474
  if (store && store.publicWarningForm) {
8395
8475
  return store.publicWarningForm;
8396
8476
  }
8397
8477
  return {};
8398
8478
  };
8399
- var selectPublicWarningState = createSelector(getPublicWarningStore, function (state) {
8400
- return state;
8401
- });
8402
- createSelector(getPublicWarningStore, function (publicWarningStore) {
8479
+ createSelector(selectPublicWarningState, function (publicWarningStore) {
8403
8480
  return publicWarningStore.object;
8404
8481
  });
8405
- var getPublicWarning = createSelector(getPublicWarningStore, function (publicWarningStore) {
8482
+ var getPublicWarning = createSelector(selectPublicWarningState, function (publicWarningStore) {
8406
8483
  return publicWarningStore == null ? void 0 : publicWarningStore.warning;
8407
8484
  });
8408
- var getPublicWarningStatus = createSelector(getPublicWarningStore, function (publicWarningStore) {
8485
+ var getPublicWarningStatus = createSelector(selectPublicWarningState, function (publicWarningStore) {
8409
8486
  var _publicWarningStore$w;
8410
8487
  return publicWarningStore == null || (_publicWarningStore$w = publicWarningStore.warning) == null ? void 0 : _publicWarningStore$w.status;
8411
8488
  });
8412
- var getPublicWarningId = createSelector(getPublicWarningStore, function (publicWarningStore) {
8489
+ var getPublicWarningId = createSelector(selectPublicWarningState, function (publicWarningStore) {
8413
8490
  var _publicWarningStore$w2;
8414
8491
  return publicWarningStore == null || (_publicWarningStore$w2 = publicWarningStore.warning) == null ? void 0 : _publicWarningStore$w2.warningDetail.id;
8415
8492
  });
8416
- var getPublicWarningAreas = createSelector(getPublicWarningStore, function (publicWarningStore) {
8493
+ var getPublicWarningAreas = createSelector(selectPublicWarningState, function (publicWarningStore) {
8417
8494
  var _publicWarningStore$w3;
8418
8495
  return (publicWarningStore == null || (_publicWarningStore$w3 = publicWarningStore.warning) == null ? void 0 : _publicWarningStore$w3.warningDetail.areas) || [];
8419
8496
  });
8420
- var getPublicWarningFormState = createSelector(getPublicWarningStore, function (publicWarningStore) {
8497
+ var getPublicWarningFormState = createSelector(selectPublicWarningState, function (publicWarningStore) {
8421
8498
  return (publicWarningStore == null ? void 0 : publicWarningStore.formState) || '';
8422
8499
  });
8423
- createSelector(getPublicWarningStore, function (publicWarningStore) {
8500
+ createSelector(selectPublicWarningState, function (publicWarningStore) {
8424
8501
  return publicWarningStore == null ? void 0 : publicWarningStore.error;
8425
8502
  });
8426
- var getSelectedWarningId = createSelector(getPublicWarningStore, function (publicWarningStore) {
8503
+ var getSelectedWarningId = createSelector(selectPublicWarningState, function (publicWarningStore) {
8427
8504
  return (publicWarningStore == null ? void 0 : publicWarningStore.selectedWarningId) || '';
8428
8505
  });
8429
- var getSelectedPublicIsFormDirty = createSelector(getPublicWarningStore, function (publicWarningStore) {
8506
+ var getSelectedPublicIsFormDirty = createSelector(selectPublicWarningState, function (publicWarningStore) {
8430
8507
  return (publicWarningStore == null ? void 0 : publicWarningStore.isFormDirty) || false;
8431
8508
  });
8432
- var getWarningType = createSelector(getPublicWarningStore, function (publicWarningStore) {
8509
+ var getWarningType = createSelector(selectPublicWarningState, function (publicWarningStore) {
8433
8510
  return publicWarningStore == null ? void 0 : publicWarningStore.warningType;
8434
8511
  });
8435
- var getPublicWarningPanelId = createSelector(getPublicWarningStore, function (publicWarningStore) {
8512
+ var getPublicWarningPanelId = createSelector(selectPublicWarningState, function (publicWarningStore) {
8436
8513
  return (publicWarningStore == null ? void 0 : publicWarningStore.panelId) || '';
8437
8514
  });
8438
8515
 
@@ -9361,6 +9438,32 @@ var useWarnings = function useWarnings(disabled) {
9361
9438
  dataUpdatedAt: dataUpdatedAt
9362
9439
  };
9363
9440
  };
9441
+ function useAutoRefetchOnExpiry(combinedWarnings, refetchWarnings) {
9442
+ React__default.useEffect(function () {
9443
+ if (!combinedWarnings || combinedWarnings.length === 0) {
9444
+ return undefined;
9445
+ }
9446
+ var now = new Date();
9447
+ var futureEnds = combinedWarnings.map(function (wn) {
9448
+ return new Date(wn.warningDetail.validUntil);
9449
+ }).filter(function (date) {
9450
+ return date > now;
9451
+ });
9452
+ if (futureEnds.length === 0) {
9453
+ return undefined;
9454
+ }
9455
+ var nextExpiry = Math.min.apply(Math, futureEnds.map(function (date) {
9456
+ return date.getTime();
9457
+ }));
9458
+ var msUntilNext = nextExpiry - now.getTime();
9459
+ var timeout = setTimeout(function () {
9460
+ refetchWarnings();
9461
+ }, msUntilNext + 1000);
9462
+ return function () {
9463
+ clearTimeout(timeout);
9464
+ };
9465
+ }, [combinedWarnings, refetchWarnings]);
9466
+ }
9364
9467
 
9365
9468
  var warningFormConfirmationOptions = function warningFormConfirmationOptions(t) {
9366
9469
  return {
@@ -11347,6 +11450,7 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
11347
11450
  isFetching = _useWarnings.isFetching,
11348
11451
  error = _useWarnings.error,
11349
11452
  dataUpdatedAt = _useWarnings.dataUpdatedAt;
11453
+ useAutoRefetchOnExpiry(combinedWarnings, refetchWarnings);
11350
11454
  var lastUpdateTime = dateUtils.dateToString(new Date(dataUpdatedAt), dateUtils.DATE_FORMAT_HOURS);
11351
11455
  var _React$useState = React__default.useState(undefined),
11352
11456
  confirmDialogOptions = _React$useState[0],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "12.13.0",
3
+ "version": "13.1.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -8,25 +8,25 @@
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
10
  "dependencies": {
11
- "@opengeoweb/api": "12.13.0",
12
- "@opengeoweb/shared": "12.13.0",
13
- "@opengeoweb/store": "12.13.0",
14
- "@opengeoweb/webmap-react": "12.13.0",
15
- "@tanstack/react-query": "^5.69.2",
11
+ "@opengeoweb/api": "13.1.0",
12
+ "@opengeoweb/shared": "13.1.0",
13
+ "@opengeoweb/store": "13.1.0",
14
+ "@opengeoweb/webmap-react": "13.1.0",
15
+ "@tanstack/react-query": "^5.85.5",
16
16
  "react-redux": "^9.2.0",
17
- "@opengeoweb/theme": "12.13.0",
18
- "@opengeoweb/form-fields": "12.13.0",
17
+ "@opengeoweb/theme": "13.1.0",
18
+ "@opengeoweb/form-fields": "13.1.0",
19
19
  "react-hook-form": "^7.50.1",
20
20
  "lodash": "^4.17.21",
21
21
  "@reduxjs/toolkit": "^2.6.1",
22
- "@opengeoweb/snackbar": "12.13.0",
22
+ "@opengeoweb/snackbar": "13.1.0",
23
23
  "react-window": "^1.8.10",
24
24
  "react-virtualized-auto-sizer": "^1.0.20",
25
25
  "axios": "^1.7.7",
26
- "@opengeoweb/core": "12.13.0",
27
- "@opengeoweb/webmap": "12.13.0",
28
- "@opengeoweb/authentication": "12.13.0",
29
- "@opengeoweb/sigmet-airmet": "12.13.0",
26
+ "@opengeoweb/core": "13.1.0",
27
+ "@opengeoweb/webmap": "13.1.0",
28
+ "@opengeoweb/authentication": "13.1.0",
29
+ "@opengeoweb/sigmet-airmet": "13.1.0",
30
30
  "react-i18next": "^15.1.1",
31
31
  "i18next": "^25.0.1",
32
32
  "@mui/material": "^7.0.1",
@@ -7,4 +7,5 @@ interface WarningsResponse {
7
7
  dataUpdatedAt: number;
8
8
  }
9
9
  export declare const useWarnings: (disabled?: boolean) => WarningsResponse;
10
+ export declare function useAutoRefetchOnExpiry(combinedWarnings: Warning[], refetchWarnings: () => void): void;
10
11
  export {};
@@ -44,6 +44,7 @@ interface DeleteDrawingParams {
44
44
  export declare const useMutateDeleteDrawing: () => UseMutationResult<{
45
45
  id: string;
46
46
  }, Error, DeleteDrawingParams>;
47
+ export declare const BE_EDITOR_WARNING = "Warning is being edited by another user and cannot be updated";
47
48
  export declare const usePostMaritimeWarnings: () => MutationReturnType<MaritimeWarning[]>;
48
49
  interface MutateMaritimeEditorParams {
49
50
  domain: MaritimeWarningsType;
@@ -16,7 +16,7 @@ export interface MaritimeWarningsFormProps {
16
16
  onAddWarning: () => void;
17
17
  onChangeWarning: (id: string, newValues: Partial<MaritimeWarningItemAttributes>) => void;
18
18
  onMoveWarning: (oldIndex: number, newIndex: number) => void;
19
- onSubmit: () => void;
19
+ onSubmit: () => Promise<void>;
20
20
  onClear: () => void;
21
21
  onToggleReadOnly: (isReadOnly: boolean) => void;
22
22
  isReadOnly: boolean;
@@ -11,3 +11,4 @@ export declare const CoastalWatersLight: Story;
11
11
  export declare const CoastalWatersDark: Story;
12
12
  export declare const EditorToggleDemo: Story;
13
13
  export declare const EditorTakeoverDemo: Story;
14
+ export declare const PublishErrorDemo: Story;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { TFunction } from 'i18next';
3
- export declare const VALID_FROM_MAX_HOURS_AFTER_CURRENT = 168;
3
+ export declare const VALID_FROM_MAX_HOURS_AFTER_CURRENT = 192;
4
4
  export declare const isValueBeforeCurrentTime: (value: string, t: TFunction) => boolean | string;
5
5
  export declare const isMaxHoursAfterCurrentTime: (value: string, t: TFunction) => boolean | string;
6
6
  export declare const ValidFrom: React.FC<{
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { TFunction } from 'i18next';
3
- export declare const VALID_UNTIL_MAX_HOURS_AFTER_CURRENT = 180;
3
+ export declare const VALID_UNTIL_MAX_HOURS_AFTER_CURRENT = 192;
4
4
  export declare const VALID_UNTIL_MIN_HOURS_AFTER_VALID_FROM = 1;
5
5
  export declare const isValueBeforeCurrentTime: (value: string, t: TFunction) => boolean | string;
6
6
  export declare const isMaxHoursAfterCurrentTime: (value: string, t: TFunction) => boolean | string;
@@ -1,27 +1,6 @@
1
1
  import { WarningModuleStore } from '../types';
2
2
  import { WarningFormState } from './reducer';
3
- export declare const getPublicWarningStore: (store: WarningModuleStore) => WarningFormState;
4
- export declare const selectPublicWarningState: ((state: WarningModuleStore) => WarningFormState) & {
5
- clearCache: () => void;
6
- resultsCount: () => number;
7
- resetResultsCount: () => void;
8
- } & {
9
- resultFunc: (resultFuncArgs_0: WarningFormState) => WarningFormState;
10
- memoizedResultFunc: ((resultFuncArgs_0: WarningFormState) => WarningFormState) & {
11
- clearCache: () => void;
12
- resultsCount: () => number;
13
- resetResultsCount: () => void;
14
- };
15
- lastResult: () => WarningFormState;
16
- dependencies: [(store: WarningModuleStore) => WarningFormState];
17
- recomputations: () => number;
18
- resetRecomputations: () => void;
19
- dependencyRecomputations: () => number;
20
- resetDependencyRecomputations: () => void;
21
- } & {
22
- argsMemoize: typeof import("reselect").weakMapMemoize;
23
- memoize: typeof import("reselect").weakMapMemoize;
24
- };
3
+ export declare const selectPublicWarningState: (store: WarningModuleStore) => WarningFormState;
25
4
  export declare const getPublicWarningObject: ((state: WarningModuleStore) => import("../warningsDrawings/types").DrawingListItem | undefined) & {
26
5
  clearCache: () => void;
27
6
  resultsCount: () => number;