@opengeoweb/warnings 10.2.1-spike-ol.3 → 11.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/index.esm.js +689 -701
  2. package/package.json +26 -38
  3. package/src/lib/api/aviation-api/fakeApi.d.ts +1 -1
  4. package/src/lib/api/hooks.spec.d.ts +1 -0
  5. package/src/lib/api/warning-api/api.d.ts +3 -1
  6. package/src/lib/api/warning-api/hooks.d.ts +13 -4
  7. package/src/lib/components/FilterList/filter-hooks.d.ts +4 -5
  8. package/src/lib/components/FilterList/filter-utils.d.ts +3 -3
  9. package/src/lib/components/PublicWarningList/PublicWarningListConnect.confirmation.integration.spec.d.ts +1 -0
  10. package/src/lib/components/PublicWarningList/PublicWarningListConnect.draft.integration.spec.d.ts +1 -0
  11. package/src/lib/components/PublicWarningList/PublicWarningListConnect.stories.d.ts +3 -3
  12. package/src/lib/components/PublicWarningsForm/PublicWarningsForm.d.ts +5 -5
  13. package/src/lib/components/PublicWarningsForm/PublicWarningsForm.stories.d.ts +20 -28
  14. package/src/lib/components/PublicWarningsForm/PublicWarningsFormConnect.d.ts +0 -1
  15. package/src/lib/components/WarningsMapView/WarningsMapView.d.ts +1 -0
  16. package/src/lib/components/WarningsModuleProvider/WarningsModuleProvider.spec.d.ts +1 -0
  17. package/src/lib/store/publicWarningForm/reducer.d.ts +1 -18
  18. package/src/lib/store/publicWarningForm/selectors.d.ts +5 -0
  19. package/src/lib/store/publicWarnings/reducer.d.ts +4 -4
  20. package/src/lib/store/publicWarnings/selectors.d.ts +5 -4
  21. package/src/lib/store/publicWarnings/types.d.ts +2 -2
  22. package/src/lib/storybookUtils/testUtils.d.ts +2 -2
  23. package/src/lib/utils/fakeApi/index.d.ts +4 -3
package/index.esm.js CHANGED
@@ -2,14 +2,14 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useDispatch, useSelector } from 'react-redux';
3
3
  import { Polygons, Share, ExitDomain, 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
4
  import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawingToolSelectors, layerSelectors, uiSelectors, drawingToolActions, layerActions, useSetupDialog, selectorMemoizationOptions, useUpdateSharedData, layersListener, drawingToolListener, layerReducer, uiReducer, drawingToolReducer } from '@opengeoweb/store';
5
- import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, defaultLayers, getFeatureExtent, OpenLayersMapView, OpenLayersLayer, GeoJSONLayer, genericOpenlayersFeatureStyle } from '@opengeoweb/webmap-react';
6
- import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, FilterChip, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
7
- import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf, combineReducers, configureStore } from '@reduxjs/toolkit';
5
+ import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, defaultLayers, MapView, MapViewLayer, getFeatureExtent } from '@opengeoweb/webmap-react';
6
+ import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, FilterChip, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, isAxiosError } from '@opengeoweb/shared';
7
+ import { createEntityAdapter, createSlice, createSelector, current, createListenerMiddleware, combineReducers, configureStore } from '@reduxjs/toolkit';
8
8
  import 'i18next';
9
9
  import { useTranslation } from 'react-i18next';
10
10
  import '@opengeoweb/core';
11
11
  import { FORM_FIELDS_NAMESPACE, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, ReactHookFormProvider, defaultFormOptions, useDraftFormHelpers, errorMessages, ReactHookFormDateTime, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
12
- import { LayerType, generateMapId } from '@opengeoweb/webmap';
12
+ import { LayerType, generateMapId, getWMJSMapById, getGeoCoordFromLatLong, WMBBOX } from '@opengeoweb/webmap';
13
13
  import { airmetConfig, sigmetConfig, SigmetForm, isInstanceOfCancelSigmet, AirmetForm, isInstanceOfCancelAirmet, getDefaultValidUntilValue, getProductFormMode, ProductAction } from '@opengeoweb/sigmet-airmet';
14
14
  import { snackbarActions, snackbarTypes, snackbarListener, snackbarReducer } from '@opengeoweb/snackbar';
15
15
  import * as React from 'react';
@@ -17,15 +17,12 @@ import React__default, { useState, useEffect, useRef, useMemo, useCallback } fro
17
17
  import { styled, Box, Typography, ListItem, Grid2, Paper, ListItemButton, Stack, LinearProgress, Button, FormHelperText, MenuItem, Tabs, Tab, Card, CardContent, 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
- import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider, AirmetPhenomena, SigmetPhenomena, getHeaders, handleResponse, useAuthQuery, useAuthenticationContext, ProductStatus, optimisticUpdate } from '@opengeoweb/api';
21
- import { rest } from 'msw';
22
- import { concat, isEqual, cloneDeep, clamp, groupBy, pick, assign } from 'lodash';
20
+ import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider, AirmetPhenomena, SigmetPhenomena, getHeaders, handleResponse, useAuthQuery, useAuthenticationContext, optimisticUpdate, ProductStatus } from '@opengeoweb/api';
21
+ import { http, HttpResponse, passthrough, delay } from 'msw';
22
+ import { concat, isEqual, cloneDeep, clamp, groupBy, pick } from 'lodash';
23
23
  import { useFormContext } from 'react-hook-form';
24
24
  import { getConfig, useAuthenticationContext as useAuthenticationContext$1 } from '@opengeoweb/authentication';
25
- import { View } from 'ol';
26
- import { fromLonLat } from 'ol/proj';
27
25
  import { useQueryClient, useMutation } from '@tanstack/react-query';
28
- import { isAxiosError } from 'axios';
29
26
 
