@opengeoweb/warnings 12.13.0 → 13.0.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,24 @@ 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
  });
7341
+ },
7342
+ onError: function onError(error) {
7343
+ // the BE_EDITOR_WARNING is handled in shouldGiveEditorWarning
7344
+ if (error.message !== BE_EDITOR_WARNING) {
7345
+ setError({
7346
+ title: error.message,
7347
+ severity: 'error'
7348
+ });
7349
+ }
7297
7350
  }
7298
7351
  });
7299
- case 4:
7352
+ case 5:
7300
7353
  case "end":
7301
7354
  return _context.stop();
7302
7355
  }
@@ -7355,12 +7408,7 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
7355
7408
  void updateEditor(false);
7356
7409
  }, [t, domainLabel, mutateEditor, domain, refetchWarnings, confirmDialog, showSnackbar]);
7357
7410
  useEffect(function () {
7358
- if (publishError) {
7359
- setError({
7360
- title: publishError.message,
7361
- severity: 'error'
7362
- });
7363
- } else if (editorError && editorError.cause !== 409) {
7411
+ if (editorError && editorError.cause !== 409) {
7364
7412
  setError({
7365
7413
  title: editorError.message,
7366
7414
  severity: 'error'
@@ -7368,10 +7416,10 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
7368
7416
  } else {
7369
7417
  setError(undefined);
7370
7418
  }
7371
- }, [publishError, editorError]);
7419
+ }, [editorError]);
7372
7420
  var shouldGiveEditorWarning = React__default.useCallback(function (newEditor, oldEditor) {
7373
7421
  var oldEditorIsYou = oldEditor && oldEditor === (auth == null ? void 0 : auth.username);
7374
- if (oldEditorIsYou && newEditor && newEditor !== oldEditor) {
7422
+ if (oldEditorIsYou && (newEditor || publishError) && newEditor !== oldEditor) {
7375
7423
  setError({
7376
7424
  title: t('maritime-editor-off', {
7377
7425
  domain: domainLabel
@@ -7379,7 +7427,7 @@ var MaritimeWarningsFormConnect = function MaritimeWarningsFormConnect(_ref) {
7379
7427
  severity: 'warning'
7380
7428
  });
7381
7429
  }
7382
- }, [auth == null ? void 0 : auth.username, domainLabel, t]);
7430
+ }, [auth == null ? void 0 : auth.username, domainLabel, publishError, t]);
7383
7431
  useEffect(function () {
7384
7432
  // Only give editor warning when the change in editor is from a refetch
7385
7433
  if (hasFetched) {
@@ -7720,6 +7768,24 @@ var Form = function Form(_ref5) {
7720
7768
  var formMethods = useForm({
7721
7769
  defaultValues: {}
7722
7770
  });
7771
+ var endOfWarningValidity = publicWarningDetails == null ? void 0 : publicWarningDetails.validUntil;
7772
+ React.useEffect(function () {
7773
+ if (!endOfWarningValidity || formState !== 'amending') {
7774
+ return function () {};
7775
+ }
7776
+ var end = new Date(endOfWarningValidity).getTime();
7777
+ var now = Date.now();
7778
+ if (end <= now) {
7779
+ onCloseForm();
7780
+ return function () {};
7781
+ }
7782
+ var timer = setTimeout(function () {
7783
+ onCloseForm();
7784
+ }, end - now + 1000);
7785
+ return function () {
7786
+ return clearTimeout(timer);
7787
+ };
7788
+ }, [endOfWarningValidity, formState, onCloseForm]);
7723
7789
  var initialPublicWarningArea = (publicWarningDetails == null || (_publicWarningDetails = publicWarningDetails.areas) == null ? void 0 : _publicWarningDetails.length) && (publicWarningDetails == null || (_publicWarningDetails2 = publicWarningDetails.areas[0]) == null ? void 0 : _publicWarningDetails2.geoJSON);
7724
7790
  var _React$useState4 = React.useState(initialPublicWarningArea),
7725
7791
  warningGeoJSONFeature = _React$useState4[0],
@@ -7816,11 +7882,27 @@ var Form = function Form(_ref5) {
7816
7882
  })) : null
7817
7883
  });
7818
7884
  };
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
- };
7885
+ var cancelAviationProduct = /*#__PURE__*/function () {
7886
+ var _ref1 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(warningType) {
7887
+ var result;
7888
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
7889
+ while (1) switch (_context6.prev = _context6.next) {
7890
+ case 0:
7891
+ _context6.next = 2;
7892
+ return onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType, isVAPhenomenon(selectedAviationProduct, ProductAction.CANCEL) && watch('vaSigmetMoveToFIR'));
7893
+ case 2:
7894
+ result = _context6.sent;
7895
+ return _context6.abrupt("return", result != null ? result : null);
7896
+ case 4:
7897
+ case "end":
7898
+ return _context6.stop();
7899
+ }
7900
+ }, _callee6);
7901
+ }));
7902
+ return function cancelAviationProduct(_x3) {
7903
+ return _ref1.apply(this, arguments);
7904
+ };
7905
+ }();
7824
7906
  var getPublishButtonLabel = function getPublishButtonLabel() {
7825
7907
  if (isCancelling) {
7826
7908
  return t('cancelling');
@@ -7836,7 +7918,7 @@ var Form = function Form(_ref5) {
7836
7918
  return t('warning-button-publish');
7837
7919
  };
7838
7920
  var handleSubmitAviationProduct = /*#__PURE__*/function () {
7839
- var _ref1 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(action, warningType) {
7921
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(action, warningType) {
7840
7922
  var formValues;
7841
7923
  return _regeneratorRuntime().wrap(function _callee0$(_context0) {
7842
7924
  while (1) switch (_context0.prev = _context0.next) {
@@ -7871,35 +7953,35 @@ var Form = function Form(_ref5) {
7871
7953
  case 14:
7872
7954
  toggleIsDraft(false);
7873
7955
  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) {
7956
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(formValues) {
7957
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
7958
+ while (1) switch (_context8.prev = _context8.next) {
7877
7959
  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) {
7960
+ _context8.next = 2;
7961
+ return showConfirmDialog(action).then(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
7962
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
7963
+ while (1) switch (_context7.prev = _context7.next) {
7882
7964
  case 0:
7883
7965
  setIsPublishing(true);
7884
- _context6.next = 3;
7966
+ _context7.next = 3;
7885
7967
  return onSaveAviationForm(formValues, 'PUBLISHED', warningType)["catch"](function () {});
7886
7968
  case 3:
7887
7969
  case "end":
7888
- return _context6.stop();
7970
+ return _context7.stop();
7889
7971
  }
7890
- }, _callee6);
7972
+ }, _callee7);
7891
7973
  })));
7892
7974
  case 2:
7893
7975
  setIsPublishing(false);
7894
7976
  onCloseForm();
7895
7977
  case 4:
7896
7978
  case "end":
7897
- return _context7.stop();
7979
+ return _context8.stop();
7898
7980
  }
7899
- }, _callee7);
7981
+ }, _callee8);
7900
7982
  }));
