@opengeoweb/warnings 9.5.0 → 9.6.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
@@ -4,7 +4,7 @@ import { useDispatch, useSelector } from 'react-redux';
4
4
  import { Polygons, Share, ExitDomain, Edit, Delete, DrawPolygon, Visibility, Add, Wind, Fog, Lightning, Snow, Rain, TemperatureHigh, FunnelCloud, TemperatureLow, CoastalEvent, breakpoints, Options } from '@opengeoweb/theme';
5
5
  import { uiTypes, uiActions, getSingularDrawtoolDrawLayerId, drawtoolSelectors, layerSelectors, uiSelectors, drawtoolActions, mapStoreActions, layerActions, useSetupDialog } from '@opengeoweb/store';
6
6
  import { emptyGeoJSON, MapControlButton, getGeoJSONPropertyValue, getIcon, rewindGeometry, currentlySupportedDrawModes } from '@opengeoweb/webmap-react';
7
- import { useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, StatusTag, ErrorBoundary, isAxiosError } from '@opengeoweb/shared';
7
+ import { useConfirmationDialog, ToggleMenu, dateUtils, calculateStartSize, ToolContainerDraggable, AlertBanner, ConfirmationDialog, getAxiosErrorMessage, usePrevious, CustomIconButton, CustomTooltip, Avatar, getInitials, SwitchButton, LastUpdateTime, StatusTag, ErrorBoundary, isAxiosError } from '@opengeoweb/shared';
8
8
  import { createEntityAdapter, createSlice, createSelector } from '@reduxjs/toolkit';
9
9
  import { snackbarActions } from '@opengeoweb/snackbar';
10
10
  import { styled, Box, Typography, ListItem, Grid, Paper, ListItemButton, Stack, LinearProgress, Button, FormHelperText, MenuItem, Tabs, Tab, FormControl, Card, CardContent, ListItemIcon, CircularProgress, List } from '@mui/material';