30
27
  var en = {
31
28
  "drawing-tool-form-tools": "Tools",
@@ -2168,36 +2165,6 @@ var slice$1 = createSlice({
2168
2165
  draft.warningType = (warning == null ? void 0 : warning.type) || warningType;
2169
2166
  draft.panelId = panelId;
2170
2167
  },
2171
- // publish warning
2172
- publishWarning: function publishWarning(draft,
2173
- // eslint-disable-next-line no-unused-vars
2174
- action) {
2175
- draft.formState = 'publishing';
2176
- delete draft.error;
2177
- },
2178
- publishWarningSuccess: function publishWarningSuccess(draft, action) {
2179
- var publicWarning = action.payload.publicWarning;
2180
- draft.warning = publicWarning;
2181
- // If form has been published, set form to readonly
2182
- draft.formState = 'readonly';
2183
- },
2184
- // save warning
2185
- saveWarning: function saveWarning(draft,
2186
- // eslint-disable-next-line no-unused-vars
2187
- action) {
2188
- draft.formState = 'saving';
2189
- delete draft.error;
2190
- draft.warning = action.payload.publicWarning;
2191
- },
2192
- saveWarningSuccess: function saveWarningSuccess(draft, action) {
2193
- var _publicWarning$warnin;
2194
- var publicWarning = action.payload.publicWarning;
2195
- draft.warning = publicWarning;
2196
- if (publicWarning != null && (_publicWarning$warnin = publicWarning.warningDetail) != null && _publicWarning$warnin.id) {
2197
- draft.selectedWarningId = publicWarning.warningDetail.id;
2198
- }
2199
- draft.formState = '';
2200
- },
2201
2168
  setFormError: function setFormError(draft, action) {
2202
2169
  var _action$payload3 = action.payload,
2203
2170
  message = _action$payload3.message,
@@ -7440,39 +7407,22 @@ var airmetList$1 = airmetListJSON;
7440
7407
  var sigmetList$1 = sigmetListJSON;
7441
7408
  var fakeSigmetTAC = 'EHAA SIGMET 1 VALID 121249/121449 EHDB- EHAA AMSTERDAM FIR FRQ TS OBS ENTIRE FIR FL010 STNR WKN';
7442
7409
  var fakeAirmetTAC = 'EHAA AIRMET -1 VALID 310700/311100 EHDB- EHAA AMSTERDAM FIR ISOL CB OBS ENTIRE FIR FL020 STNR NC';
7443
- [rest.get(/^.*\/airmetlist$/, function (_, res, ctx) {
7444
- return res(ctx.status(200), ctx.json(airmetList$1));
7445
- }), rest.get(/^.*\/sigmetlist$/, function (_, res, ctx) {
7446
- return res(ctx.status(200), ctx.json(sigmetList$1));
7447
- }), rest.get(/^.*\/airmet-config$/, function (_, res, ctx) {
7448
- return res(ctx.status(200), ctx.json(airmetConfig));
7449
- }), rest.get(/^.*\/sigmet-config$/, function (_, res, ctx) {
7450
- return res(ctx.status(200), ctx.json(sigmetConfig));
7451
- }), rest.post(/^.*\/airmet2tac$/, function (_, res, ctx) {
7452
- return res(ctx.status(200), ctx.text(fakeAirmetTAC));
7453
- }), rest.post(/^.*\/sigmet2tac$/, function (_, res, ctx) {
7454
- return res(ctx.status(200), ctx.text(fakeSigmetTAC));
7455
- }), rest.get(/^(?!.*(sigmet|airmet)).*$/, function (req) {
7456
- return req.passthrough();
7410
+ [http.get(/^.*\/airmetlist$/, function () {
7411
+ return HttpResponse.json(airmetList$1);
7412
+ }), http.get(/^.*\/sigmetlist$/, function () {
7413
+ return HttpResponse.json(sigmetList$1);
7414
+ }), http.get(/^.*\/airmet-config$/, function () {
7415
+ return HttpResponse.json(airmetConfig);
7416
+ }), http.get(/^.*\/sigmet-config$/, function () {
7417
+ return HttpResponse.json(sigmetConfig);
7418
+ }), http.post(/^.*\/airmet2tac$/, function () {
7419
+ return HttpResponse.text(fakeAirmetTAC);
7420
+ }), http.post(/^.*\/sigmet2tac$/, function () {
7421
+ return HttpResponse.text(fakeSigmetTAC);
7422
+ }), http.get(/^(?!.*(sigmet|airmet)).*$/, function () {
7423
+ return passthrough();
7457
7424
  })];
7458
7425
 
7459
- /* *
7460
- * Licensed under the Apache License, Version 2.0 (the "License");
7461
- * you may not use this file except in compliance with the License.
7462
- * You may obtain a copy of the License at
7463
- *
7464
- * http://www.apache.org/licenses/LICENSE-2.0
7465
- *
7466
- * Unless required by applicable law or agreed to in writing, software
7467
- * distributed under the License is distributed on an "AS IS" BASIS,
7468
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
7469
- * See the License for the specific language governing permissions and
7470
- * limitations under the License.
7471
- *
7472
- * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
7473
- * Copyright 2023 - Finnish Meteorological Institute (FMI)
7474
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
7475
- * */
7476
7426
  var drawingList = drawingListJSON;
7477
7427
  var drawingsListFullContent = drawingsListFullContentJSON;
7478
7428
  var warningList = warningListJSON.map(function (pw) {
@@ -7483,24 +7433,35 @@ var warningList = warningListJSON.map(function (pw) {
7483
7433
  warningList.filter(function (warning) {
7484
7434
  return warning.status !== 'EXPIRED' && warning.status !== 'WITHDRAWN';
7485
7435
  }).length;
7486
- var sigmetList = sigmetListJSON$1.map(function (s) {
7487
- return Object.assign({}, s, {
7436
+ var sigmetList = sigmetListJSON$1.map(function (sig) {
7437
+ return Object.assign({}, sig, {
7488
7438
  type: 'sigmet'
7489
7439
  });
7490
7440
  });
7491
- var airmetList = airmetListJSON$1.map(function (a) {
7492
- return Object.assign({}, a, {
7441
+ var airmetList = airmetListJSON$1.map(function (air) {
7442
+ return Object.assign({}, air, {
7493
7443
  type: 'airmet'
7494
7444
  });
7495
7445
  });
7496
7446
  concat(warningList, sigmetList, airmetList);
7497
7447
  var areaKeywordList = ['North Sea districts', 'Coastal Districts', 'KNMI Specific', 'Objects', 'Baltic areas', 'NL', 'FI', 'METNorway Specific', 'Provinces', 'FIR', 'Countries'];
7498
- [rest.get(/^.*\/warnings$/, function (req, res, ctx) {
7448
+ [http.get(/^.*\/warnings$/, function () {
7499
7449
  // respond using a mocked JSON body
7500
- return res(ctx.json(warningList));
7501
- }), rest.post(/^.*\/warnings\/(.*)$/, function (req, res, ctx) {
7502
- return res(ctx.json({}));
7503
- })];
7450
+ return HttpResponse.json(warningList);
7451
+ }), http.post(/^.*\/warnings\/(.*)$/, /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
7452
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
7453
+ while (1) switch (_context.prev = _context.next) {
7454
+ case 0:
7455
+ _context.next = 2;
7456
+ return delay();
7457
+ case 2:
7458
+ return _context.abrupt("return", HttpResponse.json(null));
7459
+ case 3:
7460
+ case "end":
7461
+ return _context.stop();
7462
+ }
7463
+ }, _callee);
7464
+ })))];
7504
7465
 
7505
7466
  /* *
7506
7467
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -7569,20 +7530,14 @@ var getApiRoutes = function getApiRoutes(axiosInstance) {
7569
7530
  });
7570
7531
  },
7571
7532
  updateDrawing: function updateDrawing(drawingId, data) {
7572
- // eslint-disable-next-line no-console
7573
- console.log('api: save drawing', drawingId, data);
7574
7533
  return axiosInstance.post("/drawings/" + drawingId + "/", data);
7575
7534
  },
7576
7535
  saveDrawingAs: function saveDrawingAs(data) {
7577
- // eslint-disable-next-line no-console
7578
- console.log('api: save drawing as', data);
7579
7536
  return axiosInstance.post("/drawings/", data).then(function () {
7580
7537
  return 'new-drawing-id';
7581
7538
  });
7582
7539
  },
7583
7540
  deleteDrawing: function deleteDrawing(drawingId) {
7584
- // eslint-disable-next-line no-console
7585
- console.log('api: delete drawing', drawingId);
7586
7541
  drawingList.splice(drawingList.findIndex(function (drawing) {
7587
7542
  return drawing.id === drawingId;
7588
7543
  }), 1);
@@ -7596,20 +7551,14 @@ var getApiRoutes = function getApiRoutes(axiosInstance) {
7596
7551
  });
7597
7552
  },
7598
7553
  saveWarningAs: function saveWarningAs(data) {
7599
- // eslint-disable-next-line no-console
7600
- console.log('api: save warning as', data);
7601
7554
  return axiosInstance.post("/warnings/", data).then(function () {
7602
7555
  return 'new-warning-id';
7603
7556
  });
7604
7557
  },
7605
7558
  updateWarning: function updateWarning(warningId, data) {
7606
- // eslint-disable-next-line no-console
7607
- console.log("api: update warning " + warningId, data);
7608
7559
  return axiosInstance.post("/warnings/" + warningId + "/", data);
7609
7560
  },
7610
7561
  deleteWarning: function deleteWarning(warningId) {
7611
- // eslint-disable-next-line no-console
7612
- console.log('api: delete warning', warningId);
7613
7562
  warningList.splice(warningList.findIndex(function (warning) {
7614
7563
  return warning.id === warningId;
7615
7564
  }), 1);
@@ -7617,7 +7566,7 @@ var getApiRoutes = function getApiRoutes(axiosInstance) {
7617
7566
  }
7618
7567
  };
7619
7568
  };
7620
- // used in storybook
7569
+ // used in storybook and tests
7621
7570
  var createApi = function createApi() {
7622
7571
  var instance = createFakeApiInstance();
7623
7572
  return getApiRoutes(instance);
@@ -8750,12 +8699,15 @@ var domainLevels = {
8750
8699
  };
8751
8700
  var defaultLevelFilter = (_defaultLevelFilter = {}, _defaultLevelFilter[emptyFilterId] = true, _defaultLevelFilter.extreme = true, _defaultLevelFilter.moderate = true, _defaultLevelFilter.severe = true, _defaultLevelFilter.AIR = true, _defaultLevelFilter.SIG = true, _defaultLevelFilter);
8752
8701
  var defaultEmptyFilter = (_defaultEmptyFilter = {}, _defaultEmptyFilter[emptyFilterId] = true, _defaultEmptyFilter);
8753
- var makeFilterFromList = function makeFilterFromList(options) {
8702
+ var makeFilterFromList = function makeFilterFromList(options, value) {
8754
8703
  var _options$reduce;
8704
+ if (value === void 0) {
8705
+ value = true;
8706
+ }
8755
8707
  return options.reduce(function (acc, p) {
8756
8708
  var _Object$assign;
8757
- return p ? Object.assign({}, acc, (_Object$assign = {}, _Object$assign[p] = true, _Object$assign)) : acc;
8758
- }, (_options$reduce = {}, _options$reduce[emptyFilterId] = true, _options$reduce));
8709
+ return p ? Object.assign({}, acc, (_Object$assign = {}, _Object$assign[p] = value, _Object$assign)) : acc;
8710
+ }, (_options$reduce = {}, _options$reduce[emptyFilterId] = value, _options$reduce));
8759
8711
  };
8760
8712
  var AllPhenomena = Object.assign({}, AirmetPhenomena, SigmetPhenomena, Phenomenon$1);
8761
8713
  var AllPhenomenaKeys = Object.fromEntries(Object.keys(AllPhenomena).map(function (key) {
@@ -8775,6 +8727,9 @@ var initialFilters = {
8775
8727
  level: defaultLevelFilter
8776
8728
  };
8777
8729
  var getSelectedOptions = function getSelectedOptions(options) {
8730
+ if (options === void 0) {
8731
+ options = {};
8732
+ }
8778
8733
  var selectedOptions = Object.keys(options).filter(function (k) {
8779
8734
  return options[k];
8780
8735
  });
@@ -9331,13 +9286,39 @@ var ValidUntil = function ValidUntil(_ref) {
9331
9286
  });
9332
9287
  };
9333
9288
 
9289
+ var zoomToFeature = function zoomToFeature(mapId, geojsonFeature) {
9290
+ var webmapjs = getWMJSMapById(mapId);
9291
+ if (!webmapjs || !geojsonFeature) {
9292
+ return;
9293
+ }
9294
+ var bboxGeoJSON = getFeatureExtent(geojsonFeature);
9295
+ var projectedCoordinateBoxBottomLeft = getGeoCoordFromLatLong(webmapjs, {
9296
+ x: bboxGeoJSON.left,
9297
+ y: bboxGeoJSON.bottom
9298
+ });
9299
+ var projectedCoordinateBoxTopRight = getGeoCoordFromLatLong(webmapjs, {
9300
+ x: bboxGeoJSON.right,
9301
+ y: bboxGeoJSON.top
9302
+ });
9303
+ if (projectedCoordinateBoxBottomLeft && projectedCoordinateBoxTopRight) {
9304
+ var transformedExtent = new WMBBOX({
9305
+ left: projectedCoordinateBoxBottomLeft.x,
9306
+ bottom: projectedCoordinateBoxBottomLeft.y,
9307
+ right: projectedCoordinateBoxTopRight.x,
9308
+ top: projectedCoordinateBoxTopRight.y
9309
+ });
9310
+ webmapjs.zoomTo(transformedExtent);
9311
+ webmapjs.zoomOut(2);
9312
+ webmapjs.draw();
9313
+ }
9314
+ };
9334
9315
  var WarningsMapView = function WarningsMapView(_ref) {
9335
9316
  var _defaultMapPreset$lay, _defaultMapPreset$lay2;
9336
9317
  var geojsonFeature = _ref.geojsonFeature,
9337
9318
  defaultMapPreset = _ref.defaultMapPreset,
9338
9319
  _ref$isSnapshot = _ref.isSnapshot,
9339
9320
  isSnapshot = _ref$isSnapshot === void 0 ? false : _ref$isSnapshot;
9340
- // const defaultBbox = defaultMapPreset?.proj;
9321
+ var defaultBbox = defaultMapPreset == null ? void 0 : defaultMapPreset.proj;
9341
9322
  var defaultBaseLayer = (defaultMapPreset == null || (_defaultMapPreset$lay = defaultMapPreset.layers) == null ? void 0 : _defaultMapPreset$lay.find(function (layer) {
9342
9323
  return layer.layerType === LayerType.baseLayer;
9343
9324
  })) || defaultLayers.baseLayerGrey;
@@ -9350,46 +9331,35 @@ var WarningsMapView = function WarningsMapView(_ref) {
9350
9331
  geojson: geojsonFeature,
9351
9332
  layerType: LayerType.featureLayer
9352
9333
  };
9353
- var view = new View({
9354
- center: [685500, 6800000],
9355
- zoom: 5.5,
9356
- projection: 'EPSG:3857'
9357
- });
9358
- var bboxGeoJSON = geojsonFeature && getFeatureExtent(geojsonFeature);
9359
- var coordMin = fromLonLat([bboxGeoJSON == null ? void 0 : bboxGeoJSON.left, bboxGeoJSON == null ? void 0 : bboxGeoJSON.bottom], 'EPSG:3857');
9360
- var coordMax = fromLonLat([bboxGeoJSON == null ? void 0 : bboxGeoJSON.right, bboxGeoJSON == null ? void 0 : bboxGeoJSON.top], 'EPSG:3857');
9361
- var center = [(coordMin[0] + coordMax[0]) / 2, (coordMin[1] + coordMax[1]) / 2];
9362
- view.setCenter(center);
9334
+ if (!defaultBbox) {
9335
+ // Zoom to the geojson when the geojsonFeature is updated in an already mounted map component
9336
+ zoomToFeature(mapId, geojsonFeature);
9337
+ }
9363
9338
  return jsx("div", {
9364
9339
  style: {
9365
9340
  height: '200px',
9366
9341
  width: '100%'
9367
9342
  },
9368
- children: jsxs(OpenLayersMapView, {
9369
- view: view,
9370
- // bbox={defaultBbox?.bbox}
9371
- // srs={defaultBbox?.srs}
9372
- // mapId={mapId}
9373
- // showScaleBar={false}
9374
- // onWMJSMount={(mapId) => {
9375
- // const webmapjs = getWMJSMapById(mapId);
9376
- // if (!webmapjs) {
9377
- // return;
9378
- // }
9379
- // webmapjs.hideMouseCursorProperties();
9380
- // if (!defaultBbox) {
9381
- // // Zoom to the geojson when the map is ready
9382
- // zoomToFeature(mapId, geojsonFeature);
9383
- // }
9384
- // }}
9343
+ children: jsxs(MapView, {
9344
+ bbox: defaultBbox == null ? void 0 : defaultBbox.bbox,
9345
+ srs: defaultBbox == null ? void 0 : defaultBbox.srs,
9346
+ mapId: mapId,
9347
+ showScaleBar: false,
9348
+ onWMJSMount: function onWMJSMount(mapId) {
9349
+ var webmapjs = getWMJSMapById(mapId);
9350
+ if (!webmapjs) {
9351
+ return;
9352
+ }
9353
+ webmapjs.hideMouseCursorProperties();
9354
+ if (!defaultBbox) {
9355
+ // Zoom to the geojson when the map is ready
9356
+ zoomToFeature(mapId, geojsonFeature);
9357
+ }
9358
+ },
9385
9359
  holdShiftToScroll: true,
9386
- children: [!isSnapshot && jsx(OpenLayersLayer, Object.assign({}, defaultBaseLayer, {
9360
+ children: [!isSnapshot && jsx(MapViewLayer, Object.assign({}, defaultBaseLayer, {
9387
9361
  id: mapId + "_baseLayer"
9388
- })), warningLayer.geojson && jsx(GeoJSONLayer, {
9389
- featureCollection: warningLayer.geojson,
9390
- style: genericOpenlayersFeatureStyle,
9391
- zIndex: 1000
9392
- }), !isSnapshot && jsx(OpenLayersLayer, Object.assign({}, defaultOverLayer, {
9362
+ })), warningLayer.geojson && jsx(MapViewLayer, Object.assign({}, warningLayer)), !isSnapshot && jsx(MapViewLayer, Object.assign({}, defaultOverLayer, {
9393
9363
  id: mapId + "_overlayer"
9394
9364
  }))]
9395
9365
  })
@@ -9799,14 +9769,32 @@ var Form = function Form(_ref5) {
9799
9769
  var _publicWarningDetails, _publicWarningDetails2;
9800
9770
  var defaultMapPreset = _ref5.defaultMapPreset,
9801
9771
  _ref5$onSaveForm = _ref5.onSaveForm,
9802
- onSaveForm = _ref5$onSaveForm === void 0 ? function () {} : _ref5$onSaveForm,
9772
+ onSaveForm = _ref5$onSaveForm === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
9773
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
9774
+ while (1) switch (_context.prev = _context.next) {
9775
+ case 0:
9776
+ return _context.abrupt("return", null);
9777
+ case 1:
9778
+ case "end":
9779
+ return _context.stop();
9780
+ }
9781
+ }, _callee);
9782
+ })) : _ref5$onSaveForm,
9803
9783
  _ref5$onPublishForm = _ref5.onPublishForm,
9804
- onPublishForm = _ref5$onPublishForm === void 0 ? function () {} : _ref5$onPublishForm,
9784
+ onPublishForm = _ref5$onPublishForm === void 0 ? /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
9785
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
9786
+ while (1) switch (_context2.prev = _context2.next) {
9787
+ case 0:
9788
+ return _context2.abrupt("return", null);
9789
+ case 1:
9790
+ case "end":
9791
+ return _context2.stop();
9792
+ }
9793
+ }, _callee2);
9794
+ })) : _ref5$onPublishForm,
9805
9795
  _ref5$onClearForm = _ref5.onClearForm,
9806
9796
  onClearForm = _ref5$onClearForm === void 0 ? function () {} : _ref5$onClearForm,
9807
9797
  object = _ref5.object,
9808
- _ref5$formAction = _ref5.formAction,
9809
- formAction = _ref5$formAction === void 0 ? '' : _ref5$formAction,
9810
9798
  publicWarningDetails = _ref5.publicWarningDetails,
9811
9799
  _ref5$error = _ref5.error,
9812
9800
  error = _ref5$error === void 0 ? {
@@ -9824,14 +9812,25 @@ var Form = function Form(_ref5) {
9824
9812
  selectedAviationProduct = _ref5.selectedAviationProduct,
9825
9813
  _ref5$warningType = _ref5.warningType,
9826
9814
  warningType = _ref5$warningType === void 0 ? 'public' : _ref5$warningType,
9827
- mode = _ref5.mode;
9815
+ mode = _ref5.mode,
9816
+ _ref5$onSetViewModeRe = _ref5.onSetViewModeResetArea,
9817
+ onSetViewModeResetArea = _ref5$onSetViewModeRe === void 0 ? function () {} : _ref5$onSetViewModeRe;
9818
+ var _React$useState = React.useState(false),
9819
+ isPublishing = _React$useState[0],
9820
+ setIsPublishing = _React$useState[1];
9821
+ var _React$useState2 = React.useState(false),
9822
+ isSaving = _React$useState2[0],
9823
+ setIsSaving = _React$useState2[1];
9828
9824
  var _useTACApi = useTACApi(),
9829
9825
  fetchSigmetTAC = _useTACApi.fetchSigmetTAC,
9830
9826
  fetchAirmetTAC = _useTACApi.fetchAirmetTAC;
9831
9827
  var initialPublicWarningArea = (publicWarningDetails == null || (_publicWarningDetails = publicWarningDetails.areas) == null ? void 0 : _publicWarningDetails.length) && (publicWarningDetails == null || (_publicWarningDetails2 = publicWarningDetails.areas[0]) == null ? void 0 : _publicWarningDetails2.geoJSON);
9832
- var _React$useState = React.useState(initialPublicWarningArea),
9833
- warningGeoJSONFeature = _React$useState[0],
9834
- setWarningGeoJSONFeature = _React$useState[1];
9828
+ var _React$useState3 = React.useState(initialPublicWarningArea),
9829
+ warningGeoJSONFeature = _React$useState3[0],
9830
+ setWarningGeoJSONFeature = _React$useState3[1];
9831
+ var _React$useState4 = React.useState(publicWarningDetails == null ? void 0 : publicWarningDetails.areas),
9832
+ originalWarningAreas = _React$useState4[0],
9833
+ setOriginalWarningAreas = _React$useState4[1];
9835
9834
  var _useWarningsTranslati = useWarningsTranslation(),
9836
9835
  t = _useWarningsTranslati.t;
9837
9836
  var _useFormContext = useFormContext(),
@@ -9843,8 +9842,6 @@ var Form = function Form(_ref5) {
9843
9842
  var _useDraftFormHelpers = useDraftFormHelpers(),
9844
9843
  toggleIsDraft = _useDraftFormHelpers.toggleIsDraft,
9845
9844
  DraftFieldHelper = _useDraftFormHelpers.DraftFieldHelper;
9846
- var isPublishing = formAction === 'publishing';
9847
- var isSaving = formAction === 'saving';
9848
9845
  var areFieldsDisabled = isPublishing || isSaving;
9849
9846
  useFormDirty({
9850
9847
  isDirty: Object.keys(dirtyFields).length > 0,
@@ -9860,19 +9857,23 @@ var Form = function Form(_ref5) {
9860
9857
  if (!isPublishing) {
9861
9858
  toggleIsDraft(false);
9862
9859
  void handleSubmit( /*#__PURE__*/function () {
9863
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
9864
- return _regeneratorRuntime().wrap(function _callee$(_context) {
9865
- while (1) switch (_context.prev = _context.next) {
9860
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {
9861
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
9862
+ while (1) switch (_context3.prev = _context3.next) {
9866
9863
  case 0:
9867
- onPublishForm(prepareFormValues(data));
9868
- case 1:
9864
+ setIsPublishing(true);
9865
+ _context3.next = 3;
9866
+ return onPublishForm(prepareFormValues(data))["catch"](function () {});
9867
+ case 3:
9868
+ setIsPublishing(false);
9869
+ case 4:
9869
9870
  case "end":
9870
- return _context.stop();
9871
+ return _context3.stop();
9871
9872
  }
9872
- }, _callee);
9873
+ }, _callee3);
9873
9874
  }));
9874
9875
  return function (_x) {
9875
- return _ref6.apply(this, arguments);
9876
+ return _ref8.apply(this, arguments);
9876
9877
  };
9877
9878
  }())();
9878
9879
  }
@@ -9881,19 +9882,23 @@ var Form = function Form(_ref5) {
9881
9882
  if (!isSaving) {
9882
9883
  toggleIsDraft(true);
9883
9884
  void handleSubmit( /*#__PURE__*/function () {
9884
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
9885
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
9886
- while (1) switch (_context2.prev = _context2.next) {
9885
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
9886
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
9887
+ while (1) switch (_context4.prev = _context4.next) {
9887
9888
  case 0:
9888
- onSaveForm(prepareFormValues(data));
9889
- case 1:
9889
+ setIsSaving(true);
9890
+ _context4.next = 3;
9891
+ return onSaveForm(prepareFormValues(data))["catch"](function () {});
9892
+ case 3:
9893
+ setIsSaving(false);
9894
+ case 4:
9890
9895
  case "end":
9891
- return _context2.stop();
9896
+ return _context4.stop();
9892
9897
  }
9893
- }, _callee2);
9898
+ }, _callee4);
9894
9899
  }));
9895
9900
  return function (_x2) {
9896
- return _ref7.apply(this, arguments);
9901
+ return _ref9.apply(this, arguments);
9897
9902
  };
9898
9903
  }())();
9899
9904
  }
@@ -9903,6 +9908,7 @@ var Form = function Form(_ref5) {
9903
9908
  setWarningGeoJSONFeature(undefined);
9904
9909
  onClearForm();
9905
9910
  };
9911
+ // When switching warning, reset the form to the new values
9906
9912
  var publicWarningId = publicWarningDetails == null ? void 0 : publicWarningDetails.id;
9907
9913
  React.useEffect(function () {
9908
9914
  if (selectedAviationProduct) {
@@ -9910,8 +9916,27 @@ var Form = function Form(_ref5) {
9910
9916
  }
9911
9917
  // sync redux with react-hook-form
9912
9918
  reset(getFormData(publicWarningDetails, object));
9919
+ setOriginalWarningAreas(publicWarningDetails == null ? void 0 : publicWarningDetails.areas);
9913
9920
  // eslint-disable-next-line react-hooks/exhaustive-deps
9914
9921
  }, [publicWarningId]);
9922
+ // When the editor gets set back to viewer and the form is dirty, reset any changes made
9923
+ React.useEffect(function () {
9924
+ if (selectedAviationProduct) {
9925
+ return;
9926
+ }
9927
+ if (isReadOnly && (Object.keys(dirtyFields).length > 0 || (publicWarningDetails == null ? void 0 : publicWarningDetails.areas) !== originalWarningAreas)) {
9928
+ // // sync redux with react-hook-form
9929
+ var oldPublicWarning = Object.assign({}, publicWarningDetails, {
9930
+ areas: originalWarningAreas
9931
+ });
9932
+ reset(getFormData(oldPublicWarning, object));
9933
+ if ((publicWarningDetails == null ? void 0 : publicWarningDetails.areas) !== originalWarningAreas) {
9934
+ // update the store to contain the original area again
9935
+ onSetViewModeResetArea(originalWarningAreas || []);
9936
+ }
9937
+ }
9938
+ // eslint-disable-next-line react-hooks/exhaustive-deps
9939
+ }, [isReadOnly]);
9915
9940
  var areas = publicWarningDetails == null ? void 0 : publicWarningDetails.areas;
9916
9941
  React.useEffect(function () {
9917
9942
  if (selectedAviationProduct) {
@@ -9919,7 +9944,9 @@ var Form = function Form(_ref5) {
9919
9944
  }
9920
9945
  if (areas) {
9921
9946
  // sync redux with react-hook-form
9922
- setValue('areas', areas);
9947
+ setValue('areas', areas, {
9948
+ shouldDirty: true
9949
+ });
9923
9950
  }
9924
9951
  // eslint-disable-next-line react-hooks/exhaustive-deps
9925
9952
  }, [areas, setValue]);
@@ -10212,7 +10239,10 @@ var getPublicWarningStore = function getPublicWarningStore(store) {
10212
10239
  }
10213
10240
  return {};
10214
10241
  };
10215
- var getPublicWarningObject = createSelector(getPublicWarningStore, function (publicWarningStore) {
10242
+ var selectPublicWarningState = createSelector(getPublicWarningStore, function (state) {
10243
+ return state;
10244
+ });
10245
+ createSelector(getPublicWarningStore, function (publicWarningStore) {
10216
10246
  return publicWarningStore.object;
10217
10247
  });
10218
10248
  var getPublicWarning = createSelector(getPublicWarningStore, function (publicWarningStore) {
@@ -10233,7 +10263,7 @@ var getPublicWarningAreas = createSelector(getPublicWarningStore, function (publ
10233
10263
  var getPublicWarningFormState = createSelector(getPublicWarningStore, function (publicWarningStore) {
10234
10264
  return (publicWarningStore == null ? void 0 : publicWarningStore.formState) || '';
10235
10265
  });
10236
- var getPublicWarningFormError = createSelector(getPublicWarningStore, function (publicWarningStore) {
10266
+ createSelector(getPublicWarningStore, function (publicWarningStore) {
10237
10267
  return publicWarningStore == null ? void 0 : publicWarningStore.error;
10238
10268
  });
10239
10269
  var getSelectedWarningId = createSelector(getPublicWarningStore, function (publicWarningStore) {
@@ -10274,51 +10304,298 @@ var PublicWarningStatus;
10274
10304
  PublicWarningStatus["WITHDRAWN"] = "WITHDRAWN";
10275
10305
  })(PublicWarningStatus || (PublicWarningStatus = {}));
10276
10306
 
10307
+ /* *
10308
+ * Licensed under the Apache License, Version 2.0 (the "License");
10309
+ * you may not use this file except in compliance with the License.
10310
+ * You may obtain a copy of the License at
10311
+ *
10312
+ * http://www.apache.org/licenses/LICENSE-2.0
10313
+ *
10314
+ * Unless required by applicable law or agreed to in writing, software
10315
+ * distributed under the License is distributed on an "AS IS" BASIS,
10316
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10317
+ * See the License for the specific language governing permissions and
10318
+ * limitations under the License.
10319
+ *
10320
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
10321
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
10322
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
10323
+ * */
10324
+ var config = getConfig();
10325
+ var publicWarningBaseUrl = config.GW_DRAWINGS_BASE_URL || '';
10326
+ // API
10327
+ var getPublicWarningList = function getPublicWarningList(auth) {
10328
+ return fetch(publicWarningBaseUrl + "/warnings", {
10329
+ headers: getHeaders(auth)
10330
+ }).then(handleResponse).then(function (warnings) {
10331
+ return warnings.map(function (warning) {
10332
+ return Object.assign({}, warning, {
10333
+ type: 'public'
10334
+ });
10335
+ });
10336
+ });
10337
+ };
10338
+ var updatePublicWarningEditor = function updatePublicWarningEditor(warningId, isEditor, auth) {
10339
+ return fetch(publicWarningBaseUrl + "/warnings/" + warningId + "?editor=" + (isEditor ? 'true' : 'false') + "&force=true", {
10340
+ headers: getHeaders(auth),
10341
+ method: 'POST'
10342
+ }).then(handleResponse);
10343
+ };
10344
+ var updatePublicWarning = function updatePublicWarning(warningId, auth, data) {
10345
+ return fetch(publicWarningBaseUrl + "/warnings/" + warningId, {
10346
+ headers: getHeaders(auth),
10347
+ method: 'POST',
10348
+ body: JSON.stringify(data)
10349
+ }).then(handleResponse);
10350
+ };
10351
+ var postPublicWarning = function postPublicWarning(auth, data) {
10352
+ return fetch(publicWarningBaseUrl + "/warnings/", {
10353
+ headers: getHeaders(auth),
10354
+ method: 'POST',
10355
+ body: JSON.stringify(data)
10356
+ }).then(handleResponse);
10357
+ };
10358
+
10359
+ /**
10360
+ * @param disabled - Disables fetching, but still returns cached values.
10361
+ * https://tanstack.com/query/v4/docs/framework/react/guides/disabling-queries
10362
+ */
10363
+ var usePublicWarnings = function usePublicWarnings(disabled) {
10364
+ if (disabled === void 0) {
10365
+ disabled = false;
10366
+ }
10367
+ return useAuthQuery(['public-warning-list'], getPublicWarningList, disabled, 1000 * 60 * 5);
10368
+ };
10369
+ var useMutatePublicWarningEditor = function useMutatePublicWarningEditor() {
10370
+ var queryClient = useQueryClient();
10371
+ var _useAuthenticationCon = useAuthenticationContext(),
10372
+ auth = _useAuthenticationCon.auth;
10373
+ var dispatch = useDispatch();
10374
+ return useMutation(Object.assign({
10375
+ mutationFn: function mutationFn(_ref) {
10376
+ var id = _ref.id,
10377
+ isEditor = _ref.isEditor;
10378
+ if (!auth) {
10379
+ throw new Error('Authentication context not found');
10380
+ }
10381
+ return updatePublicWarningEditor(id, isEditor, auth);
10382
+ }
10383
+ }, optimisticUpdate(['public-warning-list'], queryClient, function (warning, _ref2) {
10384
+ var isEditor = _ref2.isEditor;
10385
+ return Object.assign({}, warning, {
10386
+ editor: isEditor ? auth.username : undefined
10387
+ });
10388
+ }, function (error) {
10389
+ dispatch(publicWarningFormActions.setFormError({
10390
+ message: error.message
10391
+ }));
10392
+ }), {
10393
+ onSuccess: function () {
10394
+ var _onSuccess = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data, _ref3) {
10395
+ var isEditor;
10396
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
10397
+ while (1) switch (_context.prev = _context.next) {
10398
+ case 0:
10399
+ isEditor = _ref3.isEditor;
10400
+ dispatch(snackbarActions.openSnackbar({
10401
+ type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
10402
+ key: isEditor ? 'warning-editor-add-editor' : 'warning-editor-remove-editor'
10403
+ }));
10404
+ case 2:
10405
+ case "end":
10406
+ return _context.stop();
10407
+ }
10408
+ }, _callee);
10409
+ }));
10410
+ function onSuccess(_x, _x2) {
10411
+ return _onSuccess.apply(this, arguments);
10412
+ }
10413
+ return onSuccess;
10414
+ }()
10415
+ }));
10416
+ };
10417
+ var useMutateWarning = function useMutateWarning(snackBarMessage) {
10418
+ var queryClient = useQueryClient();
10419
+ var _useAuthenticationCon2 = useAuthenticationContext(),
10420
+ auth = _useAuthenticationCon2.auth;
10421
+ var dispatch = useDispatch();
10422
+ return useMutation(Object.assign({
10423
+ mutationFn: function mutationFn(_ref4) {
10424
+ var id = _ref4.id,
10425
+ data = _ref4.data;
10426
+ if (!auth) {
10427
+ throw new Error('Authentication context not found');
10428
+ }
10429
+ if (id) {
10430
+ return updatePublicWarning(id, auth, data);
10431
+ }
10432
+ return postPublicWarning(auth, data);
10433
+ }
10434
+ }, optimisticUpdate(['public-warning-list'], queryClient, function (_, _ref5) {
10435
+ var data = _ref5.data,
10436
+ id = _ref5.id;
10437
+ return Object.assign({}, data, {
10438
+ id: id,
10439
+ lastUpdatedTime: new Date().toISOString()
10440
+ });
10441
+ }, function (error) {
10442
+ dispatch(publicWarningFormActions.setFormError({
10443
+ message: error.message
10444
+ }));
10445
+ }), {
10446
+ onSuccess: function () {
10447
+ var _onSuccess2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data, variables) {
10448
+ var location, _variables$data, warningDetail, status, newId, newWarning;
10449
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
10450
+ while (1) switch (_context2.prev = _context2.next) {
10451
+ case 0:
10452
+ location = data == null ? void 0 : data.get('location');
10453
+ _variables$data = variables.data, warningDetail = _variables$data.warningDetail, status = _variables$data.status;
10454
+ if (
10455
+ // DRAFT_PUBLISHED warnings have linked_to_id to the published warning it is based on
10456
+ // When publishing a DRAFT_PUBLISHED warning we need to update the published warning and delete the draft
10457
+ warningDetail.linked_to_id && status === PublicWarningStatus.PUBLISHED) {
10458
+ queryClient.setQueryData(['public-warning-list'], function (old) {
10459
+ return old == null ? void 0 : old.reduce(function (acc, warning) {
10460
+ if (warning.id === warningDetail.linked_to_id) {
10461
+ return acc;
10462
+ }
10463
+ var id = warning.id === warningDetail.id ? warningDetail.linked_to_id : warningDetail.id;
10464
+ return [].concat(acc, [Object.assign({}, warning, {
10465
+ id: id,
10466
+ warningDetail: Object.assign({}, warningDetail, {
10467
+ id: id
10468
+ })
10469
+ })]);
10470
+ }, []);
10471
+ });
10472
+ }
10473
+ if (location) {
10474
+ // When making a new warning we get it's ID from the location header
10475
+ newId = getIdFromUrl(location);
10476
+ newWarning = Object.assign({}, variables.data, {
10477
+ id: newId,
10478
+ lastUpdatedTime: new Date().toISOString(),
10479
+ warningDetail: Object.assign({}, warningDetail, {
10480
+ id: newId,
10481
+ domain: 'public'
10482
+ })
10483
+ });
10484
+ queryClient.setQueryData(['public-warning-list'], function (old) {
10485
+ return [].concat(old || [], [newWarning]);
10486
+ });
10487
+ dispatch(publicWarningFormActions.openPublicWarningFormDialog({
10488
+ warning: newWarning,
10489
+ formState: '',
10490
+ panelId: variables.panelId
10491
+ }));
10492
+ }
10493
+ dispatch(snackbarActions.openSnackbar({
10494
+ type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
10495
+ key: snackBarMessage
10496
+ }));
10497
+ if (variables.data.status === PublicWarningStatus.PUBLISHED) {
10498
+ dispatch(uiActions.setToggleOpenDialog({
10499
+ type: publicWarningDialogType,
10500
+ setOpen: false
10501
+ }));
10502
+ }
10503
+ case 6:
10504
+ case "end":
10505
+ return _context2.stop();
10506
+ }
10507
+ }, _callee2);
10508
+ }));
10509
+ function onSuccess(_x3, _x4) {
10510
+ return _onSuccess2.apply(this, arguments);
10511
+ }
10512
+ return onSuccess;
10513
+ }()
10514
+ }));
10515
+ };
10516
+ var usePublishWarning = function usePublishWarning() {
10517
+ return useMutateWarning('warning-publish-succes');
10518
+ };
10519
+ var useSaveWarning = function useSaveWarning() {
10520
+ return useMutateWarning('warning-save-succes');
10521
+ };
10522
+
10277
10523
  var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
10278
10524
  var editor = _ref.editor,
10279
10525
  defaultMapPreset = _ref.defaultMapPreset,
10280
10526
  selectedAviationProduct = _ref.selectedAviationProduct,
10281
10527
  _ref$warningType = _ref.warningType,
10282
10528
  warningType = _ref$warningType === void 0 ? 'public' : _ref$warningType,
10283
- mode = _ref.mode,
10284
- onFormSubmit = _ref.onFormSubmit;
10285
- var publicWarning = useSelector(getPublicWarning);
10286
- var publicWarningObject = useSelector(getPublicWarningObject);
10287
- var publicWarningFormAction = useSelector(getPublicWarningFormState);
10288
- var publicWarningFormError = useSelector(getPublicWarningFormError);
10529
+ mode = _ref.mode;
10530
+ var _useSelector = useSelector(selectPublicWarningState),
10531
+ warning = _useSelector.warning,
10532
+ object = _useSelector.object,
10533
+ formState = _useSelector.formState,
10534
+ error = _useSelector.error,
10535
+ panelId = _useSelector.panelId;
10536
+ var _usePublishWarning = usePublishWarning(),
10537
+ publishWarning = _usePublishWarning.mutateAsync;
10538
+ var _useSaveWarning = useSaveWarning(),
10539
+ saveWarning = _useSaveWarning.mutateAsync;
10289
10540
  var _useAuthenticationCon = useAuthenticationContext$1(),
10290
10541
  auth = _useAuthenticationCon.auth;
10291
10542
  var isEditor = editor === (auth == null ? void 0 : auth.username) || false;
10292
10543
  var dispatch = useDispatch();
10293
- var publishForm = function publishForm(newFormValues) {
10294
- if (warningType === 'public') {
10295
- dispatch(publicWarningFormActions.publishWarning({
10296
- publicWarning: {
10297
- warningDetail: newFormValues,
10298
- status: PublicWarningStatus.PUBLISHED,
10299
- type: warningType
10300
- },
10301
- refetchWarnings: onFormSubmit
10302
- }));
10303
- }
10304
- };
10544
+ var publishForm = /*#__PURE__*/function () {
10545
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(newFormValues) {
10546
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
10547
+ while (1) switch (_context.prev = _context.next) {
10548
+ case 0:
10549
+ return _context.abrupt("return", publishWarning({
10550
+ id: newFormValues.id || newFormValues.linked_to_id || '',
10551
+ data: {
10552
+ warningDetail: newFormValues.id ? newFormValues : Object.assign({}, newFormValues, {
10553
+ id: newFormValues.linked_to_id
10554
+ }),
10555
+ status: PublicWarningStatus.PUBLISHED,
10556
+ type: 'public'
10557
+ }
10558
+ }));
10559
+ case 1:
10560
+ case "end":
10561
+ return _context.stop();
10562
+ }
10563
+ }, _callee);
10564
+ }));
10565
+ return function publishForm(_x) {
10566
+ return _ref2.apply(this, arguments);
10567
+ };
10568
+ }();
10305
10569
  var clearForm = function clearForm() {
10306
10570
  dispatch(publicWarningFormActions.removeAllAreas());
10307
10571
  };
