@opengeoweb/warnings 12.2.0 → 12.3.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,27 +1,27 @@
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, DrawPolygon, Visibility, Add, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, Thunderstorm, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, breakpoints, Options, Close, ChevronDown, ChevronUp, Copy, Update, Success, Expire, Remove, ArrowUpCompact, ArrowDownCompact } from '@opengeoweb/theme';
4
- import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawingToolSelectors, layerSelectors, uiSelectors, drawingToolActions, layerActions, useSetupDialog, genericSelectors, selectorMemoizationOptions, useUpdateSharedData, mapListener, layersListener, drawingToolListener, syncGroupsListener, syncGroupsReducer, drawingToolReducer, uiReducer, layerReducer, mapReducer } from '@opengeoweb/store';
3
+ import { Polygons, ExitDomain, Share, Edit, Delete, DrawPolygon, Visibility, Add, CoastalEvent, TemperatureLow, TemperatureHigh, Rain, Snow, Lightning, Fog, Wind, Thunderstorm, VulcanicEruption, Haze, FreezingPrecipitation, ModerateAircraftIcing, SevereAircraftIcing, ModerateTurbulence, SevereTurbulence, SandStorm, RadioactiveMaterials, breakpoints, Options, Close, ChevronDown, ChevronUp, Copy, Update, Cancel, Success, Expire, Remove, ArrowUpCompact, ArrowDownCompact } from '@opengeoweb/theme';
4
+ import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawingToolSelectors, layerSelectors, uiSelectors, drawingToolActions, layerActions, useSetupDialog, genericSelectors, selectorMemoizationOptions, useUpdateSharedData, mapListener, layersListener, drawingToolListener, syncGroupsListener, openlayersListener, syncGroupsReducer, drawingToolReducer, uiReducer, layerReducer, mapReducer } 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
- import { SHARED_NAMESPACE, useConfirmationDialog, dateUtils, ToggleMenu, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, FilterChip, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, isAxiosError } from '@opengeoweb/shared';
6
+ import { SHARED_NAMESPACE, useConfirmationDialog, dateUtils, ToggleMenu, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, sessionStorageProvider, CustomToggleButton, Filter, FilterChip, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, isAxiosError } from '@opengeoweb/shared';
7
7
  import { createEntityAdapter, createSlice, createSelector, current, createListenerMiddleware, combineReducers, configureStore } from '@reduxjs/toolkit';
8
8
  import { defaultBbox } from '@opengeoweb/core';
9
9
  import { FORM_FIELDS_NAMESPACE, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, useDraftFormHelpers, errorMessages, isEmpty, ReactHookFormDateTime, isXHoursAfter, isXHoursBefore } from '@opengeoweb/form-fields';
10
- import { SA_NAMESPACE, airmetConfig, sigmetConfig, isInstanceOfCancelSigmet, isInstanceOfCancelAirmet, getDefaultValidUntilValue, useShortTestHelpers, SigmetForm, AirmetForm, ProductAction, getConfirmationDialogCancelLabel, getConfirmationDialogButtonLabel, getConfirmationDialogContent, getConfirmationDialogTitle, isVAPhenomenon, CancelSigmetVolcanicMovements, createAirmetPostParameter, createSigmetPostParameter, getProductFormMode } from '@opengeoweb/sigmet-airmet';
10
+ import { SA_NAMESPACE, airmetConfig, sigmetConfig, isInstanceOfCancelSigmet, isInstanceOfCancelAirmet, getDefaultValidUntilValue, useShortTestHelpers, SigmetForm, AirmetForm, ProductAction, isVAPhenomenon, prepareCancelSigmet, getConfirmationDialogCancelLabel, getConfirmationDialogButtonLabel, getConfirmationDialogContent, getConfirmationDialogTitle, CancelSigmetVolcanicMovements, createAirmetPostParameter, createSigmetPostParameter, getProductFormMode } from '@opengeoweb/sigmet-airmet';
11
11
  import { LayerType, generateMapId } from '@opengeoweb/webmap';
12
- import 'i18next';
12
+ import { t } from 'i18next';
13
13
  import { useTranslation } from 'react-i18next';
14
14
  import { snackbarActions, snackbarTypes, snackbarListener, snackbarReducer } from '@opengeoweb/snackbar';
15
15
  import * as React from 'react';
16
16
  import React__default, { useState, useEffect, useRef, useMemo, useCallback } from 'react';