7901
- return function (_x5) {
7902
- return _ref10.apply(this, arguments);
7983
+ return function (_x6) {
7984
+ return _ref11.apply(this, arguments);
7903
7985
  };
7904
7986
  }())();
7905
7987
  return _context0.abrupt("break", 23);
@@ -7914,36 +7996,35 @@ var Form = function Form(_ref5) {
7914
7996
  return _context0.abrupt("break", 23);
7915
7997
  case 19:
7916
7998
  void handleSubmit(/*#__PURE__*/function () {
7917
- var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(formValues) {
7999
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(formValues) {
7918
8000
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
7919
8001
  while (1) switch (_context9.prev = _context9.next) {
7920
8002
  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:
8003
+ _context9.prev = 0;
8004
+ _context9.next = 3;
8005
+ return showConfirmDialog(action);
8006
+ case 3:
8007
+ setIsPublishing(true);
8008
+ // 1) Publish amended warning
8009
+ _context9.next = 6;
8010
+ return onSaveAviationForm(formValues, 'PUBLISHED', warningType);
8011
+ case 6:
8012
+ _context9.next = 8;
8013
+ return cancelAviationProduct(warningType);
8014
+ case 8:
8015
+ onCloseForm();
8016
+ case 9:
8017
+ _context9.prev = 9;
8018
+ setIsPublishing(false);
8019
+ return _context9.finish(9);
8020
+ case 12:
7940
8021
  case "end":
7941
8022
  return _context9.stop();
7942
8023
  }
7943
- }, _callee9);
8024
+ }, _callee9, null, [[0,, 9, 12]]);
7944
8025
  }));