10308
- var saveForm = function saveForm(newFormValues) {
10309
- var status = newFormValues.linked_to_id ? PublicWarningStatus.DRAFT_PUBLISHED : PublicWarningStatus.DRAFT;
10310
- if (warningType === 'public') {
10311
- dispatch(publicWarningFormActions.saveWarning({
10312
- publicWarning: {
10313
- warningDetail: newFormValues,
10314
- status: status,
10315
- editor: auth == null ? void 0 : auth.username,
10316
- type: warningType
10317
- },
10318
- refetchWarnings: onFormSubmit
10319
- }));
10320
- }
10321
- };
10572
+ var saveForm = /*#__PURE__*/function () {
10573
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(newFormValues) {
10574
+ var status;
10575
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
10576
+ while (1) switch (_context2.prev = _context2.next) {
10577
+ case 0:
10578
+ status = newFormValues.linked_to_id ? PublicWarningStatus.DRAFT_PUBLISHED : PublicWarningStatus.DRAFT;
10579
+ return _context2.abrupt("return", saveWarning({
10580
+ id: newFormValues.id,
10581
+ data: {
10582
+ warningDetail: newFormValues,
10583
+ status: status,
10584
+ editor: auth == null ? void 0 : auth.username,
10585
+ type: 'public'
10586
+ },
10587
+ panelId: panelId
10588
+ }));
10589
+ case 2:
10590
+ case "end":
10591
+ return _context2.stop();
10592
+ }
10593
+ }, _callee2);
10594
+ }));
10595
+ return function saveForm(_x2) {
10596
+ return _ref3.apply(this, arguments);
10597
+ };
10598
+ }();
10322
10599
  var onFormDirty = function onFormDirty(isFormDirty) {
10323
10600
  dispatch(publicWarningFormActions.setFormDirty({
10324
10601
  isFormDirty: isFormDirty
@@ -10327,20 +10604,20 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
10327
10604
  var getIsReadOnly = function getIsReadOnly() {
10328
10605
  // public warning related
10329
10606
  if (warningType === 'public') {
10330
- if (publicWarningFormAction === 'readonly') {
10607
+ if (formState === 'readonly') {
10331
10608
  return true;
10332
10609
  }
10333
- if ((publicWarning == null ? void 0 : publicWarning.status) === 'TODO') {
10610
+ if ((warning == null ? void 0 : warning.status) === 'TODO') {
10334
10611
  return false;
10335
10612
  }
10336
10613
  // Readonly in case you are not creating a new warning and you are not set as the editor
10337
- return !isEditor && (publicWarning == null ? void 0 : publicWarning.status) !== undefined;
10614
+ return !isEditor && (warning == null ? void 0 : warning.status) !== undefined;
10338
10615
  }
10339
10616
  // aviation related
10340
10617
  if ((selectedAviationProduct == null ? void 0 : selectedAviationProduct.status) === 'DRAFT') {
10341
10618
  return false;
10342
10619
  }
10343
- if (publicWarningFormAction === 'edit') {
10620
+ if (formState === 'edit') {
10344
10621
  return false;
10345
10622
  }
10346
10623
  if (mode === 'new') {
@@ -10349,28 +10626,33 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
10349
10626
  return true;
10350
10627
  };
10351
10628
  var isReadOnly = getIsReadOnly();
10352
- var formMode = publicWarningFormAction === 'edit' ? 'edit' : mode;
10629
+ var formMode = formState === 'edit' ? 'edit' : mode;
10353
10630
  var onAddObject = function onAddObject() {
10354
10631
  dispatch(uiActions.setToggleOpenDialog({
10355
10632
  type: uiTypes.DialogTypes.AreaObjectLoader,
10356
10633
  setOpen: true
10357
10634
  }));
10358
10635
  };
10636
+ var onSetViewModeResetArea = function onSetViewModeResetArea(area) {
10637
+ dispatch(publicWarningFormActions.addArea({
10638
+ area: area[0]
10639
+ }));
10640
+ };
10359
10641
  return jsx(PublicWarningsForm, {
10360
- object: publicWarningObject,
10361
- publicWarningDetails: publicWarning == null ? void 0 : publicWarning.warningDetail,
10642
+ object: object,
10643
+ publicWarningDetails: warning == null ? void 0 : warning.warningDetail,
10362
10644
  onPublishForm: publishForm,
10363
10645
  onSaveForm: saveForm,
10364
10646
  onClearForm: clearForm,
10365
- formAction: publicWarningFormAction,
10366
10647
  isReadOnly: isReadOnly,
10367
- error: publicWarningFormError,
10648
+ error: error,
10368
10649
  onFormDirty: onFormDirty,
10369
10650
  defaultMapPreset: defaultMapPreset,
10370
10651
  onAddObject: onAddObject,
10371
10652
  selectedAviationProduct: selectedAviationProduct,
10372
10653
  warningType: warningType,
10373
- mode: formMode
10654
+ mode: formMode,
10655
+ onSetViewModeResetArea: onSetViewModeResetArea
10374
10656
  });
10375
10657
  };
10376
10658
 
@@ -11308,106 +11590,9 @@ var duplicateAviationProduct = function duplicateAviationProduct(aviationWarning
11308
11590
  * See the License for the specific language governing permissions and
11309
11591
  * limitations under the License.
11310
11592
  *
11311
- * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
11312
- * Copyright 2024 - Finnish Meteorological Institute (FMI)
11313
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
11314
- * */
11315
- var config = getConfig();
11316
- var publicWarningBaseUrl = config.GW_DRAWINGS_BASE_URL || '';
11317
- // API
11318
- var getPublicWarningList = function getPublicWarningList(auth) {
11319
- return fetch(publicWarningBaseUrl + "/warnings", {
11320
- headers: getHeaders(auth)
11321
- }).then(handleResponse).then(function (warnings) {
11322
- return warnings.map(function (warning) {
11323
- return Object.assign({}, warning, {
11324
- type: 'public'
11325
- });
11326
- });
11327
- });
11328
- };
11329
- var updatePublicWarningEditor = function updatePublicWarningEditor(warningId, isEditor, auth) {
11330
- return fetch(publicWarningBaseUrl + "/warnings/" + warningId + "?editor=" + (isEditor ? 'true' : 'false') + "&force=true", {
11331
- headers: getHeaders(auth),
11332
- method: 'POST'
11333
- }).then(handleResponse);
11334
- };
11335
-
11336
- /**
11337
- * @param disabled - Disables fetching, but still returns cached values.
11338
- * https://tanstack.com/query/v4/docs/framework/react/guides/disabling-queries
11339
- */
11340
- var usePublicWarnings = function usePublicWarnings(disabled) {
11341
- if (disabled === void 0) {
11342
- disabled = false;
11343
- }
11344
- return useAuthQuery(['public-warning-list'], getPublicWarningList, disabled, 1000 * 60 * 5);
11345
- };
11346
- var useMutatePublicWarningEditor = function useMutatePublicWarningEditor() {
11347
- var queryClient = useQueryClient();
11348
- var _useAuthenticationCon = useAuthenticationContext(),
11349
- auth = _useAuthenticationCon.auth;
11350
- var dispatch = useDispatch();
11351
- return useMutation(Object.assign({
11352
- mutationFn: function mutationFn(_ref) {
11353
- var id = _ref.id,
11354
- isEditor = _ref.isEditor;
11355
- if (!auth) {
11356
- throw new Error('Authentication context not found');
11357
- }
11358
- return updatePublicWarningEditor(id, isEditor, auth);
11359
- }
11360
- }, optimisticUpdate(['public-warning-list'], queryClient, function (w, _ref2) {
11361
- var isEditor = _ref2.isEditor;
11362
- return Object.assign({}, w, {
11363
- editor: isEditor ? auth.username : undefined
11364
- });
11365
- }, function (error) {
11366
- dispatch(publicWarningFormActions.setFormError({
11367
- message: error.message
11368
- }));
11369
- }), {
11370
- onSettled: function () {
11371
- var _onSettled = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data, e, _ref3) {
11372
- var isEditor;
11373
- return _regeneratorRuntime().wrap(function _callee$(_context) {
11374
- while (1) switch (_context.prev = _context.next) {
11375
- case 0:
11376
- isEditor = _ref3.isEditor;
11377
- dispatch(snackbarActions.openSnackbar({
11378
- type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
11379
- key: isEditor ? 'warning-editor-add-editor' : 'warning-editor-remove-editor'
11380
- }));
11381
- case 2:
11382
- case "end":
11383
- return _context.stop();
11384
- }
11385
- }, _callee);
11386
- }));
11387
- function onSettled(_x, _x2, _x3) {
11388
- return _onSettled.apply(this, arguments);
11389
- }
11390
- return onSettled;
11391
- }()
11392
- }));
11393
- };
11394
-
11395
- /* *
11396
- * Licensed under the Apache License, Version 2.0 (the "License");
11397
- * you may not use this file except in compliance with the License.
11398
- * You may obtain a copy of the License at
11399
- *
11400
- * http://www.apache.org/licenses/LICENSE-2.0
11401
- *
11402
- * Unless required by applicable law or agreed to in writing, software
11403
- * distributed under the License is distributed on an "AS IS" BASIS,
11404
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11405
- * See the License for the specific language governing permissions and
11406
- * limitations under the License.
11407
- *
11408
- * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
11409
- * Copyright 2025 - Finnish Meteorological Institute (FMI)
11410
- * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
11593
+ * Copyright 2025 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
11594
+ * Copyright 2025 - Finnish Meteorological Institute (FMI)
11595
+ * Copyright 2025 - The Norwegian Meteorological Institute (MET Norway)
11411
11596
  * */
11412
11597
  var useWarnings = function useWarnings(disabled) {
11413
11598
  var _usePublicWarnings = usePublicWarnings(disabled),
@@ -11601,12 +11786,16 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
11601
11786
  dispatch(publicWarningFormActions.setFormValues({
11602
11787
  formState: isReadOnly ? 'readonly' : ''
11603
11788
  }));
11789
+ dispatch(uiActions.setToggleOpenDialog({
11790
+ type: uiTypes.DialogTypes.AreaObjectLoader,
11791
+ setOpen: false
11792
+ }));
11604
11793
  updatePublicWarningEditor.mutate({
11605
11794
  id: selectedWarningId,
11606
11795
  isEditor: !isReadOnly
11607
11796
  });
11608
11797
  return _context2.abrupt("return", true);
11609
- case 14:
11798
+ case 15:
11610
11799
  case "end":
11611
11800
  return _context2.stop();
11612
11801
  }
@@ -11728,10 +11917,7 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
11728
11917
  defaultMapPreset: defaultMapPreset,
11729
11918
  selectedAviationProduct: selectedAviationProduct,
11730
11919
  warningType: updatedWarningType,
11731
- mode: mode,
11732
- onFormSubmit: function onFormSubmit() {
11733
- return refetchWarnings();
11734
- }
11920
+ mode: mode
11735
11921
  })
11736
11922
  }), jsx(AreaObjectLoaderConnect, {})]
