@opengeoweb/warnings 9.4.1 → 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, 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;
@@ -1639,7 +1659,7 @@ var ObjectManagerConnect = function ObjectManagerConnect(_ref) {
1639
1659
  openDrawDialog = _useObjectDrawDialogA.openDrawDialog;
1640
1660
  var geoJSONLayerId = getSingularDrawtoolDrawLayerId(mapId);
1641
1661
  var currentLayer = useSelector(function (store) {
1642
- return layerSelectors.getLayerById(store, geoJSONLayerId);
1662
+ return layerSelectors.getLayerByIdWithoutTimeDimension(store, geoJSONLayerId);
1643
1663
  });
1644
1664
  var currrentDrawing = useSelector(function (store) {
1645
1665
  return selectDrawByInstanceId(store, drawingDialogType);
@@ -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
  };
@@ -4538,6 +4557,18 @@ var DrawingToolConnect = function DrawingToolConnect(_ref) {
4538
4557
  }, /*#__PURE__*/React.createElement(DrawingToolFormConnect, null));
4539
4558
  };
4540
4559
 
4560
+ var WarningAvatar = function WarningAvatar(_ref) {
4561
+ var editor = _ref.editor,
4562
+ _ref$tooltipPlacement = _ref.tooltipPlacement,
4563
+ tooltipPlacement = _ref$tooltipPlacement === void 0 ? 'bottom' : _ref$tooltipPlacement;
4564
+ return /*#__PURE__*/React.createElement(CustomTooltip, {
4565
+ title: "Editor: ".concat(editor),
4566
+ placement: tooltipPlacement
4567
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Avatar, {
4568
+ size: "small"
4569
+ }, getInitials(editor))));
4570
+ };
4571
+
4541
4572
  var DEFAULT_WARNING_DIALOG_SIZE = {
4542
4573
  width: 320,
4543
4574
  height: 800
@@ -4579,7 +4610,8 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
4579
4610
  _ref$onChangeFormMode = _ref.onChangeFormMode,
4580
4611
  onChangeFormMode = _ref$onChangeFormMode === void 0 ? function () {} : _ref$onChangeFormMode,
4581
4612
  _ref$shouldHideFormMo = _ref.shouldHideFormMode,
4582
- shouldHideFormMode = _ref$shouldHideFormMo === void 0 ? false : _ref$shouldHideFormMo;
4613
+ shouldHideFormMode = _ref$shouldHideFormMo === void 0 ? false : _ref$shouldHideFormMo,
4614
+ publicWarningEditor = _ref.publicWarningEditor;
4583
4615
  var minSize = DEFAULT_WARNING_DIALOG_MIN_SIZE;
4584
4616
  var startSizeCalc = calculateStartSize(minSize, size, startPosition);
4585
4617
  var _React$useState = React.useState(startSizeCalc),
@@ -4633,7 +4665,8 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
4633
4665
  right: 32,
4634
4666
  backgroundColor: 'geowebColors.background.surface',
4635
4667
  height: 24,
4636
- paddingLeft: 1
4668
+ paddingLeft: 1,
4669
+ paddingRight: 0.5
4637
4670
  }