@@ -14,6 +14,7 @@ import { getApi, createApiInstance, createNonAuthApiInstance, createFakeApiInsta
14
14
  import { ReactHookFormProvider, defaultFormOptions, ReactHookFormHiddenInput, isValidGeoJsonCoordinates, ReactHookFormSelect, ReactHookFormTextField, useDraftFormHelpers, errorMessages, ReactHookFormDateTime, isValidDate, isXHoursBefore, isXHoursAfter, isEmpty } from '@opengeoweb/form-fields';
15
15
  import { useFormContext } from 'react-hook-form';
16
16
  import { clamp } from 'lodash';
17
+ import { useAuthenticationContext } from '@opengeoweb/authentication';
17
18
  import { takeLatest, put, call, select } from 'redux-saga/effects';
18
19
  import { isAxiosError as isAxiosError$1 } from 'axios';
19
20
 
@@ -954,6 +955,7 @@ var DATE_FORMAT = 'dd/MM/yyyy HH:mm';
954
955
  var DATE_FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
955
956
  var DATE_FORMAT_HEADER = 'EEEE, MMMM dd';
956
957
  var DATE_FORMAT_DATE_FIELDS = 'DD/MM/YYYY HH:mm'; // TODO: should be 'ddd DD MMM HH:mm' https://gitlab.com/opengeoweb/opengeoweb/-/issues/4484
958
+ var DATE_FORMAT_LASTUPDATEDTIME = 'HH:mm';
957
959
 
958
960
  var DEFAULT_ADD_BUTTON_HEIGHT = 80;
959
961
  var OBJECT_ITEM_SIZE = 50;
@@ -1557,6 +1559,20 @@ var slice$1 = createSlice({
1557
1559
  draft.selectedPublicWarningId = publicWarning === null || publicWarning === void 0 ? void 0 : publicWarning.id;
1558
1560
  draft.formState = formState;
1559
1561
  },
1562
+ toggleEditorWarning: function toggleEditorWarning(draft,
1563
+ // eslint-disable-next-line no-unused-vars
1564
+ action) {
1565
+ draft.error = '';
1566
+ },
1567
+ toggleEditorWarningSuccess: function toggleEditorWarningSuccess(draft, action) {
1568
+ var _action$payload3 = action.payload,
1569
+ isEditor = _action$payload3.isEditor,
1570
+ username = _action$payload3.username;
1571
+ if (draft.publicWarning) {
1572
+ draft.publicWarning.editor = isEditor ? username : '';
1573
+ }
1574
+ draft.formState = isEditor ? '' : 'readonly';
1575
+ },
1560
1576
  // publish warning
1561
1577
  publishWarning: function publishWarning(draft,
1562
1578
  // eslint-disable-next-line no-unused-vars
@@ -1579,8 +1595,12 @@ var slice$1 = createSlice({
1579
1595
  draft.publicWarning = action.payload.publicWarning;
1580
1596
  },
1581
1597
  saveWarningSuccess: function saveWarningSuccess(draft, action) {
1598
+ var _a;
1582
1599
  var publicWarning = action.payload.publicWarning;
1583
1600
  draft.publicWarning = publicWarning;
1601
+ if ((_a = publicWarning === null || publicWarning === void 0 ? void 0 : publicWarning.warningDetail) === null || _a === void 0 ? void 0 : _a.id) {
1602
+ draft.selectedPublicWarningId = publicWarning.warningDetail.id;
1603
+ }
1584
1604
  draft.formState = '';
1585
1605
  },
1586
1606
  setFormError: function setFormError(draft, action) {
@@ -1595,9 +1615,9 @@ var slice$1 = createSlice({
1595
1615
  },
1596
1616
  extraReducers: function extraReducers(builder) {
1597
1617
  builder.addCase(uiActions.setToggleOpenDialog, function (draft, action) {
1598
- var _action$payload3 = action.payload,
1599
- type = _action$payload3.type,
1600
- setOpen = _action$payload3.setOpen;
1618
+ var _action$payload4 = action.payload,
1619
+ type = _action$payload4.type,
1620
+ setOpen = _action$payload4.setOpen;
1601
1621
  if (type === publicWarningDialogType && setOpen === false) {
1602
1622
  delete draft.object;
1603
1623
  delete draft.publicWarning;
@@ -1803,8 +1823,7 @@ var ObjectManagerConnect = function ObjectManagerConnect(_ref) {
1803
1823
  publicWarning: {
1804
1824
  warningDetail: {
1805
1825
  geoJSON: object.geoJSON
1806
- },
1807
- status: 'DRAFT'
1826
+ }
1808
1827
  }
1809
1828
  }));
1810
1829
  };
@@ -4657,13 +4676,14 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
4657
4676
  }, /*#__PURE__*/React.createElement(SwitchButton, {
4658
4677
  checked: !isReadOnly,
4659
4678
  onChange: onChangeMode
4660
- })), publicWarningEditor && ( /*#__PURE__*/React.createElement(Box, {
4679
+ })), /*#__PURE__*/React.createElement(Box, {
4661
4680
  sx: {
4662
4681
  position: 'relative',
4663
4682
  top: 3,
4664
- right: '-2px'
4683
+ right: '-2px',
4684
+ width: '16px'
4665
4685
  }
4666
- }, /*#__PURE__*/React.createElement(WarningAvatar, {
4686
+ }, publicWarningEditor && ( /*#__PURE__*/React.createElement(WarningAvatar, {
4667
4687
  editor: publicWarningEditor
4668
4688
  })))))
4669
4689
  }, {
@@ -5375,6 +5395,8 @@ var Form = function Form(_ref5) {
5375
5395
  publicWarningDetails = _ref5.publicWarningDetails,
5376
5396
  _ref5$error = _ref5.error,
5377
5397
  error = _ref5$error === void 0 ? '' : _ref5$error,
5398
+ _ref5$isReadOnly = _ref5.isReadOnly,
5399
+ isReadOnly = _ref5$isReadOnly === void 0 ? false : _ref5$isReadOnly,
5378
5400
  _ref5$onFormDirty = _ref5.onFormDirty,
5379
5401
  onFormDirty = _ref5$onFormDirty === void 0 ? function () {} : _ref5$onFormDirty;
5380
5402
  var _useFormContext = useFormContext(),
@@ -5386,7 +5408,6 @@ var Form = function Form(_ref5) {
5386
5408
  DraftFieldHelper = _useDraftFormHelpers.DraftFieldHelper;
5387
5409
  var isPublishing = formAction === 'publishing';
5388
5410
  var isSaving = formAction === 'saving';
5389
- var isReadOnly = formAction === 'readonly';
5390
5411
  var areFieldsDisabled = isPublishing || isSaving;
5391
5412
  useFormDirty({
5392
5413
  isDirty: isDirty,
@@ -5643,6 +5664,10 @@ var getPublicWarningStatus = createSelector(getPublicWarningStore, function (pub
5643
5664
  var _a;
5644
5665
  return (_a = publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.publicWarning) === null || _a === void 0 ? void 0 : _a.status;
5645
5666
  });
5667
+ var getPublicWarningEditor = createSelector(getPublicWarningStore, function (publicWarningStore) {
5668
+ var _a;
5669
+ return (_a = publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.publicWarning) === null || _a === void 0 ? void 0 : _a.editor;
5670
+ });
5646
5671
  var getPublicWarningFormState = createSelector(getPublicWarningStore, function (publicWarningStore) {
5647
5672
  return (publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.formState) || '';
5648
5673
  });
@@ -5685,6 +5710,12 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect() {
5685
5710
  var publicWarningFormError = useSelector(function (store) {
5686
5711
  return getPublicWarningFormError(store);
5687
5712
  });
5713
+ var publicWarningEditor = useSelector(function (store) {
5714
+ return getPublicWarningEditor(store);
5715
+ });
5716
+ var _useAuthenticationCon = useAuthenticationContext(),
5717
+ auth = _useAuthenticationCon.auth;
5718
+ var isEditor = publicWarningEditor === (auth === null || auth === void 0 ? void 0 : auth.username) || false;
5688
5719
  var dispatch = useDispatch();
5689
5720
  var publishForm = function publishForm(newFormValues) {
5690
5721
  dispatch(publicWarningFormActions.publishWarning({
@@ -5698,7 +5729,8 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect() {
5698
5729
  dispatch(publicWarningFormActions.saveWarning({
5699
5730
  publicWarning: {
5700
5731
  warningDetail: newFormValues,
5701
- status: 'DRAFT'
5732
+ status: 'DRAFT',
5733
+ editor: auth === null || auth === void 0 ? void 0 : auth.username
5702
5734
  }
5703
5735
  }));
5704
5736
  };
@@ -5707,12 +5739,15 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect() {
5707
5739
  isFormDirty: isFormDirty
5708
5740
  }));
5709
5741
  };
5742
+ // Readonly also in case you are not creating a new warning and you are not set as the editor
5743
+ var isReadOnly = publicWarningFormAction === 'readonly' || !isEditor && (publicWarning === null || publicWarning === void 0 ? void 0 : publicWarning.status) !== undefined;
5710
5744
  return /*#__PURE__*/React.createElement(PublicWarningsForm, {
5711
5745
  object: publicWarningObject,
5712
5746
  publicWarningDetails: publicWarning === null || publicWarning === void 0 ? void 0 : publicWarning.warningDetail,
5713
5747
  onPublishForm: publishForm,
5714
5748
  onSaveForm: saveForm,
5715
5749
  formAction: publicWarningFormAction,
5750
+ isReadOnly: isReadOnly,
5716
5751
  error: publicWarningFormError,
5717
5752
  onFormDirty: onFormDirty
5718
5753
  });
@@ -5725,11 +5760,15 @@ var warningFormConfirmationOptions = {
5725
5760
  confirmLabel: 'Close',
5726
5761
  catchOnCancel: true
5727
5762
  };
5763
+ var isAlreadyEdited = function isAlreadyEdited(publicWarningEditor, username) {
5764
+ return publicWarningEditor !== undefined && publicWarningEditor !== '' && publicWarningEditor !== null && publicWarningEditor !== username;
5765
+ };
5728
5766
  var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_ref) {
5729
5767
  var bounds = _ref.bounds,
5730
5768
  _ref$source = _ref.source,
5731
5769
  source = _ref$source === void 0 ? 'app' : _ref$source,
5732
5770
  startPosition = _ref.startPosition;
5771
+ var warningsApi = getWarningsApi();
5733
5772
  var _useSetupDialog = useSetupDialog(publicWarningDialogType, source),
5734
5773
  dialogOrder = _useSetupDialog.dialogOrder,
5735
5774
  setDialogOrder = _useSetupDialog.setDialogOrder,
@@ -5739,11 +5778,6 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
5739
5778
  uiIsLoading = _useSetupDialog.uiIsLoading;
5740
5779
  var dispatch = useDispatch();
5741
5780
  var confirmDialog = useConfirmationDialog();
5742
- var onChangeFormMode = function onChangeFormMode(isChecked) {
5743
- dispatch(publicWarningFormActions.setFormValues({
5744
- formState: !isChecked ? '' : 'readonly'
5745
- }));
5746
- };
5747
5781
  var formAction = useSelector(function (store) {
5748
5782
  return getPublicWarningFormState(store);
5749
5783
  });
@@ -5753,43 +5787,157 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
5753
5787
  var publicWarningStatus = useSelector(function (store) {
5754
5788
  return getPublicWarningStatus(store);
5755
5789
  });
5756
- var closeDialog = function closeDialog() {
5790
+ var selectedWarningId = useSelector(function (store) {
5791
+ return getSelectedPublicWarningId(store);
5792
+ });
5793
+ var publicWarningEditor = useSelector(function (store) {
5794
+ return getPublicWarningEditor(store);
5795
+ });
5796
+ var _useAuthenticationCon = useAuthenticationContext(),
5797
+ auth = _useAuthenticationCon.auth;
5798
+ var isEditor = publicWarningEditor === (auth === null || auth === void 0 ? void 0 : auth.username) || false;
5799
+ var getLatestEditor = function getLatestEditor() {
5757
5800
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5758
- var mayProceed;
5801
+ var latestWarnings, latestWarning;
5759
5802
  return _regeneratorRuntime().wrap(function _callee$(_context) {
5760
5803
  while (1) switch (_context.prev = _context.next) {
5804
+ case 0:
5805
+ _context.next = 2;
5806
+ return warningsApi.getWarnings();
5807
+ case 2:
5808
+ latestWarnings = _context.sent;
5809
+ latestWarning = latestWarnings.data.find(function (warning) {
5810
+ return warning.id === selectedWarningId;
5811
+ });
5812
+ return _context.abrupt("return", latestWarning.editor || '');
5813
+ case 5:
5814
+ case "end":
5815
+ return _context.stop();
5816
+ }
5817
+ }, _callee);
5818
+ }));
5819
+ };
5820
+ var setIsEditor = function setIsEditor(isReadOnly) {
5821
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
5822
+ var username, latestEditor;
5823
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
5824
+ while (1) switch (_context2.prev = _context2.next) {
5825
+ case 0:
5826
+ username = (auth === null || auth === void 0 ? void 0 : auth.username) || ''; // make sure to get the latest changes if you are editing an existing warning
5827
+ if (!selectedWarningId) {
5828
+ _context2.next = 7;
5829
+ break;
5830
+ }
5831
+ _context2.next = 4;
5832
+ return getLatestEditor();
5833
+ case 4:
5834
+ _context2.t0 = _context2.sent;
5835
+ _context2.next = 8;
5836
+ break;
5837
+ case 7:
5838
+ _context2.t0 = '';
5839
+ case 8:
5840
+ latestEditor = _context2.t0;
5841
+ if (!(!selectedWarningId || !isReadOnly && username === latestEditor || isReadOnly && latestEditor !== username)) {
5842
+ _context2.next = 12;
5843
+ break;
5844
+ }
5845
+ // currently editing a new warning or
5846
+ // correct editor is already set or
5847
+ // someone else is editor so only have to set to readonly mode
5848
+ // No need for a BE call
5849
+ dispatch(publicWarningFormActions.setFormValues({
5850
+ formState: isReadOnly ? 'readonly' : ''
5851
+ }));
5852
+ return _context2.abrupt("return", true);
5853
+ case 12:
5854
+ if (!(!isReadOnly && isAlreadyEdited(latestEditor, username))) {
5855
+ _context2.next = 15;
5856
+ break;
5857
+ }
5858
+ _context2.next = 15;
5859
+ return confirmDialog({
5860
+ title: 'Switch to edit mode',
5861
+ description: 'This warning is already in edit mode by another user and important information could get lost in the switching process.',
5862
+ confirmLabel: 'Edit mode'
5863
+ });
5864
+ case 15:
5865
+ dispatch(publicWarningFormActions.toggleEditorWarning({
5866
+ warningId: selectedWarningId,
5867
+ isEditor: !isReadOnly,
5868
+ username: username
5869
+ }));
5870
+ return _context2.abrupt("return", true);
5871
+ case 17:
5872
+ case "end":
5873
+ return _context2.stop();
5874
+ }
5875
+ }, _callee2);
5876
+ }));
5877
+ };
5878
+ var onChangeFormMode = function onChangeFormMode(isReadOnly) {
5879
+ if (isReadOnly && isFormDirty) {
5880
+ confirmDialog({
5881
+ title: 'Whoops',
5882
+ description: 'Are you sure you want to switch to view mode? Your unsaved changes will be lost.',
5883
+ confirmLabel: 'Switch mode'
5884
+ }).then(function () {
5885
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
5886
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
5887
+ while (1) switch (_context3.prev = _context3.next) {
5888
+ case 0:
5889
+ _context3.next = 2;
5890
+ return setIsEditor(isReadOnly);
5891
+ case 2:
5892
+ case "end":
5893
+ return _context3.stop();
5894
+ }
5895
+ }, _callee3);
5896
+ }));
5897
+ });
5898
+ } else {
5899
+ setIsEditor(isReadOnly);
5900
+ }
5901
+ };
5902
+ var closeDialog = function closeDialog() {
5903
+ return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
5904
+ var mayProceed;
5905
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
5906
+ while (1) switch (_context4.prev = _context4.next) {
5761
5907
  case 0:
5762
5908
  if (!isFormDirty) {
5763
- _context.next = 6;
5909
+ _context4.next = 6;
5764
5910
  break;
5765
5911
  }
5766
- _context.next = 3;
5912
+ _context4.next = 3;
5767
5913
  return confirmDialog(warningFormConfirmationOptions).then(function () {
5768
5914
  return true;
5769
5915
  })["catch"](function () {
5770
5916
  return false;
5771
5917
  });
5772
5918
  case 3:
5773
- mayProceed = _context.sent;
5919
+ mayProceed = _context4.sent;
5774
5920
  if (mayProceed) {
5775
- _context.next = 6;
5921
+ _context4.next = 6;
5776
5922
  break;
5777
5923
  }
5778
- return _context.abrupt("return");
5924
+ return _context4.abrupt("return");
5779
5925
  case 6:
5780
5926
  onCloseDialog();
5781
5927
  case 7:
5782
5928
  case "end":
5783
- return _context.stop();
5929
+ return _context4.stop();
5784
5930
  }
5785
- }, _callee);
5931
+ }, _callee4);
5786
5932
  }));