11737
11923
  });
@@ -13173,7 +13359,9 @@ var slice = createSlice({
13173
13359
  filterState = _action$payload.filterState,
13174
13360
  panelId = _action$payload.panelId;
13175
13361
  if (panelId) {
13176
- draft.filterState[panelId] = filterState;
13362
+ var _current;
13363
+ var currentFilterState = ((_current = current(draft)) == null ? void 0 : _current.filterState[panelId]) || initialFilters;
13364
+ draft.filterState[panelId] = Object.assign({}, currentFilterState, filterState);
13177
13365
  }
13178
13366
  }
13179
13367
  }
@@ -13253,84 +13441,6 @@ var selectors = /*#__PURE__*/Object.freeze({
13253
13441
  selectAllPublicWarnings: selectAllPublicWarnings
13254
13442
  });
13255
13443
 
13256
- var ConfirmDeleteWarningDialog = function ConfirmDeleteWarningDialog(_ref) {
13257
- var _ref$onClose = _ref.onClose,
13258
- onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
13259
- title = _ref.title,
13260
- description = _ref.description,
13261
- request = _ref.request,
13262
- confirmLabel = _ref.confirmLabel,
13263
- callback = _ref.callback,
13264
- isLocked = _ref.isLocked;
13265
- var _useWarningsTranslati = useWarningsTranslation(),
13266
- t = _useWarningsTranslati.t;
13267
- var defaultError = isLocked ? t('warning-dialog-delete-islocked') : undefined;
13268
- var _React$useState = React__default.useState(false),
13269
- isLoading = _React$useState[0],
13270
- setIsLoading = _React$useState[1];
13271
- var _React$useState2 = React__default.useState(defaultError),
13272
- error = _React$useState2[0],
13273
- setError = _React$useState2[1];
13274
- var onSubmit = /*#__PURE__*/function () {
13275
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13276
- return _regeneratorRuntime().wrap(function _callee$(_context) {
13277
- while (1) switch (_context.prev = _context.next) {
13278
- case 0:
13279
- setIsLoading(true);
13280
- _context.prev = 1;
13281
- _context.next = 4;
13282
- return request();
13283
- case 4:
13284
- callback();
13285
- setIsLoading(false);
13286
- _context.next = 12;
13287
- break;
13288
- case 8:
13289
- _context.prev = 8;
13290
- _context.t0 = _context["catch"](1);
13291
- setError(getAxiosErrorMessage(_context.t0));
13292
- setIsLoading(false);
13293
- case 12:
13294
- case "end":
13295
- return _context.stop();
13296
- }
13297
- }, _callee, null, [[1, 8]]);
13298
- }));
13299
- return function onSubmit() {
13300
- return _ref2.apply(this, arguments);
13301
- };
13302
- }();
13303
- return jsx(ConfirmationDialog, Object.assign({
13304
- title: title,
13305
- open: true,
13306
- confirmLabel: confirmLabel,
13307
- cancelLabel: t('warning-dialog-cancel'),
13308
- description: !error ? description : '',
13309
- onClose: onClose,
13310
- onSubmit: onSubmit,
13311
- isLoading: isLoading,
13312
- sx: {
13313
- width: 330
13314
- }
13315
- }, error && {
13316
- content: jsxs(Box, {
13317
- sx: {
13318
- marginBottom: 0
13319
- },
13320
- children: [jsx(AlertBanner, {
13321
- title: error,
13322
- severity: isLocked ? 'warning' : 'error'
13323
- }), jsx(Typography, {
13324
- variant: "body1",
13325
- sx: {
13326
- marginTop: 1
13327
- },
13328
- children: description
13329
- })]
13330
- })
13331
- }));
13332
- };
13333
-
13334
13444
  /* *
13335
13445
  * Licensed under the Apache License, Version 2.0 (the "License");
13336
13446
  * you may not use this file except in compliance with the License.
@@ -13358,31 +13468,36 @@ var getPhenomenaForDomainFilter = function getPhenomenaForDomainFilter(domainFil
13358
13468
  return domainFilter[domain] ? domainPhenomena[domain] : [];
13359
13469
  });
13360
13470
  };
13361
- var getFilterOptions = function getFilterOptions(defaultFilter, allOptions, savedFilter) {
13362
- var pickedFilterOptions = pick(defaultFilter, [emptyFilterId].concat(allOptions));
13363
- // keep options state from savedFilter if it still exists
13364
- var updatedOptions = assign(pickedFilterOptions, pick(savedFilter || {}, Object.keys(pickedFilterOptions)));
13365
- var _getSelectedOptions = getSelectedOptions(updatedOptions),
13471
+ /** Get filter object
13472
+ * @param savedFilter The savedFilter with all options
13473
+ * @param visibleOptions The options that should be shown
13474
+ * @returns pickedFilterObject - The filter object with only the relevant options
13475
+ * @returns allSelected - A value for whether or not every visible option is selected
13476
+ */
13477
+ var getFilterOptions = function getFilterOptions(savedFilter, visibleOptions) {
13478
+ var pickedFilterObject = pick(savedFilter, [emptyFilterId].concat(visibleOptions));
13479
+ var _getSelectedOptions = getSelectedOptions(pickedFilterObject),
13366
13480
  allSelected = _getSelectedOptions.allSelected;
13367
- return [updatedOptions, allSelected];
13481
+ return [pickedFilterObject, allSelected];
13368
13482
  };
