@opengeoweb/warnings 9.34.0 → 9.35.1-spike-oltanstack.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  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, Close, Options, ChevronDown, ChevronUp, Copy, Success, Expire, Remove, ArrowUpCompact, ArrowDownCompact } from '@opengeoweb/theme';
4
- import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawtoolActions, mapStoreActions, layerActions, useSetupDialog } from '@opengeoweb/store';
4
+ import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawtoolActions, mapStoreActions, layerActions, useSetupDialog, selectorMemoizationOptions, useUpdateSharedData } from '@opengeoweb/store';
5
5
  import { defaultPolygon, emptyGeoJSON, MapControlButton, getIcon, rewindGeometry, getGeoJSONPropertyValue, currentlySupportedDrawModes, defaultLayers, MapView, MapViewLayer, getFeatureExtent } from '@opengeoweb/webmap-react';
6
6
  import { SHARED_NAMESPACE, useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, CustomToggleButton, Filter, getPosition, FilterChip, FilterListItem, FilterLabel, FilterOption, StatusTag, LastUpdateTime, ErrorBoundary, pollingIntervalTimeout, isAxiosError as isAxiosError$1 } from '@opengeoweb/shared';
7
7
  import { createEntityAdapter, createSlice, createSelector, createListenerMiddleware, isAnyOf } from '@reduxjs/toolkit';
@@ -18,10 +18,11 @@ import { VariableSizeList } from 'react-window';
18
18
  import AutoSizer from 'react-virtualized-auto-sizer';
19
19
  import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInstance, ApiProvider, getHeaders, useAuthQuery, useAuthenticationContext, ProductStatus } from '@opengeoweb/api';
20
20
  import { useFormContext } from 'react-hook-form';
21
- import { isEqual, cloneDeep, clamp, pick, groupBy } from 'lodash';
21
+ import { isEqual, cloneDeep, clamp, groupBy, pick } from 'lodash';
22
22
  import { getConfig, useAuthenticationContext as useAuthenticationContext$1 } from '@opengeoweb/authentication';
23
23
  import { SigmetForm, isInstanceOfCancelSigmet, AirmetForm, isInstanceOfCancelAirmet, getProductFormMode } from '@opengeoweb/sigmet-airmet';
24
24
  import { produce } from 'immer';
25
+ import { useQueryClient } from '@tanstack/react-query';
25
26
  import { isAxiosError } from 'axios';
26
27
 