4638
4671
  }, /*#__PURE__*/React.createElement(Box, {
4639
4672
  sx: {
@@ -4643,7 +4676,16 @@ var PublicWarningsFormDialog = function PublicWarningsFormDialog(_ref) {
4643
4676
  }, /*#__PURE__*/React.createElement(SwitchButton, {
4644
4677
  checked: !isReadOnly,
4645
4678
  onChange: onChangeMode
4646
- }))))
4679
+ })), /*#__PURE__*/React.createElement(Box, {
4680
+ sx: {
4681
+ position: 'relative',
4682
+ top: 3,
4683
+ right: '-2px',
4684
+ width: '16px'
4685
+ }
4686
+ }, publicWarningEditor && ( /*#__PURE__*/React.createElement(WarningAvatar, {
4687
+ editor: publicWarningEditor
4688
+ })))))
4647
4689
  }, {
4648
4690
  sx: {
4649
4691
  footer: {
@@ -5353,6 +5395,8 @@ var Form = function Form(_ref5) {
5353
5395
  publicWarningDetails = _ref5.publicWarningDetails,
5354
5396
  _ref5$error = _ref5.error,
5355
5397
  error = _ref5$error === void 0 ? '' : _ref5$error,
5398
+ _ref5$isReadOnly = _ref5.isReadOnly,
5399
+ isReadOnly = _ref5$isReadOnly === void 0 ? false : _ref5$isReadOnly,
5356
5400
  _ref5$onFormDirty = _ref5.onFormDirty,
5357
5401
  onFormDirty = _ref5$onFormDirty === void 0 ? function () {} : _ref5$onFormDirty;
5358
5402
  var _useFormContext = useFormContext(),
@@ -5364,7 +5408,6 @@ var Form = function Form(_ref5) {
5364
5408
  DraftFieldHelper = _useDraftFormHelpers.DraftFieldHelper;
5365
5409
  var isPublishing = formAction === 'publishing';
5366
5410
  var isSaving = formAction === 'saving';
5367
- var isReadOnly = formAction === 'readonly';
5368
5411
  var areFieldsDisabled = isPublishing || isSaving;
5369
5412
  useFormDirty({
5370
5413
  isDirty: isDirty,
@@ -5621,6 +5664,10 @@ var getPublicWarningStatus = createSelector(getPublicWarningStore, function (pub
5621
5664
  var _a;
5622
5665
  return (_a = publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.publicWarning) === null || _a === void 0 ? void 0 : _a.status;
5623
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
+ });
5624
5671
  var getPublicWarningFormState = createSelector(getPublicWarningStore, function (publicWarningStore) {
5625
5672
  return (publicWarningStore === null || publicWarningStore === void 0 ? void 0 : publicWarningStore.formState) || '';
5626
5673
  });
@@ -5663,6 +5710,12 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect() {
5663
5710
  var publicWarningFormError = useSelector(function (store) {
5664
5711
  return getPublicWarningFormError(store);
5665
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;
5666
5719
  var dispatch = useDispatch();
5667
5720
  var publishForm = function publishForm(newFormValues) {
5668
5721
  dispatch(publicWarningFormActions.publishWarning({
@@ -5676,7 +5729,8 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect() {
5676
5729
  dispatch(publicWarningFormActions.saveWarning({
5677
5730
  publicWarning: {
5678
5731
  warningDetail: newFormValues,
5679
- status: 'DRAFT'
5732
+ status: 'DRAFT',
5733
+ editor: auth === null || auth === void 0 ? void 0 : auth.username
5680
5734
  }
5681
5735
  }));
5682
5736
  };
@@ -5685,12 +5739,15 @@ var PublicWarningsFormConnect = function PublicWarningsFormConnect() {
5685
5739
  isFormDirty: isFormDirty
5686
5740
  }));
5687
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;
5688
5744
  return /*#__PURE__*/React.createElement(PublicWarningsForm, {
5689
5745
  object: publicWarningObject,
5690
5746
  publicWarningDetails: publicWarning === null || publicWarning === void 0 ? void 0 : publicWarning.warningDetail,
5691
5747
  onPublishForm: publishForm,
5692
5748
  onSaveForm: saveForm,
5693
5749
  formAction: publicWarningFormAction,
5750
+ isReadOnly: isReadOnly,
5694
5751
  error: publicWarningFormError,
5695
5752
  onFormDirty: onFormDirty
5696
5753
  });
@@ -5703,11 +5760,15 @@ var warningFormConfirmationOptions = {
5703
5760
  confirmLabel: 'Close',
5704
5761
  catchOnCancel: true
5705
5762
  };
5763
+ var isAlreadyEdited = function isAlreadyEdited(publicWarningEditor, username) {
5764
+ return publicWarningEditor !== undefined && publicWarningEditor !== '' && publicWarningEditor !== null && publicWarningEditor !== username;
5765
+ };
5706
5766
  var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_ref) {
5707
5767
  var bounds = _ref.bounds,
5708
5768
  _ref$source = _ref.source,
5709
5769
  source = _ref$source === void 0 ? 'app' : _ref$source,
5710
5770
  startPosition = _ref.startPosition;
5771
+ var warningsApi = getWarningsApi();
5711
5772
  var _useSetupDialog = useSetupDialog(publicWarningDialogType, source),
5712
5773
  dialogOrder = _useSetupDialog.dialogOrder,
5713
5774
  setDialogOrder = _useSetupDialog.setDialogOrder,
@@ -5717,11 +5778,6 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
5717
5778
  uiIsLoading = _useSetupDialog.uiIsLoading;
5718
5779
  var dispatch = useDispatch();
5719
5780
  var confirmDialog = useConfirmationDialog();
5720
- var onChangeFormMode = function onChangeFormMode(isChecked) {
5721
- dispatch(publicWarningFormActions.setFormValues({
5722
- formState: !isChecked ? '' : 'readonly'
5723
- }));
5724
- };
5725
5781
  var formAction = useSelector(function (store) {
5726
5782
  return getPublicWarningFormState(store);
5727
5783
  });
@@ -5731,43 +5787,157 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
5731
5787
  var publicWarningStatus = useSelector(function (store) {
5732
5788
  return getPublicWarningStatus(store);
5733
5789
  });
5734
- 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() {
5735
5800
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
5736
- var mayProceed;
5801
+ var latestWarnings, latestWarning;
5737
5802
  return _regeneratorRuntime().wrap(function _callee$(_context) {
5738
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) {
5739
5907
  case 0:
5740
5908
  if (!isFormDirty) {
5741
- _context.next = 6;
5909
+ _context4.next = 6;
5742
5910
  break;
5743
5911
  }
5744
- _context.next = 3;
5912
+ _context4.next = 3;
5745
5913
  return confirmDialog(warningFormConfirmationOptions).then(function () {
5746
5914
  return true;
5747
5915
  })["catch"](function () {
5748
5916
  return false;
5749
5917
  });
5750
5918
  case 3:
5751
- mayProceed = _context.sent;
5919
+ mayProceed = _context4.sent;
5752
5920
  if (mayProceed) {
5753
- _context.next = 6;
5921
+ _context4.next = 6;
5754
5922
  break;
5755
5923
  }
5756
- return _context.abrupt("return");
5924
+ return _context4.abrupt("return");
5757
5925
  case 6:
5758
5926
  onCloseDialog();
5759
5927
  case 7:
5760
5928
  case "end":
5761
- return _context.stop();
5929
+ return _context4.stop();
5762
5930
  }
5763
- }, _callee);
5931
+ }, _callee4);
5764
5932
  }));
5765
5933
  };
5766
5934
  if (!isDialogOpen) {
5767
5935
  return null;
5768
5936
  }
5769
- var isReadOnly = formAction === 'readonly';
5770
- 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';
5771
5941
  return /*#__PURE__*/React__default.createElement(PublicWarningsFormDialog, {
5772
5942
  isOpen: isDialogOpen,
5773
5943
  onClose: closeDialog,
@@ -5779,7 +5949,8 @@ var PublicWarningsFormDialogConnect = function PublicWarningsFormDialogConnect(_
5779
5949
  isLoading: uiIsLoading,
5780
5950
  isReadOnly: isReadOnly,
5781
5951
  onChangeFormMode: onChangeFormMode,
5782
- shouldHideFormMode: shouldHideFormToggleMode
5952
+ shouldHideFormMode: shouldHideFormToggleMode,
5953
+ publicWarningEditor: publicWarningEditor
5783
5954
  }, /*#__PURE__*/React__default.createElement(PublicWarningsFormConnect, null));
5784
5955
  };
5785
5956
 
@@ -6011,9 +6182,22 @@ var WarningsOnStatus = function WarningsOnStatus(_ref) {
6011
6182
  }
6012
6183
  }, ((_a = warning.warningDetail) === null || _a === void 0 ? void 0 : _a.level) && (levelDetails === null || levelDetails === void 0 ? void 0 : levelDetails.title) || '-')), /*#__PURE__*/React__default.createElement(WarningListColumnContent, {
6013
6184
  status: status
6014
- }, status === 'DRAFT' ? ( /*#__PURE__*/React__default.createElement(Button, {
6185
+ }, status === 'DRAFT' ? ( /*#__PURE__*/React__default.createElement(Box, {
6186
+ sx: {
6187
+ position: 'relative'
6188
+ }
6189
+ }, warning.editor && ( /*#__PURE__*/React__default.createElement(Box, {
6015
6190
  sx: {
6016
- height: '30px',
6191
+ width: '16px',
6192
+ position: 'absolute',
6193
+ top: '1px',
6194
+ right: '-25px'
6195
+ }
6196
+ }, /*#__PURE__*/React__default.createElement(WarningAvatar, {
6197
+ editor: warning.editor
6198
+ }))), /*#__PURE__*/React__default.createElement(Button, {
6199
+ sx: {
6200
+ height: '20px',
6017
6201
  padding: '0px',
6018
6202
  '& .MuiSvgIcon-root': {
6019
6203
  marginRight: '-2px'
@@ -6021,7 +6205,7 @@ var WarningsOnStatus = function WarningsOnStatus(_ref) {
6021
6205
  },
6022
6206
  variant: "flat",
6023
6207
  startIcon: /*#__PURE__*/React__default.createElement(Edit, null)
6024
- }, "DRAFT")) : ( /*#__PURE__*/React__default.createElement(StatusTag, {
6208
+ }, "DRAFT"))) : ( /*#__PURE__*/React__default.createElement(StatusTag, {
6025
6209
  content: status.toLowerCase(),
6026
6210
  color: status === 'EXPIRED' ? 'grey' : 'green',
6027
6211
  sx: {
@@ -6035,6 +6219,9 @@ var PublicWarningList = function PublicWarningList(_ref2) {
6035
6219
  _ref2$isLoading = _ref2.isLoading,
6036
6220
  isLoading = _ref2$isLoading === void 0 ? false : _ref2$isLoading,
6037
6221
  error = _ref2.error,
6222
+ _ref2$selectedPublicW = _ref2.selectedPublicWarningId,
6223
+ selectedPublicWarningId = _ref2$selectedPublicW === void 0 ? '' : _ref2$selectedPublicW,
6224
+ lastUpdatedTime = _ref2.lastUpdatedTime,
6038
6225
  _ref2$onSelectWarning = _ref2.onSelectWarning,
6039
6226
  onSelectWarning = _ref2$onSelectWarning === void 0 ? function () {} : _ref2$onSelectWarning,
6040
6227
  _ref2$onEditWarning = _ref2.onEditWarning,
@@ -6043,8 +6230,8 @@ var PublicWarningList = function PublicWarningList(_ref2) {
6043
6230
  onCreateWarning = _ref2$onCreateWarning === void 0 ? function () {} : _ref2$onCreateWarning,
6044
6231
  _ref2$onDeleteWarning = _ref2.onDeleteWarning,
6045
6232
  onDeleteWarning = _ref2$onDeleteWarning === void 0 ? function () {} : _ref2$onDeleteWarning,
6046
- _ref2$selectedPublicW = _ref2.selectedPublicWarningId,
6047
- selectedPublicWarningId = _ref2$selectedPublicW === void 0 ? '' : _ref2$selectedPublicW;
6233
+ _ref2$onRefetchWarnin = _ref2.onRefetchWarnings,
6234
+ onRefetchWarnings = _ref2$onRefetchWarnin === void 0 ? function () {} : _ref2$onRefetchWarnin;
6048
6235
  var sortedWarnings = warnings ? sortWarningsOnStatus(warnings) : null;
6049
6236
  return /*#__PURE__*/React__default.createElement(Box, {
6050
6237
  sx: {
@@ -6071,7 +6258,17 @@ var PublicWarningList = function PublicWarningList(_ref2) {
6071
6258
  }), isLoading && ( /*#__PURE__*/React__default.createElement(LinearProgress, {
6072
6259
  "data-testid": "loading-bar",
6073
6260
  color: "secondary"
6074
- })), 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, {
6075
6272
  status: "TODO",
6076
6273
  warnings: sortedWarnings.todo,
6077
6274
  onSelectWarning: onSelectWarning,
@@ -6125,7 +6322,8 @@ var publicWarningsAdapter = createEntityAdapter({
6125
6322
  });
6126
6323
  var initialState = {
6127
6324
  warnings: publicWarningsAdapter.getInitialState(),
6128
- isLoading: true
6325
+ isLoading: true,
6326
+ lastUpdatedTime: ''
6129
6327
  };
6130
6328
  var slice = createSlice({
6131
6329
  initialState: initialState,
@@ -6136,8 +6334,11 @@ var slice = createSlice({
6136
6334
  delete draft.error;
6137
6335
  },
6138
6336
  fetchWarningsSuccess: function fetchWarningsSuccess(draft, action) {
6139
- var warnings = action.payload.warnings;
6337
+ var _action$payload = action.payload,
6338
+ warnings = _action$payload.warnings,
6339
+ lastUpdatedTime = _action$payload.lastUpdatedTime;
6140
6340
  draft.isLoading = false;
6341
+ draft.lastUpdatedTime = lastUpdatedTime;
6141
6342
  publicWarningsAdapter.setAll(draft.warnings, warnings);
6142
6343
  },
6143
6344
  fetchWarningsError: function fetchWarningsError(draft, action) {
@@ -6186,6 +6387,9 @@ var isPublicWarningsLoading = createSelector(getPublicWarningsStore, function (s
6186
6387
  var getPublicWarningsError = createSelector(getPublicWarningsStore, function (store) {
6187
6388
  return store === null || store === void 0 ? void 0 : store.error;
6188
6389
  });
6390
+ var getPublicWarningsLastUpdatedTime = createSelector(getPublicWarningsStore, function (store) {
6391
+ return store === null || store === void 0 ? void 0 : store.lastUpdatedTime;
6392
+ });
6189
6393
 
6190
6394
  var DELETE_TITLE = 'Delete warning';
6191
6395
  var DELETE_CONFIRM = 'Delete';
@@ -6286,6 +6490,9 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
6286
6490
  var isFormDirty = useSelector(function (store) {
6287
6491
  return getSelectedPublicIsFormDirty(store);
6288
6492
  });
6493
+ var lastUpdatedTime = useSelector(function (store) {
6494
+ return getPublicWarningsLastUpdatedTime(store);
6495
+ });
6289
6496
  var openPublicWarningDialog = function openPublicWarningDialog(formAction, publicWarning) {
6290
6497
  return __awaiter(void 0, void 0, void 0, /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6291
6498
  var mayProceed;
@@ -6350,12 +6557,15 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
6350
6557
  }));
6351
6558
  }
6352
6559
  openSnackbar(DELETE_WARNING_SUCCESS_MESSAGE);
6353
- dispatch(publicWarningActions.fetchWarnings());
6560
+ fetchWarnings();
6354
6561
  };
6355
- React__default.useEffect(function () {
6356
- // fetch warnings on mount
6562
+ var fetchWarnings = React__default.useCallback(function () {
6357
6563
  dispatch(publicWarningActions.fetchWarnings());
6358
6564
  }, [dispatch]);
6565
+ React__default.useEffect(function () {
6566
+ // fetch warnings on mount
6567
+ fetchWarnings();
6568
+ }, [fetchWarnings]);
6359
6569
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(PublicWarningList, {
6360
6570
  warnings: warnings,
6361
6571
  isLoading: isLoading,
@@ -6364,7 +6574,9 @@ var PublicWarningListConnect = function PublicWarningListConnect() {
6364
6574
  onCreateWarning: createWarning,
6365
6575
  onEditWarning: editWarning,
6366
6576
  onDeleteWarning: deleteWarning,
6367
- selectedPublicWarningId: selectedPublicWarningId
6577
+ selectedPublicWarningId: selectedPublicWarningId,
6578
+ lastUpdatedTime: lastUpdatedTime,
6579
+ onRefetchWarnings: fetchWarnings
6368
6580
  }), confirmDeleteWarning && ( /*#__PURE__*/React__default.createElement(ConfirmDeleteWarningDialog, {
6369
6581
  warningId: confirmDeleteWarning,
6370
6582
  onDeleteSucces: onDeleteSuccess,
@@ -6570,43 +6782,53 @@ function saveOrUpdateWarning(publicWarning) {
6570
6782
  }
6571
6783
  }, _marked$1);
6572
6784
  }
6573
- 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) {
6574
6789
  var payload = _ref.payload;
6575
6790
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
6576
- var publicWarning, publishedWarning;
6791
+ var warningId, isEditor, username, warningsApi;
6577
6792
  return _regeneratorRuntime().wrap(function _callee$(_context2) {
6578
6793
  while (1) switch (_context2.prev = _context2.next) {
6579
6794
  case 0:
6580
6795
  _context2.prev = 0;
6581
- publicWarning = payload.publicWarning;
6796
+ warningId = payload.warningId, isEditor = payload.isEditor, username = payload.username;
6582
6797
  _context2.next = 4;
6583
- return call(saveOrUpdateWarning, publicWarning);
6798
+ return call(getWarningsApi);
6584
6799
  case 4:
6585
- publishedWarning = _context2.sent;
6800
+ warningsApi = _context2.sent;
6586
6801
  _context2.next = 7;
6587
- return put(publicWarningFormActions.publishWarningSuccess({
6588
- publicWarning: publishedWarning,
6589
- message: PUBLISH_SUCCES
6590
- }));
6802
+ return call(warningsApi.toggleEditorWarning, warningId, isEditor);
6591
6803
  case 7:
6592
- _context2.next = 13;
6593
- break;
6804
+ _context2.next = 9;
6805
+ return put(publicWarningActions.fetchWarnings);
6594
6806
  case 9:
6595
- _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;
6596
6818
  _context2.t0 = _context2["catch"](0);
6597
- _context2.next = 13;
6819
+ _context2.next = 17;
6598
6820
  return call(errorSaga, getErrorMessage(_context2.t0));
6599
- case 13:
6821
+ case 17:
6600
6822
  case "end":
6601
6823
  return _context2.stop();
6602
6824
  }
6603
- }, _callee, null, [[0, 9]]);
6825
+ }, _callee, null, [[0, 13]]);
6604
6826
  })();
6605
6827
  }
6606
- function saveWarningSaga(_ref2) {
6828
+ function publishWarningSaga(_ref2) {
6607
6829
  var payload = _ref2.payload;
6608
6830
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
6609
- var publicWarning, savedWarning;
6831
+ var publicWarning, publishedWarning;
6610
6832
  return _regeneratorRuntime().wrap(function _callee2$(_context3) {
6611
6833
  while (1) switch (_context3.prev = _context3.next) {
6612
6834
  case 0:
@@ -6615,11 +6837,11 @@ function saveWarningSaga(_ref2) {
6615
6837
  _context3.next = 4;
6616
6838
  return call(saveOrUpdateWarning, publicWarning);
6617
6839
  case 4:
6618
- savedWarning = _context3.sent;
6840
+ publishedWarning = _context3.sent;
6619
6841
  _context3.next = 7;
6620
- return put(publicWarningFormActions.saveWarningSuccess({
6621
- publicWarning: savedWarning,
6622
- message: SAVE_SUCCES
6842
+ return put(publicWarningFormActions.publishWarningSuccess({
6843
+ publicWarning: publishedWarning,
6844
+ message: PUBLISH_SUCCES
6623
6845
  }));
6624
6846
  case 7:
6625
6847
  _context3.next = 13;
@@ -6636,105 +6858,141 @@ function saveWarningSaga(_ref2) {
6636
6858
  }, _callee2, null, [[0, 9]]);
6637
6859
  })();
6638
6860
  }
6639
- function successSaga(_ref3) {
6861
+ function saveWarningSaga(_ref3) {
6640
6862
  var payload = _ref3.payload;
6641
6863
  return /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
6642
- var message;
6864
+ var publicWarning, savedWarning;
6643
6865
  return _regeneratorRuntime().wrap(function _callee3$(_context4) {
6644
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) {
6645
6900
  case 0:
6646
6901
  message = payload.message;
6647
- _context4.next = 3;
6902
+ _context5.next = 3;
6648
6903
  return put(snackbarActions.openSnackbar({
6649
6904
  message: message
6650
6905
  }));
6651
6906
  case 3:
6652
- _context4.next = 5;
6907
+ _context5.next = 5;
6653
6908
  return call(toggleDialogLoadingSaga, false);
6654
6909
  case 5:
6655
6910
  case "end":
6656
- return _context4.stop();
6911
+ return _context5.stop();
6657
6912
  }
6658
- }, _callee3);
6913
+ }, _callee4);
6659
6914
  })();
6660
6915
  }
6661
6916
  function errorSaga(message) {
6662
- return _regeneratorRuntime().wrap(function errorSaga$(_context5) {
6663
- while (1) switch (_context5.prev = _context5.next) {
6917
+ return _regeneratorRuntime().wrap(function errorSaga$(_context6) {
6918
+ while (1) switch (_context6.prev = _context6.next) {
6664
6919
  case 0:
6665
- _context5.next = 2;
6920
+ _context6.next = 2;
6666
6921
  return put(publicWarningFormActions.setFormError({
6667
6922
  error: message
6668
6923
  }));
6669
6924
  case 2:
6670
- _context5.next = 4;
6925
+ _context6.next = 4;
6671
6926
  return call(toggleDialogLoadingSaga, false);
6672
6927
  case 4:
6673
6928
  case "end":
6674
- return _context5.stop();
6929
+ return _context6.stop();
6675
6930
  }
6676
6931
  }, _marked2$1);
6677
6932
  }
6678
6933
  function toggleDialogLoadingSaga(isLoading) {
6679
6934
  var isDialogOpen;
6680
- return _regeneratorRuntime().wrap(function toggleDialogLoadingSaga$(_context6) {
6681
- while (1) switch (_context6.prev = _context6.next) {
6935
+ return _regeneratorRuntime().wrap(function toggleDialogLoadingSaga$(_context7) {
6936
+ while (1) switch (_context7.prev = _context7.next) {
6682
6937
  case 0:
6683
- _context6.next = 2;
6938
+ _context7.next = 2;
6684
6939
  return select(uiSelectors.getDialogDetailsByType, publicWarningDialogType);
6685
6940
  case 2:
6686
- isDialogOpen = _context6.sent;
6941
+ isDialogOpen = _context7.sent;
6687
6942
  if (!isDialogOpen) {
6688
- _context6.next = 6;
6943
+ _context7.next = 6;
6689
6944
  break;
6690
6945
  }
6691
- _context6.next = 6;
6946
+ _context7.next = 6;
6692
6947
  return put(uiActions.toggleIsLoadingDialog({
6693
6948
  isLoading: isLoading,
6694
6949
  type: publicWarningDialogType
6695
6950
  }));
6696
6951
  case 6:
6697
6952
  case "end":
6698
- return _context6.stop();
6953
+ return _context7.stop();
6699
6954
  }
6700
6955
  }, _marked3$1);
6701
6956
  }
6702
6957
  function openDialogSaga() {
6703
- return _regeneratorRuntime().wrap(function openDialogSaga$(_context7) {
6704
- while (1) switch (_context7.prev = _context7.next) {
6958
+ return _regeneratorRuntime().wrap(function openDialogSaga$(_context8) {
6959
+ while (1) switch (_context8.prev = _context8.next) {
6705
6960
  case 0:
6706
- _context7.next = 2;
6961
+ _context8.next = 2;
6707
6962
  return put(uiActions.setToggleOpenDialog({
6708
6963
  setOpen: true,
6709
6964
  type: publicWarningDialogType
6710
6965
  }));
6711
6966
  case 2:
6712
6967
  case "end":
6713
- return _context7.stop();
6968
+ return _context8.stop();
6714
6969
  }
6715
6970
  }, _marked4);
6716
6971
  }
6717
6972
  function publicWarningRootSaga() {
6718
- return _regeneratorRuntime().wrap(function publicWarningRootSaga$(_context8) {
6719
- while (1) switch (_context8.prev = _context8.next) {
6973
+ return _regeneratorRuntime().wrap(function publicWarningRootSaga$(_context9) {
6974
+ while (1) switch (_context9.prev = _context9.next) {
6720
6975
  case 0:
6721
- _context8.next = 2;
6722
- return takeLatest(publicWarningFormActions.publishWarning, publishWarningSaga);
6976
+ _context9.next = 2;
6977
+ return takeLatest(publicWarningFormActions.toggleEditorWarning, toggleEditorWarningSaga);
6723
6978
  case 2:
6724
- _context8.next = 4;
6725
- return takeLatest(publicWarningFormActions.saveWarning, saveWarningSaga);
6979
+ _context9.next = 4;
6980
+ return takeLatest(publicWarningFormActions.publishWarning, publishWarningSaga);
6726
6981
  case 4:
6727
- _context8.next = 6;
6728
- return takeLatest([publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess], successSaga);
6982
+ _context9.next = 6;
6983
+ return takeLatest(publicWarningFormActions.saveWarning, saveWarningSaga);
6729
6984
  case 6:
6730
- _context8.next = 8;
6731
- return takeLatest([publicWarningFormActions.publishWarning, publicWarningFormActions.saveWarning], toggleDialogLoadingSaga, true);
6985
+ _context9.next = 8;
6986
+ return takeLatest([publicWarningFormActions.publishWarningSuccess, publicWarningFormActions.saveWarningSuccess, publicWarningFormActions.toggleEditorWarningSuccess], successSaga);
6732
6987
  case 8:
6733
- _context8.next = 10;
6734
- return takeLatest(publicWarningFormActions.openPublicWarningFormDialog, openDialogSaga);
6988
+ _context9.next = 10;
6989
+ return takeLatest([publicWarningFormActions.publishWarning, publicWarningFormActions.saveWarning], toggleDialogLoadingSaga, true);
6735
6990
  case 10:
6991
+ _context9.next = 12;
6992
+ return takeLatest(publicWarningFormActions.openPublicWarningFormDialog, openDialogSaga);
6993
+ case 12:
6736
6994
  case "end":
6737
- return _context8.stop();
6995
+ return _context9.stop();
6738
6996
  }
6739
6997
  }, _marked5);
6740
6998
  }
@@ -6742,8 +7000,11 @@ function publicWarningRootSaga() {
6742
7000
  var _marked = /*#__PURE__*/_regeneratorRuntime().mark(fetchWarningsSaga),
6743
7001
  _marked2 = /*#__PURE__*/_regeneratorRuntime().mark(refetchWarnings),
6744
7002
  _marked3 = /*#__PURE__*/_regeneratorRuntime().mark(publicWarnings);
7003
+ var getLastUpdatedTimeFormatted = function getLastUpdatedTimeFormatted() {
7004
+ return dateUtils.dateToString(dateUtils.utc(), DATE_FORMAT_LASTUPDATEDTIME);
7005
+ };
6745
7006
  function fetchWarningsSaga() {
6746
- var warningsApi, _yield$call, warnings;
7007
+ var warningsApi, _yield$call, warnings, lastUpdatedTime;
6747
7008
  return _regeneratorRuntime().wrap(function fetchWarningsSaga$(_context) {
6748
7009
  while (1) switch (_context.prev = _context.next) {
6749
7010
  case 0:
@@ -6757,28 +7018,30 @@ function fetchWarningsSaga() {
6757
7018
  case 6:
6758
7019
  _yield$call = _context.sent;
6759
7020
  warnings = _yield$call.data;
6760
- _context.next = 10;
7021
+ lastUpdatedTime = getLastUpdatedTimeFormatted();
7022
+ _context.next = 11;
6761
7023
  return put(publicWarningActions.fetchWarningsSuccess({
6762
- warnings: warnings
7024
+ warnings: warnings,
7025
+ lastUpdatedTime: lastUpdatedTime
6763
7026
  }));
6764
- case 10:
6765
- _context.next = 16;
7027
+ case 11:
7028
+ _context.next = 17;
6766
7029
  break;
6767
- case 12:
6768
- _context.prev = 12;
7030
+ case 13:
7031
+ _context.prev = 13;
6769
7032
  _context.t0 = _context["catch"](0);
6770
- _context.next = 16;
7033
+ _context.next = 17;
6771
7034
  return put(publicWarningActions.fetchWarningsError({
6772
7035
  error: {
6773
7036
  name: _context.t0.name,
6774
7037
  message: _context.t0.message
6775
7038
  }
6776
7039
  }));
6777
- case 16:
7040
+ case 17:
6778
7041
  case "end":
6779
7042
  return _context.stop();
6780
7043
  }
6781
- }, _marked, null, [[0, 12]]);
7044
+ }, _marked, null, [[0, 13]]);
6782
7045
  }
6783
7046
  function refetchWarnings() {
6784
7047
  return _regeneratorRuntime().wrap(function refetchWarnings$(_context2) {
@@ -6834,4 +7097,4 @@ var drawingModuleConfig = {
6834
7097
  sagas: [drawingSaga, publicWarningRootSaga, publicWarnings]
6835
7098
  };
6836
7099
 
6837
- 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.4.1",
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>;
@@ -19,4 +19,5 @@ export declare const PublicWarningsFormDialog: React.FC<{
19
19
  isReadOnly?: boolean;
20
20
  onChangeFormMode?: (isReadOnly: boolean) => void;
21
21
  shouldHideFormMode?: boolean;
22
+ publicWarningEditor?: string;
22
23
  }>;
@@ -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;
@@ -0,0 +1,8 @@
1
+ import { TooltipProps } from '@mui/material';
2
+ import * as React from 'react';
3
+ interface WarningAvatarProps {
4
+ editor: string;
5
+ tooltipPlacement?: TooltipProps['placement'];
6
+ }
7
+ declare const WarningAvatar: React.FC<WarningAvatarProps>;
8
+ export default WarningAvatar;
@@ -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";