13369
13483
  var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, savedFilterState, presetFilterState) {
13370
- var pickedDomainFilter = savedFilterState.domain,
13371
- pickedPhenomenonFilter = savedFilterState.phenomenon,
13372
- pickedLevelFilter = savedFilterState.level,
13373
- pickedSourceFilter = savedFilterState.source,
13374
- pickedIncidentFilter = savedFilterState.incident;
13375
- /// level
13484
+ var savedDomainFilter = savedFilterState.domain,
13485
+ savedPhenomenonFilter = savedFilterState.phenomenon,
13486
+ savedLevelFilter = savedFilterState.level,
13487
+ savedSourceFilter = savedFilterState.source,
13488
+ savedIncidentFilter = savedFilterState.incident;
13489
+ /** Levels for selected domain(s) */
13376
13490
  var relevantLevels = useMemo(function () {
13377
- return getLevelsForDomainFilter(pickedDomainFilter);
13378
- }, [pickedDomainFilter]);
13379
- var _getFilterOptions = getFilterOptions(defaultLevelFilter, relevantLevels, pickedLevelFilter),
13380
- updatedPickedLevels = _getFilterOptions[0],
13491
+ return getLevelsForDomainFilter(savedDomainFilter);
13492
+ }, [savedDomainFilter]);
13493
+ var _getFilterOptions = getFilterOptions(savedLevelFilter, relevantLevels),
13494
+ pickedLevelFilter = _getFilterOptions[0],
13381
13495
  allLevelsSelected = _getFilterOptions[1];