27
28
  var en = {
@@ -56,7 +57,7 @@ var en = {
56
57
  "object-manager-object-selected": "object selected",
57
58
  "object-manager-share-menu": "Share object to",
58
59
  "public-warning-title": "Public Warning",
59
- "close-warning-dialog-title": "Close Public warning",
60
+ "close-warning-dialog-title": "Close warning",
60
61
  "warning-edit-mode-title": "Switch to edit mode",
61
62
  "warning-edit-mode-description": "This warning is already in edit mode by another user and important information could get lost in the switching process.",
62
63
  "warning-dialog-cancel": "Go back",
@@ -233,7 +234,7 @@ var nl = {
233
234
  "object-manager-object-selected": "object geselecteerd",
234
235
  "object-manager-share-menu": "Object delen naar",
235
236
  "public-warning-title": "Publieke Waarschuwing",
236
- "close-warning-dialog-title": "Publieke waarschuwing sluiten",
237
+ "close-warning-dialog-title": "Waarschuwing sluiten",
237
238
  "warning-edit-mode-title": "Wissel naar bewerken",
238
239
  "warning-edit-mode-description": "Deze waarschuwing wordt al bewerkt door een andere gebruiker en belangrijke informatie kan verloren gaan.",
239
240
  "warning-dialog-cancel": "Ga terug",
@@ -371,7 +372,7 @@ var fi = {
371
372
  "object-manager-object-selected": "objekti valittuna",
372
373
  "object-manager-share-menu": "Jaa objekti",
373
374
  "public-warning-title": "Julkiset varoitukset",
374
- "close-warning-dialog-title": "Sulje julkiset varoitukset",
375
+ "close-warning-dialog-title": "Sulje varoitukset",
375
376
  "warning-edit-mode-title": "Vaihda editointitilaan",
376
377
  "warning-edit-mode-description": "Tämä varoitus on jo editointitilassa toisen käyttäjän toimesta. Tärkeää tietoa saatetaan menettää, jos editointitilaa vaihdetaan.",
377
378
  "warning-dialog-cancel": "Palaa takaisin",
@@ -2392,11 +2393,14 @@ var slice = createSlice({
2392
2393
  object = _action$payload2.object,
2393
2394
  publicWarning = _action$payload2.publicWarning,
2394
2395
  _action$payload2$form = _action$payload2.formState,
2395
- formState = _action$payload2$form === void 0 ? '' : _action$payload2$form;
2396
+ formState = _action$payload2$form === void 0 ? '' : _action$payload2$form,
2397
+ _action$payload2$warn = _action$payload2.warningType,
2398
+ warningType = _action$payload2$warn === void 0 ? 'public' : _action$payload2$warn;
2396
2399
  draft.object = object;
2397
2400
  draft.publicWarning = publicWarning;
2398
2401
  draft.selectedPublicWarningId = publicWarning == null ? void 0 : publicWarning.id;
2399
2402
  draft.formState = formState;
2403
+ draft.warningType = warningType;
2400
2404
  },
2401
2405
  toggleEditorWarning: function toggleEditorWarning(draft,
2402
2406
  // eslint-disable-next-line no-unused-vars
@@ -2470,6 +2474,7 @@ var slice = createSlice({
2470
2474
  delete draft.error;
2471
2475
  delete draft.selectedPublicWarningId;
2472
2476
  delete draft.isFormDirty;
2477
+ delete draft.warningType;
2473
2478
  }
2474
2479
  }).addCase(publicWarningActions.fetchWarningsSuccess, function (draft, action) {
2475
2480
  var warnings = action.payload.warnings;
@@ -6949,6 +6954,7 @@ var warningListJSON = [
6949
6954
  lastUpdatedTime: "2023-12-05T16:47:43Z",
6950
6955
  status: "WITHDRAWN",
6951
6956
  warningDetail: {
6957
+ id: "3f756602-937d-11ee-a1bf-4k3k3k",
6952
6958
  phenomenon: "thunderstorm",
6953
6959
  areas: [
6954
6960
  {
@@ -7005,6 +7011,7 @@ var warningListJSON = [
7005
7011
  lastUpdatedTime: "2023-12-05T14:48:04Z",
7006
7012
  status: "EXPIRED",
7007
7013
  warningDetail: {
7014
+ id: "4b94edb8-937d-11ee-b619-0ab3cf8a98c1",
7008
7015
  phenomenon: "snowIce",
7009
7016
  areas: [
7010
7017
  {
@@ -7061,6 +7068,7 @@ var warningListJSON = [
7061
7068
  lastUpdatedTime: "2023-12-05T14:47:43Z",
7062
7069
  status: "EXPIRED",
7063
7070
  warningDetail: {
7071
+ id: "3f756602-937d-11ee-a1bf-0ab3cf8a98c1",
7064
7072
  phenomenon: "thunderstorm",
7065
7073
  areas: [
7066
7074
  {
@@ -7114,6 +7122,204 @@ var warningListJSON = [
7114
7122
  }
7115
7123
  ];
7116
7124
 
7125
+ var sigmetListJSON = [
7126
+ {
7127
+ id: "57eaf6c8-a247-11ef-ac05-12e0cc025418",
7128
+ lastUpdatedTime: "2024-11-14T05:14:37",
7129
+ productStatus: "DRAFT",
7130
+ warningDetail: {
7131
+ areas: [
7132
+ {
7133
+ geoJSON: {
7134
+ features: [
7135
+ {
7136
+ geometry: {
7137
+ type: "Polygon",
7138
+ coordinates: [
7139
+ [
7140
+ [
7141
+ 10,
7142
+ 20
7143
+ ],
7144
+ [
7145
+ 15,
7146
+ 25
7147
+ ],
7148
+ [
7149
+ 20,
7150
+ 20
7151
+ ],
7152
+ [
7153
+ 10,
7154
+ 20
7155
+ ]
7156
+ ]
7157
+ ]
7158
+ },
7159
+ properties: {
7160
+ selectionType: "fir",
7161
+ stroke: "#0075a9",
7162
+ "stroke-width": 1.5,
7163
+ "stroke-opacity": 1,
7164
+ fill: "#0075a9",
7165
+ "fill-opacity": 0.4
7166
+ },
7167
+ type: "Feature"
7168
+ }
7169
+ ],
7170
+ type: "FeatureCollection"
7171
+ },
7172
+ objectName: "ENOB"
7173
+ }
7174
+ ],
7175
+ descriptionOriginal: "",
7176
+ descriptionTranslation: "",
7177
+ firName: "BODOE OCEANIC FIR",
7178
+ incident: "-1",
7179
+ level: "SIG",
7180
+ phenomenon: "EMBD_TSGR",
7181
+ probability: "0",
7182
+ validFrom: "2024-11-14T05:30:14Z",
7183
+ validUntil: "2024-11-14T07:30:14Z"
7184
+ }
7185
+ },
7186
+ {
7187
+ id: "fc4c0002-8d32-11ef-888b-ee87a1644661",
7188
+ lastUpdatedTime: "2024-11-14T05:14:06",
7189
+ productStatus: "EXPIRED",
7190
+ warningDetail: {
7191
+ areas: [
7192
+ {
7193
+ geoJSON: null,
7194
+ objectName: "EFIN"
7195
+ }
7196
+ ],
7197
+ descriptionOriginal: "",
7198
+ descriptionTranslation: "",
7199
+ firName: "HELSINKI FIR",
7200
+ incident: "T01",
7201
+ level: "SIG",
7202
+ phenomenon: "OBSC_TS",
7203
+ probability: "0",
7204
+ validFrom: "2024-11-13T05:30:14Z",
7205
+ validUntil: "2024-11-13T07:30:14Z"
7206
+ }
7207
+ },
7208
+ {
7209
+ id: "fe4a14bc-8a90-11ef-9090-6c08d8abf452",
7210
+ lastUpdatedTime: "2024-10-08T08:10:30",
7211
+ productStatus: "PUBLISHED",
7212
+ warningDetail: {
7213
+ areas: [
7214
+ {
7215
+ geoJSON: null,
7216
+ objectName: "EHAA"
7217
+ }
7218
+ ],
7219
+ descriptionOriginal: "",
7220
+ descriptionTranslation: "",
7221
+ firName: "AMSTERDAM FIR",
7222
+ incident: "Z01",
7223
+ level: "SIG",
7224
+ phenomenon: "SEV_ICE",
7225
+ probability: "0",
7226
+ validFrom: "2024-10-08T05:30:14Z",
7227
+ validUntil: "2024-10-08T09:30:14Z"
7228
+ }
7229
+ }
7230
+ ];
7231
+
7232
+ var airmetListJSON = [
7233
+ {
7234
+ id: "02d3727a-b190-11ef-ba31-067f7750936d",
7235
+ lastUpdatedTime: "2024-12-03T16:02:35",
7236
+ productStatus: "DRAFT",
7237
+ warningDetail: {
7238
+ areas: [
7239
+ {
7240
+ geoJSON: null,
7241
+ objectName: "EHAA"
7242
+ }
7243
+ ],
7244
+ descriptionOriginal: "",
7245
+ descriptionTranslation: "",
7246
+ firName: "AMSTERDAM FIR",
7247
+ incident: "-1",
7248
+ level: "AIR",
7249
+ phenomenon: "SFC_WIND",
7250
+ probability: "0",
7251
+ validFrom: "2024-12-03T17:00:09Z",
7252
+ validUntil: "2024-12-03T21:00:09Z"
7253
+ }
7254
+ },
7255
+ {
7256
+ id: "1a868884-9076-11ef-8e82-5a063b90cdf6",
7257
+ lastUpdatedTime: "2024-10-22T13:03:56",
7258
+ productStatus: "DRAFT",
7259
+ warningDetail: {
7260
+ areas: [
7261
+ {
7262
+ geoJSON: null,
7263
+ objectName: "EHAA"
7264
+ }
7265
+ ],
7266
+ descriptionOriginal: "",
7267
+ descriptionTranslation: "",
7268
+ firName: "AMSTERDAM FIR",
7269
+ incident: "-1",
7270
+ level: "AIR",
7271
+ phenomenon: "MOD_TURB",
7272
+ probability: "0",
7273
+ validFrom: "2024-10-22T15:00:09Z",
7274
+ validUntil: "2024-10-22T18:00:09Z"
7275
+ }
7276
+ },
7277
+ {
7278
+ id: "4ac7fc94-c670-11ee-8ace-92491e683685",
7279
+ lastUpdatedTime: "2024-02-08T12:26:31.803468",
7280
+ productStatus: "EXPIRED",
7281
+ warningDetail: {
7282
+ areas: [
7283
+ {
7284
+ geoJSON: null,
7285
+ objectName: "ENOR"
7286
+ }
7287
+ ],
7288
+ descriptionOriginal: "",
7289
+ descriptionTranslation: "",
7290
+ firName: "POLARIS FIR",
7291
+ incident: "T01",
7292
+ level: "AIR",
7293
+ phenomenon: "OBSC_TS",
7294
+ probability: "0",
7295
+ validFrom: "2024-02-08T09:00:09Z",
7296
+ validUntil: "2024-02-08T11:00:09Z"
7297
+ }
7298
+ },
7299
+ {
7300
+ id: "9dbcd4c6-c4c0-11ee-a0e9-9e39e246af14",
7301
+ lastUpdatedTime: "2024-02-06T07:15:18.166785",
7302
+ productStatus: "PUBLISHED",
7303
+ warningDetail: {
7304
+ areas: [
7305
+ {
7306
+ geoJSON: null,
7307
+ objectName: "EHAA"
7308
+ }
7309
+ ],
7310
+ descriptionOriginal: "",
7311
+ descriptionTranslation: "",
7312
+ firName: "AMSTERDAM FIR",
7313
+ incident: "Z01",
7314
+ level: "AIR",
7315
+ phenomenon: "SEV_ICE",
7316
+ probability: "0",
7317
+ validFrom: "2024-02-06T08:00:09Z",
7318
+ validUntil: "2024-02-06T12:00:09Z"
7319
+ }
7320
+ }
7321
+ ];
7322
+
7117
7323
  /* *
7118
7324
  * Licensed under the Apache License, Version 2.0 (the "License");
7119
7325
  * you may not use this file except in compliance with the License.
@@ -7134,6 +7340,8 @@ var warningListJSON = [
7134
7340
  var drawingList = drawingListJSON;
7135
7341
  var drawingsListFullContent = drawingsListFullContentJSON;
7136
7342
  var warningList = warningListJSON;
7343
+ var sigmetList = sigmetListJSON;
7344
+ var airmetList = airmetListJSON;
7137
7345
  var areaKeywordList = ['North Sea districts', 'Coastal Districts', 'KNMI Specific', 'Objects', 'Baltic areas', 'NL', 'FI', 'METNorway Specific', 'Provinces', 'FIR', 'Countries'];
7138
7346
 
7139
7347
  /* *
@@ -7234,7 +7442,7 @@ var getApiRoutes = function getApiRoutes(axiosInstance) {
7234
7442
  getWarnings: function getWarnings() {
7235
7443
  return axiosInstance.get("/warnings/").then(function () {
7236
7444
  return {
7237
- data: warningList
7445
+ data: warningList.concat(sigmetList, airmetList)
7238
7446
  };
7239
7447
  });
7240
7448
  },
@@ -7978,7 +8186,8 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
7978
8186
  shouldHideFormMode = _ref$shouldHideFormMo === void 0 ? false : _ref$shouldHideFormMo,
7979
8187
  publicWarningEditor = _ref.publicWarningEditor,
7980
8188
  selectedAviationProduct = _ref.selectedAviationProduct,
7981
- warningType = _ref.warningType;
8189
+ _ref$warningType = _ref.warningType,
8190
+ warningType = _ref$warningType === void 0 ? 'public' : _ref$warningType;
7982
8191
  var _useWarningsTranslati = useWarningsTranslation(),
7983
8192
  t = _useWarningsTranslati.t;
7984
8193
  var minSize = selectedAviationProduct ? {
@@ -8607,7 +8816,7 @@ var Phenomenon$1 = function Phenomenon(_ref) {
8607
8816
  isRequired = _useDraftFormHelpers.isRequired;
8608
8817
  // These phenomena are sent to Public Warning Form
8609
8818
  var warningFormPhenomena = warningPhenomena.filter(function (phenomenon) {
8610
- return !phenomenon.isAviation;
8819
+ return !phenomenon.isAviation && phenomenon.key !== 'unspecified';
8611
8820
  });
8612
8821
  return jsx(ReactHookFormSelect, {
8613
8822
  name: "phenomenon",
@@ -9111,17 +9320,51 @@ var getSigmetTAC = function getSigmetTAC(auth, product) {
9111
9320
  * Copyright 2024 - Finnish Meteorological Institute (FMI)
9112
9321
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
9113
9322
  * */
9114
- var useAirmetList = function useAirmetList() {
9115
- return useAuthQuery(['airmet-list'], getAirmetList);
9323
+ var useAirmetList = function useAirmetList(disabled) {
9324
+ if (disabled === void 0) {
9325
+ disabled = false;
9326
+ }
9327
+ return useAuthQuery(['airmet-list'], getAirmetList, disabled);
9116
9328
  };
9117
- var useSigmetList = function useSigmetList() {
9118
- return useAuthQuery(['sigmet-list'], getSigmetList);
9329
+ var useSigmetList = function useSigmetList(disabled) {
9330
+ if (disabled === void 0) {
9331
+ disabled = false;
9332
+ }
9333
+ return useAuthQuery(['sigmet-list'], getSigmetList, disabled);
9119
9334
  };
9120
- var useProductConfig = function useProductConfig(warningType) {
9121
- var airmetQuery = useAuthQuery(['airmet-config'], getAirmetConfig);
9122
- var sigmetQuery = useAuthQuery(['sigmet-config'], getSigmetConfig);
9335
+ var useProductConfig = function useProductConfig(warningType, disabled) {
9336
+ if (disabled === void 0) {
9337
+ disabled = false;
9338
+ }
9339
+ var airmetQuery = useAuthQuery(['airmet-config'], getAirmetConfig, disabled);
9340
+ var sigmetQuery = useAuthQuery(['sigmet-config'], getSigmetConfig, disabled);
9123
9341
  return warningType === 'airmet' ? airmetQuery : sigmetQuery;
9124
9342
  };
9343
+ var useTACApi = function useTACApi() {
9344
+ var _useAuthenticationCon = useAuthenticationContext(),
9345
+ auth = _useAuthenticationCon.auth;
9346
+ var queryClient = useQueryClient();
9347
+ var fetchSigmetTAC = function fetchSigmetTAC(product) {
9348
+ return queryClient.fetchQuery({
9349
+ queryKey: ['sigmet-tac', product],
9350
+ queryFn: function queryFn() {
9351
+ return getSigmetTAC(auth, product);
9352
+ }
9353
+ });
9354
+ };
9355
+ var fetchAirmetTAC = function fetchAirmetTAC(product) {
9356
+ return queryClient.fetchQuery({
9357
+ queryKey: ['airmet-tac', product],
9358
+ queryFn: function queryFn() {
9359
+ return getAirmetTAC(auth, product);
9360
+ }
9361
+ });
9362
+ };
9363
+ return {
9364
+ fetchSigmetTAC: fetchSigmetTAC,
9365
+ fetchAirmetTAC: fetchAirmetTAC
9366
+ };
9367
+ };
9125
9368
 
9126
9369
  var _excluded$6 = ["IS_DRAFT", "object", "translation-select"];
9127
9370
  var useScrollTopOnError = function useScrollTopOnError(error) {
@@ -9199,7 +9442,7 @@ var ContainerFormWrapper = styled('div')(function (_ref) {
9199
9442
  height: isReadOnly ? '100%' : "calc(100% - 206px)",
9200
9443
  overflowY: 'auto'
9201
9444
  }, _ref2[containerQueryBreakpoint] = {
9202
- height: 'calc(100% - 88px)'
9445
+ height: isReadOnly ? '100%' : 'calc(100% - 88px)'
9203
9446
  }, _ref2;
9204
9447
  });
9205
9448
  var sm6Width = 'calc(100% * 6 / var(--Grid-columns) - (var(--Grid-columns) - 6) * (var(--Grid-columnSpacing) / var(--Grid-columns)))';
@@ -9310,8 +9553,12 @@ var Form = function Form(_ref5) {
9310
9553
  _ref5$onAddObject = _ref5.onAddObject,
9311
9554
  onAddObject = _ref5$onAddObject === void 0 ? function () {} : _ref5$onAddObject,
9312
9555
  selectedAviationProduct = _ref5.selectedAviationProduct,
9313
- isSigmetWarning = _ref5.isSigmetWarning,
9556
+ _ref5$warningType = _ref5.warningType,
9557
+ warningType = _ref5$warningType === void 0 ? 'public' : _ref5$warningType,
9314
9558
  mode = _ref5.mode;
9559
+ var _useTACApi = useTACApi(),
9560
+ fetchSigmetTAC = _useTACApi.fetchSigmetTAC,
9561
+ fetchAirmetTAC = _useTACApi.fetchAirmetTAC;
9315
9562
  var initialPublicWarningArea = publicWarningDetails && (publicWarningDetails == null ? void 0 : publicWarningDetails.areas) && (publicWarningDetails == null ? void 0 : publicWarningDetails.areas.length) && (publicWarningDetails == null || (_publicWarningDetails = publicWarningDetails.areas[0]) == null ? void 0 : _publicWarningDetails.geoJSON);
9316
9563
  var _React$useState = React.useState(initialPublicWarningArea),
9317
9564
  warningGeoJSONFeature = _React$useState[0],
@@ -9388,44 +9635,63 @@ var Form = function Form(_ref5) {
9388
9635
  };
9389
9636
  var publicWarningId = publicWarningDetails == null ? void 0 : publicWarningDetails.id;
9390
9637
  React.useEffect(function () {
9391
- if (!selectedAviationProduct) {
9392
- // sync redux with react-hook-form
9393
- reset(getFormData(publicWarningDetails, object));
9638
+ if (selectedAviationProduct) {
9639
+ return;
9394
9640
  }
9641
+ // sync redux with react-hook-form
9642
+ reset(getFormData(publicWarningDetails, object));
9395
9643
  // eslint-disable-next-line react-hooks/exhaustive-deps
9396
- }, [publicWarningId, selectedAviationProduct]);
9644
+ }, [publicWarningId]);
9397
9645
  var areas = publicWarningDetails == null ? void 0 : publicWarningDetails.areas;
9398
9646
  React.useEffect(function () {
9399
9647
  if (selectedAviationProduct) {
9400
9648
  return;
9401
9649
  }
9402
- // sync redux with react-hook-form
9403
9650
  if (areas) {
9651
+ // sync redux with react-hook-form
9404
9652
  setValue('areas', areas);
9405
9653
  }
9406
- }, [areas, setValue, selectedAviationProduct]);
9654
+ // eslint-disable-next-line react-hooks/exhaustive-deps
9655
+ }, [areas, setValue]);
9407
9656
  React.useEffect(function () {
9408
9657
  if (selectedAviationProduct) {
9409
9658
  return;
9410
9659
  }
9411
9660
  // sync drawing on map with selected warning
9412
9661
  setWarningGeoJSONFeature(initialPublicWarningArea);
9413
- }, [initialPublicWarningArea, selectedAviationProduct]);
9662
+ // eslint-disable-next-line react-hooks/exhaustive-deps
9663
+ }, [initialPublicWarningArea]);
9664
+ var aviationId = selectedAviationProduct == null ? void 0 : selectedAviationProduct.uuid;
9665
+ React.useEffect(function () {
9666
+ if (!selectedAviationProduct) {
9667
+ return;
9668
+ }
9669
+ // sync redux with react-hook-form
9670
+ reset(selectedAviationProduct);
9671
+ // eslint-disable-next-line react-hooks/exhaustive-deps
9672
+ }, [aviationId, warningType]);
9414
9673
  var errors = getErrors(error.message);
9415
9674
  var level = WarningLevel[publicWarningDetails == null ? void 0 : publicWarningDetails.level] || WarningLevel[WarningLevel.moderate];
9416
9675
  var geoJSONFeature = getWarningGeoJSONWithColor(level, warningGeoJSONFeature);
9417
9676
  var ref = useScrollTopOnError(error);
9418
- var warningType = isSigmetWarning ? 'sigmet' : 'airmet';
9419
9677
  var _useProductConfig = useProductConfig(warningType),
9420
9678
  aviationConfig = _useProductConfig.data;
9421
- var _useAuthenticationCon = useAuthenticationContext(),
9422
- auth = _useAuthenticationCon.auth;
9423
9679
  return jsxs(ContainerWrapper, {
9424
- children: [selectedAviationProduct ? jsx(ContainerFormWrapper, {
9680
+ children: [jsxs(ContainerFormWrapper, {
9425
9681
  isReadOnly: isReadOnly,
9426
9682
  ref: ref,
9427
9683
  "data-testid": "scroll-container",
9428
- children: jsx(Box, {
9684
+ children: [errors && jsx(Box, {
9685
+ sx: {
9686
+ marginBottom: 2
9687
+ },
9688
+ children: jsx(AlertBanner, {
9689
+ title: errors.title,
9690
+ info: errors.errors,
9691
+ shouldClose: true,
9692
+ severity: error == null ? void 0 : error.severity
9693
+ })
9694
+ }), selectedAviationProduct ? jsx(Box, {
9429
9695
  sx: {
9430
9696
  maxWidth: {
9431
9697
  xs: '550px',
@@ -9433,45 +9699,30 @@ var Form = function Form(_ref5) {
9433
9699
  },
9434
9700
  marginLeft: '-80px'
9435
9701
  },
9436
- children: isSigmetWarning ? jsx(SigmetForm, {
9702
+ children: warningType === 'sigmet' ? jsx(SigmetForm, {
9437
9703
  showMap: false,
9438
9704
  mode: mode,
9439
- initialSigmet: selectedAviationProduct !== null && !isInstanceOfCancelSigmet(selectedAviationProduct) ? selectedAviationProduct : null,
9440
- initialCancelSigmet: selectedAviationProduct !== null && isInstanceOfCancelSigmet(selectedAviationProduct) ? selectedAviationProduct : null,
9705
+ initialSigmet: selectedAviationProduct !== undefined && !isInstanceOfCancelSigmet(selectedAviationProduct) ? selectedAviationProduct : null,
9706
+ initialCancelSigmet: selectedAviationProduct !== undefined && isInstanceOfCancelSigmet(selectedAviationProduct) ? selectedAviationProduct : null,
9441
9707
  productConfig: aviationConfig,
9442
9708
  product: selectedAviationProduct,
9443
9709
  getTAC: function getTAC(product) {
9444
- return getSigmetTAC(auth, product);
9710
+ return fetchSigmetTAC(product);
9445
9711
  }
9446
9712
  }) : jsx(AirmetForm, {
9447
9713
  showMap: false,
9448
9714
  mode: mode,
9449
- isCancelAirmet: selectedAviationProduct !== null && isInstanceOfCancelAirmet(selectedAviationProduct),
9450
- initialAirmet: selectedAviationProduct !== null && !isInstanceOfCancelAirmet(selectedAviationProduct) ? selectedAviationProduct : null,
9451
- initialCancelAirmet: selectedAviationProduct !== null && isInstanceOfCancelAirmet(selectedAviationProduct) ? selectedAviationProduct : null,
9715
+ isCancelAirmet: selectedAviationProduct !== undefined && isInstanceOfCancelAirmet(selectedAviationProduct),
9716
+ initialAirmet: selectedAviationProduct !== undefined && !isInstanceOfCancelAirmet(selectedAviationProduct) ? selectedAviationProduct : null,
9717
+ initialCancelAirmet: selectedAviationProduct !== undefined && isInstanceOfCancelAirmet(selectedAviationProduct) ? selectedAviationProduct : null,
9452
9718
  productConfig: aviationConfig,
9453
9719
  product: selectedAviationProduct,
9454
9720
  getTAC: function getTAC(product) {
9455
- return getAirmetTAC(auth, product);
9721
+ return fetchAirmetTAC(product);
9456
9722
  }
9457
9723
  })
9458
- })
9459
- }) : jsxs(ContainerFormWrapper, {
9460
- isReadOnly: isReadOnly,
9461
- ref: ref,
9462
- "data-testid": "scroll-container",
9463
- children: [jsxs(ContainerGrid, {
9464
- children: [errors && jsx(Box, {
9465
- sx: {
9466
- marginBottom: 2
9467
- },
9468
- children: jsx(AlertBanner, {
9469
- title: errors.title,
9470
- info: errors.errors,
9471
- shouldClose: true,
9472
- severity: error == null ? void 0 : error.severity
9473
- })
9474
- }), jsxs(Grid2, {
9724
+ }) : jsx(ContainerGrid, {
9725
+ children: jsxs(Grid2, {
9475
9726
  size: {
9476
9727
  xs: 12
9477
9728
  },
@@ -9565,14 +9816,14 @@ var Form = function Form(_ref5) {
9565
9816
  })
9566
9817
  })
9567
9818
  })]
9568
- })]
9819
+ })
9569
9820
  }), jsx(DraftFieldHelper, {}), jsx(ReactHookFormHiddenInput, {
9570
9821
  name: "id"
9571
9822
  })]
9572
9823
  }), !isReadOnly && jsx(Box, {
9573
9824
  sx: {
9574
9825
  padding: '24px 10px 14px 10px',
9575
- position: selectedAviationProduct ? 'relative' : 'absolute',
9826
+ position: 'absolute',
9576
9827
  bottom: 0,
9577
9828
  width: '100%',
9578
9829
  backgroundColor: 'geowebColors.background.surfaceApp',
@@ -9661,8 +9912,7 @@ var PublicWarningsForm = function PublicWarningsForm(props) {
9661
9912
  return jsx(ReactHookFormProvider, {
9662
9913
  options: Object.assign({}, defaultFormOptions, {
9663
9914
  mode: 'onSubmit',
9664
- defaultValues: defaultValues,
9665
- values: selectedAviationProduct
9915
+ defaultValues: defaultValues
9666
9916
  }),
9667
9917
  children: jsx(Form, Object.assign({}, props))
9668
9918
  });
@@ -9725,6 +9975,9 @@ var getSelectedPublicWarningId = createSelector(getPublicWarningStore, function
9725
9975
  var getSelectedPublicIsFormDirty = createSelector(getPublicWarningStore, function (publicWarningStore) {
9726
9976
  return (publicWarningStore == null ? void 0 : publicWarningStore.isFormDirty) || false;
9727
9977
  });
9978
+ var getWarningType = createSelector(getPublicWarningStore, function (publicWarningStore) {
9979
+ return publicWarningStore == null ? void 0 : publicWarningStore.warningType;
9980
+ });
9728
9981
 
9729
9982
  /* *
9730
9983
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -9757,7 +10010,8 @@ var PublicWarningStatus;
9757
10010
  var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
9758
10011
  var defaultMapPreset = _ref.defaultMapPreset,
9759
10012
  selectedAviationProduct = _ref.selectedAviationProduct,
9760
- isSigmetWarning = _ref.isSigmetWarning,
10013
+ _ref$warningType = _ref.warningType,
10014
+ warningType = _ref$warningType === void 0 ? 'public' : _ref$warningType,
9761
10015
  mode = _ref.mode;
9762
10016
  var publicWarning = useSelector(function (store) {
9763
10017
  return getPublicWarning(store);
@@ -9802,15 +10056,26 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
9802
10056
  }));
9803
10057
  };
9804
10058
  var getIsReadOnly = function getIsReadOnly() {
9805
- if (publicWarningFormAction === 'readonly') {
9806
- return true;
10059
+ // public warning related
10060
+ if (warningType === 'public') {
10061
+ if (publicWarningFormAction === 'readonly') {
10062
+ return true;
10063
+ }
10064
+ if ((publicWarning == null ? void 0 : publicWarning.status) === 'TODO') {
10065
+ return false;
10066
+ }
10067
+ // Readonly in case you are not creating a new warning and you are not set as the editor
10068
+ return !isEditor && (publicWarning == null ? void 0 : publicWarning.status) !== undefined;
10069
+ }
10070
+ // aviation related
10071
+ if ((selectedAviationProduct == null ? void 0 : selectedAviationProduct.status) === 'DRAFT') {
10072
+ return false;
9807
10073
  }
9808
- if ((publicWarning == null ? void 0 : publicWarning.status) === 'TODO' && publicWarningFormAction === '') {
10074
+ if (mode === 'new') {
9809
10075
  return false;
9810
10076
  }
9811
- return !isEditor && (publicWarning == null ? void 0 : publicWarning.status) !== undefined;
10077
+ return true;
9812
10078
  };
9813
- // Readonly also in case you are not creating a new warning and you are not set as the editor
9814
10079
  var isReadOnly = getIsReadOnly();
9815
10080
  var onAddObject = function onAddObject() {
9816
10081
  dispatch(uiActions.setToggleOpenDialog({
@@ -9830,7 +10095,7 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect(_ref) {
9830
10095
  defaultMapPreset: defaultMapPreset,
9831
10096
  onAddObject: onAddObject,
9832
10097
  selectedAviationProduct: selectedAviationProduct,
9833
- isSigmetWarning: isSigmetWarning,
10098
+ warningType: warningType,
9834
10099
  mode: mode
9835
10100
  });
9836
10101
  };
@@ -10630,6 +10895,74 @@ var transformAirmetToProductFormat = function transformAirmetToProductFormat(war
10630
10895
  validDateEndOfAirmetToCancel: cancelAirmet.validDateEndOfAirmetToCancel
10631
10896
  });
10632
10897
  };
10898
+ // For the Create and Clear buttons
10899
+ // The fields initialised to unknown will be set to their default values by ReactHookForm
10900
+ var getEmptySigmetWarning = function getEmptySigmetWarning() {
10901
+ var currentTime = new Date();
10902
+ var validFromTime = dateUtils.add(currentTime, {
10903
+ minutes: 15
10904
+ });
10905
+ var validUntilTime = dateUtils.add(currentTime, {
10906
+ hours: 4
10907
+ });
10908
+ return {
10909
+ type: undefined,
10910
+ phenomenon: '',
10911
+ status: '',
10912
+ isObservationOrForecast: '',
10913
+ issueDate: undefined,
10914
+ locationIndicatorATSR: undefined,
10915
+ locationIndicatorATSU: undefined,
10916
+ locationIndicatorMWO: undefined,
10917
+ change: '',
10918
+ // Default change
10919
+ sequence: undefined,
10920
+ validDateStart: dateUtils.dateToString(validFromTime),
10921
+ validDateEnd: dateUtils.dateToString(validUntilTime),
10922
+ level: '',
10923
+ levelInfoMode: '',
10924
+ movementType: '',
10925
+ firName: undefined
10926
+ };
10927
+ };
10928
+ // For the Create and Clear buttons
10929
+ // The fields initialised to unknown will be set to their default values by ReactHookForm
10930
+ var getEmptyAirmetWarning = function getEmptyAirmetWarning() {
10931
+ var currentTime = new Date();
10932
+ var validFromTime = dateUtils.add(currentTime, {
10933
+ minutes: 15
10934
+ });
10935
+ var validUntilTime = dateUtils.add(currentTime, {
10936
+ hours: 4
10937
+ });
10938
+ return {
10939
+ type: undefined,
10940
+ phenomenon: '',
10941
+ status: '',
10942
+ isObservationOrForecast: '',
10943
+ issueDate: undefined,
10944
+ locationIndicatorATSR: undefined,
10945
+ locationIndicatorATSU: undefined,
10946
+ locationIndicatorMWO: undefined,
10947
+ change: '',
10948
+ // Default change
10949
+ sequence: undefined,
10950
+ validDateStart: dateUtils.dateToString(validFromTime),
10951
+ validDateEnd: dateUtils.dateToString(validUntilTime),
10952
+ level: '',
10953
+ levelInfoMode: '',
10954
+ movementType: '',
10955
+ firName: undefined,
10956
+ startGeometry: {
10957
+ type: 'FeatureCollection',
10958
+ features: []
10959
+ },
10960
+ startGeometryIntersect: {
10961
+ type: 'FeatureCollection',
10962
+ features: []
10963
+ }
10964
+ };
10965
+ };
10633
10966
 
10634
10967
  var warningFormConfirmationOptions = function warningFormConfirmationOptions(t) {
10635
10968
  return {
@@ -10676,6 +11009,7 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
10676
11009
  var publicWarningEditor = useSelector(function (store) {
10677
11010
  return getPublicWarningEditor(store);
10678
11011
  });
11012
+ var warningType = useSelector(getWarningType);
10679
11013
  var _useAuthenticationCon = useAuthenticationContext$1(),
10680
11014
  auth = _useAuthenticationCon.auth;
10681
11015
  var isEditor = publicWarningEditor === (auth == null ? void 0 : auth.username) || false;
@@ -10823,9 +11157,9 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
10823
11157
  return _ref5.apply(this, arguments);
10824
11158
  };
10825
11159
  }();
10826
- var _useAirmetList = useAirmetList(),
11160
+ var _useAirmetList = useAirmetList(true),
10827
11161
  airmetList = _useAirmetList.data;
10828
- var _useSigmetList = useSigmetList(),
11162
+ var _useSigmetList = useSigmetList(true),
10829
11163
  sigmetList = _useSigmetList.data;
10830
11164
  var selectedSigmet = sigmetList == null ? void 0 : sigmetList.find(function (sigmet) {
10831
11165
  return sigmet.uuid === selectedWarningId;
@@ -10833,15 +11167,14 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
10833
11167
  var selectedAirmet = airmetList == null ? void 0 : airmetList.find(function (airmet) {
10834
11168
  return airmet.uuid === selectedWarningId;
10835
11169
  });
10836
- var isSigmetWarning = Boolean(selectedSigmet);
10837
- var warningType = isSigmetWarning ? 'sigmet' : 'airmet';
10838
- var _useProductConfig = useProductConfig(warningType),
11170
+ var updatedWarningType = selectedSigmet ? 'sigmet' : selectedAirmet && 'airmet' || warningType;
11171
+ var _useProductConfig = useProductConfig(updatedWarningType, !isDialogOpen),
10839
11172
  aviationConfig = _useProductConfig.data;
10840
- var selectedSigmetProduct = selectedSigmet ? transformSigmetToProductFormat(selectedSigmet, aviationConfig) : undefined;
10841
- var selectedAirmetProduct = selectedAirmet ? transformAirmetToProductFormat(selectedAirmet, aviationConfig) : undefined;
10842
- var selectedAviationProduct = isSigmetWarning ? selectedSigmetProduct : selectedAirmetProduct;
10843
- var productCanBe = selectedAviationProduct !== null ? (selectedSigmet == null ? void 0 : selectedSigmet.canbe) || (selectedAirmet == null ? void 0 : selectedAirmet.canbe) : ['DRAFTED', 'DISCARDED', 'PUBLISHED'];
10844
- var mode = getProductFormMode(productCanBe, selectedAviationProduct);
11173
+ var selectedSigmetProduct = selectedSigmet && aviationConfig ? transformSigmetToProductFormat(selectedSigmet, aviationConfig) : getEmptySigmetWarning();
11174
+ var selectedAirmetProduct = selectedAirmet && aviationConfig ? transformAirmetToProductFormat(selectedAirmet, aviationConfig) : getEmptyAirmetWarning();
11175
+ var selectedAviationProduct = updatedWarningType === 'sigmet' ? selectedSigmetProduct : updatedWarningType === 'airmet' && selectedAirmetProduct || undefined;
11176
+ var productCanBe = updatedWarningType === 'public' ? ['DRAFTED', 'DISCARDED', 'PUBLISHED'] : (selectedSigmet == null ? void 0 : selectedSigmet.canbe) || (selectedAirmet == null ? void 0 : selectedAirmet.canbe);
11177
+ var mode = getProductFormMode(productCanBe, !selectedWarningId ? null : selectedAviationProduct);
10845
11178
  // Readonly also in case you are not creating a new warning and you are not set as the editor
10846
11179
  var isReadOnly = formAction === 'readonly' || !isEditor && publicWarningStatus !== undefined;
10847
11180
  // Only show toggle if in draft status
@@ -10861,11 +11194,11 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
10861
11194
  shouldHideFormMode: shouldHideFormToggleMode,
10862
11195
  publicWarningEditor: publicWarningEditor,
10863
11196
  selectedAviationProduct: selectedAviationProduct,
10864
- warningType: warningType,
11197
+ warningType: updatedWarningType,
10865
11198
  children: jsx(PublicWarningsFormConnect, {
10866
11199
  defaultMapPreset: defaultMapPreset,
10867
11200
  selectedAviationProduct: selectedAviationProduct,
10868
- isSigmetWarning: isSigmetWarning,
11201
+ warningType: updatedWarningType,
10869
11202
  mode: mode
10870
11203
  })
10871
11204
  }), jsx(AreaObjectLoaderConnect, {})]
@@ -11525,6 +11858,7 @@ var WarningListItemSeperator = function WarningListItemSeperator(_ref) {
11525
11858
  padding: 0
11526
11859
  },
11527
11860
  onClick: onClick,
11861
+ "data-testid": "warninglist-" + status,
11528
11862
  children: [isExpanded ? jsx(ChevronDown, {}) : jsx(ChevronUp, {}), jsx(Typography, {
11529
11863
  variant: "caption",
11530
11864
  sx: {
@@ -11966,115 +12300,6 @@ var WarningListItem = function WarningListItem(_ref) {
11966
12300
  }), warning.id);
11967
12301
  };
11968
12302
 
11969
- /* *
11970
- * Licensed under the Apache License, Version 2.0 (the "License");
11971
- * you may not use this file except in compliance with the License.
11972
- * You may obtain a copy of the License at
11973
- *
11974
- * http://www.apache.org/licenses/LICENSE-2.0
11975
- *
11976
- * Unless required by applicable law or agreed to in writing, software
11977
- * distributed under the License is distributed on an "AS IS" BASIS,
11978
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11979
- * See the License for the specific language governing permissions and
11980
- * limitations under the License.
11981
- *
11982
- * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
11983
- * Copyright 2024 - Finnish Meteorological Institute (FMI)
11984
- * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
11985
- * */
11986
- var useFilter = function useFilter(defaultFilter, pickedOptions) {
11987
- var _useState = useState(defaultFilter),
11988
- filter = _useState[0],
11989
- setFilter = _useState[1];
11990
- var pickedFilterOptions = pick(filter, ['unspecified'].concat(pickedOptions));
11991
- var _useSelectedOptions = useSelectedOptions(pickedFilterOptions),
11992
- allSelected = _useSelectedOptions.allSelected;
11993
- return [pickedFilterOptions, setFilter, allSelected];
11994
- };
11995
- var useWarningFilters = function useWarningFilters(warnings) {
11996
- var _useState2 = useState(defaultDomainFilter),
11997
- domainFilter = _useState2[0],
11998
- setDomainFilter = _useState2[1];
11999
- var relevantLevels = Object.keys(domainFilter).flatMap(function (domain) {
12000
- return domainFilter[domain] ? domainLevels[domain] : [];
12001
- });
12002
- var _useFilter = useFilter(defaultLevelFilter, relevantLevels),
12003
- pickedLevelFilter = _useFilter[0],
12004
- setLevelFilter = _useFilter[1],
12005
- allLevelsSelected = _useFilter[2];
12006
- var existingPhenomenon = Object.values(Phenomenon).filter(function (p) {
12007
- return warnings.find(function (w) {
12008
- return w.warningDetail.phenomenon === p;
12009
- });
12010
- });
12011
- var _useFilter2 = useFilter(defaultPhenomenonFilter, existingPhenomenon),
12012
- pickedPhenomenonFilter = _useFilter2[0],
12013
- setPhenomenonFilter = _useFilter2[1],
12014
- allPhenomenonSelected = _useFilter2[2];
12015
- var _useSelectedOptions2 = useSelectedOptions(domainFilter),
12016
- allDomainSelected = _useSelectedOptions2.allSelected;
12017
- var allSelected = allDomainSelected && allLevelsSelected && allPhenomenonSelected;
12018
- /**
12019
- * @param filterKey - Name of the filter | "ALL" filters
12020
- * @param optionKey - Name of the option | "ALL" options
12021
- * @param value - The new value
12022
- * @param only - Flag that decides if all other options should be disabled
12023
- */
12024
- var updateFilter = function updateFilter(filterKey, optionKey, value, only) {
12025
- if (filterKey === 'ALL') {
12026
- setDomainFilter(function (state) {
12027
- return updateState(state, 'ALL', value);
12028
- });
12029
- setLevelFilter(function (state) {
12030
- return updateState(state, 'ALL', value);
12031
- });
12032
- setPhenomenonFilter(function (state) {
12033
- return updateState(state, 'ALL', value);
12034
- });
12035
- } else if (filterKey === 'domain') {
12036
- setDomainFilter(function (state) {
12037
- return updateState(state, optionKey, value, only);
12038
- });
12039
- } else if (filterKey === 'level') {
12040
- setLevelFilter(function (state) {
12041
- return updateState(state, optionKey, value, only);
12042
- });
12043
- } else if (filterKey === 'phenomenon') {
12044
- setPhenomenonFilter(function (state) {
12045
- return updateState(state, optionKey, value, only);
12046
- });
12047
- }
12048
- };
12049
- var byFilterState = useCallback(function (warning) {
12050
- var levelDomain = ['SIG', 'AIR'].find(function (d) {
12051
- return d === warning.warningDetail.level;
12052
- }) ? Domain.aviation : Domain["public"];
12053
- if (!domainFilter[levelDomain]) {
12054
- return false;
12055
- }
12056
- var level = getValue(Level, warning.warningDetail.level);
12057
- if (!pickedLevelFilter[level]) {
12058
- return false;
12059
- }
12060
- var phenomenon = getValue(Phenomenon, warning.warningDetail.phenomenon);
12061
- if (!pickedPhenomenonFilter[phenomenon]) {
12062
- return false;
12063
- }
12064
- return true;
12065
- }, [domainFilter, pickedLevelFilter, pickedPhenomenonFilter]);
12066
- return {
12067
- filterState: {
12068
- domain: domainFilter,
12069
- phenomenon: pickedPhenomenonFilter,
12070
- level: pickedLevelFilter
12071
- },
12072
- allSelected: allSelected,
12073
- updateFilter: updateFilter,
12074
- byFilterState: byFilterState
12075
- };
12076
- };
12077
-
12078
12303
  var BUTTON_AIRMET = 'AIRMET';
12079
12304
  var BUTTON_SIGMET = 'SIGMET';
12080
12305
  var NewWarningButton = function NewWarningButton(_ref) {
@@ -12095,6 +12320,10 @@ var NewWarningButton = function NewWarningButton(_ref) {
12095
12320
  event.stopPropagation();
12096
12321
  setAnchorEl(null);
12097
12322
  };
12323
+ var onCreateNewWarning = function onCreateNewWarning(warningType, event) {
12324
+ onCreateWarning(warningType);
12325
+ handleClose(event);
12326
+ };
12098
12327
  var buttonId = 'newWarningButton';
12099
12328
  React__default.useEffect(function () {
12100
12329
  if (isDefaultOpen) {
@@ -12155,19 +12384,22 @@ var NewWarningButton = function NewWarningButton(_ref) {
12155
12384
  },
12156
12385
  children: [jsx(MenuItem, {
12157
12386
  onClick: function onClick(event) {
12158
- onCreateWarning();
12159
- handleClose(event);
12387
+ onCreateNewWarning('public', event);
12160
12388
  },
12161
12389
  children: jsx(ListItemText, {
12162
12390
  children: t('public-warning-title').toUpperCase()
12163
12391
  })
12164
12392
  }, "Public"), jsx(MenuItem, {
12165
- disabled: true,
12393
+ onClick: function onClick(event) {
12394
+ onCreateNewWarning('airmet', event);
12395
+ },
12166
12396
  children: jsx(ListItemText, {
12167
12397
  children: BUTTON_AIRMET
12168
12398
  })
12169
12399
  }, "Airmet"), jsx(MenuItem, {
12170
- disabled: true,
12400
+ onClick: function onClick(event) {
12401
+ onCreateNewWarning('sigmet', event);
12402
+ },
12171
12403
  children: jsx(ListItemText, {
12172
12404
  children: BUTTON_SIGMET
12173
12405
  })
@@ -12269,6 +12501,7 @@ var PublicWarningList = function PublicWarningList(_ref) {
12269
12501
  var _ref$warnings = _ref.warnings,
12270
12502
  warnings = _ref$warnings === void 0 ? [] : _ref$warnings,
12271
12503
  filters = _ref.filters,
12504
+ filterHookState = _ref.filterHookState,
12272
12505
  _ref$isLoading = _ref.isLoading,
12273
12506
  isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
12274
12507
  error = _ref.error,
@@ -12294,14 +12527,14 @@ var PublicWarningList = function PublicWarningList(_ref) {
12294
12527
  _ref$onClickAllChip = _ref.onClickAllChip,
12295
12528
  onClickAllChip = _ref$onClickAllChip === void 0 ? function () {} : _ref$onClickAllChip,
12296
12529
  _ref$isAllChipSelecte = _ref.isAllChipSelected,
12297
- isAllChipSelected = _ref$isAllChipSelecte === void 0 ? true : _ref$isAllChipSelecte;
12530
+ isAllChipSelected = _ref$isAllChipSelecte === void 0 ? true : _ref$isAllChipSelecte,
12531
+ expandedSections = _ref.expandedSections,
12532
+ setExpandedSections = _ref.setExpandedSections;
12533
+ var filterState = filterHookState.filterState,
12534
+ updateFilter = filterHookState.updateFilter,
12535
+ allSelected = filterHookState.allSelected;
12298
12536
  var _useWarningsTranslati = useWarningsTranslation(),
12299
12537
  t = _useWarningsTranslati.t;
12300
- var _useWarningFilters = useWarningFilters(warnings),
12301
- filterState = _useWarningFilters.filterState,
12302
- allSelected = _useWarningFilters.allSelected,
12303
- updateFilter = _useWarningFilters.updateFilter,
12304
- byFilterState = _useWarningFilters.byFilterState;
12305
12538
  var _React$useState = React__default.useState({
12306
12539
  key: 'lastUpdatedTime',
12307
12540
  direction: 'desc'
@@ -12313,8 +12546,8 @@ var PublicWarningList = function PublicWarningList(_ref) {
12313
12546
  updateFilter('ALL', 'ALL', !isChecked);
12314
12547
  };
12315
12548
  var sortedWarnings = React__default.useMemo(function () {
12316
- return groupWarningsOnStatus(warnings.filter(byFilterState), sortState);
12317
- }, [warnings, byFilterState, sortState]);
12549
+ return groupWarningsOnStatus(warnings, sortState);
12550
+ }, [warnings, sortState]);
12318
12551
  var toggleSortDirection = function toggleSortDirection(key) {
12319
12552
  setSortState(function (prevState) {
12320
12553
  return {
@@ -12323,14 +12556,6 @@ var PublicWarningList = function PublicWarningList(_ref) {
12323
12556
  };
12324
12557
  });
12325
12558
  };
12326
- var _React$useState2 = React__default.useState({
12327
- TODO: true,
12328
- DRAFT: true,
12329
- PUBLISHED: true,
12330
- EXPIRED: true
12331
- }),
12332
- expandedSections = _React$useState2[0],
12333
- setExpandedSections = _React$useState2[1];
12334
12559
  var toggleExpand = function toggleExpand(shouldToggle, status) {
12335
12560
  var _Object$assign;
12336
12561
  setExpandedSections(Object.assign({}, expandedSections, (_Object$assign = {}, _Object$assign[status] = shouldToggle, _Object$assign)));
@@ -12661,7 +12886,7 @@ var getSelectedFilterOptions = createSelector(selectAllFilters, function (filter
12661
12886
  });
12662
12887
  });
12663
12888
  return selectedOptions;
12664
- });
12889
+ }, selectorMemoizationOptions);
12665
12890
  var getFilteredWarnings = createSelector(selectAllPublicWarnings, getIsAllSelected, getSelectedFilterOptions, selectAllFilterIds, function (warnings, isAllSelected, filters, filterIds) {
12666
12891
  if (isAllSelected) {
12667
12892
  return warnings;
@@ -12673,7 +12898,7 @@ var getFilteredWarnings = createSelector(selectAllPublicWarnings, getIsAllSelect
12673
12898
  });
12674
12899
  });
12675
12900
  return result;
12676
- });
12901
+ }, selectorMemoizationOptions);
12677
12902
 
12678
12903
  var ConfirmDeleteWarningDialog = function ConfirmDeleteWarningDialog(_ref) {
12679
12904
  var _ref$onClose = _ref.onClose,
@@ -12753,7 +12978,117 @@ var ConfirmDeleteWarningDialog = function ConfirmDeleteWarningDialog(_ref) {
12753
12978
  }));
12754
12979
  };
12755
12980
 
12756
- var PublicWarningListConnect = function PublicWarningListConnect() {
12981
+ /* *
12982
+ * Licensed under the Apache License, Version 2.0 (the "License");
12983
+ * you may not use this file except in compliance with the License.
12984
+ * You may obtain a copy of the License at
12985
+ *
12986
+ * http://www.apache.org/licenses/LICENSE-2.0
12987
+ *
12988
+ * Unless required by applicable law or agreed to in writing, software
12989
+ * distributed under the License is distributed on an "AS IS" BASIS,
12990
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12991
+ * See the License for the specific language governing permissions and
12992
+ * limitations under the License.
12993
+ *
12994
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
12995
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
12996
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
12997
+ * */
12998
+ var useFilter = function useFilter(defaultFilter, pickedOptions) {
12999
+ var _useState = useState(defaultFilter),
13000
+ filter = _useState[0],
13001
+ setFilter = _useState[1];
13002
+ var pickedFilterOptions = pick(filter, ['unspecified'].concat(pickedOptions));
13003
+ var _useSelectedOptions = useSelectedOptions(pickedFilterOptions),
13004
+ allSelected = _useSelectedOptions.allSelected;
13005
+ return [pickedFilterOptions, setFilter, allSelected];
13006
+ };
13007
+ var useWarningFilters = function useWarningFilters(warnings) {
13008
+ var _useState2 = useState(defaultDomainFilter),
13009
+ domainFilter = _useState2[0],
13010
+ setDomainFilter = _useState2[1];
13011
+ var relevantLevels = Object.keys(domainFilter).flatMap(function (domain) {
13012
+ return domainFilter[domain] ? domainLevels[domain] : [];
13013
+ });
13014
+ var _useFilter = useFilter(defaultLevelFilter, relevantLevels),
13015
+ pickedLevelFilter = _useFilter[0],
13016
+ setLevelFilter = _useFilter[1],
13017
+ allLevelsSelected = _useFilter[2];
13018
+ var existingPhenomenon = Object.values(Phenomenon).filter(function (p) {
13019
+ return warnings.find(function (w) {
13020
+ return w.warningDetail.phenomenon === p;
13021
+ });
13022
+ });
13023
+ var _useFilter2 = useFilter(defaultPhenomenonFilter, existingPhenomenon),
13024
+ pickedPhenomenonFilter = _useFilter2[0],
13025
+ setPhenomenonFilter = _useFilter2[1],
13026
+ allPhenomenonSelected = _useFilter2[2];
13027
+ var _useSelectedOptions2 = useSelectedOptions(domainFilter),
13028
+ allDomainSelected = _useSelectedOptions2.allSelected;
13029
+ var allSelected = allDomainSelected && allLevelsSelected && allPhenomenonSelected;
13030
+ /**
13031
+ * @param filterKey - Name of the filter | "ALL" filters
13032
+ * @param optionKey - Name of the option | "ALL" options
13033
+ * @param value - The new value
13034
+ * @param only - Flag that decides if all other options should be disabled
13035
+ */
13036
+ var updateFilter = function updateFilter(filterKey, optionKey, value, only) {
13037
+ if (filterKey === 'ALL') {
13038
+ setDomainFilter(function (state) {
13039
+ return updateState(state, 'ALL', value);
13040
+ });
13041
+ setLevelFilter(function (state) {
13042
+ return updateState(state, 'ALL', value);
13043
+ });
13044
+ setPhenomenonFilter(function (state) {
13045
+ return updateState(state, 'ALL', value);
13046
+ });
13047
+ } else if (filterKey === 'domain') {
13048
+ setDomainFilter(function (state) {
13049
+ return updateState(state, optionKey, value, only);
13050
+ });
13051
+ } else if (filterKey === 'level') {
13052
+ setLevelFilter(function (state) {
13053
+ return updateState(state, optionKey, value, only);
13054
+ });
13055
+ } else if (filterKey === 'phenomenon') {
13056
+ setPhenomenonFilter(function (state) {
13057
+ return updateState(state, optionKey, value, only);
13058
+ });
13059
+ }
13060
+ };
13061
+ var byFilterState = useCallback(function (warning) {
13062
+ var levelDomain = ['SIG', 'AIR'].find(function (d) {
13063
+ return d === warning.warningDetail.level;
13064
+ }) ? Domain.aviation : Domain["public"];
13065
+ if (!domainFilter[levelDomain]) {
13066
+ return false;
13067
+ }
13068
+ var level = getValue(Level, warning.warningDetail.level);
13069
+ if (!pickedLevelFilter[level]) {
13070
+ return false;
13071
+ }
13072
+ var phenomenon = getValue(Phenomenon, warning.warningDetail.phenomenon);
13073
+ if (!pickedPhenomenonFilter[phenomenon]) {
13074
+ return false;
13075
+ }
13076
+ return true;
13077
+ }, [domainFilter, pickedLevelFilter, pickedPhenomenonFilter]);
13078
+ return {
13079
+ filterState: {
13080
+ domain: domainFilter,
13081
+ phenomenon: pickedPhenomenonFilter,
13082
+ level: pickedLevelFilter
13083
+ },
13084
+ allSelected: allSelected,
13085
+ updateFilter: updateFilter,
13086
+ byFilterState: byFilterState
13087
+ };
13088
+ };
13089
+
13090
+ var PublicWarningListConnect = function PublicWarningListConnect(_ref) {
13091
+ var panelId = _ref.panelId;
12757
13092
  var _useWarningsTranslati = useWarningsTranslation(),
12758
13093
  t = _useWarningsTranslati.t;
12759
13094
  var dispatch = useDispatch();
@@ -12773,7 +13108,7 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
12773
13108
  setConfirmDialogOptions = _React$useState[1];
12774
13109
  var filters = useSelector(selectAllFilters);
12775
13110
  var isAllChipSelected = useSelector(getIsAllSelected);
12776
- var filteredWarnings = useSelector(getFilteredWarnings);
13111
+ var publicWarnings = useSelector(getFilteredWarnings);
12777
13112
  var warnings = useSelector(selectAllPublicWarnings);
12778
13113
  var selectedPublicWarningId = useSelector(getSelectedPublicWarningId);
12779
13114
  var isLoading = useSelector(isPublicWarningsLoading || isFetchingAirmet || isFetchingSigmet);
@@ -12782,7 +13117,7 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
12782
13117
  var lastUpdatedTime = useSelector(getPublicWarningsLastUpdatedTime);
12783
13118
  var warningsApi = getWarningsApi();
12784
13119
  var openPublicWarningDialog = /*#__PURE__*/function () {
12785
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(formAction, publicWarning) {
13120
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(formAction, publicWarning, warningType) {
12786
13121
  var mayProceed;
12787
13122
  return _regeneratorRuntime().wrap(function _callee$(_context) {
12788
13123
  while (1) switch (_context.prev = _context.next) {
@@ -12808,7 +13143,8 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
12808
13143
  dispatch(publicWarningFormActions.openPublicWarningFormDialog(Object.assign({}, publicWarning && {
12809
13144
  publicWarning: publicWarning
12810
13145
  }, {
12811
- formState: formAction
13146
+ formState: formAction,
13147
+ warningType: warningType
12812
13148
  })));
12813
13149
  case 7:
12814
13150
  case "end":
@@ -12816,18 +13152,18 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
12816
13152
  }
12817
13153
  }, _callee);
12818
13154
  }));
12819
- return function openPublicWarningDialog(_x, _x2) {
12820
- return _ref.apply(this, arguments);
13155
+ return function openPublicWarningDialog(_x, _x2, _x3) {
13156
+ return _ref2.apply(this, arguments);
12821
13157
  };
12822
13158
  }();
12823
13159
  var selectWarning = function selectWarning(publicWarning) {
12824
13160
  void openPublicWarningDialog('readonly', publicWarning);
12825
13161
  };
12826
- var createWarning = function createWarning() {
12827
- void openPublicWarningDialog('');
13162
+ var createWarning = function createWarning(warningType) {
13163
+ void openPublicWarningDialog('', undefined, warningType);
12828
13164
  };
12829
13165
  var editWarning = /*#__PURE__*/function () {
12830
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(publicWarning) {
13166
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(publicWarning) {
12831
13167
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
12832
13168
  while (1) switch (_context2.prev = _context2.next) {
12833
13169
  case 0:
@@ -12857,12 +13193,12 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
12857
13193
  }
12858
13194
  }, _callee2);
12859
13195
  }));
12860
- return function editWarning(_x3) {
12861
- return _ref2.apply(this, arguments);
13196
+ return function editWarning(_x4) {
13197
+ return _ref3.apply(this, arguments);
12862
13198
  };
12863
13199
  }();
12864
13200
  var expireWarning = /*#__PURE__*/function () {
12865
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(warning) {
13201
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(warning) {
12866
13202
  var expiredWarning;
12867
13203
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
12868
13204
  while (1) switch (_context3.prev = _context3.next) {
@@ -12887,12 +13223,12 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
12887
13223
  }
12888
13224
  }, _callee3);
12889
13225
  }));
12890
- return function expireWarning(_x4) {
12891
- return _ref3.apply(this, arguments);
13226
+ return function expireWarning(_x5) {
13227
+ return _ref4.apply(this, arguments);
12892
13228
  };
12893
13229
  }();
12894
13230
  var withdrawWarning = /*#__PURE__*/function () {
12895
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(warning) {
13231
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(warning) {
12896
13232
  var withdrawWarning;
12897
13233
  return _regeneratorRuntime().wrap(function _callee4$(_context4) {
12898
13234
  while (1) switch (_context4.prev = _context4.next) {
@@ -12917,8 +13253,8 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
12917
13253
  }
12918
13254
  }, _callee4);
12919
13255
  }));
12920
- return function withdrawWarning(_x5) {
12921
- return _ref4.apply(this, arguments);
13256
+ return function withdrawWarning(_x6) {
13257
+ return _ref5.apply(this, arguments);
12922
13258
  };
12923
13259
  }();
12924
13260
  var openSnackbar = function openSnackbar(message) {
@@ -12993,12 +13329,53 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
12993
13329
  newFilters: newFilters
12994
13330
  }));
12995
13331
  }, [dispatch, t, warnings]);
12996
- var transformedSigmets = (sigmetList == null ? void 0 : sigmetList.map(transformSigmetToWarningFormat)) || [];
12997
- var transformedAirmets = (airmetList == null ? void 0 : airmetList.map(transformAirmetToWarningFormat)) || [];
12998
- var combinedWarnings = filteredWarnings.concat(transformedSigmets).concat(transformedAirmets);
13332
+ var combinedWarnings = React__default.useMemo(function () {
13333
+ var transformedSigmets = (sigmetList == null ? void 0 : sigmetList.map(transformSigmetToWarningFormat)) || [];
13334
+ var transformedAirmets = (airmetList == null ? void 0 : airmetList.map(transformAirmetToWarningFormat)) || [];
13335
+ return publicWarnings.concat(transformedSigmets).concat(transformedAirmets);
13336
+ }, [publicWarnings, sigmetList, airmetList]);
13337
+ var filterHookState = useWarningFilters(combinedWarnings);
13338
+ var filteredWarnings = React__default.useMemo(function () {
13339
+ return combinedWarnings.filter(filterHookState.byFilterState);
13340
+ }, [combinedWarnings, filterHookState.byFilterState]);
13341
+ var _React$useState2 = React__default.useState({
13342
+ TODO: true,
13343
+ DRAFT: true,
13344
+ PUBLISHED: true,
13345
+ EXPIRED: false
13346
+ }),
13347
+ expandedSections = _React$useState2[0],
13348
+ setExpandedSections = _React$useState2[1];
13349
+ var filteredWarningsByExpandedSections = React__default.useMemo(function () {
13350
+ return filteredWarnings.filter(function (warning) {
13351
+ return warning.status && expandedSections[warning.status] || warning.productStatus && expandedSections[warning.productStatus];
13352
+ });
13353
+ }, [filteredWarnings, expandedSections]);
13354
+ var allFeatures = React__default.useMemo(function () {
13355
+ return filteredWarningsByExpandedSections.reduce(function (acc, warning) {
13356
+ var _warning$warningDetai;
13357
+ var features = warning == null || (_warning$warningDetai = warning.warningDetail.areas) == null ? void 0 : _warning$warningDetai.map(function (a) {
13358
+ return {
13359
+ id: warning.id + a.objectName,
13360
+ geoJSON: a.geoJSON
13361
+ };
13362
+ }).filter(function (a) {
13363
+ return a.geoJSON;
13364
+ });
13365
+ if ((features == null ? void 0 : features.length) > 0) {
13366
+ return [].concat(acc, features);
13367
+ }
13368
+ return acc;
13369
+ }, []);
13370
+ }, [filteredWarningsByExpandedSections]);
13371
+ useUpdateSharedData({
13372
+ features: allFeatures
13373
+ }, panelId);
12999
13374
  return jsxs(Fragment, {
13000
13375
  children: [jsx(PublicWarningList, {
13001
- warnings: combinedWarnings,
13376
+ warnings: filteredWarnings,
13377
+ expandedSections: expandedSections,
13378
+ setExpandedSections: setExpandedSections,
13002
13379
  isLoading: isLoading,
13003
13380
  error: error,
13004
13381
  onSelectWarning: selectWarning,
@@ -13012,6 +13389,7 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
13012
13389
  lastUpdatedTime: lastUpdatedTime,
13013
13390
  onRefetchWarnings: fetchWarnings,
13014
13391
  filters: filters,
13392
+ filterHookState: filterHookState,
13015
13393
  isAllChipSelected: isAllChipSelected,
13016
13394
  onClickAllChip: onClickAllChip
13017
13395
  }), confirmDialogOptions && jsx(ConfirmDeleteWarningDialog, {
@@ -13037,7 +13415,8 @@ var warningListViewPreset = {
13037
13415
  var PublicWarningApiWrapper = function PublicWarningApiWrapper(_ref) {
13038
13416
  var config = _ref.config,
13039
13417
  auth = _ref.auth,
13040
- onSetAuth = _ref.onSetAuth;
13418
+ onSetAuth = _ref.onSetAuth,
13419
+ panelId = _ref.panelId;
13041
13420
  return config ? jsx(ApiProvider, {
13042
13421
  config: {
13043
13422
  baseURL: config.baseURL,
@@ -13049,20 +13428,25 @@ var PublicWarningApiWrapper = function PublicWarningApiWrapper(_ref) {
13049
13428
  onSetAuth: onSetAuth,
13050
13429
  createApi: createApi$1,
13051
13430
  children: jsx(ErrorBoundary, {
13052
- children: jsx(PublicWarningListConnect, {})
13431
+ children: jsx(PublicWarningListConnect, {
13432
+ panelId: panelId
13433
+ })
13053
13434
  })
13054
13435
  }) : null;
13055
13436
  };
13056
13437
  var componentsLookUp = function componentsLookUp(payload, apiProps) {
13057
- var componentType = payload.componentType;
13438
+ var id = payload.id,
13439
+ componentType = payload.componentType;
13058
13440
  switch (componentType) {
13059
13441
  case warningListViewPreset.componentType:
13060
13442
  if (apiProps && apiProps.config) {
13061
13443
  return jsx(PublicWarningApiWrapper, Object.assign({}, apiProps, {
13444
+ panelId: id,
13062
13445
  "data-testid": "publicWarningModule"
13063
13446
  }));
13064
13447
  }
13065
13448
  return jsx(PublicWarningListConnect, {
13449
+ panelId: id,
13066
13450
  "data-testid": "publicWarningList"
13067
13451
  });
13068
13452
  default: