@opengeoweb/warnings 12.2.0 → 12.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/index.esm.js +406 -129
  2. package/package.json +16 -16
  3. package/src/lib/api/aviation-api/hooks.d.ts +1 -0
  4. package/src/lib/api/warning-api/api.d.ts +1 -0
  5. package/src/lib/api/warning-api/hooks.d.ts +3 -0
  6. package/src/lib/components/PublicWarningList/ConfirmWarningDialog.d.ts +2 -2
  7. package/src/lib/components/PublicWarningList/PublicWarningListConnect.stories.d.ts +9 -1
  8. package/src/lib/components/PublicWarningList/WarningListColumnContent.d.ts +2 -2
  9. package/src/lib/components/PublicWarningList/WarningListHeaderContent.d.ts +2 -2
  10. package/src/lib/components/PublicWarningsForm/PublicWarningsForm.d.ts +2 -2
  11. package/src/lib/components/PublicWarningsForm/PublicWarningsFormConnect.d.ts +3 -1
  12. package/src/lib/store/publicWarningForm/listener.d.ts +1 -1
  13. package/src/lib/store/publicWarningForm/reducer.d.ts +2 -2
  14. package/src/lib/store/publicWarningForm/selectors.d.ts +220 -44
  15. package/src/lib/store/publicWarnings/listener.d.ts +1 -1
  16. package/src/lib/store/publicWarnings/reducer.d.ts +1 -1
  17. package/src/lib/store/publicWarnings/selectors.d.ts +147 -19
  18. package/src/lib/store/publicWarnings/types.d.ts +1 -1
  19. package/src/lib/store/store.d.ts +9 -9
  20. package/src/lib/store/warningsDrawings/listener.d.ts +1 -1
  21. package/src/lib/store/warningsDrawings/reducer.d.ts +1 -1
  22. package/src/lib/store/warningsDrawings/selectors.d.ts +40 -4
  23. package/src/lib/store/warningsDrawings/types.d.ts +1 -1
  24. package/src/lib/storybookUtils/testUtils.d.ts +2 -0
  25. package/src/lib/utils/api.d.ts +0 -1
  26. package/src/lib/utils/sig-airmet-util.d.ts +1 -0
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, getConfirmationDialogCancelLabel, getConfirmationDialogButtonLabel, getConfirmationDialogContent, getConfirmationDialogTitle, isVAPhenomenon, CancelSigmetVolcanicMovements, createAirmetPostParameter, createSigmetPostParameter, prepareCancelSigmet, 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 = {
@@ -201,12 +201,14 @@ var en = {
201
201
  "warning-dialog-withdraw-description": "Are you sure you want to withdraw this warning?",
202
202
  "tac-missing-data": "Missing data: no TAC can be generated",
203
203
  "warning-list-button-renew": "Renew",
204
+ "warning-list-button-amend": "Amend",
204
205
  "aviation-save-success": "{{warningType}} has succesfully been saved!",
205
206
  "aviation-publish-success": "{{warningType}} has succesfully been published!",
206
207
  "publish-this-product": "Are you sure you want to publish this {{product}}?",
207
208
  "yes-cancel": "Yes, cancel {{product}}",
208
209
  "cancel-this-product": "Are you sure you want to cancel this {{product}}?",
209
- "aviation-cancel-success": "{{warningType}} has succesfully been cancelled!"
210
+ "aviation-cancel-success": "{{warningType}} has succesfully been cancelled!",
211
+ "aviation-discard-success": "{{warningType}} has been discarded!"
210
212
  };
211
213
  var nl = {
212
214
  "drawing-tool-form-tools": "Gereedschap",
@@ -298,6 +300,7 @@ var nl = {
298
300
  "warning-list-button-update": "Bijwerken",
299
301
  "warning-list-button-expire": "Verlopen",
300
302
  "warning-list-button-withdraw": "Intrekken",
303
+ "warning-list-button-amend": "Pas aan",
301
304
  "warning-list-status-draft": "Concepten",
302
305
  "warning-list-status-published": "Gepubliceerd",
303
306
  "warning-list-status-todo": "Te doen",
@@ -351,7 +354,8 @@ var nl = {
351
354
  "publish-this-product": "Weet je zeker dat je dit {{product}} wilt publiceren?",
352
355
  "yes-cancel": "Ja, annuleer {{product}}",
353
356
  "cancel-this-product": "Weet je zeker dat je dit {{product}} wilt annuleren?",
354
- "aviation-cancel-success": "niet vertaald"
357
+ "aviation-cancel-success": "niet vertaald",
358
+ "aviation-discard-success": "niet vertaald"
355
359
  };
356
360
  var fi = {
357
361
  "drawing-tool-form-tools": "Työkalut",
@@ -443,6 +447,7 @@ var fi = {
443
447
  "warning-list-button-update": "Päivitä",
444
448
  "warning-list-button-expire": "Vanhentua",
445
449
  "warning-list-button-withdraw": "Peruuttaa",
450
+ "warning-list-button-amend": "Amend",
446
451
  "warning-list-status-draft": "Luonnosta",
447
452
  "warning-list-status-published": "Julkaistua",
448
453
  "warning-list-status-todo": "Arvostelua",
@@ -496,7 +501,8 @@ var fi = {
496
501
  "publish-this-product": "Oletko varma, että haluat julkaista tämän {{product}}:n?",
497
502
  "yes-cancel": "Kyllä, peruuta {{product}}",
498
503
  "cancel-this-product": "Oletko varma, että haluat peruuttaa tämän {{product}}:n?",
499
- "aviation-cancel-success": "ei käännetty"
504
+ "aviation-cancel-success": "ei käännetty",
505
+ "aviation-discard-success": "{{warningType}} er forkastet!"
500
506
  };
501
507
  var no = {
502
508
  "drawing-tool-form-tools": "Verktøy",
@@ -588,6 +594,7 @@ var no = {
588
594
  "warning-list-button-update": "Oppdater",
589
595
  "warning-list-button-expire": "Sett som utgått",
590
596
  "warning-list-button-withdraw": "Ta ut",
597
+ "warning-list-button-amend": "Amend",
591
598
  "warning-list-status-draft": "Utkast",
592
599
  "warning-list-status-published": "Publisert",
593
600
  "warning-list-status-todo": "Til sjekk",
@@ -641,7 +648,8 @@ var no = {
641
648
  "publish-this-product": "Er du sikker på at du vil publisere dette {{product}}?",
642
649
  "yes-cancel": "Ja, kanseller {{product}}",
643
650
  "cancel-this-product": "Er du sikker på at du vil avbryte dette {{product}}?",
644
- "aviation-cancel-success": "{{warningType}} er kansellert!"
651
+ "aviation-cancel-success": "{{warningType}} er kansellert!",
652
+ "aviation-discard-success": "{{warningType}} er forkastet!"
645
653
  };
646
654
  var warningsTranslations = {
647
655
  en: en,
@@ -1694,10 +1702,10 @@ var Objects = function Objects(_ref2) {
1694
1702
  children: jsx(ListItem, {
1695
1703
  style: style,
1696
1704
  disablePadding: true,
1697
- secondaryAction: jsxs(Grid2, {
1705
+ secondaryAction: jsxs(Grid, {
1698
1706
  container: true,
1699
1707
  rowSpacing: 1,
1700
- children: [jsx(Grid2, {
1708
+ children: [jsx(Grid, {
1701
1709
  className: "objectActions",
1702
1710
  children: jsx(ToggleMenu, {
1703
1711
  buttonSx: (_buttonSx = {
@@ -1730,7 +1738,7 @@ var Objects = function Objects(_ref2) {
1730
1738
  icon: jsx(ExitDomain, {})
1731
1739
  }]
1732
1740
  })
1733
- }), object.scope === 'user' && jsx(Grid2, {
1741
+ }), object.scope === 'user' && jsx(Grid, {
1734
1742
  className: "objectActions",
1735
1743
  children: jsx(ToggleMenu, {
1736
1744
  menuTitle: t('object-manager-options-menu'),
@@ -1988,9 +1996,6 @@ var getApiRoutes$1 = function getApiRoutes(axiosInstance) {
1988
1996
  },
1989
1997
  updateWarning: function updateWarning(warningId, data) {
1990
1998
  return axiosInstance.post("/warnings/" + warningId + "/", data);
1991
- },
1992
- deleteWarning: function deleteWarning(warningId) {
1993
- return axiosInstance.post("/warnings/" + warningId + "?delete=true");
1994
1999
  }
1995
2000
  };
1996
2001
  };
@@ -7582,12 +7587,6 @@ var getApiRoutes = function getApiRoutes(axiosInstance) {
7582
7587
  },
7583
7588
  updateWarning: function updateWarning(warningId, data) {
7584
7589
  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
7590
  }
7592
7591
  };
7593
7592
  };
@@ -7808,20 +7807,20 @@ var DrawingToolFormContentsNoMemo = function DrawingToolFormContentsNoMemo(_ref)
7808
7807
  title: dialogError,
7809
7808
  shouldClose: true
7810
7809
  })
7811
- }), jsxs(Grid2, {
7810
+ }), jsxs(Grid, {
7812
7811
  "data-testid": "drawingToolForm",
7813
7812
  container: true,
7814
7813
  direction: "column",
7815
7814
  spacing: 1,
7816
7815
  padding: 2,
7817
- children: [jsx(Grid2, {
7816
+ children: [jsx(Grid, {
7818
7817
  children: jsx(Typography, {
7819
7818
  variant: "body2",
7820
7819
  children: t('drawing-tool-form-tools')
7821
7820
  })
7822
- }), jsx(Grid2, {
7821
+ }), jsx(Grid, {
7823
7822
  container: true,
7824
- children: jsxs(Grid2, {
7823
+ children: jsxs(Grid, {
7825
7824
  children: [drawModes.map(function (mode) {
7826
7825
  return jsx(CustomIconButton, {
7827
7826
  variant: "tool",
@@ -7867,10 +7866,10 @@ var DrawingToolFormContentsNoMemo = function DrawingToolFormContentsNoMemo(_ref)
7867
7866
  }
7868
7867
  })]
7869
7868
  })
7870
- }), jsx(Grid2, {
7869
+ }), jsx(Grid, {
7871
7870
  container: true,
7872
7871
  size: "grow",
7873
- children: jsx(Grid2, {
7872
+ children: jsx(Grid, {
7874
7873
  size: {
7875
7874
  xs: 12,
7876
7875
  sm: 6
@@ -7893,7 +7892,7 @@ var DrawingToolFormContentsNoMemo = function DrawingToolFormContentsNoMemo(_ref)
7893
7892
  })
7894
7893
  })
7895
7894
  })
7896
- }), jsxs(Grid2, {
7895
+ }), jsxs(Grid, {
7897
7896
  children: [jsx(ReactHookFormTextField, {
7898
7897
  name: "objectName",
7899
7898
  label: t('drawing-tool-form-object-name'),
@@ -8417,7 +8416,7 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
8417
8416
  }));
8418
8417
  };
8419
8418
 
8420
- var config$1 = getConfig();
8419
+ var config$1 = sessionStorageProvider.getConfig();
8421
8420
  var airmetBaseUrl = config$1.GW_AIRMET_BASE_URL || '';
8422
8421
  var sigmetBaseUrl = config$1.GW_SIGMET_BASE_URL || '';
8423
8422
  // API
@@ -8536,6 +8535,8 @@ var getAviationSnackbarKey = function getAviationSnackbarKey(status) {
8536
8535
  return 'aviation-publish-success';
8537
8536
  case 'CANCELLED':
8538
8537
  return 'aviation-cancel-success';
8538
+ case 'DISCARDED':
8539
+ return 'aviation-discard-success';
8539
8540
  default:
8540
8541
  return 'aviation-save-success';
8541
8542
  }
@@ -8552,6 +8553,13 @@ var useSigmetList = function useSigmetList(disabled) {
8552
8553
  }
8553
8554
  return useAuthQuery(['sigmet-list'], getSigmetList, disabled);
8554
8555
  };
8556
+ var useAviationWarnings = function useAviationWarnings() {
8557
+ var _useAirmetList = useAirmetList(),
8558
+ airmets = _useAirmetList.data;
8559
+ var _useSigmetList = useSigmetList(),
8560
+ sigmets = _useSigmetList.data;
8561
+ return (airmets || []).concat(sigmets || []);
8562
+ };
8555
8563
  var useProductConfig = function useProductConfig(warningType, disabled) {
8556
8564
  if (disabled === void 0) {
8557
8565
  disabled = false;
@@ -8569,7 +8577,8 @@ var useTACApi = function useTACApi() {
8569
8577
  queryKey: ['sigmet-tac', product],
8570
8578
  queryFn: function queryFn() {
8571
8579
  return getSigmetTAC(auth, product);
8572
- }
8580
+ },
8581
+ staleTime: 1000 * 15
8573
8582
  });
8574
8583
  };
8575
8584
  var fetchAirmetTAC = function fetchAirmetTAC(product) {
@@ -8577,7 +8586,8 @@ var useTACApi = function useTACApi() {
8577
8586
  queryKey: ['airmet-tac', product],
8578
8587
  queryFn: function queryFn() {
8579
8588
  return getAirmetTAC(auth, product);
8580
- }
8589
+ },
8590
+ staleTime: 1000 * 15
8581
8591
  });
8582
8592
  };
8583
8593
  return {
@@ -9008,6 +9018,23 @@ var renewAviationProduct = function renewAviationProduct(aviationWarning, produc
9008
9018
  sigmetAirmetDetails: renewedWarningDetail
9009
9019
  });
9010
9020
  };
9021
+ var amendAviationProduct = function amendAviationProduct(aviationWarning, productConfig) {
9022
+ var warningDetail = aviationWarning.sigmetAirmetDetails;
9023
+ var newValidStart = dateUtils.dateToString(dateUtils.add(new Date(), {
9024
+ minutes: 5
9025
+ }));
9026
+ var newValidUntil = 'phenomenon' in warningDetail ? getDefaultValidUntilValue(productConfig, warningDetail.phenomenon, warningDetail.locationIndicatorATSR, newValidStart) : warningDetail.validDateEnd;
9027
+ var amendedWarningDetail = Object.assign({}, warningDetail, {
9028
+ validDateStart: newValidStart,
9029
+ validDateEnd: newValidUntil,
9030
+ status: ProductStatus.DRAFT,
9031
+ uuid: undefined,
9032
+ sequence: '-1'
9033
+ });
9034
+ return Object.assign({}, aviationWarning, {
9035
+ sigmetAirmetDetails: amendedWarningDetail
9036
+ });
9037
+ };
9011
9038
  var duplicateAviationProduct = function duplicateAviationProduct(aviationWarning) {
9012
9039
  var duplicatedWarningDetail = Object.assign({}, aviationWarning.sigmetAirmetDetails, {
9013
9040
  status: ProductStatus.DRAFT,
@@ -9053,6 +9080,7 @@ var WarningsMapView = function WarningsMapView(_ref) {
9053
9080
  children: jsxs(OpenLayersMapView, {
9054
9081
  view: viewRef.current,
9055
9082
  holdShiftToScroll: true,
9083
+ mapId: mapId,
9056
9084
  children: [jsx(MapControls, {
9057
9085
  style: {
9058
9086
  top: 0
@@ -9842,12 +9870,12 @@ var Phenomenon = function Phenomenon(_ref) {
9842
9870
  children: warningFormPhenomena.map(function (phenomenon) {
9843
9871
  return jsx(MenuItem, {
9844
9872
  value: phenomenon.key,
9845
- children: jsxs(Grid2, {
9873
+ children: jsxs(Grid, {
9846
9874
  container: true,
9847
9875
  justifyContent: "space-between",
9848
- children: [jsx(Grid2, {
9876
+ children: [jsx(Grid, {
9849
9877
  children: t(phenomenon.translationKey)
9850
- }), jsx(Grid2, {
9878
+ }), jsx(Grid, {
9851
9879
  sx: {
9852
9880
  minWidth: 56
9853
9881
  },
@@ -10091,16 +10119,16 @@ var ContainerGrid = styled('div')(function (_ref3) {
10091
10119
  var theme = _ref3.theme;
10092
10120
  return _ref4 = {
10093
10121
  backgroundColor: theme.palette.background.paper,
10094
- '.MuiGrid2-grid-sm-6, .MuiGrid2-grid-sm-4': {
10122
+ '.MuiGrid-grid-sm-6, .MuiGrid-grid-sm-4': {
10095
10123
  width: '100%',
10096
10124
  minWidth: '100%'
10097
10125
  }
10098
10126
  }, _ref4[containerQueryBreakpoint] = {
10099
- '.MuiGrid2-grid-sm-6': {
10127
+ '.MuiGrid-grid-sm-6': {
10100
10128
  width: sm6Width,
10101
10129
  minWidth: sm6Width
10102
10130
  },
10103
- '.MuiGrid2-grid-sm-4': {
10131
+ '.MuiGrid-grid-sm-4': {
10104
10132
  width: sm4Width,
10105
10133
  minWidth: sm4Width
10106
10134
  }
@@ -10266,6 +10294,7 @@ var Form = function Form(_ref5) {
10266
10294
  _ref5$warningType = _ref5.warningType,
10267
10295
  warningType = _ref5$warningType === void 0 ? 'public' : _ref5$warningType,
10268
10296
  mode = _ref5.mode,
10297
+ formState = _ref5.formState,
10269
10298
  _ref5$onSetViewModeRe = _ref5.onSetViewModeResetArea,
10270
10299
  onSetViewModeResetArea = _ref5$onSetViewModeRe === void 0 ? function () {} : _ref5$onSetViewModeRe,
10271
10300
  storedStartGeoJSON = _ref5.storedStartGeoJSON,
@@ -10299,7 +10328,8 @@ var Form = function Form(_ref5) {
10299
10328
  reset = _useFormContext.reset,
10300
10329
  dirtyFields = _useFormContext.formState.dirtyFields,
10301
10330
  getValues = _useFormContext.getValues,
10302
- setValue = _useFormContext.setValue;
10331
+ setValue = _useFormContext.setValue,
10332
+ watch = _useFormContext.watch;
10303
10333
  var _useDraftFormHelpers = useDraftFormHelpers(),
10304
10334
  toggleIsDraft = _useDraftFormHelpers.toggleIsDraft,
10305
10335
  DraftFieldHelper = _useDraftFormHelpers.DraftFieldHelper;
@@ -10379,6 +10409,9 @@ var Form = function Form(_ref5) {
10379
10409
  })) : null
10380
10410
  });
10381
10411
  };
10412
+ var cancelAviationProduct = function cancelAviationProduct(warningType) {
10413
+ return onSaveAviationForm(selectedAviationProduct, 'CANCELLED', warningType, isVAPhenomenon(selectedAviationProduct, ProductAction.CANCEL) && watch('vaSigmetMoveToFIR'));
10414
+ };
10382
10415
  var handleSubmitAviationProduct = function handleSubmitAviationProduct(action, warningType) {
10383
10416
  if (isSaving) {
10384
10417
  return;
@@ -10440,7 +10473,50 @@ var Form = function Form(_ref5) {
10440
10473
  return _ref12.apply(this, arguments);
10441
10474
  };
10442
10475
  }())();
10476
+ break;
10443
10477
  case ProductAction.CANCEL:
10478
+ void showConfirmDialog(action).then(function () {
10479
+ setIsPublishing(true);
10480
+ void cancelAviationProduct(warningType);
10481
+ setIsPublishing(false);
10482
+ onCloseForm();
10483
+ });
10484
+ break;
10485
+ case ProductAction.AMEND:
10486
+ void handleSubmit( /*#__PURE__*/function () {
10487
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(formValues) {
10488
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
10489
+ while (1) switch (_context10.prev = _context10.next) {
10490
+ case 0:
10491
+ _context10.next = 2;
10492
+ return showConfirmDialog(action).then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
10493
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
10494
+ while (1) switch (_context9.prev = _context9.next) {
10495
+ case 0:
10496
+ setIsPublishing(true);
10497
+ void cancelAviationProduct(warningType).then(function () {
10498
+ void onSaveAviationForm(formValues, 'PUBLISHED', warningType).then(function () {
10499
+ setIsPublishing(false);
10500
+ onCloseForm();
10501
+ });
10502
+ });
10503
+ case 2:
10504
+ case "end":
10505
+ return _context9.stop();
10506
+ }
10507
+ }, _callee9);
10508
+ })));
10509
+ case 2:
10510
+ case "end":
10511
+ return _context10.stop();
10512
+ }
10513
+ }, _callee10);
10514
+ }));
10515
+ return function (_x5) {
10516
+ return _ref14.apply(this, arguments);
10517
+ };
10518
+ }())();
10519
+ break;
10444
10520
  case ProductAction.RENEW:
10445
10521
  case ProductAction.DISCARD:
10446
10522
  case ProductAction.DUPLICATE:
@@ -10581,14 +10657,14 @@ var Form = function Form(_ref5) {
10581
10657
  storedGeoJSON: storedStartGeoJSON
10582
10658
  })
10583
10659
  }) : jsx(ContainerGrid, {
10584
- children: jsxs(Grid2, {
10660
+ children: jsxs(Grid, {
10585
10661
  size: {
10586
10662
  xs: 12
10587
10663
  },
10588
10664
  container: true,
10589
10665
  rowSpacing: 2,
10590
10666
  columnSpacing: 2,
10591
- children: [jsx(Grid2, {
10667
+ children: [jsx(Grid, {
10592
10668
  size: {
10593
10669
  xs: 12
10594
10670
  },
@@ -10596,7 +10672,7 @@ var Form = function Form(_ref5) {
10596
10672
  isDisabled: areFieldsDisabled,
10597
10673
  isReadOnly: isReadOnly
10598
10674
  })
10599
- }), jsx(Grid2, {
10675
+ }), jsx(Grid, {
10600
10676
  size: {
10601
10677
  xs: 12
10602
10678
  },
@@ -10607,7 +10683,7 @@ var Form = function Form(_ref5) {
10607
10683
  onAddObject: onAddObject,
10608
10684
  isDisabled: areFieldsDisabled || isReadOnly
10609
10685
  })
10610
- }), jsx(Grid2, {
10686
+ }), jsx(Grid, {
10611
10687
  size: {
10612
10688
  xs: 12
10613
10689
  },
@@ -10616,7 +10692,7 @@ var Form = function Form(_ref5) {
10616
10692
  defaultMapPreset: defaultMapPreset,
10617
10693
  isSnapshot: isSnapshot
10618
10694
  })
10619
- }), jsx(Grid2, {
10695
+ }), jsx(Grid, {
10620
10696
  size: {
10621
10697
  xs: 12,
10622
10698
  sm: 6
@@ -10625,7 +10701,7 @@ var Form = function Form(_ref5) {
10625
10701
  isDisabled: areFieldsDisabled,
10626
10702
  isReadOnly: isReadOnly
10627
10703
  })
10628
- }), jsx(Grid2, {
10704
+ }), jsx(Grid, {
10629
10705
  size: {
10630
10706
  xs: 12,
10631
10707
  sm: 6
@@ -10634,13 +10710,13 @@ var Form = function Form(_ref5) {
10634
10710
  isDisabled: areFieldsDisabled,
10635
10711
  isReadOnly: isReadOnly
10636
10712
  })
10637
- }), jsxs(Grid2, {
10713
+ }), jsxs(Grid, {
10638
10714
  size: {
10639
10715
  xs: 12
10640
10716
  },
10641
10717
  container: true,
10642
10718
  spacing: 2,
10643
- children: [jsx(Grid2, {
10719
+ children: [jsx(Grid, {
10644
10720
  size: {
10645
10721
  xs: 12,
10646
10722
  sm: 6
@@ -10649,7 +10725,7 @@ var Form = function Form(_ref5) {
10649
10725
  isDisabled: areFieldsDisabled,
10650
10726
  isReadOnly: isReadOnly
10651
10727
  })
10652
- }), jsx(Grid2, {
10728
+ }), jsx(Grid, {
10653
10729
  size: {
10654
10730
  xs: 12,
10655
10731
  sm: 6
@@ -10659,13 +10735,13 @@ var Form = function Form(_ref5) {
10659
10735
  isReadOnly: isReadOnly
10660
10736
  })
10661
10737
  })]
10662
- }), jsx(Grid2, {
10738
+ }), jsx(Grid, {
10663
10739
  size: {
10664
10740
  xs: 12
10665
10741
  },
10666
10742
  container: true,
10667
10743
  spacing: 2,
10668
- children: jsx(Grid2, {
10744
+ children: jsx(Grid, {
10669
10745
  size: {
10670
10746
  xs: 12
10671
10747
  },
@@ -10679,7 +10755,7 @@ var Form = function Form(_ref5) {
10679
10755
  }), jsx(DraftFieldHelper, {}), jsx(ReactHookFormHiddenInput, {
10680
10756
  name: "id"
10681
10757
  })]
10682
- }), !isReadOnly && jsx(Box, {
10758
+ }), formState !== 'cancel' && !isReadOnly && jsx(Box, {
10683
10759
  sx: {
10684
10760
  padding: '24px 10px 14px 10px',
10685
10761
  position: 'absolute',
@@ -10692,10 +10768,10 @@ var Form = function Form(_ref5) {
10692
10768
  border: 'none'
10693
10769
  },
10694
10770
  children: jsx(ContainerGrid, {
10695
- children: jsxs(Grid2, {
10771
+ children: jsxs(Grid, {
10696
10772
  container: true,
10697
10773
  spacing: 2,
10698
- children: [jsx(Grid2, {
10774
+ children: [jsx(Grid, {
10699
10775
  size: {
10700
10776
  xs: 12,
10701
10777
  sm: 4
@@ -10710,7 +10786,7 @@ var Form = function Form(_ref5) {
10710
10786
  onClick: onPressClear,
10711
10787
  children: t('warning-button-clear')
10712
10788
  })
10713
- }), jsx(Grid2, {
10789
+ }), jsx(Grid, {
10714
10790
  size: {
10715
10791
  xs: 12,
10716
10792
  sm: 4
@@ -10721,7 +10797,7 @@ var Form = function Form(_ref5) {
10721
10797
  width: '100%',
10722
10798
  marginBottom: 1
10723
10799
  },
10724
- disabled: isPublishing,
10800
+ disabled: isPublishing || formState === 'amending',
10725
10801
  onClick: function onClick() {
10726
10802
  return selectedAviationProduct ? handleSubmitAviationProduct(ProductAction.SAVE, warningType) : onPressSave();
10727
10803
  },
@@ -10736,7 +10812,7 @@ var Form = function Form(_ref5) {
10736
10812
  })]
10737
10813
  })
10738
10814
  })
10739
- }), jsx(Grid2, {
10815
+ }), jsx(Grid, {
10740
10816
  size: {
10741
10817
  xs: 12,
10742
10818
  sm: 4
@@ -10748,7 +10824,7 @@ var Form = function Form(_ref5) {
10748
10824
  },
10749
10825
  disabled: isSaving,
10750
10826
  onClick: function onClick() {
10751
- selectedAviationProduct ? handleSubmitAviationProduct(ProductAction.PUBLISH, warningType) : onPressPublish();
10827
+ selectedAviationProduct ? handleSubmitAviationProduct(formState === 'amending' ? ProductAction.AMEND : ProductAction.PUBLISH, warningType) : onPressPublish();
10752
10828
  },
10753
10829
  children: jsxs("span", {
10754
10830
  style: {
@@ -10764,6 +10840,51 @@ var Form = function Form(_ref5) {
10764
10840
  })]
10765
10841
  })
10766
10842
  })
10843
+ }), formState === 'cancel' && jsx(Box, {
10844
+ sx: {
10845
+ padding: '24px 10px 14px 10px',
10846
+ position: 'absolute',
10847
+ bottom: 0,
10848
+ width: '100%',
10849
+ backgroundColor: 'geowebColors.background.surfaceApp',
10850
+ boxShadow: '0 2px 4px 0 rgba(0, 0, 0, 0.5)',
10851
+ zIndex: 1,
10852
+ overflowX: 'hidden',
10853
+ border: 'none'
10854
+ },
10855
+ children: jsx(ContainerGrid, {
10856
+ children: jsx(Grid, {
10857
+ container: true,
10858
+ spacing: 2,
10859
+ children: jsx(Grid, {
10860
+ size: {
10861
+ xs: 12,
10862
+ sm: 4,
10863
+ md: 4
10864
+ },
10865
+ children: jsx(Button, {
10866
+ variant: "primary",
10867
+ sx: {
10868
+ width: '100%'
10869
+ },
10870
+ disabled: isSaving,
10871
+ onClick: function onClick() {
10872
+ selectedAviationProduct ? handleSubmitAviationProduct(ProductAction.CANCEL, warningType) : onPressPublish();
10873
+ },
10874
+ children: jsxs("span", {
10875
+ style: {
10876
+ position: 'relative'
10877
+ },
10878
+ children: [isPublishing ? t('warning-button-publishing') : t('warning-button-publish'), isPublishing && jsx(CircularProgress, {
10879
+ "data-testid": "spinner",
10880
+ color: "inherit",
10881
+ sx: spinnerSx
10882
+ })]
10883
+ })
10884
+ })
10885
+ })
10886
+ })
10887
+ })
10767
10888
  })]
10768
10889
  });
10769
10890
  };
@@ -10798,7 +10919,7 @@ var PublicWarningsForm = function PublicWarningsForm(props) {
10798
10919
  * Copyright 2024 - Finnish Meteorological Institute (FMI)
10799
10920
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
10800
10921
  * */
10801
- var config = getConfig();
10922
+ var config = sessionStorageProvider.getConfig();
10802
10923
  var publicWarningBaseUrl = config.GW_DRAWINGS_BASE_URL || '';
10803
10924
  // API
10804
10925
  var getPublicWarningList = function getPublicWarningList(auth) {
@@ -10832,6 +10953,12 @@ var postPublicWarning = function postPublicWarning(auth, data) {
10832
10953
  body: JSON.stringify(data)
10833
10954
  }).then(handleResponse);
10834
10955
  };
10956
+ var deleteWarning = function deleteWarning(warningId, auth) {
10957
+ return fetch(publicWarningBaseUrl + "/warnings/" + warningId + "?delete=true", {
10958
+ headers: getHeaders(auth),
10959
+ method: 'POST'
10960
+ }).then(handleResponse);
10961
+ };
10835
10962
 
10836
10963
  /**
10837
10964
  * @param disabled - Disables fetching, but still returns cached values.
@@ -10993,6 +11120,49 @@ var useMutateWarning = function useMutateWarning(snackBarMessage) {
10993
11120
  }()
10994
11121
  }));
10995
11122
  };
11123
+ var useMutateDeleteWarning = function useMutateDeleteWarning() {
11124
+ var queryClient = useQueryClient();
11125
+ var dispatch = useDispatch();
11126
+ var _useAuthenticationCon3 = useAuthenticationContext(),
11127
+ auth = _useAuthenticationCon3.auth;
11128
+ return useMutation({
11129
+ mutationFn: function mutationFn(_ref6) {
11130
+ var id = _ref6.id;
11131
+ if (!auth) {
11132
+ throw new Error('Authentication context not found');
11133
+ }
11134
+ return deleteWarning(id, auth);
11135
+ },
11136
+ onSuccess: function () {
11137
+ var _onSuccess3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_, variables) {
11138
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
11139
+ while (1) switch (_context3.prev = _context3.next) {
11140
+ case 0:
11141
+ void queryClient.cancelQueries({
11142
+ queryKey: ['public-warning-list']
11143
+ });
11144
+ queryClient.setQueryData(['public-warning-list'], function (old) {
11145
+ return old == null ? void 0 : old.filter(function (warning) {
11146
+ return warning.id !== variables.id;
11147
+ });
11148
+ });
11149
+ dispatch(snackbarActions.openSnackbar({
11150
+ type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
11151
+ key: t('warning-dialog-delete-succes')
11152
+ }));
11153
+ case 3:
11154
+ case "end":
11155
+ return _context3.stop();
11156
+ }
11157
+ }, _callee3);
11158
+ }));
11159
+ function onSuccess(_x5, _x6) {
11160
+ return _onSuccess3.apply(this, arguments);
11161
+ }
11162
+ return onSuccess;
11163
+ }()
11164
+ });
11165
+ };
10996
11166
  var usePublishWarning = function usePublishWarning() {
10997
11167
  return useMutateWarning('warning-publish-succes');
10998
11168
  };
@@ -11073,6 +11243,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11073
11243
  formState = _useSelector.formState,
11074
11244
  error = _useSelector.error,
11075
11245
  panelId = _useSelector.panelId;
11246
+ var aviationWarnings = useAviationWarnings();
11076
11247
  var _usePublishWarning = usePublishWarning(),
11077
11248
  publishWarning = _usePublishWarning.mutateAsync;
11078
11249
  var _useSaveWarning = useSaveWarning(),
@@ -11119,45 +11290,58 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11119
11290
  type: publicWarningDialogType
11120
11291
  }));
11121
11292
  };
11293
+ var selectedBackendProduct = React.useMemo(function () {
11294
+ return aviationWarnings.find(function (aviationProduct) {
11295
+ return aviationProduct.uuid === (selectedAviationProduct == null ? void 0 : selectedAviationProduct.id);
11296
+ });
11297
+ }, [aviationWarnings, selectedAviationProduct]);
11298
+ var getCancelSigmet = function getCancelSigmet(selectedProduct, vaSigmetMoveToFIR) {
11299
+ if ('sigmet' in selectedProduct) {
11300
+ return prepareCancelSigmet(selectedProduct.sigmet, vaSigmetMoveToFIR || 'UNKNOWN');
11301
+ }
11302
+ return selectedProduct.airmet;
11303
+ };
11122
11304
  var saveAviationForm = /*#__PURE__*/function () {
11123
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType) {
11124
- var uuid, _postProductParam, postProductParam, errorMessage;
11305
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(productToPost, newStatus, warningType, vaSigmetMoveToFIR) {
11306
+ var product, uuid, _postProductParam, postProductParam, errorMessage;
11125
11307
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
11126
11308
  while (1) switch (_context2.prev = _context2.next) {
11127
11309
  case 0:
11128
- _context2.prev = 0;
11310
+ // if volcanic sigmet - add to which FIR it's moving
11311
+ product = newStatus === 'CANCELLED' && selectedBackendProduct ? getCancelSigmet(selectedBackendProduct, vaSigmetMoveToFIR) : productToPost;
11312
+ _context2.prev = 1;
11129
11313
  uuid = (selectedAviationProduct == null ? void 0 : selectedAviationProduct.uuid) || null;
11130
11314
  if (!(warningType === 'sigmet')) {
11131
- _context2.next = 7;
11315
+ _context2.next = 8;
11132
11316
  break;
11133
11317
  }
11134
- _postProductParam = createSigmetPostParameter(productToPost, newStatus, uuid);
11135
- _context2.next = 6;
11318
+ _postProductParam = createSigmetPostParameter(product, newStatus, uuid);
11319
+ _context2.next = 7;
11136
11320
  return postSigmet(_postProductParam);
11137
- case 6:
11138
- return _context2.abrupt("return", _context2.sent);
11139
11321
  case 7:
11140
- postProductParam = createAirmetPostParameter(productToPost, newStatus, uuid);
11141
- _context2.next = 10;
11322
+ return _context2.abrupt("return", _context2.sent);
11323
+ case 8:
11324
+ postProductParam = createAirmetPostParameter(product, newStatus, uuid);
11325
+ _context2.next = 11;
11142
11326
  return postAirmet(postProductParam);
11143
- case 10:
11327
+ case 11:
11144
11328
  return _context2.abrupt("return", _context2.sent);
11145
- case 13:
11146
- _context2.prev = 13;
11147
- _context2.t0 = _context2["catch"](0);
11329
+ case 14:
11330
+ _context2.prev = 14;
11331
+ _context2.t0 = _context2["catch"](1);
11148
11332
  errorMessage = _context2.t0 instanceof Error ? _context2.t0 : 'Unknown error occurred';
11149
11333
  dispatch(snackbarActions.openSnackbar({
11150
11334
  type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
11151
11335
  message: "Failed to save " + warningType.toUpperCase() + ": " + errorMessage
11152
11336
  }));
11153
11337
  throw _context2.t0;
11154
- case 18:
11338
+ case 19:
11155
11339
  case "end":
11156
11340
  return _context2.stop();
11157
11341
  }
11158
- }, _callee2, null, [[0, 13]]);
11342
+ }, _callee2, null, [[1, 14]]);
11159
11343
  }));
11160
- return function saveAviationForm(_x2, _x3, _x4) {
11344
+ return function saveAviationForm(_x2, _x3, _x4, _x5) {
11161
11345
  return _ref3.apply(this, arguments);
11162
11346
  };
11163
11347
  }();
@@ -11184,7 +11368,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11184
11368
  }
11185
11369
  }, _callee3);
11186
11370
  }));
11187
- return function saveForm(_x5) {
11371
+ return function saveForm(_x6) {
11188
11372
  return _ref4.apply(this, arguments);
11189
11373
  };
11190
11374
  }();
@@ -11209,7 +11393,10 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11209
11393
  if ((selectedAviationProduct == null ? void 0 : selectedAviationProduct.status) === 'DRAFT') {
11210
11394
  return false;
11211
11395
  }
11212
- if (formState === 'edit') {
11396
+ if (formState === 'cancel') {
11397
+ return true;
11398
+ }
11399
+ if (formState === 'edit' || formState === 'amending') {
11213
11400
  return false;
11214
11401
  }
11215
11402
  if (mode === 'new') {
@@ -11218,7 +11405,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11218
11405
  return true;
11219
11406
  };
11220
11407
  var isReadOnly = getIsReadOnly();
11221
- var formMode = formState === 'edit' ? 'edit' : mode;
11408
+ var formMode = formState === 'edit' || formState === 'amending' ? 'edit' : mode;
11222
11409
  var onAddObject = function onAddObject() {
11223
11410
  dispatch(uiActions.setToggleOpenDialog({
11224
11411
  type: uiTypes.DialogTypes.AreaObjectLoader,
@@ -11259,6 +11446,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
11259
11446
  selectedAviationProduct: selectedAviationProduct,
11260
11447
  warningType: warningType,
11261
11448
  mode: formMode,
11449
+ formState: formState,
11262
11450
  onSetViewModeResetArea: onSetViewModeResetArea,
11263
11451
  storedStartGeoJSON: storedStartGeoJSON,
11264
11452
  storedEndGeoJSON: storedEndGeoJSON
@@ -12376,7 +12564,7 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
12376
12564
  },
12377
12565
  isDisabled: isDisabled,
12378
12566
  size: "medium",
12379
- actionIcon: jsxs(Grid2, {
12567
+ actionIcon: jsxs(Grid, {
12380
12568
  container: true,
12381
12569
  alignItems: "center",
12382
12570
  style: {
@@ -12442,7 +12630,7 @@ var ExpandableFilterChip = function ExpandableFilterChip(_ref) {
12442
12630
  sx: {
12443
12631
  padding: '0px 24px 16px 24px'
12444
12632
  },
12445
- children: [jsxs(Grid2, {
12633
+ children: [jsxs(Grid, {
12446
12634
  container: true,
12447
12635
  justifyContent: "space-between",
12448
12636
  alignItems: "center",
@@ -12621,7 +12809,7 @@ var WarningListColumnContent = function WarningListColumnContent(_ref) {
12621
12809
  _ref$width = _ref.width,
12622
12810
  width = _ref$width === void 0 ? 76 : _ref$width,
12623
12811
  props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
12624
- return jsxs(Grid2, {
12812
+ return jsxs(Grid, {
12625
12813
  sx: Object.assign({}, props.sx, {
12626
12814
  width: width
12627
12815
  }),
@@ -12680,6 +12868,13 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12680
12868
  },
12681
12869
  icon: jsx(Copy, {})
12682
12870
  };
12871
+ var aviationDelete = {
12872
+ text: t('object-manager-button-delete'),
12873
+ action: function action() {
12874
+ return onActionAviationWarning(warning, ProductAction.DISCARD);
12875
+ },
12876
+ icon: jsx(Delete, {})
12877
+ };
12683
12878
  // disable Expire option if warning is not active
12684
12879
  var shouldDisableExpire = !dateUtils.isBetween(dateUtils.getNowUtc(), dateUtils.createDate(warning.warningDetail.validFrom), dateUtils.createDate(warning.warningDetail.validUntil), '[]');
12685
12880
  switch (warning.status) {
@@ -12740,7 +12935,7 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12740
12935
  default:
12741
12936
  switch (warning.productStatus) {
12742
12937
  case ProductStatus.DRAFT:
12743
- return [aviationDuplicate];
12938
+ return [aviationDuplicate, aviationDelete];
12744
12939
  case ProductStatus.PUBLISHED:
12745
12940
  if (warning.type !== 'public' && (isInstanceOfCancelSigmet(warning.sigmetAirmetDetails) || isInstanceOfCancelAirmet(warning.sigmetAirmetDetails))) {
12746
12941
  return [];
@@ -12753,7 +12948,22 @@ var WarningListItemMenu = function WarningListItemMenu(_ref) {
12753
12948
  }
12754
12949
  },
12755
12950
  icon: jsx(Update, {})
12756
- }, aviationDuplicate];
12951
+ }, {
12952
+ text: t('warning-list-button-amend'),
12953
+ action: function action() {
12954
+ if (warning) {
12955
+ onActionAviationWarning(warning, ProductAction.AMEND);
12956
+ }
12957
+ }
12958
+ }, aviationDuplicate, {
12959
+ text: 'CNL',
12960
+ action: function action() {
12961
+ if (warning) {
12962
+ onActionAviationWarning(warning, ProductAction.CANCEL);
12963
+ }
12964
+ },
12965
+ icon: jsx(Cancel, {})
12966
+ }];
12757
12967
  case ProductStatus.CANCELLED:
12758
12968
  return [];
12759
12969
  case ProductStatus.EXPIRED:
@@ -12949,7 +13159,7 @@ var WarningListItem = function WarningListItem(_ref) {
12949
13159
  },
12950
13160
  "aria-label": "warning item for " + warning.id,
12951
13161
  selected: activeWarningId === warning.id,
12952
- children: jsxs(Grid2, {
13162
+ children: jsxs(Grid, {
12953
13163
  className: "warning-list",
12954
13164
  container: true,
12955
13165
  rowSpacing: 0,
@@ -13225,7 +13435,7 @@ var WarningListHeaderContent = function WarningListHeaderContent(_ref) {
13225
13435
  sortDirection = _ref.sortDirection,
13226
13436
  sortable = _ref.sortable,
13227
13437
  props = _objectWithoutPropertiesLoose(_ref, _excluded$1);
13228
- return jsx(Grid2, {
13438
+ return jsx(Grid, {
13229
13439
  sx: Object.assign({}, props.sx, {
13230
13440
  width: width,
13231
13441
  cursor: _onClick ? 'pointer' : 'default'
@@ -13436,32 +13646,26 @@ var PublicWarningList = function PublicWarningList(_ref) {
13436
13646
  containerType: 'inline-size'
13437
13647
  },
13438
13648
  "data-testid": "publicWarningList",
13439
- children: [jsxs(Grid2, {
13440
- container: true,
13441
- justifyItems: "flex-end",
13649
+ children: [jsxs(Box, {
13442
13650
  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
- },
13651
+ sx: (_sx = {
13652
+ display: 'flex',
13653
+ flexWrap: 'wrap',
13654
+ alignItems: 'flex-end',
13655
+ flexDirection: 'column'
13656
+ }, _sx["@container publicWarningList (min-width: " + breakpoints.desktop + "px)"] = {
13657
+ flexDirection: 'row',
13451
13658
  ' .create-warning': {
13452
- order: 1
13659
+ order: 2
13453
13660
  }
13454
13661
  }, _sx),
13455
- children: [jsx(Grid2, {
13662
+ children: [jsx(Box, {
13456
13663
  className: "warning-filter",
13457
- order: {
13458
- xs: 2,
13459
- md: 1
13460
- },
13461
- size: {
13462
- xs: 12,
13463
- sm: 12,
13464
- md: 8
13664
+ sx: {
13665
+ flex: 1,
13666
+ minWidth: 0,
13667
+ order: 2,
13668
+ alignSelf: 'flex-start'
13465
13669
  },
13466
13670
  children: jsx(FilterList, {
13467
13671
  isAllSelected: allSelected,
@@ -13469,21 +13673,10 @@ var PublicWarningList = function PublicWarningList(_ref) {
13469
13673
  filterState: filterState,
13470
13674
  updateFilter: updateFilter
13471
13675
  })
13472
- }), jsxs(Grid2, {
13676
+ }), jsxs(Box, {
13473
13677
  className: "create-warning",
13474
- order: {
13475
- xs: 1,
13476
- md: 2
13477
- },
13478
13678
  sx: {
13479
- display: 'flex'
13480
- },
13481
- justifyContent: "flex-end",
13482
- alignItems: "self-start",
13483
- size: {
13484
- xs: 12,
13485
- sm: 12,
13486
- md: 4
13679
+ order: 1
13487
13680
  },
13488
13681
  children: [lastUpdatedTime && jsx(Box, {
13489
13682
  sx: {
@@ -13502,7 +13695,7 @@ var PublicWarningList = function PublicWarningList(_ref) {
13502
13695
  }), error && jsx(AlertBanner, {
13503
13696
  title: error.message,
13504
13697
  shouldClose: true
13505
- }), !error && jsxs(Grid2, {
13698
+ }), !error && jsxs(Grid, {
13506
13699
  container: true,
13507
13700
  rowSpacing: 0,
13508
13701
  columnSpacing: 0,
@@ -13982,7 +14175,7 @@ var ConfirmDeleteWarningDialog = function ConfirmDeleteWarningDialog(_ref) {
13982
14175
  _context.next = 4;
13983
14176
  return request();
13984
14177
  case 4:
13985
- callback();
14178
+ callback && callback();
13986
14179
  setIsLoading(false);
13987
14180
  _context.next = 12;
13988
14181
  break;
@@ -14034,6 +14227,8 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14034
14227
  var panelId = _ref.panelId,
14035
14228
  presetFilterState = _ref.presetFilterState;
14036
14229
  var updatePublicWarningEditor = useMutatePublicWarningEditor();
14230
+ var _useMutateDeleteWarni = useMutateDeleteWarning(),
14231
+ deletePublicWarning = _useMutateDeleteWarni.mutateAsync;
14037
14232
  var _useWarningsTranslati = useWarningsTranslation(),
14038
14233
  t = _useWarningsTranslati.t;
14039
14234
  var dispatch = useDispatch();
@@ -14199,6 +14394,52 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14199
14394
  var warningType = useSelector(getWarningType);
14200
14395
  var _useProductConfig = useProductConfig(warningType, false),
14201
14396
  aviationConfig = _useProductConfig.data;
14397
+ var _usePostSigmet = usePostSigmet(),
14398
+ postSigmet = _usePostSigmet.mutateAsync;
14399
+ var _usePostAirmet = usePostAirmet(),
14400
+ postAirmet = _usePostAirmet.mutateAsync;
14401
+ var deleteAviationProduct = /*#__PURE__*/function () {
14402
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(productToPost, newStatus, warningType) {
14403
+ var uuid, _postProductParam, postProductParam, errorMessage;
14404
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
14405
+ while (1) switch (_context5.prev = _context5.next) {
14406
+ case 0:
14407
+ _context5.prev = 0;
14408
+ uuid = (productToPost == null ? void 0 : productToPost.sigmetAirmetDetails.uuid) || null;
14409
+ if (!(warningType === 'sigmet')) {
14410
+ _context5.next = 7;
14411
+ break;
14412
+ }
14413
+ _postProductParam = createSigmetPostParameter(productToPost.sigmetAirmetDetails, newStatus, uuid);
14414
+ _context5.next = 6;
14415
+ return postSigmet(_postProductParam);
14416
+ case 6:
14417
+ return _context5.abrupt("return", _context5.sent);
14418
+ case 7:
14419
+ postProductParam = createAirmetPostParameter(productToPost.sigmetAirmetDetails, newStatus, uuid);
14420
+ _context5.next = 10;
14421
+ return postAirmet(postProductParam);
14422
+ case 10:
14423
+ return _context5.abrupt("return", _context5.sent);
14424
+ case 13:
14425
+ _context5.prev = 13;
14426
+ _context5.t0 = _context5["catch"](0);
14427
+ errorMessage = _context5.t0 instanceof Error ? _context5.t0 : 'Unknown error occurred';
14428
+ dispatch(snackbarActions.openSnackbar({
14429
+ type: snackbarTypes.SnackbarMessageType.VERBATIM_MESSAGE,
14430
+ message: "Failed to save " + warningType.toUpperCase() + ": " + errorMessage
14431
+ }));
14432
+ throw _context5.t0;
14433
+ case 18:
14434
+ case "end":
14435
+ return _context5.stop();
14436
+ }
14437
+ }, _callee5, null, [[0, 13]]);
14438
+ }));
14439
+ return function deleteAviationProduct(_x7, _x8, _x9) {
14440
+ return _ref6.apply(this, arguments);
14441
+ };
14442
+ }();
14202
14443
  var handleAviationProductClick = function handleAviationProductClick(warning, actionType) {
14203
14444
  if (!warning) {
14204
14445
  return;
@@ -14206,14 +14447,34 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14206
14447
  var type = warning.warningDetail.level === 'SIG' ? 'sigmet' : 'airmet';
14207
14448
  var updatedWarning;
14208
14449
  switch (actionType) {
14450
+ case ProductAction.AMEND:
14451
+ void openPublicWarningDialog('amending', amendAviationProduct(warning, aviationConfig), type);
14452
+ break;
14209
14453
  case 'RENEW':
14210
14454
  updatedWarning = renewAviationProduct(warning, aviationConfig);
14455
+ void openPublicWarningDialog('edit', updatedWarning, type);
14211
14456
  break;
14212
14457
  case 'DUPLICATE':
14213
14458
  updatedWarning = duplicateAviationProduct(warning);
14459
+ void openPublicWarningDialog('edit', updatedWarning, type);
14460
+ break;
14461
+ case 'CANCEL':
14462
+ void openPublicWarningDialog('cancel', warning, type);
14463
+ break;
14464
+ case 'DISCARD':
14465
+ setConfirmDialogOptions({
14466
+ confirmLabel: t('warning-dialog-delete-confirm'),
14467
+ title: t('warning-dialog-delete-title'),
14468
+ description: t('warning-dialog-delete-description'),
14469
+ request: function request() {
14470
+ return deleteAviationProduct(warning, 'DISCARDED', type);
14471
+ },
14472
+ callback: function callback() {
14473
+ return onRemoveSuccess(warning.id);
14474
+ }
14475
+ });
14214
14476
  break;
14215
14477
  }
14216
- void openPublicWarningDialog('edit', updatedWarning, type);
14217
14478
  };
14218
14479
  var openSnackbar = function openSnackbar(message) {
14219
14480
  dispatch(snackbarActions.openSnackbar({
@@ -14228,10 +14489,13 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14228
14489
  title: t('warning-dialog-delete-title'),
14229
14490
  description: t('warning-dialog-delete-description'),
14230
14491
  request: function request() {
14231
- return warningsApi.deleteWarning(warningId);
14232
- },
14233
- callback: function callback() {
14234
- return onRemoveSuccess(warningId, t('warning-dialog-delete-succes'));
14492
+ return deletePublicWarning({
14493
+ id: warningId
14494
+ }, {
14495
+ onSuccess: function onSuccess() {
14496
+ return onRemoveSuccessHooks(warningId);
14497
+ }
14498
+ });
14235
14499
  },
14236
14500
  isLocked: isLocked
14237
14501
  });
@@ -14252,6 +14516,17 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14252
14516
  }
14253
14517
  });
14254
14518
  };
14519
+ var onRemoveSuccessHooks = function onRemoveSuccessHooks(warningId) {
14520
+ setConfirmDialogOptions(undefined);
14521
+ // Close warning dialog if needed
14522
+ if (selectedWarningId === warningId) {
14523
+ dispatch(uiActions.setToggleOpenDialog({
14524
+ setOpen: false,
14525
+ type: publicWarningDialogType
14526
+ }));
14527
+ }
14528
+ };
14529
+ // TODO remove when all is moved to tanstack
14255
14530
  var onRemoveSuccess = function onRemoveSuccess(warningId, snackbarMessage) {
14256
14531
  // close confirm dialog
14257
14532
  setConfirmDialogOptions(undefined);
@@ -14262,7 +14537,9 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
14262
14537
  type: publicWarningDialogType
14263
14538
  }));
14264
14539
  }
14265
- openSnackbar(snackbarMessage);
14540
+ if (snackbarMessage) {
14541
+ openSnackbar(snackbarMessage);
14542
+ }
14266
14543
  refetchWarnings();
14267
14544
  };
14268
14545
  var onUpdateFilters = React__default.useCallback(function (filterState, systemUpdate) {
@@ -14590,7 +14867,7 @@ var warningsReducersMap = {
14590
14867
  snackbar: snackbarReducer,
14591
14868
  syncGroups: syncGroupsReducer
14592
14869
  };
14593
- var warningsMiddlewares = [mapListener.middleware, layersListener.middleware, drawingToolListener.middleware, warningsDrawingsListener.middleware, publicWarningsListener.middleware, publicWarningFormListener.middleware, snackbarListener.middleware, syncGroupsListener.middleware];
14870
+ var warningsMiddlewares = [mapListener.middleware, layersListener.middleware, drawingToolListener.middleware, warningsDrawingsListener.middleware, publicWarningsListener.middleware, publicWarningFormListener.middleware, snackbarListener.middleware, syncGroupsListener.middleware, openlayersListener.middleware];
14594
14871
  var warningsRootReducer = combineReducers(warningsReducersMap);
14595
14872
  var createMockStore = function createMockStore(mockState) {
14596
14873
  return configureStore({