13382
- // phenomenon
13496
+ /** Phenomena for selected domain(s) */
13383
13497
  var domainPhenomena = useMemo(function () {
13384
- return getPhenomenaForDomainFilter(pickedDomainFilter);
13385
- }, [pickedDomainFilter]);
13498
+ return getPhenomenaForDomainFilter(savedDomainFilter);
13499
+ }, [savedDomainFilter]);
13500
+ /** Phenomena in the warnings */
13386
13501
  var warningsPhenomena = useMemo(function () {
13387
13502
  return getFiltersFromWarnings(warnings, 'phenomenon');
13388
13503
  }, [warnings]);
@@ -13391,9 +13506,8 @@ var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, sa
13391
13506
  return warningsPhenomena.includes(phenomenon);
13392
13507
  });
13393
13508
  }, [warningsPhenomena, domainPhenomena]);
13394
- relevantPhenomena.push(emptyFilterId);
13395
- var _getFilterOptions2 = getFilterOptions(defaultPhenomenonFilter, relevantPhenomena, pickedPhenomenonFilter),
13396
- updatedPickedPhenomena = _getFilterOptions2[0],
13509
+ var _getFilterOptions2 = getFilterOptions(savedPhenomenonFilter, relevantPhenomena),
13510
+ pickedPhenomenaFilter = _getFilterOptions2[0],
13397
13511
  allPhenomenaSelected = _getFilterOptions2[1];
13398
13512
  // source
13399
13513
  var relevantSources = useMemo(function () {
@@ -13401,46 +13515,54 @@ var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, sa
13401
13515
  }, [warnings]);
13402
13516
  var defaultSourceFilter = useMemo(function () {
13403
13517
  return Object.fromEntries(relevantSources.map(function (key) {
13404
- return [key, true];
13518
+ var presetValue = presetFilterState == null ? void 0 : presetFilterState.source[key];
13519
+ return [key, presetValue === undefined ? true : presetValue];
13405
13520
  }));
13406
- }, [relevantSources]);
13407
- var _getFilterOptions3 = getFilterOptions(defaultSourceFilter, relevantSources, pickedSourceFilter),
13408
- updatedPickedSources = _getFilterOptions3[0],
13409
- allSourcesSelected = _getFilterOptions3[1];
13410
- // incident
13521
+ },
13522
+ // eslint-disable-next-line react-hooks/exhaustive-deps
13523
+ [relevantSources]);
13524
+ var _getSelectedOptions2 = getSelectedOptions(savedSourceFilter),
13525
+ allSourcesSelected = _getSelectedOptions2.allSelected;
13526
+ /** Incidents in the warnings */
13411
13527
  var relevantIncidents = useMemo(function () {
13412
13528
  return getFiltersFromWarnings(warnings, 'incident');
13413
13529
  }, [warnings]);
13530
+ /** FilterObject based on relevant incidents with values from the preset */
13414
13531
  var defaultIncidentFilter = useMemo(function () {
13415
13532
  return Object.fromEntries(relevantIncidents.map(function (key) {
13416
- return [key, true];
13533
+ var presetValue = presetFilterState == null ? void 0 : presetFilterState.incident[key];
13534
+ return [key, presetValue === undefined ? true : presetValue];
13417
13535
  }));
13418
- }, [relevantIncidents]);
13419
- var _getFilterOptions4 = getFilterOptions(defaultIncidentFilter, relevantIncidents, pickedIncidentFilter),
13420
- updatedPickedIncidents = _getFilterOptions4[0],
13421
- allIncidentsSelected = _getFilterOptions4[1];
13536
+ }, [relevantIncidents, presetFilterState == null ? void 0 : presetFilterState.incident]);
13537
+ var _getSelectedOptions3 = getSelectedOptions(savedIncidentFilter),
13538
+ allIncidentsSelected = _getSelectedOptions3.allSelected;
13539
+ var populatedIncidentAndSourceFilter = useMemo(function () {
13540
+ return {
13541
+ incident: defaultIncidentFilter,
13542
+ source: defaultSourceFilter
13543
+ };
13544
+ }, [defaultIncidentFilter, defaultSourceFilter]);
13545
+ var initialFiltersWithPresets = useMemo(function () {
13546
+ return {
13547
+ incident: defaultIncidentFilter || defaultEmptyFilter,
13548
+ source: defaultSourceFilter || defaultEmptyFilter,
13549
+ domain: Object.assign({}, initialFilters.domain, presetFilterState == null ? void 0 : presetFilterState.domain),
13550
+ phenomenon: Object.assign({}, initialFilters.phenomenon, presetFilterState == null ? void 0 : presetFilterState.phenomenon),
13551
+ level: Object.assign({}, initialFilters.level, presetFilterState == null ? void 0 : presetFilterState.level)
13552
+ };
13553
+ },
13554
+ // eslint-disable-next-line react-hooks/exhaustive-deps
13555
+ [presetFilterState]);
13556
+ useEffect(function () {
13557
+ onUpdateFilters(populatedIncidentAndSourceFilter, true);
13558
+ }, [populatedIncidentAndSourceFilter, onUpdateFilters]);
13422
13559
  useEffect(function () {
13423
13560
  // when the preset changes, update the filters
13424
- if (presetFilterState) {
13425
- var initialFiltersWithPresets = {
13426
- incident: Object.assign({}, makeFilterFromList(relevantIncidents), presetFilterState.incident),
13427
- source: Object.assign({}, makeFilterFromList(relevantSources), presetFilterState.source),
13428
- domain: Object.assign({}, initialFilters.domain, presetFilterState.domain),
13429
- phenomenon: Object.assign({}, initialFilters.phenomenon, presetFilterState.phenomenon),
13430
- level: Object.assign({}, initialFilters.level, presetFilterState.level)
13431
- };
13432
- onUpdateFilters(initialFiltersWithPresets, 'system');
13433
- } else {
13434
- // for a preset without filters saved use the initial filters
13435
- onUpdateFilters(Object.assign({}, initialFilters, {
13436
- incident: makeFilterFromList(relevantIncidents),
13437
- source: makeFilterFromList(relevantSources)
13438
- }), 'system');
13439
- }
13561
+ onUpdateFilters(initialFiltersWithPresets, true);
13440
13562
  // eslint-disable-next-line react-hooks/exhaustive-deps
13441
- }, [presetFilterState, onUpdateFilters]);
13442
- var _getSelectedOptions2 = getSelectedOptions(pickedDomainFilter),
13443
- allDomainSelected = _getSelectedOptions2.allSelected;
13563
+ }, [initialFiltersWithPresets, onUpdateFilters]);
13564
+ var _getSelectedOptions4 = getSelectedOptions(savedDomainFilter),
13565
+ allDomainSelected = _getSelectedOptions4.allSelected;
13444
13566
  var allSelected = allDomainSelected && allLevelsSelected && allPhenomenaSelected && allIncidentsSelected && allSourcesSelected;