7945
- return function (_x6) {
7946
- return _ref12.apply(this, arguments);
8026
+ return function (_x7) {
8027
+ return _ref13.apply(this, arguments);
7947
8028
  };
7948
8029
  }())();
7949
8030
  return _context0.abrupt("break", 23);
@@ -7957,8 +8038,8 @@ var Form = function Form(_ref5) {
7957
8038
  }
7958
8039
  }, _callee0);
7959
8040
  }));
7960
- return function handleSubmitAviationProduct(_x3, _x4) {
7961
- return _ref1.apply(this, arguments);
8041
+ return function handleSubmitAviationProduct(_x4, _x5) {
8042
+ return _ref10.apply(this, arguments);
7962
8043
  };
7963
8044
  }();
7964
8045
  var onPressClear = function onPressClear() {
@@ -8067,7 +8148,8 @@ var Form = function Form(_ref5) {
8067
8148
  return fetchSigmetTAC(product);
8068
8149
  },
8069
8150
  storedGeoJSON: storedStartGeoJSON,
8070
- storedEndGeoJSON: storedEndGeoJSON
8151
+ storedEndGeoJSON: storedEndGeoJSON,
8152
+ isAmending: formState === 'amending'
8071
8153
  })
8072
8154
  });
8073
8155
  }
@@ -8090,7 +8172,8 @@ var Form = function Form(_ref5) {
8090
8172
  getTAC: function getTAC(product) {
8091
8173
  return fetchAirmetTAC(product);
8092
8174
  },
8093
- storedGeoJSON: storedStartGeoJSON
8175
+ storedGeoJSON: storedStartGeoJSON,
8176
+ isAmending: formState === 'amending'
8094
8177
  })
8095
8178
  });
8096
8179
  }
@@ -9361,6 +9444,32 @@ var useWarnings = function useWarnings(disabled) {
9361
9444
  dataUpdatedAt: dataUpdatedAt
9362
9445
  };
9363
9446
  };
9447
+ function useAutoRefetchOnExpiry(combinedWarnings, refetchWarnings) {
9448
+ React__default.useEffect(function () {
9449
+ if (!combinedWarnings || combinedWarnings.length === 0) {
9450
+ return undefined;
9451
+ }
9452
+ var now = new Date();
9453
+ var futureEnds = combinedWarnings.map(function (wn) {
9454
+ return new Date(wn.warningDetail.validUntil);
9455
+ }).filter(function (date) {
9456
+ return date > now;
9457
+ });
9458
+ if (futureEnds.length === 0) {
9459
+ return undefined;
9460
+ }
9461
+ var nextExpiry = Math.min.apply(Math, futureEnds.map(function (date) {
9462
+ return date.getTime();
9463
+ }));
9464
+ var msUntilNext = nextExpiry - now.getTime();
9465
+ var timeout = setTimeout(function () {
9466
+ refetchWarnings();
9467
+ }, msUntilNext + 1000);
9468
+ return function () {
9469
+ clearTimeout(timeout);
9470
+ };
9471
+ }, [combinedWarnings, refetchWarnings]);
9472
+ }
9364
9473
 
9365
9474
  var warningFormConfirmationOptions = function warningFormConfirmationOptions(t) {
9366
9475
  return {
@@ -11347,6 +11456,7 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
11347
11456
  isFetching = _useWarnings.isFetching,
11348
11457
  error = _useWarnings.error,
11349
11458
  dataUpdatedAt = _useWarnings.dataUpdatedAt;
11459
+ useAutoRefetchOnExpiry(combinedWarnings, refetchWarnings);
11350
11460
  var lastUpdateTime = dateUtils.dateToString(new Date(dataUpdatedAt), dateUtils.DATE_FORMAT_HOURS);
11351
11461
  var _React$useState = React__default.useState(undefined),
11352
11462
  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.0.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.0.0",
12
+ "@opengeoweb/shared": "13.0.0",
13
+ "@opengeoweb/store": "13.0.0",
14
+ "@opengeoweb/webmap-react": "13.0.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.0.0",
18
+ "@opengeoweb/form-fields": "13.0.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.0.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.0.0",
27
+ "@opengeoweb/webmap": "13.0.0",
28
+ "@opengeoweb/authentication": "13.0.0",
29
+ "@opengeoweb/sigmet-airmet": "13.0.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;