17
- import { styled, Box, Typography, ListItem, Paper, ListItemButton, Stack, Grid2, LinearProgress, Button, FormHelperText, MenuItem, Card, CardContent, Tabs, Tab, CircularProgress, Menu, DialogTitle, DialogContent, Switch, ListItemText } from '@mui/material';
17
+ import { styled, Box, Typography, ListItem, Paper, ListItemButton, Stack, Grid, LinearProgress, Button, FormHelperText, MenuItem, Card, CardContent, Tabs, Tab, CircularProgress, Menu, DialogTitle, DialogContent, Switch, ListItemText } from '@mui/material';
18
18
  import { VariableSizeList } from 'react-window';
19
19
  import AutoSizer from 'react-virtualized-auto-sizer';
20
20
  import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider, getHeaders, handleResponse, useAuthQuery, useAuthenticationContext, ProductStatus, AirmetPhenomena, SigmetPhenomena, optimisticUpdate } from '@opengeoweb/api';
21
21
  import { http, HttpResponse, passthrough, delay } from 'msw';
22
22
  import { concat, isEqual, cloneDeep, clamp, groupBy, pick } from 'lodash';
23
23
  import { useFormContext, useForm, FormProvider } from 'react-hook-form';
24
- import { getConfig, useAuthenticationContext as useAuthenticationContext$1 } from '@opengeoweb/authentication';
24
+ import { useAuthenticationContext as useAuthenticationContext$1 } from '@opengeoweb/authentication';
25
25
  import { useQueryClient, useMutation } from '@tanstack/react-query';
26
26
 