13445
13567
  /**
13446
13568
  * @param filterKey - Name of the filter | "ALL" filters
@@ -13452,44 +13574,40 @@ var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, sa
13452
13574
  var levelFilter = value ? defaultLevelFilter : defaultEmptyFilter;
13453
13575
  if (filterKey === 'ALL') {
13454
13576
  onUpdateFilters({
13455
- domain: updateState(pickedDomainFilter, 'ALL', value),
13577
+ domain: updateState(savedDomainFilter, 'ALL', value),
13456
13578
  level: updateState(levelFilter, 'ALL', value),
13457
- phenomenon: updateState(pickedPhenomenonFilter, 'ALL', value),
13458
- incident: updateState(pickedIncidentFilter, 'ALL', value),
13459
- source: updateState(pickedSourceFilter, 'ALL', value)
13460
- }, 'user');
13579
+ phenomenon: updateState(savedPhenomenonFilter, 'ALL', value),
13580
+ incident: updateState(savedIncidentFilter, 'ALL', value),
13581
+ source: updateState(savedSourceFilter, 'ALL', value)
13582
+ });
13461
13583
  } else if (filterKey === 'domain') {
13462
- var newDomain = updateState(pickedDomainFilter, optionKey, value, only);
13463
- var _relevantLevels = getLevelsForDomainFilter(newDomain);
13464
- var _getFilterOptions5 = getFilterOptions(defaultLevelFilter, _relevantLevels, pickedLevelFilter),
13465
- newLevel = _getFilterOptions5[0];
13466
- onUpdateFilters(Object.assign({}, savedFilterState, {
13467
- domain: newDomain,
13468
- level: newLevel // levels depend on selected domains
13469
- }), 'user');
13584
+ var newDomain = updateState(savedDomainFilter, optionKey, value, only);
13585
+ onUpdateFilters({
13586
+ domain: newDomain
13587
+ });
13470
13588
  } else if (filterKey === 'level') {
13471
- onUpdateFilters(Object.assign({}, savedFilterState, {
13472
- level: updateState(pickedLevelFilter, optionKey, value, only)
13473
- }), 'user');
13589
+ onUpdateFilters({
13590
+ level: updateState(savedLevelFilter, optionKey, value, only)
13591
+ });
13474
13592
  } else if (filterKey === 'phenomenon') {
13475
- onUpdateFilters(Object.assign({}, savedFilterState, {
13476
- phenomenon: updateState(pickedPhenomenonFilter, optionKey, value, only)
13477
- }), 'user');
13593
+ onUpdateFilters({
13594
+ phenomenon: updateState(savedPhenomenonFilter, optionKey, value, only)
13595
+ });
13478
13596
  } else if (filterKey === 'source') {
13479
- onUpdateFilters(Object.assign({}, savedFilterState, {
13480
- source: updateState(pickedSourceFilter, optionKey, value, only)
13481
- }), 'user');
13597
+ onUpdateFilters({
13598
+ source: updateState(savedSourceFilter, optionKey, value, only)
13599
+ });
13482
13600
  } else if (filterKey === 'incident') {
13483
- onUpdateFilters(Object.assign({}, savedFilterState, {
13484
- incident: updateState(pickedIncidentFilter, optionKey, value, only)
13485
- }), 'user');
13601
+ onUpdateFilters({
13602
+ incident: updateState(savedIncidentFilter, optionKey, value, only)
13603
+ });
13486
13604
  }
13487
13605
  };
13488
13606
  var byFilterState = useCallback(function (warning) {
13489
- var levelDomain = ['SIG', 'AIR'].find(function (d) {
13490
- return d === warning.warningDetail.level;
13607
+ var levelDomain = ['SIG', 'AIR'].find(function (dom) {
13608
+ return dom === warning.warningDetail.level;
13491
13609
  }) ? Domain.aviation : Domain["public"];
13492
- if (!pickedDomainFilter[levelDomain]) {
13610
+ if (!savedDomainFilter[levelDomain]) {
13493
13611
  return false;
13494
13612
  }
13495
13613
  var level = getValue(Level, warning.warningDetail.level);
@@ -13497,37 +13615,115 @@ var useWarningFilters = function useWarningFilters(warnings, onUpdateFilters, sa
13497
13615
  return false;
13498
13616
  }
13499
13617
  var phenomenon = getValue(AllPhenomenaKeys, warning.warningDetail.phenomenon);
13500
- if (!pickedPhenomenonFilter[phenomenon]) {
13618
+ if (!pickedPhenomenaFilter[phenomenon]) {
13501
13619
  return false;
13502
13620
  }
13503
13621
  var source = relevantSources.find(function (source) {
13504
13622
  return source === warning.warningDetail.warningProposalSource;
13505
13623
  }) || emptyFilterId;
13506
- if (!updatedPickedSources[source]) {
13624
+ if (!savedSourceFilter[source]) {
13507
13625
  return false;
13508
13626
  }
13509
13627
  var incident = relevantIncidents.find(function (incident) {
13510
13628
  return incident === warning.warningDetail.incident;
13511
13629
  }) || emptyFilterId;
13512
- if (!updatedPickedIncidents[incident]) {
13630
+ if (!savedIncidentFilter[incident]) {
13513
13631
  return false;
13514
13632
  }
13515
13633
  return true;
13516
- }, [pickedDomainFilter, pickedLevelFilter, pickedPhenomenonFilter, relevantSources, updatedPickedSources, relevantIncidents, updatedPickedIncidents]);
13634
+ }, [savedDomainFilter, pickedLevelFilter, pickedPhenomenaFilter, relevantSources, savedSourceFilter, relevantIncidents, savedIncidentFilter]);
13517
13635
  return {
13518
13636
  allSelected: allSelected,
13519
13637
  updateFilter: updateFilter,
13520
13638
  byFilterState: byFilterState,
13521
13639
  filterState: {
13522
- domain: pickedDomainFilter,
13523
- level: updatedPickedLevels,
13524
- phenomenon: updatedPickedPhenomena,
13525
- incident: updatedPickedIncidents,
13526
- source: updatedPickedSources
13640
+ domain: savedDomainFilter,
13641
+ level: pickedLevelFilter,
13642
+ phenomenon: pickedPhenomenaFilter,
13643
+ incident: savedIncidentFilter,
13644
+ source: savedSourceFilter
13527
13645
  }
13528
13646
  };
13529
13647
  };
13530
13648
 
13649
+ var ConfirmDeleteWarningDialog = function ConfirmDeleteWarningDialog(_ref) {
13650
+ var _ref$onClose = _ref.onClose,
13651
+ onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose,
13652
+ title = _ref.title,
13653
+ description = _ref.description,
13654
+ request = _ref.request,
13655
+ confirmLabel = _ref.confirmLabel,
13656
+ callback = _ref.callback,
13657
+ isLocked = _ref.isLocked;
13658
+ var _useWarningsTranslati = useWarningsTranslation(),
13659
+ t = _useWarningsTranslati.t;
13660
+ var defaultError = isLocked ? t('warning-dialog-delete-islocked') : undefined;
13661
+ var _React$useState = React__default.useState(false),
13662
+ isLoading = _React$useState[0],
13663
+ setIsLoading = _React$useState[1];
13664
+ var _React$useState2 = React__default.useState(defaultError),
13665
+ error = _React$useState2[0],
13666
+ setError = _React$useState2[1];
13667
+ var onSubmit = /*#__PURE__*/function () {
13668
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
13669
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
13670
+ while (1) switch (_context.prev = _context.next) {
13671
+ case 0:
13672
+ setIsLoading(true);
13673
+ _context.prev = 1;
13674
+ _context.next = 4;
13675
+ return request();
13676
+ case 4:
13677
+ callback();
13678
+ setIsLoading(false);
13679
+ _context.next = 12;
13680
+ break;
13681
+ case 8:
13682
+ _context.prev = 8;
13683
+ _context.t0 = _context["catch"](1);
13684
+ setError(getAxiosErrorMessage(_context.t0));
13685
+ setIsLoading(false);
13686
+ case 12:
13687
+ case "end":
13688
+ return _context.stop();
13689
+ }
13690
+ }, _callee, null, [[1, 8]]);
13691
+ }));
13692
+ return function onSubmit() {
13693
+ return _ref2.apply(this, arguments);
13694
+ };
13695
+ }();
13696
+ return jsx(ConfirmationDialog, Object.assign({
13697
+ title: title,
13698
+ open: true,
13699
+ confirmLabel: confirmLabel,
13700
+ cancelLabel: t('warning-dialog-cancel'),
13701
+ description: !error ? description : '',
13702
+ onClose: onClose,
13703
+ onSubmit: onSubmit,
13704
+ isLoading: isLoading,
13705
+ sx: {
13706
+ width: 330
13707
+ }
13708
+ }, error && {
13709
+ content: jsxs(Box, {
13710
+ sx: {
13711
+ marginBottom: 0
13712
+ },
13713
+ children: [jsx(AlertBanner, {
13714
+ title: error,
13715
+ severity: isLocked ? 'warning' : 'error'
13716
+ }), jsx(Typography, {
13717
+ variant: "body1",
13718
+ sx: {
13719
+ marginTop: 1
13720
+ },
13721
+ children: description
13722
+ })]
13723
+ })
13724
+ }));
13725
+ };
13726
+
13531
13727
  var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
13532
13728
  var panelId = _ref.panelId,
13533
13729
  presetFilterState = _ref.presetFilterState;
@@ -13763,11 +13959,14 @@ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
13763
13959
  openSnackbar(snackbarMessage);
13764
13960
  refetchWarnings();
13765
13961
  };