5787
5933
  };
5788
5934
  if (!isDialogOpen) {
5789
5935
  return null;
5790
5936
  }
5791
- var isReadOnly = formAction === 'readonly';
5792
- var shouldHideFormToggleMode = publicWarningStatus !== undefined && publicWarningStatus !== 'DRAFT';
5937
+ // Readonly also in case you are not creating a new warning and you are not set as the editor
5938
+ var isReadOnly = formAction === 'readonly' || !isEditor && publicWarningStatus !== undefined;
5939
+ // Only show toggle if in draft status
5940
+ var shouldHideFormToggleMode = publicWarningStatus !== 'DRAFT';
5793
5941
  return /*#__PURE__*/React__default.createElement(PublicWarningsFormDialog, {
5794
5942
  isOpen: isDialogOpen,
5795
5943
  onClose: closeDialog,
@@ -5801,7 +5949,8 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
5801
5949
  isLoading: uiIsLoading,
5802
5950
  isReadOnly: isReadOnly,
5803
5951
  onChangeFormMode: onChangeFormMode,
5804
- shouldHideFormMode: shouldHideFormToggleMode
5952
+ shouldHideFormMode: shouldHideFormToggleMode,
5953
+ publicWarningEditor: publicWarningEditor
5805
5954
  }, /*#__PURE__*/React__default.createElement(PublicWarningsFormConnect, null));