27
27
  var en = {
@@ -1694,10 +1694,10 @@ var Objects = function Objects(_ref2) {
1694
1694
  children: jsx(ListItem, {
1695
1695
  style: style,
1696
1696
  disablePadding: true,
1697
- secondaryAction: jsxs(Grid2, {
1697
+ secondaryAction: jsxs(Grid, {
1698
1698
  container: true,
1699
1699
  rowSpacing: 1,
1700
- children: [jsx(Grid2, {
1700
+ children: [jsx(Grid, {
1701
1701
  className: "objectActions",
1702
1702
  children: jsx(ToggleMenu, {
1703
1703
  buttonSx: (_buttonSx = {
@@ -1730,7 +1730,7 @@ var Objects = function Objects(_ref2) {
1730
1730
  icon: jsx(ExitDomain, {})
1731
1731
  }]
1732
1732
  })
1733
- }), object.scope === 'user' && jsx(Grid2, {
1733
+ }), object.scope === 'user' && jsx(Grid, {
1734
1734
  className: "objectActions",
1735
1735
  children: jsx(ToggleMenu, {
1736
1736
  menuTitle: t('object-manager-options-menu'),
@@ -1988,9 +1988,6 @@ var getApiRoutes$1 = function getApiRoutes(axiosInstance) {
1988
1988
  },
1989
1989
  updateWarning: function updateWarning(warningId, data) {
1990
1990
  return axiosInstance.post("/warnings/" + warningId + "/", data);
1991
- },
1992
- deleteWarning: function deleteWarning(warningId) {
1993
- return axiosInstance.post("/warnings/" + warningId + "?delete=true");
1994
1991
  }
1995
1992
  };
1996
1993
  };
@@ -7582,12 +7579,6 @@ var getApiRoutes = function getApiRoutes(axiosInstance) {
7582
7579
  },
7583
7580
  updateWarning: function updateWarning(warningId, data) {
7584
7581
  return axiosInstance.post("/warnings/" + warningId + "/", data);
7585
- },
7586
- deleteWarning: function deleteWarning(warningId) {
7587
- warningList.splice(warningList.findIndex(function (warning) {
7588
- return warning.id === warningId;
7589
- }), 1);
7590
- return axiosInstance.post("/warnings/" + warningId + "?delete=true");
7591
7582
  }
7592
7583
  };
7593
7584
  };
@@ -7808,20 +7799,20 @@ var DrawingToolFormContentsNoMemo = function DrawingToolFormContentsNoMemo(_ref)
7808
7799
  title: dialogError,
7809
7800
  shouldClose: true
7810
7801
  })
7811
- }), jsxs(Grid2, {
7802
+ }), jsxs(Grid, {
7812
7803
  "data-testid": "drawingToolForm",
7813
7804
  container: true,
7814
7805
  direction: "column",
7815
7806
  spacing: 1,
7816
7807
  padding: 2,
7817
- children: [jsx(Grid2, {
7808
+ children: [jsx(Grid, {
7818
7809
  children: jsx(Typography, {
7819
7810
  variant: "body2",
7820
7811
  children: t('drawing-tool-form-tools')
7821
7812
  })
7822
- }), jsx(Grid2, {
7813
+ }), jsx(Grid, {
7823
7814
  container: true,
7824
- children: jsxs(Grid2, {
7815
+ children: jsxs(Grid, {
7825
7816
  children: [drawModes.map(function (mode) {
7826
7817
  return jsx(CustomIconButton, {
7827
7818
  variant: "tool",
@@ -7867,10 +7858,10 @@ var DrawingToolFormContentsNoMemo = function DrawingToolFormContentsNoMemo(_ref)
7867
7858
  }
7868
7859
  })]
7869
7860
  })
7870
- }), jsx(Grid2, {
7861
+ }), jsx(Grid, {
7871
7862
  container: true,
7872
7863
  size: "grow",
7873
- children: jsx(Grid2, {
7864
+ children: jsx(Grid, {
7874
7865
  size: {
7875
7866
  xs: 12,
7876
7867
  sm: 6
@@ -7893,7 +7884,7 @@ var DrawingToolFormContentsNoMemo = function DrawingToolFormContentsNoMemo(_ref)
7893
7884
  })
7894
7885
  })
7895
7886
  })
7896
- }), jsxs(Grid2, {
7887
+ }), jsxs(Grid, {
7897
7888
  children: [jsx(ReactHookFormTextField, {
7898
7889
  name: "objectName",
7899
7890
  label: t('drawing-tool-form-object-name'),
@@ -8417,7 +8408,7 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
8417
8408
  }));
8418
8409
  };
8419
8410
 
8420
- var config$1 = getConfig();
8411
+ var config$1 = sessionStorageProvider.getConfig();
8421
8412
  var airmetBaseUrl = config$1.GW_AIRMET_BASE_URL || '';
8422
8413
  var sigmetBaseUrl = config$1.GW_SIGMET_BASE_URL || '';
8423
8414
  // API
@@ -9053,6 +9044,7 @@ var WarningsMapView = function WarningsMapView(_ref) {
9053
9044
  children: jsxs(OpenLayersMapView, {
9054
9045
  view: viewRef.current,
9055
9046
  holdShiftToScroll: true,
9047
+ mapId: mapId,
9056
9048
  children: [jsx(MapControls, {
9057
9049
  style: {
9058
9050
  top: 0
@@ -9842,12 +9834,12 @@ var Phenomenon = function Phenomenon(_ref) {
9842
9834
  children: warningFormPhenomena.map(function (phenomenon) {
9843
9835
  return jsx(MenuItem, {
9844
9836
  value: phenomenon.key,
9845
- children: jsxs(Grid2, {
9837
+ children: jsxs(Grid, {
9846
9838
  container: true,
9847
9839
  justifyContent: "space-between",
9848
- children: [jsx(Grid2, {
9840
+ children: [jsx(Grid, {
9849
9841
  children: t(phenomenon.translationKey)
9850
- }), jsx(Grid2, {
9842
+ }), jsx(Grid, {
9851
9843
  sx: {
9852
9844
  minWidth: 56
9853
9845
  },
@@ -10091,16 +10083,16 @@ var ContainerGrid = styled('div')(function (_ref3) {
10091
10083
  var theme = _ref3.theme;
10092
10084
  return _ref4 = {
10093
10085
  backgroundColor: theme.palette.background.paper,
10094
- '.MuiGrid2-grid-sm-6, .MuiGrid2-grid-sm-4': {
10086
+ '.MuiGrid-grid-sm-6, .MuiGrid-grid-sm-4': {
10095
10087
  width: '100%',
10096
10088
  minWidth: '100%'
10097
10089
  }
10098
10090
  }, _ref4[containerQueryBreakpoint] = {
10099
- '.MuiGrid2-grid-sm-6': {
10091
+ '.MuiGrid-grid-sm-6': {
10100
10092
  width: sm6Width,
10101
10093
  minWidth: sm6Width
10102
10094
  },
10103
- '.MuiGrid2-grid-sm-4': {
10095
+ '.MuiGrid-grid-sm-4': {
10104
10096
  width: sm4Width,
10105
10097
  minWidth: sm4Width
10106
10098
  }
@@ -10266,6 +10258,7 @@ var Form = function Form(_ref5) {
10266
10258
  _ref5$warningType = _ref5.warningType,
10267
10259
  warningType = _ref5$warningType === void 0 ? 'public' : _ref5$warningType,
10268
10260
  mode = _ref5.mode,
10261
+ formState = _ref5.formState,
10269
10262
  _ref5$onSetViewModeRe = _ref5.onSetViewModeResetArea,
10270
10263
  onSetViewModeResetArea = _ref5$onSetViewModeRe === void 0 ? function () {} : _ref5$onSetViewModeRe,
10271
10264
  storedStartGeoJSON = _ref5.storedStartGeoJSON,
@@ -10299,7 +10292,8 @@ var Form = function Form(_ref5) {
10299
10292
  reset = _useFormContext.reset,
10300
10293
  dirtyFields = _useFormContext.formState.dirtyFields,
10301
10294
  getValues = _useFormContext.getValues,
10302
- setValue = _useFormContext.setValue;
10295
+ setValue = _useFormContext.setValue,
10296
+ watch = _useFormContext.watch;
10303
10297
  var _useDraftFormHelpers = useDraftFormHelpers(),
10304
10298
  toggleIsDraft = _useDraftFormHelpers.toggleIsDraft,
10305
10299
  DraftFieldHelper = _useDraftFormHelpers.DraftFieldHelper;
@@ -10440,7 +10434,20 @@ var Form = function Form(_ref5) {
10440
10434
  return _ref12.apply(this, arguments);
10441
10435
  };
10442
10436
  }())();
10437
+ break;
10443
10438
  case ProductAction.CANCEL:
10439
+ void showConfirmDialog(action).then(function () {
10440
+ setIsPublishing(true);
10441
+ // if volcanic sigmet - add to which FIR it's moving
10442
+ if (isVAPhenomenon(selectedAviationProduct, action)) {
10443
+ void onSaveAviationForm(prepareCancelSigmet(selectedAviationProduct, watch('vaSigmetMoveToFIR')), 'CANCELLED', warningType);
10444
+ } else {
10445
+ void onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType);
10446
+ }
10447
+ setIsPublishing(false);
10448
+ onCloseForm();
10449
+ });
10450
+ break;
10444
10451
  case ProductAction.RENEW:
10445
10452
  case ProductAction.DISCARD:
10446
10453
  case ProductAction.DUPLICATE:
@@ -10581,14 +10588,14 @@ var Form = function Form(_ref5) {
10581
10588
  storedGeoJSON: storedStartGeoJSON
10582
10589
  })
10583
10590
  }) : jsx(ContainerGrid, {
10584
- children: jsxs(Grid2, {
10591
+ children: jsxs(Grid, {
10585
10592
  size: {
10586
10593
  xs: 12
10587
10594
  },
10588
10595
  container: true,
10589
10596
  rowSpacing: 2,
10590
10597
  columnSpacing: 2,
10591
- children: [jsx(Grid2, {
10598
+ children: [jsx(Grid, {
10592
10599
  size: {
10593
10600
  xs: 12
10594
10601
  },
@@ -10596,7 +10603,7 @@ var Form = function Form(_ref5) {
10596
10603
  isDisabled: areFieldsDisabled,
10597
10604
  isReadOnly: isReadOnly
10598
10605
  })
10599
- }), jsx(Grid2, {
10606
+ }), jsx(Grid, {
10600
10607
  size: {
10601
10608
  xs: 12
10602
10609
  },
@@ -10607,7 +10614,7 @@ var Form = function Form(_ref5) {
10607
10614
  onAddObject: onAddObject,
10608
10615
  isDisabled: areFieldsDisabled || isReadOnly
10609
10616
  })
10610
- }), jsx(Grid2, {
10617
+ }), jsx(Grid, {
10611
10618
  size: {
10612
10619
  xs: 12
10613
10620
  },
@@ -10616,7 +10623,7 @@ var Form = function Form(_ref5) {
10616
10623
  defaultMapPreset: defaultMapPreset,
10617
10624
  isSnapshot: isSnapshot
10618
10625
  })
10619
- }), jsx(Grid2, {
10626
+ }), jsx(Grid, {
10620
10627
  size: {
10621
10628
  xs: 12,
10622
10629
  sm: 6
@@ -10625,7 +10632,7 @@ var Form = function Form(_ref5) {
10625
10632
  isDisabled: areFieldsDisabled,
10626
10633
  isReadOnly: isReadOnly
10627
10634
  })
10628
- }), jsx(Grid2, {
10635
+ }), jsx(Grid, {
10629
10636
  size: {
10630
10637
  xs: 12,
10631
10638
  sm: 6
@@ -10634,13 +10641,13 @@ var Form = function Form(_ref5) {
10634
10641
  isDisabled: areFieldsDisabled,
10635
10642
  isReadOnly: isReadOnly
10636
10643
  })
10637
- }), jsxs(Grid2, {
10644
+ }), jsxs(Grid, {
10638
10645
  size: {
10639
10646
  xs: 12
10640
10647
  },
10641
10648
  container: true,
10642
10649
  spacing: 2,
10643
- children: [jsx(Grid2, {
10650
+ children: [jsx(Grid, {
10644
10651
  size: {
10645
10652
  xs: 12,
10646
10653
  sm: 6
@@ -10649,7 +10656,7 @@ var Form = function Form(_ref5) {
10649
10656
  isDisabled: areFieldsDisabled,
10650
10657
  isReadOnly: isReadOnly
10651
10658
  })
10652
- }), jsx(Grid2, {
10659
+ }), jsx(Grid, {
10653
10660
  size: {
10654
10661
  xs: 12,
10655
10662
  sm: 6
@@ -10659,13 +10666,13 @@ var Form = function Form(_ref5) {
10659
10666
  isReadOnly: isReadOnly
10660
10667
  })
10661
10668
  })]
10662
- }), jsx(Grid2, {
10669
+ }), jsx(Grid, {
10663
10670
  size: {
10664
10671
  xs: 12
10665
10672
  },
10666
10673
  container: true,
10667
10674
  spacing: 2,
10668
- children: jsx(Grid2, {
10675
+ children: jsx(Grid, {
10669
10676
  size: {
10670
10677
  xs: 12
10671
10678
  },
@@ -10679,7 +10686,7 @@ var Form = function Form(_ref5) {
10679
10686
  }), jsx(DraftFieldHelper, {}), jsx(ReactHookFormHiddenInput, {
10680
10687
  name: "id"
10681
10688
  })]
10682
- }), !isReadOnly && jsx(Box, {
10689
+ }), formState !== 'cancel' && !isReadOnly && jsx(Box, {
10683
10690
  sx: {
10684
10691
  padding: '24px 10px 14px 10px',
10685
10692
  position: 'absolute',
@@ -10692,10 +10699,10 @@ var Form = function Form(_ref5) {
10692
10699
  border: 'none'
10693
10700
  },
10694
10701
  children: jsx(ContainerGrid, {
10695
- children: jsxs(Grid2, {
10702
+ children: jsxs(Grid, {
10696
10703
  container: true,
10697
10704
  spacing: 2,
10698
- children: [jsx(Grid2, {
10705
+ children: [jsx(Grid, {
10699
10706
  size: {
10700
10707
  xs: 12,
10701
10708
  sm: 4
@@ -10710,7 +10717,7 @@ var Form = function Form(_ref5) {
10710
10717
  onClick: onPressClear,
10711
10718
  children: t('warning-button-clear')
10712
10719
  })
10713
- }), jsx(Grid2, {
10720
+ }), jsx(Grid, {
10714
10721
  size: {
10715
10722
  xs: 12,
10716
10723
  sm: 4
@@ -10736,7 +10743,7 @@ var Form = function Form(_ref5) {
10736
10743
  })]
10737
10744
  })
10738
10745
  })
10739
- }), jsx(Grid2, {
10746
+ }), jsx(Grid, {
10740
10747
  size: {
10741
10748
  xs: 12,
10742
10749
  sm: 4
@@ -10764,6 +10771,51 @@ var Form = function Form(_ref5) {
10764
10771
  })]
10765
10772
  })
10766
10773
  })
10774
+ }), formState === 'cancel' && jsx(Box, {
10775
+ sx: {
10776
+ padding: '24px 10px 14px 10px',
10777
+ position: 'absolute',
10778
+ bottom: 0,
10779
+ width: '100%',
10780
+ backgroundColor: 'geowebColors.background.surfaceApp',
10781
+ boxShadow: '0 2px 4px 0 rgba(0, 0, 0, 0.5)',
10782
+ zIndex: 1,
10783
+ overflowX: 'hidden',
10784
+ border: 'none'
10785
+ },
10786
+ children: jsx(ContainerGrid, {
10787
+ children: jsx(Grid, {
10788
+ container: true,
10789
+ spacing: 2,
10790
+ children: jsx(Grid, {
10791
+ size: {
10792
+ xs: 12,
10793
+ sm: 4,
10794
+ md: 4
10795
+ },
10796
+ children: jsx(Button, {
10797
+ variant: "primary",
10798
+ sx: {
10799
+ width: '100%'
10800
+ },
10801
+ disabled: isSaving,
10802
+ onClick: function onClick() {
10803
+ selectedAviationProduct ? handleSubmitAviationProduct(ProductAction.CANCEL, warningType) : onPressPublish();
10804
+ },
10805
+ children: jsxs("span", {
10806
+ style: {
10807
+ position: 'relative'
10808
+ },
10809
+ children: [isPublishing ? t('warning-button-publishing') : t('warning-button-publish'), isPublishing && jsx(CircularProgress, {
10810
+ "data-testid": "spinner",
10811
+ color: "inherit",
10812
+ sx: spinnerSx
10813
+ })]
10814
+ })
10815
+ })
10816
+ })
10817
+ })
10818
+ })
10767
10819
  })]
10768
10820
  });
10769
10821
  };
@@ -10798,7 +10850,7 @@ var PublicWarningsForm = function PublicWarningsForm(props) {
10798
10850
  * Copyright 2024 - Finnish Meteorological Institute (FMI)
10799
10851
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
10800
10852
  * */
10801
- var config = getConfig();
10853
+ var config = sessionStorageProvider.getConfig();
10802
10854
  var publicWarningBaseUrl = config.GW_DRAWINGS_BASE_URL || '';
10803
10855
  // API
10804
10856
  var getPublicWarningList = function getPublicWarningList(auth) {
@@ -10832,6 +10884,12 @@ var postPublicWarning = function postPublicWarning(auth, data) {
10832
10884
  body: JSON.stringify(data)
10833
10885
  }).then(handleResponse);
10834
10886
  };
10887
+ var deleteWarning = function deleteWarning(warningId, auth) {
10888
+ return fetch(publicWarningBaseUrl + "/warnings/" + warningId + "?delete=true", {
10889
+ headers: getHeaders(auth),
10890
+ method: 'POST'
10891
+ }).then(handleResponse);
10892
+ };
10835
10893
 
10836
10894
  /**
10837
10895
  * @param disabled - Disables fetching, but still returns cached values.
@@ -10993,6 +11051,49 @@ var useMutateWarning = function useMutateWarning(snackBarMessage) {
10993
11051
  }()
10994
11052
  }));
10995
11053
  };
11054
+ var useMutateDeleteWarning = function useMutateDeleteWarning() {
11055
+ var queryClient = useQueryClient();
11056
+ var dispatch = useDispatch();
11057
+ var _useAuthenticationCon3 = useAuthenticationContext(),
11058
+ auth = _useAuthenticationCon3.auth;
11059
+ return useMutation({
11060
+ mutationFn: function mutationFn(_ref6) {
11061
+ var id = _ref6.id;
11062
+ if (!auth) {
11063
+ throw new Error('Authentication context not found');
11064
+ }
11065
+ return deleteWarning(id, auth);
11066
+ },
11067
+ onSuccess: function () {
11068
+ var _onSuccess3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_, variables) {
11069
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
11070
+ while (1) switch (_context3.prev = _context3.next) {
11071
+ case 0:
11072
+ void queryClient.cancelQueries({
11073
+ queryKey: ['public-warning-list']
11074
+ });
11075
+ queryClient.setQueryData(['public-warning-list'], function (old) {
11076
+ return old == null ? void 0 : old.filter(function (warning) {
11077
+ return warning.id !== variables.id;
11078
+ });
11079
+ });
11080
+ dispatch(snackbarActions.openSnackbar({
11081
+ type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
11082
+ key: t('warning-dialog-delete-succes')
11083
+ }));
11084
+ case 3:
11085
+ case "end":
11086
+ return _context3.stop();
11087
+ }
11088
+ }, _callee3);
11089
+ }));
11090
+ function onSuccess(_x5, _x6) {
11091
+ return _onSuccess3.apply(this, arguments);
11092
+ }
11093
+ return onSuccess;
11094
+ }()
11095
+ });
11096
+ };
10996
11097
  var usePublishWarning = function usePublishWarning() {
10997
11098
  return useMutateWarning('warning-publish-succes');
10998
11099
  };
@@ -11209,6 +11310,9 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11209
11310
  if ((selectedAviationProduct == null ? void 0 : selectedAviationProduct.status) === 'DRAFT') {
11210
11311
  return false;
11211
11312
  }
11313
+ if (formState === 'cancel') {
11314
+ return true;
11315
+ }
11212
11316
  if (formState === 'edit') {
11213
11317
  return false;
11214
11318
  }
@@ -11259,6 +11363,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11259
11363
  selectedAviationProduct: selectedAviationProduct,
11260
11364
  warningType: warningType,
11261
11365
  mode: formMode,
11366
+ formState: formState,
11262
11367
  onSetViewModeResetArea: onSetViewModeResetArea,
11263
11368
  storedStartGeoJSON: storedStartGeoJSON,
11264
11369
  storedEndGeoJSON: storedEndGeoJSON
@@ -12376,7 +12481,7 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
12376
12481
  },
12377
12482
  isDisabled: isDisabled,
12378
12483
  size: "medium",
12379
- actionIcon: jsxs(Grid2, {
12484
+ actionIcon: jsxs(Grid, {
12380
12485
  container: true,
12381
12486
  alignItems: "center",
12382
12487
  style: {
@@ -12442,7 +12547,7 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
12442
12547
  sx: {
12443
12548
  padding: '0px 24px 16px 24px'
12444
12549
  },
12445
- children: [jsxs(Grid2, {
12550
+ children: [jsxs(Grid, {
12446
12551
  container: true,
12447
12552
  justifyContent: "space-between",
12448
12553
  alignItems: "center",
@@ -12621,7 +12726,7 @@ var WarningListColumnContent = function WarningListColumnContent(_ref) {
12621
12726
  _ref$width = _ref.width,
12622
12727
  width = _ref$width === void 0 ? 76 : _ref$width,
12623
12728
  props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
12624
- return jsxs(Grid2, {
12729
+ return jsxs(Grid, {
12625
12730
  sx: Object.assign({}, props.sx, {
12626
12731
  width: width
12627
12732
  }),
@@ -12753,7 +12858,15 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12753
12858
  }
12754
12859
  },
12755
12860
  icon: jsx(Update, {})
12756
- }, aviationDuplicate];
12861
+ }, aviationDuplicate, {
12862
+ text: 'CNL',
12863
+ action: function action() {
12864
+ if (warning) {
12865
+ onActionAviationWarning(warning, ProductAction.CANCEL);
12866
+ }
12867
+ },
12868
+ icon: jsx(Cancel, {})
12869
+ }];
12757
12870
  case ProductStatus.CANCELLED:
12758
12871
  return [];
12759
12872
  case ProductStatus.EXPIRED:
@@ -12949,7 +13062,7 @@ var WarningListItem = function WarningListItem(_ref) {
12949
13062
  },
12950
13063
  "aria-label": "warning item for " + warning.id,
12951
13064
  selected: activeWarningId === warning.id,
12952
- children: jsxs(Grid2, {
13065
+ children: jsxs(Grid, {
12953
13066
  className: "warning-list",
12954
13067
  container: true,
12955
13068
  rowSpacing: 0,
@@ -13225,7 +13338,7 @@ var WarningListHeaderContent = function WarningListHeaderContent(_ref) {
13225
13338
  sortDirection = _ref.sortDirection,
13226
13339
  sortable = _ref.sortable,
13227
13340
  props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
13228
- return jsx(Grid2, {
13341
+ return jsx(Grid, {
13229
13342
  sx: Object.assign({}, props.sx, {
13230
13343
  width: width,
13231
13344
  cursor: _onClick ? 'pointer' : 'default'
@@ -13436,32 +13549,26 @@ var PublicWarningList = function PublicWarningList(_ref) {
13436
13549
  containerType: 'inline-size'
13437
13550
  },
13438
13551
  "data-testid": "publicWarningList",
13439
- children: [jsxs(Grid2, {
13440
- container: true,
13441
- justifyItems: "flex-end",
13552
+ children: [jsxs(Box, {
13442
13553
  ref: filterRef,
13443
- sx: (_sx = {}, _sx["@container publicWarningList (max-width: " + breakpoints.tablet + "px)"] = {
13444
- ' .MuiGrid2-grid-sm-12': {
13445
- maxWidth: '100%',
13446
- flexBasis: '100%'
13447
- },
13448
- ' .warning-filter': {
13449
- order: 2
13450
- },
13554
+ sx: (_sx = {
13555
+ display: 'flex',
13556
+ flexWrap: 'wrap',
13557
+ alignItems: 'flex-end',
13558
+ flexDirection: 'column'
13559
+ }, _sx["@container publicWarningList (min-width: " + breakpoints.desktop + "px)"] = {
13560
+ flexDirection: 'row',
13451
13561
  ' .create-warning': {
13452
- order: 1
13562
+ order: 2
13453
13563
  }
13454
13564
  }, _sx),
13455
- children: [jsx(Grid2, {
13565
+ children: [jsx(Box, {
13456
13566
  className: "warning-filter",
13457
- order: {
13458
- xs: 2,
13459
- md: 1
13460
- },
13461
- size: {
13462
- xs: 12,
13463
- sm: 12,
13464
- md: 8
13567
+ sx: {
13568
+ flex: 1,
13569
+ minWidth: 0,
13570
+ order: 2,
13571
+ alignSelf: 'flex-start'
13465
13572
  },
13466
13573
  children: jsx(FilterList, {
13467
13574
  isAllSelected: allSelected,
@@ -13469,21 +13576,10 @@ var PublicWarningList = function PublicWarningList(_ref) {
13469
13576
  filterState: filterState,
13470
13577
  updateFilter: updateFilter
13471
13578
  })
13472
- }), jsxs(Grid2, {
13579
+ }), jsxs(Box, {
13473
13580
  className: "create-warning",
13474
- order: {
13475
- xs: 1,
13476
- md: 2
13477
- },
13478
13581
  sx: {
13479
- display: 'flex'
13480
- },
13481
- justifyContent: "flex-end",
13482
- alignItems: "self-start",
13483
- size: {
13484
- xs: 12,
13485
- sm: 12,
13486
- md: 4
13582
+ order: 1
13487
13583
  },
13488
13584
  children: [lastUpdatedTime && jsx(Box, {
13489
13585
  sx: {
@@ -13502,7 +13598,7 @@ var PublicWarningList = function PublicWarningList(_ref) {
13502
13598
  }), error && jsx(AlertBanner, {
13503
13599
  title: error.message,
13504
13600
  shouldClose: true
13505
- }), !error && jsxs(Grid2, {
13601
+ }), !error && jsxs(Grid, {
13506
13602
  container: true,
13507
13603
  rowSpacing: 0,
13508
13604
  columnSpacing: 0,
@@ -13982,7 +14078,7 @@ var ConfirmDeleteWarningDialog = function ConfirmDeleteWarningDialog(_ref) {
13982
14078
  _context.next = 4;
13983
14079
  return request();
13984
14080
  case 4:
13985
- callback();
14081
+ callback && callback();
13986
14082
  setIsLoading(false);
13987
14083
  _context.next = 12;
13988
14084
  break;
@@ -14034,6 +14130,8 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14034
14130
  var panelId = _ref.panelId,
14035
14131
  presetFilterState = _ref.presetFilterState;
14036
14132
  var updatePublicWarningEditor = useMutatePublicWarningEditor();
14133
+ var _useMutateDeleteWarni = useMutateDeleteWarning(),
14134
+ deletePublicWarning = _useMutateDeleteWarni.mutateAsync;
14037
14135
  var _useWarningsTranslati = useWarningsTranslation(),
14038
14136
  t = _useWarningsTranslati.t;
14039
14137
  var dispatch = useDispatch();
@@ -14208,12 +14306,16 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14208
14306
  switch (actionType) {
14209
14307
  case 'RENEW':
14210
14308
  updatedWarning = renewAviationProduct(warning, aviationConfig);
14309
+ void openPublicWarningDialog('edit', updatedWarning, type);
14211
14310
  break;
14212
14311
  case 'DUPLICATE':
14213
14312
  updatedWarning = duplicateAviationProduct(warning);
14313
+ void openPublicWarningDialog('edit', updatedWarning, type);
14314
+ break;
14315
+ case 'CANCEL':
14316
+ void openPublicWarningDialog('cancel', warning, type);
14214
14317
  break;
14215
14318
  }
14216
- void openPublicWarningDialog('edit', updatedWarning, type);
14217
14319
  };
14218
14320
  var openSnackbar = function openSnackbar(message) {
14219
14321
  dispatch(snackbarActions.openSnackbar({
@@ -14228,10 +14330,13 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14228
14330
  title: t('warning-dialog-delete-title'),
14229
14331
  description: t('warning-dialog-delete-description'),
14230
14332
  request: function request() {
14231
- return warningsApi.deleteWarning(warningId);
14232
- },
14233
- callback: function callback() {
14234
- return onRemoveSuccess(warningId, t('warning-dialog-delete-succes'));
14333
+ return deletePublicWarning({
14334
+ id: warningId
14335
+ }, {
14336
+ onSuccess: function onSuccess() {
14337
+ return onRemoveSuccessHooks(warningId);
14338
+ }
14339
+ });
14235
14340
  },
14236
14341
  isLocked: isLocked
14237
14342
  });
@@ -14252,6 +14357,17 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14252
14357
  }
14253
14358
  });
14254
14359
  };
14360
+ var onRemoveSuccessHooks = function onRemoveSuccessHooks(warningId) {
14361
+ setConfirmDialogOptions(undefined);
14362
+ // Close warning dialog if needed
14363
+ if (selectedWarningId === warningId) {
14364
+ dispatch(uiActions.setToggleOpenDialog({
14365
+ setOpen: false,
14366
+ type: publicWarningDialogType
14367
+ }));
14368
+ }
14369
+ };
14370
+ // TODO remove when all is moved to tanstack
14255
14371
  var onRemoveSuccess = function onRemoveSuccess(warningId, snackbarMessage) {
14256
14372
  // close confirm dialog
14257
14373
  setConfirmDialogOptions(undefined);
@@ -14590,7 +14706,7 @@ var warningsReducersMap = {
14590
14706
  snackbar: snackbarReducer,
14591
14707
  syncGroups: syncGroupsReducer
14592
14708
  };
14593
- var warningsMiddlewares = [mapListener.middleware, layersListener.middleware, drawingToolListener.middleware, warningsDrawingsListener.middleware, publicWarningsListener.middleware, publicWarningFormListener.middleware, snackbarListener.middleware, syncGroupsListener.middleware];
14709
+ var warningsMiddlewares = [mapListener.middleware, layersListener.middleware, drawingToolListener.middleware, warningsDrawingsListener.middleware, publicWarningsListener.middleware, publicWarningFormListener.middleware, snackbarListener.middleware, syncGroupsListener.middleware, openlayersListener.middleware];
14594
14710
  var warningsRootReducer = combineReducers(warningsReducersMap);
14595
14711
  var createMockStore = function createMockStore(mockState) {
14596
14712
  return configureStore({