13766
- var onUpdateFilters = React__default.useCallback(function (filterState, origin) {
13962
+ var onUpdateFilters = React__default.useCallback(function (filterState, systemUpdate) {
13963
+ if (systemUpdate === void 0) {
13964
+ systemUpdate = false;
13965
+ }
13767
13966
  dispatch(publicWarningActions.setWarningFilters({
13768
13967
  filterState: filterState,
13769
13968
  panelId: panelId,
13770
- origin: origin
13969
+ systemUpdate: systemUpdate
13771
13970
  }));
13772
13971
  }, [dispatch, panelId]);
13773
13972
  var filterHookState = useWarningFilters(combinedWarnings, onUpdateFilters, savedFilterState, presetFilterState);
@@ -13895,52 +14094,28 @@ var componentsLookUp = function componentsLookUp(payload, apiProps) {
13895
14094
  }
13896
14095
  };
13897
14096
 
13898
- var getErrorMessage = function getErrorMessage(error) {
13899
- return isAxiosError(error) ? getAxiosErrorMessage(error) : error.message;
13900
- };
13901
14097
  var publicWarningFormListener = createListenerMiddleware();
13902
14098
  publicWarningFormListener.startListening({
13903
- actionCreator: publicWarningFormActions.publishWarning,
14099
+ actionCreator: publicWarningFormActions.openPublicWarningFormDialog,
13904
14100
  effect: function () {
13905
14101
  var _effect = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref, listenerApi) {
13906
- var payload, publicWarning, refetchWarnings, publishedWarning, isDialogOpen;
14102
+ var payload, panelId;
13907
14103
  return _regeneratorRuntime().wrap(function _callee$(_context) {
13908
14104
  while (1) switch (_context.prev = _context.next) {
13909
14105
  case 0:
13910
14106
  payload = _ref.payload;
13911
14107
  listenerApi.cancelActiveListeners();
13912
- _context.prev = 2;
13913
- publicWarning = payload.publicWarning, refetchWarnings = payload.refetchWarnings;
13914
- _context.next = 6;
13915
- return saveOrUpdateWarning(publicWarning);
13916
- case 6:
13917
- publishedWarning = _context.sent;
13918
- if (refetchWarnings) {
13919
- refetchWarnings();
13920
- }
13921
- listenerApi.dispatch(publicWarningFormActions.publishWarningSuccess({
13922
- publicWarning: publishedWarning,
13923
- message: {
13924
- type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
13925
- key: 'warning-publish-succes'
13926
- }
13927
- }));
14108
+ panelId = payload.panelId;
13928
14109
  listenerApi.dispatch(uiActions.setToggleOpenDialog({
14110
+ setOpen: true,
13929
14111
  type: publicWarningDialogType,
13930
- setOpen: false
14112
+ sourcePanelId: panelId
13931
14113
  }));
13932
- _context.next = 16;
13933
- break;
13934
- case 12:
13935
- _context.prev = 12;
13936
- _context.t0 = _context["catch"](2);
13937
- isDialogOpen = uiSelectors.getisDialogOpen(listenerApi.getState(), publicWarningDialogType);
13938
- errorEffect(listenerApi.dispatch, getErrorMessage(_context.t0), isDialogOpen);
13939
- case 16:
14114
+ case 4:
13940
14115
  case "end":
13941
14116
  return _context.stop();
13942
14117
  }
13943
- }, _callee, null, [[2, 12]]);
14118
+ }, _callee);
13944
14119
  }));
13945
14120
  function effect(_x, _x2) {
13946
14121
  return _effect.apply(this, arguments);
@@ -13949,201 +14124,14 @@ publicWarningFormListener.startListening({
13949
14124
  }()
13950
14125
  });
13951
14126
  publicWarningFormListener.startListening({
13952
- actionCreator: publicWarningFormActions.saveWarning,
14127
+ actionCreator: uiActions.setToggleOpenDialog,
13953
14128
  effect: function () {
13954
14129
  var _effect2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2, listenerApi) {
13955
- var payload, publicWarning, refetchWarnings, savedWarning, isDialogOpen;
14130
+ var payload;
13956
14131
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
13957
14132
  while (1) switch (_context2.prev = _context2.next) {
13958
14133
  case 0:
13959
14134
  payload = _ref2.payload;
13960
- listenerApi.cancelActiveListeners();
13961
- _context2.prev = 2;
13962
- publicWarning = payload.publicWarning, refetchWarnings = payload.refetchWarnings;
13963
- _context2.next = 6;
13964
- return saveOrUpdateWarning(publicWarning);
13965
- case 6:
13966
- savedWarning = _context2.sent;
13967
- if (refetchWarnings) {
13968
- refetchWarnings();
13969
- }
13970
- listenerApi.dispatch(publicWarningFormActions.saveWarningSuccess({
13971
- publicWarning: savedWarning,
13972
- message: {
13973
- type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
13974
- key: 'warning-save-succes'
13975
- }
13976
- }));
13977
- _context2.next = 15;
13978
- break;
13979
- case 11:
13980
- _context2.prev = 11;
13981
- _context2.t0 = _context2["catch"](2);
13982
- isDialogOpen = uiSelectors.getisDialogOpen(listenerApi.getState(), publicWarningDialogType);
13983
- errorEffect(listenerApi.dispatch, getErrorMessage(_context2.t0), isDialogOpen);
13984
- case 15:
13985
- case "end":
13986
- return _context2.stop();
13987
- }
13988
- }, _callee2, null, [[2, 11]]);
13989
- }));
13990
- function effect(_x3, _x4) {
13991
- return _effect2.apply(this, arguments);
13992
- }
13993
- return effect;
13994
- }()
13995
- });
13996
- // Side effects/snackbar listeners
13997
- publicWarningFormListener.startListening({
13998
- matcher: isAnyOf(publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess),
13999
- effect: function () {
14000
- var _effect3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3, listenerApi) {
14001
- var payload, message, isDialogOpen;
14002
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
14003
- while (1) switch (_context3.prev = _context3.next) {
14004
- case 0:
14005
- payload = _ref3.payload;
14006
- listenerApi.cancelActiveListeners();
14007
- message = payload.message;
14008
- listenerApi.dispatch(snackbarActions.openSnackbar(message));
14009
- isDialogOpen = uiSelectors.getisDialogOpen(listenerApi.getState(), publicWarningDialogType);
14010
- toggleDialogLoadingEffect(listenerApi.dispatch, isDialogOpen, false);
14011
- case 6:
14012
- case "end":
14013
- return _context3.stop();
14014
- }
14015
- }, _callee3);
14016
- }));
14017
- function effect(_x5, _x6) {
14018
- return _effect3.apply(this, arguments);
14019
- }
14020
- return effect;
14021
- }()
14022
- });
14023
- publicWarningFormListener.startListening({
14024
- matcher: isAnyOf(publicWarningFormActions.publishWarning, publicWarningFormActions.saveWarning),
14025
- effect: function () {
14026
- var _effect4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_, listenerApi) {
14027
- var isDialogOpen;
14028
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
14029
- while (1) switch (_context4.prev = _context4.next) {
14030
- case 0:
14031
- listenerApi.cancelActiveListeners();
14032
- isDialogOpen = uiSelectors.getisDialogOpen(listenerApi.getState(), publicWarningDialogType);
14033
- toggleDialogLoadingEffect(listenerApi.dispatch, isDialogOpen, true);
14034
- case 3:
14035
- case "end":
14036
- return _context4.stop();
14037
- }
14038
- }, _callee4);
14039
- }));
14040
- function effect(_x7, _x8) {
14041
- return _effect4.apply(this, arguments);
14042
- }
14043
- return effect;
14044
- }()
14045
- });
14046
- publicWarningFormListener.startListening({
14047
- actionCreator: publicWarningFormActions.openPublicWarningFormDialog,
14048
- effect: function () {
14049
- var _effect5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref4, listenerApi) {
14050
- var payload, panelId;
14051
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
14052
- while (1) switch (_context5.prev = _context5.next) {
14053
- case 0:
14054
- payload = _ref4.payload;
14055
- listenerApi.cancelActiveListeners();
14056
- panelId = payload.panelId;
14057
- listenerApi.dispatch(uiActions.setToggleOpenDialog({
14058
- setOpen: true,
14059
- type: publicWarningDialogType,
14060
- sourcePanelId: panelId
14061
- }));
14062
- case 4:
14063
- case "end":
14064
- return _context5.stop();
14065
- }
14066
- }, _callee5);
14067
- }));
14068
- function effect(_x9, _x10) {
14069
- return _effect5.apply(this, arguments);
14070
- }
14071
- return effect;
14072
- }()
14073
- });
14074
- var saveOrUpdateWarning = /*#__PURE__*/function () {
14075
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(publicWarning) {
14076
- var warningsApi, warningDetail, status, warning, newWarningId;
14077
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
14078
- while (1) switch (_context6.prev = _context6.next) {
14079
- case 0:
14080
- warningsApi = getWarningsApi();
14081
- warningDetail = publicWarning.warningDetail, status = publicWarning.status;
14082
- if (!warningDetail.id) {
14083
- _context6.next = 6;
14084
- break;
14085
- }
14086
- _context6.next = 5;
14087
- return warningsApi.updateWarning(warningDetail.id, publicWarning);
14088
- case 5:
14089
- return _context6.abrupt("return", publicWarning);
14090
- case 6:
14091
- if (!(status === 'PUBLISHED' && warningDetail.linked_to_id)) {
14092
- _context6.next = 11;
14093
- break;
14094
- }
14095
- warning = Object.assign({}, publicWarning, {
14096
- warningDetail: Object.assign({}, warningDetail, {
14097
- id: warningDetail.linked_to_id
14098
- })
14099
- });
14100
- _context6.next = 10;
14101
- return warningsApi.updateWarning(warningDetail.linked_to_id, warning);
14102
- case 10:
14103
- return _context6.abrupt("return", warning);
14104
- case 11:
14105
- _context6.next = 13;
14106
- return warningsApi.saveWarningAs(publicWarning);
14107
- case 13:
14108
- newWarningId = _context6.sent;
14109
- return _context6.abrupt("return", Object.assign({}, publicWarning, {
14110
- warningDetail: Object.assign({}, warningDetail, {
14111
- id: newWarningId
14112
- })
14113
- }));
14114
- case 15:
14115
- case "end":
14116
- return _context6.stop();
14117
- }
14118
- }, _callee6);
14119
- }));
14120
- return function saveOrUpdateWarning(_x11) {
14121
- return _ref5.apply(this, arguments);
14122
- };
14123
- }();
14124
- var toggleDialogLoadingEffect = function toggleDialogLoadingEffect(dispatch, isDialogOpen, isLoading) {
14125
- if (isDialogOpen) {
14126
- dispatch(uiActions.toggleIsLoadingDialog({
14127
- isLoading: isLoading,
14128
- type: publicWarningDialogType
14129
- }));
14130
- }
14131
- };
14132
- var errorEffect = function errorEffect(dispatch, message, isDialogOpen) {
14133
- dispatch(publicWarningFormActions.setFormError({
14134
- message: message
14135
- }));
14136
- toggleDialogLoadingEffect(dispatch, isDialogOpen, false);
14137
- };
14138
- publicWarningFormListener.startListening({
14139
- actionCreator: uiActions.setToggleOpenDialog,
14140
- effect: function () {
14141
- var _effect6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref6, listenerApi) {
14142
- var payload;
14143
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
14144
- while (1) switch (_context7.prev = _context7.next) {
14145
- case 0:
14146
- payload = _ref6.payload;
14147
14135
  if (!payload.setOpen && payload.type === publicWarningDialogType) {
14148
14136
  listenerApi.dispatch(uiActions.setToggleOpenDialog({
14149
14137
  setOpen: false,
@@ -14152,12 +14140,12 @@ publicWarningFormListener.startListening({
14152
14140
  }
14153
14141
  case 2:
14154
14142
  case "end":
14155
- return _context7.stop();
14143
+ return _context2.stop();
14156
14144
  }
14157
- }, _callee7);
14145
+ }, _callee2);
14158
14146
  }));
14159
- function effect(_x12, _x13) {
14160
- return _effect6.apply(this, arguments);
14147
+ function effect(_x3, _x4) {
14148
+ return _effect2.apply(this, arguments);
14161
14149
  }
14162
14150
  return effect;
14163
14151
  }()
@@ -14231,7 +14219,7 @@ warningsDrawingsListener.startListening({
14231
14219
  isLoading: false,
14232
14220
  type: drawingDialogType
14233
14221
  }));
14234
- errorMessage = isAxiosError$1(taskError) ? getAxiosErrorMessage(taskError) : taskError.message;
14222
+ errorMessage = isAxiosError(taskError) ? getAxiosErrorMessage(taskError) : taskError.message;
14235
14223
  listenerApi.dispatch(uiActions.setErrorDialog({
14236
14224
  type: drawingDialogType,
14237
14225
  error: errorMessage