5806
5955
  };
5807
5956
 
@@ -6070,6 +6219,9 @@ var PublicWarningList = function PublicWarningList(_ref2) {
6070
6219
  _ref2$isLoading = _ref2.isLoading,
6071
6220
  isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading,
6072
6221
  error = _ref2.error,
6222
+ _ref2$selectedPublicW = _ref2.selectedPublicWarningId,
6223
+ selectedPublicWarningId = _ref2$selectedPublicW === void 0 ? '' : _ref2$selectedPublicW,
6224
+ lastUpdatedTime = _ref2.lastUpdatedTime,
6073
6225
  _ref2$onSelectWarning = _ref2.onSelectWarning,
6074
6226
  onSelectWarning = _ref2$onSelectWarning === void 0 ? function () {} : _ref2$onSelectWarning,
6075
6227
  _ref2$onEditWarning = _ref2.onEditWarning,
@@ -6078,8 +6230,8 @@ var PublicWarningList = function PublicWarningList(_ref2) {
6078
6230
  onCreateWarning = _ref2$onCreateWarning === void 0 ? function () {} : _ref2$onCreateWarning,
6079
6231
  _ref2$onDeleteWarning = _ref2.onDeleteWarning,
6080
6232
  onDeleteWarning = _ref2$onDeleteWarning === void 0 ? function () {} : _ref2$onDeleteWarning,
6081
- _ref2$selectedPublicW = _ref2.selectedPublicWarningId,
6082
- selectedPublicWarningId = _ref2$selectedPublicW === void 0 ? '' : _ref2$selectedPublicW;
6233
+ _ref2$onRefetchWarnin = _ref2.onRefetchWarnings,
6234
+ onRefetchWarnings = _ref2$onRefetchWarnin === void 0 ? function () {} : _ref2$onRefetchWarnin;
6083
6235
  var sortedWarnings = warnings ? sortWarningsOnStatus(warnings) : null;
6084
6236
  return /*#__PURE__*/React__default.createElement(Box, {
6085
6237
  sx: {
@@ -6106,7 +6258,17 @@ var PublicWarningList = function PublicWarningList(_ref2) {
6106
6258
  }), isLoading && ( /*#__PURE__*/React__default.createElement(LinearProgress, {
6107
6259
  "data-testid": "loading-bar",
6108
6260
  color: "secondary"
6109
- })), sortedWarnings && !error && ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(WarningsOnStatus, {
6261
+ })), lastUpdatedTime && ( /*#__PURE__*/React__default.createElement(Box, {
6262
+ sx: {
6263
+ marginBottom: -3.25,
6264
+ button: {
6265
+ marginRight: 0
6266
+ }
6267
+ }
6268
+ }, /*#__PURE__*/React__default.createElement(LastUpdateTime, {
6269
+ onPressRefresh: onRefetchWarnings,
6270
+ lastUpdateTime: lastUpdatedTime
6271
+ }))), sortedWarnings && !error && ( /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(WarningsOnStatus, {
6110
6272
  status: "TODO",
6111
6273
  warnings: sortedWarnings.todo,
6112
6274
  onSelectWarning: onSelectWarning,
@@ -6160,7 +6322,8 @@ var publicWarningsAdapter = createEntityAdapter({
6160
6322
  });
6161
6323
  var initialState = {
6162
6324
  warnings: publicWarningsAdapter.getInitialState(),
6163
- isLoading: true
6325
+ isLoading: true,
6326
+ lastUpdatedTime: ''
6164
6327
  };
6165
6328
  var slice = createSlice({
6166
6329
  initialState: initialState,
@@ -6171,8 +6334,11 @@ var slice = createSlice({
6171
6334
  delete draft.error;
6172
6335
  },
6173
6336
  fetchWarningsSuccess: function fetchWarningsSuccess(draft, action) {
6174
- var warnings = action.payload.warnings;
6337
+ var _action$payload = action.payload,
6338
+ warnings = _action$payload.warnings,
6339
+ lastUpdatedTime = _action$payload.lastUpdatedTime;
6175
6340
  draft.isLoading = false;
6341
+ draft.lastUpdatedTime = lastUpdatedTime;
6176
6342
  publicWarningsAdapter.setAll(draft.warnings, warnings);
6177
6343
  },
6178
6344
  fetchWarningsError: function fetchWarningsError(draft, action) {
@@ -6221,6 +6387,9 @@ var isPublicWarningsLoading = createSelector(getPublicWarningsStore, function (s
6221
6387
  var getPublicWarningsError = createSelector(getPublicWarningsStore, function (store) {
6222
6388
  return store === null || store === void 0 ? void 0 : store.error;
6223
6389
  });
6390
+ var getPublicWarningsLastUpdatedTime = createSelector(getPublicWarningsStore, function (store) {
6391
+ return store === null || store === void 0 ? void 0 : store.lastUpdatedTime;
6392
+ });
6224
6393
 
6225
6394
  var DELETE_TITLE = 'Delete warning';
6226
6395
  var DELETE_CONFIRM = 'Delete';
@@ -6321,6 +6490,9 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
6321
6490
  var isFormDirty = useSelector(function (store) {
6322
6491
  return getSelectedPublicIsFormDirty(store);
6323
6492
  });
6493
+ var lastUpdatedTime = useSelector(function (store) {
6494
+ return getPublicWarningsLastUpdatedTime(store);
6495
+ });
6324
6496
  var openPublicWarningDialog = function openPublicWarningDialog(formAction, publicWarning) {
6325
6497
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6326
6498
  var mayProceed;
@@ -6385,12 +6557,15 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
6385
6557
  }));
6386
6558
  }
6387
6559
  openSnackbar(DELETE_WARNING_SUCCESS_MESSAGE);
6388
- dispatch(publicWarningActions.fetchWarnings());
6560
+ fetchWarnings();
6389
6561
  };
6390
- React__default.useEffect(function () {
6391
- // fetch warnings on mount
6562
+ var fetchWarnings = React__default.useCallback(function () {
6392
6563
  dispatch(publicWarningActions.fetchWarnings());
6393
6564
  }, [dispatch]);
6565
+ React__default.useEffect(function () {
6566
+ // fetch warnings on mount
6567
+ fetchWarnings();
6568
+ }, [fetchWarnings]);
6394
6569
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PublicWarningList, {
6395
6570
  warnings: warnings,
6396
6571
  isLoading: isLoading,
@@ -6399,7 +6574,9 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
6399
6574
  onCreateWarning: createWarning,
6400
6575
  onEditWarning: editWarning,
6401
6576
  onDeleteWarning: deleteWarning,
6402
- selectedPublicWarningId: selectedPublicWarningId
6577
+ selectedPublicWarningId: selectedPublicWarningId,
6578
+ lastUpdatedTime: lastUpdatedTime,
6579
+ onRefetchWarnings: fetchWarnings
6403
6580
  }), confirmDeleteWarning && ( /*#__PURE__*/React__default.createElement(ConfirmDeleteWarningDialog, {
6404
6581
  warningId: confirmDeleteWarning,
6405
6582
  onDeleteSucces: onDeleteSuccess,
@@ -6605,43 +6782,53 @@ function saveOrUpdateWarning(publicWarning) {
6605
6782
  }
6606
6783
  }, _marked$1);
6607
6784
  }
6608
- function publishWarningSaga(_ref) {
6785
+ var getToggleEditorSuccessMessage = function getToggleEditorSuccessMessage(isEditor) {
6786
+ return "You are now ".concat(isEditor ? '' : 'no longer ', "the editor for this warning");
6787
+ };
6788
+ function toggleEditorWarningSaga(_ref) {
6609
6789
  var payload = _ref.payload;
6610
6790
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6611
- var publicWarning, publishedWarning;
6791
+ var warningId, isEditor, username, warningsApi;
6612
6792
  return _regeneratorRuntime().wrap(function _callee$(_context2) {
6613
6793
  while (1) switch (_context2.prev = _context2.next) {
6614
6794
  case 0:
6615
6795
  _context2.prev = 0;
6616
- publicWarning = payload.publicWarning;
6796
+ warningId = payload.warningId, isEditor = payload.isEditor, username = payload.username;
6617
6797
  _context2.next = 4;
6618
- return call(saveOrUpdateWarning, publicWarning);
6798
+ return call(getWarningsApi);
6619
6799
  case 4:
6620
- publishedWarning = _context2.sent;
6800
+ warningsApi = _context2.sent;
6621
6801
  _context2.next = 7;
6622
- return put(publicWarningFormActions.publishWarningSuccess({
6623
- publicWarning: publishedWarning,
6624
- message: PUBLISH_SUCCES
6625
- }));
6802
+ return call(warningsApi.toggleEditorWarning, warningId, isEditor);
6626
6803
  case 7:
6627
- _context2.next = 13;
6628
- break;
6804
+ _context2.next = 9;
6805
+ return put(publicWarningActions.fetchWarnings);
6629
6806
  case 9:
6630
- _context2.prev = 9;
6807
+ _context2.next = 11;
6808
+ return put(publicWarningFormActions.toggleEditorWarningSuccess({
6809
+ isEditor: isEditor,
6810
+ username: username,
6811
+ message: getToggleEditorSuccessMessage(isEditor)
6812
+ }));
6813
+ case 11:
6814
+ _context2.next = 17;
6815
+ break;
6816
+ case 13:
6817
+ _context2.prev = 13;
6631
6818
  _context2.t0 = _context2["catch"](0);
6632
- _context2.next = 13;
6819
+ _context2.next = 17;
6633
6820
  return call(errorSaga, getErrorMessage(_context2.t0));
6634
- case 13:
6821
+ case 17:
6635
6822
  case "end":
6636
6823
  return _context2.stop();
6637
6824
  }
6638
- }, _callee, null, [[0, 9]]);
6825
+ }, _callee, null, [[0, 13]]);
6639
6826
  })();
6640
6827
  }
6641
- function saveWarningSaga(_ref2) {
6828
+ function publishWarningSaga(_ref2) {
6642
6829
  var payload = _ref2.payload;
6643
6830
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
6644
- var publicWarning, savedWarning;
6831
+ var publicWarning, publishedWarning;
6645
6832
  return _regeneratorRuntime().wrap(function _callee2$(_context3) {
6646
6833
  while (1) switch (_context3.prev = _context3.next) {
6647
6834
  case 0:
@@ -6650,11 +6837,11 @@ function saveWarningSaga(_ref2) {
6650
6837
  _context3.next = 4;
6651
6838
  return call(saveOrUpdateWarning, publicWarning);
6652
6839
  case 4:
6653
- savedWarning = _context3.sent;
6840
+ publishedWarning = _context3.sent;
6654
6841
  _context3.next = 7;
6655
- return put(publicWarningFormActions.saveWarningSuccess({
6656
- publicWarning: savedWarning,
6657
- message: SAVE_SUCCES
6842
+ return put(publicWarningFormActions.publishWarningSuccess({
6843
+ publicWarning: publishedWarning,
6844
+ message: PUBLISH_SUCCES
6658
6845
  }));
6659
6846
  case 7:
6660
6847
  _context3.next = 13;
@@ -6671,105 +6858,141 @@ function saveWarningSaga(_ref2) {
6671
6858
  }, _callee2, null, [[0, 9]]);
6672
6859
  })();
6673
6860
  }
6674
- function successSaga(_ref3) {
6861
+ function saveWarningSaga(_ref3) {
6675
6862
  var payload = _ref3.payload;
6676
6863
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
6677
- var message;
6864
+ var publicWarning, savedWarning;
6678
6865
  return _regeneratorRuntime().wrap(function _callee3$(_context4) {
6679
6866
  while (1) switch (_context4.prev = _context4.next) {
6867
+ case 0:
6868
+ _context4.prev = 0;
6869
+ publicWarning = payload.publicWarning;
6870
+ _context4.next = 4;
6871
+ return call(saveOrUpdateWarning, publicWarning);
6872
+ case 4:
6873
+ savedWarning = _context4.sent;
6874
+ _context4.next = 7;
6875
+ return put(publicWarningFormActions.saveWarningSuccess({
6876
+ publicWarning: savedWarning,
6877
+ message: SAVE_SUCCES
6878
+ }));
6879
+ case 7:
6880
+ _context4.next = 13;
6881
+ break;
6882
+ case 9:
6883
+ _context4.prev = 9;
6884
+ _context4.t0 = _context4["catch"](0);
6885
+ _context4.next = 13;
6886
+ return call(errorSaga, getErrorMessage(_context4.t0));
6887
+ case 13:
6888
+ case "end":
6889
+ return _context4.stop();
6890
+ }
6891
+ }, _callee3, null, [[0, 9]]);
6892
+ })();
6893
+ }
6894
+ function successSaga(_ref4) {
6895
+ var payload = _ref4.payload;
6896
+ return /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
6897
+ var message;
6898
+ return _regeneratorRuntime().wrap(function _callee4$(_context5) {
6899
+ while (1) switch (_context5.prev = _context5.next) {
6680
6900
  case 0:
6681
6901
  message = payload.message;
6682
- _context4.next = 3;
6902
+ _context5.next = 3;
6683
6903
  return put(snackbarActions.openSnackbar({
6684
6904
  message: message
6685
6905
  }));
6686
6906
  case 3:
6687
- _context4.next = 5;
6907
+ _context5.next = 5;
6688
6908
  return call(toggleDialogLoadingSaga, false);
6689
6909
  case 5:
6690
6910
  case "end":
6691
- return _context4.stop();
6911
+ return _context5.stop();
6692
6912
  }
6693
- }, _callee3);
6913
+ }, _callee4);
6694
6914
  })();
6695
6915
  }
6696
6916
  function errorSaga(message) {
6697
- return _regeneratorRuntime().wrap(function errorSaga$(_context5) {
6698
- while (1) switch (_context5.prev = _context5.next) {
6917
+ return _regeneratorRuntime().wrap(function errorSaga$(_context6) {
6918
+ while (1) switch (_context6.prev = _context6.next) {
6699
6919
  case 0:
6700
- _context5.next = 2;
6920
+ _context6.next = 2;
6701
6921
  return put(publicWarningFormActions.setFormError({
6702
6922
  error: message
6703
6923
  }));
6704
6924
  case 2:
6705
- _context5.next = 4;
6925
+ _context6.next = 4;
6706
6926
  return call(toggleDialogLoadingSaga, false);
6707
6927
  case 4:
6708
6928
  case "end":
6709
- return _context5.stop();
6929
+ return _context6.stop();
6710
6930
  }
6711
6931
  }, _marked2$1);
6712
6932
  }
6713
6933
  function toggleDialogLoadingSaga(isLoading) {
6714
6934
  var isDialogOpen;
6715
- return _regeneratorRuntime().wrap(function toggleDialogLoadingSaga$(_context6) {
6716
- while (1) switch (_context6.prev = _context6.next) {
6935
+ return _regeneratorRuntime().wrap(function toggleDialogLoadingSaga$(_context7) {
6936
+ while (1) switch (_context7.prev = _context7.next) {
6717
6937
  case 0:
6718
- _context6.next = 2;
6938
+ _context7.next = 2;
6719
6939
  return select(uiSelectors.getDialogDetailsByType, publicWarningDialogType);
6720
6940
  case 2:
6721
- isDialogOpen = _context6.sent;
6941
+ isDialogOpen = _context7.sent;
6722
6942
  if (!isDialogOpen) {
6723
- _context6.next = 6;
6943
+ _context7.next = 6;
6724
6944
  break;
6725
6945
  }
6726
- _context6.next = 6;
6946
+ _context7.next = 6;
6727
6947
  return put(uiActions.toggleIsLoadingDialog({
6728
6948
  isLoading: isLoading,
6729
6949
  type: publicWarningDialogType
6730
6950
  }));
6731
6951
  case 6:
6732
6952
  case "end":
6733
- return _context6.stop();
6953
+ return _context7.stop();
6734
6954
  }
6735
6955
  }, _marked3$1);
6736
6956
  }
6737
6957
  function openDialogSaga() {
6738
- return _regeneratorRuntime().wrap(function openDialogSaga$(_context7) {
6739
- while (1) switch (_context7.prev = _context7.next) {
6958
+ return _regeneratorRuntime().wrap(function openDialogSaga$(_context8) {
6959
+ while (1) switch (_context8.prev = _context8.next) {
6740
6960
  case 0:
6741
- _context7.next = 2;
6961
+ _context8.next = 2;
6742
6962
  return put(uiActions.setToggleOpenDialog({
6743
6963
  setOpen: true,
6744
6964
  type: publicWarningDialogType
6745
6965
  }));
6746
6966
  case 2:
6747
6967
  case "end":
6748
- return _context7.stop();
6968
+ return _context8.stop();
6749
6969
  }
6750
6970
  }, _marked4);
6751
6971
  }
6752
6972
  function publicWarningRootSaga() {
6753
- return _regeneratorRuntime().wrap(function publicWarningRootSaga$(_context8) {
6754
- while (1) switch (_context8.prev = _context8.next) {
6973
+ return _regeneratorRuntime().wrap(function publicWarningRootSaga$(_context9) {
6974
+ while (1) switch (_context9.prev = _context9.next) {
6755
6975
  case 0:
6756
- _context8.next = 2;
6757
- return takeLatest(publicWarningFormActions.publishWarning, publishWarningSaga);
6976
+ _context9.next = 2;
6977
+ return takeLatest(publicWarningFormActions.toggleEditorWarning, toggleEditorWarningSaga);
6758
6978
  case 2:
6759
- _context8.next = 4;
6760
- return takeLatest(publicWarningFormActions.saveWarning, saveWarningSaga);
6979
+ _context9.next = 4;
6980
+ return takeLatest(publicWarningFormActions.publishWarning, publishWarningSaga);
6761
6981
  case 4:
6762
- _context8.next = 6;
6763
- return takeLatest([publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess], successSaga);
6982
+ _context9.next = 6;
6983
+ return takeLatest(publicWarningFormActions.saveWarning, saveWarningSaga);
6764
6984
  case 6:
6765
- _context8.next = 8;
6766
- return takeLatest([publicWarningFormActions.publishWarning, publicWarningFormActions.saveWarning], toggleDialogLoadingSaga, true);
6985
+ _context9.next = 8;
6986
+ return takeLatest([publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess, publicWarningFormActions.toggleEditorWarningSuccess], successSaga);
6767
6987
  case 8:
6768
- _context8.next = 10;
6769
- return takeLatest(publicWarningFormActions.openPublicWarningFormDialog, openDialogSaga);
6988
+ _context9.next = 10;
6989
+ return takeLatest([publicWarningFormActions.publishWarning, publicWarningFormActions.saveWarning], toggleDialogLoadingSaga, true);
6770
6990
  case 10:
6991
+ _context9.next = 12;
6992
+ return takeLatest(publicWarningFormActions.openPublicWarningFormDialog, openDialogSaga);
6993
+ case 12:
6771
6994
  case "end":
6772
- return _context8.stop();
6995
+ return _context9.stop();
6773
6996
  }
6774
6997
  }, _marked5);
6775
6998
  }
@@ -6777,8 +7000,11 @@ function publicWarningRootSaga() {
6777
7000
  var _marked = /*#__PURE__*/_regeneratorRuntime().mark(fetchWarningsSaga),
6778
7001
  _marked2 = /*#__PURE__*/_regeneratorRuntime().mark(refetchWarnings),
6779
7002
  _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(publicWarnings);
7003
+ var getLastUpdatedTimeFormatted = function getLastUpdatedTimeFormatted() {
7004
+ return dateUtils.dateToString(dateUtils.utc(), DATE_FORMAT_LASTUPDATEDTIME);
7005
+ };
6780
7006
  function fetchWarningsSaga() {
6781
- var warningsApi, _yield$call, warnings;
7007
+ var warningsApi, _yield$call, warnings, lastUpdatedTime;
6782
7008
  return _regeneratorRuntime().wrap(function fetchWarningsSaga$(_context) {
6783
7009
  while (1) switch (_context.prev = _context.next) {
6784
7010
  case 0:
@@ -6792,28 +7018,30 @@ function fetchWarningsSaga() {
6792
7018
  case 6:
6793
7019
  _yield$call = _context.sent;
6794
7020
  warnings = _yield$call.data;
6795
- _context.next = 10;
7021
+ lastUpdatedTime = getLastUpdatedTimeFormatted();
7022
+ _context.next = 11;
6796
7023
  return put(publicWarningActions.fetchWarningsSuccess({
6797
- warnings: warnings
7024
+ warnings: warnings,
7025
+ lastUpdatedTime: lastUpdatedTime
6798
7026
  }));
6799
- case 10:
6800
- _context.next = 16;
7027
+ case 11:
7028
+ _context.next = 17;
6801
7029
  break;
6802
- case 12:
6803
- _context.prev = 12;
7030
+ case 13:
7031
+ _context.prev = 13;
6804
7032
  _context.t0 = _context["catch"](0);
6805
- _context.next = 16;
7033
+ _context.next = 17;
6806
7034
  return put(publicWarningActions.fetchWarningsError({
6807
7035
  error: {
6808
7036
  name: _context.t0.name,
6809
7037
  message: _context.t0.message
6810
7038
  }
6811
7039
  }));
6812
- case 16:
7040
+ case 17:
6813
7041
  case "end":
6814
7042
  return _context.stop();
6815
7043
  }
6816
- }, _marked, null, [[0, 12]]);
7044
+ }, _marked, null, [[0, 13]]);
6817
7045
  }
6818
7046
  function refetchWarnings() {
6819
7047
  return _regeneratorRuntime().wrap(function refetchWarnings$(_context2) {
@@ -6869,4 +7097,4 @@ var drawingModuleConfig = {
6869
7097
  sagas: [drawingSaga, publicWarningRootSaga, publicWarnings]
6870
7098
  };
6871
7099
 
6872
- export { DIALOG_TITLE, DrawingToolConnect, Wrapper as DrawingToolForm, DrawingToolFormConnect, DrawingToolMapButtonConnect, ObjectManagerConnect, ObjectManagerMapButtonConnect, PublicWarningApiWrapper, PublicWarningsFormDialog, PublicWarningsFormDialogConnect, WarningsModuleProvider, componentsLookUp, drawingModuleConfig, useObjectDrawDialogAction, warningFormConfirmationOptions };
7100
+ export { DIALOG_TITLE, DrawingToolConnect, Wrapper as DrawingToolForm, DrawingToolFormConnect, DrawingToolMapButtonConnect, ObjectManagerConnect, ObjectManagerMapButtonConnect, PublicWarningApiWrapper, PublicWarningsFormDialog, PublicWarningsFormDialogConnect, WarningsModuleProvider, componentsLookUp, drawingModuleConfig, isAlreadyEdited, useObjectDrawDialogAction, warningFormConfirmationOptions };
package/package.json CHANGED
@@ -1,13 +1,37 @@
1
1
  {
2
2
  "name": "@opengeoweb/warnings",
3
- "version": "9.5.0",
3
+ "version": "9.6.0",
4
4
  "description": "GeoWeb warinings library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
9
  },
10
- "dependencies": {},
10
+ "dependencies": {
11
+ "@opengeoweb/api": "*",
12
+ "@redux-eggs/redux-toolkit": "^2.2.0",
13
+ "@opengeoweb/shared": "*",
14
+ "@opengeoweb/store": "*",
15
+ "@opengeoweb/webmap-react": "*",
16
+ "react-redux": "^8.1.3",
17
+ "@mui/material": "5.12.0",
18
+ "@opengeoweb/theme": "*",
19
+ "@opengeoweb/form-fields": "*",
20
+ "react-hook-form": "7.47.0",
21
+ "lodash": "^4.17.21",
22
+ "redux-saga": "^1.2.3",
23
+ "@reduxjs/toolkit": "^1.9.7",
24
+ "@opengeoweb/snackbar": "*",
25
+ "react-window": "^1.8.10",
26
+ "react-virtualized-auto-sizer": "^1.0.20",
27
+ "axios": "1.5.0",
28
+ "@opengeoweb/core": "*",
29
+ "@opengeoweb/webmap": "*",
30
+ "@opengeoweb/authentication": "*"
31
+ },
32
+ "peerDependencies": {
33
+ "react": "18"
34
+ },
11
35
  "module": "./index.esm.js",
12
36
  "type": "module",
13
37
  "main": "./index.esm.js"
@@ -15,10 +15,12 @@ export declare const PublicWarningList: React.FC<{
15
15
  warnings: PublicWarning[];
16
16
  isLoading?: boolean;
17
17
  error?: Error;
18
+ selectedPublicWarningId?: string;
19
+ lastUpdatedTime?: string;
18
20
  onSelectWarning?: (warning: PublicWarning) => void;
19
21
  onEditWarning?: (warning: PublicWarning) => void;
20
22
  onCreateWarning?: () => void;
21
23
  onDeleteWarning?: (warningId: string) => void;
22
- selectedPublicWarningId?: string;
24
+ onRefetchWarnings?: () => void;
23
25
  }>;
24
26
  export default PublicWarningList;
@@ -23,6 +23,7 @@ interface FormProps {
23
23
  object?: DrawingListItem;
24
24
  publicWarningDetails?: PublicWarningDetail;
25
25
  error?: string;
26
+ isReadOnly?: boolean;
26
27
  onFormDirty?: (isFormDirty: boolean) => void;
27
28
  }
28
29
  export declare const PublicWarningsForm: React.FC<FormProps>;
@@ -8,6 +8,7 @@ export declare const warningFormConfirmationOptions: {
8
8
  confirmLabel: string;
9
9
  catchOnCancel: boolean;
10
10
  };
11
+ export declare const isAlreadyEdited: (publicWarningEditor: string | undefined, username: string | undefined) => boolean;
11
12
  export declare const PublicWarningsFormDialogConnect: React.FC<{
12
13
  bounds?: string;
13
14
  source?: uiTypes.Source;
@@ -23,6 +23,16 @@ export declare const publicWarningFormActions: import("@reduxjs/toolkit").CaseRe
23
23
  formState?: FormAction;
24
24
  publicWarning?: PublicWarning;
25
25
  }>) => void;
26
+ toggleEditorWarning: (draft: Draft<PublicWarningFormState>, action: PayloadAction<{
27
+ warningId: string;
28
+ isEditor: boolean;
29
+ username: string;
30
+ }>) => void;
31
+ toggleEditorWarningSuccess: (draft: Draft<PublicWarningFormState>, action: PayloadAction<{
32
+ isEditor: boolean;
33
+ username: string;
34
+ message: string;
35
+ }>) => void;
26
36
  publishWarning: (draft: Draft<PublicWarningFormState>, action: PayloadAction<{
27
37
  publicWarning: PublicWarning;
28
38
  }>) => void;
@@ -4,6 +4,8 @@ import { PublicWarning } from './types';
4
4
  export declare const PUBLISH_SUCCES = "Public warning has succesfully been published!";
5
5
  export declare const SAVE_SUCCES = "Public warning has succesfully been saved!";
6
6
  export declare function saveOrUpdateWarning(publicWarning: PublicWarning): SagaIterator<PublicWarning>;
7
+ export declare const getToggleEditorSuccessMessage: (isEditor: boolean) => string;
8
+ export declare function toggleEditorWarningSaga({ payload, }: ReturnType<typeof publicWarningFormActions.toggleEditorWarning>): SagaIterator;
7
9
  export declare function publishWarningSaga({ payload, }: ReturnType<typeof publicWarningFormActions.publishWarning>): SagaIterator;
8
10
  export declare function saveWarningSaga({ payload, }: ReturnType<typeof publicWarningFormActions.saveWarning>): SagaIterator;
9
11
  export declare function successSaga({ payload, }: ReturnType<typeof publicWarningFormActions.publishWarningSuccess | typeof publicWarningFormActions.saveWarningSuccess>): SagaIterator;
@@ -16,6 +16,11 @@ export declare const getPublicWarningStatus: ((state: WarningModuleStore) => imp
16
16
  }> & {
17
17
  clearCache: () => void;
18
18
  };
19
+ export declare const getPublicWarningEditor: ((state: WarningModuleStore) => string | undefined) & import("reselect").OutputSelectorFields<(args_0: PublicWarningFormState) => string | undefined, {
20
+ clearCache: () => void;
21
+ }> & {
22
+ clearCache: () => void;
23
+ };
19
24
  export declare const getPublicWarningFormState: ((state: WarningModuleStore) => "" | "saving" | "publishing" | "readonly") & import("reselect").OutputSelectorFields<(args_0: PublicWarningFormState) => "" | "saving" | "publishing" | "readonly", {
20
25
  clearCache: () => void;
21
26
  }> & {
@@ -15,7 +15,7 @@ export type PublicWarningDetail = {
15
15
  };
16
16
  export type PublicWarningStatus = 'DRAFT' | 'PUBLISHED' | 'TODO' | 'EXPIRED';
17
17
  export type PublicWarning = {
18
- status: PublicWarningStatus;
18
+ status?: PublicWarningStatus;
19
19
  editor?: string;
20
20
  warningDetail: PublicWarningDetail;
21
21
  id?: string;
@@ -8,6 +8,7 @@ export declare const publicWarningActions: import("@reduxjs/toolkit").CaseReduce
8
8
  fetchWarnings: (draft: Draft<PublicWarningsState>) => void;
9
9
  fetchWarningsSuccess: (draft: Draft<PublicWarningsState>, action: PayloadAction<{
10
10
  warnings: PublicWarning[];
11
+ lastUpdatedTime: string;
11
12
  }>) => void;
12
13
  fetchWarningsError: (draft: Draft<PublicWarningsState>, action: PayloadAction<{
13
14
  error: {
@@ -1,4 +1,5 @@
1
1
  import { SagaIterator } from 'redux-saga';
2
+ export declare const getLastUpdatedTimeFormatted: () => string;
2
3
  export declare function fetchWarningsSaga(): SagaIterator;
3
4
  export declare function refetchWarnings(): SagaIterator;
4
5
  declare function publicWarnings(): SagaIterator;
@@ -12,3 +12,8 @@ export declare const getPublicWarningsError: ((state: WarningModuleStore) => imp
12
12
  }> & {
13
13
  clearCache: () => void;
14
14
  };
15
+ export declare const getPublicWarningsLastUpdatedTime: ((state: WarningModuleStore) => string) & import("reselect").OutputSelectorFields<(args_0: PublicWarningsState) => string, {
16
+ clearCache: () => void;
17
+ }> & {
18
+ clearCache: () => void;
19
+ };
@@ -7,5 +7,6 @@ export type PublicWarningError = {
7
7
  export type PublicWarningsState = {
8
8
  warnings: EntityState<PublicWarning>;
9
9
  isLoading: boolean;
10
+ lastUpdatedTime: string;
10
11
  error?: PublicWarningError;
11
12
  };
@@ -2,3 +2,4 @@ export declare const DATE_FORMAT = "dd/MM/yyyy HH:mm";
2
2
  export declare const DATE_FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
3
3
  export declare const DATE_FORMAT_HEADER = "EEEE, MMMM dd";
4
4
  export declare const DATE_FORMAT_DATE_FIELDS = "DD/MM/YYYY HH:mm";
5
+ export declare const DATE_FORMAT_LASTUPDATEDTIME = "HH:mm";